diff options
Diffstat (limited to 'tex/context/base/mkxl')
23 files changed, 414 insertions, 103 deletions
diff --git a/tex/context/base/mkxl/anch-pos.lmt b/tex/context/base/mkxl/anch-pos.lmt index 07e338cb6..d3b52ad4d 100644 --- a/tex/context/base/mkxl/anch-pos.lmt +++ b/tex/context/base/mkxl/anch-pos.lmt @@ -819,7 +819,7 @@ function jobpositions.used() if positionsused == nil then positionsused = false for k, v in next, collected do - if k ~= "shared" and next(v) then + if k ~= "shared" and type(v) == "table" and next(v) then positionsused = true break end diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 0b9cb38b8..6dbbe3ccb 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{2022.04.15 20:13} +\newcontextversion{2022.04.19 19:50} %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 9ae6ef38f..a34772bbb 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. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2022.04.15 20:13} +\immutable\edef\contextversion{2022.04.19 19:50} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/lpdf-rul.lmt b/tex/context/base/mkxl/lpdf-rul.lmt index 1dfcc11a3..371549e19 100644 --- a/tex/context/base/mkxl/lpdf-rul.lmt +++ b/tex/context/base/mkxl/lpdf-rul.lmt @@ -33,6 +33,10 @@ local floor = math.floor local getrandom = utilities.randomizer.get local formatters = string.formatters +local setdimen = tex.setdimen +local setcount = tex.setcount +local setmacro = tokens.setters.macro + local codeinjections = backends.registered.pdf.codeinjections -- This is very pdf specific. Maybe move some to lpdf-rul.lua some day. @@ -82,18 +86,21 @@ FakeWord(%width%,%height%,%depth%,%line%,%color%); %initializations% FakeRule(%width%,%height%,%depth%,%line%,%color%); ]], +-- ["fake:rest"] = replacer [[ +--RuleDirection := "%direction%" ; +--RuleOption := "%option%" ; +--RuleWidth := %width% ; +--RuleHeight := %height% ; +--RuleDepth := %depth% ; +--RuleH := %h% ; +--RuleV := %v% ; +--RuleThickness := %line% ; +--RuleFactor := %factor% ; +--RuleOffset := %offset% ; +--def RuleColor = %color% enddef ; +--%data%; +-- ]] ["fake:rest"] = replacer [[ -RuleDirection := "%direction%" ; -RuleOption := "%option%" ; -RuleWidth := %width% ; -RuleHeight := %height% ; -RuleDepth := %depth% ; -RuleH := %h% ; -RuleV := %v% ; -RuleThickness := %line% ; -RuleFactor := %factor% ; -RuleOffset := %offset% ; -def RuleColor = %color% enddef ; %data%; ]] } @@ -107,21 +114,35 @@ def RuleColor = %color% enddef ; local total = ht + dp local code = (predefined[name] or predefined["fake:rest"]) { data = p.data or "", - -- width = p.width * bpfactor, - -- height = p.height * bpfactor, - -- depth = p.depth * bpfactor, - width = h * bpfactor, - height = v * bpfactor * ht / total, - depth = v * bpfactor * dp / total, - factor = (p.factor or 0) * bpfactor, -- needs checking - offset = p.offset or 0, - line = (p.line or 65536) * bpfactor, - color = mpcolor(p.ma,p.ca,p.ta), - option = p.option or "", - direction = p.direction or lefttoright_code, - h = h * bpfactor, - v = v * bpfactor, + -- -- width = p.width * bpfactor, + -- -- height = p.height * bpfactor, + -- -- depth = p.depth * bpfactor, + -- width = h * bpfactor, + -- height = v * bpfactor * ht / total, + -- depth = v * bpfactor * dp / total, + -- factor = (p.factor or 0) * bpfactor, -- needs checking + -- offset = p.offset or 0, + -- line = (p.line or 65536) * bpfactor, + -- color = mpcolor(p.ma,p.ca,p.ta), + -- option = p.option or "", + -- direction = p.direction or lefttoright_code, + -- h = h * bpfactor, + -- v = v * bpfactor, } + -- + setdimen("d_rule_width", h) + setdimen("d_rule_height", v * ht / total) + setdimen("d_rule_depth", v * dp / total) + setdimen("d_rule_h", h) + setdimen("d_rule_v", v) + setdimen("d_rule_line", p.line or 65536) + setdimen("d_rule_offset", p.offset or 0) + setmacro("m_rule_factor", p.factor or 0) + setmacro("m_rule_option", p.option or "") + setmacro("m_rule_direction", p.direction or lefttoright_code) + setmacro("m_rule_color", mpcolor(p.ma,p.ca,p.ta)) + print("!!!",mpcolor(p.ma,p.ca,p.ta)) + -- if not initialized then initialized = true simplemetapost("rulefun",formatters["randomseed := %s;"](getrandom("rulefun",0,4095))) diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index f63827906..0b3bdf54d 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -1582,7 +1582,7 @@ \permanent\protected\def\mfunctionlabeltext{\math_function_handle\mathlabeltext} \permanent\tolerant\protected\def\definemathfunction[#1]#*[#2]% - {\frozen\defcsname#1\endcsname{\math_function_handle_label{#1}{#2}}} + {\frozen\protected\defcsname#1\endcsname{\math_function_handle_label{#1}{#2}}} \protected\def\math_function_handle_label#1#2% tag settings {\begingroup diff --git a/tex/context/base/mkxl/meta-ini.mkxl b/tex/context/base/mkxl/meta-ini.mkxl index 82cf516c2..86eaea3ae 100644 --- a/tex/context/base/mkxl/meta-ini.mkxl +++ b/tex/context/base/mkxl/meta-ini.mkxl @@ -1012,9 +1012,17 @@ %D This one is not optimized because it's only used for small snippets, if it %D is used at all. +%D +%D \starttyping +%D test \MPcode {draw unitcircle scaled 1.5ExHeight} test test \MPcode [doublefun] +%D {draw unitcircle scaled 3mm shifted (0,-1mm)} test +%D \stoptyping -\permanent\tolerant\protected\def\MPcode#=#:#*#=% - {\ifparameter#1\or +\permanent\tolerant\protected\def\MPcode[#1]#:#2% + {\dontleavehmode + \begingroup + \obeyMPboxdepth + \ifparameter#1\or \meta_begin_graphic_group{#1}% \meta_enable_include \meta_process_graphic{#2}% @@ -1022,8 +1030,9 @@ \else \let\currentMPinstance\defaultMPinstance \meta_enable_include - \meta_process_graphic{#1}% - \fi} + \meta_process_graphic{#2}% + \fi + \endgroup} % a bit nasty (also needed for compatibility: diff --git a/tex/context/base/mkxl/mlib-int.lmt b/tex/context/base/mkxl/mlib-int.lmt index ae883b1e8..ace2fee17 100644 --- a/tex/context/base/mkxl/mlib-int.lmt +++ b/tex/context/base/mkxl/mlib-int.lmt @@ -16,6 +16,7 @@ local get = tex.get local emwidths = fonts.hashes.emwidths local exheights = fonts.hashes.exheights +local registerscript = metapost.registerscript local registerdirect = metapost.registerdirect local on_right_page = structures.pages.on_right @@ -169,6 +170,21 @@ registerdirect("InPageBody", in_body_page ) registerdirect("defaultcolormodel", defaultcolormodel) +-- see node-rul.* + +registerdirect("RuleWidth", function() return getdimen("d_rule_width") * factor end) +registerdirect("RuleHeight", function() return getdimen("d_rule_height") * factor end) +registerdirect("RuleDepth", function() return getdimen("d_rule_depth") * factor end) +registerdirect("RuleH", function() return getdimen("d_rule_h") * factor end) +registerdirect("RuleV", function() return getdimen("d_rule_v") * factor end) +registerdirect("RuleThickness", function() return getdimen("d_rule_line") * factor end) +registerdirect("RuleOffset", function() return getdimen("d_rule_offset") * factor end) +registerdirect("RuleDirection", function() return getmacro("c_rule_direction") end) +registerdirect("RuleFactor", function() return getmacro("m_rule_factor") end) +registerdirect("RuleOption", function() return getmacro("m_rule_option") end) +--------------("RuleColor", function() return getmacro("m_rule_color") end) +registerscript("RuleColor", function() return getmacro("m_rule_color") end) + -- see typo-ada.* registerdirect("AdaptiveWidth", function() return getdimen("d_adaptive_width") * factor end) diff --git a/tex/context/base/mkxl/mlib-pps.mkxl b/tex/context/base/mkxl/mlib-pps.mkxl index 00ab5281d..39dafb2f6 100644 --- a/tex/context/base/mkxl/mlib-pps.mkxl +++ b/tex/context/base/mkxl/mlib-pps.mkxl @@ -277,7 +277,7 @@ \permanent\protected\lettonothing\MPLIBstopgetpattern -% For now here ... will be cleaned up: +% For now here ... will be cleaned up and become macro calls instead: \newtoks\mptexttoks \newbox \mptextbox diff --git a/tex/context/base/mkxl/mult-sys.mkxl b/tex/context/base/mkxl/mult-sys.mkxl index caae5b365..71342e582 100644 --- a/tex/context/base/mkxl/mult-sys.mkxl +++ b/tex/context/base/mkxl/mult-sys.mkxl @@ -176,6 +176,7 @@ \definesystemconstant {data} \definesystemconstant {dd} \definesystemconstant {decimal} +\definesystemconstant {delay} \definesystemconstant {DefaultFont} \definesystemconstant {default} \definesystemconstant {depth} diff --git a/tex/context/base/mkxl/node-nut.lmt b/tex/context/base/mkxl/node-nut.lmt index 6fb25c313..dbc4696cc 100644 --- a/tex/context/base/mkxl/node-nut.lmt +++ b/tex/context/base/mkxl/node-nut.lmt @@ -63,6 +63,7 @@ local nuts = { effectiveglue = direct.effectiveglue, endofmath = direct.endofmath, exchange = direct.exchange, + flattenleaders = direct.flattenleaders, findattribute = direct.findattribute, findnode = direct.findnode, firstglyph = direct.firstglyph, @@ -258,6 +259,7 @@ local nuts = { traverseglyph = direct.traverseglyph, traverseid = direct.traverseid, traverselist = direct.traverselist, + traverseleader = direct.traverseleader, unprotectglyph = direct.unprotectglyph, unprotectglyphs = direct.unprotectglyphs, unsetattribute = direct.unsetattribute, diff --git a/tex/context/base/mkxl/node-res.lmt b/tex/context/base/mkxl/node-res.lmt index da4283e7f..672f3c5a5 100644 --- a/tex/context/base/mkxl/node-res.lmt +++ b/tex/context/base/mkxl/node-res.lmt @@ -597,12 +597,14 @@ do traversers.glyph = nuts.traverseglyph (glyph) traversers.list = nuts.traverselist (glyph) traversers.content = nuts.traversecontent(glyph) + traversers.leader = nuts.traverseleader (glyph) treversers.node = nuts.traverse (glyph,true) treversers.char = nuts.traversechar (glyph,true) treversers.glyph = nuts.traverseglyph (glyph,true) treversers.list = nuts.traverselist (glyph,true) treversers.content = nuts.traversecontent(glyph,true) + treversers.leader = nuts.traverseleader (glyph,true) nuts.traversers = traversers nuts.treversers = treversers diff --git a/tex/context/base/mkxl/node-rul.mkxl b/tex/context/base/mkxl/node-rul.mkxl index 231a2f32b..4f13b16f1 100644 --- a/tex/context/base/mkxl/node-rul.mkxl +++ b/tex/context/base/mkxl/node-rul.mkxl @@ -280,6 +280,19 @@ %D %D \typebuffer \getbuffer +\newdimen\d_rule_width +\newdimen\d_rule_height +\newdimen\d_rule_depth +\newdimen\d_rule_h +\newdimen\d_rule_v +\newdimen\d_rule_line +\newdimen\d_rule_offset + +\mutable\let\m_rule_direction\empty +\mutable\let\m_rule_factor \empty +\mutable\let\m_rule_option \empty +\mutable\let\m_rule_color \empty + \startuseMPgraphic{rules:under:random} draw ((0,RuleDepth) ... (RuleWidth,RuleDepth)) randomized (4*RuleThickness) diff --git a/tex/context/base/mkxl/node-tsk.lmt b/tex/context/base/mkxl/node-tsk.lmt index 197d28538..ed6b3e13b 100644 --- a/tex/context/base/mkxl/node-tsk.lmt +++ b/tex/context/base/mkxl/node-tsk.lmt @@ -778,6 +778,56 @@ nonut = [[ } +tasks.new { + name = "vboxhandlers", + processor = nodeprocessor, + sequence = { + "before", -- for users + "normalizers", + "after", -- for users + }, + templates = { + +default = [[ +return function(head) + return head +end +]], + +process = [[ +local tonut = nodes.tonut +local tonode = nodes.nuts.tonode + +%localize% + +return function(head,groupcode) + local nuthead = tonut(head) + +%actions% + return tonode(nuthead) +end +]], + +step = [[ + nuthead = tonut((%action%(tonode(nuthead),groupcode))) +]], + +nut = [[ + nuthead = %action%(nuthead,groupcode) +]], + +nohead = [[ + %action%(tonode(nuthead),groupcode) +]], + +nonut = [[ + %action%(nuthead,groupcode) +]], + + } + +} + -- these operate on the content on a line, so no injections tasks.new { diff --git a/tex/context/base/mkxl/pack-rul.mkxl b/tex/context/base/mkxl/pack-rul.mkxl index cce05e985..2ae83cb98 100644 --- a/tex/context/base/mkxl/pack-rul.mkxl +++ b/tex/context/base/mkxl/pack-rul.mkxl @@ -1029,6 +1029,44 @@ %D \defineframed[test][hoffset=1cm] %D \stoptyping +%D A byproduct of \type {\uleaders} in the 2022 math upgrade project: +%D +%D \starttyping +%D \startsetups adaptive:test:a +%D \setbox\usedadaptivebox\vbox to \usedadaptivetotal \bgroup +%D \externalfigure +%D [cow.pdf] +%D [width=\framedmaxwidth, +%D frame=on, +%D height=\usedadaptivetotal]% +%D \egroup +%D \stopsetups +%D +%D \startsetups adaptive:test:b +%D \setbox\usedadaptivebox\vbox to \usedadaptivetotal \bgroup +%D \externalfigure +%D [cow.pdf] +%D [width=\usedadaptivewidth, +%D frame=on, +%D height=\usedadaptivetotal]% +%D \egroup +%D \stopsetups +%D +%D \framed[height=18cm,align=middle,adaptive=yes,top=,bottom=] {% +%D \begstrut \samplefile{tufte} \endstrut +%D \par +%D \adaptivevbox +%D [strut=yes,setups=adaptive:test:a] +%D {\showstruts\strut\hsize5cm\hss}% +%D \par +%D \adaptivevbox +%D [strut=yes,setups=adaptive:test:b] +%D {\showstruts\strut\hsize5cm\hss}% +%D \par +%D \begstrut \samplefile{tufte} \endstrut +%D } +%D \stoptyping + \newdimen\d_framed_width \newdimen\d_framed_height \newdimen\d_framed_frameoffset @@ -1192,8 +1230,13 @@ \fi % the next check could move to heightalternative \ifconditional\c_framed_has_height - % obey user set height, also downward compatible + \ifcstok{\framedparameter\c!adaptive}\v!yes + \let\p_framed_adaptive\s!delay + \else + \let\p_framed_adaptive\empty + \fi \else + \let\p_framed_adaptive\empty \edef\p_framed_lines{\framedparameter\c!lines}% \ifempty\p_framed_lines \orelse\ifcase\p_framed_lines @@ -1278,12 +1321,12 @@ \fi \pack_framed_check_extra_offsets \edef\p_framed_background{\framedparameter\c!background}% -% \ifempty\p_framed_background -% \let\pack_framed_forgetall\forgetall -% \else -% \let\pack_framed_forgetall\relax -% \forgetall -% \fi + % \ifempty\p_framed_background + % \let\pack_framed_forgetall\forgetall + % \else + % \let\pack_framed_forgetall\relax + % \forgetall + % \fi \edef\framedwidth {\the\ifdim\d_framed_width >\zeropoint \d_framed_width \else\zeropoint\fi}% public \edef\framedheight{\the\ifdim\d_framed_height>\zeropoint \d_framed_height\else\zeropoint\fi}% public \edef\framedoffset{\the\dimexpr\ifconditional\c_framed_has_offset\localoffset \else\zeropoint\fi}% public @@ -2218,7 +2261,7 @@ \fi} \def\pack_framed_format_format_yes - {\vbox to \d_framed_height + {\vbox to \d_framed_height \p_framed_adaptive \bgroup \let\postprocessframebox\relax % \pack_framed_forgetall @@ -2423,6 +2466,9 @@ \else \clf_doreshapeframedbox \fi\b_framed_normal\relax + \ifx\p_framed_adaptive\s!delay + \adaptivecheckbox\b_framed_normal + \fi \fi} \def\pack_framed_reshape_analyze diff --git a/tex/context/base/mkxl/spac-hor.mkxl b/tex/context/base/mkxl/spac-hor.mkxl index ee9001e62..9bde93997 100644 --- a/tex/context/base/mkxl/spac-hor.mkxl +++ b/tex/context/base/mkxl/spac-hor.mkxl @@ -19,13 +19,16 @@ \aliased\let\parfillrightskip\parfillskip -\bitwiseflip \normalizelinemode \parindentskipnormalizecode \bitwiseflip \normalizelinemode \normalizelinenormalizecode +\bitwiseflip \normalizelinemode \parindentskipnormalizecode \bitwiseflip \normalizelinemode \clipwidthnormalizecode \bitwiseflip \normalizelinemode \flattendiscretionariesnormalizecode -\bitwiseflip \normalizelinemode \flattenleadersnormalizecode % neglectable overhead +\bitwiseflip \normalizelinemode \flattenhleadersnormalizecode %bitwiseflip \normalizelinemode \discardzerotabskipsnormalizecode +\bitwiseflip \normalizeparmode \normalizeparnormalizeparcode +\bitwiseflip \normalizeparmode \flattenvleadersnormalizeparcode + \let\v_spac_indentation_current\empty % amount/keyword \newdimen \d_spac_indentation_par diff --git a/tex/context/base/mkxl/spac-ver.mkxl b/tex/context/base/mkxl/spac-ver.mkxl index be7b2bf5e..12cf8c687 100644 --- a/tex/context/base/mkxl/spac-ver.mkxl +++ b/tex/context/base/mkxl/spac-ver.mkxl @@ -2368,4 +2368,26 @@ \permanent\protected\def\ignoreparskip{\c_spac_vspacing_ignore_parskip\plusone} +%D New, use with care: +%D +%D \starttyping +%D test test test \hfill\break +%D test \blankbefore test +%D test \blankbefore[2*line] test +%D test \blankbefore test +%D test test test \hfill\break +%D test \blankbefore test +%D test \blankbefore test +%D test \blankbefore test +%D test test test \hfill\break +%D test \blankafter test +%D test \blankafter test +%D test \blankafter test +%D test test test \hfill\break +%D test test test \hfill\break +%D \stoptyping + +\permanent\tolerant\protected\def\blankbefore[#1]{\vadjust pre {\ifcstok{#1}\emptytoks\blank\else\blank[#1]\fi}} +\permanent\tolerant\protected\def\blankafter [#1]{\vadjust post{\ifcstok{#1}\emptytoks\blank\else\blank[#1]\fi}} + \protect \endinput diff --git a/tex/context/base/mkxl/supp-box.mkxl b/tex/context/base/mkxl/supp-box.mkxl index ed5668ce3..ed4f1da45 100644 --- a/tex/context/base/mkxl/supp-box.mkxl +++ b/tex/context/base/mkxl/supp-box.mkxl @@ -2911,7 +2911,7 @@ %D \showboxhere 0 % always on console, less clutter %D \stoptyping -\untraced\permanent\protected\def\showboxhere{\showbox nolevels content online } +\untraced\permanent\protected\def\showboxhere{\showbox nolevels content online all } % % possible extra interface, currently disabled % diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index 3d25aa087..2bc352cf0 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -656,9 +656,17 @@ \hfuzz \maxdimen \vfuzz \maxdimen} +\permanent\protected\def\noboxtracing + {\showboxdepth \zerocount + \showboxbreadth\zerocount} + \permanent\protected\def\lessboxtracing - {\showboxdepth \plusthree - \showboxbreadth\plusfive} + {\showboxdepth \plusfive + \showboxbreadth\plusten} + +\permanent\protected\def\moreboxtracing + {\showboxbreadth\maxcount + \showboxdepth \maxcount} %D Some expected plain variants follow. We don't reuse registers because we don't %D want clashes. These will go away and packages that need them have to define them. @@ -837,8 +845,10 @@ %D When we want to see a box we can as well show all of it. -\showboxdepth \maxcount -\showboxbreadth\maxcount +% \showboxdepth \maxcount +% \showboxbreadth\maxcount + +\lessboxtracing %D Just for tracing purposes we set: diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt index 9e06dac99..3b657414a 100644 --- a/tex/context/base/mkxl/task-ini.lmt +++ b/tex/context/base/mkxl/task-ini.lmt @@ -136,7 +136,7 @@ appendaction("contributers", "normalizers", "nodes.handlers.wipe", appendaction("adjusters", "normalizers", "nodes.handlers.adjusters", nil, "nut", "enabled" ) -appendaction("vboxbuilders", "normalizers", "nodes.adaptive.handle", nil, "nut", "disabled" ) +appendaction("vboxbuilders", "normalizers", "nodes.adaptive.handlehorizontal", nil, "nut", "disabled" ) appendaction("vboxbuilders", "normalizers", "nodes.handlers.backgroundsvbox", nil, "nut", "disabled" ) ------------("vboxbuilders", "normalizers", "typesetters.margins.localhandler", nil, "nut", "disabled" ) appendaction("vboxbuilders", "normalizers", "builders.vspacing.vboxhandler", nil, "nut", "enabled" ) @@ -144,7 +144,6 @@ appendaction("vboxbuilders", "normalizers", "builders.profiling.vboxhandler", appendaction("vboxbuilders", "normalizers", "typesetters.checkers.handler", nil, "nut", "disabled" ) appendaction("vboxbuilders", "normalizers", "typesetters.synchronize.handler", nil, "nut", "disabled" ) -appendaction("mvlbuilders", "normalizers", "nodes.adaptive.handle", nil, "nut", "disabled" ) appendaction("mvlbuilders", "normalizers", "nodes.handlers.backgroundspage", nil, "nut", "disabled" ) appendaction("mvlbuilders", "normalizers", "typesetters.margins.globalhandler", nil, "nut", "disabled" ) appendaction("mvlbuilders", "normalizers", "nodes.handlers.migrate", nil, "nut", "disabled" ) @@ -153,6 +152,8 @@ appendaction("mvlbuilders", "normalizers", "builders.profiling.pagehandler", appendaction("mvlbuilders", "normalizers", "typesetters.checkers.handler", nil, "nut", "disabled" ) appendaction("mvlbuilders", "normalizers", "typesetters.synchronize.handler", nil, "nut", "disabled" ) +appendaction("vboxhandlers", "normalizers", "nodes.adaptive.handlevertical", nil, "nut", "disabled" ) + appendaction("everypar", "normalizers", "nodes.handlers.checkparcounter", nil, "nut", "disabled" ) appendaction("alignments", "normalizers", "nodes.handlers.aligncharacter", nil, "nut", "disabled" ) diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index e1d3fabf4..9377bad42 100644 --- a/tex/context/base/mkxl/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt @@ -185,7 +185,8 @@ tex.hyphenationcodes = getthem(tex.gethyphenationvalues, "hyphenationcode" tex.mathcontrolcodes = getthem(tex.getmathcontrolvalues, "mathcontrolcode") ---.mathflattencodes = getthem(tex.getmathflattenvalues, "mathflattencode") tex.noadoptioncodes = getthem(tex.getnoadoptionvalues, "") -- only at lua end -tex.normalizecodes = getthem(tex.getnormalizevalues, "normalizecode") +tex.normalizelinecodes = getthem(tex.getnormalizelinevalues, "normalizecode") -- we keep the short name +tex.normalizeparcodes = getthem(tex.getnormalizeparvalues, "normalizeparcode") tex.automigrationcodes = getthem(tex.getautomigrationvalues, "automigrationcode") -- only at lua end tex.parcontextcodes = getthem(tex.getparcontextvalues, "parcontextcode") tex.textcontrolcodes = getthem(tex.gettextcontrolvalues, "") -- only at lua end diff --git a/tex/context/base/mkxl/typo-ada.lmt b/tex/context/base/mkxl/typo-ada.lmt index 813c3ada2..17e18f01e 100644 --- a/tex/context/base/mkxl/typo-ada.lmt +++ b/tex/context/base/mkxl/typo-ada.lmt @@ -7,25 +7,33 @@ if not modules then modules = { } end modules ['typo-adj'] = { license = "see context related readme files" } -local setdimen = tex.setdimen -local setcount = tex.setcount -local setmacro = tokens.setters.macro -local expandmacro = token.expandmacro +local setdimen = tex.setdimen +local setcount = tex.setcount +local setmacro = tokens.setters.macro +local expandmacro = token.expandmacro -local nuts = nodes.nuts -local getwhd = nuts.getwhd -local getattr = nuts.getattr -local getwidth = nuts.getwidth -local setlist = nuts.setlist -local setlink = nuts.setlink -local setstate = nuts.setstate +local nuts = nodes.nuts +local getid = nuts.getid +local getlist = nuts.getlist +local getwhd = nuts.getwhd +local getattr = nuts.getattr +local getwidth = nuts.getwidth +local setlist = nuts.setlist +local setlink = nuts.setlink +local setstate = nuts.setstate +local setattr = nuts.setattr -local takebox = nuts.takebox +local hlist_code = nodes.nodecodes.hlist +local vlist_code = nodes.nodecodes.vlist -local new_kern = nuts.pool.kern +local getbox = nuts.getbox +local takebox = nuts.takebox -local traverselist = node.direct.traverselist -local traverseleader = node.direct.traverseleader +local new_kern = nuts.pool.kern + +local flattenleaders = nuts.flattenleaders +local traverselist = nuts.traverselist +local traverseleader = nuts.traverseleader local a_adaptive = attributes.private("adaptive") @@ -42,7 +50,8 @@ local enableaction = nodes.tasks.enableaction function adaptive.set(settings) if not enabled then - enableaction("vboxbuilders","nodes.adaptive.handle") + enableaction("vboxbuilders","nodes.adaptive.handlehorizontal") + enableaction("vboxhandlers","nodes.adaptive.handlevertical") enabled = true end texsetattribute(a_adaptive,registervalue(a_adaptive,settings)) @@ -58,30 +67,63 @@ end local methods = { -- overlay - [1] = function(settings,hlist,list) + [1] = function(settings,parent,list) local setups = settings.setups if setups and setups ~= "" then - local w, h, d = getwhd(hlist) + local w, h, d = getwhd(parent) setadaptive(w,h,d,settings.rulethickness,settings.color) expandmacro("setup",true,setups) local l = takebox("b_adaptive_box") if l then - setlist(hlist, setlink(l,new_kern(-getwidth(l)),list)) + setlist(parent, setlink(l,new_kern(-getwidth(l)),list)) end end end } -function adaptive.handle(n) +-- The hlist leaders get done before we enter vpacking, so that is where the +-- first call kicks in. Then we do a vpack (so one can indeed also adapt the +-- ht/dp). After packing we know the glue and do the vlist leaders. + +local function handlehorizontal(n) + if hasvalues(a_adaptive) then + for _, t, _, l in traverselist(n) do + if t == hlist_code then + for m, _, _, ll in traverseleader(l) do + local a = getattr(m,a_adaptive) + if a then + local settings = getvalue(a_adaptive,a) + if settings then + setstate(m,0) + local action = methods[settings.method or 1] + if action then + action(settings,m,ll) + end + end + end + end + end + end + end + return n +end + +local function handlevertical(n) if hasvalues(a_adaptive) then - for _, _, _, l in traverselist(n) do - for m, _, _, ll in traverseleader(l) do - local settings = getvalue(a_adaptive,getattr(m,a_adaptive)) - if settings then - setstate(m,0) - local action = methods[settings.method or 1] - if action then - action(settings,m,ll) + -- not a list just a node + for nn, t, _, l in traverselist(n) do + if t == vlist_code then + for m, _, _, ll in traverseleader(l) do + local a = getattr(m,a_adaptive) + if a then + local settings = getvalue(a_adaptive,a) + if settings then + setstate(m,0) + local action = methods[settings.method or 1] + if action then + action(settings,m,ll) + end + end end end end @@ -90,6 +132,9 @@ function adaptive.handle(n) return n end +adaptive.handlehorizontal = handlehorizontal +adaptive.handlevertical = handlevertical + interfaces.implement { name = "setadaptive", actions = adaptive.set, @@ -104,4 +149,19 @@ interfaces.implement { } } -nodes.tasks.prependaction("vboxbuilders", "normalizers", "nodes.adaptive.handle", nil, "nut", "disabled") +interfaces.implement { + name = "adaptivecheckbox", + arguments = "integer", + public = true, + protected = true, + actions = function(n) + local b = getbox(n) + if b and flattenleaders(b) > 0 then + if getid(b) == hlist_code then + handlehorizontal(b) + else + handlevertical(b) + end + end + end, +} diff --git a/tex/context/base/mkxl/typo-ada.mkxl b/tex/context/base/mkxl/typo-ada.mkxl index 6b7ce3902..e8b37997b 100644 --- a/tex/context/base/mkxl/typo-ada.mkxl +++ b/tex/context/base/mkxl/typo-ada.mkxl @@ -25,16 +25,20 @@ \newdimen\d_adaptive_height \newdimen\d_adaptive_depth \newdimen\d_adaptive_line +\newdimen\d_adaptive_hsize \mutable\let\m_adaptive_color\empty \newbox\b_adaptive_box -\aliased\let\usedadaptivewidth \d_adaptive_width -\aliased\let\usedadaptiveheight \d_adaptive_height -\aliased\let\usedadaptivedepth \d_adaptive_depth -\aliased\let\usedadaptivelinewidth\d_adaptive_linewidth -\aliased\let\usedadaptivebox \b_adaptive_box +\aliased\let\usedadaptivewidth \d_adaptive_width +\aliased\let\usedadaptiveheight\d_adaptive_height +\aliased\let\usedadaptivedepth \d_adaptive_depth +\aliased\let\usedadaptiveline \d_adaptive_line +\aliased\let\usedadaptivehsize \d_adaptive_hsize +\aliased\let\usedadaptivebox \b_adaptive_box + +\protected\untraced\def\usedadaptivetotal{\dimexpr\usedadaptiveheight+\usedadaptivedepth\relax} \definesystemattribute[adaptive][public] @@ -57,21 +61,31 @@ %\c!strut=\v!no, \c!margin=2\emwidth] -\permanent\tolerant\protected\def\adaptivebox[#1]#*[#2]% - {\dontleavehmode +\permanent\protected\def\adaptivehbox{\typo_adaptive_box\zerocount} +\permanent\protected\def\adaptivevbox{\typo_adaptive_box\plusone } + +\aliased\let\adaptivebox\adaptivehbox + +\tolerant\def\typo_adaptive_box#1#*[#2]#*[#3]% + {\ifcase#1\dontleavehmode\fi \begingroup - \ifhastok={#1}% + \ifhastok={#2}% \let\currentadaptive\empty - \setupcurrentadaptive[#1]% - \else - \edef\currentadaptive{#1}% \setupcurrentadaptive[#2]% + \else + \edef\currentadaptive{#2}% + \setupcurrentadaptive[#3]% \fi \edef\p_setups{\adaptiveparameter\c!setups}% \dowithnextboxcontent {\useadaptivestyleandcolor\c!foregroundstyle\c!foregroundcolor - \ifcstok{\adaptiveparameter\c!strut}\v!yes\strut\fi % for now - } + \ifcstok{\adaptiveparameter\c!strut}\v!yes + \ifcase#1% + \strut + \else + % maybe \begstrut .. \endstrut + \fi + \fi} {\ifempty\p_setups % there is no need for postprocessing \else @@ -86,17 +100,26 @@ \edef\p_stretch{\adaptiveparameter\c!stretch}% \edef\p_shrink {\adaptiveparameter\c!shrink}% \uleaders - \hbox - \s!spread \scratchdimen - \bgroup - \hss\box\nextbox\hss - \egroup - \hskip + \ifcase#1% + \hbox + \s!spread \scratchdimen + \bgroup + \hss\box\nextbox\hss + \egroup + \hskip + \else + \vbox + \s!spread \scratchdimen + \bgroup + \vss\box\nextbox\vss + \egroup + \vskip + \fi \zeropoint \s!plus \ifempty\p_stretch\scratchdimen\else\p_stretch\fi \s!minus \ifempty\p_shrink \scratchdimen\else\p_shrink \fi \endgroup}% - \hbox} + \ifcase#1\hbox\else\vbox\fi} %D Here is a test case, expect more: %D @@ -170,6 +193,24 @@ %D } %D \blank %D } +%D +%D \page +%D +%D \startsetups adaptive:test +%D \setbox\usedadaptivebox\vbox to \usedadaptivetotal \bgroup +%D \externalfigure +%D [cow.pdf] +%D [width=\usedadaptivewidth, +%D height=\usedadaptivetotal]% +%D \egroup +%D \stopsetups +%D +%D \ruledvbox to \textheight { +%D \par \begstrut \samplefile{tufte} \endstrut \par +%D \adaptivevbox[strut=yes,setups=adaptive:test]{\hsize\textwidth\hss} +%D \par \begstrut \samplefile{tufte} \endstrut +%D } +%D %D \stoptyping \protect diff --git a/tex/context/base/mkxl/typo-bld.lmt b/tex/context/base/mkxl/typo-bld.lmt index ae644d297..1a581e118 100644 --- a/tex/context/base/mkxl/typo-bld.lmt +++ b/tex/context/base/mkxl/typo-bld.lmt @@ -199,13 +199,13 @@ end) nodes.builders = nodes.builder or { } local builders = nodes.builders -local vboxactions = nodes.tasks.actions("vboxbuilders") +local vpackactions = nodes.tasks.actions("vboxbuilders") function builders.vpack_filter(head,groupcode,size,packtype,maxdepth,direction) local done = false if head then starttiming(builders) - head, done = vboxactions(head,groupcode) + head, done = vpackactions(head,groupcode) stoptiming(builders) end return head, done @@ -249,6 +249,19 @@ end registercallback('vpack_filter', builders.vpack_filter, "vertical spacing etc") registercallback('buildpage_filter', builders.buildpage_filter, "vertical spacing etc (mvl)") +local vboxactions = nodes.tasks.actions("vboxhandlers") + +function builders.vbox_filter(head,groupcode) + if head then + starttiming(builders) + head = vboxactions(head,groupcode) + stoptiming(builders) + end + return head +end + +registercallback('packed_vbox_filter', builders.vbox_filter, "packed vbox treatments") + statistics.register("v-node processing time", function() return statistics.elapsedseconds(builders) end) |