summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/trac-vis.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/trac-vis.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/trac-vis.lua68
1 files changed, 33 insertions, 35 deletions
diff --git a/Master/texmf-dist/tex/context/base/trac-vis.lua b/Master/texmf-dist/tex/context/base/trac-vis.lua
index eb5373ee350..86af6da0bdc 100644
--- a/Master/texmf-dist/tex/context/base/trac-vis.lua
+++ b/Master/texmf-dist/tex/context/base/trac-vis.lua
@@ -190,7 +190,7 @@ end
local function enable()
if not usedfont then
- -- we use a narrow monospaced font
+ -- we use a narrow monospaced font -- infofont ?
visualizers.setfont(fonts.definers.define { name = "lmmonoltcond10regular", size = tex.sp("4pt") })
end
for mode, value in next, modes do
@@ -280,13 +280,6 @@ function visualizers.setlayer(n)
texsetattribute(a_layer,layers[n] or unsetvalue)
end
-commands.setvisual = visualizers.setvisual
-commands.setlayer = visualizers.setlayer
-
-function commands.visual(n)
- context(setvisual(n))
-end
-
local function set(mode,v)
texsetattribute(a_visual,setvisual(mode,texgetattribute(a_visual),v))
end
@@ -322,7 +315,7 @@ local c_glyph_d = "trace:do"
local c_white_d = "trace:dw"
local c_math_d = "trace:dr"
-local function sometext(str,layer,color,textcolor) -- we can just paste verbatim together .. no typesteting needed
+local function sometext(str,layer,color,textcolor,lap) -- we can just paste verbatim together .. no typesteting needed
local text = fast_hpack_string(str,usedfont)
local size = getfield(text,"width")
local rule = new_rule(size,2*exheight,exheight/2)
@@ -336,10 +329,13 @@ local function sometext(str,layer,color,textcolor) -- we can just paste verbatim
local info = linked_nodes(rule,kern,text)
setlisttransparency(info,c_zero)
info = fast_hpack(info)
+ local width = getfield(info,"width")
+ if lap then
+ info = fast_hpack(linked_nodes(new_kern(-width),info))
+ end
if layer then
setattr(info,a_layer,layer)
end
- local width = getfield(info,"width")
setfield(info,"width",0)
setfield(info,"height",0)
setfield(info,"depth",0)
@@ -580,7 +576,8 @@ local function ruledglyph(head,current,previous)
setfield(current,"prev",nil)
local linewidth = emwidth/20
local baseline
- if dp ~= 0 and ht ~= 0 then
+ -- if dp ~= 0 and ht ~= 0 then
+ if (dp >= 0 and ht >= 0) or (dp <= 0 and ht <= 0) then
baseline = new_rule(wd-2*linewidth,linewidth,0)
end
local doublelinewidth = 2*linewidth
@@ -740,7 +737,7 @@ local function ruledpenalty(head,current,vertical)
return head, getnext(current)
end
-local function visualize(head,vertical)
+local function visualize(head,vertical,forced)
local trace_hbox = false
local trace_vbox = false
local trace_vtop = false
@@ -760,7 +757,7 @@ local function visualize(head,vertical)
local prev_trace_fontkern = nil
while current do
local id = getid(current)
- local a = getattr(current,a_visual) or unsetvalue
+ local a = forced or getattr(current,a_visual) or unsetvalue
if a ~= attr then
prev_trace_fontkern = trace_fontkern
if a == unsetvalue then
@@ -801,19 +798,17 @@ local function visualize(head,vertical)
head, current = ruledglyph(head,current,previous)
end
elseif id == disc_code then
- if trace_glyph then
- local pre = getfield(current,"pre")
- if pre then
- setfield(current,"pre",ruledglyph(pre,pre))
- end
- local post = getfield(current,"post")
- if post then
- setfield(current,"post",ruledglyph(post,post))
- end
- local replace = getfield(current,"replace")
- if replace then
- setfield(current,"replace",ruledglyph(replace,replace))
- end
+ local pre = getfield(current,"pre")
+ if pre then
+ setfield(current,"pre",visualize(pre,false,a))
+ end
+ local post = getfield(current,"post")
+ if post then
+ setfield(current,"post",visualize(post,false,a))
+ end
+ local replace = getfield(current,"replace")
+ if replace then
+ setfield(current,"replace",visualize(replace,false,a))
end
elseif id == kern_code then
local subtype = getsubtype(current)
@@ -822,7 +817,7 @@ local function visualize(head,vertical)
if trace_fontkern or prev_trace_fontkern then
head, current = fontkern(head,current)
end
- elseif subtype == user_kern_code then
+ else -- if subtype == user_kern_code then
if trace_kern then
head, current = ruledkern(head,current,vertical)
end
@@ -838,10 +833,6 @@ local function visualize(head,vertical)
if trace_penalty then
head, current = ruledpenalty(head,current,vertical)
end
- elseif id == disc_code then
- setfield(current,"pre",visualize(getfield(current,"pre")))
- setfield(current,"post",isualize(getfield(current,"post")))
- setfield(current,"replace",visualize(getfield(current,"replace")))
elseif id == hlist_code then
local content = getlist(current)
if content then
@@ -967,10 +958,6 @@ function visualizers.markfonts(list)
markfonts(type(n) == "number" and getlist(getbox(n)) or n)
end
-function commands.markfonts(n)
- visualizers.markfonts(n)
-end
-
luatex.registerstopactions(cleanup)
statistics.register("visualization time",function()
@@ -979,3 +966,14 @@ statistics.register("visualization time",function()
return format("%s seconds",statistics.elapsedtime(visualizers))
end
end)
+
+-- interface
+
+local implement = interfaces.implement
+
+implement { name = "setvisual", arguments = "string", actions = visualizers.setvisual }
+implement { name = "getvisual", arguments = "string", actions = { setvisual, context } }
+implement { name = "setvisuallayer", arguments = "string", actions = visualizers.setlayer }
+implement { name = "markvisualfonts", arguments = "integer", actions = visualizers.markfonts }
+implement { name = "setvisualfont", arguments = "integer", actions = visualizers.setfont }
+