diff options
Diffstat (limited to 'tex/context/base/mkxl')
-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/meta-fig.mkxl | 5 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-ini.mkxl | 110 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-pdf.lmt | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-pps.lmt | 33 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-ini.mkxl | 84 |
7 files changed, 210 insertions, 28 deletions
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 4fec9a7f9..974b7c4df 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.07.09 18:13} +\newcontextversion{2021.07.10 21:47} %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 4339426be..efba80182 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.07.09 18:13} +\immutable\edef\contextversion{2021.07.10 21:47} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/meta-fig.mkxl b/tex/context/base/mkxl/meta-fig.mkxl index b8a22f6fe..8348dfbaf 100644 --- a/tex/context/base/mkxl/meta-fig.mkxl +++ b/tex/context/base/mkxl/meta-fig.mkxl @@ -42,13 +42,16 @@ [MPpage] [\c!align=, \c!command=\meta_process_graphic_command, + \c!stacking=, \c!instance=] \permanent\protected\def\setupMPpage {\setupfittingpage[MPpage]} \protected\def\meta_process_graphic_command - {\meta_process_graphic_instance{\fittingpageparameter\c!instance}} + {\meta_process_graphic_instance + {\fittingpageparameter\c!instance}% + {\fittingpageparameter\c!stacking}} %D \macros %D {MPfigure} diff --git a/tex/context/base/mkxl/meta-ini.mkxl b/tex/context/base/mkxl/meta-ini.mkxl index def3900fe..8fca5d503 100644 --- a/tex/context/base/mkxl/meta-ini.mkxl +++ b/tex/context/base/mkxl/meta-ini.mkxl @@ -279,11 +279,12 @@ \meta_relocate_graphic \popMPboundingbox} -\protected\def\meta_process_graphic_instance#1% +\protected\def\meta_process_graphic_instance#1#2% used in startMPpage {\edef\currentMPinstance{#1}% \ifempty\currentMPinstance \let\currentMPinstance\defaultMPinstance \fi + \setmpcategoryparameter\c!stacking{#2}% \edef\currentMPformat{\MPinstanceparameter\s!format}% \meta_process_graphic} @@ -302,7 +303,7 @@ inclusions {\meta_flush_current_inclusions}% definitions {\meta_flush_current_definitions}% figure {\MPaskedfigure}% - filtering {\mpcategoryparameter\c!list} + filtering {\mpcategoryparameter\c!stacking} method {\MPinstanceparameter\c!method}% namespace {\??graphicvariable\currentmpcategory:}% \relax}% @@ -661,7 +662,31 @@ \permanent\protected\def\meta_start_unique_graphic_indeed#1#2#3\stopuniqueMPgraphic {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_unique_graphic{#1}{#2}{#3}}} -\permanent\tolerant\protected\def\uniqueMPgraphic#=#*#=% +% \permanent\tolerant\protected\def\uniqueMPgraphic#=#*#=% +% {\meta_begin_graphic_group{#1}% +% \checkmpcategoryparent +% \let\currentmpcategory\currentMPgraphicname +% \setupcurrentmpcategory[#2]% +% \begincsname\??mpgraphic#1\endcsname\empty +% \meta_end_graphic_group} + +\permanent\tolerant\protected\def\uniqueMPgraphic + {\futureexpandis[\meta_uniquempgraphic_yes\meta_uniquempgraphic_nop} + +\def\meta_uniquempgraphic_yes[#1]#*#=% + {% ugly code but we run on top of older code + \letdummyparameter\c!instance\empty + \getdummyparameters[#1]% + \edef\currentMPinstance{\dummyparameter\c!instance}% + % here we feed the instance into the analyzer + \meta_begin_graphic_group{\ifempty\currentMPinstance\else\currentMPinstance::\fi#1}% + \checkmpcategoryparent + \let\currentmpcategory\currentMPgraphicname + \setupcurrentmpcategory[#1]% + \begincsname\??mpgraphic#2\endcsname\empty + \meta_end_graphic_group} + +\def\meta_uniquempgraphic_nop#=#*#=% {\meta_begin_graphic_group{#1}% \checkmpcategoryparent \let\currentmpcategory\currentMPgraphicname @@ -719,7 +744,51 @@ \protected\def\meta_start_reusable_graphic_indeed#1#2#3\stopreusableMPgraphic {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_reusable_graphic{#1}{#2}{#3}}} -\permanent\tolerant\protected\def\useMPgraphic#=#*#=% +% \permanent\tolerant\protected\def\useMPgraphic#=#*#=% +% {\meta_begin_graphic_group{#1}% +% \ifcsname\??mpgraphic#1\endcsname +% \edef\currentmpcategory{#1}% +% \orelse\ifcsname\??mpgraphic\currentMPgraphicname\endcsname +% \let\currentmpcategory\currentMPgraphicname +% \else +% \let\currentmpcategory\empty +% \fi +% \ifempty\currentmpcategory +% % message +% \else +% \checkmpcategoryparent +% \doifsomething{#2}{\setupcurrentmpcategory[#2]}% +% \csname\??mpgraphic\currentmpcategory\endcsname +% \fi +% \meta_end_graphic_group} + +\permanent\tolerant\protected\def\useMPgraphic + {\futureexpandis[\meta_usempgraphic_yes\meta_usempgraphic_nop} + +\def\meta_usempgraphic_yes[#1]#*#=% + {% ugly code but we run on top of older code + \letdummyparameter\c!instance\empty + \getdummyparameters[#1]% + \edef\currentMPinstance{\dummyparameter\c!instance}% + % here we feed the instance into the analyzer + \meta_begin_graphic_group{\ifempty\currentMPinstance\else\currentMPinstance::\fi#2}% + \ifcsname\??mpgraphic#2\endcsname + \edef\currentmpcategory{#2}% + \orelse\ifcsname\??mpgraphic\currentMPgraphicname\endcsname + \let\currentmpcategory\currentMPgraphicname + \else + \let\currentmpcategory\empty + \fi + \ifempty\currentmpcategory + % message + \else + \checkmpcategoryparent + \setupcurrentmpcategory[#1]% + \csname\??mpgraphic\currentmpcategory\endcsname + \fi + \meta_end_graphic_group} + +\def\meta_usempgraphic_nop#=#*#=% {\meta_begin_graphic_group{#1}% \ifcsname\??mpgraphic#1\endcsname \edef\currentmpcategory{#1}% @@ -892,7 +961,22 @@ %D %D The most simple case: -\permanent\tolerant\protected\def\startMPcode#=#:#2\stopMPcode +% \permanent\tolerant\protected\def\startMPcode#=#:#2\stopMPcode +% {\begingroup +% \edef\currentMPinstance{#1}% +% \ifempty\currentMPinstance +% \let\currentMPinstance\defaultMPinstance +% \fi +% \let\currentMPgraphicname\empty +% \edef\currentMPformat{\MPinstanceparameter\s!format}% +% \meta_enable_include +% \meta_process_graphic{#2}% +% \endgroup} + +\permanent\tolerant\protected\def\startMPcode + {\futureexpandis[\meta_start_mpcode_yes\meta_start_mpcode_nop} + +\tolerant\def\meta_start_mpcode_nop#:#=#:#2\stopMPcode {\begingroup \edef\currentMPinstance{#1}% \ifempty\currentMPinstance @@ -904,6 +988,22 @@ \meta_process_graphic{#2}% \endgroup} +\def\meta_start_mpcode_yes[#1]#2\stopMPcode + {\begingroup + \letdummyparameter\c!instance\empty + \letdummyparameter\c!stacking\empty + \getdummyparameters[#1]% + \edef\currentMPinstance{\dummyparameter\c!instance}% + \setmpcategoryparameter\c!stacking{\dummyparameter\c!stacking}% + \ifempty\currentMPinstance + \let\currentMPinstance\defaultMPinstance + \fi + \let\currentMPgraphicname\empty + \edef\currentMPformat{\MPinstanceparameter\s!format}% + \meta_enable_include + \meta_process_graphic{#2}% + \endgroup} + \permanent\protected\lettonothing\stopMPcode %D This one is not optimized because it's only used for small snippets, if it diff --git a/tex/context/base/mkxl/mlib-pdf.lmt b/tex/context/base/mkxl/mlib-pdf.lmt index 11f211b2b..58a1129eb 100644 --- a/tex/context/base/mkxl/mlib-pdf.lmt +++ b/tex/context/base/mkxl/mlib-pdf.lmt @@ -388,7 +388,7 @@ function metapost.flush(specification,result) local textfigure = flusher.textfigure -- local processspecial = flusher.processspecial or metapost.processspecial local tocomment = flusher.tocomment - if type(filtering) ~= "table" then + if type(filtering) ~= "table" or not next(filtering) then filtering = false end -- patterns: we always use image 1 and then can use patterns for 2..n (or one number) diff --git a/tex/context/base/mkxl/mlib-pps.lmt b/tex/context/base/mkxl/mlib-pps.lmt index 7790f0f23..cea8a179d 100644 --- a/tex/context/base/mkxl/mlib-pps.lmt +++ b/tex/context/base/mkxl/mlib-pps.lmt @@ -6,6 +6,7 @@ if not modules then modules = { } end modules ['mlib-pps'] = { license = "see context related readme files", } +local next = next local format, gmatch, match, split, gsub = string.format, string.gmatch, string.match, string.split, string.gsub local tonumber, type, unpack, next, select = tonumber, type, unpack, next, select local round, sqrt, min, max, abs = math.round, math.sqrt, math.min, math.max, math.abs @@ -592,9 +593,13 @@ function metapost.graphic_base_pass(specification) top.data = data top.initializations = initializations if filtering then - local t = { } - stepper(filtering,function(k) t[k] = true end) - filtering = t + if #filtering > 0 then + local t = { } + stepper(filtering,function(k) t[k] = true end) + filtering = next(t) and t or false + else + filtering = false + end end if trace_runs then report_metapost("running job %s, asked figure %a",nofruns,askedfig) @@ -1558,15 +1563,19 @@ end -- groups local function getcorners(path) - local p1 = path[1] - local p2 = path[2] - local p3 = path[3] - local p4 = path[4] - return - min(p1.x_coord,p2.x_coord,p3.x_coord,p4.x_coord), - min(p1.y_coord,p2.y_coord,p3.y_coord,p4.y_coord), - max(p1.x_coord,p2.x_coord,p3.x_coord,p4.x_coord), - max(p1.y_coord,p2.y_coord,p3.y_coord,p4.y_coord) +-- if #path == 1 then +-- return 0, 0, 0, 0 +-- else + local p1 = path[1] + local p2 = path[2] + local p3 = path[3] + local p4 = path[4] + return + min(p1.x_coord,p2.x_coord,p3.x_coord,p4.x_coord), + min(p1.y_coord,p2.y_coord,p3.y_coord,p4.y_coord), + max(p1.x_coord,p2.x_coord,p3.x_coord,p4.x_coord), + max(p1.y_coord,p2.y_coord,p3.y_coord,p4.y_coord) +-- end end local function gr_process(object,prescript,before,after) diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index c13e5eaef..15e349330 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -16,13 +16,77 @@ %D this loader is found in \type {syst-tex.tex}. Some of the comment's are Don %D Knuths and more of it can be found in the plain \TEX\ format. %D +%D Successive versions will be adapted to \LUAMETATEX. That also means that we +%D define things a bit differently than in \MKII\ and \MKIV. This is party due to +%D the fact that in this engine we removed some side effects or added features. The +%D original \TEX\ program is well defined and documented and is still the benchmark. +%D The \ETEX\ extensions originally were meant as systematic follow up but that +%D never went beyond a first upgrade. It had a dual mode: compatible or extensible. +%D We always used the second mode. The \LUATEX\ engines don't have that. +%D +%D There are some hard coded properties that relate to for instance node types but +%D we always used abstraction. There are also side effects that (probably) originate +%D in the fact that \ETEX\ had to stay compatible with the dominant set of macros +%D using the original \TEX\ ones (either or not wrapped). Even unwanted side effects +%D eventually become features. In\LUATEX\ and even more in \LUAMETATEX\ we get +%D around that by additional mode variables that you can find below. +%D +%D Side note: those who complain about \TEX\ as rather special language, \ETEX\ +%D extensions that should have been or be different, should really look into how +%D \TEX\ and friends evolved, and not come to quick and wrong conclusions. There are +%D only a very few languages that evolve this way. As a comparison one can wonder +%D why \CCODE\ never had proper strings like \PASCAL\ bit it's just hindsight and +%D discussing it has no use. In a similar fashion one should keep in mind that what +%D you see here is just a logical follow up in \MKII\ where we had to bend the rules +%D and \MKIV\ where we had a bit more available. Not many who look at the latest +%D engines had to jump though all the hoops. +%D +%D This is for instance noticeable in the names of some primitvies: \CONTEXT\ has a +%D concept of protection before \type {\protected} showed up, and similarly had +%D expansion helpers. This is why in \MKII\ you find \type {\protected}, \type +%D {\expanded}, and \type {\unexpanded} commands with different meanings than the +%D later \ETEX\ primitives. In \MKIV\ we stuck to the \CONTEXT\ originals and use +%D \type {\normal...} ones when needed (so \type {\normal...} is there for a +%D reason!). In \LMTX\ we made the transition from \type {\unexpanded} to \type +%D {\protected} so again this file looks different than the \MKIV\ ancestor. +%D +%D When primitives get initialized they come from the \TEX\ namespace (the +%D originals), the \ETEX\ extensions (although we dropped some) and \LUATEX\ which +%D includes the \LUAMETATEX\ ones. The most noticeable \ETEX\ extensions we kept are +%D those that relate to expansion and the expression scanners. The last group has +%D always been somewhat special because (we were told) it was modelled after a macro +%D set so it had to be compatible. It is tempting to replace it (and eventually I +%D might do that) but for now we stick to them (although with an integer divide +%D extension (like the \LUA\ \type {//} and the source has commented binary +%D operators but I haven't yet decided on the symbols to use because we need to +%D avoid expansion issues). For the record: the more extensive, related to \ETEX\ +%D follow up \NTS\ never took of, probably because of the implementation language +%D and because performance made it unuseable. This is also why \LUATEX\ took a +%D different route: extending by an extension language. Of course in the end some +%D core functionality got added too. +%D +%D The most noticeable \LUAMETATEX\ specific code here has to do with additional +%D data types (integer and dimension constants) and macro argument extensions. We +%D also set up some defaults in handling math, languages, etc. Elsewhere in the +%D \CONTEXT\ source the real configuration and usage happens so don't consider this +%D an tutorial (as the plain format is). +%D +%D Category codes are another areas where subtle changed happened. You might not +%D grasp it (maybe because \CONTEXT\ is alien to you) but whenever you see something +%D that looks weird keep in mind that there is a valid reason for it. +%D +%D In due time I will add some more comments here, also because some \CONTEXT\ +%D users might be interested in the hostiry. Now to the code! + %D Characters can have special states, that can be triggered by setting their %D category coded. Some are preset, others are to be set as soon as possible, %D otherwise we cannot define any useful macros. %D %D First we define a bunch of constants. Normally we would \type {\setconstant} %D but we're prestine and have no macros defined yet. Abstraction also makes it -%D possible to avoid the \type {^^} in the input. +%D possible to avoid the \type {^^} in the input. We no longer define the \ETEX\ +%D nodes here (we have not only more, but also different numbers) so we do it +%D elsewhere. % cheatsheet % @@ -311,7 +375,10 @@ %D consecutive ranges more easily, for instance if for \MPLIB\ we want to allocate a %D continuous range of boxes. It also permits us to do a proper upward allocation %D for inserts. The current code evolved from code that dealt with older engines but -%D as all engines now provide many registers we removed all traces. +%D as all engines now provide many registers we removed all traces. If you ever run +%D into the \MKII\ \type {mptopdf} code, you'll notice that some register magic was +%D needed to fit into existing macro packages. The same is true for \PICTEX\ that we +%D used in (gheneric) \PPCHTEX. \ifdefined\writestatus \else %\protected\def\writestatus#1#2{\immediate\write\statuswrite{#1: #2}} @@ -563,8 +630,8 @@ {\showboxdepth \plusthree \showboxbreadth\plusfive} -%D Some expected plain variants follow. We don't reuse registers because we -%D don't want clashes. +%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. \aliased\let\p@ \onepoint \aliased\let\m@ne \minusone @@ -639,9 +706,12 @@ \newif\ifscratchconditionone \newif\ifscratchconditiontwo +%D This used to be a protected definition with a \type {dimexpr} but now we have +%D it natively (less tracking noise). + \aliased\let\htdp\boxtotal -%D A few shortcuts: +%D A few shortcuts (gone by now): % \permanent\protected\def\udef {\protected\def } % \permanent\protected\def\ugdef{\protected\gdef} @@ -660,7 +730,7 @@ \permanent\protected\def\defUmathchar #1#2#3#4{\global\immutable\Umathchardef #1 "#2 "#3 "#4 } %D For a while we keep the following, as systems like tikz need it. Best not use -%D that one \CONTEXT. +%D that one \CONTEXT. It will probably move to the tikz loader. \aliased\let\active\activecatcode @@ -1177,7 +1247,7 @@ {\ifflags#2\permanent\permanent\fi % the rest is taken with the copy \def#1{\syst_suggested_alias#1#2}} -% A few traditional allocations (these might go): +% A few traditional allocations (these might go too): % \countdef \count@ 255 % hm, used in \newif .. todo: replace it there % \dimendef \dimen@ 0 |