This repository was archived by the owner on Jan 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlua-visual-debug-keys.lua
More file actions
97 lines (91 loc) · 2.97 KB
/
lua-visual-debug-keys.lua
File metadata and controls
97 lines (91 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
local lvd = require('lua-visual-debug')
local params = lvd.params
local keyval = require('luakeyval')
local process_keys = keyval.process
local scan_bool = keyval.bool
local scan_string = token.scan_string
local scan_float = token.scan_float
local inner_keys = {
hlist = {
show = {scanner = scan_bool},
color = {scanner = scan_string},
width = {scanner = scan_float}
},
vlist = {
show = {scanner = scan_bool},
color = {scanner = scan_string},
width = {scanner = scan_float}
},
rule = {
show = {scanner = scan_bool},
color = {scanner = scan_string},
width = {scanner = scan_float}
},
disc = {
show = {scanner = scan_bool},
color = {scanner = scan_string},
width = {scanner = scan_float}
},
glue = {
show = {scanner = scan_bool},
},
kern = {
show = {scanner = scan_bool},
negative_color = {scanner = scan_string},
color = {scanner = scan_string},
width = {scanner = scan_float}
},
penalty = {
show = {scanner = scan_bool},
},
glyph = {
show = {scanner = scan_bool},
color = {scanner = scan_string},
width = {scanner = scan_float},
baseline = {scanner = scan_bool}
},
}
local messages = {
error1 = "lua-visual-debug: Wrong syntax in \\lvdset",
value_forbidden = 'lua-visual-debug: The key "%s" does not accept a value',
value_required = 'lua-visual-debug: The key "%s" requires a value',
}
local function set_params(key)
local vals = process_keys(inner_keys[key],messages)
for k,v in pairs(vals) do
params[key][k] = v
end
end
local function onlyglyphs()
for _,v in pairs(params) do
if v.show then
v.show = false
end
end
params.glyph.show = true
end
local outer_keys = {
hlist = {scanner = function() return true end, func = set_params},
vlist = {scanner = function() return true end, func = set_params},
rule = {scanner = function() return true end, func = set_params},
disc = {scanner = function() return true end, func = set_params},
glue = {scanner = function() return true end, func = set_params},
kern = {scanner = function() return true end, func = set_params},
penalty = {scanner = function() return true end, func = set_params},
glyph = {scanner = function() return true end, func = set_params},
opacity = {scanner = scan_string},
onlyglyphs = {default = true, func = onlyglyphs}
}
do
if token.is_defined('lvdset') then
texio.write_nl('log', "lua-visual-debug: redefining \\lvdset")
end
local function_table = lua.get_functions_table()
local luafnalloc = luatexbase and luatexbase.new_luafunction
and luatexbase.new_luafunction('lvdset') or #function_table + 1
token.set_lua('lvdset', luafnalloc)
function_table[luafnalloc] = function()
local vals = process_keys(outer_keys,messages)
params.opacity = vals.opacity or params.opacity
end
end