From c6ae1bb6230894346094364eb08d3aca0efdea9a Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 2 Jul 2021 14:01:19 +0200 Subject: 2021-07-02 13:18:00 --- tex/context/base/mkxl/cont-new.mkxl | 2 +- tex/context/base/mkxl/context.mkxl | 2 +- tex/context/base/mkxl/font-fil.mklx | 2 +- tex/context/base/mkxl/lang-dis.lmt | 22 ++++ tex/context/base/mkxl/luat-ini.mkxl | 28 ++++- tex/context/base/mkxl/mlib-lmt.lmt | 56 +++++----- tex/context/base/mkxl/mlib-scn.lmt | 207 +++++++++++++++++++----------------- tex/context/base/mkxl/page-cst.mkxl | 1 - tex/context/base/mkxl/page-mcl.mkxl | 3 +- tex/context/base/mkxl/page-sid.mkxl | 8 +- 10 files changed, 192 insertions(+), 139 deletions(-) (limited to 'tex/context/base/mkxl') diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index db941e888..d977c4982 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{2021.06.30 19:17} +\newcontextversion{2021.07.02 13:15} %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 529d2cb2e..a509a9205 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{2021.06.30 19:17} +\immutable\edef\contextversion{2021.07.02 13:15} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/font-fil.mklx b/tex/context/base/mkxl/font-fil.mklx index 57ed47fa2..b71f8df69 100644 --- a/tex/context/base/mkxl/font-fil.mklx +++ b/tex/context/base/mkxl/font-fil.mklx @@ -379,6 +379,6 @@ % bonus -% \currentfontinstancespec % define ad the lua end +% \currentfontinstancespec % defined at the lua end \protect \endinput diff --git a/tex/context/base/mkxl/lang-dis.lmt b/tex/context/base/mkxl/lang-dis.lmt index 1236ba749..5c4ab1e34 100644 --- a/tex/context/base/mkxl/lang-dis.lmt +++ b/tex/context/base/mkxl/lang-dis.lmt @@ -26,6 +26,7 @@ local getsubtype = nuts.getsubtype local setsubtype = nuts.setsubtype local getchar = nuts.getchar local setchar = nuts.setchar +local getdiscpart = nuts.getdiscpart local getdisc = nuts.getdisc local setdisc = nuts.setdisc local getlanguage = nuts.getlanguage @@ -39,6 +40,7 @@ local remove_node = nuts.remove ----- flushnode = nuts.flushnode local nextdisc = nuts.traversers.disc +local nextglyph = nuts.traversers.glyph local new_disc = nuts.pool.disc @@ -48,6 +50,12 @@ local disccodes = nodes.disccodes local disc_code = nodecodes.disc local glyph_code = nodecodes.glyph +local discoptioncodes = tex.discoptioncodes +local pre_part_code = discoptioncodes.pre +local post_part_code = discoptioncodes.post +local replace_part_code = discoptioncodes.replace +local always_part_code = discoptioncodes.always + local explicitdisc_code = disccodes.explicit local a_visualize = attributes.private("visualizediscretionary") @@ -76,6 +84,20 @@ function languages.visualizediscretionaries(head) end end end + for g in nextglyph, head do + if getattr(g,a_visualize) then + local c = getdiscpart(g) + if c == pre_part_code then + setlistcolor(g,"darkmagenta") + elseif c == post_part_code then + setlistcolor(g,"darkcyan") + elseif c == replace_part_code then + setlistcolor(g,"darkyellow") + elseif c == always_part_code then + setlistcolor(g,"darkgray") + end + end + end return head end diff --git a/tex/context/base/mkxl/luat-ini.mkxl b/tex/context/base/mkxl/luat-ini.mkxl index 98095a4de..d1a84f60c 100644 --- a/tex/context/base/mkxl/luat-ini.mkxl +++ b/tex/context/base/mkxl/luat-ini.mkxl @@ -59,8 +59,32 @@ %D It is nicer for checking with \type {s-system-macros} if we have some meaning: \pushoverloadmode - % \aliased\let\-\explicitdiscretionary - \permanent\protected\def\-{\begingroup\hyphenationmode\explicithyphenationmodecode\explicitdiscretionary\endgroup} + + % We anyway need this: + + \permanent\protected\def\superexplicitdiscretionary + {\begingroup + \hyphenationmode\explicithyphenationmodecode\explicitdiscretionary + \endgroup} + + % Conceptually the best: + + \aliased\let\-\explicitdiscretionary + + % But we could do this to be compatible: + + % \permanent\protected\def\-{\begingroup\hyphenationmode\explicithyphenationmodecode\explicitdiscretionary\endgroup} + + % Or maybe even this: + + % \aliased\let\lang_explicit_discretionary_nop\explicitdiscretionary + % + % \permanent\protected\def\lang_explicit_discretionary_yes-% + % {\superexplicitdiscretionary} + % + % \permanent\protected\def\-% + % {\doifelsenextcharcs-\lang_explicit_discretionary_yes\lang_explicit_discretionary_nop} + \popoverloadmode \ifdefined\n \else \mutable\def\n{n} \fi \ifdefined\r \else \mutable\def\r{r} \fi diff --git a/tex/context/base/mkxl/mlib-lmt.lmt b/tex/context/base/mkxl/mlib-lmt.lmt index 651a98be5..55485e5f8 100644 --- a/tex/context/base/mkxl/mlib-lmt.lmt +++ b/tex/context/base/mkxl/mlib-lmt.lmt @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['mlib-lmt'] = { -- todo: check for possible inject usage local type = type -local round = math.round +local round, abs = math.round, math.abs local aux = mp.aux local mpdirect = aux.direct @@ -154,44 +154,36 @@ todecimal = xdecimal and xdecimal.new or tonumber -- bonus -- mail on list by Mikael Sundqvist and Taco's analysis of near duplicate points (2021/02/11+) registerscript("scrutenized", function() - local p = scanpath() - local d = 10^scannumeric() - for i=1,#p do - local pi = p[i] - pi[1] = round(pi[1] * d) / d - pi[2] = round(pi[2] * d) / d - end - local x1 = round(p[1][1]) - local y1 = round(p[1][2]) - local n = 1 - local m = #p - local t = { p[1], cycle = p.cycle } - for i=2,m-1 do - local pi = p[i] - local x2 = round(pi[1]) - local y2 = round(pi[2]) - if x1 ~= x2 or y1 ~= y2 then - n = n + 1 - t[n] = p[i] - x1 = x2 - y1 = y2 + local pth = scanpath() + local d = 1/10^scannumeric() -- decimals + local p1 = pth[1] + local x1 = p1[1] + local y1 = p1[2] + local res = { pth[1] } + local r = 1 + for i=2,#pth do + local pi = pth[i] + x2 = pi[1] + y2 = pi[2] + if abs(x1-x2) > d or abs(y1-y2) > d then + r = r + 1 res[r] = pi end + x1 = x2 + y1 = y2 end - local x1 = round(p[1][1]) - local y1 = round(p[1][2]) - local x2 = round(p[m][1]) - local y2 = round(p[m][2]) - if x1 ~= x2 or y1 ~= y2 then - n = n + 1 - t[n] = p[m] + if pth.cycle then + res.cycle = true + if abs(x1-p1[1]) > d or abs(y1-p1[2]) > d then + -- keep + else + res[r] = nil + end end - -- mp.path(t) - injectpath(t) + injectpath(res) end) -- A goodie, mostly a side effect of updating the metafun manual. - local labtorgb = attributes.colors.labtorgb registerscript("labtorgb", function() diff --git a/tex/context/base/mkxl/mlib-scn.lmt b/tex/context/base/mkxl/mlib-scn.lmt index 1d6514a0b..4f76ca545 100644 --- a/tex/context/base/mkxl/mlib-scn.lmt +++ b/tex/context/base/mkxl/mlib-scn.lmt @@ -767,129 +767,144 @@ end -- This is an experiment for Alan and me. -local records = { } -local stack = setmetatableindex("table") -local nofrecords = 0 -local interim = 0 - -registerdirect("newrecord", function() - scantoken() -- semicolon - local p = get_parameters() - local n = 0 - if interim > 0 then - records[interim] = p - local top = stack[interim] - if top then - top = stack[interim][#top] +do + + local records = { } + local stack = setmetatableindex("table") + local nofrecords = 0 + local interim = 0 + local names = { } + -- local types = { } + + registerdirect("newrecord", function() + scantoken() -- semicolon + local p = get_parameters() + local n = 0 + if interim > 0 then + records[interim] = p + local top = stack[interim] if top then - setmetatableindex(p,top) + top = stack[interim][#top] + if top then + setmetatableindex(p,top) + end end + n = interim + interim = 0 + else + nofrecords = nofrecords + 1 + records[nofrecords] = p + n = nofrecords end - n = interim - interim = 0 - else - nofrecords = nofrecords + 1 - records[nofrecords] = p - n = nofrecords - end - return n -end) - -local function merge(old,new) - for knew, vnew in next, new do - local vold = old[knew] - if vold then - if type(vnew) == "table" then - if type(vold) == "table" then - merge(vold,vnew) + return n + end) + + local function merge(old,new) + for knew, vnew in next, new do + local vold = old[knew] + if vold then + if type(vnew) == "table" then + if type(vold) == "table" then + merge(vold,vnew) + else + old[knew] = vnew + end else old[knew] = vnew end else old[knew] = vnew end - else - old[knew] = vnew end end -end -registerdirect("setrecord", function() - scantoken() -- semicolon - local p = get_parameters() - local n = 0 - if interim > 0 then - local r = records[interim] - if r then - merge(r,p) - else - records[interim] = p - end - local top = stack[interim] - if top then - top = stack[interim][#top] + registerdirect("setrecord", function() + scantoken() -- semicolon + local p = get_parameters() + local n = 0 + if interim > 0 then + local r = records[interim] + if r then + merge(r,p) + else + records[interim] = p + end + local top = stack[interim] if top then - setmetatableindex(p,top) + top = stack[interim][#top] + if top then + setmetatableindex(p,top) + end end + n = interim + interim = 0 + else + nofrecords = nofrecords + 1 + records[nofrecords] = p + n = nofrecords end - n = interim - interim = 0 - else - nofrecords = nofrecords + 1 - records[nofrecords] = p - n = nofrecords - end - return n -end) + return n + end) -registerdirect("getrecord", function() - local n = scaninteger() - local v = records[n] - while true do - local t = scansymbol(true) - if t == ";" or t == ")" or t == ":" then - return v - elseif t == "." then - scansymbol() - elseif t == "#" or t == "##" then -- from tex's we get a double - scansymbol() - t = scansymbol() - v = v[t] - return type(v) == "table" and #v or 0 - elseif t == "[" then - scansymbol() - t = scansymbol(true) - if t == "]" then + registerdirect("getrecord", function() + local n = scaninteger() + local v = records[n] + while true do + local t = scansymbol(true) + if t == ";" or t == ")" or t == ":" then + return v + elseif t == "." then scansymbol() - return #v - else - t = scaninteger() + elseif t == "#" or t == "##" then -- from tex's we get a double + scansymbol() + t = scansymbol() v = v[t] - if scansymbol(true) == "]" then + return type(v) == "table" and #v or 0 + elseif t == "[" then + scansymbol() + t = scansymbol(true) + if t == "]" then scansymbol() + return #v else - report("] expected") + t = scaninteger() + v = v[t] + if scansymbol(true) == "]" then + scansymbol() + else + report("] expected") + end end + else + t = scansymbol() + v = v[t] end - else - t = scansymbol() - v = v[t] + end + end) + + function metapost.getrecord(name) + local index = names[name] + if index then + return records[index] end end -end) -function metapost.runinternal(action,index,kind) - if action == 0 then - -- allocate - elseif action == 1 then - -- save - insert(stack[index],records[index]) - interim = index - elseif action == 2 then - -- restore - records[index] = remove(stack[index]) or records[index] + function metapost.runinternal(action,index,kind,name) + if action == 0 then + -- allocate + names[name] = index + -- types[index] = kind + elseif action == 1 then + -- save + insert(stack[index],records[index]) + interim = index + elseif action == 2 then + -- restore + records[index] = remove(stack[index]) or records[index] + end end + end -- goodies diff --git a/tex/context/base/mkxl/page-cst.mkxl b/tex/context/base/mkxl/page-cst.mkxl index 0afc2a645..12ee0bd38 100644 --- a/tex/context/base/mkxl/page-cst.mkxl +++ b/tex/context/base/mkxl/page-cst.mkxl @@ -255,7 +255,6 @@ \fi \endgroup} - \protected\def\page_grd_command_set_vsize {\clf_setvsizecolumnset{\currentpagegrid}% \ifdim\d_page_grd_gap_height<\lineheight diff --git a/tex/context/base/mkxl/page-mcl.mkxl b/tex/context/base/mkxl/page-mcl.mkxl index d36e76d94..e88371da1 100644 --- a/tex/context/base/mkxl/page-mcl.mkxl +++ b/tex/context/base/mkxl/page-mcl.mkxl @@ -125,6 +125,7 @@ \fi \fi \c_page_mcl_n_of_lines\noflines} + % \protected\def\page_mcl_command_set_vsize % {%%\page_one_command_set_vsize % indeed? % \page_mcl_set_n_of_lines\zeropoint @@ -187,7 +188,7 @@ {\scratchdimen\dimexpr \d_page_mcl_saved_pagetotal -\d_page_mcl_preceding_height - -\topskip + % -\topskip % no, this is already part of the saved total \relax \box\b_page_mcl_preceding \kern\scratchdimen} diff --git a/tex/context/base/mkxl/page-sid.mkxl b/tex/context/base/mkxl/page-sid.mkxl index fd9f6837a..dccfcbce9 100644 --- a/tex/context/base/mkxl/page-sid.mkxl +++ b/tex/context/base/mkxl/page-sid.mkxl @@ -472,10 +472,10 @@ \installcorenamespace{sidefloatsteps} -\setvalue{\??sidefloatsteps\v!line }{\strut} -\setvalue{\??sidefloatsteps\v!big }{\strut} -\setvalue{\??sidefloatsteps\v!medium}{\halflinestrut} % was \halfstrut -\setvalue{\??sidefloatsteps\v!small }{\noheightstrut} % was \quarterstrut +\defcsname\??sidefloatsteps\v!line \endcsname{\strut} +\defcsname\??sidefloatsteps\v!big \endcsname{\strut} +\defcsname\??sidefloatsteps\v!medium\endcsname{\halflinestrut} % was \halfstrut +\defcsname\??sidefloatsteps\v!small \endcsname{\noheightstrut} % was \quarterstrut \def\page_sides_flush_floats_tracer {\dontleavehmode -- cgit v1.2.3