diff options
author | Hans Hagen <pragma@wxs.nl> | 2021-02-18 11:28:41 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2021-02-18 11:28:41 +0100 |
commit | 298afdcdcb9d3c88fcc9abdbf17ac66f2f5006a1 (patch) | |
tree | 44bbefa57072479622fa253684ec3cb96258255f /tex/context/base/mkxl | |
parent | 84aae20fa32c9a50ae1c63576573f52d010de43b (diff) | |
download | context-298afdcdcb9d3c88fcc9abdbf17ac66f2f5006a1.tar.gz |
2021-02-18 10:24:00
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r-- | tex/context/base/mkxl/anch-bck.mklx | 39 | ||||
-rw-r--r-- | tex/context/base/mkxl/anch-pgr.lmt | 105 | ||||
-rw-r--r-- | tex/context/base/mkxl/catc-ini.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-new.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/context.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-ini.lmt | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-ini.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-cnt.lmt | 10 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-ctx.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-lmp.lmt | 14 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-sec.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-inf.lmt | 2 |
12 files changed, 112 insertions, 72 deletions
diff --git a/tex/context/base/mkxl/anch-bck.mklx b/tex/context/base/mkxl/anch-bck.mklx index c8f989624..36416c93d 100644 --- a/tex/context/base/mkxl/anch-bck.mklx +++ b/tex/context/base/mkxl/anch-bck.mklx @@ -11,6 +11,9 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +% when tested for a while: \MPgetmultipars -> getmultipars +% when tested for a while: \MPvar -> mpvar + \writestatus{loading}{ConTeXt Anchoring Macros / Backgrounds} %D This module is quite okay but at some point I might add methods that use @@ -595,6 +598,7 @@ \startMPpositiongraphic{mpos:region}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius,lineoffset} \includeMPgraphic{mpos:region:setup} ; \includeMPgraphic{mpos:region:extra} ; + % \getmultipars("self","anchor") ; \MPgetmultipars{\MPvar{self}}{\MPanchorid} ; \includeMPgraphic{\MPvar{mp}} ; \includeMPgraphic{mpos:region:anchor} ; @@ -666,13 +670,21 @@ lineoffset=5pt, linewidth=1pt] +% \startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth,lineoffset} +% getposboxes("self","anchor") ; +% if nofposboxes = 1 : +% posboxes[1] := posboxes[1] enlarged \MPvar{lineoffset} cornered \MPvar{lineoffset} ; +% fill posboxes[1] withcolor \MPvar{fillcolor} ; +% draw posboxes[1] withpen pencircle scaled \MPvar{linewidth} withcolor \MPvar{linecolor} ; +% fi ; +% \stopMPpositiongraphic + \startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth,lineoffset} - \MPgetposboxes{\MPvar{self}}{\MPanchorid} - % getposboxes("self","anchor") ; + getposboxes("self","anchor") ; if nofposboxes = 1 : - posboxes[1] := posboxes[1] enlarged \MPvar{lineoffset} cornered \MPvar{lineoffset} ; - fill posboxes[1] withcolor \MPvar{fillcolor} ; - draw posboxes[1] withpen pencircle scaled \MPvar{linewidth} withcolor \MPvar{linecolor} ; + posboxes[1] := (posboxes[1] enlarged mpvar "lineoffset") cornered mpvar "lineoffset" ; + fill posboxes[1] withcolor mpvar "fillcolor" ; + draw posboxes[1] withpen pencircle scaled mpvar "linewidth" withcolor mpvar "linecolor" ; fi ; \stopMPpositiongraphic @@ -682,12 +694,19 @@ lineoffset=.25ex, linewidth=1pt] +% \startMPpositiongraphic{mpos:connect}{linecolor,lineoffset,linewidth} +% boxlinewidth := \MPvar{linewidth} ; +% boxlineoffset := \MPvar{lineoffset} ; +% def boxlineoptions = withcolor \MPvar{linecolor} enddef ; +% getposboxes("from,to","anchor") ; +% connect_positions ; +% \stopMPpositiongraphic + \startMPpositiongraphic{mpos:connect}{linecolor,lineoffset,linewidth} - boxlinewidth := \MPvar{linewidth} ; - boxlineoffset := \MPvar{lineoffset} ; - def boxlineoptions = withcolor \MPvar{linecolor} enddef ; - \MPgetposboxes{\MPvar{from},\MPvar{to}}{\MPanchorid} - % getposboxes("from,to","anchor") ; + boxlinewidth := mpvar "linewidth" ; + boxlineoffset := mpvar "lineoffset" ; + def boxlineoptions = withcolor mpvar "linecolor" enddef ; + getposboxes("from,to","anchor") ; connect_positions ; \stopMPpositiongraphic diff --git a/tex/context/base/mkxl/anch-pgr.lmt b/tex/context/base/mkxl/anch-pgr.lmt index 0cf9ea9e4..5b750d80e 100644 --- a/tex/context/base/mkxl/anch-pgr.lmt +++ b/tex/context/base/mkxl/anch-pgr.lmt @@ -24,6 +24,7 @@ local lpegmatch = lpeg.match local jobpositions = job.positions local formatters = string.formatters local setmetatableindex = table.setmetatableindex +local settings_to_array = utilities.parsers.settings_to_array local enableaction = nodes.tasks.enableaction @@ -33,6 +34,8 @@ local context = context local implement = interfaces.implement local getmacro = tokens.getters.macro +local scanmpstring = mp.scan.string +local mpgnamespace = getmacro("??graphicvariable") local report_graphics = logs.reporter("backgrounds") local report_shapes = logs.reporter("backgrounds","shapes") @@ -57,6 +60,12 @@ graphics = graphics or { } local backgrounds = { } graphics.backgrounds = backgrounds +-- -- -- these can go -- -- -- + +backgrounds.point = f_point +backgrounds.pair = f_pair +backgrounds.path = f_path + -- -- -- local texsetattribute = tex.setattribute @@ -1183,9 +1192,29 @@ end backgrounds.fetchmultipar = fetchmultipar -backgrounds.point = f_point -backgrounds.pair = f_pair -backgrounds.path = f_path +local function getwhatever(action) + local tags = scanmpstring() + local anchor = scanmpstring() + local page = nil + if tags == "self" then + tags = getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":self",true) -- Isn't it already edef'd? + elseif type(tags) == "string" then + tags = settings_to_array(tags) + for i=1,#tags do + tags[i] = getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. tags[i],true) -- Isn't it already edef'd? + end + end + if anchor == "anchor" then + anchor = getmacro("MPanchorid") -- brrr + end + if tags and anchor then + return action(tags,anchor,page) + end +end + +metapost.registerscript("getmultipars", function() + return getwhatever(fetchmultipar) +end) -- n anchor page @@ -1199,8 +1228,6 @@ implement { do - local scanstring = mp.scan.string - local f_template_a = formatters[ [[ path posboxes[], posregions[] ; numeric pospages[] ; @@ -1218,7 +1245,7 @@ do local function getposboxes(tags,anchor,page) -- no caching (yet) / page local collected = jobpositions.collected if type(tags) == "string" then - tags = utilities.parsers.settings_to_array(tags) + tags = settings_to_array(tags) end local list = { } local nofboxes = 0 @@ -1258,32 +1285,8 @@ do return f_template_a(nofboxes,list) end - local namespace - - -- metapost.registerscript("var", function() - -- local name = scanstring() - -- if not namespace then - -- namespace = getmacro("??graphicvariable") - -- end - -- return getmacro(namespace .. getmacro("currentmpvariableclass") .. ":" .. name) - -- end - metapost.registerscript("getposboxes", function() - local tags = scanstring() - local anchor = scanstring() - local page = nil - if tags == "self" then - if not namespace then - namespace = getmacro("??graphicvariable") - end - tags = getmacro(namespace .. getmacro("currentmpvariableclass") .. ":self") - end - if anchor == "anchor" then - anchor = getmacro("MPanchorid") -- brrr - end - if tags and anchor then - return getposboxes(tags,anchor,page) - end + return getwhatever(getposboxes) end) implement { @@ -1294,25 +1297,29 @@ do end -local doifelse = commands.doifelse +do -implement { - name = "doifelserangeonpage", - arguments = { "string", "string", "integer" }, - actions = function(first,last,page) - local c = jobpositions.collected - local f = c[first] - if f then - f = f.p - if f and f ~= true and page >= f then - local l = c[last] - if l then - l = l.p - doifelse(l and l ~= true and page <= l) - return + local doifelse = commands.doifelse + + implement { + name = "doifelserangeonpage", + arguments = { "string", "string", "integer" }, + actions = function(first,last,page) + local c = jobpositions.collected + local f = c[first] + if f then + f = f.p + if f and f ~= true and page >= f then + local l = c[last] + if l then + l = l.p + doifelse(l and l ~= true and page <= l) + return + end end end + doifelse(false) end - doifelse(false) - end -} + } + +end diff --git a/tex/context/base/mkxl/catc-ini.mkxl b/tex/context/base/mkxl/catc-ini.mkxl index 7f1a89f6c..5b33db981 100644 --- a/tex/context/base/mkxl/catc-ini.mkxl +++ b/tex/context/base/mkxl/catc-ini.mkxl @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\registerctxluafile{catc-ini}{} +\registerctxluafile{catc-ini}{autosuffix} \unprotect diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 13ddba0fd..6f7a14b13 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.02.17 13:30} +\newcontextversion{2021.02.18 10:21} %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 68860f7e5..89cf5654a 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.02.17 13:30} +\immutable\edef\contextversion{2021.02.18 10:21} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/luat-ini.lmt b/tex/context/base/mkxl/luat-ini.lmt index cec0161e7..3bfd191b9 100644 --- a/tex/context/base/mkxl/luat-ini.lmt +++ b/tex/context/base/mkxl/luat-ini.lmt @@ -39,7 +39,7 @@ JITSUPPORTED = LUATEXENGINE == "luajittex" or jit INITEXMODE = status.ini_version -CONTEXTLMTXMODE = CONTEXTLMTXMODE or (LUATEXENGINE == "luametatex" and 1) or 0 +CONTEXTLMTXMODE = 1 function os.setlocale() -- no need for a message diff --git a/tex/context/base/mkxl/meta-ini.mkxl b/tex/context/base/mkxl/meta-ini.mkxl index 2100912d7..823d369f0 100644 --- a/tex/context/base/mkxl/meta-ini.mkxl +++ b/tex/context/base/mkxl/meta-ini.mkxl @@ -500,7 +500,7 @@ \let \m_meta_current_variable \empty \let \m_meta_current_variable_template\empty -\installcorenamespace{graphicvariable} +% \installcorenamespace{graphicvariable} % already set \def\meta_prepare_variable_default{\MPcolor{black}} % just to be sure we use a color but ... diff --git a/tex/context/base/mkxl/mlib-cnt.lmt b/tex/context/base/mkxl/mlib-cnt.lmt index 667384ed7..bddcb33b8 100644 --- a/tex/context/base/mkxl/mlib-cnt.lmt +++ b/tex/context/base/mkxl/mlib-cnt.lmt @@ -53,7 +53,8 @@ local bor = bit32.bor -- it's really time to ditch support for luajit local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming -local elapsedtime = statistics.elapsedtime +local resettiming = statistics.resettiming +local elapsedtiming = statistics.elapsed local formatters = string.formatters local setmetatableindex = table.setmetatableindex @@ -250,6 +251,7 @@ end function mp.lmt_contours_start() + resettiming("lmt_contours") starttiming("lmt_contours") nofcontours = nofcontours + 1 @@ -546,14 +548,12 @@ end function mp.lmt_contours_stop() local p = getparameterset() - local e = stoptiming("lmt_contours") + stoptiming("lmt_contours") setcache(p) p.result = nil local f = p["function"] local l = p.functions - report("index %i, %0.3f seconds for: %s", - nofcontours, e, "[ " .. concat(l or { f } ," ] [ ") .. " ]" - ) + report("index %i, %0.3f seconds for: %s", nofcontours, elapsedtiming("lmt_contours"), "[ " .. concat(l or { f } ," ] [ ") .. " ]") end function mp.lmt_contours_bitmap_set() diff --git a/tex/context/base/mkxl/mlib-ctx.mkxl b/tex/context/base/mkxl/mlib-ctx.mkxl index 81fbffa85..fb069b6ea 100644 --- a/tex/context/base/mkxl/mlib-ctx.mkxl +++ b/tex/context/base/mkxl/mlib-ctx.mkxl @@ -13,6 +13,8 @@ \writestatus{loading}{MetaPost Library Graphics / Initializations} +\installcorenamespace{graphicvariable} + \registerctxluafile{mlib-fio}{autosuffix} \registerctxluafile{mlib-run}{autosuffix} \registerctxluafile{mlib-ctx}{autosuffix} diff --git a/tex/context/base/mkxl/mlib-lmp.lmt b/tex/context/base/mkxl/mlib-lmp.lmt index 19288b32b..2b3e910ba 100644 --- a/tex/context/base/mkxl/mlib-lmp.lmt +++ b/tex/context/base/mkxl/mlib-lmp.lmt @@ -88,3 +88,17 @@ registerscript("showhashentry", function() end end end) + +local getmacro = tokens.getters.macro +local mpgnamespace = getmacro("??graphicvariable") + +local scanmpstring = mp.scan.string + +local injectnumeric = mp.inject.numeric +local injectstring = mp.inject.string + +-- registerscript("mpv_numeric", function() injectnumeric (getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. scanmpstring())) end) +-- registerscript("mpv_dimension", function() return getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. scanmpstring()) end) +-- registerscript("mpv_string", function() injectstring (getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. scanmpstring())) end) + +registerscript("mpvar", function() return getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. scanmpstring(), true) end) -- Isn't it already edef'd? diff --git a/tex/context/base/mkxl/strc-sec.mkxl b/tex/context/base/mkxl/strc-sec.mkxl index 4e6464db4..7a3a64875 100644 --- a/tex/context/base/mkxl/strc-sec.mkxl +++ b/tex/context/base/mkxl/strc-sec.mkxl @@ -179,7 +179,7 @@ \glet\currentstructurecoding\s!tex \fi \iflocation \ifempty\currentstructurebookmark \orelse \ifx\currentstructurebookmark\currentstructuretitle \else - \showmessage\m!structures3{\currentstructurebookmark}% + \showmessage\m!structures3{{\currentstructurebookmark}}% \fi \fi \setnextinternalreference \storeinternalreference\currentstructurename{\the\locationcount}% diff --git a/tex/context/base/mkxl/trac-inf.lmt b/tex/context/base/mkxl/trac-inf.lmt index 301a56e9b..ebcd21e07 100644 --- a/tex/context/base/mkxl/trac-inf.lmt +++ b/tex/context/base/mkxl/trac-inf.lmt @@ -78,10 +78,8 @@ local function stoptiming(instance) timer.loadtime = timer.loadtime + loadtime timer.timing = 0 timer.starttime = 0 - return loadtime end end - return 0 end local function benchmarktimer(instance) |