diff options
Diffstat (limited to 'tex')
27 files changed, 1420 insertions, 52 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index e264dc856..6b7b74e02 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2020.11.23 18:34} +\newcontextversion{2020.11.23 22:37} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index a4eaeaf72..da1378517 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.23 18:34} +\edef\contextversion{2020.11.23 22:37} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-en.mkii b/tex/context/base/mkii/mult-en.mkii index 8b2a78ba0..4c9092f89 100644 --- a/tex/context/base/mkii/mult-en.mkii +++ b/tex/context/base/mkii/mult-en.mkii @@ -774,6 +774,7 @@ \setinterfaceconstant{deepnumbercommand}{deepnumbercommand} \setinterfaceconstant{deeptextcommand}{deeptextcommand} \setinterfaceconstant{default}{default} +\setinterfaceconstant{define}{define} \setinterfaceconstant{delay}{delay} \setinterfaceconstant{depth}{depth} \setinterfaceconstant{depthcorrection}{depthcorrection} @@ -1368,7 +1369,6 @@ \setinterfaceelement{type}{type} % definitions for interface commands for language en % -\setinterfacecommand{CAPPED}{CAP} \setinterfacecommand{Character}{Character} \setinterfacecommand{Characters}{Characters} \setinterfacecommand{MONTH}{MONTH} @@ -2074,7 +2074,7 @@ \setinterfacecommand{startnarrower}{startnarrower} \setinterfacecommand{startopposite}{startopposite} \setinterfacecommand{startoverlay}{startoverlay} -\setinterfacecommand{startoverzicht}{startoverview} +\setinterfacecommand{startoverview}{startoverview} \setinterfacecommand{startpacked}{startpacked} \setinterfacecommand{startpositioning}{startpositioning} \setinterfacecommand{startproduct}{startproduct} @@ -2117,7 +2117,7 @@ \setinterfacecommand{stopnarrower}{stopnarrower} \setinterfacecommand{stopopposite}{stopopposite} \setinterfacecommand{stopoverlay}{stopoverlay} -\setinterfacecommand{stopoverzicht}{stopoverview} +\setinterfacecommand{stopoverview}{stopoverview} \setinterfacecommand{stoppacked}{stoppacked} \setinterfacecommand{stoppositioning}{stoppositioning} \setinterfacecommand{stopproduct}{stopproduct} diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index 0663659e3..997c3f4ab 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -774,6 +774,7 @@ \setinterfaceconstant{deepnumbercommand}{deepnumbercommand} \setinterfaceconstant{deeptextcommand}{deeptextcommand} \setinterfaceconstant{default}{implicit} +\setinterfaceconstant{define}{define} \setinterfaceconstant{delay}{intarziere} \setinterfaceconstant{depth}{inaltime} \setinterfaceconstant{depthcorrection}{corectieadancime} @@ -2073,7 +2074,7 @@ \setinterfacecommand{startnarrower}{startingust} \setinterfacecommand{startopposite}{startopozit} \setinterfacecommand{startoverlay}{startoverlay} -\setinterfacecommand{startoverzicht}{startoverview} +\setinterfacecommand{startoverview}{startoverview} \setinterfacecommand{startpacked}{startimpachetat} \setinterfacecommand{startpositioning}{startpozitionare} \setinterfacecommand{startproduct}{startprodus} @@ -2116,7 +2117,7 @@ \setinterfacecommand{stopnarrower}{stopingust} \setinterfacecommand{stopopposite}{stopopozit} \setinterfacecommand{stopoverlay}{stopoverlay} -\setinterfacecommand{stopoverzicht}{stopoverview} +\setinterfacecommand{stopoverview}{stopoverview} \setinterfacecommand{stoppacked}{stopimpachetat} \setinterfacecommand{stoppositioning}{stoppozitionare} \setinterfacecommand{stopproduct}{stopprodus} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 6ff794299..8a24a93a4 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2020.11.23 18:34} +\newcontextversion{2020.11.23 22:37} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 0e8437dc0..766799ade 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.23 18:34} +\edef\contextversion{2020.11.23 22:37} %D Kind of special: diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex c96cba81a..fa36e1032 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex cbfa899a4..0d1afbfb5 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkxl/chem-str.mkxl b/tex/context/base/mkxl/chem-str.mkxl index 2212ddfcb..3645713c6 100644 --- a/tex/context/base/mkxl/chem-str.mkxl +++ b/tex/context/base/mkxl/chem-str.mkxl @@ -249,7 +249,7 @@ \ifempty\m_bodyfont \switchtobodyfont[\m_bodyfont]% \fi - \getvalue{\??chemicalsize\chemicalparameter\c!size}% + \begincsname\??chemicalsize\chemicalparameter\c!size\endcsname % \to \everystructurechemical \to \everychemical diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index e44f73f9d..85c5ba30d 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2020.11.23 18:34} +\newcontextversion{2020.11.23 22:37} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index ca9c6be40..339c64360 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.23 18:34} +\edef\contextversion{2020.11.23 22:37} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/font-sty.mklx b/tex/context/base/mkxl/font-sty.mklx index 9444232ba..e5fe227e2 100644 --- a/tex/context/base/mkxl/font-sty.mklx +++ b/tex/context/base/mkxl/font-sty.mklx @@ -368,11 +368,11 @@ \permanent\tolerant\protected\def\definestyleinstance[#instance]#*[#2]#*[#3]#*[#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever] {\ifparameter#instance\or \ifarguments\or\or - \letvalueempty{\??stylecollection#instance::#2}% + \letcsname\??stylecollection#instance::#2\endcsname\empty \or - \setvalue{\??stylecollection#instance::#2}{#3}% + \defcsname\??stylecollection#instance::#2\endcsname{#3}% \or - \setvalue{\??stylecollection#instance:#2:#3}{#4}% + \defcsname\??stylecollection#instance:#2:#3\endcsname{#4}% \fi \ifcsname#instance\endcsname\else\font_styles_define_style_collection[#instance]\fi \fi} diff --git a/tex/context/base/mkxl/luat-cod.lmt b/tex/context/base/mkxl/luat-cod.lmt index e4432345e..91aa6592e 100644 --- a/tex/context/base/mkxl/luat-cod.lmt +++ b/tex/context/base/mkxl/luat-cod.lmt @@ -189,6 +189,9 @@ if not environment.luafilechunk then if sourcepath ~= "" then fullname = sourcepath .. "/" .. filename end + if not lfs.isfile(fullname) then + fullname = gsub(fullname,"mkxl","mkiv") + end local data = loadfile(fullname) texio.write("terminal_and_logfile","<",data and "+ " or "- ",fullname,">") if data then diff --git a/tex/context/base/mkxl/node-fin.lmt b/tex/context/base/mkxl/node-fin.lmt new file mode 100644 index 000000000..6d29ed57f --- /dev/null +++ b/tex/context/base/mkxl/node-fin.lmt @@ -0,0 +1,743 @@ +if not modules then modules = { } end modules ['node-fin'] = { + version = 1.001, + optimize = true, + comment = "companion to node-fin.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +-- this module is being reconstructed +-- local functions, only slightly slower +-- +-- leaders are also triggers ... see colo-ext for an example (negate a box) + +local next, type, format = next, type, string.format +local setmetatableindex = table.setmetatableindex + +local attributes, nodes, node = attributes, nodes, node + +local nuts = nodes.nuts +local tonut = nodes.tonut + +local getnext = nuts.getnext +local getid = nuts.getid +local getlist = nuts.getlist +local getleader = nuts.getleader +local getattr = nuts.getattr +local getattrs = nuts.getattrs +local getwidth = nuts.getwidth +local getwhd = nuts.getwhd +local getorientation = nuts.getorientation +local has_dimensions = nuts.has_dimensions +local getbox = nuts.getbox + +local setlist = nuts.setlist +local setleader = nuts.setleader + +local copy_node = nuts.copy +local insert_node_before = nuts.insert_before +local insert_node_after = nuts.insert_after + +local nextnode = nuts.traversers.node +local nextcontent = nuts.traversers.content + +local nodecodes = nodes.nodecodes +local rulecodes = nodes.rulecodes + +local boxrule_code = rulecodes.box +local imagerule_code = rulecodes.image +local emptyrule_code = rulecodes.empty + +local glyph_code = nodecodes.glyph +local disc_code = nodecodes.disc +local glue_code = nodecodes.glue +local rule_code = nodecodes.rule +local hlist_code = nodecodes.hlist +local vlist_code = nodecodes.vlist + +local texlists = tex.lists +local texgetnest = tex.getnest + +local states = attributes.states +local numbers = attributes.numbers +local a_trigger = attributes.private('trigger') +local triggering = false + +local implement = interfaces.implement + +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming +local loadstripped = utilities.lua.loadstripped +local unsetvalue = attributes.unsetvalue + +-- these two will be like trackers + +function states.enabletriggering () triggering = true end +function states.disabletriggering() triggering = false end + +implement { name = "enablestatetriggering", actions = states.enabletriggering } +implement { name = "disablestatetriggering", actions = states.disabletriggering } + +nodes.plugindata = nil + +-- inheritance: -0x7FFFFFFF -- we can best use nil and skip ! + +local template = [[ +local plugin = nodes.plugindata +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming +local namespace = plugin.namespace +local attribute = namespace.attribute or attributes.numbers[plugin.name] +local processor = plugin.processor +local initializer = plugin.initializer +local resolver = plugin.resolver +local finalizer = plugin.finalizer +local flusher = plugin.flusher +if not processor then + return function(head) + return head + end +elseif initializer or finalizer or resolver then + return function(head) + starttiming(attributes) + local used, inheritance + if resolver then + inheritance = resolver() + end + if initializer then + initializer(namespace,attribute,head) + end + head = processor(namespace,attribute,head,inheritance) + if finalizer then + head, used = finalizer(namespace,attribute,head) + if used and flusher then + head = flusher(namespace,attribute,head,used) + end + end + stoptiming(attributes) + return head + end +else + return function(head) + starttiming(attributes) + head = processor(namespace,attribute,head) + stoptiming(attributes) + return head + end +end +nodes.plugindata = nil +]] + +function nodes.installattributehandler(plugin) + nodes.plugindata = plugin + return loadstripped(template)() +end + +-- the injectors + +local nsdata, nsnone, nslistwise, nsforced, nsselector, nstrigger +local current, current_selector = 0, 0 -- nb, stack has a local current ! +local nsbegin, nsend, nsreset + +function states.initialize(namespace,attribute,head) + nsdata = namespace.data + nsnone = namespace.none + nsforced = namespace.forced + nsselector = namespace.selector + nslistwise = namespace.listwise + nstrigger = triggering and namespace.triggering and a_trigger + current = 0 + current_selector = 0 + nsstep = namespace.resolve_step + if nsstep then + nsreset = namespace.resolve_reset + nsbegin = namespace.resolve_begin + nsend = namespace.resolve_end + nspush = namespace.push + nspop = namespace.pop + end +end + +function states.finalize(namespace,attribute,head) -- is this one ok? + if current > 0 and nsnone then + local id = getid(head) + if id == hlist_code or id == vlist_code then + local content = getlist(head) + if content then + local list = insert_node_before(content,content,copy_node(nsnone)) -- two return values + if list ~= content then + setlist(head,list) + end + end + else + head = insert_node_before(head,head,copy_node(nsnone)) + end + return head, true + end + return head, false +end + +-- we need to deal with literals too (reset as well as oval) + +local function process(attribute,head,inheritance,default) -- one attribute + local check = false + local leader = nil + for stack, id, subtype, content in nextcontent, head do + if id == glyph_code or id == disc_code then + check = true + elseif id == glue_code then + check = true + leader = content + elseif id == hlist_code or id == vlist_code then + -- tricky checking + local outer + if getorientation(stack) then + outer = getattr(stack,attribute) + if outer then + if default and outer == inheritance then + if current ~= default then + head = insert_node_before(head,stack,copy_node(nsdata[default])) + current = default + end + elseif current ~= outer then + head = insert_node_before(head,stack,copy_node(nsdata[c])) + current = outer + end + elseif default and inheritance then + if current ~= default then + head = insert_node_before(head,stack,copy_node(nsdata[default])) + current = default + end + elseif current > 0 then + head = insert_node_before(head,stack,copy_node(nsnone)) + current = 0 + end + end + -- begin nested -- + local list + if nstrigger and getattr(stack,nstrigger) then + if not outer then + outer = getattr(stack,attribute) + end + if outer ~= inheritance then + list = process(attribute,content,inheritance,outer) + else + list = process(attribute,content,inheritance,default) + end + else + list = process(attribute,content,inheritance,default) + end + if content ~= list then + setlist(stack,list) + end + -- end nested -- + elseif id == rule_code then + check = has_dimensions(stack) + end + -- much faster this way than using a check() and nested() function + if check then + local c = getattr(stack,attribute) + if c then + if default and c == inheritance then + if current ~= default then + head = insert_node_before(head,stack,copy_node(nsdata[default])) + current = default + end + elseif current ~= c then + head = insert_node_before(head,stack,copy_node(nsdata[c])) + current = c + end + if leader then + local savedcurrent = current + local ci = getid(leader) + if ci == hlist_code or ci == vlist_code then + -- else we reset inside a box unneeded, okay, the downside is + -- that we trigger color in each repeated box, so there is room + -- for improvement here + current = 0 + end + -- begin nested -- + local list + if nstrigger and getattr(stack,nstrigger) then + local outer = getattr(stack,attribute) + if outer ~= inheritance then + list = process(attribute,leader,inheritance,outer) + else + list = process(attribute,leader,inheritance,default) + end + else + list = process(attribute,leader,inheritance,default) + end + if leader ~= list then + setleader(stack,list) + end + -- end nested -- + current = savedcurrent + leader = false + end + elseif default and inheritance then + if current ~= default then + head = insert_node_before(head,stack,copy_node(nsdata[default])) + current = default + end + elseif current > 0 then + head = insert_node_before(head,stack,copy_node(nsnone)) + current = 0 + end + check = false + end + end + return head +end + +states.process = function(namespace,attribute,head,default) + return process(attribute,head,default) +end + +-- we can force a selector, e.g. document wide color spaces, saves a little +-- watch out, we need to check both the selector state (like colorspace) and +-- the main state (like color), otherwise we get into troubles when a selector +-- state changes while the main state stays the same (like two glyphs following +-- each other with the same color but different color spaces e.g. \showcolor) + +-- local function selective(attribute,head,inheritance,default) -- two attributes +-- local check = false +-- local leader = nil +-- for stack, id, subtype, content in nextcontent, head do +-- if id == glyph_code or id == disc_code then +-- check = true +-- elseif id == glue_code then +-- check = true +-- leader = content -- getleader(stack) +-- elseif id == hlist_code or id == vlist_code then +-- -- tricky checking +-- local outer +-- if getorientation(stack) then +-- outer = getattr(stack,attribute) +-- if outer then +-- if default and outer == inheritance then +-- if current ~= default then +-- local data = nsdata[default] +-- head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) +-- current = default +-- end +-- else +-- local s = getattr(stack,nsselector) +-- -- local s = nsforced or getattr(stack,nsselector) +-- if current ~= outer or current_selector ~= s then +-- local data = nsdata[outer] +-- head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) +-- current = outer +-- current_selector = s +-- end +-- end +-- elseif default and inheritance then +-- if current ~= default then +-- local data = nsdata[default] +-- head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) +-- current = default +-- end +-- elseif current > 0 then +-- head = insert_node_before(head,stack,copy_node(nsnone)) +-- current, current_selector = 0, 0 +-- end +-- end +-- -- begin nested +-- local list +-- if nstrigger and getattr(stack,nstrigger) then +-- if not outer then +-- outer = getattr(stack,attribute) +-- end +-- if outer ~= inheritance then +-- list = selective(attribute,content,inheritance,outer) +-- else +-- list = selective(attribute,content,inheritance,default) +-- end +-- else +-- list = selective(attribute,content,inheritance,default) +-- end +-- if content ~= list then +-- setlist(stack,list) +-- end +-- -- end nested +-- elseif id == rule_code then +-- if subtype == boxrule_code or subtype == imagerule_code or subtype == emptyrule_code then +-- -- so no redundant color stuff (only here, layers for instance should obey) +-- check = false +-- else +-- check = has_dimensions(stack) +-- end +-- end +-- if check then +-- local c = getattr(stack,attribute) +-- if c then +-- if default and c == inheritance then +-- if current ~= default then +-- local data = nsdata[default] +-- head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) +-- current = default +-- end +-- else +-- local s = getattr(stack,nsselector) +-- -- local s = nsforced or getattr(stack,nsselector) +-- if current ~= c or current_selector ~= s then +-- local data = nsdata[c] +-- head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) +-- current = c +-- current_selector = s +-- end +-- end +-- if leader then +-- -- begin nested +-- local list +-- if nstrigger and getattr(stack,nstrigger) then +-- local outer = getattr(stack,attribute) +-- if outer ~= inheritance then +-- list = selective(attribute,leader,inheritance,outer) +-- else +-- list = selective(attribute,leader,inheritance,default) +-- end +-- else +-- list = selective(attribute,leader,inheritance,default) +-- end +-- if leader ~= list then +-- setleader(stack,list) +-- end +-- -- end nested +-- leader = false +-- end +-- elseif default and inheritance then +-- if current ~= default then +-- local data = nsdata[default] +-- head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) +-- current = default +-- end +-- elseif current > 0 then +-- head = insert_node_before(head,stack,copy_node(nsnone)) +-- current, current_selector = 0, 0 +-- end +-- check = false +-- end +-- end +-- return head +-- end + +local function selective(attribute,head,inheritance,default) -- two attributes + local check = false + local leader = nil + for stack, id, subtype, content in nextcontent, head do + if id == glyph_code or id == disc_code then + check = true + elseif id == glue_code then + check = true + leader = content -- getleader(stack) + elseif id == hlist_code or id == vlist_code then + -- tricky checking + local outer, s + if getorientation(stack) then + outer, s = getattrs(stack,attribute,nsselector) + if outer then + if default and outer == inheritance then + if current ~= default then + local data = nsdata[default] + head = insert_node_before(head,stack,copy_node(data[nsforced or nsselector])) + current = default + end + elseif current ~= outer or current_selector ~= s then + local data = nsdata[outer] + head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + current = outer + current_selector = s + end + elseif default and inheritance then + if current ~= default then + local data = nsdata[default] + head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + current = default + end + elseif current > 0 then + head = insert_node_before(head,stack,copy_node(nsnone)) + current, current_selector = 0, 0 + end + end + -- begin nested + local list + if nstrigger and getattr(stack,nstrigger) then + if not outer then + outer = getattr(stack,attribute) + end + if outer ~= inheritance then + list = selective(attribute,content,inheritance,outer) + else + list = selective(attribute,content,inheritance,default) + end + else + list = selective(attribute,content,inheritance,default) + end + if content ~= list then + setlist(stack,list) + end + -- end nested + elseif id == rule_code then + if subtype == boxrule_code or subtype == imagerule_code or subtype == emptyrule_code then + -- so no redundant color stuff (only here, layers for instance should obey) + check = false + else + check = has_dimensions(stack) + end + end + if check then + local c, s = getattrs(stack,attribute,nsselector) + if c then + if default and c == inheritance then + if current ~= default then + local data = nsdata[default] + head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + current = default + end + elseif current ~= c or current_selector ~= s then + local data = nsdata[c] + head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + current = c + current_selector = s + end + if leader then + -- begin nested + local list + if nstrigger and getattr(stack,nstrigger) then + local outer = getattr(stack,attribute) + if outer ~= inheritance then + list = selective(attribute,leader,inheritance,outer) + else + list = selective(attribute,leader,inheritance,default) + end + else + list = selective(attribute,leader,inheritance,default) + end + if leader ~= list then + setleader(stack,list) + end + -- end nested + leader = false + end + elseif default and inheritance then + if current ~= default then + local data = nsdata[default] + head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + current = default + end + elseif current > 0 then + head = insert_node_before(head,stack,copy_node(nsnone)) + current, current_selector = 0, 0 + end + check = false + end + end + return head +end + +states.selective = function(namespace,attribute,head,default) + return selective(attribute,head,default) +end + +-- Ideally the next one should be merged with the previous but keeping it separate is +-- safer. We deal with two situations: efficient boxwise (layoutareas) and mixed layers +-- (as used in the stepper). In the stepper we cannot use the box branch as it involves +-- paragraph lines and then gets mixed up. A messy business (esp since we want to be +-- efficient). +-- +-- Todo: make a better stacker. Keep track (in attribute) about nesting level. Not +-- entirely trivial and a generic solution is nicer (compares to the exporter). + +local function stacked(attribute,head,default) -- no triggering, no inheritance, but list-wise + local stack = head + local current = default or 0 + local depth = 0 + local check = false + local leader = false + while stack do + local id = getid(stack) + if id == glyph_code then + check = true + elseif id == glue_code then + leader = getleader(stack) + if leader then + check = true + end + elseif id == hlist_code or id == vlist_code then + local content = getlist(stack) + if content then + -- the problem is that broken lines gets the attribute which can be a later one + local list + if nslistwise then + local a = getattr(stack,attribute) + if a and current ~= a and nslistwise[a] then -- viewerlayer / needs checking, see below + local p = current + current = a + head = insert_node_before(head,stack,copy_node(nsdata[a])) + list = stacked(attribute,content,current) -- two return values + head, stack = insert_node_after(head,stack,copy_node(nsnone)) + current = p + else + list = stacked(attribute,content,current) + end + else + list = stacked(attribute,content,current) + end + if content ~= list then + setlist(stack,list) -- only if ok + end + end + elseif id == rule_code then + check = has_dimensions(stack) + end + if check then + local a = getattr(stack,attribute) + if a then + if current ~= a then + head = insert_node_before(head,stack,copy_node(nsdata[a])) + depth = depth + 1 + current = a + end + if leader then + local content = getlist(leader) + if content then + local list = stacked(attribute,content,current) + if leader ~= list then + setleader(stack,list) -- only if ok + end + end + leader = false + end + elseif default > 0 then + -- + elseif current > 0 then + head = insert_node_before(head,stack,copy_node(nsnone)) + depth = depth - 1 + current = 0 + end + check = false + end + stack = getnext(stack) + end + while depth > 0 do + head = insert_node_after(head,stack,copy_node(nsnone)) + depth = depth - 1 + end + return head +end + +states.stacked = function(namespace,attribute,head,default) + return stacked(attribute,head,default) +end + +-- experimental + +local function stacker(attribute,head,default) -- no triggering, no inheritance, but list-wise + + -- nsbegin() + local stacked = false + + local current = head + local previous = head + local attrib = default or unsetvalue + local check = false + local leader = false + + while current do + local id = getid(current) + if id == glyph_code then + check = true + elseif id == glue_code then + leader = getleader(current) + if leader then + check = true + end + elseif id == hlist_code or id == vlist_code then + local content = getlist(current) + if content then + local list + if nslistwise then + local a = getattr(current,attribute) + if a and attrib ~= a and nslistwise[a] then -- viewerlayer + head = insert_node_before(head,current,copy_node(nsdata[a])) + list = stacker(attribute,content,a) + if list ~= content then + setlist(current,list) + end + head, current = insert_node_after(head,current,copy_node(nsnone)) + else + list = stacker(attribute,content,attrib) + if list ~= content then + setlist(current,list) + end + end + else + list = stacker(attribute,content,default) + if list ~= content then + setlist(current,list) + end + end + end + elseif id == rule_code then + check = has_dimensions(current) + end + + if check then + local a = getattr(current,attribute) or unsetvalue + if a ~= attrib then + if not stacked then + stacked = true + nsbegin() + end + local n = nsstep(a) + if n then + head = insert_node_before(head,current,n) -- a + end + attrib = a + if leader then + -- tricky as a leader has to be a list so we cannot inject before + -- local list = stacker(attribute,leader,attrib) + -- leader = false + + local content = getlist(leader) + if content then + local list = stacker(attribute,leader,attrib) + if leader ~= list then + setleader(current,list) + end + end + + leader = false + end + end + check = false + end + + previous = current + current = getnext(current) + end + + if stacked then + local n = nsend() + while n do + head = insert_node_after(head,previous,n) + n = nsend() + end + end + + return head +end + +states.stacker = function(namespace,attribute,head,default) + local head = stacker(attribute,head,default) + nsreset() + return head +end + +-- -- -- + +statistics.register("attribute processing time", function() + return statistics.elapsedseconds(attributes,"front- and backend") +end) diff --git a/tex/context/base/mkxl/node-fin.mkxl b/tex/context/base/mkxl/node-fin.mkxl index 183e02429..b2217d3ca 100644 --- a/tex/context/base/mkxl/node-fin.mkxl +++ b/tex/context/base/mkxl/node-fin.mkxl @@ -16,8 +16,8 @@ \unprotect \registerctxluafile{node-shp}{optimize} -% \registerctxluafile{node-fin}{autosuffix,optimize} % we might generalize this one -\registerctxluafile{node-fin}{optimize} % we might generalize this one +\registerctxluafile{node-fin}{autosuffix,optimize} % we might generalize this one +% \registerctxluafile{node-fin}{optimize} % we might generalize this one \permanent\protected\def\finalizeobjectbox #1{\clf_finalizebox#1\relax} \permanent\protected\def\finalizeshipoutbox#1{\clf_finalizebox#1\relax} diff --git a/tex/context/base/mkxl/pack-box.mkxl b/tex/context/base/mkxl/pack-box.mkxl index 7221f7a5f..975f657b7 100644 --- a/tex/context/base/mkxl/pack-box.mkxl +++ b/tex/context/base/mkxl/pack-box.mkxl @@ -468,7 +468,7 @@ {\egroup\collectedtext}% {\egroup\layeredtext }% [#1][#2]}% - {\egroup\getvalue{#1}}} + {\egroup\csname#1\endcsname}} \permanent\tolerant\protected\def\defineornament[#1]#*[#2]#*[#3]% {\setuvalue{#1}{\pack_ornament_text[#2][#3]}} diff --git a/tex/context/base/mkxl/pack-com.mkxl b/tex/context/base/mkxl/pack-com.mkxl index 034035f35..21511f6b3 100644 --- a/tex/context/base/mkxl/pack-com.mkxl +++ b/tex/context/base/mkxl/pack-com.mkxl @@ -814,8 +814,8 @@ \let\pack_pairedboxes_align_t\vss \let\pack_pairedboxes_align_b\vss} -\setvalue{\??pairedboxalign\v!bottom}{\getvalue{\??pairedboxalign\v!low }} -\setvalue{\??pairedboxalign \v!top}{\getvalue{\??pairedboxalign\v!high}} +\setvalue{\??pairedboxalign\v!bottom}{\csname\??pairedboxalign\v!low \endcsname} +\setvalue{\??pairedboxalign \v!top}{\csname\??pairedboxalign\v!high\endcsname} \def\pack_pairedbox_valign#1{\setbox#1\vpack to \s_pack_pairedboxes_size{\pack_pairedboxes_align_t\box#1\pack_pairedboxes_align_b}} \def\pack_pairedbox_halign#1{\setbox#1\hpack to \s_pack_pairedboxes_size{\pack_pairedboxes_align_l\box#1\pack_pairedboxes_align_r}} diff --git a/tex/context/base/mkxl/page-lin.mklx b/tex/context/base/mkxl/page-lin.mklx new file mode 100644 index 000000000..fc911191d --- /dev/null +++ b/tex/context/base/mkxl/page-lin.mklx @@ -0,0 +1,617 @@ +%D \module +%D [ file=page-lin, +%D version=2007.11.29, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Line Numbering, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% generic or not ... maybe not bother too much and simplify to mkiv only get rid of +% \mk* (left over from experimental times) +% +% to be redone (was experiment) .. can be hooked into margin code reshuffle +% arguments +% +% this is early luatex code, 2007 or even before that, and it shows ... we have +% better tricks now + +\writestatus{loading}{ConTeXt Core Macros / Line Numbering} + +\unprotect + +% todo: save settings +% +% low level interface +% +% we should use normal counters but then we need to sync settings + +% some line +% +% \startlocallinenumbering +% some source code 1\par +% some source code 2\par +% some source code 3\par +% \stoplocallinenumbering +% +% some line + +\registerctxluafile{page-lin}{} + +\definesystemattribute[linenumber] [public] +\definesystemattribute[linereference][public] + +\appendtoksonce + \c_attr_linenumber\attributeunsetvalue +\to \everyforgetall + +\appendtoks + \c_attr_linenumber\attributeunsetvalue +\to \everyinsidefloat + +\mutable\let\linenumber\!!zerocount + +\newbox \b_page_lines_scratch +\newcount \c_page_lines_reference +\newconstant\c_page_lines_nesting + +\newconditional\tracelinenumbering % we keep this for old times sake + +\installtextracker + {lines.numbers.show} + {\settrue \tracelinenumbering} + {\setfalse\tracelinenumbering} + +% id nr shift width leftskip dir + +\installcorenamespace{linenumberinginstance} + +% tag skipflag s getfield(n,"shift") getfield(n,"width") leftmarginwidth(getlist(n)) getfield(n,"dir")) + +\let\makelinenumber\gobblefivearguments % used at lua end + +\newconditional\page_postprocessors_needed_box + +\protected\def\page_postprocessors_linenumbers_page_indeed #tag{\page_lines_add_numbers_to_box{#tag}\plusone \plusone \zerocount} +\protected\def\page_postprocessors_linenumbers_box_indeed #tag{\page_lines_add_numbers_to_box{#tag}\plusone \plusone \zerocount} +\protected\def\page_postprocessors_linenumbers_deepbox_indeed#tag{\page_lines_add_numbers_to_box{#tag}\plusone \plusone \plusone } +\protected\def\page_postprocessors_linenumbers_column_indeed #tag{\page_lines_add_numbers_to_box{#tag}\currentcolumn\nofcolumns\zerocount} + +\let\page_postprocessors_linenumbers_page \gobbleoneargument +\let\page_postprocessors_linenumbers_box \gobbleoneargument +\let\page_postprocessors_linenumbers_deepbox\gobbleoneargument +\let\page_postprocessors_linenumbers_column \gobbleoneargument + +\protected\def\page_postprocessors_linenumbers_check + {\glet\page_postprocessors_linenumbers_check \relax + \glet\page_postprocessors_linenumbers_page \page_postprocessors_linenumbers_page_indeed + \glet\page_postprocessors_linenumbers_box \page_postprocessors_linenumbers_box_indeed + \glet\page_postprocessors_linenumbers_deepbox\page_postprocessors_linenumbers_deepbox_indeed + \glet\page_postprocessors_linenumbers_column \page_postprocessors_linenumbers_column_indeed} + +\def\page_lines_start_define + {\setxvalue{\??linenumberinginstance\currentlinenumbering}% + {\clf_registerlinenumbering + continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}% + start \linenumberingparameter\c!start + step \linenumberingparameter\c!step + method {\linenumberingparameter\c!method}% + tag {\currentlinenumbering}% + }} + +\def\page_lines_start_update + {\clf_setuplinenumbering + \csname\??linenumberinginstance\currentlinenumbering\endcsname + {% + continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}% + }% + \relax} + +\def\page_lines_setup + {\ifcsname \??linenumberinginstance\currentlinenumbering\endcsname + \clf_setuplinenumbering + \lastnamedcs + {% + continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}% + start \linenumberingparameter\c!start + step \linenumberingparameter\c!step + method {\linenumberingparameter\c!method}% + tag {\currentlinenumbering}% + }% + \relax + \fi} + +% we could make this a bit more efficient by putting the end reference +% in the same table as the start one but why make things complex ... + +\protected\def\page_lines_some_reference#1#2#3% + {\dontleavehmode\begingroup + \global\advance\c_page_lines_reference\plusone + \c_attr_linereference\c_page_lines_reference + #3% todo: #3{#1} as there is no need to pass #1 as part of #3 + % for the moment we use a simple system i.e. no prefixes etc .. todo: store as number + \c_strc_references_bind_state\zerocount % we don't want the prewordbreak and manage it here + \normalexpanded{\strc_references_set_named_reference{line}{#2}{conversion=\linenumberingparameter\c!conversion}{\the\c_page_lines_reference}}% kind labels userdata text + \endgroup} + +% \def\page_lines_reference_start#1{\page_lines_some_reference{#1}{lr:b:#1}{}} % reimplemented later +% \def\page_lines_reference_stop #1{\page_lines_some_reference{#1}{lr:e:#1}{}} % reimplemented later + +% \def\mklinestartreference#1[#2]{\in{#1}[lr:b:#2]} % not interfaced/ not used +% \def\mklinestopreference #1[#2]{\in{#1}[lr:e:#2]} % not interfaced/ not used + +\newif\ifnumberinglines % will change +\newif\iftypesettinglines % will change + +\installcorenamespace{linenumbering} + +\installcommandhandler \??linenumbering {linenumbering} \??linenumbering + +\setnewconstant\c_page_lines_mode \plusone % 0=continue, 1=restart +\setnewconstant\c_page_lines_location \plusone % 0=middle, 1=left, 2=right, 3=inner, 4=outer, 5=text, 6=begin, 7=end +\setnewconstant\c_page_lines_alignment\plusfive % 0=middle, 1=left, 2=right, 5=auto + +\newdimen\d_page_lines_width +\newdimen\d_page_lines_distance + +\newevery \beforeeverylinenumbering \relax +\newevery \aftereverylinenumbering \relax +\newevery \everylinenumber \relax + +\appendtoks + \page_lines_setup +\to \everysetuplinenumbering + +\appendtoks + \page_lines_start_define +\to \everydefinelinenumbering + +\setuplinenumbering + [\c!conversion=\v!numbers, + \c!start=1, + \c!step=1, + \c!method=\v!first, + \c!continue=\v!no, + \c!style=, + \c!color=, + \c!width=2\emwidth, + \c!left=, + \c!right=, + \c!command=, + \c!margin=2.5\emwidth, + \c!distance=\zeropoint, + \c!location=\v!default, % depends on direction, columns etc + \c!align=\v!auto] + +\definelinenumbering + [] + +% \startlinenumbering[<startvalue>|continue|settings|name] +% \startlinenumbering[name][<startvalue>|continue|settings] + +\newcount\c_pages_lines_nesting + +\permanent\tolerant\protected\def\startlinenumbering[#1]#*[#2]% + {\begingroup + \page_postprocessors_linenumbers_check + \advance\c_pages_lines_nesting\plusone + \ifnum\c_pages_lines_nesting>\plusone + \expandafter\gobbletwooptionals + \orelse\ifparameter#2\or + \expandafter\page_lines_start_two + \orelse\ifparameter#1\or + \expandafter\page_lines_start_one + \else + \expandafter\page_lines_start_zero + \fi[#1][#2]} + +\def\page_lines_start_zero[#1][#2]% + {\edef\m_argument{\linenumberingparameter\c!continue}% + \ifx\m_argument\v!yes + \c_page_lines_mode\zerocount + \else + \c_page_lines_mode\plusone + \fi + \page_lines_start_followup} + +\def\page_lines_start_one[#1][#2]% [continue|<number>|settings] % historic + {\edef\m_argument{#1}% + \ifx\m_argument\v!continue + \c_page_lines_mode\zerocount + \let\currentlinenumbering\empty + \else + \c_page_lines_mode\plusone + \ifx\m_argument\v!empty + \let\currentlinenumbering\empty + \orelse\ifhastok={#1}% + \let\currentlinenumbering\empty + \setupcurrentlinenumbering[#1]% + \else + \doifelsenumber\m_argument + {\let\currentlinenumbering\empty + \letlinenumberingparameter\c!start\m_argument} + {\let\currentlinenumbering\m_argument}% + \fi + \edef\p_continue{\linenumberingparameter\c!continue}% + \ifx\p_continue\v!yes + \c_page_lines_mode\zerocount + \fi + \fi + \page_lines_start_followup} + +\def\page_lines_start_two[#1][#2]% [tag][continue|<number>|settings] + {\edef\currentlinenumbering{#1}% + \edef\m_argument{#2}% + \ifx\m_argument\v!continue + \c_page_lines_mode\zerocount + \else + \c_page_lines_mode\plusone + \ifx\m_argument\v!empty \else + \doifelseassignment{#2} + {\setupcurrentlinenumbering[#2]} + {\doifnumber\m_argument + {\letlinenumberingparameter\c!start\m_argument}}% + \fi + \edef\p_continue{\linenumberingparameter\c!continue}% + \ifx\p_continue\v!yes + \c_page_lines_mode\zerocount + \fi + \fi + \page_lines_start_followup} + +\newconditional\c_page_lines_auto_narrow +%\newconditional\c_page_lines_enabled + +\appendtoks + \ifconditional\page_postprocessors_needed_box + \page_postprocessors_linenumbers_page\b_page_postprocessor + \fi +\to \t_page_postprocessors_page + +\appendtoks + \ifconditional\page_postprocessors_needed_box + \page_postprocessors_linenumbers_column\b_page_postprocessor + \fi +\to \t_page_postprocessors_column + +\def\page_lines_start_followup + {\numberinglinestrue + \edef\p_location{\linenumberingparameter\c!location}% + \setfalse\c_page_lines_auto_narrow + \ifhmode \else + \ifx\p_location\v!text + \ifdim\leftskip>\zeropoint \else + \advance\leftskip\linenumberingparameter\c!margin + \settrue\c_page_lines_auto_narrow + \fi + \orelse\ifx\p_location\v!begin + \ifdim\leftskip>\zeropoint \else + \advance\leftskip\linenumberingparameter\c!margin + \settrue\c_page_lines_auto_narrow + \fi + \orelse\ifx\p_location\v!end + \ifdim\leftskip>\zeropoint \else + \advance\rightskip\linenumberingparameter\c!margin + \settrue\c_page_lines_auto_narrow + \fi + \fi + \fi + \the\beforeeverylinenumbering + %\global\settrue\c_page_lines_enabled % + \global\settrue\page_postprocessors_needed_box % see core-rul.mkiv + \ifcase\c_page_lines_mode\relax + \page_lines_start_update % continue + \or + \page_lines_start_define % only when assignment + \fi + \c_attr_linenumber\csname\??linenumberinginstance\currentlinenumbering\endcsname\relax} + +\permanent\protected\def\stoplinenumbering + {\ifconditional\c_pages_lines_nesting=\plusone + \c_attr_linenumber\attributeunsetvalue + \the\aftereverylinenumbering + \ifconditional\c_page_lines_auto_narrow\par\fi + \fi + \endgroup} + +% number placement .. will change into (the new) margin code + +\newconditional\c_page_lines_fake_number +\newconstant \b_page_lines_number +\newconstant \c_page_lines_column +\newconstant \c_page_lines_last_column +\newdimen \d_page_lines_line_width +\settrue \c_page_lines_dir_left_to_right + +\installcorenamespace{linenumberinghandler} + +\def\page_line_swap_align % can become a helper + {\ifx\p_align\v!inner \let\p_align\v!outer \orelse + \ifx\p_align\v!outer \let\p_align\v!inner \orelse + \ifx\p_align\v!flushleft \let\p_align\v!flushright\orelse + \ifx\p_align\v!flushright\let\p_align\v!flushleft \orelse + \ifx\p_align\v!left \let\p_align\v!right \orelse + \ifx\p_align\v!right \let\p_align\v!left \fi} + +\let\page_lines_make_number_indeed\relax + +% \def\page_lines_rlap{\ifconditional\c_page_lines_dir_left_to_right\expandafter\rlap\else\expandafter\llap\fi} +% \def\page_lines_llap{\ifconditional\c_page_lines_dir_left_to_right\expandafter\llap\else\expandafter\rlap\fi} + +\def\page_lines_add_numbers_to_box#box#column#max#nesting% + {\bgroup + \strc_tags_enable_indeed + \b_page_lines_number #box\relax + \c_page_lines_column #column\relax + \c_page_lines_last_column#max\relax + \fullrestoreglobalbodyfont + \let\makelinenumber\page_lines_make_number % used at lua end + \setbox\b_page_lines_scratch\vbox + {\forgetall + \offinterlineskip + \clf_linenumbersstageone + \b_page_lines_number + #nesting% + \relax}% + \clf_linenumbersstagetwo + \b_page_lines_number + \b_page_lines_scratch + \relax + \egroup} + +\def\page_lines_make_number#tag#mode#linenumber#width#dir% with hang and parindent and skips we have to compensate for \hsize + {\naturalhbox to \zeropoint \bgroup + \ifcase#mode\relax + % \settrue \c_page_lines_fake_number + \else + % \setfalse\c_page_lines_fake_number + \edef\currentlinenumbering{#tag}% + \def\linenumber{#linenumber}% unsafe + \d_page_lines_line_width#width\scaledpoint\relax + \d_page_lines_distance\linenumberingparameter\c!distance\relax + \edef\p_align{\linenumberingparameter\c!align}% + \edef\p_location{\linenumberingparameter\c!location}% + \ifcase#dir\relax + \settrue \c_page_lines_dir_left_to_right + \else + \setfalse\c_page_lines_dir_left_to_right + \fi + % + % maybe we also need an option to ignore columns, so that we renumber + % once but on the other hand this assumes aligned lines + % + \ifcase\c_page_lines_last_column\relax + \settrue \c_page_lines_fake_number % why + \or + % one column + \or + % two columns + \ifx\p_location\v!default % or just margin + \ifcase\c_page_lines_column\relax + \settrue \c_page_lines_fake_number % why + \or + \let\p_location\v!left % one + \else + \let\p_location\v!right % two + \page_line_swap_align % can become a helper + \fi + \fi + % \else + % too fuzzy + \fi + \ifx\p_location\v!default + \ifconditional\c_page_lines_dir_left_to_right + \let\p_location\v!left + \else + \let\p_location\v!right + \page_line_swap_align % yes or no + \fi + \fi + % + \begincsname\??linenumberinghandler\p_location\endcsname + \fi + \egroup} + +\def\page_lines_number_inject#align#width% + {\edef\p_width{\linenumberingparameter\c!width}% + \ifx\p_width\v!margin + \d_page_lines_width#width% + \else + \d_page_lines_width\p_width + \fi + \relax + \ifdim\d_page_lines_width>\zeropoint + \ifconditional\tracelinenumbering + \ruledhbox{\simplealignedbox\d_page_lines_width#align{\page_lines_number_inject_indeed}}% + \else + \simplealignedbox\d_page_lines_width#align{\page_lines_number_inject_indeed}% + \fi + \else + \ifconditional\tracelinenumbering + \ruledhbox + % \else + % \hbox + \fi + {\page_lines_number_inject_indeed}% + \fi} + +\def\page_lines_number_inject_indeed + {\uselinenumberingstyleandcolor\c!style\c!color + \linenumberingparameter\c!command + {\linenumberingparameter\c!left + \convertnumber{\linenumberingparameter\c!conversion}\linenumber + \linenumberingparameter\c!right}} + +% \def\dodorlap{\hbox to \zeropoint{\box\nextbox\normalhss}\endgroup} +% \def\dodollap{\hbox to \zeropoint{\normalhss\box\nextbox}\endgroup} + +\def\page_line_handle_left#align#width#distance% + {\dostarttagged\t!linenumber\empty + \llap + {\page_lines_number_inject#align#width% + \dostarttagged\t!ignore\empty + \kern\dimexpr + #distance+\d_page_lines_distance + \ifconditional\c_page_lines_dir_left_to_right\else+\d_page_lines_line_width\fi + \relax + \the\everylinenumber + \hss + \dostoptagged}% + \dostoptagged} + +\def\page_line_handle_right#align#width#distance% + {\dostarttagged\t!linenumber\empty + \rlap + {\dostarttagged\t!ignore\empty + \kern\dimexpr + #distance+\d_page_lines_distance + \ifconditional\c_page_lines_dir_left_to_right+\d_page_lines_line_width\fi + \relax + \dostoptagged + \page_lines_number_inject#align#width% + \dostarttagged\t!ignore\empty + \the\everylinenumber + \hss + \dostoptagged}% + \dostoptagged} + +\setuvalue{\??linenumberinghandler\v!left}% + {\page_line_handle_left\p_align\leftmarginwidth\leftmargindistance} + +\setuvalue{\??linenumberinghandler\v!right}% + {\page_line_handle_right\p_align\rightmarginwidth\rightmargindistance} + +\setuvalue{\??linenumberinghandler\v!inner}% + {\ifodd\realpageno + \ifx\p_align\v!inner + \page_line_handle_left\v!flushleft\leftmarginwidth\leftmargindistance + \orelse\ifx\p_align\v!outer + \page_line_handle_left\v!flushright\leftmarginwidth\leftmargindistance + \else + \page_line_handle_left\p_align\leftmarginwidth\leftmargindistance + \fi + \else + \ifx\p_align\v!inner + \page_line_handle_right\v!flushright\rightmarginwidth\rightmargindistance + \orelse\ifx\p_align\v!outer + \page_line_handle_right\v!flushleft\rightmarginwidth\rightmargindistance + \else + \page_line_handle_right\p_align\rightmarginwidth\rightmargindistance + \fi + \fi} + +\setuvalue{\??linenumberinghandler\v!outer}% + {\ifodd\realpageno + \ifx\p_align\v!inner + \page_line_handle_right\v!flushleft\leftmarginwidth\leftmargindistance + \orelse\ifx\p_align\v!outer + \page_line_handle_right\v!flushright\leftmarginwidth\leftmargindistance + \else + \page_line_handle_right\p_align\leftmarginwidth\leftmargindistance + \fi + \else + \ifx\p_align\v!inner + \page_line_handle_left\v!flushright\rightmarginwidth\rightmargindistance + \orelse\ifx\p_align\v!outer + \page_line_handle_left\v!flushleft\rightmarginwidth\rightmargindistance + \else + \page_line_handle_left\p_align\rightmarginwidth\rightmargindistance + \fi + \fi} + +\def\page_line_handle_begin#align% + {\rlap + {\kern\d_page_lines_distance + \page_lines_number_inject#align\zeropoint + \the\everylinenumber}} + +\def\page_line_handle_end#align% + {\rlap + {\kern\d_page_lines_line_width\relax + \llap + {\page_lines_number_inject#align\zeropoint + \kern\d_page_lines_distance + \the\everylinenumber}}} + +\protected\defcsname\??linenumberinghandler\v!begin\endcsname{\page_line_handle_begin\p_align} +\protected\defcsname\??linenumberinghandler\v!end \endcsname{\page_line_handle_end \p_align} +\protected\defcsname\??linenumberinghandler\v!text \endcsname{\page_line_handle_begin\p_align} + +\letcsname\??linenumberinghandler\v!inleft \expandafter\endcsname\csname\??linenumberinghandler\v!left \endcsname +\letcsname\??linenumberinghandler\v!inmargin\expandafter\endcsname\csname\??linenumberinghandler\v!left \endcsname +\letcsname\??linenumberinghandler\v!margin \expandafter\endcsname\csname\??linenumberinghandler\v!left \endcsname +\letcsname\??linenumberinghandler\v!inright \expandafter\endcsname\csname\??linenumberinghandler\v!right\endcsname + +% referencing: \permithyphenation, also removes leading spaces (new per 29-11-2013) + +\permanent\protected\def\someline [#1]{\page_lines_reference_start{#1}\page_lines_reference_stop{#1}} % was just a def +\permanent\protected\def\startline[#1]{\page_lines_reference_start{#1}\permithyphenation\ignorespaces} %okay? +\permanent\protected\def\stopline [#1]{\removeunwantedspaces\permithyphenation\page_lines_reference_stop{#1}} + +\def\page_lines_reference_show_start + {\ifconditional\tracelinenumbering + \expandafter\page_lines_reference_show_start_indeed + \else + \expandafter\gobbleoneargument + \fi} + +\def\page_lines_reference_show_stop + {\ifconditional\tracelinenumbering + \expandafter\page_lines_reference_show_stop_indeed + \else + \expandafter\gobbleoneargument + \fi} + +\def\page_lines_reference_show_start_indeed#1% + {\setbox\scratchbox\hpack{\llap + {\vrule\s!width\onepoint\s!depth\strutdp\s!height.8\strutht\raise.85\strutht\hpack{\llap{\tt\txx#1}}}}% + \smashbox\scratchbox + \box\scratchbox} + +\def\page_lines_reference_show_stop_indeed#1% + {\setbox\scratchbox\hpack{\rlap + {\raise.85\strutht\hpack{\rlap{\tt\txx#1}}\vrule\s!width\onepoint\s!depth\strutdp\s!height.8\strutht}}% + \smashbox\scratchbox + \box\scratchbox} + +\def\page_lines_reference_start#1{\page_lines_some_reference{#1}{lr:b:#1}{\page_lines_reference_show_start{#1}}} +\def\page_lines_reference_stop #1{\page_lines_some_reference{#1}{lr:e:#1}{\page_lines_reference_show_stop {#1}}} + +% eventually we will do this in lua + +\permanent\def\currentreferencelinenumber{\clf_filterreference{linenumber}} + +\let\m_page_lines_from\empty +\let\m_page_lines_to \empty + +\permanent\protected\def\doifelsesamelinereference#1#2#3% + {\doifelsereferencefound{lr:b:#1} + {\edef\m_page_lines_from{\currentreferencelinenumber}% + \doifelsereferencefound{lr:e:#1} + {\edef\m_page_lines_to{\currentreferencelinenumber}% + %[\m_page_lines_from,\m_page_lines_to] + \ifx\m_page_lines_from\m_page_lines_to#2\else#3\fi}% + {#2}} + {#2}} + +\aliased\let\doifsamelinereferenceelse\doifelsesamelinereference + +\permanent\protected\def\inline#1[#2]% + {\doifelsenothing{#1}% + {\doifelsesamelinereference{#2}% + {\in{\leftlabeltext\v!line}{\rightlabeltext\v!line}[lr:b:#2]}% + {\in{\leftlabeltext\v!lines}{}[lr:b:#2]--\in{}{\rightlabeltext\v!lines}[lr:e:#2]}}% + {\doifelsesamelinereference{#2}% + {\in{#1}[lr:b:#2]}% + {\in{#1}[lr:b:#2]--\in[lr:e:#2]}}} + +\permanent\protected\def\inlinerange[#1]% + {\doifelsesamelinereference{#1}% + {\in[lr:b:#1]}% + {\in[lr:b:#1]\endash\in[lr:e:#1]}} + +\protect \endinput diff --git a/tex/context/base/mkxl/strc-not.mklx b/tex/context/base/mkxl/strc-not.mklx index ec8cf849f..c07cd2085 100644 --- a/tex/context/base/mkxl/strc-not.mklx +++ b/tex/context/base/mkxl/strc-not.mklx @@ -946,20 +946,20 @@ \protected\def\strc_notes_set_delayed_yes{\settrue \c_strc_notes_delayed} \protected\def\strc_notes_set_delayed_nop{\setfalse\c_strc_notes_delayed} -\setvalue{\??notelocation\v!page }{\letvalue{\??notedelayedvariant \currentnote}\strc_notes_set_delayed_nop - \letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_page} -\setvalue{\??notelocation\v!columns }{\letvalue{\??notedelayedvariant \currentnote}\strc_notes_set_delayed_nop - \letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_columns} -\setvalue{\??notelocation\v!lastcolumn }{\letvalue{\??notedelayedvariant \currentnote}\strc_notes_set_delayed_nop - \letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_lastcolumn} -\setvalue{\??notelocation\v!firstcolumn}{\letvalue{\??notedelayedvariant \currentnote}\strc_notes_set_delayed_nop - \letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_firstcolumn} -\setvalue{\??notelocation\v!none }{\letvalue{\??notedelayedvariant \currentnote}\strc_notes_set_delayed_yes - \letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_none} -\setvalue{\??notelocation\v!text }{\letvalue{\??notedelayedvariant \currentnote}\strc_notes_set_delayed_yes - \letvalue{\??notelocationvariant\currentnote}\strc_notes_set_location_text} -\setvalue{\??notelocation\v!high }{\letvalue{\??notepositionvariant\currentnote}\strc_notes_set_position_high} -\setvalue{\??notelocation\v!bottom }{\letvalue{\??notepositionvariant\currentnote}\strc_notes_set_position_bottom} +\setvalue{\??notelocation\v!page }{\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_nop + \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_page} +\setvalue{\??notelocation\v!columns }{\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_nop + \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_columns} +\setvalue{\??notelocation\v!lastcolumn }{\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_nop + \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_lastcolumn} +\setvalue{\??notelocation\v!firstcolumn}{\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_nop + \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_firstcolumn} +\setvalue{\??notelocation\v!none }{\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_yes + \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_none} +\setvalue{\??notelocation\v!text }{\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_yes + \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_text} +\setvalue{\??notelocation\v!high }{\letcsname\??notepositionvariant\currentnote\endcsname\strc_notes_set_position_high} +\setvalue{\??notelocation\v!bottom }{\letcsname\??notepositionvariant\currentnote\endcsname\strc_notes_set_position_bottom} \setvalue{\??notedelayedvariant \??notedelayedvariant }{\strc_notes_set_delayed_nop} % not let \setvalue{\??notepositionvariant\??notepositionvariant}{\strc_notes_set_position_bottom} % not let diff --git a/tex/context/base/mkxl/strc-pag.mkxl b/tex/context/base/mkxl/strc-pag.mkxl index 07ac30d26..abab94e72 100644 --- a/tex/context/base/mkxl/strc-pag.mkxl +++ b/tex/context/base/mkxl/strc-pag.mkxl @@ -136,8 +136,8 @@ \installcorenamespace{pagestatestack} % no level yet -\protected\def\strc_pagenumbers_page_state_push{\setxvalue{\??pagestatestack\c!state}{\namedcounterparameter\s!userpage\c!state}} -\protected\def\strc_pagenumbers_page_state_pop {\normalexpanded{\setuppagenumber[\c!state=\getvalue{\??pagestatestack\c!state}]}} +\protected\def\strc_pagenumbers_page_state_push{\xdefcsname\??pagestatestack\c!state\endcsname{\namedcounterparameter\s!userpage\c!state}} +\protected\def\strc_pagenumbers_page_state_pop {\normalexpanded{\setuppagenumber[\c!state=\csname\??pagestatestack\c!state\endcsname]}} \setuppagenumber [\c!way=\v!by\v!text, diff --git a/tex/context/base/mkxl/supp-box.mkxl b/tex/context/base/mkxl/supp-box.mkxl index 88fd5c9fb..f571e504d 100644 --- a/tex/context/base/mkxl/supp-box.mkxl +++ b/tex/context/base/mkxl/supp-box.mkxl @@ -2327,7 +2327,7 @@ \ifcsname\??stacklst#1\endcsname \expandafter\processcommacommand\expandafter[\lastnamedcs]\docommand \fi - \letgvalueempty{\??stacklst#1}} + \gletcsname\??stacklst#1\endcsname\empty} \permanent\protected\def\savebox#1#2% stack name {% beware, \setxvalue defines the cs beforehand so we cannot use the test inside the { } diff --git a/tex/context/base/mkxl/syst-aux.mkxl b/tex/context/base/mkxl/syst-aux.mkxl index 8fc9d6e02..8a7da172d 100644 --- a/tex/context/base/mkxl/syst-aux.mkxl +++ b/tex/context/base/mkxl/syst-aux.mkxl @@ -4714,16 +4714,13 @@ {\dodoglobal\edef#2{#1\ifempty#2\else,#2\fi}}} \permanent\protected\def\xsplitstring#1#2% \cs {str} - %{\def\syst_helpers_split_string##1,#2,##2,#2,##3\\% {\def\syst_helpers_split_string##1,#2,##2,#2,##-\\% - {\edef\m_syst_string_one{\bcleanedupcommalist##1\empty\empty\relax}% - \edef\m_syst_string_two{\acleanedupcommalist##2,,\relax}}% + {\edef\m_syst_string_one{\syst_cleanedup_commalist_b##1\empty\empty\relax}% + \edef\m_syst_string_two{\syst_cleanedup_commalist_a##2,,\relax}}% \expandafter\syst_helpers_split_string\expandafter,#1,,#2,,#2,\\} -\def\bcleanedupcommalist#1#2#3\relax{\if#1,\else#1\fi\if#2,\else#2\fi#3} -\def\bcleanedupcommalist#1#2\relax{\if#1,\else#1\fi#2} -%def\acleanedupcommalist#1,,#2\relax{#1} -\def\acleanedupcommalist#1,,#-\relax{#1} +\def\syst_cleanedup_commalist_b#1#2\relax{\if#1,\else#1\fi#2} +\def\syst_cleanedup_commalist_a#1,,#-\relax{#1} \permanent\protected\def\removefromcommalist#1#2% to be sped up {\rawdoifelseinset{#1}#2% diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index 50fe1c1bb..1f78c5864 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -1104,4 +1104,10 @@ \mutable\let\par\par \popoverloadmode +%D Temp hack ... build bot down: + +\ifdefined\gletcsname \else \protected\def\gletcsname{\global\letcsname } \fi +\ifdefined\gdefcsname \else \protected\def\gdefcsname{\global\defcsname } \fi +\ifdefined\xdefcsname \else \protected\def\xdefcsname{\global\edefcsname} \fi + \protect \endinput diff --git a/tex/context/base/mkxl/type-ini.mklx b/tex/context/base/mkxl/type-ini.mklx index 23c277f99..bbb2ae2c7 100644 --- a/tex/context/base/mkxl/type-ini.mklx +++ b/tex/context/base/mkxl/type-ini.mklx @@ -432,12 +432,12 @@ \edef\fontclass{#typeface}% \else % todo: message - \letvalueempty{\??fontclassnop#typeface}% + \letcsname\??fontclassnop#typeface\endcsname\empty \fi \fi \else % todo: message - \letvalueempty{\??fontclassnop#typeface}% + \letcsname\??fontclassnop#typeface\endcsname\empty \fi} %D Now we define: diff --git a/tex/context/interface/mkii/keys-en.xml b/tex/context/interface/mkii/keys-en.xml index 54c02665a..c7cdcfa74 100644 --- a/tex/context/interface/mkii/keys-en.xml +++ b/tex/context/interface/mkii/keys-en.xml @@ -780,6 +780,7 @@ <cd:constant name='deepnumbercommand' value='deepnumbercommand'/> <cd:constant name='deeptextcommand' value='deeptextcommand'/> <cd:constant name='default' value='default'/> + <cd:constant name='define' value='define'/> <cd:constant name='delay' value='delay'/> <cd:constant name='depth' value='depth'/> <cd:constant name='depthcorrection' value='depthcorrection'/> @@ -1380,7 +1381,6 @@ <!-- definitions for interface commands for language en --> <cd:commands> - <cd:command name='CAPPED' value='CAP'/> <cd:command name='Character' value='Character'/> <cd:command name='Characters' value='Characters'/> <cd:command name='MONTH' value='MONTH'/> @@ -2086,7 +2086,7 @@ <cd:command name='startnarrower' value='startnarrower'/> <cd:command name='startopposite' value='startopposite'/> <cd:command name='startoverlay' value='startoverlay'/> - <cd:command name='startoverzicht' value='startoverview'/> + <cd:command name='startoverview' value='startoverview'/> <cd:command name='startpacked' value='startpacked'/> <cd:command name='startpositioning' value='startpositioning'/> <cd:command name='startproduct' value='startproduct'/> @@ -2129,7 +2129,7 @@ <cd:command name='stopnarrower' value='stopnarrower'/> <cd:command name='stopopposite' value='stopopposite'/> <cd:command name='stopoverlay' value='stopoverlay'/> - <cd:command name='stopoverzicht' value='stopoverview'/> + <cd:command name='stopoverview' value='stopoverview'/> <cd:command name='stoppacked' value='stoppacked'/> <cd:command name='stoppositioning' value='stoppositioning'/> <cd:command name='stopproduct' value='stopproduct'/> diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index f27a02302..6d215d6c3 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -780,6 +780,7 @@ <cd:constant name='deepnumbercommand' value='deepnumbercommand'/> <cd:constant name='deeptextcommand' value='deeptextcommand'/> <cd:constant name='default' value='implicit'/> + <cd:constant name='define' value='define'/> <cd:constant name='delay' value='intarziere'/> <cd:constant name='depth' value='inaltime'/> <cd:constant name='depthcorrection' value='corectieadancime'/> @@ -2085,7 +2086,7 @@ <cd:command name='startnarrower' value='startingust'/> <cd:command name='startopposite' value='startopozit'/> <cd:command name='startoverlay' value='startoverlay'/> - <cd:command name='startoverzicht' value='startoverview'/> + <cd:command name='startoverview' value='startoverview'/> <cd:command name='startpacked' value='startimpachetat'/> <cd:command name='startpositioning' value='startpozitionare'/> <cd:command name='startproduct' value='startprodus'/> @@ -2128,7 +2129,7 @@ <cd:command name='stopnarrower' value='stopingust'/> <cd:command name='stopopposite' value='stopopozit'/> <cd:command name='stopoverlay' value='stopoverlay'/> - <cd:command name='stopoverzicht' value='stopoverview'/> + <cd:command name='stopoverview' value='stopoverview'/> <cd:command name='stoppacked' value='stopimpachetat'/> <cd:command name='stoppositioning' value='stoppozitionare'/> <cd:command name='stopproduct' value='stopprodus'/> diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 38dcce9aa..f84c4408f 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2020-11-23 18:34 +-- merge date : 2020-11-23 22:37 do -- begin closure to overcome local limits and interference |