summaryrefslogtreecommitdiff
path: root/tex/context
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-12-13 17:40:23 +0200
committerMarius <mariausol@gmail.com>2011-12-13 17:40:23 +0200
commit008b7b212da48ca7ef8fc8ac876dbf13ca7b21a5 (patch)
tree8571937aba1460b4bf7daa0e08738f8768c48d03 /tex/context
parent0396ead2bd0816d7e546848690271bbbe9077334 (diff)
downloadcontext-008b7b212da48ca7ef8fc8ac876dbf13ca7b21a5.tar.gz
beta 2011.12.13 15:17
Diffstat (limited to 'tex/context')
-rw-r--r--tex/context/base/anch-pgr.mkiv102
-rw-r--r--tex/context/base/attr-lay.mkiv18
-rw-r--r--tex/context/base/back-exp.lua215
-rw-r--r--tex/context/base/back-exp.mkiv32
-rw-r--r--tex/context/base/bibl-bib.mkiv17
-rw-r--r--tex/context/base/bibl-tra.mkiv21
-rw-r--r--tex/context/base/buff-ver.lua4
-rw-r--r--tex/context/base/buff-ver.mkiv6
-rw-r--r--tex/context/base/char-act.mkiv2
-rw-r--r--tex/context/base/char-def.lua28
-rw-r--r--tex/context/base/chem-str.lua2
-rw-r--r--tex/context/base/chem-str.mkiv8
-rw-r--r--tex/context/base/colo-ini.mkiv40
-rw-r--r--tex/context/base/cont-fil.mkii3
-rw-r--r--tex/context/base/cont-fil.mkiv3
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4069 -> 4074 bytes
-rw-r--r--tex/context/base/context-version.pngbin105821 -> 106150 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv16
-rw-r--r--tex/context/base/core-def.mkiv3
-rw-r--r--tex/context/base/core-mis.mkiv37
-rw-r--r--tex/context/base/core-sys.mkiv6
-rw-r--r--tex/context/base/core-var.mkiv13
-rw-r--r--tex/context/base/file-job.mkvi4
-rw-r--r--tex/context/base/font-ctx.lua224
-rw-r--r--tex/context/base/font-ini.mkiv189
-rw-r--r--tex/context/base/font-otd.lua11
-rw-r--r--tex/context/base/font-otf.lua133
-rw-r--r--tex/context/base/grph-fil.lua15
-rw-r--r--tex/context/base/l-file.lua4
-rw-r--r--tex/context/base/l-lpeg.lua13
-rw-r--r--tex/context/base/luat-mac.lua3
-rw-r--r--tex/context/base/lxml-aux.lua131
-rw-r--r--tex/context/base/lxml-tab.lua8
-rw-r--r--tex/context/base/lxml-xml.lua4
-rw-r--r--tex/context/base/m-database.mkiv28
-rw-r--r--tex/context/base/math-act.lua16
-rw-r--r--tex/context/base/math-ali.mkiv604
-rw-r--r--tex/context/base/math-dim.lua2
-rw-r--r--tex/context/base/math-pln.mkiv22
-rw-r--r--tex/context/base/meta-ini.mkiv82
-rw-r--r--tex/context/base/meta-pag.mkiv10
-rw-r--r--tex/context/base/mult-aux.mkiv175
-rw-r--r--tex/context/base/mult-de.mkii4
-rw-r--r--tex/context/base/mult-def.lua24
-rw-r--r--tex/context/base/mult-en.mkii4
-rw-r--r--tex/context/base/mult-fr.mkii4
-rw-r--r--tex/context/base/mult-ini.mkiv38
-rw-r--r--tex/context/base/mult-it.mkii4
-rw-r--r--tex/context/base/mult-low.lua2
-rw-r--r--tex/context/base/mult-nl.mkii4
-rw-r--r--tex/context/base/mult-pe.mkii4
-rw-r--r--tex/context/base/mult-ro.mkii4
-rw-r--r--tex/context/base/mult-sys.mkiv9
-rw-r--r--tex/context/base/node-rul.mkiv4
-rw-r--r--tex/context/base/pack-bck.mkvi2
-rw-r--r--tex/context/base/pack-box.mkiv18
-rw-r--r--tex/context/base/pack-lyr.mkiv2
-rw-r--r--tex/context/base/pack-mis.mkvi2
-rw-r--r--tex/context/base/pack-rul.mkiv68
-rw-r--r--tex/context/base/page-app.mkiv35
-rw-r--r--tex/context/base/page-bck.mkiv557
-rw-r--r--tex/context/base/page-box.mkvi322
-rw-r--r--tex/context/base/page-brk.mkiv393
-rw-r--r--tex/context/base/page-col.mkiv156
-rw-r--r--tex/context/base/page-fac.mkiv77
-rw-r--r--tex/context/base/page-flt.mkiv23
-rw-r--r--tex/context/base/page-flw.mkiv3
-rw-r--r--tex/context/base/page-grd.mkiv85
-rw-r--r--tex/context/base/page-imp.mkiv407
-rw-r--r--tex/context/base/page-inf.mkiv104
-rw-r--r--tex/context/base/page-ini.mkiv1640
-rw-r--r--tex/context/base/page-lay.mkiv1208
-rw-r--r--tex/context/base/page-lin.mkiv17
-rw-r--r--tex/context/base/page-mak.mkvi41
-rw-r--r--tex/context/base/page-mar.mkiv14
-rw-r--r--tex/context/base/page-mbk.mkvi4
-rw-r--r--tex/context/base/page-mis.lua2
-rw-r--r--tex/context/base/page-mis.mkiv28
-rw-r--r--tex/context/base/page-mrk.mkiv75
-rw-r--r--tex/context/base/page-mul.mkiv45
-rw-r--r--tex/context/base/page-one.mkiv186
-rw-r--r--tex/context/base/page-par.mkiv5
-rw-r--r--tex/context/base/page-plg.mkiv48
-rw-r--r--tex/context/base/page-set.mkiv50
-rw-r--r--tex/context/base/page-sid.mkiv972
-rw-r--r--tex/context/base/page-spr.mkiv2
-rw-r--r--tex/context/base/page-txt.mkiv801
-rw-r--r--tex/context/base/page-txt.mkvi922
-rw-r--r--tex/context/base/page-var.mkiv20
-rw-r--r--tex/context/base/phys-dim.lua71
-rw-r--r--tex/context/base/phys-dim.mkiv63
-rw-r--r--tex/context/base/ppchtex.mkiv8
-rw-r--r--tex/context/base/s-fnt-10.mkiv2
-rw-r--r--tex/context/base/s-pre-50.tex2
-rw-r--r--tex/context/base/scrn-but.mkvi12
-rw-r--r--tex/context/base/scrn-fld.mkvi20
-rw-r--r--tex/context/base/scrn-ini.mkvi14
-rw-r--r--tex/context/base/spac-chr.lua36
-rw-r--r--tex/context/base/spac-def.mkiv22
-rw-r--r--tex/context/base/spac-fnt.mkiv93
-rw-r--r--tex/context/base/spac-hor.mkiv2
-rw-r--r--tex/context/base/spac-ver.mkiv389
-rw-r--r--tex/context/base/status-files.pdfbin23989 -> 23993 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin169508 -> 169692 bytes
-rw-r--r--tex/context/base/strc-blk.mkiv4
-rw-r--r--tex/context/base/strc-des.mkiv289
-rw-r--r--tex/context/base/strc-doc.lua2
-rw-r--r--tex/context/base/strc-flt.mkvi44
-rw-r--r--tex/context/base/strc-ini.lua142
-rw-r--r--tex/context/base/strc-itm.mkiv1451
-rw-r--r--tex/context/base/strc-itm.mkvi1514
-rw-r--r--tex/context/base/strc-lst.mkiv93
-rw-r--r--tex/context/base/strc-mar.mkiv12
-rw-r--r--tex/context/base/strc-mat.mkiv2
-rw-r--r--tex/context/base/strc-not.mkiv50
-rw-r--r--tex/context/base/strc-pag.lua2
-rw-r--r--tex/context/base/strc-pag.mkiv53
-rw-r--r--tex/context/base/strc-prc.lua9
-rw-r--r--tex/context/base/strc-ref.mkvi18
-rw-r--r--tex/context/base/strc-reg.lua2
-rw-r--r--tex/context/base/strc-reg.mkiv28
-rw-r--r--tex/context/base/strc-ren.mkiv22
-rw-r--r--tex/context/base/strc-rsc.lua4
-rw-r--r--tex/context/base/strc-sec.mkiv22
-rw-r--r--tex/context/base/strc-syn.mkiv149
-rw-r--r--tex/context/base/strc-tag.mkiv37
-rw-r--r--tex/context/base/supp-box.mkiv5
-rw-r--r--tex/context/base/supp-mat.mkiv27
-rw-r--r--tex/context/base/symb-imp-mis.mkiv23
-rw-r--r--tex/context/base/symb-ini.mkiv29
-rw-r--r--tex/context/base/syst-aux.lua39
-rw-r--r--tex/context/base/syst-aux.mkiv176
-rw-r--r--tex/context/base/syst-ini.mkiv31
-rw-r--r--tex/context/base/tabl-ltb.mkiv66
-rw-r--r--tex/context/base/tabl-ntb.mkiv2
-rw-r--r--tex/context/base/tabl-xtb.lua10
-rw-r--r--tex/context/base/trac-log.lua1
-rw-r--r--tex/context/base/type-lucidanova.mkiv56
-rw-r--r--tex/context/base/typo-ini.lua2
-rw-r--r--tex/context/base/typo-mar.mkiv6
-rw-r--r--tex/context/base/typo-par.mkiv6
-rw-r--r--tex/context/base/typo-prc.lua126
-rw-r--r--tex/context/base/typo-prc.mkvi (renamed from tex/context/base/strc-prc.mkiv)65
-rw-r--r--tex/context/base/xtag-exp.mkii2
-rw-r--r--tex/context/interface/cont-cs.xml10
-rw-r--r--tex/context/interface/cont-de.xml10
-rw-r--r--tex/context/interface/cont-en.xml10
-rw-r--r--tex/context/interface/cont-fr.xml10
-rw-r--r--tex/context/interface/cont-it.xml10
-rw-r--r--tex/context/interface/cont-nl.xml10
-rw-r--r--tex/context/interface/cont-pe.xml10
-rw-r--r--tex/context/interface/cont-ro.xml10
-rw-r--r--tex/context/interface/keys-cs.xml4
-rw-r--r--tex/context/interface/keys-de.xml4
-rw-r--r--tex/context/interface/keys-en.xml4
-rw-r--r--tex/context/interface/keys-fr.xml4
-rw-r--r--tex/context/interface/keys-it.xml4
-rw-r--r--tex/context/interface/keys-nl.xml4
-rw-r--r--tex/context/interface/keys-pe.xml4
-rw-r--r--tex/context/interface/keys-ro.xml4
163 files changed, 8166 insertions, 8000 deletions
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv
index 046a161e5..45843c76d 100644
--- a/tex/context/base/anch-pgr.mkiv
+++ b/tex/context/base/anch-pgr.mkiv
@@ -69,18 +69,22 @@
\appendtoks \presetpositionanchors \to \aftereverypage
% todo: change with each page size change .. can be made more efficient
-% as some values are the same
+% as some values are the same .. this one can (at some point) be used
+% to provide correction for imposition
-\def\registerpageposition#1% this one is flushed first !
+\def\doregisterpageposition#1%
+ {\setbox#1\hbox{\hpos\pageanchor{\box#1}}}
+
+\def\registerpageposition#1% this one is flushed first ! ... can't we avoid this one
{\ifpositioning\ifcase\realpageno\or
\ifdim\printpaperheight=\paperheight
\ifdim\printpaperwidth=\paperwidth
% not needed,
\else
- \setbox#1\hbox{\hpos\pageanchor{\box#1}}%
+ \doregisterpageposition{#1}%
\fi
\else
- \setbox#1\hbox{\hpos\pageanchor{\box#1}}%
+ \doregisterpageposition{#1}%
\fi
\fi\fi}
@@ -597,10 +601,10 @@
\def\textbackgroundoverlay#1%
{\iflocalpositioning\v!local\else\v!text\fi#1}
-\newcounter\localpositionnumber
+\newcount\localpositionnumber
\def\MPanchornumber
- {\iflocalpositioning\localpositionnumber\else\the\realpageno\fi}
+ {\iflocalpositioning\the\localpositionnumber\else\the\realpageno\fi}
%D So far for the trickery.
@@ -738,92 +742,28 @@
\carryoverpar\egroup}
\unexpanded\def\starttextbackgroundmanual
- {\dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
+ {\begingroup
+ \dousestylehashparameter{\??td\currenttextbackground}\c!style
+ \dousecolorhashparameter{\??td\currenttextbackground}\c!color
\fpos\currentparbackground\ignorespaces}
\unexpanded\def\stoptextbackgroundmanual
{\tpos\currentparbackground
- \dostopattributes}
+ \endgroup}
\def\dostarttextbackgroundtxt
{\ifvmode \dontleavehmode \fi
- \dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
+ \begingroup
+ \dousestylehashparameter{\??td\currenttextbackground}\c!style
+ \dousecolorhashparameter{\??td\currenttextbackground}\c!color
\fpos\currentparbackground\ignorespaces}
\def\dostoptextbackgroundtxt
{\tpos\currentparbackground
- \dostopattributes}
+ \endgroup}
\newskip\textbackgroundskip
-% \def\dostarttextbackgroundpar
-% {\endgraf % new
-% \textbackgroundparameter\c!before
-% \noindent
-% \ifgridsnapping
-% \doassignsomeskip\textbackgroundparameter\c!topoffset\to\textbackgroundskip
-% \ifdim\textbackgroundskip>\zeropoint
-% \struttedbox{\hbox{\raise\textbackgroundskip\hbox{\fpos\currentparbackground}}}%
-% \else
-% \fpos\currentparbackground
-% \fi
-% \else
-% \fpos\currentparbackground
-% \fi
-% \bgroup
-% \endgraf % we need a vertical nobreak - 29/06/2004
-% \nobreak \vskip-\lineheight \nobreak
-% \ifgridsnapping \else
-% \doassignsomeskip\textbackgroundparameter\c!topoffset\to\textbackgroundskip
-% \ifdim\textbackgroundskip>\zeropoint
-% \kern\textbackgroundskip\nobreak
-% \fi
-% \fi
-% \dosetleftskipadaption{\textbackgroundparameter\c!leftoffset}%
-% \advance\leftskip\leftskipadaption
-% \dosetleftskipadaption{\textbackgroundparameter\c!rightoffset}%
-% \advance\rightskip\leftskipadaption
-% % new
-% \dosetraggedcommand{\textbackgroundparameter\c!align}%
-% \raggedcommand
-% %
-% \dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
-% \nowhitespace
-% \nobreak % new per 23/04/2006 (else potential break when whitespace)
-% \seteffectivehsize
-% \doinhibitblank % \blank[\v!disable]% new
-% \par}
-
-% \def\dostoptextbackgroundpar
-% {\par
-% \removelastskip % new
-% \dostopattributes
-% \doassignsomeskip\textbackgroundparameter\c!bottomoffset\to\textbackgroundskip
-% \ifdim\lastskip>\zeropoint
-% \advance\textbackgroundskip-\lastskip
-% \fi
-% \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint
-% \kern\textbackgroundskip\nobreak
-% \fi \fi
-% \nobreak \vskip-\dimexpr\lineheight+\parskip\relax \nobreak
-% %\nobreak \vskip-\lineheight \nobreak \nowhitespace % does not work
-% \egroup
-% \bgroup \forgeteverypar % NOT REALLY NEEDED, SAVES HASH/MEM
-% \nobreak \noindent \strut \hfill \kern\zeropoint
-% \doassignsomeskip\textbackgroundparameter\c!bottomoffset\to\textbackgroundskip
-% \ifgridsnapping % experimental, pascal (todo: topoffset in same way)
-% \ifdim\textbackgroundskip>\zeropoint
-% \struttedbox\plusone{\hbox{\lower\textbackgroundskip\hbox{\tpos\currentparbackground}}}%
-% \else
-% \tpos\currentparbackground
-% \fi
-% \else
-% \tpos\currentparbackground
-% \fi
-% \egroup
-% \endgraf % new
-% \textbackgroundparameter\c!after}
-
\def\dostarttextbackgroundpar
{\endgraf % new
\textbackgroundparameter\c!before
@@ -858,7 +798,9 @@
\dosetraggedcommand{\textbackgroundparameter\c!align}%
\raggedcommand
%
- \dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
+ %\begingroup
+ \dousestylehashparameter{\??td\currenttextbackground}\c!style
+ \dousecolorhashparameter{\??td\currenttextbackground}\c!color
\nowhitespace
\nobreak % new per 23/04/2006 (else potential break when whitespace)
\seteffectivehsize
@@ -868,7 +810,7 @@
\def\dostoptextbackgroundpar
{\par
\removelastskip % new
- \dostopattributes
+ %\endgroup
\doassignsomeskip\textbackgroundparameter\c!bottomoffset\to\textbackgroundskip
\ifdim\lastskip>\zeropoint
\advance\textbackgroundskip-\lastskip
diff --git a/tex/context/base/attr-lay.mkiv b/tex/context/base/attr-lay.mkiv
index 293122f42..7dd0e35b9 100644
--- a/tex/context/base/attr-lay.mkiv
+++ b/tex/context/base/attr-lay.mkiv
@@ -74,27 +74,27 @@
% layout components are implemented rather directly (speed)
-\def\doinitializelayoutcomponent#1#2%
+\def\doinitializelayoutcomponent#1%
{\ctxcommand{defineviewerlayer{% this will move to the lua end i.e be merged with register
- tag = "#1:#2",
- title = "#1 #2",
+ tag = "#1",
+ title = "#1", % todo: auto remove :
visible = "\v!start",
editable = "\v!yes",
printable = "\v!yes"
}}%
- \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \ctxlua{tex.write(attributes.viewerlayers.register('#1:#2',true))}\relax}%
- \expandafter\glet\csname\??ly>#1:#2\endcsname\layoutcomponentboxattribute}
+ \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \ctxlua{tex.write(attributes.viewerlayers.register('#1',true))}\relax}%
+ \expandafter\glet\csname\??ly>#1\endcsname\layoutcomponentboxattribute}
-\def\dosetlayoutcomponentattribute#1#2% make this faster
- {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??ly>#1:#2\endcsname
+\def\dosetlayoutcomponentattribute#1% make this faster
+ {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??ly>#1\endcsname
\ifx\layoutcomponentboxattribute\relax
- \doinitializelayoutcomponent{#1}{#2}% get rid of { }
+ \doinitializelayoutcomponent{#1}% get rid of { }
\fi}
\def\doresetlayoutcomponentattribute
{\let\layoutcomponentboxattribute\empty}
-\let\setlayoutcomponentattribute \gobbletwoarguments
+\let\setlayoutcomponentattribute \gobbleoneargument
\let\resetlayoutcomponentattribute\relax
\let\layoutcomponentboxattribute \empty
diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua
index 750b26fe1..fd3d4eb1b 100644
--- a/tex/context/base/back-exp.lua
+++ b/tex/context/base/back-exp.lua
@@ -1200,8 +1200,7 @@ function extras.tabulate(result,element,detail,n,fulltag,di)
local content = false
for i=1,#did do
local d = did[i].data
- local c = d and d.content
- if c and #c > 0 then
+ if d and #d > 0 and d[1].content then
content = true
break
end
@@ -1847,15 +1846,18 @@ local function collectresults(head,list) -- is last used (we also have currentat
local c = n.char
if last ~= at then
local tl = taglist[at]
- if trace_export then
- report_export("%s<!-- processing glyph %s (tag %s) -->",spaces[currentdepth],utfchar(c),at)
- end
+-- if trace_export then
+-- report_export("%s<!-- processing glyph %s (tag %s) -->",spaces[currentdepth],utfchar(c),at)
+-- end
pushcontent()
currentnesting = tl
currentparagraph = has_attribute(n,a_taggedpar)
currentattribute = at
last = at
pushentry(currentnesting)
+ if trace_export then
+ report_export("%s<!-- processing glyph %s (tag %s) -->",spaces[currentdepth],utfchar(c),at)
+ end
-- We need to intercept this here; maybe I will also move this
-- to a regular setter at the tex end.
local r = has_attribute(n,a_reference)
@@ -1951,52 +1953,91 @@ local function collectresults(head,list) -- is last used (we also have currentat
collectresults(n.replace,nil)
elseif id == glue_code then
-- we need to distinguish between hskips and vskips
- local subtype = n.subtype
- if subtype == userskip_code then
- local ca = has_attribute(n,a_characters)
- if ca then
- if ca == 0 then
- -- skip this one ... already converted special character (node-acc)
- else
- local a = has_attribute(n,a_tagged)
- if somespace[currentcontent[nofcurrentcontent]] then
- if trace_export then
- report_export("%s<!-- removing space -->",spaces[currentdepth])
- end
- nofcurrentcontent = nofcurrentcontent - 1
+ local ca = has_attribute(n,a_characters)
+ if ca == 0 then
+ -- skip this one ... already converted special character (node-acc)
+ elseif ca then
+ local a = has_attribute(n,a_tagged)
+ if a then
+ local c = specialspaces[ca]
+ if last ~= a then
+ local tl = taglist[a]
+ if trace_export then
+ report_export("%s<!-- processing space glyph U+%05X (tag %s) case 1 -->",spaces[currentdepth],ca,a)
end
- if last ~= a then
- pushcontent()
- last = a
- currentnesting = taglist[last]
+ pushcontent()
+ currentnesting = tl
+ currentparagraph = has_attribute(n,a_taggedpar)
+ currentattribute = a
+ last = a
+ pushentry(currentnesting)
+ -- no reference check (see above)
+ elseif last then
+ local ap = has_attribute(n,a_taggedpar)
+ if ap ~= currentparagraph then
+ pushcontent(format("new paragraph (%s -> %s)",tostring(currentparagraph),tostring(ap)))
pushentry(currentnesting)
currentattribute = last
+ currentparagraph = ap
end
- nofcurrentcontent = nofcurrentcontent + 1
- currentcontent[nofcurrentcontent] = specialspaces[ca] -- utfchar(ca)
if trace_export then
- report_export("%s<!-- adding special space/glue (tag %s => %s) -->",spaces[currentdepth],last,a)
+ report_export("%s<!-- processing space glyph U+%05X (tag %s) case 2 -->",spaces[currentdepth],ca,last)
end
end
- elseif n.spec.width > threshold then
- if last and not somespace[currentcontent[nofcurrentcontent]] then
+ -- if somespace[currentcontent[nofcurrentcontent]] then
+ -- if trace_export then
+ -- report_export("%s<!-- removing space -->",spaces[currentdepth])
+ -- end
+ -- nofcurrentcontent = nofcurrentcontent - 1
+ -- end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = c
+ end
+ else
+ local subtype = n.subtype
+ if subtype == userskip_code then
+ if n.spec.width > threshold then
+ if last and not somespace[currentcontent[nofcurrentcontent]] then
+ local a = has_attribute(n,a_tagged)
+ if a == last then
+ if trace_export then
+ report_export("%s<!-- injecting spacing 5a -->",spaces[currentdepth])
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ elseif a then
+ -- e.g LOGO<space>LOGO
+ if trace_export then
+ report_export("%s<!-- processing glue > threshold (tag %s => %s) -->",spaces[currentdepth],last,a)
+ end
+ pushcontent()
+ if trace_export then
+ report_export("%s<!-- injecting spacing 5b -->",spaces[currentdepth])
+ end
+ last = a
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ currentnesting = taglist[last]
+ pushentry(currentnesting)
+ currentattribute = last
+ end
+ end
+ end
+ elseif subtype == spaceskip_code or subtype == xspaceskip_code then
+ if not somespace[currentcontent[nofcurrentcontent]] then
local a = has_attribute(n,a_tagged)
if a == last then
if trace_export then
- report_export("%s<!-- injecting spacing 5a -->",spaces[currentdepth])
+ report_export("%s<!-- injecting spacing 7 (stay in element) -->",spaces[currentdepth])
end
nofcurrentcontent = nofcurrentcontent + 1
currentcontent[nofcurrentcontent] = " "
- elseif a then
- -- e.g LOGO<space>LOGO
- if trace_export then
- report_export("%s<!-- processing glue > threshold (tag %s => %s) -->",spaces[currentdepth],last,a)
- end
- pushcontent()
+ else
if trace_export then
- report_export("%s<!-- injecting spacing 5b -->",spaces[currentdepth])
+ report_export("%s<!-- injecting spacing 7 (end of element) -->",spaces[currentdepth])
end
last = a
+ pushcontent()
nofcurrentcontent = nofcurrentcontent + 1
currentcontent[nofcurrentcontent] = " "
currentnesting = taglist[last]
@@ -2004,57 +2045,28 @@ local function collectresults(head,list) -- is last used (we also have currentat
currentattribute = last
end
end
- end
- elseif subtype == spaceskip_code or subtype == xspaceskip_code then
- if not somespace[currentcontent[nofcurrentcontent]] then
- local a = has_attribute(n,a_tagged)
- if a == last then
- if trace_export then
- report_export("%s<!-- injecting spacing 7 (stay in element) -->",spaces[currentdepth])
- end
- nofcurrentcontent = nofcurrentcontent + 1
- currentcontent[nofcurrentcontent] = " "
- else
- if trace_export then
- report_export("%s<!-- injecting spacing 7 (end of element) -->",spaces[currentdepth])
- end
- last = a
- pushcontent()
- nofcurrentcontent = nofcurrentcontent + 1
- currentcontent[nofcurrentcontent] = " "
- currentnesting = taglist[last]
- pushentry(currentnesting)
- currentattribute = last
- end
- end
- elseif id == kern_code then
- local kern = n.kern
- if kern > 0 then
- local limit = threshold
- if p and p.id == glyph_code then
- limit = fontquads[p.font] / 4
- end
- if kern > limit then
- if last and not somespace[currentcontent[nofcurrentcontent]] then
+ elseif subtype == rightskip_code then
+ -- a line
+ if nofcurrentcontent > 0 then
+ local r = currentcontent[nofcurrentcontent]
+ if r == hyphen then
+ if not keephyphens then
+ nofcurrentcontent = nofcurrentcontent - 1
+ end
+ elseif not somespace[r] then
local a = has_attribute(n,a_tagged)
if a == last then
- if not somespace[currentcontent[nofcurrentcontent]] then
- if trace_export then
- report_export("%s<!-- injecting spacing 8 (%s) -->",spaces[currentdepth],topoints(kern,true))
- end
- nofcurrentcontent = nofcurrentcontent + 1
- currentcontent[nofcurrentcontent] = " "
+ if trace_export then
+ report_export("%s<!-- injecting spacing 1 (end of line, stay in element) -->",spaces[currentdepth])
end
- elseif a then
- -- e.g LOGO<space>LOGO
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ else
if trace_export then
- report_export("%s<!-- processing kern, threshold %s, tag %s => %s -->",spaces[currentdepth],topoints(limit,true),last,a)
+ report_export("%s<!-- injecting spacing 1 (end of line, end of element) -->",spaces[currentdepth])
end
last = a
pushcontent()
- if trace_export then
- report_export("%s<!-- injecting spacing 9 (%s) -->",spaces[currentdepth],topoints(kern,true))
- end
nofcurrentcontent = nofcurrentcontent + 1
currentcontent[nofcurrentcontent] = " "
currentnesting = taglist[last]
@@ -2063,29 +2075,40 @@ local function collectresults(head,list) -- is last used (we also have currentat
end
end
end
+ elseif subtype == parfillskip_code then
+ -- deal with paragaph endings (crossings) elsewhere and we quit here
+ -- as we don't want the rightskip space addition
+ return
end
- elseif subtype == rightskip_code then
- -- a line
- if nofcurrentcontent > 0 then
- local r = currentcontent[nofcurrentcontent]
- if r == hyphen then
- if not keephyphens then
- nofcurrentcontent = nofcurrentcontent - 1
- end
- elseif not somespace[r] then
+ end
+ elseif id == kern_code then
+ local kern = n.kern
+ if kern > 0 then
+ local limit = threshold
+ if p and p.id == glyph_code then
+ limit = fontquads[p.font] / 4
+ end
+ if kern > limit then
+ if last and not somespace[currentcontent[nofcurrentcontent]] then
local a = has_attribute(n,a_tagged)
if a == last then
- if trace_export then
- report_export("%s<!-- injecting spacing 1 (end of line, stay in element) -->",spaces[currentdepth])
+ if not somespace[currentcontent[nofcurrentcontent]] then
+ if trace_export then
+ report_export("%s<!-- injecting spacing 8 (%s) -->",spaces[currentdepth],topoints(kern,true))
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
end
- nofcurrentcontent = nofcurrentcontent + 1
- currentcontent[nofcurrentcontent] = " "
- else
+ elseif a then
+ -- e.g LOGO<space>LOGO
if trace_export then
- report_export("%s<!-- injecting spacing 1 (end of line, end of element) -->",spaces[currentdepth])
+ report_export("%s<!-- processing kern, threshold %s, tag %s => %s -->",spaces[currentdepth],topoints(limit,true),last,a)
end
last = a
pushcontent()
+ if trace_export then
+ report_export("%s<!-- injecting spacing 9 (%s) -->",spaces[currentdepth],topoints(kern,true))
+ end
nofcurrentcontent = nofcurrentcontent + 1
currentcontent[nofcurrentcontent] = " "
currentnesting = taglist[last]
@@ -2094,10 +2117,6 @@ local function collectresults(head,list) -- is last used (we also have currentat
end
end
end
- elseif subtype == parfillskip_code then
- -- deal with paragaph endings (crossings) elsewhere and we quit here
- -- as we don't want the rightskip space addition
- return
end
end
p = n
diff --git a/tex/context/base/back-exp.mkiv b/tex/context/base/back-exp.mkiv
index 217e32513..f891224e4 100644
--- a/tex/context/base/back-exp.mkiv
+++ b/tex/context/base/back-exp.mkiv
@@ -28,7 +28,7 @@
\definesystemattribute[taggedpar][public]
-\def\setelementexporttag
+\unexpanded\def\setelementexporttag
{\dotripleargument\dosetelementexporttag}
\def\dosetelementexporttag
@@ -38,8 +38,8 @@
\expandafter\expandafter\expandafter\dosetelementexporttagb
\fi\fi}
-\def\dosetelementexporttaga[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","#2","#3")}}
-\def\dosetelementexporttagb[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","export","#2")}}
+\unexpanded\def\dosetelementexporttaga[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","#2","#3")}}
+\unexpanded\def\dosetelementexporttagb[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","export","#2")}}
% todo: no need for calls when trialtypesetting
@@ -67,50 +67,50 @@
\to \everytabulatepar % tricky, maybe this should be neverypar
\appendtoks
- \def\dotagTABLEcell {\taggedctxcommand{settagtablecell(\number\tablecellrows,\number\tablecellcolumns,\number\raggedstatus)}}%
- \def\dotagTABLEsignal{\char\zerocount}% brrr, we need to tag empty cells (unless we start numbering)
+ \unexpanded\def\dotagTABLEcell {\taggedctxcommand{settagtablecell(\number\tablecellrows,\number\tablecellcolumns,\number\raggedstatus)}}%
+ \unexpanded\def\dotagTABLEsignal{\char\zerocount}% brrr, we need to tag empty cells (unless we start numbering)
\to \everyenableelements
\appendtoks
- \def\dotagtabulatecell {\taggedctxcommand{settagtabulatecell(\number\tabulatealign)}}%
- \def\dotagtabulatesignal{\dontleavehmode\char\zerocount\ignorespaces}%
+ \unexpanded\def\dotagtabulatecell {\taggedctxcommand{settagtabulatecell(\number\tabulatealign)}}%
+ \unexpanded\def\dotagtabulatesignal{\dontleavehmode\char\zerocount\ignorespaces}%
\to \everyenableelements
\appendtoks
- \def\dotagsynonym{\taggedctxcommand{settagsynonym("\currentsynonym","\currentsynonymtag")}}%
+ \unexpanded\def\dotagsynonym{\taggedctxcommand{settagsynonym("\currentsynonym","\currentsynonymtag")}}%
\to \everyenableelements
\appendtoks % frozen and assumed global per highlight class
- \def\dotaghighlight{\taggedctxcommand{settaghighlight("\currenthighlight","\highlightparameter\c!style",\number\attribute\colorattribute)}}%
+ \unexpanded\def\dotaghighlight{\taggedctxcommand{settaghighlight("\currenthighlight","\highlightparameter\c!style",\number\attribute\colorattribute)}}%
\to \everyenableelements
\appendtoks % we can have differently scaled images
- \def\dotagfigure{\taggedctxcommand{settagfigure("\figurefileoriginal","\figurefilepage",\number\dimexpr\figurewidth,\number\dimexpr\figureheight)}}%
+ \unexpanded\def\dotagfigure{\taggedctxcommand{settagfigure("\figurefileoriginal","\figurefilepage",\number\dimexpr\figurewidth,\number\dimexpr\figureheight)}}%
\to \everyenableelements
\appendtoks
%\def\dotagcombination{\taggedctxcommand{settagcombination(\combinationparameter\c!nx,\combinationparameter\c!ny)}}%
- \def\dotagcombination{\taggedctxcommand{settagcombination(\number\horcombination,\number\totcombination)}}%
+ \unexpanded\def\dotagcombination{\taggedctxcommand{settagcombination(\number\horcombination,\number\totcombination)}}%
\to \everyenableelements
\appendtoks
- \def\dotagsorting{\taggedctxcommand{settagsorting("\currentsorting","\currentsortingtag")}}%
+ \unexpanded\def\dotagsorting{\taggedctxcommand{settagsorting("\currentsorting","\currentsortingtag")}}%
\to \everyenableelements
\appendtoks
- \def\dotagsetparcounter{\global\advance\tagparcounter\plusone\attribute\taggedparattribute\tagparcounter}%
+ \unexpanded\def\dotagsetparcounter{\global\advance\tagparcounter\plusone\attribute\taggedparattribute\tagparcounter}%
\to \everyenableelements
\appendtoks
- \def\dotagsetitemgroup{\taggedctxcommand{settagitemgroup("\currentitemgroup",\ifconditional\packlistitem true\else false\fi,"\currentitemsymbol")}}%
+ \unexpanded\def\dotagsetitemgroup{\taggedctxcommand{settagitemgroup("\currentitemgroup",\ifconditional\packlistitem true\else false\fi,"\currentitemsymbol")}}%
\to \everyenableelements
\appendtoks
- \def\dotagsetdescription{\taggedctxcommand{settagdescription("\currentdescription",\currentdescriptionnumberentry)}}%
+ \unexpanded\def\dotagsetdescription{\taggedctxcommand{settagdescription("\currentdescription",\currentdescriptionnumberentry)}}%
\to \everyenableelements
\appendtoks
- \def\dotagsetnotesymbol{\taggedctxcommand{settagdescriptionsymbol("\currentnote",\currentnotenumber)}}%
+ \unexpanded\def\dotagsetnotesymbol{\taggedctxcommand{settagdescriptionsymbol("\currentnote",\currentnotenumber)}}%
\to \everyenableelements
\appendtoks
diff --git a/tex/context/base/bibl-bib.mkiv b/tex/context/base/bibl-bib.mkiv
index 760338f39..6144015ad 100644
--- a/tex/context/base/bibl-bib.mkiv
+++ b/tex/context/base/bibl-bib.mkiv
@@ -527,24 +527,29 @@
\edef\currentbibtexsession{#1}%
\let\currentlist\currentbibtexsession
\setuplist[\currentbibtexsession][\c!criterium=\v!previous,#2]
- \doifelsenothing{\namedlistparameter\currentbibtexsession\c!title}
- {\systemsuppliedchapter[\currentbibtexsession]{\headtext{\currentbibtexsession}}}
- {\normalexpanded{\systemsuppliedchapter[\currentbibtexsession]{\namedlistparameter\currentbibtexsession\c!title}}}%
- \dodoplacebibtexpublications}
+ \edef\currentbibtexsessiontitle{\namedlistparameter\currentbibtexsession\c!title}%
+ \ifx\currentbibtexsessiontitle\empty
+ \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbibtexsession,\c!title={\headtext{\currentbibtexsession}}]}%
+ \else
+ \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbibtexsession,\c!title={\currentbibtexsessiontitle}]}%
+ \fi
+ \dodoplacebibtexpublications
+ \stopnamedsection
+ \endgroup}
\def\doplacebibtexpublications[#1][#2]%
{\begingroup
\edef\currentbibtexsession{#1}%
\let\currentlist\currentbibtexsession
\setuplist[\currentbibtexsession][\c!criterium=\v!previous,#2]%
- \dodoplacebibtexpublications}
+ \dodoplacebibtexpublications
+ \endgroup}
\def\dodoplacebibtexpublications
{\determinelistcharacteristics[\currentbibtexsession]%
\the\everysetupbibtexlistplacement
\forgetall
\typesetbibtexlist
- \endgroup
\global\advance\bibtexblock\plusone}
\setvalue{\??pb:\c!numbering:\v!short}#1% todo var s -> short tag
diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv
index c00847ae2..d3336ecf2 100644
--- a/tex/context/base/bibl-tra.mkiv
+++ b/tex/context/base/bibl-tra.mkiv
@@ -814,12 +814,16 @@
\def\docompletepublications[#1]%
{\begingroup
-% \setuplist[pubs][\c!criterium=\v!previous,#1]
- \setuplist[pubs][#1]
- \doifelsenothing{\publicationlistparameter\c!title}
- {\systemsuppliedchapter[pubs]{\headtext{pubs}}}
- {\normalexpanded{\systemsuppliedchapter[pubs]{\publicationlistparameter\c!title}}}%
- \dodoplacepublications}
+ \setuplist[pubs][#1]%
+ \edef\currentbibtexsessiontitle{\publicationlistparameter\c!title}%
+ \ifx\currentbibtexsessiontitle\empty
+ \normalexpanded{\startnamedsection[\v!chapter][\c!reference=pubs,\c!title={\headtext{pubs}}]}%
+ \else
+ \normalexpanded{\startnamedsection[\v!chapter][\c!reference=pubs,\c!title={\currentbibtexsessiontitle}]}%
+ \fi
+ \dodoplacepublications
+ \stopnamedsection
+ \endgroup}
%D And the portion with the entries only.
@@ -830,9 +834,9 @@
\def\doplacepublications[#1]%
{\begingroup
-% \setuplist[pubs][\c!criterium=\v!previous,#1]%
\setuplist[pubs][#1]%
- \dodoplacepublications}
+ \dodoplacepublications
+ \endgroup}
\def\dodoplacepublications
{\determinelistcharacteristics[pubs]%
@@ -842,7 +846,6 @@
\inpublisttrue
\typesetpubslist
\inpublistfalse
- \endgroup
\global\advance\bibtexblock\plusone}
%D \subsubject{What's in a publication}
diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua
index bf486045a..e35545605 100644
--- a/tex/context/base/buff-ver.lua
+++ b/tex/context/base/buff-ver.lua
@@ -340,8 +340,8 @@ local function hack(pattern)
return Cs(pattern * Cc(signal))
end
-local split_processor = structures.processors.split
-local apply_processor = structures.processors.apply
+local split_processor = typesetters.processors.split
+local apply_processor = typesetters.processors.apply
-- function visualizers.registerescapepattern(name,before,after,normalmethod,escapemethod,processor)
-- local escapepattern = escapepatterns[name]
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index 7ceb90954..8b9c98a28 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -67,7 +67,7 @@
\def\firststageinitializetype
{\let\obeylines\ignorelines
\ignorehyphens % default
- \dosettypeattributes\c!style\c!color
+ \usetypestyleandcolor\c!style\c!color
\setcatcodetable\vrbcatcodes}
\let\doverbatimsetlinemargin\relax
@@ -98,7 +98,7 @@
\def\firststageinitializetyping
{\switchtobodyfont[\typingparameter\c!bodyfont]%
\docheckverbatimmargins
- \dosettypingattributes\c!style\c!color
+ \usetypingstyleandcolor\c!style\c!color
\doifsomething{\typingparameter\c!align}{\setupalign[\typingparameter\c!align]}%
\ignorehyphens} % default
@@ -383,7 +383,7 @@
\let\normaltextmat\mat
\let\normaltextdis\dis
-\def\astype{\groupedcommand{\dosettypeattributes\c!style\c!color}{}}
+\def\astype{\groupedcommand{\usetypestyleandcolor\c!style\c!color}{}}
%D The basic display verbatim commands are defined in an
%D indirect way. As we will see, they are a specific case of a
diff --git a/tex/context/base/char-act.mkiv b/tex/context/base/char-act.mkiv
index f791ba9e2..472bf89ae 100644
--- a/tex/context/base/char-act.mkiv
+++ b/tex/context/base/char-act.mkiv
@@ -38,7 +38,7 @@
\def\obeyedspace {\ifprocessingverbatim\hbox{ }\else\space\fi}
\def\obeyedtab {\obeyedspace}
\def\obeyedline {\par}
-\def\obeyedpage {\vfill\eject}
+\def\obeyedpage {\page_otr_fill_and_eject_page}
%D \macros
%D {controlspace,setcontrolspaces}
diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua
index ec9a7b134..7ca6f4f70 100644
--- a/tex/context/base/char-def.lua
+++ b/tex/context/base/char-def.lua
@@ -458,7 +458,7 @@ characters.data={
description="SOLIDUS",
direction="cs",
linebreak="sy",
- mathclass="binary",
+ mathclass="ord",
mathsymbol=0x2044,
unicodeslot=0x002F,
},
@@ -56864,7 +56864,7 @@ characters.data={
linebreak="is",
mathspec={
{
- class="binary",
+ class="ord",
name="slash",
},
{
@@ -63198,8 +63198,16 @@ characters.data={
description="LEFT CEILING",
direction="on",
linebreak="al",
- mathclass="open",
- mathname="lceiling",
+ mathspec = {
+ {
+ class="open",
+ name="lceil",
+ },
+ {
+ class="open",
+ name="lceiling",
+ }
+ },
mirror=0x2309,
unicodeslot=0x2308,
},
@@ -63208,8 +63216,16 @@ characters.data={
description="RIGHT CEILING",
direction="on",
linebreak="al",
- mathclass="close",
- mathname="rceiling",
+ mathspec = {
+ {
+ class="close",
+ name="rceil",
+ },
+ {
+ class="close",
+ name="rceiling",
+ }
+ },
mirror=0x2308,
unicodeslot=0x2309,
},
diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua
index 02bfcf737..ac7176bf1 100644
--- a/tex/context/base/chem-str.lua
+++ b/tex/context/base/chem-str.lua
@@ -17,7 +17,7 @@ local report_chemistry = logs.reporter("chemistry")
local format, gmatch, match, lower, gsub = string.format, string.gmatch, string.match, string.lower, string.gsub
local concat, insert, remove = table.concat, table.insert, table.remove
-local processor_tostring = structures.processors.tostring
+local processor_tostring = typesetters.processors.tostring
local lpegmatch = lpeg.match
local settings_to_array = utilities.parsers.settings_to_array
diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv
index 6b460b513..998ff942a 100644
--- a/tex/context/base/chem-str.mkiv
+++ b/tex/context/base/chem-str.mkiv
@@ -82,14 +82,14 @@
\def\dodefinechemicalsymbol[#1][#2]%
{\setvalue{\??cm::#1}{#2}}
-\def\chemicalsymbol[#1]%
+\unexpanded\def\chemicalsymbol[#1]%
{\getvalue{\??cm::#1}}
% size (small medium big)
-\def\dosetchemicaltext
- {\dosetfontattribute \??cm\c!style
- \dosetcolorattribute\??cm\c!color}
+\unexpanded\def\dosetchemicaltext
+ {\dousestyleparameter\@cmstyle
+ \dousecolorparameter\@cmcolor}
\edef\chemicaltoplocation{t}
\edef\chemicalbotlocation{b}
diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv
index 14db85e2d..411ff9fbb 100644
--- a/tex/context/base/colo-ini.mkiv
+++ b/tex/context/base/colo-ini.mkiv
@@ -151,8 +151,6 @@
\unexpanded\def\graycolor [#1]{\groupedcommand{\dosetcolormodel{gray}\doactivatecolor{#1}}{}}
\unexpanded\def\colored [#1]{\groupedcommand{\definecolor[@colored@][#1]\doactivatecolor{@colored@}}{}}
\unexpanded\def\fastcolored [#1]#2{\begingroup\dodefinefastcolor[@colored@][#1]\doactivatecolor{@colored@}#2\endgroup}
-\unexpanded\def\predefinecolor [#1]{\flushatshipout{\hbox{\color[#1]{}}}}
-\unexpanded\def\predefineindexcolor[#1]{\flushatshipout{\hbox{\color[#1]{}}}}
% some of this will go away
@@ -163,7 +161,6 @@
\unexpanded\def\raster [#1]{\groupedcommand{\dosetrastercolor{#1}}{}}
\unexpanded\def\faststartcolor [#1]{\doactivatecolor{#1}}
\unexpanded\def\faststopcolor {}
-\unexpanded\def\dosetcolorattribute#1#2{\ifcsname#1#2\endcsname\doactivatecolor{\csname#1#2\endcsname}\fi}
\def\getcolorattributevalue#1#2% color macro (obsolete again, we have a better method)
{\begingroup
@@ -765,18 +762,39 @@
\letvalueempty{(cs:-}
\letvalueempty{(ts:-}
-\def\doactivatecolor#1% : in currentpalet, maybe not, ugly (some day at the lua end)
- {\def\currentcolorname{#1}%
- \ifcsname(cs:\currentpalet#1)\endcsname
- \csname(cs:\currentpalet#1)\endcsname
- \csname(ts:\currentpalet#1)\endcsname
- \else\ifcsname(cs:#1)\endcsname
- \csname(cs:#1)\endcsname
- \csname(ts:#1)\endcsname
+\unexpanded\def\doactivatecolor#1% : in currentpalet, maybe not, ugly (some day at the lua end)
+ {\edef\currentcolorname{#1}%
+ \ifcsname(cs:\currentpalet\currentcolorname)\endcsname
+ \csname(cs:\currentpalet\currentcolorname)\endcsname
+ \csname(ts:\currentpalet\currentcolorname)\endcsname
+ \else\ifcsname(cs:\currentcolorname)\endcsname
+ \csname(cs:\currentcolorname)\endcsname
+ \csname(ts:\currentcolorname)\endcsname
\fi\fi}
\let\normaldoactivatecolor\doactivatecolor
+% new:
+
+\let\dousecolorparameter\doactivatecolor
+
+\unexpanded\def\dousecolorhashparameter#1#2%
+ {\ifcsname#1#2\endcsname
+ \expandafter\dousecolorparameter\csname#1#2\endcsname
+ \fi}
+
+\unexpanded\def\dousecurrentcolorparameter
+ {\let\currentcolorname\currentcolorparameter % maybe only when success
+ \ifcsname(cs:\currentpalet\currentcolorparameter)\endcsname
+ \csname(cs:\currentpalet\currentcolorparameter)\endcsname
+ \csname(ts:\currentpalet\currentcolorparameter)\endcsname
+ \else\ifcsname(cs:\currentcolorparameter)\endcsname
+ \csname(cs:\currentcolorparameter)\endcsname
+ \csname(ts:\currentcolorparameter)\endcsname
+ \fi\fi}
+
+\let\dosetcolorattribute\dousecolorhashparameter % for a while
+
% if it becomes a bottleneck we can set up a more complex system with one shared
% attribute for colorspace, color and transparency
%
diff --git a/tex/context/base/cont-fil.mkii b/tex/context/base/cont-fil.mkii
index a6276a482..e05d8eac4 100644
--- a/tex/context/base/cont-fil.mkii
+++ b/tex/context/base/cont-fil.mkii
@@ -121,4 +121,7 @@
\definefilesynonym [mml] [mathml]
\definefilesynonym [cml] [chemml]
+\definefilesynonym [letter] [cor-01]
+\definefilesynonym [memo] [cor-02]
+
\endinput
diff --git a/tex/context/base/cont-fil.mkiv b/tex/context/base/cont-fil.mkiv
index b6d716237..02288a701 100644
--- a/tex/context/base/cont-fil.mkiv
+++ b/tex/context/base/cont-fil.mkiv
@@ -93,4 +93,7 @@
\definefilesynonym [mml] [mathml]
\definefilesynonym [cml] [chemml]
+\definefilesynonym [letter] [cor-01]
+\definefilesynonym [memo] [cor-02]
+
\endinput
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 6124778a6..a6a4c706b 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.11.29 23:11}
+\newcontextversion{2011.12.13 15:17}
%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/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index f141e451f..cd8855bd9 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.11.29 23:11}
+\newcontextversion{2011.12.13 15:17}
%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/context-version.pdf b/tex/context/base/context-version.pdf
index 3a029c70b..4663b5c72 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 84c8ee74e..6d51beecd 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index caae9f255..7467753ba 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.11.29 23:11}
+\edef\contextversion{2011.12.13 15:17}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 0cb59b556..a4b567738 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.11.29 23:11}
+\edef\contextversion{2011.12.13 15:17}
%D For those who want to use this:
@@ -203,12 +203,13 @@
\loadmarkfile{lxml-ini}
\loadmarkfile{lxml-sor}
+\loadmkvifile{typo-prc}
+
\loadmarkfile{strc-ini}
\loadmarkfile{strc-tag}
\loadmarkfile{strc-doc}
\loadmarkfile{strc-num}
\loadmarkfile{strc-mar}
-\loadmarkfile{strc-prc}
\loadmarkfile{strc-sbe}
\loadmarkfile{strc-lst}
\loadmarkfile{strc-sec}
@@ -236,19 +237,26 @@
\loadmarkfile{pack-obj}
-\loadmarkfile{strc-itm}
+\loadmkvifile{strc-itm}
\loadmarkfile{strc-des}
\loadmarkfile{strc-syn}
\loadmarkfile{core-sys}
+\loadmarkfile{page-var}
\loadmarkfile{page-ini}
+\loadmarkfile{page-fac}
+\loadmarkfile{page-brk}
+\loadmarkfile{page-col}
+\loadmarkfile{page-inf}
+\loadmarkfile{page-grd}
\loadmarkfile{page-flt}
\loadmarkfile{page-bck}
\loadmarkfile{page-not}
\loadmarkfile{page-one}
\loadmarkfile{page-lay}
-\loadmarkfile{page-txt}
+\loadmkvifile{page-box}
+\loadmkvifile{page-txt}
\loadmarkfile{page-sid}
\loadmkvifile{strc-flt}
diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv
index 9022044d7..3a07980cc 100644
--- a/tex/context/base/core-def.mkiv
+++ b/tex/context/base/core-def.mkiv
@@ -43,7 +43,8 @@
\appendtoks \initializemainlanguage \to \everyjob
%appendtoks \MPLIBregister \to \everyjob
\appendtoks \xmlinitialize \to \everyjob
-\appendtoks \newbackgroundfalse \to \everyjob % global
+\appendtoks \setfalse\c_page_backgrounds_new \to \everyjob
+\appendtoks \setfalse\c_page_backgrounds_some \to \everyjob
\appendtoks \initializepagecounters \to \everyjob
\appendtoks \directsetup{*runtime:options} \to \everyjob % we could erase them afterwards % order can change
\appendtoks \directsetup{*runtime:modules} \to \everyjob % we could erase them afterwards % order can change
diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv
index 34222a39e..93f3d2061 100644
--- a/tex/context/base/core-mis.mkiv
+++ b/tex/context/base/core-mis.mkiv
@@ -321,7 +321,9 @@
{\!!widtha\alhsize
\divide\!!widtha \alnsize}
{\!!widtha\paragraphcellmeter\alcounter\c!width}%
- \dostartattributes{\??al\currentparagraph\number\alcounter}\c!style\c!color\empty
+ \begingroup
+ \dousestylehashparameter{\??al\currentparagraph\number\alcounter}\c!style
+ \dousecolorhashparameter{\??al\currentparagraph\number\alcounter}\c!color
\doifelse{\paragraphcellmeter\alcounter\c!height}\v!fit
{\setbox\scratchbox\vtop}
{\setbox\scratchbox\vtop to \paragraphcellmeter\alcounter\c!height}%
@@ -361,7 +363,7 @@
\wd\scratchbox\!!widtha
\fi
\box\scratchbox
- \dostopattributes
+ \endgroup
\ifnum\alcounter<\paragraphparameter\c!n\relax
\@EA\doparagraphcell
\else
@@ -837,7 +839,9 @@
\pushmacro\checkindentation
\doifsomething{\delimitedtextparameter\c!indenting} % WS
{\setupindenting[\delimitedtextparameter\c!indenting]}%
- \dostartattributes{\??ci\currentdelimitedtext}\c!style\c!color\empty
+ \begingroup
+ \dousestylehashparameter{\??ci\currentdelimitedtext}\c!style
+ \dousecolorhashparameter{\??ci\currentdelimitedtext}\c!color
\leftdelimitedtextmark
\ignorespaces}
@@ -845,7 +849,7 @@
{\removeunwantedspaces
\removelastskip
\rightdelimitedtextmark
- \dostopattributes
+ \begingroup
\popmacro\checkindentation
\dodostopdelimitedtextpar
\delimitedtextparameter\c!after
@@ -856,14 +860,16 @@
\def\dostartdelimitedtexttxt
{\let\dostopdelimitedtext\dostopdelimitedtexttxt
- \dostartattributes{\??ci\currentdelimitedtext}\c!style\c!color\empty
+ \begingroup
+ \dousestylehashparameter{\??ci\currentdelimitedtext}\c!style
+ \dousecolorhashparameter{\??ci\currentdelimitedtext}\c!color
\dohandleleftdelimitedtext\c!left
\ignorespaces}
\def\dostopdelimitedtexttxt
{\removeunwantedspaces
\dohandlerightdelimitedtext\c!right
- \dostopattributes}
+ \endgroup}
\unexpanded\def\stopdelimitedtext
{\dostopdelimitedtext
@@ -1025,9 +1031,9 @@
\def\doattributeddelimited
{\groupedcommand
{\dostarttagged\t!delimited\currentdelimitedtext
- \dostartattributes{\??ci\currentdelimitedtext}\c!style\c!color}
- {\dostopattributes
- \dostoptagged
+ \dousestylehashparameter{\??ci\currentdelimitedtext}\c!style
+ \dousecolorhashparameter{\??ci\currentdelimitedtext}\c!color}
+ {\dostoptagged
\popdelimitedtext}}
\def\dofontdrivendelimited
@@ -1661,11 +1667,14 @@
\definepairedbox[\v!legend]
-%D Goody:
+%D Goody (to be reconsidered):
+
+\newsystemmode{combination}
+\newsystemmode{pairedbox}
\appendtoks
- \global\resetsystemmode{combination}%
- \global\resetsystemmode{pairedbox}%
+ \global\resetsystemmode{combination}%
+ \global\resetsystemmode{pairedbox}%
\to \everyinsidefloat
% todo: \startcombination \startcomb \stopcomb ...
@@ -1779,10 +1788,10 @@
{\ifx\nexttoken\egroup \else % the next box is empty
\hsize\wd0
\setupalign[\combinationparameter\c!align]%
- \dostartattributes{\??co\currentcombination}\c!style\c!color\empty
+ \dousestylehashparameter{\??co\currentcombination}\c!style
+ \dousecolorhashparameter{\??co\currentcombination}\c!color
\bgroup
\aftergroup\endstrut
- \aftergroup\dostopattributes
\aftergroup\egroup
\begstrut
\fi}%
diff --git a/tex/context/base/core-sys.mkiv b/tex/context/base/core-sys.mkiv
index 247aa3b52..bfacd3c48 100644
--- a/tex/context/base/core-sys.mkiv
+++ b/tex/context/base/core-sys.mkiv
@@ -202,7 +202,7 @@
\def\currentstartstop{#1}%
\startstopparameter\c!commands
\dostarttagged\t!construct\currentstartstop
- \dosetstartstopattributes\c!style\c!color}
+ \usestartstopstyleandcolor\c!style\c!color}
\unexpanded\def\dostartstop_stop#1%
{\dostoptagged
@@ -214,7 +214,7 @@
{\def\currentstartstop{#1}%
\startstopparameter\c!commands % will become setups
\dostarttagged\t!construct\currentstartstop
- \dosetstartstopattributes\c!style\c!color}
+ \usestartstopstyleandcolor\c!style\c!color}
{\def\currentstartstop{#1}%
\dostoptagged
\startstopparameter\c!inbetween}}
@@ -231,7 +231,7 @@
{\dontleavehmode\groupedcommand % otherwise wrong par number in tags
{\def\currenthighlight{#1}%
\dostarttagged\t!highlight\currenthighlight
- \dosethighlightattributes\c!style\c!color
+ \usehighlightstyleandcolor\c!style\c!color
\dotaghighlight}
{\dostoptagged}}
diff --git a/tex/context/base/core-var.mkiv b/tex/context/base/core-var.mkiv
index bcad4abba..0d9e3ee1c 100644
--- a/tex/context/base/core-var.mkiv
+++ b/tex/context/base/core-var.mkiv
@@ -235,19 +235,8 @@
%D Add-ons:
-\let\setlayoutcomponentattribute \gobbletwoarguments
+\let\setlayoutcomponentattribute \gobbleoneargument
\let\resetlayoutcomponentattribute\relax
\let\layoutcomponentboxattribute \empty
-
-%D Concepts:
-
-\newconstant\conceptmode
-
-\def\doifconcepttracing
- {\ifnum\conceptmode>\plustwo
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
\protect \endinput
diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi
index 7f2c5b2fa..43179e156 100644
--- a/tex/context/base/file-job.mkvi
+++ b/tex/context/base/file-job.mkvi
@@ -172,12 +172,12 @@
\def\processedfile {\ctxcommand{processedfile()}}
\def\processedfiles {\ctxcommand{processedfiles()}}
-\unexpanded\def\loadtexfile [#name]{\cxtcommand{usetexfile("#name")}}
+\unexpanded\def\loadtexfile [#name]{\ctxcommand{usetexfile("#name")}}
\unexpanded\def\loadluafile [#name]{\ctxcommand{useluafile("#name")}}
\unexpanded\def\loadcldfile [#name]{\ctxcommand{usecldfile("#name")}}
\unexpanded\def\loadanyfile [#name]{\ctxcommand{useanyfile("#name")}}
-\unexpanded\def\loadtexfileonce [#name]{\cxtcommand{usetexfile("#name",true)}}
+\unexpanded\def\loadtexfileonce [#name]{\ctxcommand{usetexfile("#name",true)}}
\unexpanded\def\loadluafileonce [#name]{\ctxcommand{useluafile("#name",true)}}
\unexpanded\def\loadcldfileonce [#name]{\ctxcommand{usecldfile("#name",true)}}
\unexpanded\def\loadanyfileonce [#name]{\ctxcommand{useanyfile("#name",true)}}
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index f58893c7d..6a7e0f5d3 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -112,10 +112,13 @@ commands.resetnullfont = definers.resetnullfont
setmetatableindex(fontdata, function(t,k) return nulldata end)
+-- we might make an font-hsh.lua
+
local chardata = allocate() -- chardata
local descriptions = allocate()
local parameters = allocate()
local properties = allocate()
+local resources = allocate()
local quaddata = allocate()
local markdata = allocate()
local xheightdata = allocate()
@@ -126,6 +129,7 @@ hashes.characters = chardata
hashes.descriptions = descriptions
hashes.parameters = parameters
hashes.properties = properties
+hashes.resources = resources
hashes.quads = quaddata
hashes.marks = markdata
hashes.xheights = xheightdata
@@ -156,6 +160,14 @@ setmetatableindex(properties, function(t,k)
return properties
end)
+setmetatableindex(resources, function(t,k)
+ local shared = fontdata[k].shared
+ local rawdata = shared and shared.rawdata
+ local resources = rawdata and rawdata.resources
+ t[k] = resources or false -- better than resolving each time
+ return resources
+end)
+
setmetatableindex(quaddata, function(t,k)
local parameters = parameters[k]
local quad = parameters and parameters.quad or 0
@@ -207,68 +219,138 @@ local privatefeatures = {
anum = true,
}
-local function modechecker(tfmdata,features,mode) -- we cannot adapt features as they are shared!
- if trace_features then
- report_features(serialize(features,"used"))
- end
- local rawdata = tfmdata.shared.rawdata
- local resources = rawdata and rawdata.resources
- local script = features.script
- if script == "auto" then
- local latn = false
- for g, list in next, resources.features do
- for f, scripts in next, list do
- if privatefeatures[f] then
- -- skip
- elseif scripts.dflt then
- script = "dflt"
- break
- elseif scripts.latn then
- latn = true
- end
+-- local function modechecker(tfmdata,features,mode) -- we cannot adapt features as they are shared!
+-- if trace_features then
+-- report_features(serialize(features,"used"))
+-- end
+-- local rawdata = tfmdata.shared.rawdata
+-- local resources = rawdata and rawdata.resources
+-- local script = features.script
+-- if script == "auto" then
+-- local latn = false
+-- for g, list in next, resources.features do
+-- for f, scripts in next, list do
+-- if privatefeatures[f] then
+-- -- skip
+-- elseif scripts.dflt then
+-- script = "dflt"
+-- break
+-- elseif scripts.latn then
+-- latn = true
+-- end
+-- end
+-- end
+-- if script == "auto" then
+-- script = latn and "latn" or "dflt"
+-- end
+-- features.script = script
+-- if trace_automode then
+-- report_defining("auto script mode: using script '%s' in font '%s'",script,file.basename(tfmdata.properties.name))
+-- end
+-- end
+-- if mode == "auto" then
+-- local sequences = resources.sequences
+-- if sequences and #sequences > 0 then
+-- local script = features.script or "dflt"
+-- local language = features.language or "dflt"
+-- for feature, value in next, features do
+-- if value then
+-- local found = false
+-- for i=1,#sequences do
+-- local sequence = sequences[i]
+-- local features = sequence.features
+-- if features then
+-- local scripts = features[feature]
+-- if scripts then
+-- local languages = scripts[script]
+-- if languages and languages[language] then
+-- if found then
+-- -- more than one lookup
+-- if trace_automode then
+-- report_defining("forcing node mode in font %s for feature %s, script %s, language %s (multiple lookups)",file.basename(tfmdata.properties.name),feature,script,language)
+-- end
+-- features.mode = "node"
+-- return "node"
+-- elseif needsnodemode[sequence.type] then
+-- if trace_automode then
+-- report_defining("forcing node mode in font %s for feature %s, script %s, language %s (no base support)",file.basename(tfmdata.properties.name),feature,script,language)
+-- end
+-- features.mode = "node"
+-- return "node"
+-- else
+-- -- at least one lookup
+-- found = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- return "base"
+-- else
+-- return mode
+-- end
+-- end
+
+local function checkedscript(tfmdata,resources,features)
+ local latn = false
+ local script = false
+ for g, list in next, resources.features do
+ for f, scripts in next, list do
+ if privatefeatures[f] then
+ -- skip
+ elseif scripts.dflt then
+ script = "dflt"
+ break
+ elseif scripts.latn then
+ latn = true
end
end
- if script == "auto" then
- script = latn and "latn" or "dflt"
- end
- features.script = script
- if trace_automode then
- report_defining("auto script mode: using script '%s' in font '%s'",script,file.basename(tfmdata.properties.name))
- end
end
- if mode == "auto" then
- local sequences = resources.sequences
- if sequences and #sequences > 0 then
- local script = features.script or "dflt"
- local language = features.language or "dflt"
- for feature, value in next, features do
- if value then
- local found = false
- for i=1,#sequences do
- local sequence = sequences[i]
- local features = sequence.features
- if features then
- local scripts = features[feature]
- if scripts then
- local languages = scripts[script]
- if languages and languages[language] then
- if found then
- -- more than one lookup
- if trace_automode then
- report_defining("forcing node mode in font %s for feature %s, script %s, language %s (multiple lookups)",file.basename(tfmdata.properties.name),feature,script,language)
- end
- features.mode = "node"
- return "node"
- elseif needsnodemode[sequence.type] then
- if trace_automode then
- report_defining("forcing node mode in font %s for feature %s, script %s, language %s (no base support)",file.basename(tfmdata.properties.name),feature,script,language)
- end
- features.mode = "node"
- return "node"
- else
- -- at least one lookup
- found = true
+ if not script then
+ script = latn and "latn" or "dflt"
+ end
+ if trace_automode then
+ report_defining("auto script mode: using script '%s' in font '%s'",script,file.basename(tfmdata.properties.name))
+ end
+ features.script = script
+ return script
+end
+
+local function checkedmode(tfmdata,resources,features)
+ local sequences = resources.sequences
+ if sequences and #sequences > 0 then
+ local script = features.script or "dflt"
+ local language = features.language or "dflt"
+ for feature, value in next, features do
+ if value then
+ local found = false
+ for i=1,#sequences do
+ local sequence = sequences[i]
+ local features = sequence.features
+ if features then
+ local scripts = features[feature]
+ if scripts then
+ local languages = scripts[script]
+ if languages and languages[language] then
+ if found then
+ -- more than one lookup
+ if trace_automode then
+ report_defining("forcing node mode in font %s for feature %s, script %s, language %s (multiple lookups)",file.basename(tfmdata.properties.name),feature,script,language)
+ end
+ features.mode = "node"
+ return "node"
+ elseif needsnodemode[sequence.type] then
+ if trace_automode then
+ report_defining("forcing node mode in font %s for feature %s, script %s, language %s (no base support)",file.basename(tfmdata.properties.name),feature,script,language)
end
+ features.mode = "node"
+ return "node"
+ else
+ -- at least one lookup
+ found = true
end
end
end
@@ -276,10 +358,32 @@ local function modechecker(tfmdata,features,mode) -- we cannot adapt features as
end
end
end
- return "base"
+ end
+ features.mode = "base" -- new, or is this wrong?
+ return "base"
+end
+
+definers.checkedscript = checkedscript
+definers.checkedmode = checkedmode
+
+local function modechecker(tfmdata,features,mode) -- we cannot adapt features as they are shared!
+ if trace_features then
+ report_features(serialize(features,"used"))
+ end
+ local rawdata = tfmdata.shared.rawdata
+ local resources = rawdata and rawdata.resources
+ local script = features.script
+ if resources then
+ if script == "auto" then
+ script = checkedscript(tfmdata,resources,features)
+ end
+ if mode == "auto" then
+ mode = checkedmode(tfmdata,resources,features)
+ end
else
- return mode
+ report_features("missing resources for font''%s'",file.basename(tfmdata.properties.name))
end
+ return mode
end
registerotffeature {
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 57fd53854..9ccad32d3 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -3510,7 +3510,7 @@
\unexpanded\def\definealternativestyle
{\dotripleempty\dodefinealternativestyle}
-\unexpanded\def\definestyle{\definealternativestyle} % later redefined
+\let\definestyle\definealternativestyle % later redefined
%D Maybe too geneneric, but probably ok is the following. (Maybe one
%D day we will use a dedicated grouped command for styles.)
@@ -3565,58 +3565,15 @@
%D \type{\noconvertfont}. In nested calls, we can restore the
%D conversion by saying \type{\redoconvertfont}.
-% subtle ... \expandafter is needed else problems with lookahead caps
-%
-% this will be cleaned up
-%
-% beware: p!defined can contain crap like \edef crap {...} and such
-% so we need to pass #1 as well .. no longer needed in luatex
-
-% \def\@@dodoconvertfont{\csname\@letter@ \p!defined\expandafter\endcsname\gobbleoneargument}
-% \def\@@donoconvertfont{\csname\@noletter@\p!defined\endcsname}
-% \def\@@redoconvertfont{\csname \p!defined\expandafter\endcsname\gobbleoneargument}
-%
-% \unexpanded\def\dodoconvertfont#1% #2% we need the protection
-% {\edef\p!defined{#1}%
-% \ifx\p!defined\empty\else
-% \@EA\dododoconvertfont
-% \fi{#1}}
-%
-% \def\dododoconvertfont % #1 (detokenize no longer needed in luatex)
-% {\ifcsname\@letter@\detokenize\@EA{\p!defined}\endcsname
-% \expandafter\@@dodoconvertfont
-% \else\ifcsname\detokenize\@EA{\p!defined}\endcsname
-% \doubleexpandafter\@@redoconvertfont
-% \else
-% \doubleexpandafter\firstofoneargument
-% \fi\fi} % {#1}
-%
-% \let\doconvertfont\dodoconvertfont
-%
-% \unexpanded\def\noconvertfont#1% #2%
-% {\edef\p!defined{#1}%
-% \ifx\p!defined\empty
-% \else
-% \@EA\nononoconvertfont
-% \fi}
-%
-% \def\nononoconvertfont
-% {\ifcsname\@noletter@\detokenize\@EA{\p!defined}\endcsname
-% \@EA\@@donoconvertfont
-% \fi}
-%
-% %D Extras:
-%
-% \unexpanded\def\dontconvertfont{\let\doconvertfont\noconvertfont}
-% \unexpanded\def\redoconvertfont{\let\doconvertfont\dodoconvertfont}
-
%D These commands are not grouped! Grouping is most probably
%D done by the calling macro's and would lead to unnecessary
%D overhead.
\unexpanded\def\doconvertfont#1% #2% we need the protection
{\edef\currentconvertfont{#1}%
- \ifx\currentconvertfont\empty \else
+ \ifx\currentconvertfont\empty
+ %\expandafter\firstofoneargument
+ \else
\expandafter\dodoconvertfont
\fi}
@@ -3635,6 +3592,32 @@
\unexpanded\def\dontconvertfont{\currentalternativestyleindex\plustwo}
\unexpanded\def\redoconvertfont{\currentalternativestyleindex\plusone}
+%D The new one:
+
+\unexpanded\def\dousestyleparameter#1%
+ {\edef\currentstyleparameter{#1}%
+ \ifx\currentstyleparameter\empty\else
+ \expandafter\dousecurrentstyleparameter
+ \fi}
+
+\unexpanded\def\dousestylehashparameter#1#2%
+ {\ifcsname#1#2\endcsname
+ \expandafter\dousestyleparameter\csname#1#2\endcsname
+ \fi}
+
+\unexpanded\def\dousecurrentstyleparameter % empty check outside here
+ {\edef\detokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}%
+ \settrue\fontattributeisset % reset is done elsewhere
+ \ifcsname\??ft:as:\detokenizedstyleparameter\endcsname
+ \csname\??ft:as:\detokenizedstyleparameter\endcsname
+ \else\ifcsname\detokenizedstyleparameter\endcsname
+ \csname\detokenizedstyleparameter\endcsname
+ \else
+ \currentstyleparameter
+ \fi\fi}
+
+\let\dosetfontattribute\dousestylehashparameter % for a while
+
%D \macros
%D {em,emphasistypeface,emphasisboldface}
%D
@@ -4447,84 +4430,80 @@
\def\removemissingcharacters{\ctxcommand{removemissingcharacters}}
%D New commands (not yet interfaced):
-
-% \def\style[#1]% for inline usage, like \color
-% {\groupedcommand{\ifcsname#1\endcsname\csname#1\endcsname\else\definedfont[#1]\fi}{}}
-%
-% \unexpanded\def\startstyle[#1]%
-% {\begingroup
-% \ifcsname#1\endcsname\csname#1\endcsname\else\definedfont[#1]\fi}
-%
-% \unexpanded\def\stopstyle
-% {\endgroup}
+%D
+%D \startbuffer
+%D \definestyle[one][style=bold,color=darkblue]
+%D
+%D test \one{test} test
+%D test \style[one]{test} test
+%D test \style[color=red]{test} test
+%D test \style[Serif at 20pt]{test} test
+%D \stopbuffer
+%D
+%D \typebuffer \startlines \getbuffer \stoplines
% definitions .. no tagging here
-\def\definestyle
- {\dotripleargument\dodefinestyle}
-
-\def\dodefinestyle[#1][#2][#3]%
- {\doifassignmentelse{#2}\dododefinestyle\definealternativestyle[#1][#2][#3]}
+\installcommandhandler \??cf {style} \??cf
-\def\dododefinestyle[#1][#2][#3]% no commalist and for the moment #3 is ignored
- {\getparameters[\??cf:#1][\c!style=,\c!color=,#2]%
- \setuvalue{\e!start#1}{\begingroup\dostartattributes{\??cf:#1}\c!style\c!color}%
- \setuvalue{\e!stop #1}{\dostopattributes\endgroup}%
- \setuvalue {#1}{\groupedcommand{\dostartattributes{\??cf:#1}\c!style\c!color}\dostopattributes}}
+\appendtoks
+ \letvalue{\??cf\currentstyle\s!check}\relax
+ \setuevalue{\e!start\currentstyle}{\begingroup\use_defined_style{\currentstyle}}%
+ \setuevalue{\e!stop \currentstyle}{\endgroup}%
+ \setuevalue {\currentstyle}{\groupedcommand{\use_defined_style{\currentstyle}}{}}%
+\to \everydefinestyle
-\def\setupstyle
- {\dotripleargument\dosetupstyle}
+\unexpanded\def\use_defined_style#1%
+ {\edef\currentstyle{#1}%
+ \usestylestyleandcolor\c!style\c!color}
-\def\dosetupstyle[#1][#2][#3]% no commalist and for the moment #3 is ignored
- {\ifcsname\??cf:#1\c!style\endcsname
- \getparameters[\??cf:#1][#2]%
- \else
- \getparameters[\??cf:#1][\c!style=,\c!color=,#2]% so we define but without commands (todo for all define related things)
- \fi}
+\unexpanded\def\use_generic_style#1%
+ {\getparameters[\??cf][\c!style=,\c!color=,#1]%
+ \dousestyleparameter\@@cfstyle
+ \dousecolorparameter\@@cfcolor}
% commands
\unexpanded\def\style[#1]%
- {\csname\ifcsname#1\endcsname n\else\ifcsname\??cf:#1\c!style\endcsname c\else d\fi\fi ostyle\endcsname{#1}}
-
-\def\nostyle#1{\csname#1\endcsname}
-\def\costyle#1{\groupedcommand{\dostartattributes{\??cf:#1}\c!style\c!color}\dostopattributes}
-\def\dostyle#1{\doifassignmentelse{#1}\dostyleassignment\dostyledirect{#1}}
-
-\def\dostyleassignment#1%
- {\groupedcommand
- {\getparameters[\??cf][\c!style=,\c!color=,#1]%
- \dostartattributes\??cf\c!style\c!color}
- {\dostopattributes}}
+ {\csname style_%
+ \ifcsname#1\endcsname
+ nop%
+ \else\ifcsname\??cf#1\s!check\endcsname
+ use%
+ \else
+ yes%
+ \fi\fi
+ \endcsname{#1}}
-\def\dostyledirect#1%
- {\groupedcommand
- {\definedfont[#1]}
- {}}
+\def\style_nop #1{\csname#1\endcsname}
+\def\style_use #1{\groupedcommand{\use_defined_style{#1}}{}}
+\def\style_yes #1{\doifassignmentelse{#1}\style_assignment\style_direct{#1}}
+\def\style_assignment#1{\groupedcommand{\use_generic_style{#1}}{}}
+\def\style_direct #1{\groupedcommand{\definedfont[#1]}{}}
% environments
\unexpanded\def\startstyle[#1]%
{\begingroup
- \csname\ifcsname#1\endcsname n\else\ifcsname\??cf:#1\c!style\endcsname c\else d\fi\fi ostyless\endcsname{#1}}
+ \csname start_style_%
+ \ifcsname#1\endcsname
+ nop%
+ \else\ifcsname\??cf#1\s!check\endcsname
+ use%
+ \else
+ yes%
+ \fi\fi
+ \endcsname{#1}}
\unexpanded\def\stopstyle
- {\dostopstyle
- \endgroup
+ {\endgroup
\autoinsertnextspace} % will be configurable, maybe also in \definestartstop
-\def\nostyless#1{\let\dostopstyle\donothing\csname#1\endcsname}
-\def\costyless#1{\let\dostopstyle\dostopattributes\dostartattributes{\??cf:#1}\c!style\c!color}
-\def\dostyless#1{\doifassignmentelse{#1}\dostylessassignment\dostylessdirect{#1}}
-
-\def\dostylessassignment#1%
- {\let\dostopstyle\dostopattributes
- \getparameters[\??cf][\c!style,\c!color=,#1]%
- \dostartattributes\??cf\c!style\c!color}
-
-\def\dostylessdirect#1%
- {\let\dostopstyle\donothing
- \definedfont[#1]\relax}
+\def\start_style_nop #1{\csname#1\endcsname}
+\def\start_style_use #1{\use_defined_style{#1}}
+\def\start_style_yes #1{\doifassignmentelse{#1}\start_style_assignment\start_style_direct{#1}}
+\def\start_style_assignment#1{\usegenericstyle{#1}}
+\def\start_style_direct #1{\definedfont[#1]\relax}
%D Still experimental (might even go away).
diff --git a/tex/context/base/font-otd.lua b/tex/context/base/font-otd.lua
index 501eff41b..ebd487959 100644
--- a/tex/context/base/font-otd.lua
+++ b/tex/context/base/font-otd.lua
@@ -17,11 +17,14 @@ local report_process = logs.reporter("fonts","otf process")
local fonts = fonts
local otf = fonts.handlers.otf
-local fontdata = fonts.hashes.identifiers
+local hashes = fonts.hashes
local definers = fonts.definers
local constructors = fonts.constructors
local specifiers = fonts.specifiers
+local fontdata = hashes.identifiers
+----- fontresources = hashes.resources -- not yet defined
+
local contextsetups = specifiers.contextsetups
local contextnumbers = specifiers.contextnumbers
local contextmerged = specifiers.contextmerged
@@ -32,7 +35,7 @@ local otffeatures = fonts.constructors.newfeatures("otf")
local registerotffeature = otffeatures.register
local fontdynamics = { }
-fonts.hashes.dynamics = fontdynamics
+hashes.dynamics = fontdynamics
local a_to_script = { }
local a_to_language = { }
@@ -49,6 +52,10 @@ function otf.setdynamics(font,attribute)
local dynamics = fontdynamics[font]
local script = features.script or 'dflt'
local language = features.language or 'dflt'
+ if script == "auto" then
+ -- checkedscript and resources are defined later so we cannot shortcut them
+ script = definers.checkedscript(fontdata[font],hashes.resources[font],features)
+ end
local ds = dynamics[script] -- can be metatable magic (less testing)
if not ds then
ds = { }
diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua
index 924e9a69c..03376f94b 100644
--- a/tex/context/base/font-otf.lua
+++ b/tex/context/base/font-otf.lua
@@ -1002,6 +1002,20 @@ local g_directions = {
gpos_reversecontextchain = -1,
}
+-- Research by Khaled Hosny has demonstrated that the font loader merges
+-- regular and AAT features and that these can interfere (especially because
+-- we dropped checking for valid features elsewhere. So, we just check for
+-- the special flag and drop the feature if such a tag is found.
+
+local function supported(features)
+ for i=1,#features do
+ if features[i].ismac then
+ return false
+ end
+ end
+ return true
+end
+
actions["reorganize subtables"] = function(data,filename,raw)
local resources = data.resources
local sequences = { }
@@ -1014,69 +1028,72 @@ actions["reorganize subtables"] = function(data,filename,raw)
if dw then
for k=1,#dw do
local gk = dw[k]
- local typ = gk.type
- local chain = g_directions[typ] or 0
- local subtables = gk.subtables
- if subtables then
- local t = { }
- for s=1,#subtables do
- t[s] = subtables[s].name
+ local features = gk.features
+ if features and supported(features) then
+ local typ = gk.type
+ local chain = g_directions[typ] or 0
+ local subtables = gk.subtables
+ if subtables then
+ local t = { }
+ for s=1,#subtables do
+ t[s] = subtables[s].name
+ end
+ subtables = t
end
- subtables = t
- end
- local flags, markclass = gk.flags, nil
- if flags then
- local t = { -- forcing false packs nicer
- (flags.ignorecombiningmarks and "mark") or false,
- (flags.ignoreligatures and "ligature") or false,
- (flags.ignorebaseglyphs and "base") or false,
- flags.r2l or false,
- }
- markclass = flags.mark_class
- if markclass then
- markclass = resources.markclasses[markclass]
+ local flags, markclass = gk.flags, nil
+ if flags then
+ local t = { -- forcing false packs nicer
+ (flags.ignorecombiningmarks and "mark") or false,
+ (flags.ignoreligatures and "ligature") or false,
+ (flags.ignorebaseglyphs and "base") or false,
+ flags.r2l or false,
+ }
+ markclass = flags.mark_class
+ if markclass then
+ markclass = resources.markclasses[markclass]
+ end
+ flags = t
end
- flags = t
- end
- --
- local name = gk.name
- --
- local features = gk.features
- if features then
- -- scripts, tag, ismac
- local f = { }
- for i=1,#features do
- local df = features[i]
- local tag = strip(lower(df.tag))
- local ft = f[tag] if not ft then ft = {} f[tag] = ft end
- local dscripts = df.scripts
- for i=1,#dscripts do
- local d = dscripts[i]
- local languages = d.langs
- local script = strip(lower(d.script))
- local fts = ft[script] if not fts then fts = {} ft[script] = fts end
- for i=1,#languages do
- fts[strip(lower(languages[i]))] = true
+ --
+ local name = gk.name
+ --
+ local features = gk.features
+ if features then
+ -- scripts, tag, ismac
+ local f = { }
+ for i=1,#features do
+ local df = features[i]
+ local tag = strip(lower(df.tag))
+ local ft = f[tag] if not ft then ft = {} f[tag] = ft end
+ local dscripts = df.scripts
+ for i=1,#dscripts do
+ local d = dscripts[i]
+ local languages = d.langs
+ local script = strip(lower(d.script))
+ local fts = ft[script] if not fts then fts = {} ft[script] = fts end
+ for i=1,#languages do
+ fts[strip(lower(languages[i]))] = true
+ end
end
end
+ sequences[#sequences+1] = {
+ type = typ,
+ chain = chain,
+ flags = flags,
+ name = name,
+ subtables = subtables,
+ markclass = markclass,
+ features = f,
+ }
+ else
+ lookups[name] = {
+ type = typ,
+ chain = chain,
+ flags = flags,
+ subtables = subtables,
+ markclass = markclass,
+ }
end
- sequences[#sequences+1] = {
- type = typ,
- chain = chain,
- flags = flags,
- name = name,
- subtables = subtables,
- markclass = markclass,
- features = f,
- }
- else
- lookups[name] = {
- type = typ,
- chain = chain,
- flags = flags,
- subtables = subtables,
- markclass = markclass,
- }
end
end
end
diff --git a/tex/context/base/grph-fil.lua b/tex/context/base/grph-fil.lua
index 0856f5b08..da7441288 100644
--- a/tex/context/base/grph-fil.lua
+++ b/tex/context/base/grph-fil.lua
@@ -12,6 +12,8 @@ local trace_run = false trackers.register("graphic.runfile",function(v) trace_r
local report_run = logs.reporter("graphics","run")
+-- this code will move
+
local allocate = utilities.storage.allocate
local collected = allocate()
@@ -33,17 +35,20 @@ job.register('job.files.collected', tobesaved, initializer)
jobfiles.forcerun = false
-function jobfiles.run(name,command)
+function jobfiles.run(name,action)
local oldchecksum = collected[name]
local newchecksum = file.checksum(name)
if jobfiles.forcerun or not oldchecksum or oldchecksum ~= newchecksum then
if trace_run then
report_run("processing file, changes in '%s', processing forced",name)
end
- if command and command ~= "" then
- os.execute(command)
+ local a = type(action)
+ if a == "function" then
+ a(name)
+ elseif a == "string" and action ~= "" then
+ os.execute(a)
else
- report_run("processing file, no command given for processing '%s'",name)
+ report_run("processing file, no action given for processing '%s'",name)
end
elseif trace_run then
report_run("processing file, no changes in '%s', not processed",name)
@@ -51,6 +56,8 @@ function jobfiles.run(name,command)
tobesaved[name] = newchecksum
end
+--
+
function jobfiles.context(name,options)
if type(name) == "table" then
local result = { }
diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua
index bf05e2c64..48f6a39fe 100644
--- a/tex/context/base/l-file.lua
+++ b/tex/context/base/l-file.lua
@@ -226,7 +226,7 @@ end
--~ variant. After some skyping we got it sort of compatible with the old
--~ one. After that the anchoring to currentdir was added in a better way.
--~ Of course there are some optimizations too. Finally we had to deal with
---~ windows drive prefixes and thinsg like sys://.
+--~ windows drive prefixes and things like sys://.
function file.collapsepath(str,anchor)
if anchor and not find(str,"^/") and not find(str,"^%a:") then
@@ -254,7 +254,7 @@ function file.collapsepath(str,anchor)
if element == '.' then
-- do nothing
elseif element == '..' then
- local n = i -1
+ local n = i - 1
while n > 0 do
local element = oldelements[n]
if element ~= '..' and element ~= '.' then
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua
index 9fb22e1b5..25d48ee75 100644
--- a/tex/context/base/l-lpeg.lua
+++ b/tex/context/base/l-lpeg.lua
@@ -600,7 +600,7 @@ end
-- For the moment here, but it might move to utilities. Beware, we need to
-- have the longest keyword first, so 'aaa' comes beforte 'aa' which is why we
--- loop back from the end.
+-- loop back from the end cq. prepend.
local sort, fastcopy, sortedkeys = table.sort, table.fastcopy, table.sortedkeys -- dependency!
@@ -620,13 +620,13 @@ function lpeg.append(list,pp,delayed,checked)
elseif delayed then -- hm, it looks like the lpeg parser resolves anyway
local keys = sortedkeys(list)
if p then
- for i=#keys,1,-1 do
+ for i=1,#keys,1 do
local k = keys[i]
local v = list[k]
p = P(k)/list + p
end
else
- for i=#keys,1,-1 do
+ for i=1,#keys do
local k = keys[i]
local v = list[k]
if p then
@@ -642,7 +642,7 @@ function lpeg.append(list,pp,delayed,checked)
elseif checked then
-- problem: substitution gives a capture
local keys = sortedkeys(list)
- for i=#keys,1,-1 do
+ for i=1,#keys do
local k = keys[i]
local v = list[k]
if p then
@@ -661,7 +661,7 @@ function lpeg.append(list,pp,delayed,checked)
end
else
local keys = sortedkeys(list)
- for i=#keys,1,-1 do
+ for i=1,#keys do
local k = keys[i]
local v = list[k]
if p then
@@ -674,6 +674,9 @@ function lpeg.append(list,pp,delayed,checked)
return p
end
+-- inspect(lpeg.append({ a = "1", aa = "1", aaa = "1" } ,nil,true))
+-- inspect(lpeg.append({ ["degree celsius"] = "1", celsius = "1", degree = "1" } ,nil,true))
+
-- function lpeg.exact_match(words,case_insensitive)
-- local pattern = concat(words)
-- if case_insensitive then
diff --git a/tex/context/base/luat-mac.lua b/tex/context/base/luat-mac.lua
index 5189759a5..7287692fc 100644
--- a/tex/context/base/luat-mac.lua
+++ b/tex/context/base/luat-mac.lua
@@ -112,7 +112,7 @@ local poplocal = always / pop
local declaration = variable / set
local identifier = variable / get
-local argument = leftbrace * ((identifier + (1-rightbrace))^0) * rightbrace
+local argument = P { leftbrace * ((identifier + V(1) + (1 - leftbrace - rightbrace))^0) * rightbrace }
local function matcherror(str,pos)
report_macros("runaway definition at: %s",sub(str,pos-30,pos))
@@ -250,6 +250,7 @@ end
-- print(macros.preprocessed([[\def\test#oeps{test:#{oeps}}]]))
-- print(macros.preprocessed([[\def\test#{oeps:1}{test:#{oeps:1}}]]))
-- print(macros.preprocessed([[\def\test#{oeps}{test:#oeps}]]))
+-- print(macros.preprocessed([[\def\x[#a][#b][#c]{\setvalue{\y{#a}\z{#b}}{#c}}]]))
-- print(macros.preprocessed([[\def\test#{oeps}{test:#oeps \halign{##\cr #oeps\cr}]]))
-- print(macros.preprocessed([[\def\test#{oeps}{test:#oeps \halign{##\cr #oeps\cr}}]]))
-- print(macros.preprocessed([[% test
diff --git a/tex/context/base/lxml-aux.lua b/tex/context/base/lxml-aux.lua
index 560ef557d..4bcac4520 100644
--- a/tex/context/base/lxml-aux.lua
+++ b/tex/context/base/lxml-aux.lua
@@ -18,6 +18,7 @@ local xml = xml
local xmlconvert, xmlcopy, xmlname = xml.convert, xml.copy, xml.name
local xmlinheritedconvert = xml.inheritedconvert
local xmlapplylpath = xml.applylpath
+local xmlfilter = xml.filter
local type, setmetatable, getmetatable = type, setmetatable, getmetatable
local insert, remove, fastcopy, concat = table.insert, table.remove, table.fastcopy, table.concat
@@ -167,7 +168,7 @@ local function xmltoelement(whatever,root)
end
local element
if type(whatever) == "string" then
- element = xmlinheritedconvert(whatever,root)
+ element = xmlinheritedconvert(whatever,root) -- beware, not really a root
else
element = whatever -- we assume a table
end
@@ -273,32 +274,39 @@ end
local function inject_element(root,pattern,whatever,prepend)
local element = root and xmltoelement(whatever,root)
local collected = element and xmlapplylpath(root,pattern)
- if collected then
- for c=1,#collected do
- local e = collected[c]
- local r = e.__p__
- local d, k, rri = r.dt, e.ni, r.ri
- local edt = (rri and d[rri].dt) or (d and d[k] and d[k].dt)
- if edt then
- local be, af
- local cp = copiedelement(element,e)
- if prepend then
- be, af = cp, edt
- else
- be, af = edt, cp
- end
- local bn = #be
- for i=1,#af do
- bn = bn + 1
- be[bn] = af[i]
- end
- if rri then
- r.dt[rri].dt = be
- else
- d[k].dt = be
- end
- redo_ni(d)
+ local function inject_e(e)
+ local r = e.__p__
+ local d, k, rri = r.dt, e.ni, r.ri
+ local edt = (rri and d[rri].dt) or (d and d[k] and d[k].dt)
+ if edt then
+ local be, af
+ local cp = copiedelement(element,e)
+ if prepend then
+ be, af = cp, edt
+ else
+ be, af = edt, cp
+ end
+ local bn = #be
+ for i=1,#af do
+ bn = bn + 1
+ be[bn] = af[i]
end
+ if rri then
+ r.dt[rri].dt = be
+ else
+ d[k].dt = be
+ end
+ redo_ni(d)
+ end
+ end
+ if not collected then
+ -- nothing
+ elseif collected.tg then
+ -- first or so
+ inject_e(collected)
+ else
+ for c=1,#collected do
+ inject_e(collected[c])
end
end
end
@@ -306,16 +314,23 @@ end
local function insert_element(root,pattern,whatever,before) -- todo: element als functie
local element = root and xmltoelement(whatever,root)
local collected = element and xmlapplylpath(root,pattern)
- if collected then
+ local function insert_e(e)
+ local r = e.__p__
+ local d, k = r.dt, e.ni
+ if not before then
+ k = k + 1
+ end
+ insert(d,k,copiedelement(element,r))
+ redo_ni(d)
+ end
+ if not collected then
+ -- nothing
+ elseif collected.tg then
+ -- first or so
+ insert_e(collected)
+ else
for c=1,#collected do
- local e = collected[c]
- local r = e.__p__
- local d, k = r.dt, e.ni
- if not before then
- k = k + 1
- end
- insert(d,k,copiedelement(element,r))
- redo_ni(d)
+ insert_e(collected[c])
end
end
end
@@ -618,3 +633,49 @@ xml.remap_tag = xml.remaptag obsolete.remap_tag
xml.remap_name = xml.remapname obsolete.remap_name = xml.remapname
xml.remap_namespace = xml.remapnamespace obsolete.remap_namespace = xml.remapnamespace
+-- new (probably ok)
+
+function xml.cdata(e)
+ if e then
+ local dt = e.dt
+ if dt and #dt == 1 then
+ local first = dt[1]
+ return first.tg == "@cd@" and first.dt[1] or ""
+ end
+ end
+ return ""
+end
+
+function xml.finalizers.xml.cdata(collected)
+ if collected then
+ local e = collected[1]
+ if e then
+ local dt = e.dt
+ if dt and #dt == 1 then
+ local first = dt[1]
+ return first.tg == "@cd@" and first.dt[1] or ""
+ end
+ end
+ end
+ return ""
+end
+
+function xml.insertcomment(e,str,n) -- also insertcdata
+ table.insert(e.dt,n or 1,{
+ tg = "@cm@",
+ ns = "",
+ special = true,
+ at = { },
+ dt = { str },
+ })
+end
+
+function xml.setcdata(e,str) -- also setcomment
+ e.dt = { {
+ tg = "@cd@",
+ ns = "",
+ special = true,
+ at = { },
+ dt = { str },
+ } }
+end
diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua
index 5b841e218..2d99577b6 100644
--- a/tex/context/base/lxml-tab.lua
+++ b/tex/context/base/lxml-tab.lua
@@ -774,11 +774,13 @@ end
xml.convert = xmlconvert
-function xml.inheritedconvert(data,xmldata)
+function xml.inheritedconvert(data,xmldata) -- xmldata is parent
local settings = xmldata.settings
- settings.parent_root = xmldata -- to be tested
+ if settings then
+ settings.parent_root = xmldata -- to be tested
+ end
-- settings.no_root = true
- local xc = xmlconvert(data,settings)
+ local xc = xmlconvert(data,settings) -- hm, we might need to locate settings
-- xc.settings = nil
-- xc.entities = nil
-- xc.special = nil
diff --git a/tex/context/base/lxml-xml.lua b/tex/context/base/lxml-xml.lua
index d87ad8b1b..7ecb69196 100644
--- a/tex/context/base/lxml-xml.lua
+++ b/tex/context/base/lxml-xml.lua
@@ -164,7 +164,7 @@ end
local function text(collected) -- hybrid
if collected then -- no # test here !
- local e = collected[1] or collected
+ local e = collected[1] or collected -- why fallback to element, how about cdata
return e and xmltotext(e) or ""
else
return ""
@@ -334,7 +334,7 @@ function xml.raw(id,pattern)
end
end
-function xml.text(id,pattern)
+function xml.text(id,pattern) -- brrr either content or element (when cdata)
if pattern then
-- return text(xmlfilter(id,pattern))
local collected = xmlfilter(id,pattern)
diff --git a/tex/context/base/m-database.mkiv b/tex/context/base/m-database.mkiv
index 80ae75258..370045d4b 100644
--- a/tex/context/base/m-database.mkiv
+++ b/tex/context/base/m-database.mkiv
@@ -22,34 +22,6 @@
\def\c!quotechar {quotechar}
\def\c!commentchar {commentchar}
-% \def\????db{@@@@db}
-%
-% \installparameterhandler \????db {database}
-% \installcommandhandler \????db {database} \????db % #3 == defaultroot
-% \installattributehandler \????db {database}
-%
-% or:
-%
-% \installnamespace{db} \installcommandhandler\????db{database}\????db
-%
-% \appendtoks
-% \getparameters
-% [\????db\currentdatabase]
-% [\c!separator={,},
-% \c!quotechar=,
-% \c!commentchar=,
-% \c!setups=,
-% \c!before=,
-% \c!after=,
-% \c!first=,
-% \c!last=,
-% \c!left=,
-% \c!right=,
-% \c!command=]%
-% \to \everypresetdatabase
-%
-% or:
-
\definenamespace
[db]
[type=module,
diff --git a/tex/context/base/math-act.lua b/tex/context/base/math-act.lua
index 061da0519..cc058bf60 100644
--- a/tex/context/base/math-act.lua
+++ b/tex/context/base/math-act.lua
@@ -50,6 +50,9 @@ local how = {
function mathematics.scaleparameters(target,original)
if not target.properties.math_is_scaled then
+-- print("\n",target.properties.fontname)
+-- print(original.mathparameters.DisplayOperatorMinHeight)
+-- print(target.mathparameters.DisplayOperatorMinHeight)
local mathparameters = target.mathparameters
if mathparameters and next(mathparameters) then
local parameters = target.parameters
@@ -59,16 +62,21 @@ function mathematics.scaleparameters(target,original)
for name, value in next, mathparameters do
local h = how[name]
if h == "unscaled" then
- mathparameters[name] = value
+ -- kept
elseif h == "horizontal" then
- mathparameters[name] = value * hfactor
+ value = value * hfactor
elseif h == "vertical"then
- mathparameters[name] = value * vfactor
+ value = value * vfactor
else
- mathparameters[name] = value * factor
+ value = value * factor
end
+-- if name == "DisplayOperatorMinHeight" then
+-- report_math("f: %s, p: %s, h: %s, b: %s, a: %s",target.properties.fontname,name,h or "scaled",mathparameters[name],value)
+-- end
+ mathparameters[name] = value
end
end
+-- print(mathparameters.DisplayOperatorMinHeight)
target.properties.math_is_scaled = true
end
end
diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv
index 9efd948a2..9e2837cc2 100644
--- a/tex/context/base/math-ali.mkiv
+++ b/tex/context/base/math-ali.mkiv
@@ -15,11 +15,20 @@
\unprotect
-% todo: \aligntab
-% todo: less code (more efficient)
+% helpers .. will move
+
+\def\doxxdoubleempty#1#2%
+ {\ifx#2[\expandafter\dodoxxdoubleempty\else\expandafter\noxxdoubleempty\fi#1#2}
+
+\def\dodoxxdoubleempty#1[#2]#3%
+ {\ifx#3[\else\expandafter\nonoxxdoubleempty\fi#1[#2]#3}
+
+\def\noxxdoubleempty #1{#1[][]}
+\def\nonoxxdoubleempty#1[#2]{#1[#2][]}
%D The code here has been moved from other files. Beware: the \MKII\ and
-%D \MKIV\ code is not gathered in files with the same name.
+%D \MKIV\ code is not gathered in files with the same name. In the
+%D meantime this code has been adapted to \MKIV\ but mnore is possible.
%D \macros
%D {definemathalignment, setupmathalignment, startmathalignment}
@@ -29,31 +38,24 @@
% n>1 #### needed, strange # interaction in recurse
-\def\presetdisplaymath{\displ@y} % some day i will relocate the plain stuff
+\def\presetdisplaymath{\displ@y}
-\def\buildeqalign
+\def\math_build_eqalign
{\scratchtoks\emptytoks
\dorecurse{\mathalignmentparameter\c!m}
{\ifnum\recurselevel>\plusone
- \appendtoks
- \tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint
- \to\scratchtoks
+ %\appendtoks
+ % \tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint
+ %\to\scratchtoks
+ \scratchtoks\expandafter{\the\scratchtoks\tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint}%
\fi
\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
\dorecurse{\numexpr\mathalignmentparameter\c!n-\plusone\relax}
{\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}}%
\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}
-\def\forgetalign
- {\tabskip\zeropoint\everycr\emptytoks}
-
-\let\firstineqalign\empty
-\let\nextineqalign \empty
-\let\leftofeqalign \empty
-\let\rightofeqalign\empty
-
-\def\mathineqalign#1{$\forgetalign\displaystyle{{}#1{}}$}
-\def\textineqalign#1{$\forgetalign#1$}
+\def\math_math_in_eqalign#1{$\tabskip\zeropoint\everycr\emptytoks\displaystyle{{}#1{}}$}
+\def\math_text_in_eqalign#1{$\tabskip\zeropoint\everycr\emptytoks#1$}
\def\eqalign#1% why no halign here, probably because of displaywidth
{\emptyhbox\,\vcenter
@@ -66,65 +68,65 @@
\setnewconstant\eqalignmode\plusone
-\def\preparereqalignno
- {\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
- \!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
+\def\math_prepare_r_eqalign_no
+ {\!!toksa{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ \!!toksb{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
\ifnum\mathraggedstatus=\plusone
- \!!toksc{\hfil&\span\textineqalign{##}\tabskip\zeropoint}%
+ \!!toksc{\hfil&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
\else\ifnum\mathraggedstatus=\plusthree
- \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\span\textineqalign{##}\tabskip\zeropoint}%
+ \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
\else
- \!!toksc{\hfil\tabskip\centering&\llap{\span\textineqalign{##}}\tabskip\zeropoint}%
+ \!!toksc{\hfil\tabskip\centering&\llap{\span\math_text_in_eqalign{##}}\tabskip\zeropoint}%
\fi\fi
\global\mathnumberstatus\zerocount
- \buildeqalign
+ \math_build_eqalign
\presetdisplaymath
\tabskip\centering}
-\def\prepareleqalignno
- {\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
- \!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
+\def\math_prepare_l_eqalign_no
+ {\!!toksa{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ \!!toksb{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
% problem: number is handled after rest and so ends up in the margin
\ifnum\mathraggedstatus=\plusone
- \!!toksc{\hfil&\kern-\displaywidth\rlap{\span\textineqalign{##}}\tabskip\displaywidth}%
+ \!!toksc{\hfil&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\else\ifnum\mathraggedstatus=\plusthree
- \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\kern-\displaywidth\span\mrlap{\span\textineqalign{##}}\tabskip\displaywidth}%
+ \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\kern-\displaywidth\span\math_rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\else
- \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\textineqalign{##}}\tabskip\displaywidth}%
+ \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\fi\fi
\global\mathnumberstatus\zerocount
- \buildeqalign
+ \math_build_eqalign
\presetdisplaymath
\tabskip\centering}
-\def\dobotheqalignno#1#2%
+\def\math_both_eqalign_no#1#2%
{\ifmmode
\displ@y % \let\doplaceformulanumber\relax % strange hack
\vcenter\bgroup
- \let\finishalignno\egroup
+ \let\math_finish_eqalign_no\egroup
\else
- \let\finishalignno\relax
+ \let\math_finish_eqalign_no\relax
\fi
#1%
\halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#2\crcr}%
- \finishalignno}
+ \math_finish_eqalign_no}
-\def\dobothaligneqalignno#1%
+\def\math_both_eqalign_no_aligned#1%
{\ifmmode
\displ@y
\global\mathnumberstatus\plusone
\ifcase\mathraggedstatus
- \def\finishalignno{\crcr\egroup}%
+ \def\math_finish_eqalign_no{\crcr\egroup}%
\else
% we're in a mathbox
\vcenter\bgroup
- \def\finishalignno{\crcr\egroup\egroup}%
+ \def\math_finish_eqalign_no{\crcr\egroup\egroup}%
\fi
\fi
#1%
\halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}
-\def\mrlap#1%
+\def\math_rlap#1%
{\setbox\scratchbox\hbox{#1}%
\ifdim\wd\scratchbox>\mathnumbercorrection
\xdef\mathnumbercorrection{\the\wd\scratchbox}%
@@ -132,30 +134,23 @@
\box\scratchbox
\global\mathnumberstatus\plustwo}
-% \def\dobothaligneqalignno#1%
-% {\ifmmode
-% \displ@y
-% \global\mathnumberstatus\plusone
-% we're in a mathbox
-% \vcenter\bgroup
-% \def\finishalignno{\crcr\egroup\egroup}%
-% \else
-% \def\finishalignno{\crcr\egroup}%
-% \fi
-% #1%
-% \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}
-
-\def\reqalignno {\dobotheqalignno \preparereqalignno}
-\def\leqalignno {\dobotheqalignno \prepareleqalignno}
-\def\alignreqalignno{\dobothaligneqalignno\preparereqalignno}
-\def\alignleqalignno{\dobothaligneqalignno\prepareleqalignno}
-\def\finishalignno {\crcr\egroup}
-
-\let \equalignno \reqalignno
-\let\aligneqalignno\alignreqalignno
+\def\math_handle_eqalign_no_r_normal {\math_both_eqalign_no_normal \math_prepare_r_eqalign_no}
+\def\math_handle_eqalign_no_l_normal {\math_both_eqalign_no_normal \math_prepare_l_eqalign_no}
+\def\math_handle_eqalign_no_r_aligned{\math_both_eqalign_no_aligned\math_prepare_r_eqalign_no}
+\def\math_handle_eqalign_no_l_aligned{\math_both_eqalign_no_aligned\math_prepare_l_eqalign_no}
+\def\math_finish_eqalign_no {\crcr\egroup}
+
+\let \reqalignno \math_handle_eqalign_no_r_normal
+\let \leqalignno \math_handle_eqalign_no_l_normal
+\let\alignreqalignno \math_handle_eqalign_no_r_aligned
+\let\alignleqalignno \math_handle_eqalign_no_l_aligned
+\let \equalignno \math_handle_eqalign_no_r_normal
+\let \aligneqalignno \math_handle_eqalign_no_r_aligned
%D Here we implement the user interface part. We start with basic math alignments:
+\newcount\c_math_eqalign_column
+
\newtoks \everymathalignment
\def\math_alignment_NR_indeed[#1][#2]%
@@ -185,7 +180,7 @@
\let\NR\math_alignment_NR
\to \everymathalignment
-\def\math_alignment_start#1%
+\unexpanded\def\math_alignment_start#1%
{\edef\currentmathalignment{#1}%
\dosingleempty\math_alignment_start_indeed}
@@ -195,25 +190,25 @@
\setupmathalignment[\currentmathalignment][#1]%
\fi
\the\everymathalignment
- \eqaligncolumn\zerocount
+ \c_math_eqalign_column\zerocount
\processcommacommand
[\mathalignmentparameter\c!align]
- {\advance\eqaligncolumn\plusone\doseteqaligncolumn}% takes argument
- \global\eqaligncolumn\plusone
+ {\advance\c_math_eqalign_column\plusone\doseteqaligncolumn}% takes argument
+ \global\c_math_eqalign_column\plusone
\dostarttagged\t!math\empty
\dostarttagged\t!mathtable\currentmathalignment
\numberedeqalign}
\def\math_alignment_stop
- {\finishalignno
+ {\math_finish_eqalign_no
\dostoptagged
\dostoptagged}
\installcommandhandler \??eq {mathalignment} \??eq
\appendtoks
- \setevalue{\e!start\currentmathalignment}{\noexpand\math_alignment_start{\currentmathalignment}}%
- \setevalue{\e!stop \currentmathalignment}{\noexpand\math_alignment_stop}%
+ \setuevalue{\e!start\currentmathalignment}{\math_alignment_start{\currentmathalignment}}%
+ \setvalue {\e!stop \currentmathalignment}{\math_alignment_stop}%
\to \everydefinemathalignment
\setupmathalignment
@@ -224,59 +219,37 @@
\definemathalignment[align] % default case (this is what amstex users expect)
\definemathalignment[\v!mathalignment] % prefered case (this is cleaner, less clashing)
-% helpers
-
\def\numberedeqalign
- {\doifelse{\formulaparameter\c!location}\v!left\alignleqalignno\alignreqalignno}
-
-\def\doxxdoubleempty#1#2%
- {\ifx#2[\expandafter\dodoxxdoubleempty\else\expandafter\noxxdoubleempty\fi#1#2}
+ {\doifelse{\formulaparameter\c!location}\v!left
+ \math_handle_eqalign_no_l_aligned
+ \math_handle_eqalign_no_r_aligned}
-\def\dodoxxdoubleempty#1[#2]#3%
- {\ifx#3[\else\expandafter\nonoxxdoubleempty\fi#1[#2]#3}
-
-\def\noxxdoubleempty #1{#1[][]}
-\def\nonoxxdoubleempty#1[#2]{#1[#2][]}
-
-\newcount\eqaligncolumn
-
-\def\firstineqalign
- {\global\eqaligncolumn\plusone
+\def\math_first_in_eqalign
+ {\global\c_math_eqalign_column\plusone
\dostarttagged\t!mathtablerow \empty
\dostarttagged\t!mathtablecell\empty}
-\def\nextineqalign
- {\global\advance\eqaligncolumn\plusone
+\def\math_next_in_eqalign
+ {\global\advance\c_math_eqalign_column\plusone
\dostoptagged % finish cell
\dostarttagged\t!mathtablecell\empty}
-% \def\leftofeqalign {\getvalue{\??eq:\v!left :\number\eqaligncolumn}}
-% \def\rightofeqalign{\getvalue{\??eq:\v!right:\number\eqaligncolumn}}
-
-% \def\doseteqaligncolumn#1% we could just add to the preamble (as with other alignments)
-% {\letvalueempty{\??eq:\v!left :\number\eqaligncolumn}%
-% \letvalueempty{\??eq:\v!right:\number\eqaligncolumn}%
-% \doif{#1}\v!left {\letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfill}%
-% \doif{#1}\v!right {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\hfill}%
-% \doif{#1}\v!middle{\letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfill
-% \letvalue{\??eq:\v!left :\number\eqaligncolumn}\hfill}}
-
-\def\leftofeqalign
- {\ifcsname\??eq::a::\number\eqaligncolumn\endcsname
- \ifcase\csname\??eq::a::\number\eqaligncolumn\endcsname\or
+\def\math_left_of_equalign
+ {\ifcsname\??eq::a::\number\c_math_eqalign_column\endcsname
+ \ifcase\csname\??eq::a::\number\c_math_eqalign_column\endcsname\or
\relax \or \hfill \or \hfill
\fi
\fi}
-\def\rightofeqalign
- {\ifcsname\??eq::a::\number\eqaligncolumn\endcsname
- \ifcase\csname\??eq::a::\number\eqaligncolumn\endcsname\or
+\def\math_right_of_eqalign
+ {\ifcsname\??eq::a::\number\c_math_eqalign_column\endcsname
+ \ifcase\csname\??eq::a::\number\c_math_eqalign_column\endcsname\or
\hfill \or \relax \or \hfill
\fi
\fi}
\def\doseteqaligncolumn#1% we could just add to the preamble (as with other alignments)
- {\expandafter\let\csname\??eq::a::\number\eqaligncolumn\expandafter\endcsname
+ {\expandafter\let\csname\??eq::a::\number\c_math_eqalign_column\expandafter\endcsname
\csname\??eq::a::\ifcsname\??eq::a::#1\endcsname#1\else\v!normal\fi\endcsname}
\letvalue{\??eq::a::\v!normal}\zerocount
@@ -284,10 +257,7 @@
\letvalue{\??eq::a::\v!right }\plustwo
\letvalue{\??eq::a::\v!middle}\plusthree
-\def\dodoalignNC
- {\gdef\doalignNC##1{&##1}}
-
-\def\doalignNR[#1][#2]%
+\def\math_align_NR_generic[#1][#2]%
{\donestedformulanumber{#1}{#2}\crcr}
%D \starttyping
@@ -426,20 +396,7 @@
%D
%D Another wish \unknown
-\unexpanded\def\setupmathcases
- {\dodoubleempty\dosetupmathcases}
-
-\def\dosetupmathcases[#1][#2]%
- {\ifsecondargument
- \getparameters[\??ce#1][#2]%
- \else
- \getparameters[\??ce][#1]%
- \fi}
-
-\let\currentmathcases\empty
-
-\def\mathcasesparameter#1%
- {\executeifdefined{\??ce\currentmathcases#1}{\executeifdefined{\??ce#1}\empty}}
+\installcommandhandler \??ce {mathcases} \??ce
\setupmathcases
[\c!distance=1em,
@@ -447,52 +404,54 @@
\c!left={\left\{\,},
\c!right={\right.}]
-\def\dodocasesNC
- {\gdef\docasesNC{\endmath&}}
-
-\let\docasesNR\doalignNR
+\appendtoks
+ \setuevalue{\e!start\currentmathcases}{\math_cases_start{\currentmathcases}}%
+ \setvalue {\e!stop \currentmathcases}{\math_cases_stop}%
+\to \everydefinemathcases
-\def\dostartmathcases[#1][#2]%
+\unexpanded\def\math_cases_start#1%
{\begingroup
\edef\currentmathcases{#1}%
- \doifassignmentelse{#2}{\setupmathcases[#1][#2]}\donothing
+ \dosingleempty\math_cases_start_indeed}
+
+\unexpanded\def\math_cases_start_indeed[#1]%
+ {\iffirstargument
+ \setupcurrentmathcases[#1]%
+ \fi
\mathcasesparameter\c!left
\vcenter\bgroup
- \pushmacro\docasesNC
+ \pushmacro\math_cases_NC
\let\endmath\relax
- \def\NC{\docasesNC}%
- \def\MC{\docasesNC\ifmmode\else$\def\endmath{$}\fi}%
- \global\let\docasesNC\dodocasesNC
- \def\NR{\unskip\endmath&\global\let\docasesNC\dodocasesNC\doxxdoubleempty\docasesNR}%
+ \def\NC{\math_cases_NC}%
+ \def\MC{\math_cases_NC\ifmmode\else$\def\endmath{$}\fi}%
+ \global\let\math_cases_NC\math_cases_NC_indeed
+ \def\NR{\unskip\endmath&\global\let\math_cases_NC\math_cases_NC_indeed\doxxdoubleempty\math_cases_NR}%
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
\tabskip\zeropoint
- \global\eqaligncolumn\plusone
+ \global\c_math_eqalign_column\plusone
\halign\bgroup
$\mathcasesparameter\c!style##$\hfil
&\hskip\mathcasesparameter\c!distance\relax
- \popmacro\docasesNC##\hfil
+ \popmacro\math_cases_NC##\hfil
&\hskip\mathcasesparameter\c!numberdistance\relax
\let\formuladistance\!!zeropoint
- \span\textineqalign{##}%
+ \span\math_text_in_eqalign{##}%
\crcr} % todo: number
-\def\dostopmathcases
+\def\math_cases_stop
{\crcr
\egroup
- \popmacro\docasesNC
+ \popmacro\math_cases_NC
\egroup
\mathcasesparameter\c!right
\endgroup}
-\unexpanded\def\definemathcases
- {\dodoubleempty\dodefinemathcases}
+\def\math_cases_NC_indeed
+ {\gdef\math_cases_NC{\endmath&}}
-\def\dodefinemathcases[#1]% [#2]%
- {\setvalue{\e!start#1}{\dodoubleempty\dostartmathcases[#1]}%
- \setvalue{\e!stop #1}{\dostopmathcases}%
- \setupmathcases[#1]}% [#2]
+\let\math_cases_NR\math_align_NR_generic
\definemathcases[cases]
\definemathcases[\v!mathcases]
@@ -542,20 +501,7 @@
%D
%D Yet another one \unknown
-\unexpanded\def\setupmathmatrix
- {\dodoubleempty\dosetupmathmatrix}
-
-\def\dosetupmathmatrix[#1][#2]%
- {\ifsecondargument
- \getparameters[\??mx#1][#2]%
- \else
- \getparameters[\??mx][#1]%
- \fi}
-
-\let\currentmathmatrix\empty
-
-\def\mathmatrixparameter#1%
- {\executeifdefined{\??mx\currentmathmatrix#1}{\executeifdefined{\??mx#1}\empty}}
+\installcommandhandler \??mk {mathmatrix} \??mk
\setupmathmatrix
[\c!distance=1em,
@@ -563,127 +509,22 @@
\c!right=,
\c!align=\v!middle]
-\def\dosetmatrixcolumn#1% hh: todo: \definematrixalign
- {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\hfil
- \letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfil
- \doif{#1}\v!left {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\relax
- \letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfil}%
- \doif{#1}\v!right {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\hfil
- \letvalue{\??eq:\v!right:\number\eqaligncolumn}\relax }%
- \doif{#1}\v!middle{\letvalue{\??eq:\v!left :\number\eqaligncolumn}\hfil
- \letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfil}}
-
-\def\buildmathmatrix % beware: etex only
- {\scratchtoks\emptytoks
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
- \dorecurse{\numexpr\scratchcounter-\plusone\relax}
- {\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}%
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}
-
-\def\preparemathmatrix
- {\!!toksa{\strut \firstineqalign\leftofeqalign \span
- \textineqalign{\mathmatrixparameter\c!style ##}\rightofeqalign}%
- \!!toksb{&\hskip\mathmatrixparameter\c!distance
- \nextineqalign\leftofeqalign \span
- \textineqalign{\mathmatrixparameter\c!style ##}\rightofeqalign}%
- \!!toksc{&&\hskip\mathmatrixparameter\c!distance
- \leftofeqalign \span
- \textineqalign{\mathmatrixparameter\c!style ##}\rightofeqalign}%
- \buildmathmatrix
- \halign \@EA \bgroup\the\scratchtoks \crcr}
-
-\unexpanded\def\definemathmatrix
- {\dodoubleempty\dodefinemathmatrix}
-
-\def\dodefinemathmatrix[#1]% [#2]%
- {\setuvalue{\e!start#1}{\dodoubleempty\dostartmathmatrix[#1]}%
- \setvalue {\e!stop #1}{\dostopmathmatrix}% no u else lookahead problem
- \setupmathmatrix[#1]}% [#2]
-
-\definemathmatrix[matrix]
-\definemathmatrix[\v!mathmatrix]
-
-\unexpanded\def\dodomatrixNC
- {\gdef\domatrixNC{\endmath&}}
-
-\def\installmathmatrixhandler#1#2%
- {\setvalue{\??mx:#1}{#2}}
-
-% First alternative:
-%
-% \def\processlowhighmathmatrix#1%
-% {\def\mathmatrixleft
-% {\setbox\nextbox}
-% \def\mathmatrixright
-% {#1.5\dimexpr\nextboxdp-\nextboxht\relax
-% \hbox{$\mathmatrixparameter\c!left
-% \vcenter{\unvbox\nextbox}%
-% \mathmatrixparameter\c!right$}}%
-% \let\mathmatrixbox\vbox}
-%
-% \installmathmatrixhandler\v!high {\processlowhighmathmatrix\raise}
-% \installmathmatrixhandler\v!low {\processlowhighmathmatrix\lower}
-%
-% \installmathmatrixhandler\v!top {\processlowhighmathmatrix\raise}
-% \installmathmatrixhandler\v!bottom{\processlowhighmathmatrix\lower}
-%
-% \installmathmatrixhandler\v!lohi
-% {\def\mathmatrixleft {\mathmatrixparameter\c!left}%
-% \def\mathmatrixright{\mathmatrixparameter\c!right}%
-% \let\mathmatrixbox\vcenter}
-%
-% An alternative
-%
-% \let\mathmatrixleft \empty
-% \let\mathmatrixright\empty
-%
-% \def\processlowhighmathmatrix#1%
-% {\dowithnextbox
-% {#1.5\dimexpr\nextboxdp-\nextboxht\relax
-% \hbox{$\mathmatrixparameter\c!left
-% \vcenter{\unvbox\nextbox}%
-% \mathmatrixparameter\c!right$}}%
-% \vbox}
-%
-% \def\processlohimathmatrix
-% {\dowithnextbox
-% {\mathmatrixparameter\c!left
-% \vcenter{\unvbox\nextbox}%
-% \mathmatrixparameter\c!right}%
-% \vbox}
-%
-% \installmathmatrixhandler\v!high {\def\mathmatrixbox{\processlowhighmathmatrix\raise}}
-% \installmathmatrixhandler\v!low {\def\mathmatrixbox{\processlowhighmathmatrix\lower}}
-% \installmathmatrixhandler\v!top {\def\mathmatrixbox{\processlowhighmathmatrix\raise}}
-% \installmathmatrixhandler\v!bottom{\def\mathmatrixbox{\processlowhighmathmatrix\lower}}
-% \installmathmatrixhandler\v!lohi {\let\mathmatrixbox \processlohimathmatrix}
-%
-% Final version
-
-\let\mathmatrixleft \empty % experimental hook
-\let\mathmatrixright\empty % experimental hook
-
-\def\processlowhighmathmatrix#1#2%
- {\dowithnextbox
- {\scratchdimen\dimexpr(\nextboxdp-\nextboxht)/2 \ifcase#2\or+\mathaxisheight\textfont2\fi\relax
- \ifcase#1\relax\or\lower\scratchdimen\or\or\raise\scratchdimen\fi
- \hbox{$\mathmatrixparameter\c!left
- \vcenter{\unvbox\nextbox}%
- \mathmatrixparameter\c!right$}}%
- \vbox}
-
-\installmathmatrixhandler\v!top {\def\mathmatrixbox{\processlowhighmathmatrix\plusthree\plusone }}
-\installmathmatrixhandler\v!high {\def\mathmatrixbox{\processlowhighmathmatrix\plusthree\zerocount}}
-\installmathmatrixhandler\v!lohi {\def\mathmatrixbox{\processlowhighmathmatrix\plustwo \zerocount}}
-\installmathmatrixhandler\v!low {\def\mathmatrixbox{\processlowhighmathmatrix\plusone \zerocount}}
-\installmathmatrixhandler\v!bottom{\def\mathmatrixbox{\processlowhighmathmatrix\plusone \plusone }}
+\appendtoks
+ \setuevalue{\e!start\currentmathmatrix}{\math_matrix_start{\currentmathmatrix}}%
+ \setvalue {\e!stop \currentmathmatrix}{\math_matrix_stop}% no u else lookahead problem
+\to \everydefinemathmatrix
-\def\dostartmathmatrix[#1][#2]%
+\unexpanded\def\math_matrix_start#1%
{\begingroup
\edef\currentmathmatrix{#1}%
- \doifassignmentelse{#2}{\setupmathmatrix[#1][#2]}\donothing
+ \dosingleempty\math_matrix_start_indeed}
+
+\unexpanded\def\math_matrix_start_indeed[#1]%
+ {\iffirstargument
+ \setupcurrentmathmatrix[#1]%
+ \fi
\emptyhbox
- \executeifdefined{\??mx:\mathmatrixparameter\c!location}{\getvalue{\??mx:\v!lohi}}%
+ \math_matrix_handler_apply
\mathmatrixleft
\mathmatrixbox\bgroup
\pushmacro\domatrixNC
@@ -696,13 +537,15 @@
\mathsurround\zeropoint
\everycr\emptytoks
\tabskip\zeropoint
- \eqaligncolumn\zerocount
- \processcommacommand[\mathmatrixparameter\c!align]{\advance\eqaligncolumn\plusone\dosetmatrixcolumn}%
- \scratchcounter=\ifnum\eqaligncolumn>\zerocount \eqaligncolumn \else \plusone \fi
- \global\eqaligncolumn\plusone
- \preparemathmatrix } % uses scratchcounter
+ \c_math_eqalign_column\zerocount
+ \processcommacommand
+ [\mathmatrixparameter\c!align]
+ {\advance\c_math_eqalign_column\plusone\doseteqaligncolumn}% was \dosetmatrixcolumn
+ \scratchcounter=\ifnum\c_math_eqalign_column>\zerocount \c_math_eqalign_column \else \plusone \fi
+ \global\c_math_eqalign_column\plusone
+ \math_matrix_prepare}
-\def\dostopmathmatrix
+\def\math_matrix_stop
{\crcr
\mathstrut\crcr
\noalign{\kern-\baselineskip}%
@@ -712,6 +555,57 @@
\mathmatrixright
\endgroup}
+\definemathmatrix[matrix]
+\definemathmatrix[\v!mathmatrix]
+
+\def\math_matrix_prepare
+ {\!!toksa{\strut\math_first_in_eqalign\math_left_of_equalign\span
+ \math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
+ \!!toksb{&\hskip\mathmatrixparameter\c!distance
+ \math_next_in_eqalign\math_left_of_equalign\span
+ \math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
+ \!!toksc{&&\hskip\mathmatrixparameter\c!distance
+ \math_left_of_equalign\span
+ \math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
+ \scratchtoks\emptytoks
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
+ \dorecurse{\numexpr\scratchcounter-\plusone\relax}
+ {\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}%
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}%
+ \halign \@EA \bgroup\the\scratchtoks \crcr}
+
+\unexpanded\def\dodomatrixNC
+ {\gdef\domatrixNC{\endmath&}}
+
+\def\installmathmatrixhandler#1#2%
+ {\setvalue{\??mx:h:#1}{#2}}
+
+\let\mathmatrixleft \empty % experimental hook
+\let\mathmatrixright\empty % experimental hook
+
+\def\math_matrix_process#1#2%
+ {\dowithnextbox
+ {\scratchdimen\dimexpr(\nextboxdp-\nextboxht)/2 \ifcase#2\or+\mathaxisheight\textfont2\fi\relax
+ \ifcase#1\relax\or\lower\scratchdimen\or\or\raise\scratchdimen\fi
+ \hbox{$\mathmatrixparameter\c!left
+ \vcenter{\unvbox\nextbox}%
+ \mathmatrixparameter\c!right$}}%
+ \vbox}
+
+\installmathmatrixhandler\v!top {\def\mathmatrixbox{\math_matrix_process\plusthree\plusone }}
+\installmathmatrixhandler\v!high {\def\mathmatrixbox{\math_matrix_process\plusthree\zerocount}}
+\installmathmatrixhandler\v!lohi {\def\mathmatrixbox{\math_matrix_process\plustwo \zerocount}}
+\installmathmatrixhandler\v!low {\def\mathmatrixbox{\math_matrix_process\plusone \zerocount}}
+\installmathmatrixhandler\v!bottom{\def\mathmatrixbox{\math_matrix_process\plusone \plusone }}
+\installmathmatrixhandler\v!normal{\def\mathmatrixbox{\math_matrix_process\plustwo \zerocount}} % lohi
+
+\def\math_matrix_handler_apply
+ {\csname\??mx:h:\ifcsname\??mx:h:\mathmatrixparameter\c!location\endcsname
+ \mathmatrixparameter\c!location
+ \else
+ \v!normal
+ \fi\endcsname}
+
%D \startbuffer
%D \placeformula \startformula[-] \startmatrix
%D \NC 1 \NC x \NC a \NR
@@ -847,62 +741,21 @@
%D The intertext commands have to be expandable (in aligment lookahead) so
%D we cannot use \type {\unexpanded}.
-\let\stopintertext\relax
-
\def\startintertext#1\stopintertext
- {\noalign{\dointertext{#1}}}
+ {\noalign{\math_intertext{#1}}}
+
+\let\stopintertext\relax
\def\intertext#1%
- {\noalign{\dointertext{#1}}}
+ {\noalign{\math_intertext{#1}}}
-\unexpanded\def\dointertext#1%
+\unexpanded\def\math_intertext#1%
{\penalty\postdisplaypenalty
\afterdisplayspace
\vbox{\forgetall\noindent#1\par}%
\penalty\predisplaypenalty
\beforedisplayspace}
-% \macros
-% {substack}
-%
-% Preliminary code:
-%
-% \starttyping
-% \startformula
-% \sum_{%
-% \startsubstack
-% i = 1 \NR
-% i \neq n \NR
-% i \neq m
-% \stopsubstack
-% }a_i
-% \stopformula
-% \stoptyping
-%
-% \unexpanded\def\startsubstack
-% {\begingroup
-% \emptyhbox
-% \vcenter\bgroup
-% \pushmacro\domatrixNC
-% \let\stopmathmode\relax
-% \def\NC{\domatrixNC}%
-% \def\MC{\domatrixNC\startmathmode}%
-% \global\let\domatrixNC\dodomatrixNC
-% \def\NR
-% {\stopmathmode
-% \global\let\domatrixNC\dodomatrixNC
-% \crcr\noalign{\nointerlineskip}}%
-% \mathsurround\zeropoint
-% \everycr\emptytoks
-% \halign\bgroup\hfil$\scriptstyle\mathstrut##$\hfil\crcr}
-%
-% \unexpanded\def\stopsubstack
-% {\crcr
-% \egroup
-% \popmacro\domatrixNC
-% \egroup
-% \endgroup}
-
%D \macros
%D {substack}
%D
@@ -953,7 +806,7 @@
\everycr\emptytoks
\halign\bgroup\hfil$\scriptstyle##$\hfil\crcr}
-\unexpanded\def\stopsubstack
+\def\stopsubstack
{\crcr
\egroup
\egroup
@@ -968,12 +821,12 @@
\ifx\mathparentwd\undefined \newdimen\mathparentwd \fi
-\let\normalbordermatrix\bordermatrix
+\let\normalbordermatrix\bordermatrix % move that code to here instead
\def\bordermatrix
{\begingroup
\setbox\scratchbox\hbox{\mr\char"239C}%
- \global\mathparentwd\wd\scratchbox\relax
+ \global\mathparentwd\wd\scratchbox
\endgroup
\normalbordermatrix}
@@ -1003,11 +856,11 @@
%D Use these macros sparingly. Remember, \TEX\ was designed for
%D mathematics, so there is usually a proper method for typesetting
%D common math notation.
+%D
+%D These macros are a cleaner version of \type {\binrel@} and
+%D \type {\binrel@@} macros in \AMSTEX\ packages.
-%D These macros are a clearer version of \type{\binrel@} and
-%D \type{\binrel@@} macros in \AMSTEX\ packages.
-
-\def\preparebinrel#1%
+\def\math_binrel_apply#1%
{\begingroup
\setbox\scratchbox\hbox
{\thinmuskip 0mu
@@ -1016,48 +869,46 @@
\setbox\scratchbox\hbox{$#1\mathsurround\zeropoint$}%
\kern-\wd\scratchbox
${}#1{}\mathsurround\zeropoint$}%
- \normalexpanded
- {\endgroup
- \let\noexpand\currentbinrel
- \ifdim\wd\scratchbox<\zeropoint
- \mathbin
- \else\ifdim\wd\scratchbox>\zeropoint
- \mathrel
- \else
- \relax
- \fi\fi}}
+ \ifdim\wd\scratchbox<\zeropoint
+ \endgroup
+ \expandafter\mathbin
+ \else\ifdim\wd\scratchbox>\zeropoint
+ \endgroup
+ \expandafter\expandafter\expandafter\mathrel
+ \else
+ \endgroup
+ \expandafter\expandafter\expandafter\firstofoneargument
+ \fi\fi}
\unexpanded\def\overset#1#2%
- {\preparebinrel{#2}%
- \currentbinrel{\mathop{\kern\zeropoint#2}\limits\normalsuperscript{#1}}}
+ {\math_binrel_apply{#2}{\mathop{\kern\zeropoint#2}\limits\normalsuperscript{#1}}}
\unexpanded\def\underset#1#2%
- {\preparebinrel{#2}%
- \currentbinrel{\mathop{\kern\zeropoint#2}\limits\normalsubscript{#1}}}
+ {\math_binrel_apply{#2}{\mathop{\kern\zeropoint#2}\limits\normalsubscript {#1}}}
%D The following code comes from \type {math-str.mkiv}.
-
+%D
%D Here we implement a basic math alignment mechanism. Numbers
%D are also handled. The macros \type {\startinnermath} and
%D \type {\stopinnermath} can be overloaded in specialized
%D modules.
\unexpanded\def\startinnermath
- {\getvalue{\e!start\??fm\formulaparameter\c!align}}
+ {\csname\??fm:\e!start:\formulaparameter\c!align\endcsname}
\unexpanded\def\stopinnermath
- {\getvalue{\e!stop \??fm\formulaparameter\c!align}}
+ {\csname\??fm:\e!stop :\formulaparameter\c!align\endcsname}
\def\mathinnerstrut
{\doif{\formulaparameter\c!strut}\v!yes\strut}
-\long\unexpanded\def\defineinnermathhandler#1#2#3%
- {\setvalue{\e!start\??fm#1}{#2}%
- \setvalue{\e!stop \??fm#1}{#3}}
+\unexpanded\def\defineinnermathhandler#1#2#3%
+ {\setvalue{\??fm:\e!start:#1}{#2}%
+ \setvalue{\??fm:\e!stop :#1}{#3}}
\newif\iftracemath
-\def\mathhbox
+\def\math_hbox
{\iftracemath\ruledhbox\else\hbox\fi}
\newconstant\mathraggedstatus % normal left center right
@@ -1065,40 +916,47 @@
\let\mathnumbercorrection\!!zeropoint
+\let\math_the_r_eq_no\empty
+\let\math_the_l_eq_no\empty
+
\unexpanded\def\startmathbox#1%
{\hsize\displaywidth
\global\mathnumberstatus\plusone
\mathraggedstatus#1\relax
\let\mathnumbercorrection\!!zeropoint
- \global\let\@eqno \empty \def\eqno {\gdef\@eqno }%
- \global\let\@leqno\empty \def\leqno{\gdef\@leqno}%
+ \global\let\math_the_r_eq_no\empty
+ \global\let\math_the_l_eq_no\empty
+ \def\reqno{\gdef\math_the_r_eq_no}%
+ \def\leqno{\gdef\math_the_l_eq_no}%
+ \let\eqno\reqno
% added
- \let\normalreqno\eqno
+ \let\normalreqno\reqno
\let\normalleqno\leqno
+ \let\normaleqno \eqno
% added
\doplaceformulanumber
- \setbox\scratchbox\mathhbox to \displaywidth\bgroup
+ \setbox\scratchbox\math_hbox to \displaywidth\bgroup
\mathinnerstrut
$%
\displaystyle
\ifcase\mathraggedstatus\or\hfill\or\hfill\fi}
-\def\llappedmathno
+\def\math_box_llapped_math_no
{\ifcase\mathraggedstatus\or
- \@eqno
+ \math_the_r_eq_no
\or
- \llap{\@eqno}%
+ \llap{\math_the_r_eq_no}%
\or
- \llap{\@eqno}%
+ \llap{\math_the_r_eq_no}%
\fi}
-\def\rlappedmathno
+\def\math_box_rlapped_math_no
{\ifcase\mathraggedstatus\or
- \rlap{\@leqno}%
+ \rlap{\math_the_l_eq_no}%
\or
- \rlap{\@leqno}%
+ \rlap{\math_the_l_eq_no}%
\or
- \@leqno
+ \math_the_l_eq_no
\fi}
\unexpanded\def\stopmathbox
@@ -1116,21 +974,21 @@
\ifcase\mathnumberstatus
\box\scratchbox
\or
- \ifx\@leqno\empty
- \ifx\@eqno\empty
+ \ifx\math_the_l_eq_no\empty
+ \ifx\math_the_r_eq_no\empty
\box\scratchbox
\else
\ifdone
- \vbox{\box\scratchbox\hbox to \displaywidth{\hss\llappedmathno}}%
+ \vbox{\box\scratchbox\hbox to \displaywidth{\hss\math_box_llapped_math_no}}%
\else
- \hss\box\scratchbox\llappedmathno % hss makes room for number
+ \hss\box\scratchbox\math_box_llapped_math_no % hss makes room for number
\fi
\fi
\else
\ifdone
- \vbox{\hbox to \displaywidth{\rlappedmathno\hss}\box\scratchbox}%
+ \vbox{\hbox to \displaywidth{\math_box_rlapped_math_no\hss}\box\scratchbox}%
\else
- \rlappedmathno\box\scratchbox\hss % hss makes room for number
+ \math_box_rlapped_math_no\box\scratchbox\hss % hss makes room for number
\fi
\fi
\or
diff --git a/tex/context/base/math-dim.lua b/tex/context/base/math-dim.lua
index 00b766dc2..d245bfb3a 100644
--- a/tex/context/base/math-dim.lua
+++ b/tex/context/base/math-dim.lua
@@ -124,7 +124,7 @@ end
function mathematics.dimensions(dimens) -- beware, dimens get spoiled
if dimens.SpaceAfterScript then
- dimens.SubscriptShiftDownWithSuperscript = dimens.SubscriptShiftDown * 1.5
+ dimens.SubscriptShiftDownWithSuperscript = dimens.SubscriptShiftDown * 1.5 -- move this one
return table.fastcopy(dimens), { }
elseif dimens.AxisHeight or dimens.axis_height then
local t = { }
diff --git a/tex/context/base/math-pln.mkiv b/tex/context/base/math-pln.mkiv
index cdbc400a1..1f846d5ac 100644
--- a/tex/context/base/math-pln.mkiv
+++ b/tex/context/base/math-pln.mkiv
@@ -206,7 +206,7 @@
\ifx\mfunction\undefined \def\mfunction#1{\mathbin{\rm#1}} \fi
-\def\bmod
+\unexpanded\def\bmod
{\nonscript
\mskip-\medmuskip
\mkern5mu
@@ -216,12 +216,12 @@
\nonscript
\mskip-\medmuskip}
-\def\pmod#1%
+\unexpanded\def\pmod#1%
{\allowbreak
\mkern18mu
(\mfunction{mod}\,\,#1)}
-\def\cases#1%
+\unexpanded\def\cases#1%
{\left\{%
\,%
\vcenter
@@ -230,7 +230,7 @@
\ialign{$##\hfil$&\quad##\hfil\crcr#1\crcr}}%
\right.}
-\def\matrix#1%
+\unexpanded\def\matrix#1%
{\emptyhbox
\,%
\vcenter
@@ -240,14 +240,14 @@
#1\crcr\mathstrut\crcr\noalign{\kern-\baselineskip}}}%
\,}
-\def\pmatrix#1%
+\unexpanded\def\pmatrix#1%
{\left(\matrix{#1}\right)}
\newdimen\mathparentwd
% \setbox0=\hbox{\tenex B} \mathparentwd=\wd0 % width of the big left (
-\def\bordermatrix#1%
+\unexpanded\def\bordermatrix#1%
{\begingroup
\mathsurround\zeropoint
\setbox\zerocount\vbox
@@ -275,7 +275,7 @@
% \advance\baselineskip\dimen@
% \advance\lineskiplimit\dimen@}
-\def\openup
+\unexpanded\def\openup
{\afterassignment\doopenup\scratchdimen=}
\def\doopenup
@@ -287,7 +287,7 @@
\def\displayopenupvalue{.25\bodyfontsize}
-\def\eqalign#1%
+\unexpanded\def\eqalign#1%
{\emptyhbox
\,%
\vcenter
@@ -302,14 +302,14 @@
{\tabskip\zeroskip
\everycr{}}
-\def\displaylines#1%
+\unexpanded\def\displaylines#1%
{\displ@y
\tabskip\zeroskip
\halign
{\hbox to \displaywidth{$\@lign\hfil\displaystyle##\hfil$}\crcr
#1\crcr}}
-\def\eqalignno#1%
+\def\eqalignno#1% \unexpanded (needs testing in alignments)
{\displ@y
\tabskip\centering
\halign to \displaywidth
@@ -318,7 +318,7 @@
&\llap{$\@lign##$}\tabskip\zeroskip\crcr
#1\crcr}}
-\def\leqalignno#1%
+\def\leqalignno#1% \unexpanded (needs testing in alignments)
{\displ@y
\tabskip\centering
\halign to \displaywidth
diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv
index ad4bd768b..9ce75364a 100644
--- a/tex/context/base/meta-ini.mkiv
+++ b/tex/context/base/meta-ini.mkiv
@@ -49,30 +49,30 @@
\def\startMPdefinitions
{\dosinglegroupempty\dostartMPdefinitions}
-\long\def\dostartMPdefinitions#1#2\stopMPdefinitions
+\def\dostartMPdefinitions#1#2\stopMPdefinitions
{\edef\currentMPgraphicinstance{#1}%
\ifx\currentMPgraphicinstance\empty
\let\currentMPgraphicinstance\defaultMPgraphicinstance
\fi
\global\MPinstancetoks\expandafter{\the\MPinstancetoks#2}}
-\long\def\startMPextensions#1\stopMPextensions
+\def\startMPextensions#1\stopMPextensions
{\global\MPextensions\expandafter{\the\MPextensions#1}}
-\long\def\startMPinitializations#1\stopMPinitializations
+\def\startMPinitializations#1\stopMPinitializations
{\global\MPinitializations\expandafter{\the\MPinitializations#1}}
-\long\def\startMPinclusions
+\def\startMPinclusions
{\dosingleempty\dostartMPinclusions}
-\long\def\dostartMPinclusions[#1]#2\stopMPinclusions
+\def\dostartMPinclusions[#1]#2\stopMPinclusions
{\doifnot{#1}{+}{\global\MPuserinclusions\emptytoks}%
\global\MPuserinclusions\expandafter{\the\MPuserinclusions#2}}
\def\MPinclusions
{\dosingleempty\doMPinclusions}
-\long\def\doMPinclusions[#1]#2%
+\def\doMPinclusions[#1]#2%
{\doifnot{#1}{+}{\global\MPuserinclusions\emptytoks}%
\global\MPuserinclusions\expandafter{\the\MPuserinclusions#2}}
@@ -162,7 +162,7 @@
{\global\MPinstancetoks\emptytoks
\endgroup}
-\unexpanded\long\def\processMPgraphic#1% todo: extensions and inclusions outside beginfig
+\unexpanded\def\processMPgraphic#1% todo: extensions and inclusions outside beginfig
{\dostartcurrentMPgraphic
\forgetall
\setbox\MPgraphicbox\hbox\bgroup % ; added 20100901 (as in mkii)
@@ -229,29 +229,29 @@
\def\startMPdrawing
{\dosingleempty\dostartMPdrawing}
-\long\def\dostartMPdrawing[#1]#2\stopMPdrawing
+\def\dostartMPdrawing[#1]#2\stopMPdrawing
{\relax
\bgroup
\enableincludeMPgraphics
\presetMPdefinitions % in case #2 has measures
- \doifelse{#1}{-}{\convertargument#2\to\asciia}{\long\def\asciia{#2}}%
- \long\xdef\MPdrawingdata{\MPdrawingdata\asciia}%
+ \doifelse{#1}{-}{\convertargument#2\to\asciia}{\def\asciia{#2}}%
+ \xdef\MPdrawingdata{\MPdrawingdata\asciia}%
\egroup}
\let\stopMPdrawing\relax
-\long\def\MPdrawing#1%
+\def\MPdrawing#1%
{\relax
\bgroup
\enableincludeMPgraphics
\presetMPdefinitions
- \long\xdef\MPdrawingdata{\MPdrawingdata#1}%
+ \xdef\MPdrawingdata{\MPdrawingdata#1}%
\egroup}
\let\stopMPclip\relax
-\long\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less
- {\long\setgvalue{MPC:#1}{#2}}
+\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less
+ {\setgvalue{MPC:#1}{#2}}
\def\grabMPclippath#1#2#3#4#5% #5 is alternative
{\begingroup
@@ -454,7 +454,7 @@
\xdef\MPury{#5}%
\hbox{\forcecolorhack\getobject{MP}{#1}}} % else no proper color intent
-\long\def\handleuniqueMPgraphic#1#2#3%
+\def\handleuniqueMPgraphic#1#2#3%
{\begingroup
\def\@@meta{#1:}%
\extendMPoverlaystamp{#2}% incl prepare
@@ -467,11 +467,11 @@
\getvalue{\@@MPG\overlaystamp:#1}%
\endgroup}
-\long\unexpanded\def\startuniqueMPgraphic
+\unexpanded\def\startuniqueMPgraphic
{\dodoublegroupempty\dostartuniqueMPgraphic}
-\long\def\dostartuniqueMPgraphic#1#2#3\stopuniqueMPgraphic%
- {\long\setgvalue{\@@MPG#1}{\handleuniqueMPgraphic{#1}{#2}{#3}}}
+\def\dostartuniqueMPgraphic#1#2#3\stopuniqueMPgraphic%
+ {\setgvalue{\@@MPG#1}{\handleuniqueMPgraphic{#1}{#2}{#3}}}
\unexpanded\def\uniqueMPgraphic
{\dodoublegroupempty\douniqueMPgraphic}
@@ -484,7 +484,7 @@
\let\stopuniqueMPcode \relax % so that we can use it in \expanded
-\long\def\handleuseMPgraphic#1#2#3%
+\def\handleuseMPgraphic#1#2#3%
{\begingroup
\def\@@meta{#1:}%
\prepareMPvariables{#2}%
@@ -492,22 +492,22 @@
\processMPgraphic{#3}%
\endgroup}
-\long\unexpanded\def\startuseMPgraphic
+\unexpanded\def\startuseMPgraphic
{\dodoublegroupempty\dostartuseMPgraphic}
-\long\def\dostartuseMPgraphic#1#2#3\stopuseMPgraphic
- {\long\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}}
+\def\dostartuseMPgraphic#1#2#3\stopuseMPgraphic
+ {\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}}
-\long\unexpanded\def\startusableMPgraphic % redundant but handy
+\unexpanded\def\startusableMPgraphic % redundant but handy
{\dodoublegroupempty\dostartusableMPgraphic}
-\long\def\dostartusableMPgraphic#1#2#3\stopusableMPgraphic
- {\long\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}}
+\def\dostartusableMPgraphic#1#2#3\stopusableMPgraphic
+ {\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}}
\let\stopuseMPgraphic \relax % so that we can use it in \expanded
\let\stopusableMPgraphic \relax % so that we can use it in \expanded
-\long\def\handlereusableMPgraphic#1#2#3%
+\def\handlereusableMPgraphic#1#2#3%
{\begingroup
\def\@@meta{#1:}%
\prepareMPvariables{#2}%
@@ -518,11 +518,11 @@
\getvalue{\@@MPG#1}%
\endgroup}
-\long\unexpanded\def\startreusableMPgraphic
+\unexpanded\def\startreusableMPgraphic
{\dodoublegroupempty\dostartreusableMPgraphic}
-\long\def\dostartreusableMPgraphic#1#2#3\stopreusableMPgraphic
- {\long\setgvalue{\@@MPG#1}{\handlereusableMPgraphic{#1}{#2}{#3}}}
+\def\dostartreusableMPgraphic#1#2#3\stopreusableMPgraphic
+ {\setgvalue{\@@MPG#1}{\handlereusableMPgraphic{#1}{#2}{#3}}}
\let\stopreusableMPgraphic \relax % so that we can use it in \expanded
@@ -557,12 +557,12 @@
\def\overlaypagestamp
{\MPpageprefix\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}
-\long\unexpanded\def\startuniqueMPpagegraphic
+\unexpanded\def\startuniqueMPpagegraphic
{\dodoublegroupempty\dostartuniqueMPpagegraphic}
-\long\def\dostartuniqueMPpagegraphic#1#2#3\stopuniqueMPpagegraphic
- {\long\setgvalue{\@@MPG o:#1}{\handleuniqueMPgraphic{o:#1}{#2}{#3}}%
- \long\setgvalue{\@@MPG e:#1}{\handleuniqueMPgraphic{e:#1}{#2}{#3}}}
+\def\dostartuniqueMPpagegraphic#1#2#3\stopuniqueMPpagegraphic
+ {\setgvalue{\@@MPG o:#1}{\handleuniqueMPgraphic{o:#1}{#2}{#3}}%
+ \setgvalue{\@@MPG e:#1}{\handleuniqueMPgraphic{e:#1}{#2}{#3}}}
\unexpanded\def\uniqueMPpagegraphic
{\dodoublegroupempty\douniqueMPpagegraphic}
@@ -692,7 +692,7 @@
\def\startMPenvironment % second arg gobbles spaces, so that reset gives \emptytoks
{\dodoubleempty\dostartMPenvironment}
-\long\def\dostartMPenvironment[#1][#2]#3\stopMPenvironment
+\def\dostartMPenvironment[#1][#2]#3\stopMPenvironment
{\doif{#1}\s!reset\resetMPenvironment % reset mp toks
\doif{#1}\v!global{#3}% % use in main doc too
\doif{#1}+{#3}% % use in main doc too
@@ -776,7 +776,7 @@
\def\startMPrun
{\dosinglegroupempty\dostartMPrun}
-\long\def\dostartMPrun#1#2\stopMPrun
+\def\dostartMPrun#1#2\stopMPrun
{\iffirstargument
\startuseMPgraphic{#1}#2\stopuseMPgraphic
\else
@@ -845,7 +845,7 @@
\def\@@MPT{@MPT@}
\def\forceMPTEXgraphic
- {\long\def\checkMPTEXgraphic##1{\global\MPTEXgraphictrue}}
+ {\def\checkMPTEXgraphic##1{\global\MPTEXgraphictrue}}
\def\setMPtext#1#2% todo : #1 must be made : safe
{%\forceMPTEXgraphic
@@ -998,7 +998,7 @@
%D \macros
%D {startMPcolor}
-\long\unexpanded\def\startMPcolor#1\stopMPcolor
+\unexpanded\def\startMPcolor#1\stopMPcolor
{\writestatus \m!metapost % eventually this placeholder will go away
{\string\startMPcolor...\stopMPcolor\space is obsolete,\space
use \string\defineintermediatecolor\space instead}}
@@ -1077,7 +1077,7 @@
%D
%D \typebuffer \getbuffer
-\def\usestaticMPfigure
+\unexpanded\def\usestaticMPfigure
{\dodoubleempty\dousestaticMPfigure}
\def\dousestaticMPfigure[#1][#2]%
@@ -1090,11 +1090,11 @@
\unexpanded\def\startstaticMPfigure#1#2\stopstaticMPfigure
{\startreusableMPgraphic{\@@MPG#1@S@}#2\stopreusableMPgraphic}
-\long\unexpanded\def\startstaticMPgraphic
+\unexpanded\def\startstaticMPgraphic
{\dodoublegroupempty\dostartstaticMPgraphic}
-\long\def\dostartstaticMPgraphic#1#2#3\stopstaticMPgraphic
- {\long\setgvalue{\@@MPG#1@S@}{\handlereusableMPgraphic{#1}{#2}{#3}}}
+\def\dostartstaticMPgraphic#1#2#3\stopstaticMPgraphic
+ {\setgvalue{\@@MPG#1@S@}{\handlereusableMPgraphic{#1}{#2}{#3}}}
%D New:
diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv
index 60f7d7830..19051e872 100644
--- a/tex/context/base/meta-pag.mkiv
+++ b/tex/context/base/meta-pag.mkiv
@@ -97,7 +97,7 @@
%D zero (overlay).
\appendtoks
- \freezeMPpagelayout
+ \freezeMPpagelayout
\to \everybeforepagebody
%D By freezing these value every graphic, we can use layout
@@ -105,9 +105,9 @@
%D has.
\prependtoks
- \calculatereducedvsizes % this is really needed
- \freezeMPpagelayout
- \freezeMPlayout % to be used grouped
+ \calculatereducedvsizes % this is really needed
+ \freezeMPpagelayout
+ \freezeMPlayout % to be used grouped
\to \everyMPgraphic
%D The next feature provides information about for instance
@@ -137,6 +137,8 @@
% optimaliseren voor herhaling
+\newif\iftracetextareas
+
\def\registerMPtextarea#1%
{\ifpositioning
\bgroup
diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv
index 453661d19..24b1aa6c5 100644
--- a/tex/context/base/mult-aux.mkiv
+++ b/tex/context/base/mult-aux.mkiv
@@ -25,18 +25,18 @@
%D \unprotect
%D \def\????aa{@@@@aa}
%D
-%D \installparameterhandler \????aa {whatever}
-%D \installsetuphandler \????aa {whatever}
-%D \installdefinehandler \????aa {whatever} \????aa % #3 == defaultroot
-%D \installattributehandler \????aa {whatever}
+%D \installparameterhandler \????aa {whatever}
+%D \installsetuphandler \????aa {whatever}
+%D \installdefinehandler \????aa {whatever} \????aa % #3 == defaultroot
+%D \installfontandcolorhandler\????aa {whatever}
%D
-%D % \installcommandhandler \????aa {whatever} \????aa
+%D % \installcommandhandler \????aa {whatever} \????aa
%D \protect
%D
%D % \whateverparameter \c!test
%D % \whateverparameterhash \c!test
%D % \namedwhateverparameter \mycurrentwhatever \c!test
-%D % \dosetwhateverattributes \c!style \c!color
+%D % \dosetwhateverstyleandcolor \c!style \c!color
%D % \everydefinewhatever (sets \currentwhatever)
%D % \everypresetwhatever (can be used to reset parameters as we can redefine)
%D % \everysetupwhatever (sets \currentwhatever)
@@ -64,12 +64,71 @@
% todo: add (relaxed) postsetup and postdefine hooks, just after the everys
-\unexpanded\def\doinstallparameterhandler#1#2#3#4#5#6#7#8#9%
- {\ifx#2\relax\let#2\empty\fi
- \def#3##1{\csname#4{#1#2}{##1}\endcsname}%
+% Start of experimental code: especially tables can have many assignments
+% and although most time is spent in the typesetting anyway, we can squeeze
+% out a little bit. Of course having 500 rows of 50 columns each with some
+% setting does not happen that often. One should keep in mind that in the
+% average document having some 500 assignments is no exception but there we're
+% talking of neglectable runtime for them. Of course in the definitions below
+% there is no real gain, only in the generated \setup* commands. Another
+% situation with many assignments is \XML\ where we can pass attributes
+% and normally don't do testing of them making sense.
+%
+% \testfeatureonce{100000}{\getparameters[bla][a=111,b=222,c=333]}% 1.669s
+% \testfeatureonce{100000}{\get_parameters{bla} [a=111,b=222,c=333]}% 1.529s
+% \testfeatureonce{100000}{\def\current_parameter_namespace{bla}\get_parameters_indeed[a=111,b=222,c=333]}% 1.466s
+%
+% \get_parameter {...} [...]
+% \def\current_parameter_namespace{...} \get_parameter_indeed[...]
+
+\def\get_parameters#1[#2%
+ {\if\noexpand#2]%
+ \expandafter\gobbleoneargument
+ \else
+ \def\current_parameter_namespace{#1}%
+ \expandafter\get_parameters_indeed
+ \fi#2}
+
+% \def\get_parameters#1% we can assume that the test already happened
+% {\def\current_parameter_namespace{#1}%
+% \get_parameters_indeed}
+
+\def\get_parameters_indeed#1]% namespace already set
+ {\get_parameters_item#1,],\@relax@}
+
+\def\get_parameters_item#1,#2% #2 takes space before ,
+ {\if,#1,% dirty trick for testing #1=empty
+ \expandafter\get_parameters_item
+ \else\if]#1%
+ \doubleexpandafter\gobbleoneargument
+ \else
+ \get_parameters_assign#1==\empty\@relax@
+ \doubleexpandafter\get_parameters_item
+ \fi\fi#2}
+
+\def\get_parameters_error#1#2#3%
+ {\showassignerror{#2}{\the\inputlineno\space(#1)}}
+
+\def\get_parameters_assign#1=#2=#3#4\@relax@
+ {\ifx\empty#1\empty
+ \expandafter\get_parameters_error
+ \else\ifx#3\empty
+ \doubleexpandafter\get_parameters_error
+ \else
+ \doubleexpandafter\dosetvalue
+ \fi\fi
+ \current_parameter_namespace{#1}{#2}}
+
+% End of experimental code.
+
+\unexpanded\def\doinstallparameterhandler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only)
+ {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing
+ %\def#3##1{\csname#4{#1#2}{##1}\endcsname}%
+ \def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}%
\def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
\def#5##1##2{\ifx##1\relax\s!empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ?
- \def#6##1##2{\csname#4{#1##1}{##2}\endcsname}%
+ %\def#6##1##2{\csname#4{#1##1}{##2}\endcsname}%
+ \def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}%
\def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack
\def#8##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\s!empty\fi\endcsname}%
\def#9##1{\csname#1#2:##1\endcsname}}
@@ -106,7 +165,7 @@
\def#6{#1#2:}%
\def#7##1{#1##1:}%
\def#8{\ifx#2\empty\else\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi\fi}%
- \def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}}
+ \unexpanded\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}}
\unexpanded\def\installparameterhashhandler#1#2%
@@ -147,26 +206,32 @@
\expandafter\noexpand\csname let#2parameter\endcsname
\expandafter\noexpand\csname reset#2parameter\endcsname}}
-\unexpanded\def\doinstallattributehandler#1#2#3#4%
+\let\dousecurrentstyleparameter\relax
+\let\dousecurrentcolorparameter\relax
+
+\let\currentstyleparameter\empty
+\let\currentcolorparameter\empty
+
+\unexpanded\def\doinstallstyleandcolorhandler#1#2#3#4%
{\unexpanded\def#2##1##2% style color
- {\edef\fontattributehash {#1{##1}}% this name is public
- \edef\colorattributehash{#1{##2}}% this name is public
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash {##1}\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash{##2}\fi}%
+ {\edef\currentstyleparameter{#1{##1}}% this name is public
+ \edef\currentcolorparameter{#1{##2}}% this name is public
+ \ifx\currentstyleparameter\empty\else\dousecurrentstyleparameter\fi
+ \ifx\currentcolorparameter\empty\else\dousecurrentcolorparameter\fi}%
\unexpanded\def#3##1% style
- {\edef\fontattributehash {#1{##1}}% this name is public
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash {##1}\fi}%
+ {\edef\currentstyleparameter{#1{##1}}% this name is public
+ \ifx\currentstyleparameter\empty\else\dousecurrentstyleparameter\fi}%
\unexpanded\def#4##1% color
- {\edef\colorattributehash{#1{##1}}% this name is public
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash{##1}\fi}}
+ {\edef\currentcolorparameter{#1{##1}}% this name is public
+ \ifx\currentcolorparameter\empty\else\dousecurrentcolorparameter\fi}}
-\unexpanded\def\installattributehandler#1#2%
+\unexpanded\def\installstyleandcolorhandler#1#2%
{\normalexpanded
- {\doinstallattributehandler
- \expandafter\noexpand\csname #2parameterhash\endcsname
- \expandafter\noexpand\csname doset#2attributes\endcsname
- \expandafter\noexpand\csname doset#2fontattribute\endcsname
- \expandafter\noexpand\csname doset#2colorattribute\endcsname}}
+ {\doinstallstyleandcolorhandler
+ \expandafter\noexpand\csname #2parameter\endcsname
+ \expandafter\noexpand\csname use#2styleandcolor\endcsname % maybe an alias use#2styleandcolorparameters
+ \expandafter\noexpand\csname use#2styleparameter\endcsname
+ \expandafter\noexpand\csname use#2colorparameter\endcsname}}
\let\definehandlerparent\empty
@@ -181,16 +246,20 @@
\the#6% predefine
\ifthirdargument
\edef#8{##2}%
- \getparameters[#1#4:][\s!parent=#1##2,##3]%
+ % \getparameters[#1#4:][\s!parent=#1##2,##3]%
+ \get_parameters{#1#4:}[\s!parent=#1##2,##3]%
\else\ifsecondargument
\doifassignmentelse{##2}
{\let#8\empty
- \getparameters[#1#4:][\s!parent=#3,##2]}
+ % \getparameters[#1#4:][\s!parent=#3,##2]}
+ \get_parameters{#1#4:}[\s!parent=#3,##2]}
{\edef#8{##2}%
- \getparameters[#1#4:][\s!parent=#1##2]}%
+ % \getparameters[#1#4:][\s!parent=#1##2]}%
+ \get_parameters{#1#4:}[\s!parent=#1##2]}%
\else
\let#8\empty
- \getparameters[#1#4:][\s!parent=#3]%
+ % \getparameters[#1#4:][\s!parent=#3]%
+ \get_parameters{#1#4:}[\s!parent=#3]%
\fi\fi
\the#7%
\let#4\saveddefinewhatever}}
@@ -210,19 +279,22 @@
\unexpanded\def\doinstallsetuphandler#1#2#3#4#5#6%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dodoubleempty#4}%
- \unexpanded\def#6{\getparameters[#1#3:]}% no every ! don't change it
+ % \unexpanded\def#6{\getparameters[#1#3:]}% no every ! don't change it
+ \unexpanded\def#6{\get_parameters{#1#3:}}% no every ! don't change it
\newtoks#5%
\def#4[##1][##2]% maybe helper
{\let\savedsetupwhatever#3%
\ifsecondargument
\def\docommand####1% we will have a simple one as well
{\edef#3{####1}%
- \getparameters[#1#3:][##2]%
+ % \getparameters[#1#3:][##2]%
+ \get_parameters{#1#3:}[##2]%
\the#5}%
\processcommalist[##1]\docommand
\else
\let#3\empty
- \getparameters[#1:][##1]%
+ % \getparameters[#1:][##1]%
+ \get_parameters{#1:}[##1]%
\the#5%
\fi
\let#3\savedsetupwhatever}}
@@ -240,20 +312,23 @@
\unexpanded\def\doinstallswitchsetuphandler#1#2#3#4#5#6%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dodoubleempty#4}%
- \unexpanded\def#6{\getparameters[#1#3:]}%
+ % \unexpanded\def#6{\getparameters[#1#3:]}%
+ \unexpanded\def#6{\get_parameters{#1#3:}}%
\newtoks#5%
\def#4[##1][##2]% maybe helper
{\ifsecondargument % no commalist here
\let\savedsetupwhatever#3%
\edef#3{##1}%
- \getparameters[#1#3:][##2]%
+ % \getparameters[#1#3:][##2]%
+ \get_parameters{#1#3:}[##2]%
\the#5%
\let#3\savedsetupwhatever
\else\iffirstargument
\doifassignmentelse{##1}
{\let\savedsetupwhatever#3%
\let#3\empty
- \getparameters[#1:][##1]%
+ % \getparameters[#1:][##1]%
+ \get_parameters{#1:}[##1]%
\the#5%
\let#3\savedsetupwhatever}
{\edef#3{##1}% this will catch reset
@@ -276,25 +351,29 @@
\unexpanded\def\doinstallautosetuphandler#1#2#3#4#5#6%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dotripleempty#4}%
- \unexpanded\def#6{\getparameters[#1#3:]}%
+ % \unexpanded\def#6{\getparameters[#1#3:]}%
+ \unexpanded\def#6{\get_parameters{#1#3:}}%
\newtoks#5%
\def#4[##1][##2][##3]%
{\let\savedsetupwhatever#3%
\ifthirdargument
\def\docommand####1%
{\edef#3{####1}%
- \getparameters[#1#3:][\s!parent=#1##2,##3]%
+ % \getparameters[#1#3:][\s!parent=#1##2,##3]%
+ \get_parameters{#1#3:}[\s!parent=#1##2,##3]%
\the#5}%
\processcommalist[##1]\docommand
\else\ifsecondargument
\def\docommand####1%
{\edef#3{####1}%
- \getparameters[#1#3:][##2]%
+ % \getparameters[#1#3:][##2]%
+ \get_parameters{#1#3:}[##2]%
\the#5}%
\processcommalist[##1]\docommand
\else
\let#3\empty
- \getparameters[#1:][##1]%
+ % \getparameters[#1:][##1]%
+ \get_parameters{#1:}[##1]%
\the#5%
\fi\fi
\let#3\savedsetupwhatever}}
@@ -309,7 +388,7 @@
\expandafter\noexpand\csname everysetup#2\endcsname
\expandafter\noexpand\csname setupcurrent#2\endcsname}}
-\def\installbasicparameterhandler#1#2%
+\unexpanded\def\installbasicparameterhandler#1#2%
{\installparameterhandler {#1}{#2}%
\installparameterhashhandler{#1}{#2}%
\installparametersethandler {#1}{#2}%
@@ -319,24 +398,24 @@
{\installbasicparameterhandler{#1}{#2}%
\installdefinehandler {#1}{#2}{#3}%
\installsetuphandler {#1}{#2}%
- \installattributehandler {#1}{#2}}
+ \installstyleandcolorhandler {#1}{#2}}
\unexpanded\def\installswitchcommandhandler#1#2#3% \??self name \??parent (can be \??self)
{\installbasicparameterhandler{#1}{#2}%
\installdefinehandler {#1}{#2}{#3}%
\installswitchsetuphandler {#1}{#2}%
- \installattributehandler {#1}{#2}}
+ \installstyleandcolorhandler {#1}{#2}}
\unexpanded\def\installautocommandhandler#1#2#3% automatically defined cloned setups
{\installbasicparameterhandler{#1}{#2}%
\installdefinehandler {#1}{#2}{#3}%
\installautosetuphandler {#1}{#2}%
- \installattributehandler {#1}{#2}}
+ \installstyleandcolorhandler {#1}{#2}}
-\unexpanded\def\installsimplecommandhandler#1#2#3% no define (experiment)
+\unexpanded\def\installsimplecommandhandler#1#2#3% no define (experiment) - use \check*parent when defining
{\installbasicparameterhandler{#1}{#2}%
\installsetuphandler {#1}{#2}%
- \installattributehandler {#1}{#2}}
+ \installstyleandcolorhandler {#1}{#2}}
\unexpanded\def\installnamespace#1%
{\setvalue{????#1}{@@@@#1}}
@@ -394,8 +473,8 @@
\def\doshowparentchain#1%
{#1 => %
- \ifcsname#1\s!parent\endcsname
- \expandafter\doshowparentchain\csname#1\s!parent\endcsname
+ \ifcsname#1:\s!parent\endcsname
+ \expandafter\doshowparentchain\csname#1:\s!parent\endcsname
\fi}
\def\showparentchain#1#2%
diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii
index bfddfb0d9..01c98ef8b 100644
--- a/tex/context/base/mult-de.mkii
+++ b/tex/context/base/mult-de.mkii
@@ -1166,7 +1166,7 @@
\setinterfacecommand{defineframedtext}{definiereumrahmtertext}
\setinterfacecommand{definehbox}{definierehbox}
\setinterfacecommand{definehead}{definiereueberschrift}
-\setinterfacecommand{defineindenting}{definiereeinzug}
+\setinterfacecommand{defineindentedtext}{defineindentedtext}
\setinterfacecommand{defineinmargin}{defineinmargin}
\setinterfacecommand{defineinteractionmenu}{definiereinteraktionsmenue}
\setinterfacecommand{defineitemgroup}{defineitemgroup}
@@ -1477,7 +1477,7 @@
\setinterfacecommand{setupheads}{stelleueberschriftenein}
\setinterfacecommand{setupheadtext}{stelleueberschrifttextein}
\setinterfacecommand{setuphyphenmark}{stellebindestrichein}
-\setinterfacecommand{setupindentations}{stelleeinzuegein}
+\setinterfacecommand{setupindentedtext}{setupindentedtext}
\setinterfacecommand{setupindenting}{stelleeinziehenein}
\setinterfacecommand{setupinmargin}{stelleinmarginalieein}
\setinterfacecommand{setupinteraction}{stelleinteraktionein}
diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua
index 7dab4eaa6..74d2584ac 100644
--- a/tex/context/base/mult-def.lua
+++ b/tex/context/base/mult-def.lua
@@ -920,15 +920,9 @@ return {
["pe"]="تعریف‌سر",
["ro"]="definesteantet",
},
- ["defineindenting"]={
- ["cs"]="definujodsazovani",
- ["de"]="definiereeinzug",
- ["en"]="defineindenting",
- ["fr"]="definitcompoalinea",
- ["it"]="definiscirientro",
- ["nl"]="doorspringen",
- ["pe"]="تعریف‌تورفتگی",
- ["ro"]="definestealiat",
+ ["defineindentedtext"]={
+ ["en"]="defineindentedtext",
+ ["nl"]="definieeringesprongentext",
},
["defineinmargin"]={
["cs"]="defineinmargin",
@@ -4030,15 +4024,9 @@ return {
["pe"]="بارگذاری‌نشانه‌شکستن",
["ro"]="seteazaliniesilabe",
},
- ["setupindentations"]={
- ["cs"]="nastavodsazeni",
- ["de"]="stelleeinzuegein",
- ["en"]="setupindentations",
- ["fr"]="reglealineas",
- ["it"]="impostarientri",
- ["nl"]="steldoorspringenin",
- ["pe"]="بارگذاری‌تورفتگیها",
- ["ro"]="seteazaaliniate",
+ ["setupindentedtext"]={
+ ["en"]="setupindentedtext",
+ ["nl"]="stelingesprongentextin",
},
["setupindenting"]={
["cs"]="nastavodsazovani",
diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii
index 587b82b78..9610c4b13 100644
--- a/tex/context/base/mult-en.mkii
+++ b/tex/context/base/mult-en.mkii
@@ -1166,7 +1166,7 @@
\setinterfacecommand{defineframedtext}{defineframedtext}
\setinterfacecommand{definehbox}{definehbox}
\setinterfacecommand{definehead}{definehead}
-\setinterfacecommand{defineindenting}{defineindenting}
+\setinterfacecommand{defineindentedtext}{defineindentedtext}
\setinterfacecommand{defineinmargin}{defineinmargin}
\setinterfacecommand{defineinteractionmenu}{defineinteractionmenu}
\setinterfacecommand{defineitemgroup}{defineitemgroup}
@@ -1477,7 +1477,7 @@
\setinterfacecommand{setupheads}{setupheads}
\setinterfacecommand{setupheadtext}{setupheadtext}
\setinterfacecommand{setuphyphenmark}{setuphyphenmark}
-\setinterfacecommand{setupindentations}{setupindentations}
+\setinterfacecommand{setupindentedtext}{setupindentedtext}
\setinterfacecommand{setupindenting}{setupindenting}
\setinterfacecommand{setupinmargin}{setupinmargin}
\setinterfacecommand{setupinteraction}{setupinteraction}
diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii
index 6be307377..62593922e 100644
--- a/tex/context/base/mult-fr.mkii
+++ b/tex/context/base/mult-fr.mkii
@@ -1166,7 +1166,7 @@
\setinterfacecommand{defineframedtext}{defineframedtext}
\setinterfacecommand{definehbox}{definithbox}
\setinterfacecommand{definehead}{definittete}
-\setinterfacecommand{defineindenting}{definitcompoalinea}
+\setinterfacecommand{defineindentedtext}{defineindentedtext}
\setinterfacecommand{defineinmargin}{definitdansmarge}
\setinterfacecommand{defineinteractionmenu}{definitmenuinteraction}
\setinterfacecommand{defineitemgroup}{defineitemgroup}
@@ -1477,7 +1477,7 @@
\setinterfacecommand{setupheads}{regletetes}
\setinterfacecommand{setupheadtext}{regletextetete}
\setinterfacecommand{setuphyphenmark}{reglemarquagehyphenation}
-\setinterfacecommand{setupindentations}{reglealineas}
+\setinterfacecommand{setupindentedtext}{setupindentedtext}
\setinterfacecommand{setupindenting}{reglecomposeenalinea}
\setinterfacecommand{setupinmargin}{regledansmarge}
\setinterfacecommand{setupinteraction}{regleinteraction}
diff --git a/tex/context/base/mult-ini.mkiv b/tex/context/base/mult-ini.mkiv
index bb7e5b514..658716e31 100644
--- a/tex/context/base/mult-ini.mkiv
+++ b/tex/context/base/mult-ini.mkiv
@@ -373,10 +373,12 @@
\def\nostartmessages#1#2\stopmessages
{\egroup}
-\def\setinterfacemessage#1#2#3%
+\unexpanded\def\setinterfacemessage#1#2#3%
{\ifcsname\m!prefix!#1\endcsname\else\setgvalue{\m!prefix!#1}{#1}\fi
\ctxlua{interfaces.setmessage("#1","#2",\!!bs#3\!!es)}}
+\let\stopmessages\relax
+
\unexpanded\def\setmessagetext #1#2{\edef\currentmessagetext{\cldcontext{interfaces.getmessage("#1","#2")}}}
\unexpanded\def\getmessage #1#2{\cldcontext{interfaces.getmessage("#1","#2")}}
@@ -408,14 +410,14 @@
\let\normalshowmessage\showmessage
-\def\showwarning
+\unexpanded\def\showwarning
{\ifshowwarnings
\expandafter\showmessage
\else
\expandafter\gobblethreearguments
\fi}
-\def\showmessage
+\unexpanded\def\showmessage
{\ifshowmessages
\expandafter\normalshowmessage
\else
@@ -435,22 +437,22 @@
%D interface. (We no longer need the link back to the main
%D internal interface.)
-\def\doresetvalue #1#2{\dosetvalue{#1}{#2}{}}
-\def\doignorevalue#1#2#3{\dosetvalue{#1}{#2}{}}
+\unexpanded\def\doresetvalue #1#2{\dosetvalue{#1}{#2}{}}
+\unexpanded\def\doignorevalue#1#2#3{\dosetvalue{#1}{#2}{}}
-\def\doletvalue #1#2{\@EA \let\csname#1#2\endcsname}
-\def\dosetvalue #1#2{\@EA \def\csname#1#2\endcsname}
-\def\dosetevalue #1#2{\@EA\edef\csname#1#2\endcsname}
-\def\dosetgvalue #1#2{\@EA\gdef\csname#1#2\endcsname}
-\def\dosetxvalue #1#2{\@EA\xdef\csname#1#2\endcsname}
-\def\docopyvalue#1#2#3{\@EA \def\csname#1#3\@EA\endcsname\@EA{\csname#2#3\endcsname}}
+\unexpanded\def\doletvalue #1#2{\@EA \let\csname#1#2\endcsname}
+\unexpanded\def\dosetvalue #1#2{\@EA \def\csname#1#2\endcsname}
+\unexpanded\def\dosetevalue #1#2{\@EA\edef\csname#1#2\endcsname}
+\unexpanded\def\dosetgvalue #1#2{\@EA\gdef\csname#1#2\endcsname}
+\unexpanded\def\dosetxvalue #1#2{\@EA\xdef\csname#1#2\endcsname}
+\unexpanded\def\docopyvalue#1#2#3{\@EA \def\csname#1#3\@EA\endcsname\@EA{\csname#2#3\endcsname}}
%D We can now redefine some messages that will be
%D introduced in the multi||lingual system module.
-\def\showassignerror #1#2{\showmessage\m!check1{#1,#2}\waitonfatalerror}
-\def\showargumenterror#1#2{\showmessage\m!check2{#1,#2}\waitonfatalerror}
-\def\showdefinederror #1#2{\showmessage\m!check3{#1,#2}\waitonfatalerror}
+\unexpanded\def\showassignerror #1#2{\showmessage\m!check1{#1,#2}\waitonfatalerror}
+\unexpanded\def\showargumenterror#1#2{\showmessage\m!check2{#1,#2}\waitonfatalerror}
+\unexpanded\def\showdefinederror #1#2{\showmessage\m!check3{#1,#2}\waitonfatalerror}
%D \CONTEXT\ is a parameter driven package. This means that
%D users instruct the system by means of variables, values and
@@ -708,11 +710,11 @@
% temporary mkiv hack (we can best just store the whole table in memory)
-\def\setinterfaceconstant#1#2%
+\unexpanded\def\setinterfaceconstant#1#2%
{\ctxlua{interfaces.setconstant("#1","#2")}%
\setvalue{\c!prefix!#1}{#1}}
-\def\setinterfacevariable#1#2%
+\unexpanded\def\setinterfacevariable#1#2%
{\ctxlua{interfaces.setvariable("#1","#2")}%
\setvalue{\v!prefix!#1}{#2}}
@@ -741,7 +743,7 @@
%D problem, because we just define two elements. When no second
%D part is needed, we use a \type{-}:
-\def\setinterfaceelement#1#2%
+\unexpanded\def\setinterfaceelement#1#2%
{\ctxlua{interfaces.setelement("#1","#2")}%
\ifcsname\e!prefix!#1\endcsname
\doifnotvalue{\e!prefix!#1}{#2}{\setvalue{\e!prefix!#1}{#2}}%
@@ -749,7 +751,7 @@
\setvalue{\e!prefix!#1}{#2}%
\fi}
-\def\setinterfacecommand#1#2%
+\unexpanded\def\setinterfacecommand#1#2%
{\doifnot{#1}{#2}{\@EA\def\csname#2\@EA\endcsname\@EA{\csname#1\endcsname}}}% or just \let ?
%D We just ignore these:
diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii
index 371a3bb00..de04a8ede 100644
--- a/tex/context/base/mult-it.mkii
+++ b/tex/context/base/mult-it.mkii
@@ -1166,7 +1166,7 @@
\setinterfacecommand{defineframedtext}{definiscitestoincorniciato}
\setinterfacecommand{definehbox}{definiscihbox}
\setinterfacecommand{definehead}{definiscitesta}
-\setinterfacecommand{defineindenting}{definiscirientro}
+\setinterfacecommand{defineindentedtext}{defineindentedtext}
\setinterfacecommand{defineinmargin}{defineinmargin}
\setinterfacecommand{defineinteractionmenu}{definiscimenuinterazione}
\setinterfacecommand{defineitemgroup}{defineitemgroup}
@@ -1477,7 +1477,7 @@
\setinterfacecommand{setupheads}{impostateste}
\setinterfacecommand{setupheadtext}{impostatestointestazioni}
\setinterfacecommand{setuphyphenmark}{impostasegnosillabazione}
-\setinterfacecommand{setupindentations}{impostarientri}
+\setinterfacecommand{setupindentedtext}{setupindentedtext}
\setinterfacecommand{setupindenting}{impostarientro}
\setinterfacecommand{setupinmargin}{impostainmargine}
\setinterfacecommand{setupinteraction}{impostainterazione}
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index 4c7421568..87581d70f 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -74,7 +74,7 @@ return {
"scratchtoks", "globalscratchtoks",
"scratchbox", "globalscratchbox",
--
- "scratchwidth", "scratchheight", "scratchdepth",
+ "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset",
--
"scratchcounterone", "scratchcountertwo", "scratchcounterthree",
"scratchdimenone", "scratchdimentwo", "scratchdimenthree",
diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii
index 2484ea818..1cc2a7dd3 100644
--- a/tex/context/base/mult-nl.mkii
+++ b/tex/context/base/mult-nl.mkii
@@ -1166,7 +1166,7 @@
\setinterfacecommand{defineframedtext}{definieerkadertekst}
\setinterfacecommand{definehbox}{definieerhbox}
\setinterfacecommand{definehead}{definieerkop}
-\setinterfacecommand{defineindenting}{doorspringen}
+\setinterfacecommand{defineindentedtext}{definieeringesprongentext}
\setinterfacecommand{defineinmargin}{definieerinmarge}
\setinterfacecommand{defineinteractionmenu}{definieerinteractiemenu}
\setinterfacecommand{defineitemgroup}{definieeritemgroep}
@@ -1477,7 +1477,7 @@
\setinterfacecommand{setupheads}{stelkoppenin}
\setinterfacecommand{setupheadtext}{stelkoptekstin}
\setinterfacecommand{setuphyphenmark}{stelkoppeltekenin}
-\setinterfacecommand{setupindentations}{steldoorspringenin}
+\setinterfacecommand{setupindentedtext}{stelingesprongentextin}
\setinterfacecommand{setupindenting}{stelinspringenin}
\setinterfacecommand{setupinmargin}{stelinmargein}
\setinterfacecommand{setupinteraction}{stelinteractiein}
diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii
index 1ea8fe86a..9244557a8 100644
--- a/tex/context/base/mult-pe.mkii
+++ b/tex/context/base/mult-pe.mkii
@@ -1166,7 +1166,7 @@
\setinterfacecommand{defineframedtext}{تعریف‌متن‌قالبی}
\setinterfacecommand{definehbox}{تعریف‌جعبه‌‌افقی}
\setinterfacecommand{definehead}{تعریف‌سر}
-\setinterfacecommand{defineindenting}{تعریف‌تورفتگی}
+\setinterfacecommand{defineindentedtext}{defineindentedtext}
\setinterfacecommand{defineinmargin}{تعریف‌درون‌حاشیه}
\setinterfacecommand{defineinteractionmenu}{تعریف‌منوی‌پانل}
\setinterfacecommand{defineitemgroup}{تعریف‌گروه‌آیتم}
@@ -1477,7 +1477,7 @@
\setinterfacecommand{setupheads}{بارگذاری‌سرها}
\setinterfacecommand{setupheadtext}{بارگذاری‌متن‌سر}
\setinterfacecommand{setuphyphenmark}{بارگذاری‌نشانه‌شکستن}
-\setinterfacecommand{setupindentations}{بارگذاری‌تورفتگیها}
+\setinterfacecommand{setupindentedtext}{setupindentedtext}
\setinterfacecommand{setupindenting}{بارگذاری‌تورفتگی}
\setinterfacecommand{setupinmargin}{بارگذاری‌درون‌حاشیه}
\setinterfacecommand{setupinteraction}{بارگذاری‌پانل}
diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii
index 8cd97a261..89a4af4f8 100644
--- a/tex/context/base/mult-ro.mkii
+++ b/tex/context/base/mult-ro.mkii
@@ -1166,7 +1166,7 @@
\setinterfacecommand{defineframedtext}{definestetextinconjurat}
\setinterfacecommand{definehbox}{definestehbox}
\setinterfacecommand{definehead}{definesteantet}
-\setinterfacecommand{defineindenting}{definestealiat}
+\setinterfacecommand{defineindentedtext}{defineindentedtext}
\setinterfacecommand{defineinmargin}{defineinmargin}
\setinterfacecommand{defineinteractionmenu}{definestemeniuinteractiune}
\setinterfacecommand{defineitemgroup}{defineitemgroup}
@@ -1477,7 +1477,7 @@
\setinterfacecommand{setupheads}{seteazatitluri}
\setinterfacecommand{setupheadtext}{seteazatexttitlu}
\setinterfacecommand{setuphyphenmark}{seteazaliniesilabe}
-\setinterfacecommand{setupindentations}{seteazaaliniate}
+\setinterfacecommand{setupindentedtext}{setupindentedtext}
\setinterfacecommand{setupindenting}{seteazaaliniat}
\setinterfacecommand{setupinmargin}{seteazamarginal}
\setinterfacecommand{setupinteraction}{seteazainteractiunea}
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index 051b32ded..5ae28db77 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -643,7 +643,7 @@
\definesystemvariable {pc} % PageComment
\definesystemvariable {pe} % PagEhandler
\definesystemvariable {pf} % ProFiel
-\definesystemvariable {pg} % KoppelPagina
+%definesystemvariable {pg} %
\definesystemvariable {ph} % ParagrapH
\definesystemvariable {pl} % PLaats
\definesystemvariable {pn} % PaginaNummer
@@ -725,13 +725,16 @@
\definesystemvariable {wl} % WidgetLabel
\definesystemvariable {wc} % WidgetContent
\definesystemvariable {wt} % WidgetTotal
-\definesystemvariable {ws} % WidgetStack
+\definesystemvariable {ws} % WidgetStack (not used)
\definesystemvariable {wh} % WidgetHelp
\definesystemvariable {wp} % WidgetPopuphelp
+\definesystemvariable {wz} % whitespace
\definesystemvariable {xm} % xml (mkiv)
\definesystemvariable {xp} % XML Processing
\definesystemvariable {xy} % schaal
-\definesystemvariable {za} % ZetspiegelAanpassing
+\definesystemvariable {za} % layout adapt % ZetspiegelAanpassing
+\definesystemvariable {zc} % columns
+\definesystemvariable {zo} % otr
%D Next we define some language independant one letter
%D variables and keywords. (should become s!)
diff --git a/tex/context/base/node-rul.mkiv b/tex/context/base/node-rul.mkiv
index 0567a9f29..b093521f9 100644
--- a/tex/context/base/node-rul.mkiv
+++ b/tex/context/base/node-rul.mkiv
@@ -125,7 +125,7 @@
{\edef\currentbar{#1}%
\advance\csname\??on:#1:c\endcsname\plusone % local ?
\scratchcounter\csname\??on:#1:c\endcsname
- \dosetbarattributes\c!foregroundstyle\c!foregroundcolor
+ \usebarstyleandcolor\c!foregroundstyle\c!foregroundcolor
\attribute\ruledattribute\numexpr
1000*\scratchcounter
+\csname\??on#1\ifcsname\??on#1:\number\scratchcounter\s!parent\endcsname:\number\scratchcounter\fi:a\endcsname
@@ -266,7 +266,7 @@
\scratchcounter\csname\??ra:#1:c\endcsname
\attribute\shiftedattribute\numexpr1000*\scratchcounter
+\csname\??ra#1\ifcsname\??ra#1:\number\scratchcounter\s!parent\endcsname:\number\scratchcounter\fi:a\endcsname
- \dosetshiftattributes\c!style\c!color
+ \useshiftstyleandcolor\c!style\c!color
\dosetupisolatedalign{\shiftparameter\c!align}}
\unexpanded\def\doshifted#1%
diff --git a/tex/context/base/pack-bck.mkvi b/tex/context/base/pack-bck.mkvi
index c783a17d8..db7cd7bee 100644
--- a/tex/context/base/pack-bck.mkvi
+++ b/tex/context/base/pack-bck.mkvi
@@ -152,7 +152,7 @@
\ifcase\backgroundsplitmode % no split
\backgroundparameter\c!after
\else % some split
- \vfill\eject % geen \page !
+ \page_otr_fill_and_eject_page % no \page !
\fi
\else
\page
diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv
index 9fab9c434..a7a025a15 100644
--- a/tex/context/base/pack-box.mkiv
+++ b/tex/context/base/pack-box.mkiv
@@ -297,10 +297,11 @@
\setcollector
[caption][#1]
{\getparameters[\??du][#2]%
- \dosetfontattribute\??du\c!style\setupinterlinespace
+ \dousestyleparameter\@@dustyle
+ \setupinterlinespace
\framed % watch the special setting of kader/overlay
- [\c!frame=\v!overlay,#2]
- {\doattributes\??du\c!style\c!color{#3}}}%
+ [\c!frame=\v!overlay,\c!foregroundcolor=\@@ducolor,\c!foregroundstyle=\@@dustyle,#2]
+ {#3}}%
\composedcollector{caption}%
\egroup}%
\hbox}
@@ -342,10 +343,11 @@
[caption]
[#1]
{\getparameters[\??du][#2]%
- \dosetfontattribute\??du\c!style\setupinterlinespace
+ \dousestyleparameter\@@dustyle
+ \setupinterlinespace
\framed
- [\c!frame=\v!overlay,,#2]
- {\doattributes\??du\c!style\c!color{#3}}}%
+ [\c!frame=\v!overlay,\c!foregroundcolor=\@@ducolor,\c!foregroundstyle=\@@dustyle,#2]
+ {#3}}%
\egroup
\framed
[\c!offset=\v!overlay,
@@ -603,8 +605,8 @@
{\forgetall
\hsize\@@lxwidth
\expanded{\setupalign[\@@lxalign]}%
- \dosetfontattribute\??lx\c!style}
- {\setlayer[#1][#2]{\strut\color[\@@lxcolor]{\flushnextbox}}%
+ \dousestyleparameter\@@lxstyle}
+ {\setlayer[#1][#2]{\strut\dousecolorparameter\@@lxcolor\flushnextbox}%
\egroup}%
\vtop}
diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv
index f812586ce..69cce43cb 100644
--- a/tex/context/base/pack-lyr.mkiv
+++ b/tex/context/base/pack-lyr.mkiv
@@ -501,7 +501,7 @@
\if!!donec\box\else\copy\fi\layerbox % sorry for the delay due to copying
\fi
% todo: method=offset => overlayoffset right/down (handy for backgrounds with offset)
- \doifoverlayelse{#2}{\setlayoutcomponentattribute\v!layer{#2}}\resetlayoutcomponentattribute
+ \doifoverlayelse{#2}{\setlayoutcomponentattribute{\v!layer:#2}}\resetlayoutcomponentattribute
\iftracelayers \ruledvbox \else \vbox \fi \if!!donea to \overlayheight \fi \layoutcomponentboxattribute
{\hbox \if!!donea to \overlaywidth \fi
{\edef\@@currentlayerpageposition{\csname\??ll#2\realfolio\c!position\endcsname}%
diff --git a/tex/context/base/pack-mis.mkvi b/tex/context/base/pack-mis.mkvi
index f7c506b8e..289b1232c 100644
--- a/tex/context/base/pack-mis.mkvi
+++ b/tex/context/base/pack-mis.mkvi
@@ -62,7 +62,7 @@
\flushnextbox
\placementparameter\c!right}%
\ifinsidefloat \else
- \addlocalbackgroundtobox\nextbox
+ \page_backgrounds_add_local_to_box\nextbox
\fi
\ifgridsnapping
\doifinset{\placementparameter\c!margin}{\v!standard,\v!yes}\noindent % unchecked
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index 80196c098..4c33e44c0 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -307,7 +307,7 @@
\long\def\executedefinedoverlay#1#2%
{\bgroup
- \setlayoutcomponentattribute\v!overlay{#1}%
+ \setlayoutcomponentattribute{\v!overlay:#1}%
\edef\overlaywidth {\the\frameddimenwd\space}%
\edef\overlayheight{\the\dimexpr\frameddimenht+\frameddimendp\relax\space}%
\edef\overlaydepth {\the\frameddimendp\space}%
@@ -424,7 +424,7 @@
\ifx\component\empty
\resetlayoutcomponentattribute
\else
- \setlayoutcomponentattribute\v!background\component
+ \setlayoutcomponentattribute{\v!background:\component}%
\fi
\let\foregroundbox\normalforegroundbox
\hbox \layoutcomponentboxattribute to \backgroundwidth % width in case 'foreground' is used as overlay
@@ -716,12 +716,12 @@
%D Here is another fast one:
-\def\localbackgroundframed#1#2#3#4% tag box wd ht
- {\setbox#2\vbox\bgroup
- \doinitializeframed{\??ma#1}%
- \expandafter\def\csname\??ma#1\c!component\endcsname{#1}%
- \expandafter\def\csname\??ma#1\c!width \endcsname{#3}%
- \expandafter\def\csname\??ma#1\c!height \endcsname{#4}%
+\def\localbackgroundframed#1#2#3#4#5% namespace location box wd ht
+ {\setbox#3\vbox\bgroup
+ \doinitializeframed{#1#2}% watch out! am used here
+ \expandafter\def\csname#1#2\c!component\endcsname{#2}%
+ % \expandafter\def\csname#1#2\c!width \endcsname{#4}%
+ % \expandafter\def\csname#1#2\c!height \endcsname{#5}%
\!!framedframeoffset\framedparameter\c!frameoffset
\edef\@@framedbackgroundoffset{\framedparameter\c!backgroundoffset}%
\ifx\@@framedbackgroundoffset\v!frame
@@ -729,7 +729,9 @@
\else
\!!framedbackgroundoffset\@@framedbackgroundoffset
\fi
- \setbox\framebox\box#2%
+ \setbox\framebox\box#3%
+ \wd\framebox#4%
+ \ht\framebox#5%
\dp\framebox\zeropoint
\edef\framedbackground {\framedparameter\c!background}%
\edef\framedrulethickness{\framedparameter\c!rulethickness}%
@@ -780,11 +782,11 @@
\def\doframedparentparameter#1#2{\ifx#1\relax\doframedrootparameter#2\else\doframedparameter#1{#2}\fi}
\def\doframedrootparameter #1{\ifcsname\??oi#1\endcsname\??oi#1\else\s!empty\fi}
-\def\dosetframedattributes#1#2% style color
- {\edef\fontattributehash {\framedparameterhash#1}%
- \edef\colorattributehash{\framedparameterhash#2}%
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
+\def\useframedstyleandcolor#1#2% style color
+ {\edef\currentstyleparameter{\framedparameter#1}%
+ \edef\currentcolorparameter{\framedparameter#2}%
+ \ifx\currentstyleparameter\empty\else\dousestyleparameter\currentstyleparameter\fi
+ \ifx\currentcolorparameter\empty\else\dousecolorparameter\currentcolorparameter\fi}
\def\frameddimension#1{\the\dimexpr\framedparameter{#1}\relax}
@@ -957,8 +959,8 @@
% new, experimental dirty hook
\framedparameter\c!extras
% to get the right spacing
- \edef\fontattributehash{\framedparameterhash\c!foregroundstyle}%
- \ifx\fontattributehash\empty\else\dosetfontattribute\fontattributehash\c!foregroundstyle\fi
+ \edef\!!framedforegroundstyle{\framedparameter\c!foregroundstyle}%
+ \ifx\!!framedforegroundstyle\empty\else\dousestyleparameter\!!framedforegroundstyle\fi
% beware, both the frame and background offset can be overruled
%
\edef\doframedsetups{\framedparameter\c!setups}%
@@ -1749,8 +1751,8 @@
\def\framedforgetall{\forgetall}
\def\setframedforegroundcolor
- {\edef\colorattributehash{\framedparameterhash\c!foregroundcolor}%
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash\c!foregroundcolor\fi}
+ {\edef\!!framedforegroundcolor{\framedparameter\c!foregroundcolor}%
+ \ifx\!!framedforegroundcolor\empty\else\dousecolorparameter\!!framedforegroundcolor\fi}
\def\doformatboxSomeFormat
{\vbox to \!!framedheight
@@ -2826,8 +2828,7 @@
\doif{\framedtextparameter\c!depthcorrection}\v!on\doftstartdepthcorrection
\doinhibitblank % \blank[\v!disable]% plaatst signal
\setupindenting[\framedtextparameter\c!indenting]%
- %\doconvertfont{\framedtextparameter\c!style}\empty} %%%%% todo: attr setter
- \dosetframedtextattributes\c!style\c!color}
+ \useframedtextstyleandcolor\c!style\c!color}
%D The \type {none} option is handy for nested usage, as
%D in the presentation styles, where we don't want
@@ -2860,7 +2861,7 @@
\def\checkframedtext % messy dependency
{\ifinsidefloat
\localhsize\hsize
- \else\ifdim\sidefloatvsize>\zeropoint % will be proper handle
+ \else\ifdim\d_page_sides_vsize>\zeropoint % also possible: \c_page_sides_checks_done>\zeropoint
% \strut % rather clean way to invoke the sidefloat OTR
% \setbox0=\lastbox % and get the widths set, so from now on we
% \setlocalhsize % can have framed texts alongside sidefloats
@@ -2935,7 +2936,7 @@
\blank[\v!disable]%
\let\\=\endgraf
\framedtextparameter\c!inner
- \dosetframedtextattributes\c!style\c!color
+ \useframedtextstyleandcolor\c!style\c!color
\bgroup
\aftergroup\docloseframedtext
\let\next=}
@@ -3088,11 +3089,19 @@
\dimen6\dimexpr-.5ex+.5\linewidth\relax
\doifsomething{#1}
{\doifelse\@@tllocation\v!inmargin
- {\llap{\doattributes\??tl\c!style\c!color{#1}\hskip\leftmargindistance}}
+ {\llap
+ {\dousestyleparameter\@tlstyle
+ \dousecolorparameter\@tlcolor
+ #1%
+ \hskip\leftmargindistance}}
{\color[\@@tlrulecolor]
{\vrule\!!height\dimen4\!!depth\dimen6\!!width\@@tlwidth}%
\hbox spread 2\dimexpr\@@tldistance\relax
- {\hss\doattributes\??tl\c!style\c!color{\strut#1}\hss}}}%
+ {\hss
+ \dousestyleparameter\@tlstyle
+ \dousecolorparameter\@tlcolor
+ \strut#1%
+ \hss}}}%
\color[\@@tlrulecolor]
{\leaders\hrule\!!height\dimen4\!!depth\dimen6\hfill}}%
\ht\scratchbox\strutht
@@ -3218,9 +3227,10 @@
{\hbox}
{\hbox to \@@ilwidth}}%
\bgroup
- \doattributes\??il\c!style\c!color{\strut#2\hfill\@@ilseparator}%
- \hskip\@@ildistance
- \egroup}%
+ \dousestyleparameter\@@ilstyle
+ \dousecolorparameter\@@ilcolor
+ \strut#2\hfill\@@ilseparator\hskip\@@ildistance
+ \egroup}%
%\hangindent=\wd0\relax % tzt hang=yes,n
%\parindent=\hangindent
%\box0\relax
@@ -3229,7 +3239,9 @@
#4%
\doifsomething{#3}
{\kern\@@ildistance
- \doattributes\??il\c!style\c!color{#3\strut}}%
+ \dousestyleparameter\@@ilstyle
+ \dousecolorparameter\@@ilcolor
+ #3\strut}%
\endgroup
\endgraf
\@@ilafter}
diff --git a/tex/context/base/page-app.mkiv b/tex/context/base/page-app.mkiv
index b85132870..e2a249531 100644
--- a/tex/context/base/page-app.mkiv
+++ b/tex/context/base/page-app.mkiv
@@ -45,8 +45,8 @@
\c!location=\v!middle]
\appendtoks
- \setuevalue{\e!start\currentfittingpage}{\startfittingpage[\currentfittingpage]}%
- \setuevalue{\e!stop \currentfittingpage}{\stopfittingpage}%
+ \setuevalue{\e!start\currentfittingpage}{\startfittingpage[\currentfittingpage]}%
+ \setuevalue{\e!stop \currentfittingpage}{\stopfittingpage}%
\to \everydefinefittingpage
\unexpanded\def\startfittingpage
@@ -56,6 +56,7 @@
{\page % this is kind of tricky! there can be preceding page refs
\autostarttext
\bgroup % resulting in a zero height page; test fig-make !
+ \setupinterlinespace[\v!top=0]% no topskip
\def\currentfittingpage{#1}%
\dontcomplain
% runs under current page regime, i.e. page variables passed to mp
@@ -148,17 +149,17 @@
%D maybe I should support stream=yes in framed.
\unexpanded\def\startTEXstream
- {\dosingleempty\dostartTEXstream}
+ {\dosingleempty\start_TEX_stream}
-\def\dostartTEXstream[#1]% old code, to be redone
+\def\start_TEX_stream[#1]% old code, to be redone
{\page
- \defineoutputstream[tex]%
- \enableoutputstream[tex]%
- \unexpanded\def\stopTEXstream
- {\disableoutputstream
- \startTEXpage
- \outputstreamunvbox[tex]%
- \stopTEXpage}}
+ \enableoutputstream[tex]}
+
+\unexpanded\def\stopTEXstream
+ {\disableoutputstream
+ \startTEXpage
+ \outputstreamunvbox[tex]%
+ \stopTEXpage}
%D Application pages, a quick \MKIV\ hack:
@@ -169,7 +170,7 @@
\def\TEXapplicationfilename{\jobname-texapplication.tex}
-\def\stopTEXapplication
+\unexpanded\def\stopTEXapplication
{\savebuffer[\thedefinedbuffer{TEXapplication}][\TEXapplicationfilename]%
\typesetfile[TEXapplication][\TEXapplicationfilename]\relax}
@@ -181,9 +182,9 @@
%D \stoptyping
\unexpanded\def\startpagefigure
- {\dodoubleempty\dostartpagefigure}
+ {\dodoubleempty\start_page_figure}
-\def\dostartpagefigure[#1][#2]%
+\def\start_page_figure[#1][#2]%
{\bgroup
\getparameters[\??ex][\c!offset=\v!overlay,#2]%
\startTEXpage[\c!offset=\@@exoffset]%
@@ -194,9 +195,9 @@
\egroup}
\def\pagefigure
- {\dodoubleempty\dopagefigure}
+ {\dodoubleempty\page_figure}
-\def\dopagefigure[#1][#2]%
- {\dostartpagefigure[#1][#2]\stoppagefigure}
+\def\page_figure[#1][#2]%
+ {\start_page_figure[#1][#2]\stoppagefigure}
\protect \endinput
diff --git a/tex/context/base/page-bck.mkiv b/tex/context/base/page-bck.mkiv
index 2608ee828..164549d9d 100644
--- a/tex/context/base/page-bck.mkiv
+++ b/tex/context/base/page-bck.mkiv
@@ -11,29 +11,12 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\writestatus{loading}{ConTeXt Page Macros / Backgrounds}
+% todo: ma:r:c
-% todo \fastlocalframed -> \localbackgroundframed
+\writestatus{loading}{ConTeXt Page Macros / Backgrounds}
\unprotect
-%D \macros
-%D {recalculatebackgrounds}
-%D
-%D We use a couple of switches so that we can minimize the
-%D amount of background calculations. The main switch is set
-%D by the recalculate directive.
-%D
-%D \starttyping
-%D \recalculatebackgrounds
-%D \stoptyping
-%D
-%D Other modules may not directly set the switches
-%D themselves.
-
-\newif\ifnewbackground
-\newif\ifsomebackground
-
%D For special purposes, users can question the \type
%D {*background} mode. This mode is only available when
%D typesetting the pagebody.
@@ -42,63 +25,103 @@
%D \startmode[*background] ...
%D \stoptyping
+\newconditional\c_page_backgrounds_new
+\newconditional\c_page_backgrounds_new_right
+\newconditional\c_page_backgrounds_new_left
+\newconditional\c_page_backgrounds_some
+
\appendtoks
- \ifsomebackground \ifnewbackground \setsystemmode\v!background \fi \fi
+ \ifconditional\c_page_backgrounds_some
+ \ifconditional\c_page_backgrounds_new
+ \setsystemmode\v!background
+ \fi
+ \fi
\to \everybeforepagebody
-%D \macros
-%D {addmainbackground, addtextbackground,
-%D addpagebackground, addprintbackground}
-%D
-%D Apart from the previously mentioned directive, the
-%D interface between this module and the other modules
-%D is made up by four macros that add background to parts of
-%D the layout.
-%D
-%D \starttyping
-%D \addmainbackground <box>
-%D \addtextbackground <box>
-%D \addpagebackground <box>
-%D \addprintbackground <box>
-%D \stoptyping
-
-%D To minimize calculations, we keep track of the state of the
-%D background of each area. A previous implementation did
-%D check each call to the background calculation macro, but
-%D using an intermediate usage flag instead of testing each
-%D time saves about 3\% on a run with a couple of backgrounds.
-%D (On the 824 pages maps bibliography runtime went down from
-%D 309 to 299 seconds.)
+%D We keep calculations and checks to a minimum and also
+%D try to minimize the amount of tracing due to expansion.
\let\currentotrbackground\empty
-\def\@@docheckbackground#1#2%
- {\ifcsname\currentotrbackground#1\endcsname
- \edef\!!stringa{\csname\currentotrbackground#1\endcsname}\ifx\!!stringa#2\!!doneatrue\fi
+\def\page_backgrounds_set_yes{\expandafter\let\csname\currentotrbackground\endcsname\relax }
+\def\page_backgrounds_set_nop{\expandafter\let\csname\currentotrbackground\endcsname\undefined}
+
+\def\page_backgrounds_check_background
+ {\ifcsname\currentotrbackground\c!background\endcsname
+ \edef\page_background_temp{\csname\currentotrbackground\c!background\endcsname}%
+ \ifx\page_background_temp\empty
+ \expandafter\expandafter\expandafter\page_backgrounds_check_frame
+ \else
+ \page_backgrounds_set_yes
+ \fi
+ \else
+ \expandafter\page_backgrounds_check_frame
\fi}
-\def\@@nocheckbackground#1#2%
- {\ifcsname\currentotrbackground#1\endcsname
- \edef\!!stringa{\csname\currentotrbackground#1\endcsname}\ifx\!!stringa#2\else\!!doneatrue\fi
+\def\page_backgrounds_check_frame
+ {\ifcsname\currentotrbackground\c!frame\endcsname
+ \edef\page_background_temp{\csname\currentotrbackground\c!frame\endcsname}%
+ \ifx\page_background_temp\v!on
+ \page_backgrounds_set_yes
+ \else
+ \expandafter\expandafter\expandafter\page_backgrounds_check_leftframe
+ \fi
+ \else
+ \expandafter\page_backgrounds_check_leftframe
\fi}
-\def\checkbackground#1% here we need an \ifempty primitive
- {\edef\currentotrbackground{\??ma#1}%
- \begingroup
- \!!doneafalse
- \if!!donea\else\@@nocheckbackground\c!background \empty
- \if!!donea\else\@@docheckbackground\c!frame \v!on
- \if!!donea\else\@@nocheckbackground\c!foregroundcolor\empty
- \if!!donea\else\@@docheckbackground\c!leftframe \v!on
- \if!!donea\else\@@docheckbackground\c!rightframe \v!on
- \if!!donea\else\@@docheckbackground\c!topframe \v!on
- \if!!donea\else\@@docheckbackground\c!bottomframe \v!on \fi\fi\fi\fi\fi\fi\fi
- \if!!donea
- \endgroup\expandafter\let\csname\currentotrbackground\endcsname\relax
+\def\page_backgrounds_check_leftframe
+ {\ifcsname\currentotrbackground\c!leftframe\endcsname
+ \edef\page_background_temp{\csname\currentotrbackground\c!leftframe\endcsname}%
+ \ifx\page_background_temp\v!on
+ \page_backgrounds_set_yes
+ \else
+ \expandafter\expandafter\expandafter\page_backgrounds_check_rightframe
+ \fi
\else
- \endgroup\expandafter\let\csname\currentotrbackground\endcsname\undefined
+ \expandafter\page_backgrounds_check_rightframe
\fi}
+\def\page_backgrounds_check_rightframe
+ {\ifcsname\currentotrbackground\c!rightframe\endcsname
+ \edef\page_background_temp{\csname\currentotrbackground\c!rightframe\endcsname}%
+ \ifx\page_background_temp\v!on
+ \page_backgrounds_set_yes
+ \else
+ \expandafter\expandafter\expandafter\page_backgrounds_check_topframe
+ \fi
+ \else
+ \expandafter\page_backgrounds_check_topframe
+ \fi}
+
+\def\page_backgrounds_check_topframe
+ {\ifcsname\currentotrbackground\c!topframe\endcsname
+ \edef\page_background_temp{\csname\currentotrbackground\c!topframe\endcsname}%
+ \ifx\page_background_temp\v!on
+ \page_backgrounds_set_yes
+ \else
+ \expandafter\expandafter\expandafter\page_backgrounds_check_bottomframe
+ \fi
+ \else
+ \expandafter\page_backgrounds_check_bottomframe
+ \fi}
+
+\def\page_backgrounds_check_bottomframe
+ {\ifcsname\currentotrbackground\c!bottomframe\endcsname
+ \edef\page_background_temp{\csname\currentotrbackground\c!bottomframe\endcsname}%
+ \ifx\page_background_temp\v!on
+ \page_backgrounds_set_yes
+ \else
+ \page_backgrounds_set_nop
+ \fi
+ \else
+ \page_backgrounds_set_nop
+ \fi}
+
+\def\page_backgrounds_check#1%
+ {\edef\currentotrbackground{\??ma#1}%
+ \page_backgrounds_check_background}
+
\def\ifsomebackgroundfound#1%
{\ifcsname\??ma#1\endcsname}
@@ -120,31 +143,35 @@
%D macro. This means that all normal frame and overlay
%D features can be used.
-\def\addsomebackground#1#2#3#4% area box width height / zero test added
- {\ifsomebackgroundfound#1\ifdim#3>\zeropoint\ifdim#4>\zeropoint
- \ifcsname\??ma#1\c!setups\endcsname % to be done
- \doprocesslocalsetups{\csname\??ma#1\c!setups\endcsname}% should not produce funny spaces !
+\def\page_backgrounds_add_to_box#1#2#3#4% area box width height / zero test added
+ {\ifcsname\??ma#1\endcsname
+ \ifdim#3>\zeropoint
+ \ifdim#4>\zeropoint
+ \ifcsname\??ma#1\c!setups\endcsname % to be done
+ \doprocesslocalsetups{\csname\??ma#1\c!setups\endcsname}% should not produce funny spaces !
+ \fi
+ \localbackgroundframed\??ma{#1}{#2}{#3}{#4}%
+ \fi
\fi
- \localbackgroundframed{#1}{#2}{#3}{#4}%
- \fi\fi\fi}
+ \fi}
%D There are quite some backgrounds. At the bottom layer,
%D there is the {\em paper} background. This one is only
%D used for special purposes, like annotations to documents.
-\def\addprintbackground#1%
- {\addsomebackground\v!paper#1\printpaperwidth\printpaperheight}
+\def\page_backgrounds_add_to_print#1%
+ {\page_backgrounds_add_to_box\v!paper#1\printpaperwidth\printpaperheight}
%D The page backgrounds can be put behind the {\em left
%D page}, the {\em right page} or {\em each page}. As with
%D the paper background, these are calculated on each page.
-\def\addpagebackground#1%
+\def\page_backgrounds_add_to_paper#1%
{\doifbothsidesoverruled
- {\addsomebackground\v!rightpage#1\paperwidth\paperheight}
- {\addsomebackground\v!rightpage#1\paperwidth\paperheight}
- {\addsomebackground\v!leftpage #1\paperwidth\paperheight}%
- \addsomebackground\v!page #1\paperwidth\paperheight}
+ {\page_backgrounds_add_to_box\v!rightpage#1\paperwidth\paperheight}
+ {\page_backgrounds_add_to_box\v!rightpage#1\paperwidth\paperheight}
+ {\page_backgrounds_add_to_box\v!leftpage #1\paperwidth\paperheight}%
+ \page_backgrounds_add_to_box\v!page#1\paperwidth\paperheight}
%D Then there are the 25 areas that make up the layout: {\em
%D top, header, text, footer, bottom} times {\em left edge,
@@ -155,28 +182,17 @@
\newbox\leftbackground
\newbox\rightbackground
-\def\addmainbackground#1% todo: dimension spec
- {\ifcase\pageornamentstate
- \ifsomebackground
- \ifnewbackground \setbackgroundboxes \fi
- \setbox#1\vbox
- {\offinterlineskip
- \doifmarginswapelse{\copy\leftbackground}{\copy\rightbackground}%
- \box#1}%
- \fi
- \fi}
-
%D Finaly there is an aditional {\em text} background, again
%D useful for special purposes only. This one is calculated
%D each time. The hidden backgrounds are not meant for users!
-\newconditional\hiddenbackgroundenabled
+\newconditional\c_page_backgrounds_hidden_enabled
-\def\addtextbackground#1%
- {\ifconditional\hiddenbackgroundenabled
- \addsomebackground\v!hidden#1\makeupwidth\textheight % mine !
+\def\page_backgrounds_add_to_text#1%
+ {\ifconditional\c_page_backgrounds_hidden_enabled
+ \page_backgrounds_add_to_box\v!hidden#1\makeupwidth\textheight % mine !
\fi
- \addsomebackground\v!text#1\makeupwidth\textheight}
+ \page_backgrounds_add_to_box\v!text#1\makeupwidth\textheight}
%D The next couple of macros implement the area backgrounds.
%D As said, these are cached in dedicated boxes. The offsets
@@ -190,50 +206,56 @@
%D background at the same time since something may have
%D changed halfway a page.
-\newconditional\newrightbackground
-\newconditional\newleftbackground
+%D Margin swapping has been simplified: see mkii code in case of
+%D regression. Calculation is delayed till the page anyway so the
+%D state is known.
-\def\recalculatebackgrounds
- {\global\newbackgroundtrue}
+\def\recalculatebackgrounds % will be renamed
+ {\global\settrue\c_page_backgrounds_new}
-\def\setbackgroundboxes
- {\ifnewbackground
- \dosetbackgroundboxesr
+\def\page_backgrounds_set_boxes
+ {\ifconditional\c_page_backgrounds_new
+ \page_backgrounds_set_boxes_r
\fi
- \doifbothsides\dosetbackgroundboxesa\dosetbackgroundboxesb\dosetbackgroundboxesc
- \ifx\@@mastate\v!repeat\else\global\newbackgroundfalse\fi}
+ \doifbothsides
+ \page_backgrounds_set_boxes_a
+ \page_backgrounds_set_boxes_b
+ \page_backgrounds_set_boxes_c
+ \ifx\@@mastate\v!repeat\else
+ \global\setfalse\c_page_backgrounds_new
+ \fi}
-\def\dosetbackgroundboxesr
- {\global\settrue\newrightbackground
- \global\settrue\newleftbackground
+\def\page_backgrounds_set_boxes_r
+ {\global\settrue\c_page_backgrounds_new_right
+ \global\settrue\c_page_backgrounds_new_left
\global\setbox\leftbackground\emptybox
\global\setbox\rightbackground\emptybox}
-\def\dosetbackgroundboxesa
- {\ifconditional\newleftbackground
+\def\page_backgrounds_set_boxes_a
+ {\ifconditional\c_page_backgrounds_new_left
% \showmessage\m!layouts8\empty
- \setbackgroundbox\leftbackground\relax
- \global\setfalse\newleftbackground
- \global\setfalse\newrightbackground
+ \page_backgrounds_set_box\leftbackground % \conditionalfalse
+ \global\setfalse\c_page_backgrounds_new_left
+ \global\setfalse\c_page_backgrounds_new_right
\fi}
-\def\dosetbackgroundboxesb
- {\ifconditional\newleftbackground
+\def\page_backgrounds_set_boxes_b
+ {\ifconditional\c_page_backgrounds_new_left
% \showmessage\m!layouts8\empty
- \setbackgroundbox\leftbackground\relax
- \global\setfalse\newleftbackground
+ \page_backgrounds_set_box\leftbackground % \conditionalfalse
+ \global\setfalse\c_page_backgrounds_new_left
\fi}
-\def\dosetbackgroundboxesc
- {\ifconditional\newrightbackground
+\def\page_backgrounds_set_boxes_c
+ {\ifconditional\c_page_backgrounds_new_right
% \showmessage\m!layouts8\empty
- \setbackgroundbox\rightbackground\doswapmargins
- \global\setfalse\newrightbackground
+ \page_backgrounds_set_box\rightbackground % \conditionaltrue
+ \global\setfalse\c_page_backgrounds_new_right
\fi}
-\def\addmainbackground#1% todo: dimension spec
- {\ifsomebackground
- \setbackgroundboxes
+\def\page_backgrounds_add_to_main#1% todo: dimension spec
+ {\ifconditional\c_page_backgrounds_some
+ \page_backgrounds_set_boxes
\setbox#1\vbox
{\offinterlineskip
\doifmarginswapelse{\copy\leftbackground}{\copy\rightbackground}%
@@ -243,34 +265,61 @@
\newdimen\pagebackgroundhoffset % THESE WILL BECOME OBSOLETE
\newdimen\pagebackgroundvoffset
\newdimen\pagebackgrounddepth
-\newdimen\pagebackgroundoffset
-
-\def\setbackgroundoffsets % used in menus (we can use ifcsname's here)
- {\ifsomebackground \ifnewbackground
- \global\pagebackgroundhoffset\zeropoint
- \global\pagebackgroundvoffset\zeropoint
- \global\pagebackgrounddepth \zeropoint
- \doifsomebackgroundelse{\v!text\v!text}\donetrue\donefalse
- \ifdone\else\doifsomebackgroundelse\v!text\donetrue\donothing\fi
- \ifdone
- \begingroup
- \scratchdimen\csname\??ma\v!page\c!offset\endcsname
- \doifsomebackgroundelse{\v!top\v!text}\donothing
- {\doifsomebackgroundelse{\v!bottom\v!text}\donothing
- {\global\pagebackgroundhoffset\scratchdimen}}%
- \doifsomebackgroundelse{\v!text\v!rightedge}\donothing
- {\doifsomebackgroundelse{\v!text\v!leftedge}\donothing
- {\global\pagebackgroundvoffset\scratchdimen
- \global\pagebackgrounddepth\csname\??ma\v!page\c!depth\endcsname}}%
- \endgroup
- \fi
+\newdimen\pagebackgroundcompensation
+
+\newdimen\pagebackgroundoffset % used elsewhere
+
+\def\page_backgrounds_set_offsets % used in menus (we can use ifcsname's here)
+ {\ifconditional\c_page_backgrounds_some \ifconditional\c_page_backgrounds_new
+ \page_backgrounds_set_offsets_indeed % indirect, less tracing
\fi \fi}
-\appendtoks \setbackgroundoffsets \to \everybeforepagebody
+\def\page_backgrounds_set_offsets_indeed
+ {\ifcsname\??ma\v!text\v!text\endcsname
+ \page_backgrounds_set_offsets_yes
+ \else\ifcsname\??ma\v!text\endcsname
+ \page_backgrounds_set_offsets_yes
+ \else
+ \page_backgrounds_set_offsets_nop
+ \fi\fi}
+
+\def\page_backgrounds_set_offsets_nop
+ {\global\pagebackgroundhoffset \zeropoint
+ \global\pagebackgroundvoffset \zeropoint
+ \global\pagebackgrounddepth \zeropoint
+ \global\pagebackgroundcompensation\zeropoint}
+
+\def\page_backgrounds_set_offsets_yes
+ {\global\pagebackgroundcompensation\csname\??ma\v!page\c!offset\endcsname\relax
+ \ifzeropt\pagebackgroundcompensation
+ \page_backgrounds_set_offsets_nop
+ \else
+ \ifcsname\??ma\v!top\v!text\endcsname
+ \global\pagebackgroundhoffset\zeropoint
+ \else\ifcsname\??ma\v!bottom\v!text\endcsname
+ \global\pagebackgroundhoffset\zeropoint
+ \else
+ \global\pagebackgroundhoffset\pagebackgroundcompensation
+ \fi\fi
+ \ifcsname\??ma\v!text\v!rightedge\endcsname
+ \global\pagebackgroundvoffset\zeropoint
+ \global\pagebackgrounddepth \zeropoint
+ \else\ifcsname\??ma\v!text\v!leftedge\endcsname
+ \global\pagebackgroundvoffset\zeropoint
+ \global\pagebackgrounddepth \zeropoint
+ \else
+ \global\pagebackgroundvoffset\pagebackgroundcompensation
+ \global\pagebackgrounddepth \csname\??ma\v!page\c!depth\endcsname\relax
+ \fi\fi
+ \fi}
+
+\appendtoks
+ \page_backgrounds_set_offsets
+\to \everybeforepagebody
\newconditional\swapbackgroundmargins \settrue\swapbackgroundmargins
-\def\setbackgroundbox#1#2%
+\def\page_backgrounds_set_box#1% #2%
{\global\setbox#1\vbox
{\dontcomplain
\swapmargins
@@ -281,60 +330,95 @@
\fi
\calculatereducedvsizes
\offinterlineskip
- #2\relax
+ % \ifconditional#2\relax
+ % \doswapmargins % hm, this one gets nilled in \swapmargins anyway
+ % \fi
\vskip\dimexpr-\topheight-\topdistance\relax
- \dodopagebodybackground\v!top\topheight
+ \ifdim\topheight>\zeropoint
+ \page_backgrounds_set_box_column\v!top\topheight
+ \fi
\vskip\topdistance
- \dodopagebodybackground\v!header\headerheight
+ \ifdim\headerheight>\zeropoint
+ \page_backgrounds_set_box_column\v!header\headerheight
+ \fi
\vskip\headerdistance
- \dodopagebodybackground\v!text\textheight
+ \ifdim\textheight>\zeropoint
+ \page_backgrounds_set_box_column\v!text\textheight
+ \fi
\vskip\footerdistance
- \dodopagebodybackground\v!footer\footerheight
+ \ifdim\footerheight>\zeropoint
+ \page_backgrounds_set_box_column\v!footer\footerheight
+ \fi
\vskip\bottomdistance
- \dodopagebodybackground\v!bottom\bottomheight
+ \ifdim\bottomheight>\zeropoint
+ \page_backgrounds_set_box_column\v!bottom\bottomheight
+ \fi
\vfilll}%
\smashbox#1}
-\def\dodopagebodybackground#1#2% maybe helper
- {\ifdim#2>\zeropoint % added, faster
- \setbox\scratchbox\vbox to #2
- \bgroup\hbox\bgroup
- % \swapmargins
- \goleftonpage
- \dododopagebodybackground\leftedgewidth #2#1\v!leftedge
- \hskip\leftedgedistance
- \dododopagebodybackground\leftmarginwidth #2#1\v!leftmargin
- \hskip\leftmargindistance
- \dododopagebodybackground\makeupwidth #2#1\v!text
- \hskip\rightmargindistance
- \dododopagebodybackground\rightmarginwidth#2#1\v!rightmargin
- \hskip\rightedgedistance
- \dododopagebodybackground\rightedgewidth #2#1\v!rightedge
- \egroup\egroup
- \wd\scratchbox\zeropoint
- \box\scratchbox\relax
- \fi}
-
-\def\dododopagebodybackground#1#2#3#4% width height pos pos % maybe helper
- {\ifsomebackgroundfound{#3#4}%
- \ifdim#2>\zeropoint\relax
- \ifdim#1>\zeropoint\relax
- \ifcsname\??ma#3#4\c!setups\endcsname % to be done
- \doprocesslocalsetups{\csname\??ma#3#4\c!setups\endcsname}% should not produce funny spaces !
+\def\page_backgrounds_set_box_column#1#2% maybe helper
+ {\setbox\scratchbox\vbox to #2
+ \bgroup\hbox\bgroup
+ \goleftonpage
+ \ifdim\leftedgewidth>\zeropoint
+ \ifcsname\??ma#1\v!leftedge\endcsname
+ \page_backgrounds_set_box_cell#1\v!leftedge\leftedgewidth#2%
+ \else
+ \hskip\leftedgewidth
\fi
- \fastlocalframed
- [\??ma#3#4]%
- [\c!component=#3-#4]%
- {\vbox to #2{\vss\hbox to#1{\hss\csname\??ma#3#4\c!command\endcsname\hss}\vss}}%
+ \fi
+ \hskip\leftedgedistance
+ \ifdim\leftmarginwidth>\zeropoint
+ \ifcsname\??ma#1\v!leftmargin\endcsname
+ \page_backgrounds_set_box_cell#1\v!leftmargin\leftmarginwidth#2%
+ \else
+ \hskip\leftmarginwidth
+ \fi
+ \fi
+ \hskip\leftmargindistance
+ \ifcsname\??ma#1\v!text\endcsname
+ \page_backgrounds_set_box_cell#1\v!text\makeupwidth#2%
\else
- \hskip#1%
+ \hskip\makeupwidth
\fi
- \else
- \hskip#1%
- \fi
- \else
- \hskip#1%
- \fi}
+ \hskip\rightmargindistance
+ \ifdim\rightmarginwidth>\zeropoint
+ \ifcsname\??ma#1\v!rightmargin\endcsname
+ \page_backgrounds_set_box_cell#1\v!rightmargin\rightmarginwidth#2%
+ \else
+ \hskip\rightmarginwidth
+ \fi
+ \fi
+ \hskip\rightedgedistance
+ \ifdim\rightedgewidth>\zeropoint
+ \ifcsname\??ma#1\v!rightedge\endcsname
+ \page_backgrounds_set_box_cell#1\v!rightedge\rightedgewidth#2%
+ \else
+ \hskip\rightedgewidth
+ \fi
+ \fi
+ \egroup\egroup
+ \wd\scratchbox\zeropoint
+ \box\scratchbox\relax}
+
+% \def\page_backgrounds_set_box_cell#1#2#3#4% width height pos pos % maybe helper
+% {\ifcsname\??ma#1#2\c!setups\endcsname % to be done
+% \doprocesslocalsetups{\csname\??ma#1#2\c!setups\endcsname}% should not produce funny spaces !
+% \fi
+% \fastlocalframed % can we avoid boxes here?
+% [\??ma#1#2]%
+% [\c!component=#1:#2]%
+% {\vbox to #4{\vss\hbox to#3{\hss\csname\??ma#1#2\c!command\endcsname\hss}\vss}}}
+
+\def\page_backgrounds_set_box_cell#1#2#3#4% pos pos width height
+ {\begingroup
+ \ifcsname\??ma#1#2\c!setups\endcsname
+ \doprocesslocalsetups{\csname\??ma#1#2\c!setups\endcsname}% should not produce funny spaces !
+ \fi
+ \setbox\scratchbox\hbox{\csname\??ma#1#2\c!command\endcsname}%
+ \localbackgroundframed\??ma{#1#2}\scratchbox#3#4%
+ \box\scratchbox
+ \endgroup}
%D The background mechanism is quite demanding in terms or
%D resources. We used to delay these definitions till runtime
@@ -352,30 +436,22 @@
%D Because the number of arguments runs from one to three,
%D we need to check for it.
+\newtoks\everybackgroundssetup
+
\unexpanded\def\setupbackgrounds
- {\dotripleempty\dosetupbackgrounds}
+ {\dotripleempty\page_backgrounds_setup}
-\def\dosetupbackgrounds[#1][#2][#3]%
+\def\page_backgrounds_setup[#1][#2][#3]%
{\ifthirdargument
- \global\somebackgroundtrue
- \def\docommand##1%
- {\doifinsetelse{##1}{\v!paper,\v!page,\v!leftpage,\v!rightpage}
- {\getparameters[\??ma##1][#3]\checkbackground{##1}}
- {\def\dodocommand####1{\getparameters[\??ma##1####1][#3]\checkbackground{##1####1}}%
- \processcommalist[#2]\dodocommand}}%
- \processcommalist[#1]\docommand
+ \page_backgrounds_setup_double{#1}{#2}{#3}%
\else\ifsecondargument
- \global\somebackgroundtrue
- \doifcommonelse{#1}{\v!text,\v!hidden,\v!paper,\v!page,\v!leftpage,\v!rightpage}
- {\def\docommand##1{\getparameters[\??ma##1][#2]\checkbackground{##1}}%
- \processcommalist[#1]\docommand}%
- {\setupbackgrounds
- [#1]%
- [\v!leftedge,\v!leftmargin,\v!text,\v!rightmargin,\v!rightedge]%
- [#2]}%
+ \page_backgrounds_setup_single{#1}{#2}%
\else\iffirstargument
- \getparameters[\??ma][#1]%
+ \page_backgrounds_setup_basics{#1}%
\fi\fi\fi
+ \the\everybackgroundssetup}
+
+\appendtoks
\doifelsevalue{\??ma\v!page\c!offset}\v!overlay
{\global\pageoffset\zeropoint}
{\global\pageoffset\csname\??ma\v!page\c!offset\endcsname}%
@@ -383,13 +459,42 @@
\global\pagebackgroundoffset\pageoffset
\global\pagebackgrounddepth\pagedepth
\doifelse\@@mastate\v!stop
- {\global\newbackgroundfalse}
- {\global\newbackgroundtrue }}
+ {\global\setfalse\c_page_backgrounds_new}
+ {\global\settrue \c_page_backgrounds_new}%
+\to \everybackgroundssetup
+
+\def\v_page_backgrounds_double_set{\v!paper,\v!page,\v!leftpage,\v!rightpage}
+\def\v_page_backgrounds_single_set{\v!text,\v!hidden,\v!paper,\v!page,\v!leftpage,\v!rightpage}
+\def\v_page_backgrounds_common_set{\v!leftedge,\v!leftmargin,\v!text,\v!rightmargin,\v!rightedge}
+
+\def\page_backgrounds_setup_double#1#2#3%
+ {\global\settrue\c_page_backgrounds_some
+ \def\docommand##1%
+ {\doifinsetelse{##1}\v_page_backgrounds_double_set
+ {\page_backgrounds_setup_and_check{##1}{#3}}
+ {\def\dodocommand####1{\page_backgrounds_setup_and_check{##1####1}{#3}}%
+ \processcommalist[#2]\dodocommand}}%
+ \processcommalist[#1]\docommand}
+
+\def\page_backgrounds_setup_single#1#2%
+ {\global\settrue\c_page_backgrounds_some
+ \doifcommonelse{#1}\v_page_backgrounds_single_set
+ {\def\docommand##1{\page_backgrounds_setup_and_check{##1}{#2}}%
+ \processcommalist[#1]\docommand}%
+ {\page_backgrounds_setup_double{#1}\v_page_backgrounds_common_set{#2}}}
+
+\def\page_backgrounds_setup_basics#1%
+ {\getparameters[\??ma][#1]}
+
+\def\page_backgrounds_setup_and_check#1#2% tag settings
+ {\edef\currentotrbackground{\??ma#1}%
+ \getparameters[\currentotrbackground][#2]%
+ \page_backgrounds_check_background}
%D Each areas (currently there are $1+3+25+1=30$ of them)
%D has its own low level framed object associated.
-\def\installsomebackground#1#2{\inheritlocalframed[\??ma#1#2][\??od]}
+\unexpanded\def\installsomebackground#1#2{\inheritlocalframed[\??ma#1#2][\??od]}
\installsomebackground \v!paper \empty
\installsomebackground \v!page \empty
@@ -446,19 +551,19 @@
% spread-2 .. spread+2 achter spread -> spread (repeat 2 times)
\def\enablehiddenbackground
- {\global\settrue\hiddenbackgroundenabled
- \global\somebackgroundtrue
+ {\global\settrue\c_page_backgrounds_hidden_enabled
+ \global\settrue\c_page_backgrounds_some
\recalculatebackgrounds}
\def\disablehiddenbackground
- {\global\setfalse\hiddenbackgroundenabled}
+ {\global\setfalse\c_page_backgrounds_hidden_enabled}
-\def\hiddenbackground
+\def\hiddenbackgroundlist
{\v!text-2,\v!text-1,\v!foreground,\v!text+1,\v!text+2}
\setupbackgrounds
[\v!hidden]
- [\c!background=\hiddenbackground]
+ [\c!background=\hiddenbackgroundlist]
% The next series is used in local (for instance floating)
% backgrounds.
@@ -468,9 +573,9 @@
\getparameters
[\??ma\v!local]
[\c!component=local,
- \c!background=\localbackground]
+ \c!background=\localbackgroundlist]
-\def\localbackground
+\def\localbackgroundlist
{\v!local-2,\v!local-1,\v!foreground,\v!local+1,\v!local+2}
\defineoverlay[\v!local-2][\positionoverlay{\v!local-2}]
@@ -478,17 +583,23 @@
\defineoverlay[\v!local+1][\positionoverlay{\v!local+1}]
\defineoverlay[\v!local+2][\positionoverlay{\v!local+2}]
-\def\addlocalbackgroundtobox
- {\ifconditional\hiddenbackgroundenabled
- \expandafter\doaddlocalbackground
+\def\page_backgrounds_add_local_to_box
+ {\ifconditional\c_page_backgrounds_hidden_enabled
+ \expandafter\page_backgrounds_add_local_to_box_indeed
\else
- \resetglobal \expandafter\gobbleoneargument
+ \expandafter\gobbleoneargument
\fi}
-\def\doaddlocalbackground#1%
- {\dodoglobal\setbox#1\hbox{\fastlocalframed[\??ma\v!local][]{\registerMPlocaltextarea{\box#1}}}%
- \resetglobal % redundant
- \doglobal\increment\localpositionnumber\relax} % afterwards !
+% \def\page_backgrounds_add_local_to_box_indeed#1%
+% {\setbox#1\hbox{\fastlocalframed[\??ma\v!local][]{\registerMPlocaltextarea{\box#1}}}%
+% \global\advance\localpositionnumber\plusone} % afterwards !
+
+\def\page_backgrounds_add_local_to_box_indeed#1% patch yet unchecked, \doglobal support is gone
+ {\scratchwidth \wd#1%
+ \scratchheight\ht#1%
+ \setbox#1\hbox{\registerMPlocaltextarea{\box#1}}%
+ \setbox#1\hbox{\localbackgroundframed\??ma\v!local#1\scratchwidth\scratchheight}%
+ \global\advance\localpositionnumber\plusone} % afterwards !
% Test how previous macro behaves with depth:
%
@@ -503,6 +614,6 @@
%D Because we haven't really set up backgrounds yet, we set
%D the main efficiency switch to false.
-\somebackgroundfalse
+\setfalse\c_page_backgrounds_some
\protect \endinput
diff --git a/tex/context/base/page-box.mkvi b/tex/context/base/page-box.mkvi
new file mode 100644
index 000000000..145f2192b
--- /dev/null
+++ b/tex/context/base/page-box.mkvi
@@ -0,0 +1,322 @@
+%D \module
+%D [ file=page-box,
+%D version=2011.12.05, % moved from other page-* files
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Page Boxing,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Boxing}
+
+\unprotect
+
+%D The often two step approach (_indeed) saves skippign tokens
+%D which is nicer for tracing.
+
+%D Centering the paper area on the print area is determined
+%D by the \type {top}, \type {bottom}, \type {left} and \type
+%D {right} parameters.
+
+\def\page_boxes_apply_center#box% we could test for a difference (saves packing)
+ {\printpaperwidth \v_page_target_scale\printpaperwidth \relax
+ \printpaperheight\v_page_target_scale\printpaperheight\relax
+ \ifdim\printpaperheight>\ht#box\relax
+ \page_boxes_apply_center_indeed#box%
+ \else\ifdim\printpaperwidth>\wd#box\relax
+ \page_boxes_apply_center_indeed#box%
+ \fi\fi}
+
+\def\page_boxes_apply_center_indeed_l_r#box%
+ {\v_page_target_left
+ \v_page_target_left_fill
+ \box#box%
+ \v_page_target_right_fill
+ \v_page_target_right}
+
+\def\page_boxes_apply_center_indeed_r_l#box%
+ {\v_page_target_right
+ \v_page_target_right_fill
+ \box#box%
+ \v_page_target_left_fill
+ \v_page_target_left}
+
+\def\page_boxes_apply_center_indeed#box% we could test for a difference (saves packing)
+ {\setbox#box\vbox to \printpaperheight
+ {\v_page_target_top
+ \v_page_target_top_fill
+ \hbox to \printpaperwidth
+ {\ifconditional\c_page_target_print_doublesided
+ \doifbothsides
+ {\page_boxes_apply_center_indeed_l_r#box}%
+ {\page_boxes_apply_center_indeed_l_r#box}%
+ {\page_boxes_apply_center_indeed_r_l#box}%
+ \else
+ \page_boxes_apply_center_indeed_l_r#box%
+ \fi}%
+ \par
+ \v_page_target_bottom_fill
+ \v_page_target_bottom}}
+
+\def\page_boxes_apply_offset % #box
+ {\ifdim\topoffset=\zeropoint
+ \ifdim\backoffset=\zeropoint
+ \doubleexpandafter\gobbleoneargument
+ \else
+ \doubleexpandafter\page_boxes_apply_offset_indeed
+ \fi
+ \else
+ \expandafter\page_boxes_apply_offset_indeed
+ \fi}
+
+\def\page_boxes_apply_offset_indeed#box%
+ {\scratchwidth \wd#box%
+ \scratchheight\ht#box%
+ \scratchdepth \dp#box%
+ \setbox#box\vbox
+ {\offinterlineskip
+ \vskip\topoffset
+ \hskip\doifbothsides\backoffset\backoffset{-\backoffset}%
+ \box#box}%
+ \wd#box\scratchwidth
+ \ht#box\scratchheight
+ \dp#box\scratchdepth}
+
+\def\page_boxes_apply_replicate
+ {\ifnum\layoutparameter\c!nx>\plusone
+ \expandafter\page_boxes_apply_replicate_indeed
+ \else\ifnum\layoutparameter\c!ny>\plusone
+ \doubleexpandafter\page_boxes_apply_replicate_indeed
+ \else
+ \doubleexpandafter\gobbleoneargument
+ \fi\fi}
+
+\def\page_boxes_apply_replicate_indeed#box%
+ {\setbox#box\vbox
+ {\offinterlineskip
+ \dorecurse{\layoutparameter\c!ny}
+ {\hbox{\dorecurse{\layoutparameter\c!nx}{\copy#box\hskip\layoutparameter\c!dx}\unskip}%
+ \vskip\layoutparameter\c!dy}
+ \unskip}}
+
+\def\page_boxes_apply_orientate_paper#box%
+ {\ifnum\number\c_page_target_paper_orientation\number\c_page_target_paper_reverse>\zerocount
+ \page_boxes_apply_orientate_indeed\c_page_target_paper_orientation\c_page_target_paper_reverse{#box}%
+ \fi}
+
+\def\page_boxes_apply_orientate_print#box%
+ {\ifnum\number\c_page_target_print_orientation\number\c_page_target_print_reverse>\zerocount
+ \page_boxes_apply_orientate_indeed\c_page_target_print_orientation\c_page_target_print_reverse{#box}%
+ \fi}
+
+\def\page_boxes_apply_orientate_indeed#odd#even#box%
+ {\setbox#box\vbox
+ {\edef\somerotation{\number\ifdoublesided\ifodd\realpageno#odd\else#even\fi\else##odd\fi}%
+ \dorotatebox\somerotation\hbox{\box#box}}}
+
+\def\page_boxes_apply_mirror#box%
+ {\setbox#box\vbox{\domirrorbox\vbox{\box#box}}}
+
+\def\page_boxes_apply_mirror_paper#box{\ifconditional\c_page_target_paper_mirror\page_boxes_apply_mirror{#box}\fi}
+\def\page_boxes_apply_mirror_print#box{\ifconditional\c_page_target_print_mirror\page_boxes_apply_mirror{#box}\fi}
+
+\let\page_boxes_apply_negate\negatecolorbox
+
+\def\page_boxes_apply_negate_print#box%
+ {\ifconditional\c_page_target_print_negate
+ \page_boxes_apply_negate#box%
+ \else\ifconditional\c_page_target_paper_negate
+ \page_boxes_apply_negate#box%
+ \fi\fi}
+
+\def\page_boxes_apply_scale#box%
+ {\edef\tmp_currentlayout_scale{\layoutparameter\c!scale}%
+ \ifdim\tmp_currentlayout_scale\points=\onepoint
+ \edef\tmp_currentlayout_sx{\layoutparameter\c!sx}%
+ \edef\tmp_currentlayout_sy{\layoutparameter\c!sy}%
+ \ifdim\tmp_currentlayout_sx\points=\onepoint
+ \ifdim\layoutparameter\c!sy\points=\onepoint
+ % no scaling done (and no copying either)
+ \else
+ \page_boxes_apply_scale_indeed\tmp_currentlayout_sx\tmp_currentlayout_sy{#box}%
+ \fi
+ \else
+ \page_boxes_apply_scale_indeed\tmp_currentlayout_sx\tmp_currentlayout_sy{#box}%
+ \fi
+ \else
+ \page_boxes_apply_scale_indeed\tmp_currentlayout_scale\tmp_currentlayout_scale{#box}%
+ \fi}
+
+\def\page_boxes_apply_scale_indeed#sx#sy#box%
+ {\setbox#box\vbox{\scale[\c!sx=#sx,\c!sy=#sy]{\box#box}}% can be a fast one
+ \paperwidth #sx\paperwidth
+ \paperheight#sy\paperheight}
+
+% \setuppagenumbering[alternative=doublesided]
+% \setupcolors[state=start]
+% \setuppapersize[A4][A4,oversized]
+% \setuplayout[location=middle,clipoffset=5mm]
+% \setupbackgrounds
+% [page]
+% [frame=on,rulethickness=1mm,
+% backgroundoffset=10mm,background=color,backgroundcolor=red]
+% \starttext \dorecurse{10}{\input tufte \par} \stoptext
+
+\newconditional\c_page_boxes_clip_print \settrue\c_page_boxes_clip_print
+
+\def\page_boxes_apply_clip_print_left % box
+ {\ifconditional\c_page_boxes_clip_print
+ \expandafter\page_boxes_apply_clip_print_indeed\expandafter\conditionalfalse
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\def\page_boxes_apply_clip_print_right % box
+ {\ifconditional\c_page_boxes_clip_print
+ \expandafter\page_boxes_apply_clip_print_indeed\expandafter\conditionaltrue
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\def\page_boxes_apply_clip_print_indeed#right#box% can be made more efficient, see other clipper
+ {\scratchoffset\pagebackgroundoffset % can be zero which is valid % maybe another variable
+ \scratchwidth \wd#box%
+ \scratchheight\ht#box%
+ \scratchdepth \dp#box%
+ \setbox#box\hbox
+ {\advance\scratchheight\dimexpr\scratchdepth+2\scratchoffset\relax
+ \advance\scratchwidth \scratchoffset
+ \ifconditional#right\relax
+ \scratchdimen-\scratchoffset
+ \hskip\scratchdimen
+ \else
+ \scratchdimen\zeropoint
+ \fi
+ \lower\scratchoffset\hbox
+ {\clip
+ [\c!hoffset=\scratchdimen,
+ \c!voffset=-\scratchoffset,
+ \c!width=\scratchwidth,
+ \c!height=\scratchheight]%
+ {\box#box}}}%
+ \wd#box\scratchwidth
+ \ht#box\scratchheight
+ \dp#box\scratchdepth}
+
+\def\page_boxes_apply_clip_paper
+ {\scratchoffset\layoutparameter\c!clipoffset\relax
+ \ifdim\scratchoffset>\zeropoint
+ \expandafter\page_boxes_apply_clip_paper_indeed
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\def\page_boxes_apply_clip_paper_indeed#box%
+ {\scratchwidth \wd#box%
+ \scratchheight\ht#box%
+ \scratchdepth \dp#box%
+ \setbox#box\hbox
+ {\advance\scratchheight\dimexpr\scratchdepth+2\scratchoffset\relax
+ \advance\scratchwidth \scratchoffset
+ \doifbothsides
+ {\advance\scratchwidth\scratchoffset
+ \scratchdimen-\scratchoffset
+ \hskip\scratchdimen}%
+ {\scratchdimen\zeropoint}
+ {\scratchdimen-\scratchoffset
+ \hskip\scratchdimen}%
+ \lower\scratchoffset\hbox
+ {\clip
+ [\c!hoffset=\scratchdimen,
+ \c!voffset=-\scratchoffset,
+ \c!width=\scratchwidth,
+ \c!height=\scratchheight]%
+ {\box#box}}}%
+ \wd#box\scratchwidth
+ \ht#box\scratchheight
+ \dp#box\scratchdepth}
+
+% nearly always some displacement so no speedup test needed
+
+\def\page_boxes_apply_offsets#1%
+ {\setbox#1\vbox to \paperheight
+ {\hsize\paperwidth
+ \vskip\topspace
+ \doifbothsides
+ {\hskip\backspace}
+ {\hskip\backspace}
+ {\hskip\dimexpr\paperwidth-\backspace-\makeupwidth\relax}%
+ \box#1}%
+ \dp#1\zeropoint}
+
+% \let\page_boxes_apply_clip_paper \gobbleoneargument
+% \let\page_boxes_apply_clip_print_left \gobbleoneargument
+% \let\page_boxes_apply_clip_print_right\gobbleoneargument
+
+%D This is rather specialized:
+
+\newconditional\c_page_areas_enabled
+\newbox \b_page_areas_registered
+
+\def\enabletextarearegistration
+ {\global\settrue\c_page_areas_enabled}
+
+\def\page_areas_registered_box
+ {\ifconditional\c_page_areas_enabled
+ \expandafter\page_areas_registered_box_indeed
+ \else
+ \expandafter\page_areas_registered_box_forget
+ \fi}
+
+\def\page_areas_registered_box_forget#1#2#3% #1=lower-dp #2=correct-ht #3=box
+ {\box#3}
+
+\def\page_areas_registered_box_indeed#1#2#3% #1=lower-dp #2=correct-ht #3=box
+ {\hbox\bgroup
+ \ifx\registerMPtextarea\undefined \else
+ \setbox\b_page_areas_registered\emptyhbox
+ \wd\b_page_areas_registered\wd#3%
+ \ht\b_page_areas_registered\ht#3%
+ \dp\b_page_areas_registered\dp#3%
+ \ifcase#1\or % 1
+ \setbox\b_page_areas_registered\hbox{\lower\strutdp\box\b_page_areas_registered}%
+ \fi
+ \ifcase#2\or % 1
+ \setbox\b_page_areas_registered\hbox{\raise\topskip\hbox{\lower\strutht\box\b_page_areas_registered}}%
+ \dp\b_page_areas_registered\strutdp
+ \fi
+ \dp\b_page_areas_registered\strutdp % needed
+ \setbox\b_page_areas_registered\hbox
+ {\registerMPtextarea{\box\b_page_areas_registered}}%
+ \smashbox\b_page_areas_registered
+ \box\b_page_areas_registered
+ \fi
+ \box#3%
+ \egroup}
+
+\def\page_areas_register_direct#1%
+ {\xypos{pbd:\realfolio:b}% we could save bytes by only saving the y
+ \endgraf
+ \begingroup
+ \scratchdimen\dimexpr\MPy{pbd:\realfolio:b}-\MPy{pbd:\realfolio:e}\relax
+ \setbox\scratchbox\emptyhbox
+ \wd\scratchbox\makeupwidth
+ \ht\scratchbox\scratchdimen
+ \vsmash{\page_areas_registered_box00\scratchbox}%
+ \endgroup
+ #1%
+ \endgraf
+ \xypos{pbd:\realfolio:e}}
+
+\def\page_areas_register_boxed#1%
+ {\begingroup
+ \setbox\scratchbox\vbox{#1}%
+ \wd\scratchbox\makeupwidth % somehow a space creeps in
+ \vbox{\page_areas_registered_box00\scratchbox}%
+ \endgroup}
+
+\protect \endinput
diff --git a/tex/context/base/page-brk.mkiv b/tex/context/base/page-brk.mkiv
new file mode 100644
index 000000000..0ee720662
--- /dev/null
+++ b/tex/context/base/page-brk.mkiv
@@ -0,0 +1,393 @@
+%D \module
+%D [ file=page-brk, % moved from page-ini
+%D version=2011.12.07, % 2000.10.20,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Breaks,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Breaks}
+
+\unprotect
+
+\ifdefined\resetcurrentstructuremarkswithpage \else \let\resetcurrentstructuremarkswithpage\relax \fi
+\ifdefined\noheaderandfooterlines \else \let\noheaderandfooterlines \relax \fi
+
+%D Page breaks.
+
+% \definepagebreak
+% [chapter]
+% [yes,header,right]
+%
+% \setuphead
+% [chapter]
+% [page=chapter,
+% header=empty,
+% footer=chapter]
+%
+% \definepagebreak % untested
+% [lastpage]
+% [left,{empty,right},{empty,left}]
+
+% public page handler, beware: definepage already in use (core-ref)
+%
+% \definepagebreak[instance][forsure]
+% \definepagebreak[forsure][yes,+4]
+
+\newconditional\c_page_breaks_enabled \settrue\c_page_breaks_enabled
+\newcount \c_page_breaks_prevpage
+
+\newtoks\everybeforepagebreak
+\newtoks\everyafterpagebreak
+
+\let\page_breaks_current_option \empty
+\let\page_breaks_current_options\empty
+
+\def\page_breaks_handle#1%
+ {\edef\page_breaks_current_options{#1}% handy for tracing
+ \processcommacommand[\page_breaks_current_options]\page_breaks_handle_indeed}
+
+\def\page_breaks_handle_indeed#1%
+ {\edef\page_breaks_current_option{#1}% can be used in handler
+ \ifcsname\??pe:\page_breaks_current_option\endcsname
+ \csname\??pe:\page_breaks_current_option\endcsname
+ \else\ifcsname\??pe::\page_breaks_current_option\endcsname
+ \expandafter\page_breaks_handle\csname\??pe::\page_breaks_current_option\endcsname
+ \else
+ \csname\??pe:\s!unknown\endcsname
+ \fi\fi}
+
+\def\page_breaks_handle_direct#1%
+ {\csname\??pe:#1\endcsname}
+
+\def\installpagebreakhandler#1#2% low level definer
+ {\setvalue{\??pe:#1}{#2}}
+
+\unexpanded\def\definepagebreak
+ {\dodoubleargument\page_breaks_define}
+
+\def\page_breaks_define[#1][#2]%
+ {\setvalue{\??pe::#1}{#2}}
+
+\unexpanded\def\pagebreak
+ {\dosingleempty\page_breaks_process}
+
+\let\page\pagebreak
+
+\appendtoks
+ \flushnotes
+\to \everybeforepagebreak
+
+\def\page_breaks_process[#1]% so, page ornaments are reset after a pagebreak command, unless set
+ {\par % always before group so that we clear hangs etc (as in side floats)
+ \ifvmode % extra check
+ \begingroup
+ \the\everybeforepagebreak
+ \c_page_breaks_prevpage\realpageno
+ \ifcase\pageornamentstate \or
+ % disable reset after shipout
+ \global\pageornamentstate\plustwo
+ \fi
+ \iffirstargument % or if empty i.e. []
+ \page_breaks_handle{#1}%
+ \else % so, no pagebreak when \pagebreak[] ! ! !
+ \page_breaks_handle_direct\v!yes
+ \fi
+ \relax
+ \ifnum\c_page_breaks_prevpage<\realpageno
+ \global\pageornamentstate\zerocount
+ \fi
+ \the\everyafterpagebreak
+ \endgroup
+ \fi}
+
+\def\resetpagebreak % used elsewhere too
+ {\global\settrue\c_page_breaks_enabled}
+
+\def\simplifypagebreak % to be used grouped !
+ {\def\page_breaks_process[##1]{\goodbreak}}
+
+\def\disablepagebreaks % to be used grouped !
+ {\def\page_breaks_process[##1]{}}
+
+\installpagebreakhandler \s!dummy
+ {\page_otr_flush_all_floats
+ \gotonextpage
+ \page_otr_insert_dummy_page}
+
+\installpagebreakhandler \v!frame
+ {\page
+ \begingroup
+ \showframe
+ \page[\v!empty]
+ \endgroup}
+
+\installpagebreakhandler \s!unknown
+ {\doifinstringelse{+}\page_breaks_current_option
+ {\page_otr_flush_all_floats
+ \gotonextpage
+ \dorecurse\page_breaks_current_option\page_otr_insert_dummy_page}
+ {\doifnumberelse\page_breaks_current_option
+ {\page_otr_flush_all_floats
+ \gotonextpage
+ \doloop
+ {\ifnum\userpageno<\page_breaks_current_option\relax
+ \page_otr_insert_dummy_page
+ \else
+ \exitloop
+ \fi}}
+ {}}}
+
+\installpagebreakhandler \s!default
+ {} % do nothing if empty
+
+\installpagebreakhandler \v!reset
+ {% better not: \global\pageornamentstate\zerocount
+ \resetpagebreak}
+
+\installpagebreakhandler \v!disable
+ {\global\setfalse\c_page_breaks_enabled}
+
+\installpagebreakhandler \v!yes
+ {\ifconditional\c_page_breaks_enabled
+ \page_otr_flush_all_floats
+ \gotonextpage
+ \ifinsidecolumns % this will move to MUL
+ \page_otr_eject_page % otherwise sometimes no change
+ \fi
+ \fi}
+
+\installpagebreakhandler \v!makeup
+ {\ifconditional\c_page_breaks_enabled
+ \page_otr_fill_and_eject_page
+ \fi}
+
+\installpagebreakhandler \v!blank
+ {\ifcase\pageornamentstate
+ \global\pageornamentstate\plusone
+ \fi}
+
+\installpagebreakhandler \v!no
+ {\ifconditional\c_page_breaks_enabled
+ \dosomebreak\nobreak
+ \fi}
+
+\installpagebreakhandler \v!preference
+ {\ifconditional\c_page_breaks_enabled
+ \ifinsidecolumns % this will move to MUL
+ \dosomebreak\goodbreak
+ \else
+ \testpage[3][\zeropoint]%
+ \fi
+ \fi}
+
+\installpagebreakhandler \v!bigpreference
+ {\ifconditional\c_page_breaks_enabled
+ \ifinsidecolumns % this will move to MUL
+ \dosomebreak\goodbreak
+ \else
+ \testpage[5][\zeropoint]%
+ \fi
+ \fi}
+
+% \installpagebreakhandler \v!empty {} % defined in page-txt.mkiv
+% \installpagebreakhandler \v!header{} % defined in page-txt.mkiv
+% \installpagebreakhandler \v!footer{} % defined in page-txt.mkiv
+% \installpagebreakhandler \v!left {} % defined in page-txt.mkiv
+
+\installpagebreakhandler \v!right
+ {\page_otr_flush_all_floats
+ \gotonextpageX % will become \gotonextpage
+ \doifbothsidesoverruled{}{}{\resetcurrentstructuremarkswithpage\page_otr_insert_dummy_page}}
+
+\installpagebreakhandler \v!even
+ {\page
+ \doifoddpageelse{\resetcurrentstructuremarkswithpage\page_otr_insert_dummy_page}\donothing}
+
+\installpagebreakhandler \v!odd
+ {\page
+ \doifoddpageelse\donothing{\resetcurrentstructuremarkswithpage\page_otr_insert_dummy_page}}
+
+\installpagebreakhandler \v!quadruple % not yet ok inside columnsets
+ {\ifdoublesided
+ \ifnum\numexpr\realpageno/4\relax=\numexpr\realpageno/2\relax\else
+ \page_breaks_handle_direct\v!yes
+ \page_breaks_handle_direct\v!empty
+ \page_breaks_handle_direct\v!empty
+ \fi
+ \fi}
+
+\installpagebreakhandler \v!last
+ {\page_otr_flush_all_floats
+ \gotonextpageX % will become \gotonextpage
+ \relax
+ \doifbothsidesoverruled
+ {\page_facings_flush}% hm
+ {}
+ {\noheaderandfooterlines
+ \page_otr_insert_dummy_page}%
+ \filluparrangedpages}
+
+\installpagebreakhandler \v!lastpage % handy for backpage preceded by empty pages
+ {\page_breaks_handle_direct\v!yes
+ \ifdoublesided
+ \page_breaks_handle_direct\v!left
+ \page_breaks_handle_direct\v!empty
+ \page_breaks_handle_direct\v!empty
+ \fi}
+
+\installpagebreakhandler \v!start {\global\settrue \c_otr_shipout_enabled}
+\installpagebreakhandler \v!stop {\global\setfalse\c_otr_shipout_enabled}
+
+% Column breaks.
+
+\newtoks\everybeforecolumnbreak
+\newtoks\everyaftercolumnbreak
+
+\let\page_breaks_columns_current_option \empty
+\let\page_breaks_columns_current_options\empty
+
+\def\page_breaks_columns_handle#1%
+ {\edef\page_breaks_columns_current_options{#1}%
+ \processcommacommand[#1]\page_breaks_columns_handle_indeed}
+
+\def\page_breaks_columns_handle_indeed#1%
+ {\edef\page_breaks_columns_current_option{#1}%
+ \ifcsname\??cn:\OTRidentifier:\page_breaks_columns_current_option\endcsname
+ \csname\??cn:\OTRidentifier:\page_breaks_columns_current_option\endcsname
+ \else\ifcsname\??cn::\page_breaks_columns_current_option\endcsname
+ \expandafter\csname\page_breaks_columns_handle\??cn::\page_breaks_columns_current_option\endcsname
+ \else
+ \csname\??cn:\OTRidentifier:\s!unknown\endcsname
+ \fi\fi}
+
+\def\page_breaks_columns_handle_direct#1%
+ {\csname\??cn:\OTRidentifier:#1\endcsname}
+
+\def\installcolumnbreakhandler#1#2#3% #1=otr-id #2=tag #3=action
+ {\setvalue{\??cn:#1:#2}{#3}}
+
+\unexpanded\def\definecolumnbreak
+ {\dodoubleargument\page_break_columns_define}
+
+\def\page_break_columns_define[#1][#2]%
+ {\setvalue{\??cn::#1}{#2}}
+
+\unexpanded\def\columnbreak
+ {\dosingleempty\page_breaks_columns_process}
+
+\let\column\columnbreak
+
+\def\page_breaks_columns_process[#1]% so, page ornaments are reset after a pagebreak command, unless set
+ {\begingroup
+ \the\everybeforecolumnbreak
+ \iffirstargument
+ \page_breaks_columns_handle{#1}%
+ \else
+ \page_breaks_columns_handle_direct\v!yes
+ \fi
+ \relax
+ \the\everyaftercolumnbreak
+ \endgroup}
+
+%D Test page breaks.
+
+\newdimen \d_page_tests_test
+\newconstant\c_page_tests_mode
+
+\newconstant\testpagemethod % todo: \testnewpage[method=,lines=,voffset=]
+\newconstant\testpagetrigger
+
+\unexpanded\def\testpage {\c_page_tests_mode\plusone \dodoubleempty\page_tests_test} %
+\unexpanded\def\testpageonly{\c_page_tests_mode\plustwo \dodoubleempty\page_tests_test} % no penalties added to the mvl
+\unexpanded\def\testpagesync{\c_page_tests_mode\plusthree\dodoubleempty\page_tests_test} % force sync
+
+\def\page_tests_test[#1][#2]% don't change, only add more methods
+ {\relax % needed before \if
+ \ifconditional\c_page_breaks_enabled
+ % new from here
+ \ifcase\testpagetrigger
+ \endgraf
+ \or\ifvmode
+ \dosomebreak\allowbreak
+ \else % indeed?
+ \vadjust{\allowbreak}%
+ \endgraf
+ \fi\fi
+ % till here
+ \ifdim\pagegoal<\maxdimen \relax
+ \ifdim\pagetotal<\pagegoal \relax
+ \d_page_tests_test\dimexpr
+ #1\lineheight
+ +\pagetotal
+ \ifdim\lastskip<\parskip+\parskip\fi
+ \ifthirdargument+#2\fi
+ \relax
+ \ifcase\testpagemethod
+ \ifdim\d_page_tests_test>.99\pagegoal
+ \penalty-\!!tenthousand\relax
+ \fi
+ \or
+ \ifdim\dimexpr\d_page_tests_test-\pagegoal\relax>-\lineheight
+ \penalty-\!!tenthousand\relax
+ \fi
+ \or
+ \getnoflines\pagegoal
+ \ifdim\dimexpr\d_page_tests_test-\noflines\lineheight\relax>-\lineheight
+ \penalty-\!!tenthousand\relax
+ \fi
+ \or % same as 0 but more accurate
+ \ifdim\dimexpr\d_page_tests_test-10\scaledpoint\relax>\pagegoal
+ \penalty-\!!tenthousand\relax
+ \fi
+ \fi
+ \else\ifnum\c_page_tests_mode=\plusthree
+ \page_tests_flush_so_far
+ \fi\fi
+ \else\ifnum\c_page_tests_mode=\plusone
+ \goodbreak
+ \fi\fi
+ \else
+ \endgraf
+ \fi}
+
+\def\page_tests_flush_so_far
+ {\endgraf
+ \ifdim\pagetotal>\pagegoal
+ \ifdim\dimexpr\pagetotal-\pageshrink\relax>\pagegoal
+ \goodbreak
+ \else
+ \page
+ \fi
+ \fi}
+
+%D Test column breaks.
+
+\def\testcolumn
+ {\dodoubleempty\page_tests_columns_test}
+
+\def\page_tests_columns_test[#1][#2]%
+ {\endgraf
+ \ifdim\pagegoal<\maxdimen
+ \ifdim\pagetotal<\pagegoal
+ \d_page_tests_test\dimexpr
+ \pagegoal
+ -\pagetotal
+ \ifdim\lastskip<\parskip+\parskip\fi
+ \ifsecondargument+#2\fi
+ \relax
+ \getrawnoflines\d_page_tests_test % (raw)
+ \ifnum#1>\noflines
+ \column
+ \fi
+ \else
+ \penalty-\plustenthousand % (untested)
+ \fi
+ \fi}
+
+\protect \endinput
diff --git a/tex/context/base/page-col.mkiv b/tex/context/base/page-col.mkiv
new file mode 100644
index 000000000..50a05d351
--- /dev/null
+++ b/tex/context/base/page-col.mkiv
@@ -0,0 +1,156 @@
+%D \module
+%D [ file=page-col, % moved from page-ini
+%D version=2011.12.07, % 2000.10.20,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Column Helpers,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Column Helpers}
+
+%D Here we implement a coouple of helpers for dealing with
+%D columns. For the moment we keep the names.
+
+\unprotect
+
+%D The next two registers can be used to store pre column
+%D material as well as footnotes or so.
+
+\newbox\precolumnbox \newdimen\precolumnboxheight
+\newbox\postcolumnbox \newdimen\postcolumnboxheight
+
+%D We reserve a counter for the number of columns as well as
+%D the current column. Both are not to be changed by users!
+
+\newcount\nofcolumns \nofcolumns = 1
+\newcount\mofcolumns \mofcolumns = 1
+
+\setnewconstant\maxnofcolumns 50
+\setnewconstant\allocatednofcolumns 0
+
+%D The next dimensions reports the final column height
+
+\newdimen\finalcolumnheights
+\newcount\finalcolumnlines
+
+%D This register can be used as a temporary storage for page
+%D content.
+
+\newbox\restofpage
+
+%D A few more (some might go away):
+
+\newif\ifintermediatefootnotes
+\newif\ifcarryoverfootnotes %\carryoverfootnotestrue
+\newif\iflastcolumnfootnotes %\lastcolumnfootnotestrue
+\newif\ifbalancecolumns %\balancecolumnstrue
+\newif\ifbalancetoheight %\balancetoheighttrue
+\newif\ifforcecolumngrid \forcecolumngridtrue
+\newif\ifstretchcolumns \stretchcolumnsfalse
+\newif\ifinheritcolumns \inheritcolumnsfalse
+\newif\ifheightencolumns \heightencolumnsfalse
+
+\newif\ifbalancingcolumns
+\newif\ifcollectingcontent
+\newif\ifcolumnoverflow
+
+\newdimen\intercolumnwidth
+\newdimen\localcolumnwidth
+\newdimen\savedpagetotal
+
+\newconstant\columndirection % 0:lr 1:rl
+
+\def\minbalancetoplines {1}
+\def\minfreecolumnlines {2}
+
+\newif\ifrecentercolumnbox \recentercolumnboxtrue
+\newif\ifrerecentercolumnbox \rerecentercolumnboxtrue
+\newif\ifpackcolumnfloats \packcolumnfloatstrue
+
+%D During initialization the temporary boxes are allocated.
+%D This enables us to use as much columns as we want, without
+%D exhausting the pool of boxes too fast. We could have packed
+%D them in one box, but we've got enough boxes.
+%D
+%D Two sets of boxes are declared, the txtboxes are used for
+%D the text, the topboxes are for moved column floats.
+
+\def\initializecolumns#1%
+ {\ifnum#1>\maxnofcolumns
+ \showmessage\m!columns1\maxnofcolumns
+ \nofcolumns\maxnofcolumns
+ \else
+ \nofcolumns#1\relax
+ \fi
+ \ifnum\nofcolumns>\allocatednofcolumns
+ \dorecurse\nofcolumns
+ {\ifnum\recurselevel>\allocatednofcolumns\relax
+ % \newbox\next \letgvalue{\??zc-\recurselevel-t}=\next
+ \expandafter\newbox\csname\??zc-\recurselevel-t\endcsname % text
+ \expandafter\newbox\csname\??zc-\recurselevel-f\endcsname % foot
+ \expandafter\newbox\csname\??zc-\recurselevel-h\endcsname % top insert
+ \expandafter\newbox\csname\??zc-\recurselevel-l\endcsname % top insert
+ \fi}%
+ \global\allocatednofcolumns\nofcolumns
+ \fi}
+
+\def\firstcolumnbox {\columntextbox\plusone}
+\def\currentcolumnbox {\columntextbox\mofcolumns}
+\def\lastcolumnbox {\columntextbox\nofcolumns}
+
+\def\firsttopcolumnbox {\columntopbox \plusone}
+\def\currenttopcolumnbox {\columntopbox \mofcolumns}
+\def\lasttopcolumnbox {\columntopbox \nofcolumns}
+
+\def\columntextbox #1{\csname\??zc-\number#1-t\endcsname}
+\def\columnfootbox #1{\csname\??zc-\number#1-f\endcsname}
+\def\columntopbox #1{\csname\??zc-\number#1-h\endcsname}
+\def\columnbotbox #1{\csname\??zc-\number#1-l\endcsname}
+
+\def\columnsettextbox {\global\setbox\columntextbox}
+\def\columnsetfootbox {\global\setbox\columnfootbox}
+\def\columnsettopbox {\global\setbox\columntopbox}
+\def\columnsetbotbox {\global\setbox\columnbotbox}
+
+\def\columngettextbox {\copy\columntextbox}
+\def\columngetfootbox {\copy\columnfootbox}
+\def\columngettopbox {\copy\columntopbox}
+\def\columngetbotbox {\copy\columnbotbox}
+
+\def\columnerasetextboxes{\dorecurse\allocatednofcolumns{\columnsettextbox\recurselevel\emptybox}}
+\def\columnerasefootboxes{\dorecurse\allocatednofcolumns{\columnsetfootbox\recurselevel\emptybox}}
+\def\columnerasetopboxes {\dorecurse\allocatednofcolumns{\columnsettopbox \recurselevel\emptybox}}
+\def\columnerasebotboxes {\dorecurse\allocatednofcolumns{\columnsetbotbox \recurselevel\emptybox}}
+
+%D Without going in details we present two macro's which handle
+%D the columns. The action which is transfered by the the first
+%D and only parameter can do something with \type
+%D {\currentcolumnbox}. In case of the mid columns, \type
+%D {\firstcolumnbox} and \type {\lastcolumnbox} are handled
+%D outside these macro's.
+
+\def\dohandlecolumn#1%
+ {\mofcolumns\recurselevel
+ \let\currentcolumn\recurselevel
+ #1\relax}
+
+\def\dohandleallcolumns#1%
+ {\dorecurse\nofcolumns{\dohandlecolumn{#1}}}
+
+\def\dohandlerevcolumns#1%
+ {\dostepwiserecurse\nofcolumns\plusone\minusone{\dohandlecolumn{#1}}}
+
+\def\dohandlemidcolumns#1%
+ {\dohandleallcolumns
+ {\ifnum\recurselevel>\plusone
+ \ifnum\recurselevel<\nofcolumns
+ \dohandlecolumn{#1}%
+ \fi
+ \fi}}
+
+\protect \endinput
diff --git a/tex/context/base/page-fac.mkiv b/tex/context/base/page-fac.mkiv
new file mode 100644
index 000000000..fef1cd5ac
--- /dev/null
+++ b/tex/context/base/page-fac.mkiv
@@ -0,0 +1,77 @@
+%D \module
+%D [ file=page-fac, % moved from page-ini
+%D version=2011.12.07, % 2000.10.20,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Facing Pages,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Facing Pages}
+
+\unprotect
+
+%D \macros
+%D {setupoppositeplacing,startopposite}
+%D
+%D \starttyping
+%D \starttext
+%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test
+%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test
+%D \stoptext
+%D \stoptyping
+
+\newbox\b_page_facings_content
+
+\unexpanded\def\setupoppositeplacing
+ {\dodoubleargument\getparameters[\??np]}
+
+\unexpanded\def\startopposite
+ {\dowithnextboxcontent
+ {\hsize\makeupwidth}%
+ {\global\setbox\b_page_facings_content\vbox
+ {\ifvoid\b_page_facings_content
+ \@@npbefore
+ \else
+ \@@npinbetween
+ \unvbox\b_page_facings_content
+ \fi
+ \box\nextbox}}%
+ \vbox\bgroup}
+
+\unexpanded\def\stopopposite
+ {\egroup}
+
+\def\page_facings_finish
+ {\ifvoid\b_page_facings_content\else
+ \global\setbox\b_page_facings_content\vbox to \makeupheight
+ {\unvbox\b_page_facings_content
+ \@@npafter
+ \vss}%
+ \fi}
+
+\def\page_facings_flush
+ {\doif\@@npstate\v!start
+ {\ifvoid\b_page_facings_content\else
+ \ifnum\realpageno>\plusone
+ \begingroup
+ \pageornamentstate\plusone % tricky
+ \page_facings_finish
+ \page_boxes_shipout{\page_boxes_constructed_page\box\b_page_facings_content}%
+ \endgroup
+ \else
+ \global\setbox\b_page_facings_content\emptybox
+ \fi
+ \fi}}
+
+\setupoppositeplacing
+ [\c!state=\v!start,
+ \c!before=,
+ \c!inbetween=\blank,
+ \c!after=]
+
+\protect \endinput
diff --git a/tex/context/base/page-flt.mkiv b/tex/context/base/page-flt.mkiv
index 0a44ce992..29de9acd4 100644
--- a/tex/context/base/page-flt.mkiv
+++ b/tex/context/base/page-flt.mkiv
@@ -209,33 +209,14 @@
{\doifnotinset\v!high\floatspecification\vfill
\box\floatbox
\doifnotinset\v!low\floatspecification\vfill}%
- \vfill\eject}
-
-% \def\doflushpagefloats
-% {\doifoddpageelse
-% {\ifnum\nofstackedfloatsincategory\s!rightpage>\zerocount
-% \doflushsomepagefloat\s!rightpage
-% \else\ifnum\nofstackedfloatsincategory\s!page>\zerocount
-% \doflushsomepagefloat\s!page
-% \else\ifnum\nofstackedfloatsincategory\s!leftpage>\zerocount
-% \emptyhbox\vfill\eject
-% %\doflushsomepagefloat\s!leftpage
-% \fi\fi\fi}
-% {\ifnum\nofstackedfloatsincategory\s!leftpage>\zerocount
-% \doflushsomepagefloat\s!leftpage
-% \else\ifnum\nofstackedfloatsincategory\s!page>\zerocount
-% \doflushsomepagefloat\s!page
-% \else\ifnum\nofstackedfloatsincategory\s!rightpage>\zerocount
-% \emptyhbox\vfill\eject
-% %\doflushsomepagefloat\s!rightpage
-% \fi\fi\fi}}
+ \page_otr_fill_and_eject_page}
\def\doflushpagefloats
{\edef\checkedpagefloat{\ctxcommand{checkedpagefloat()}}% (true) for packed
\ifx\checkedpagefloat\empty
% nothing
\else\ifx\checkedpagefloat\v!empty
- \emptyhbox\vfill\eject
+ \emptyhbox \page_otr_fill_and_eject_page % why not dummy_page
\else
\doflushsomepagefloat\checkedpagefloat
\fi\fi}
diff --git a/tex/context/base/page-flw.mkiv b/tex/context/base/page-flw.mkiv
index b896a9598..9afacf584 100644
--- a/tex/context/base/page-flw.mkiv
+++ b/tex/context/base/page-flw.mkiv
@@ -53,8 +53,7 @@
\bgroup
\unvbox\textflowcollector{#1}%
\hsize\textflowparameter{#1}\c!width
- \doifsomething{\textflowparameter{#1}\c!style}%
- {\doconvertfont{\textflowparameter{#1}\c!style}}%
+ \dousestyleparameter{\textflowparameter{#1}\c!style}%
\unexpanded\def\stoptextflow{\endgraf\egroup}}
{\let\stoptextflow\relax}}
diff --git a/tex/context/base/page-grd.mkiv b/tex/context/base/page-grd.mkiv
new file mode 100644
index 000000000..e882978ca
--- /dev/null
+++ b/tex/context/base/page-grd.mkiv
@@ -0,0 +1,85 @@
+%D \module
+%D [ file=page-grd, % moved from page-ini
+%D version=2011.12.07, % 2000.10.20,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Grids,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Grids}
+
+\unprotect
+
+\definepalet
+ [layout]
+ [grid=red,
+ page=green]
+
+\newconstant\c_page_grids_location
+\newconstant\c_page_grids_line_mode
+\newconstant\c_page_grids_lineno_mode
+
+\unexpanded\def\showgrid
+ {\dosingleempty\page_grids_show}
+
+\def\page_grids_show[#1]%
+ {\c_page_grids_location \plusone % downward compatible default
+ \c_page_grids_line_mode \plusone
+ \c_page_grids_lineno_mode\plusone
+ \processallactionsinset
+ [#1]%
+ [ \v!reset=>\c_page_grids_location \zerocount,
+ \v!bottom=>\c_page_grids_location \plusone,
+ \v!top=>\c_page_grids_location \plustwo,
+ \v!none=>\c_page_grids_line_mode \zerocount,
+ \v!all=>\c_page_grids_line_mode \plusone,
+ \v!lines=>\c_page_grids_line_mode \plustwo,
+ \v!frame=>\c_page_grids_line_mode \plusthree,
+ \v!nonumber=>\c_page_grids_lineno_mode\zerocount,
+ \v!right=>\c_page_grids_lineno_mode\plusone,
+ \v!left=>\c_page_grids_lineno_mode\plustwo,
+ \v!outer=>\c_page_grids_lineno_mode\plusthree]%
+ \ifcase\c_page_grids_location
+ \let\page_grids_add_to_box\gobbleoneargument
+ \else % 1=bottom 2=top
+ \let\page_grids_add_to_box\page_grids_add_to_box_indeed
+ \fi}
+
+% if really needed for speed we can cache the grid
+
+\let\page_grids_add_to_box\gobbleoneargument
+
+\def\page_grids_add_to_box_indeed#1% to be checked for color and layer ..... use mp
+ {\startcolor[layout:grid]%
+ \gridboxlinemode \c_page_grids_line_mode
+ \gridboxlinenomode\c_page_grids_lineno_mode
+ \setgridbox\scratchbox\makeupwidth\textheight % todo: check color
+ \global\setbox#1\hbox % global ?
+ {\ifcase\c_page_grids_location\or\or\box#1\hskip-\makeupwidth\fi
+ \begingroup % color
+ \ifcase\layoutcolumns\else
+ \gray
+ \setlayoutcomponentattribute{\v!grid:\v!columns}%
+ \hbox \layoutcomponentboxattribute to \makeupwidth
+ {\dorecurse\layoutcolumns
+ {\hskip\layoutcolumnwidth
+ \ifnum\recurselevel<\layoutcolumns
+ \vrule
+ \!!height\ht\scratchbox
+ \!!depth\dp\scratchbox
+ \!!width\layoutcolumndistance
+ \fi}}%
+ \hskip-\makeupwidth
+ \fi
+ \setlayoutcomponentattribute{\v!grid:\v!lines}%
+ \hbox \layoutcomponentboxattribute{\box\scratchbox}%
+ \endgroup
+ \ifcase\c_page_grids_location\or\hskip-\makeupwidth\box#1\fi}%
+ \stopcolor}
+
+\protect \endinput
diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv
index b320eae03..fcfe43e34 100644
--- a/tex/context/base/page-imp.mkiv
+++ b/tex/context/base/page-imp.mkiv
@@ -17,89 +17,6 @@
\unprotect
-% todo: impose a la mkiv (us elua specification tables)
-
-% sizing bug:
-%
-% \setuppapersize[A4][A4,landscape] \setuparranging[2UP] \showframe
-%
-% \starttext \dorecurse{10}{\input tufte \par} \stoptext
-
-\newif\ifclipprintbox \clipprintboxtrue % todo: conditional
-%newif\ifclippagebox \clippageboxtrue
-
-\def\clippedprintbox#1#2% can be made more efficient, see other clipper
- {\ifclipprintbox
- \!!widthc \pagebackgroundoffset
- \!!widtha \dimexpr\paperwidth + \!!widthc\relax
- \!!heighta\dimexpr\paperheight+2\!!widthc\relax
- \setbox#2\vbox to \paperheight{\vfill\box#2}%
- \ht#2\paperheight
- \wd#2\paperwidth
- \setbox#2\vbox
- {\framed
- [\c!offset=\!!widthc,\c!strut=\v!no,\c!frame=\v!off]
- {\box#2}}%
- \setbox#2\hbox to \paperwidth
- {\ifcase#1\relax
- \!!widthb\zeropoint
- \hskip-\!!widthc
- \else
- \!!widthb\!!widthc
- \fi
- \lower\!!widthc\hbox
- {\clip
- [\c!width=\!!widtha,\c!height=\!!heighta,
- \c!hoffset=\!!widthb,\c!voffset=\zeropoint]
- {\box#2}}}%
- \wd#2\paperwidth
- \ht#2\paperheight
- \fi
- \box#2\relax}
-
-\let\clippagebox \gobbleoneargument
-\let\clipprintbox\gobbleoneargument
-
-% \setuppagenumbering[alternative=doublesided]
-% \setupcolors[state=start]
-% \setuppapersize[A4][A4,oversized]
-% \setuplayout[location=middle,clipoffset=5mm]
-% \setupbackgrounds
-% [page]
-% [frame=on,rulethickness=1mm,
-% backgroundoffset=10mm,background=color,backgroundcolor=red]
-% \starttext \dorecurse{10}{\input tufte \par} \stoptext
-
-\def\clippagebox % skip fast over false
- {\ifdim\layoutparameter\c!clipoffset>\zeropoint
- \expandafter\doclippagebox
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\def\doclippagebox#1%
- {\!!widtha \wd#1%
- \!!heighta\ht#1%
- \!!deptha \dp#1%
- \setbox#1\hbox
- {\!!widthb\layoutparameter\c!clipoffset
- \advance\!!heighta\dimexpr\!!deptha+2\!!widthb\relax
- \advance\!!widtha \!!widthb
- \doifbothsides
- {\advance\!!widtha\!!widthb \!!widthc-\!!widthb \hskip\!!widthc}%
- {\!!widthc\zeropoint}
- {\!!widthc-\!!widthb \hskip\!!widthc}%
- \lower\!!widthb\hbox
- {\clip
- [\c!hoffset=\!!widthc,
- \c!voffset=-\!!widthb,
- \c!width=\!!widtha,
- \c!height=\!!heighta]%
- {\box#1}}}%
- \wd#1\!!widtha
- \ht#1\!!heighta
- \dp#1\!!deptha}
-
%D \macros
%D {starttextdata}
%D
@@ -118,12 +35,6 @@
\prependtoks \flushtextdata \to \everylastshipout
-\def\installpagehandler#1#2% % a handler takes one argument: something to be boxed
- {\setgvalue{\??pp:\c!method:#1}##1{#2{##1}}} % and shipped out (don't depend on the exact package)
-
-\installpagehandler\v!normal
- {\ifarrangingpages\expandafter\actualarrange\else\expandafter\actualshipout\fi}
-
% Problem: we need to apply the finalizers to a to be shipped out page (as
% we can have positioning involved). However, we can also add stuff in the
% imposition, like cropmarks. Fortunately we do that with metapost so
@@ -140,35 +51,75 @@
\newconstant \whichpagetoshipout % 0=all 1=odd 2=even
\newbox \shipoutscratchbox
-\newbox \postponedcontent
\setnewconstant\shipoutfinalizemethod\plusone % this will be default (we will have two finalizers)
-\def\myshipout#1%
- {\beforeshipout % voor de pagebody dus !
- \dontshowcomposition
- \dontcomplain
+\def\installpagehandler#1#2% % a handler takes one argument: something to be boxed
+ {\setgvalue{\??pp:h:#1}##1{#2{##1}}} % and shipped out (don't depend on the exact package)
+
+\def\page_shipouts_handle
+ {\csname\??pp:h:\ifcsname\??pp:h:\v_page_target_method\endcsname
+ \v_page_target_method
+ \else
+ \v!none
+ \fi\endcsname}
+
+\installpagehandler\v!normal
+ {\ifarrangingpages
+ \expandafter\page_shipouts_arrange
+ \else
+ \expandafter\page_shipouts_normal
+ \fi}
+
+\installpagehandler\v!none
+ {\page_shipouts_ignore}
+
+\def\page_boxes_shipout#1% or: \page_shipouts_apply
+ {\dontshowcomposition % redundant
+ \dontcomplain % redundant
+ \the\everybeforeshipout
\ifcase\shipoutfinalizemethod
- \executeifdefined{\??pp:\c!method:\@@ppmethod}\gobbleoneargument{#1}%
+ \page_shipouts_handle{#1}%
\else
\setbox\shipoutscratchbox\hbox{#1}% just in case there are objects there, hook for testing (will go away)
\finalizeshipoutbox\shipoutscratchbox
- \executeifdefined{\??pp:\c!method:\@@ppmethod}\gobbleoneargument{\box\shipoutscratchbox}%
+ \page_shipouts_handle{\box\shipoutscratchbox}%
\fi
- \setnextrealpageno
- \aftershipout}
-
-\def\flushatshipout
- {\dowithnextbox
- {\global\setbox\postponedcontent\hbox to \zeropoint
- {%\hskip-\maxdimen % niet hier, gaat mis in acrobat (clipt)
- \unhbox\postponedcontent\unhbox\nextbox}% was \box
- \global\postponedcontent\zeropoint
- \global\postponedcontent\zeropoint
- \global\postponedcontent\zeropoint}%
- \hbox}
-
-\def\actualshipout#1% todo: less callbacks, #1 will go away
+ \the\everyaftershipout
+ \setnextrealpageno}
+
+\def\page_shipouts_ignore#1%
+ {\begingroup
+ \message
+ {[\ifarrangingpages arranged \fi page
+ \ifarrangingpages\the\arrangeno\else\the\realpageno\fi\normalspace
+ not flushed]}%
+ \setbox\scratchbox\hbox{#1}%
+ \deadcycles\zerocount
+ \endgroup}
+
+\def\page_otr_flush_every_stuff % this will become obsolete ... was backend related
+ {\begingroup
+ \setbox\scratchbox\hbox
+ {% before the main one !
+ \ifcase\realfolio \or
+ \the\everyfirstshipout
+ \global\everyfirstshipout\emptytoks
+ \fi
+ % the main one
+ \the\everyshipout\relax
+ % always last (and after the main one)
+ \ifnum\realpageno=\lastpage\relax
+ \the\everylastshipout
+ \global\everylastshipout\emptytoks
+ \fi}%
+ \smashbox\scratchbox
+ \box\scratchbox
+ \endgroup}
+
+\newdimen\d_page_shipouts_offset \d_page_shipouts_offset=-1in
+
+\def\page_shipouts_normal#1%
{\global\advance\shippedoutpages\plusone
% this is not resource safe!
\ifx\pagestoshipout\empty
@@ -182,55 +133,29 @@
\donetrue
\fi
\else % testen, aangepast / expanded nodig ?
- \normalexpanded{\noexpand\doifinsetelse{\the\shippedoutpages}{\pagestoshipout}}%
+ \normalexpanded{\doifinsetelse{\the\shippedoutpages}{\pagestoshipout}}%
\donetrue\donefalse
\fi
\ifdone
- \begingroup
+ \setbox\shipoutscratchbox\hbox{#1}%
\ifcase\shipoutfinalizemethod
- \setbox\shipoutscratchbox\hbox{#1}%
\finalizeshipoutbox\shipoutscratchbox
\fi
- \setbox\scratchbox\hbox
- {% before the main one !
- \ifcase\realfolio \or
- \the\everyfirstshipout
- \global\everyfirstshipout\emptytoks
- \fi
- % the main one
- \the\everyshipout\relax
- % always last (and after the main one)
- \ifnum\realpageno=\lastpage\relax
- \the\everylastshipout
- \global\everylastshipout\emptytoks
- \fi}%
- \smashbox\scratchbox
- \shipout\vbox
+ \normalshipout\vbox
{\offinterlineskip
- \scratchdimen-1in % to be done in luatex: zero that one
- \vskip\scratchdimen
- \hskip\scratchdimen
- \hbox % \setbox0=\box.. is nicer
- {\box\scratchbox
- \ifvoid\postponedcontent\else\box\postponedcontent\fi % evt ver naar links !
- \ifcase\shipoutfinalizemethod
- \box\shipoutscratchbox
- \else
- \hbox{#1}%
- \fi}}%
- \endgroup
+ \vskip\d_page_shipouts_offset
+ \hskip\d_page_shipouts_offset
+ \hbox
+ {\page_otr_flush_every_stuff
+ \page_otr_flush_special_content
+ \box\shipoutscratchbox}}%
\else
- \message
- {[\ifarrangingpages arranged \fi page
- \ifarrangingpages\the\arrangeno\else\the\realpageno\fi\normalspace
- not flushed]}%
- \setbox0\hbox{#1}%
- \deadcycles\zerocount
+ \page_shipouts_ignore{#1}%
\fi}
-\def\actualarrange#1%
- {\setbox0\hbox{#1}%
- \pusharrangedpage0%
+\def\page_shipouts_arrange#1%
+ {\setbox\scratchbox\hbox{#1}%
+ \pusharrangedpage\scratchbox
\deadcycles\zerocount}
%D We need a couple of boxes for duplex printing \unknown
@@ -257,17 +182,17 @@
\newcount\arrangedpageX \arrangedpageX\plusone
\newcount\arrangedpageY \arrangedpageY\plusone
-\def\calculatepaperoffsets#1%
- {\global\paperoffset\getvalue{\??pp#1\c!offset}%
+\def\pages_paper_set_offsets
+ {\global\paperoffset\v_page_target_offset
\global\advance\paperwidth -2\dimexpr\paperoffset/\arrangedpageX\relax
\global\advance\paperheight-2\dimexpr\paperoffset/\arrangedpageY\relax}
\def\doinstallarrangedoption#1#2%
- {\setvalue{\??pp=>#1}{#2}}
+ {\setvalue{\??pp:o:#1}{#2}}
\def\doinstalledarrangedoption#1%
- {\ifcsname\??pp=>#1\endcsname
- \csname\??pp=>#1\endcsname
+ {\ifcsname\??pp:o:#1\endcsname
+ \csname\??pp:o:#1\endcsname
\else
\checkinstalledpagearrangement{#1}% this installs the arranger
\fi}
@@ -334,10 +259,13 @@
\fi}
\def\installpagearrangement #1 % will lchange, no space
- {\setgvalue{\??pp\??pp#1}}
+ {\setgvalue{\??pp:a:#1}}
\def\checkinstalledpagearrangement#1% can be empty: aaa,,bbb
- {\executeifdefined{\??pp\??pp#1}\donothing}
+ {\executeifdefined{\??pp:a:#1}\donothing}
+
+\let\poparrangedpages\relax
+\let\pusharrangedpage\relax
\def\dosetuparrangement#1#2#3#4#5#6#7#8%
{\global\arrangedpageX #1%
@@ -407,7 +335,7 @@
\ifcase\scratchcounter\else
\advance\scratchcounter \plusone
\dostepwiserecurse\scratchcounter\arrangedpageT\plusone
- {\noheaderandfooterlines\ejectdummypage}%
+ {\noheaderandfooterlines\page_otr_insert_dummy_page}%
\fi
\fi}
@@ -427,7 +355,7 @@
\def\pagecutmarksymbol{\the\arrangeno}}
\def\outputarrangedbox#1%
- {\bgroup
+ {\begingroup
\forgetall % somehow we're back and need to redo this
\gotonextarrangepage
\ifnum\arrangedrotationO\arrangedrotationE>\zerocount
@@ -443,15 +371,24 @@
\fi}%
\fi
\ifconditional\arrangedmirrorstate
- \setbox#1\vbox{\domirrorbox\vbox{\box#1}}%
+ \page_boxes_apply_mirror{#1}%
\fi
\ifconditional\arrangednegatestate
- \negatecolorbox{#1}%
+ \page_boxes_apply_negate{#1}%
\fi
- \finishpagebox#1%
- \ifconditional\arrangedbackgroundstate\addprintbackground#1\fi
- \actualshipout{\box#1}%
- \egroup}
+ \page_marks_add_more #1%
+ \page_boxes_apply_center #1%
+ \page_boxes_apply_mirror_print #1%
+ \page_boxes_apply_orientate_print#1%
+ \page_boxes_apply_offset #1%
+ \page_boxes_apply_negate_print #1%
+ %
+ \ifconditional\arrangedbackgroundstate
+ \page_backgrounds_add_to_print#1%
+ \fi
+ %
+ \page_shipouts_normal{\box#1}%
+ \endgroup}
%D The format file can be 16K smaller when we postpone the
%D real arrangments. Some day ...
@@ -604,13 +541,13 @@
{\splitoffarrangedpagesTWO
\ifconditional\arrangedswapstate
\global\setbox\arrangedpageA\hbox
- {\clippedprintbox\zerocount\arrangedpageA
- \clippedprintbox\plusone \arrangedpageB}%
+ {\page_boxes_apply_clip_print_left \arrangedpageA\box\arrangedpageA
+ \page_boxes_apply_clip_print_right\arrangedpageB\box\arrangedpageB}%
\setfalse\arrangedswapstate
\else
\global\setbox\arrangedpageA\hbox
- {\clippedprintbox\zerocount\arrangedpageB
- \clippedprintbox\plusone \arrangedpageA}%
+ {\page_boxes_apply_clip_print_left \arrangedpageB\box\arrangedpageB
+ \page_boxes_apply_clip_print_right\arrangedpageA\box\arrangedpageA}%
\settrue\arrangedswapstate
\fi
\ht\arrangedpageA\paperheight
@@ -1141,22 +1078,30 @@
{\advancearrangedpageN
\global\advance\arrangedpageM\plusone
\reportarrangedpage\arrangedpageN
- \global\setbox\arrangedpageB\hbox \ifdim\@@ppwidth>\zeropoint to \@@ppwidth \fi
+ \global\setbox\arrangedpageB\hbox \ifdim\v_page_target_width>\zeropoint to \v_page_target_width \fi
{\ifvoid\arrangedpageB\else
\unhbox\arrangedpageB
- \ifdim\@@ppdx>\zeropoint \else \hss\fi
- \hskip\@@ppdx
- \ifdim\@@ppdx>\zeropoint \else \hss\fi
+ \ifdim\v_page_target_dx>\zeropoint
+ \hskip\v_page_target_dx
+ \else
+ \hss
+ \hskip\v_page_target_dx
+ \hss
+ \fi
\fi
\box#1}%
\ifnum\arrangedpageM<\arrangedpageX\else
- \global\setbox\arrangedpageA\vbox \ifdim\@@ppheight>\zeropoint to \@@ppheight \fi
+ \global\setbox\arrangedpageA\vbox \ifdim\v_page_target_height>\zeropoint to \v_page_target_height \fi
{\offinterlineskip
\ifvoid\arrangedpageA\else
\unvbox\arrangedpageA
- \ifdim\@@ppdy>\zeropoint \else \vss\fi
- \vskip\@@ppdy
- \ifdim\@@ppdy>\zeropoint \else \vss\fi
+ \ifdim\v_page_target_dy>\zeropoint
+ \vskip\v_page_target_dy
+ \else
+ \vss
+ \vskip\v_page_target_dy
+ \vss
+ \fi
\fi
\box\arrangedpageB}%
\global\arrangedpageM\zerocount
@@ -1175,19 +1120,42 @@
\fi}
\installpagearrangement XY
- {\dosetuparrangement\@@ppnx\@@ppny\@@ppxy\!!zerocount\!!zerocount
+ {\dosetuparrangement
+ \v_page_target_nx
+ \v_page_target_ny
+ \v_page_target_xy
+ \zerocount
+ \zerocount
\pusharrangedpageXY\poparrangedpagesXY\relax}
%D A crazy definition, don't guess who pushed me for the landscape option.
+\def\page_imposition_xy_height
+ {\dimexpr
+ \dimexpr
+ \v_page_target_height
+ -\numexpr\v_page_target_ny-1\relax\v_page_target_dy
+ \relax
+ /\v_page_target_ny
+ \relax}
+
+\def\page_imposition_xy_width
+ {\dimexpr
+ \dimexpr
+ \v_page_target_width
+ -\numexpr\v_page_target_nx-1\relax\v_page_target_dx
+ \relax
+ /\v_page_target_nx
+ \relax}
+
\definepapersize
[XY]
- [\c!height=\dimexpr\dimexpr\@@ppheight-\numexpr\@@ppny-1\relax\dimexpr\@@ppdy\relax\relax/\@@ppny\relax,
- \c!width =\dimexpr\dimexpr\@@ppwidth -\numexpr\@@ppnx-1\relax\dimexpr\@@ppdx\relax\relax/\@@ppnx\relax]
+ [\c!height=\page_imposition_xy_height,
+ \c!width =\page_imposition_xy_width]
\setuppaper
- [\c!width =\dimexpr\printpaperwidth -2\dimexpr\@@ppbackspace\relax\relax,
- \c!height=\dimexpr\printpaperheight-2\dimexpr\@@pptopspace \relax\relax]
+ [\c!width =\dimexpr\printpaperwidth -2\v_page_target_backspace\relax,
+ \c!height=\dimexpr\printpaperheight-2\v_page_target_topspace \relax]
% \definepageshift[test][horizontal][10pt,20pt,30pt,40pt,50pt]
% \definepageshift[test][vertical] [10pt,20pt,30pt,40pt,50pt]
@@ -1205,52 +1173,68 @@
% #1=name #2=horizontal|vertical #3=shiftlist
\unexpanded\def\definepageshift
- {\dotripleargument\dodefinepageshift}
+ {\dotripleargument\page_boxes_define_shift}
-\def\dodefinepageshift[#1][#2][#3]%
+\def\page_boxes_define_shift[#1][#2][#3]%
{\setvalue{\??pt#2:#1}{#3}}
-\letempty\hpageshifts \newcount\nofhpageshifts
-\letempty\vpageshifts \newcount\nofvpageshifts
+\let\page_boxes_h_shifts\empty
+\let\page_boxes_v_shifts\empty
-\def\dogetpageshift#1#2#3% #1=\dimenx #2=\xpageshifts #3=\nofxpageshifts
- {\ifx#2\empty % we could do this in lua
- #1\zeropoint
- \else
+\newcount\c_page_boxes_h_shifts
+\newcount\c_page_boxes_v_shifts
+
+\newdimen\d_page_boxes_h_shifts
+\newdimen\d_page_boxes_v_shifts
+
+\let\page_boxes_apply_shift_print\gobbleoneargument
+\let\page_boxes_apply_shift_paper\gobbleoneargument
+
+\def\page_boxes_filter_shift#1#2#3% #1=\dimenx #2=\xpageshifts #3=\nofxpageshifts
+ {#1\zeropoint
+ \ifx#2\empty \else
\global\advance#3\plusone
\getfromcommacommand[#2][#3]%
\ifx\commalistelement\empty
\global#3\plusone % we cycle
\getfromcommacommand[#2][#3]%
\fi
- \ifx\commalistelement\empty
- #1\zeropoint
- \else
- #1=\commalistelement
- \donetrue
+ \ifx\commalistelement\empty \else
+ #1\commalistelement
\fi
\fi}
-\def\shiftpagebox#1%
- {\donefalse
- \dogetpageshift{\dimen0}\hpageshifts\nofhpageshifts
- \dogetpageshift{\dimen2}\vpageshifts\nofvpageshifts
- \ifdone % see also layout offsets, maybe \movebox
- \edef\next{\wd#1\the\wd#1\ht#1\the\ht#1\dp#1\the\dp#1}%
- \setbox#1\vbox
- {\offinterlineskip\vskip\dimen2\hskip\dimen0\box#1}%
- \next
+\def\page_boxes_apply_shift#1%
+ {\page_boxes_filter_shift\d_page_boxes_h_shifts\page_boxes_h_shifts\c_page_boxes_h_shifts
+ \page_boxes_filter_shift\d_page_boxes_v_shifts\page_boxes_v_shifts\c_page_boxes_v_shifts
+ \ifzeropt\d_page_boxes_h_shifts
+ \ifzeropt\d_page_boxes_v_shifts
+ % nothing to shift
+ \else
+ \page_boxes_apply_shift_indeed#1%
+ \fi
+ \else
+ \page_boxes_apply_shift_indeed#1%
\fi}
+\def\page_boxes_apply_shift_indeed#1%
+ {\edef\next{\wd#1\the\wd#1\ht#1\the\ht#1\dp#1\the\dp#1}%
+ \setbox#1\vbox
+ {\offinterlineskip
+ \vskip\d_page_boxes_v_shifts
+ \hskip\d_page_boxes_h_shifts
+ \box#1}%
+ \next}
+
\unexpanded\def\setuppageshift
- {\dotripleempty\dosetuppageshift}
-
-\def\dosetuppageshift[#1][#2][#3]% page|paper horizontal vertical
- {\ifthirdargument % paper=arrange
- \edef\hpageshifts{\ifcsname\??pt\v!horizontal:#2\endcsname\csname\??pt\v!horizontal:#2\endcsname\fi}%
- \edef\vpageshifts{\ifcsname\??pt\v!vertical :#3\endcsname\csname\??pt\v!vertical :#3\endcsname\fi}%
- \doifelse{#1}\v!page {\let\shiftprintpagebox\shiftpagebox}{\let\shiftprintpagebox\gobbleoneargument}%
- \doifelse{#1}\v!paper{\let\shiftpaperpagebox\shiftpagebox}{\let\shiftpaperpagebox\gobbleoneargument}%
+ {\dotripleempty\page_boxes_setup_shift}
+
+\def\page_boxes_setup_shift[#1][#2][#3]% page|paper horizontal vertical
+ {\ifthirdargument % paper=arrange
+ \edef\page_boxes_h_shifts{\ifcsname\??pt\v!horizontal:#2\endcsname\csname\??pt\v!horizontal:#2\endcsname\fi}%
+ \edef\page_boxes_v_shifts{\ifcsname\??pt\v!vertical :#3\endcsname\csname\??pt\v!vertical :#3\endcsname\fi}%
+ \doifelse{#1}\v!page {\let\page_boxes_apply_shift_print\page_boxes_apply_shift}{\let\page_boxes_apply_shift_print\gobbleoneargument}%
+ \doifelse{#1}\v!paper{\let\page_boxes_apply_shift_paper\page_boxes_apply_shift}{\let\page_boxes_apply_shift_paper\gobbleoneargument}%
\else\ifsecondargument
\doifinsetelse{#1}{\v!page,\v!paper}
{\setuppageshift[#1][#2][#2]}
@@ -1259,5 +1243,4 @@
\setuppageshift[\v!page][#1][#1]%
\fi\fi\fi}
-
\protect \endinput
diff --git a/tex/context/base/page-inf.mkiv b/tex/context/base/page-inf.mkiv
new file mode 100644
index 000000000..41e3520c8
--- /dev/null
+++ b/tex/context/base/page-inf.mkiv
@@ -0,0 +1,104 @@
+%D \module
+%D [ file=page-inf, % moved from page-ini
+%D version=2011.12.07, % 2000.10.20,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Tracing Info,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Tracing Info}
+
+% this needs a real cleanup .. will be a more detailed list
+
+\unprotect
+
+\newtoks\everyresetversion
+\newtoks\everysetupversion
+
+\let\currentversioninfo\empty
+
+\def\setupversion
+ {\dosingleargument\page_info_setup}
+
+\let\version\setupversion
+
+\let\page_info_add_to_box\gobbleoneargument
+
+\def\page_info_setup[#1]%
+ {\the\everyresetversion
+ \ifcsname\??ly:v:#1\endcsname
+ \edef\currentversioninfo{#1}%
+ \let\page_info_add_to_box\page_info_add_to_box_indeed
+ \else
+ \let\currentversioninfo\empty
+ \let\page_info_add_to_box\gobbleoneargument
+ \fi
+ \the\everysetupversion}
+
+\unexpanded\def\place_info_place_info % at the bottom of the page
+ {\csname\??ly:v:\currentversioninfo\endcsname}
+
+\unexpanded\def\installversioninfo#1#2%
+ {\setvalue{\??ly:v:#1}{#2}}
+
+\unexpanded\def\includeversioninfo#1%
+ {\csname\??ly:v:#1\endcsname}
+
+\installversioninfo\v!concept
+ {\vskip\!!sixpoint
+ \hbox to \makeupwidth
+ {\infofont
+ \v!concept:\space\currentdate
+ \hss
+ \page_adapts_status_info}}
+
+\installversioninfo\v!file
+ {\vskip\!!sixpoint
+ \hbox to \makeupwidth
+ {\infofont
+ \getmessage\m!system{27}:\space\currentdate\space
+ \donefalse
+ \ifx\currentproject \empty \else \space\v!project :\space\currentproject \space \donetrue \fi
+ \ifx\currentproduct \empty \else \space\v!product :\space\currentproduct \space \donetrue \fi
+ \ifx\currentcomponent\empty \else \space\v!component:\space\currentcomponent\space \donetrue \fi
+ \ifdone \else \space\v!file :\space\jobname \space \fi
+ \hss
+ \page_adapts_status_info}}
+
+\installversioninfo\v!temporary
+ {\includeversioninfo\v!file}
+
+\appendtoks
+ \overfullrule\zeropoint
+\to \everyresetversion
+
+\appendtoks
+ \ifx\currentversioninfo\v!temporary
+ \overfullrule5\points
+ \fi
+\to \everysetupversion
+
+\newbox\b_page_versions
+
+\def\page_info_add_to_box_indeed#1%
+ {\scratchdimen\wd#1%
+ \setbox\b_page_versions\vbox to \ht#1%
+ {\vfill
+ \settexthoffset
+ \hsize\dimexpr\scratchdimen-2\texthoffset\relax
+ \hskip\texthoffset % brrrr
+ \vbox to \zeropoint{\vss\place_info_place_info}%
+ \vskip\bodyfontsize}%
+ \dp\b_page_versions\zeropoint
+ \wd\b_page_versions\scratchdimen
+ \setbox#1\hbox{\box#1\hskip-\scratchdimen\box\b_page_versions}}
+
+\setupversion % resets
+ [\v!final]
+
+\protect \endinput
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index c9bd05775..8cb146505 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -25,177 +25,93 @@
%D mechanism use a different way of looping over columns.
\unprotect
-
-\def\m!otr{otr}
-
-% \setnewconstant\normalpagebox 255 % already set
-
-\newbox\pagebox
-
-\ifx\recalculatelayout\undefined
-
- \let \recalculatelayout \relax
-
-\fi
-
-\ifx\recalculatebackgrounds\undefined
-
- \let \recalculatebackgrounds \relax
- \let \addmainbackground \gobbleoneargument % <box>
- \let \addtextbackground \gobbleoneargument % <box>
- \let \addpagebackground \gobbleoneargument % <box>
- \let \addprintbackground \gobbleoneargument % <box>
- \let \addstatusinfo \gobbleoneargument % <box>
-
-\fi
-\ifx\realpageno\undefined
-
- \countdef\realpageno = 0 \realpageno = 1
- \countdef\userpageno = 1 \userpageno = 1
- \countdef\subpageno = 2 \subpageno = 0 % !!
- \countdef\arrangeno = 3 \arrangeno = 0 % !!
-
- \let\pageno\userpageno
-
-\fi
-
-\ifx\realfolio\undefined
+\def\m!otr{otr}
- \def\realfolio{\the\realpageno}
+\newbox \pagebox
+\newcount \nofshipouts
-\fi
+\newconstant\c_page_otr_eject_penalty \c_page_otr_eject_penalty -\plustenthousand
+\newconstant\c_page_otr_super_penalty \c_page_otr_super_penalty -\plustwentythousand
-\newcount\nofshipouts
+\let\ejectpenalty\c_page_otr_eject_penalty % for old times sake
\appendtoks
- \global\advance\nofshipouts\plusone
+ \global\advance\nofshipouts\plusone
\to \everyaftershipout
-% principle:
-%
-% multiple otr's
-%
-% (1) single column, simple routine (old one)
-% (2) multi column, collect and split routine (old one)
-% (3) multi column, page by page (new one, needed for taco)
-% (4) single column, spread handling (for fun)
-% (5) multi column, page by page, spread handling (as challenge)
-%
-% common components
-%
-% (1) float placement
-% (2) float flushing
-% (3) page body building
-% (4) ...
-%
-% ort
-%
-% + balancing
-% - mixed / one / multi / balancetofit
-% + backgrounds
-% + pre / post
-% + distances / heights
-% + ragged / baseline / normal
-% - pos sync
-% - last page
-%
-% - itemize / subtexts -> old mechanism
-%
-% floats
-%
-% - top / bottom / side / page / column / spead
-% - flush / packed flush / current page / next page / area
-%
-% footnotes
-%
-% + carry over pre column / local to column
-% + last column / pre last column / each column
-% - multiple classes
-% - area / page / end
-%
-% areas
-%
-% - top / bottom / mid in spread
-%
-% IMPORTANT
-%
-% switchtobodyfont in between ivm top
-
-% floats:
-%
-% tricky in balancing mode, a la huidige multi columns
-
-% \ifx\dosetuplayout\undefined % overloaded in page-lay !
-% \unexpanded\def\setuplayout{\dodoubleempty\getparameters[\??ly]}
-% \fi
-
\ifx\mkprocesscolumncontents\undefined\let\mkprocesscolumncontents\gobbleoneargument\fi
\ifx\mkprocesspagecontents \undefined\let\mkprocesspagecontents \gobbleoneargument\fi
\ifx\mkprocessboxcontents \undefined\let\mkprocessboxcontents \gobbleoneargument\fi
-
-\def\normalejectpenalty{-\plustenthousand } \let\ejectpenalty\normalejectpenalty
-\def\normalsuperpenalty{-\plustwentythousand} \let\superpenalty\normalsuperpenalty
-
-%D In case we're not running \ETEX, we need to bypass a
-%D couple of primitives.
-
-% ONE = single column
-% MUL = multi column
-% SET = columns sets
-\def\@@OTR{OTR}
+%D As we have several fundamentally different output routines
+%D available we need commands that adapt themselves to the
+%D current output routine. Such commands are implemented
+%D in the respective modules and prefixed:
+%D
+%D \starttabulate[|T|T|]
+%D \NC OTRONE \NC single column \NC \NR
+%D \NC OTRMUL \NC multi column \NC \NR
+%D \NC OTRSET \NC columns sets \NC \NR
+%D \stoptabulate
+%D
+%D The following macros are not to be changed by users:
-\let\OTRdefault\empty
+\let\OTRidentifier\empty % public
+\let\OTRdefault \empty % public
+\let\OTRunknown \empty
+\def\OTRprefix {OTR}
-% obsolete
+%D We keep a list of registered commands so that we can
+%D bind them when we switch to a specific routine.
-\def\installotr#1% andere naam, beter \connectotr of zo
- {\def\OTRidentifier{#1}}
+\newtoks\t_page_otr_registered_commands
-\def\OTRcommand#1%
- {\csname\@@OTR
- \ifcsname\@@OTR\OTRidentifier\expandafter\gobbleoneargument\string#1\endcsname
- \OTRidentifier
- \else\ifcsname\@@OTR\OTRdefault\expandafter\gobbleoneargument\string#1\endcsname % fallback
- \OTRdefault
+\def\registerotrcommand#1%
+ {\t_page_otr_registered_commands\expandafter
+ {\the\t_page_otr_registered_commands
+ \page_otr_with_command#1}}
+
+\def\page_otr_preset_command#1%
+ {\expandafter\let\expandafter#1\csname\OTRprefix
+ \ifcsname\OTRprefix\OTRidentifier\expandafter\gobbleoneargument\string#1\endcsname
+ \OTRidentifier % dedicated
+ \else\ifcsname\OTRprefix\OTRdefault\expandafter\gobbleoneargument\string#1\endcsname
+ \OTRdefault % fallback
+ \else
+ \s!unknown % dummy
\fi\fi
\expandafter\gobbleoneargument\string#1\endcsname}
-\def\activateotr#1#2%
+\def\page_otr_activate#1#2%
{\def\OTRidentifier{#1}%
- \def\OTRdefault {#2}}
+ \def\OTRdefault {#2}%
+ \let\page_otr_with_command\page_otr_preset_command
+ \the\t_page_otr_registered_commands}
-% variant that does a preset:
+\appendtoks
+ \page_otr_activate{ONE}\empty
+\to \everydump
-\newtoks\registeredotrcommands
+%D The next commands is a direct call to a specific command but is
+%D normally only used if one wants to call a command inside another
+%D one or for the main (not triggered) outputroutines.
-\def\registerotrcommand#1%
- {\appendtoks\dowithotrcommand#1\to\registeredotrcommands}
-
-\def\dopresetotrcommand#1%
- {\expandafter\let\expandafter#1\csname\@@OTR
- \ifcsname\@@OTR\OTRidentifier\expandafter\gobbleoneargument\string#1\endcsname
- \OTRidentifier
- \else\ifcsname\@@OTR\OTRdefault\expandafter\gobbleoneargument\string#1\endcsname % fallback
- \OTRdefault
+\def\OTRcommand#1%
+ {\csname\OTRprefix
+ \ifcsname\OTRprefix\OTRidentifier\expandafter\gobbleoneargument\string#1\endcsname
+ \OTRidentifier % dedicated
+ \else\ifcsname\OTRprefix\OTRdefault\expandafter\gobbleoneargument\string#1\endcsname
+ \OTRdefault % fallback
+ \else
+ \s!unknown % dummy
\fi\fi
\expandafter\gobbleoneargument\string#1\endcsname}
-\def\activateotr#1#2%
- {\def\OTRidentifier{#1}%
- \def\OTRdefault {#2}%
- \let\dowithotrcommand\dopresetotrcommand
- \the\registeredotrcommands}
-
-\appendtoks
- \activateotr{ONE}{}%
-\to\everydump
-
%D The initialization of the \type {\hsize} and \type {\vsize}
-%D depends on the OTR used.
+%D depends on the OTR used, as do some other commands.
-% todo: \registerotrcommand\output, is a toks
+% These definitions will move to where they are introduced.
\registerotrcommand\setvsize
\registerotrcommand\sethsize
@@ -216,588 +132,251 @@
\registerotrcommand\setfloathsize
-% wrong, will be redone
-%
-% \registerotrcommand\someherefloat
-% \registerotrcommand\somefixdfloat
-% \registerotrcommand\somepagefloat
-% \registerotrcommand\sometopsfloat
-% \registerotrcommand\somebotsfloat
-% \registerotrcommand\somesidefloat
+% \registerotrcommand\_specific_final_side_float_output % todo
-% beter een \installotr#1 met #1 = macro en auto test
-
-\newif \iftraceotr
-\newif \ifinotr
-\newtoks \mainoutput
-\newcount\otrlevel
+%registerotrcommand\someherefloat % not ok this way
+%registerotrcommand\somefixdfloat % not ok this way
+%registerotrcommand\somepagefloat % not ok this way
+%registerotrcommand\sometopsfloat % not ok this way
+%registerotrcommand\somebotsfloat % not ok this way
+%registerotrcommand\somesidefloat % not ok this way
% When issuing two \par\penalty-\plustenthousand's, only the first
-% triggers the otr; obscure feature or optimization?
+% triggers the otr. Is this an obscure feature or an optimization?
+
+\newif \iftraceotr % will change
+\newif \ifinotr % might change
-\newcount\outputcounter \outputcounter=-100010 % -10010
+\newcount\c_page_otf_trigger_penalty \c_page_otf_trigger_penalty=-100010 % -10010
-\def\doinvokeoutput
+\unexpanded\def\page_otr_trigger
{\iftraceotr
- \expandafter\dodotracedoutput
+ \expandafter\page_otr_trigger_traced
\else
- \expandafter\dodoinvokeoutput
+ \expandafter\page_otr_trigger_normal
\fi}
-\def\doshowoutputmessage#1#2#3%
- {\writestatus\m!otr{#1 #2 \number#3}}
-
-\def\dodoinvokeoutput#1%
- {\bgroup\par\penalty#1\egroup}
-
-\def\dodotracedoutput#1%
- {\doshowoutputmessage+{traced}{#1/\the\outputpenalty}%
- \writestatus\m!otr{c:\number\mofcolumns,v:\the\vsize,g:\the\pagegoal,t:\the\pagetotal}%
- \dodoinvokeoutput{#1}%
- \writestatus\m!otr{c:\number\mofcolumns,v:\the\vsize,g:\the\pagegoal,t:\the\pagetotal}%
- \doshowoutputmessage-{traced}{#1/\the\outputpenalty}}
-
-\def\installoutput#1#2% \invoke \action
- {\global\advance\outputcounter\minusone
- \edef#1{\noexpand\doinvokeoutput{\number\outputcounter}}%
- \setvalue{\@@OTR\number\outputcounter}{#2}}
-
-\def\invoketracedoutputroutine
- {\doshowoutputmessage+{trying}\outputpenalty
- \ifcsname\@@OTR\the\outputpenalty\endcsname
- \doshowoutputmessage+{special}\outputpenalty
- \csname\@@OTR\the\outputpenalty\endcsname
- \doshowoutputmessage-{special}\outputpenalty
+\def\page_otr_message_b#1#2%
+ {\writestatus\m!otr{+ #1 \number#1}}
+
+\def\page_otr_message_e#1#2%
+ {\writestatus\m!otr{- #1 \number#2}}
+
+\def\page_otr_message_s
+ {\writestatus\m!otr{c:\number\mofcolumns,v:\the\vsize,g:\the\pagegoal,t:\the\pagetotal}}
+
+\def\page_otr_trigger_normal#1%
+ {\begingroup\par\penalty#1\endgroup}
+
+\def\page_otr_trigger_traced#1%
+ {\page_otr_message_b{traced}{#1}%
+ \page_otr_message_s
+ \page_otr_trigger_normal{#1}%
+ \page_otr_message_s
+ \page_otr_message_e{traced}{#1}}
+
+\def\installoutputroutine#1#2% \invoke \action
+ {\global\advance\c_page_otf_trigger_penalty\minusone
+ \edef#1{\page_otr_trigger{\number\c_page_otf_trigger_penalty}}%
+ \setvalue{\??zo\number\c_page_otf_trigger_penalty}{#2}}
+
+\def\page_otr_triggered_output_routine_traced
+ {\page_otr_message_b{trying}\outputpenalty
+ \ifcsname\??zo\the\outputpenalty\endcsname
+ \page_otr_message_b{special}\outputpenalty
+ \csname\??zo\the\outputpenalty\endcsname
+ \page_otr_message_e{special}\outputpenalty
\else
- \doshowoutputmessage+{normal}\outputpenalty
- \the\OTRcommand\output
- \doshowoutputmessage-{normal}\outputpenalty
+ \page_otr_message_b{normal}\outputpenalty
+ \the\OTRcommand\output % currently a toks but this will become a normal command
+ \page_otr_message_e{normal}\outputpenalty
\fi
- \doshowoutputmessage-{trying}\outputpenalty}
+ \page_otr_message_e{trying}\outputpenalty}
-\def\invokenormaloutputroutine
- {\ifcsname\@@OTR\the\outputpenalty\endcsname
- \csname\@@OTR\the\outputpenalty\endcsname
+\def\page_otr_triggered_output_routine_normal
+ {\ifcsname\??zo\the\outputpenalty\endcsname
+ \csname\??zo\the\outputpenalty\endcsname
\else
\the\OTRcommand\output
\fi}
-\def\invokeoutputroutine
+\def\page_otr_triggered_output_routine
{\iftraceotr
- \expandafter\invoketracedoutputroutine
+ \expandafter\page_otr_triggered_output_routine_traced
\else
- \expandafter\invokenormaloutputroutine
+ \expandafter\page_otr_triggered_output_routine_normal
\fi}
-\mainoutput{\invokeoutputroutine}
-
%D Some hooks:
-\def\setoutputroutine#1%
- {\global\output{\inotrtrue\the\everybeforeoutput#1\the\everyafteroutput}}
+\def\page_otf_set_engine_output_routine#1%
+ {\global\output
+ {\inotrtrue
+ \the\everybeforeoutput
+ #1\relax
+ \the\everyafteroutput}}
-\setoutputroutine{\the\mainoutput}
-
-\ifx\pagediscards\undefined \let\pagediscards\relax \fi
+\page_otf_set_engine_output_routine{\page_otr_triggered_output_routine}
-\installoutput\synchronizeoutput % maybe add pagediscards
+\installoutputroutine\synchronizeoutput
{\ifvoid\normalpagebox\else
\unvbox\normalpagebox
- \pagediscards % maybe not needed ?
+ \pagediscards
\fi}
-\installoutput\discardpage
+\installoutputroutine\discardpage
{\setbox\scratchbox\box\normalpagebox}
-
-%D In order to force consistent use of variables, we
-%D predefine a lot of them here.
-
-%D The next two registers can be used to store pre column
-%D material as well as footnotes or so.
-
-\newbox\precolumnbox \newdimen\precolumnboxheight
-\newbox\postcolumnbox \newdimen\postcolumnboxheight
-
-%D We reserve a counter for the number of columns as well as
-%D the current column. Both are not to be changed by users!
-\newcount\nofcolumns \nofcolumns = 1
-\newcount\mofcolumns \mofcolumns = 1
-
-\setnewconstant\maxnofcolumns 50
-\setnewconstant\allocatednofcolumns 0
-
-%D The next dimensions reports the final column height
-
-\newdimen\finalcolumnheights
-\newcount\finalcolumnlines
-
-%D During initialization the temporary boxes are allocated.
-%D This enables us to use as much columns as we want, without
-%D exhausting the pool of boxes too fast. We could have packed
-%D them in one box, but we've got enough boxes.
-%D
-%D Two sets of boxes are declared, the txtboxes are used for
-%D the text, the topboxes are for moved column floats.
-
-\def\@col@{@col@}
-
-\def\initializecolumns#1%
- {\ifnum#1>\maxnofcolumns
- \showmessage\m!columns1\maxnofcolumns
- \nofcolumns\maxnofcolumns
- \else
- \nofcolumns#1\relax
+\def\page_otr_trigger_output_routine
+ {\par
+ \ifvmode
+ \penalty\c_page_otr_eject_penalty
\fi
- \ifnum\nofcolumns>\allocatednofcolumns
- \dorecurse\nofcolumns
- {\ifnum\recurselevel>\allocatednofcolumns\relax
- % \newbox\next \letgvalue{\@col@-\recurselevel-t}=\next
- \@EA\newbox\csname\@col@-\recurselevel-t\endcsname % text
- \@EA\newbox\csname\@col@-\recurselevel-f\endcsname % foot
- \@EA\newbox\csname\@col@-\recurselevel-h\endcsname % top insert
- \@EA\newbox\csname\@col@-\recurselevel-l\endcsname % top insert
- \fi}%
- \global\allocatednofcolumns\nofcolumns
- \fi}
-
-\def\firstcolumnbox {\columntextbox\plusone}
-\def\currentcolumnbox {\columntextbox\mofcolumns}
-\def\lastcolumnbox {\columntextbox\nofcolumns}
-
-\def\firsttopcolumnbox {\columntopbox \plusone}
-\def\currenttopcolumnbox{\columntopbox \mofcolumns}
-\def\lasttopcolumnbox {\columntopbox \nofcolumns}
-
-\def\columntextbox#1{\csname\@col@-\number#1-t\endcsname}
-\def\columnfootbox#1{\csname\@col@-\number#1-f\endcsname}
-\def\columntopbox #1{\csname\@col@-\number#1-h\endcsname}
-\def\columnbotbox #1{\csname\@col@-\number#1-l\endcsname}
-
-\def\columnsettextbox{\global\setbox\columntextbox}
-\def\columnsetfootbox{\global\setbox\columnfootbox}
-\def\columnsettopbox {\global\setbox\columntopbox}
-\def\columnsetbotbox {\global\setbox\columnbotbox}
-
-\def\columngettextbox{\copy\columntextbox}
-\def\columngetfootbox{\copy\columnfootbox}
-\def\columngettopbox {\copy\columntopbox}
-\def\columngetbotbox {\copy\columnbotbox}
-
-\def\columnerasetextboxes{\dorecurse\allocatednofcolumns{\columnsettextbox\recurselevel\emptybox}}
-\def\columnerasefootboxes{\dorecurse\allocatednofcolumns{\columnsetfootbox\recurselevel\emptybox}}
-\def\columnerasetopboxes {\dorecurse\allocatednofcolumns{\columnsettopbox \recurselevel\emptybox}}
-\def\columnerasebotboxes {\dorecurse\allocatednofcolumns{\columnsetbotbox \recurselevel\emptybox}}
-
-%D Without going in details we present two macro's which handle
-%D the columns. The action which is transfered by the the first
-%D and only parameter can do something with \type
-%D {\currentcolumnbox}. In case of the mid columns, \type
-%D {\firstcolumnbox} and \type {\lastcolumnbox} are handled
-%D outside these macro's.
-
-\def\dohandlecolumn#1%
- {\mofcolumns\recurselevel
- \let\currentcolumn\recurselevel
- #1\relax}
-
-\def\dohandleallcolumns#1%
- {\dorecurse\nofcolumns{\dohandlecolumn{#1}}}
-
-\def\dohandlerevcolumns#1%
- {\dostepwiserecurse\nofcolumns\plusone\minusone{\dohandlecolumn{#1}}}
-
-\def\dohandlemidcolumns#1%
- {\dohandleallcolumns
- {\ifnum\recurselevel>\plusone
- \ifnum\recurselevel<\nofcolumns
- \dohandlecolumn{#1}%
- \fi
- \fi}}
-
-%D This register can be used as a temporary storage for page
-%D content.
-
-\newbox\restofpage
-
-%D Features.
-
-\newif\ifintermediatefootnotes
-\newif\ifcarryoverfootnotes %\carryoverfootnotestrue
-\newif\iflastcolumnfootnotes %\lastcolumnfootnotestrue
-\newif\ifbalancecolumns %\balancecolumnstrue
-\newif\ifbalancetoheight %\balancetoheighttrue
-\newif\ifforcecolumngrid \forcecolumngridtrue
-\newif\ifstretchcolumns \stretchcolumnsfalse
-\newif\ifinheritcolumns \inheritcolumnsfalse
-\newif\ifheightencolumns \heightencolumnsfalse
-
-\newif\ifbalancingcolumns
-\newif\ifcollectingcontent
-\newif\ifcolumnoverflow
-
-\newdimen\intercolumnwidth
-\newdimen\localcolumnwidth
-\newdimen\savedpagetotal
-
-\newconstant\columndirection % 0:lr 1:rl
-
-\def\minbalancetoplines {1}
-\def\minfreecolumnlines {2}
-
-\newif\ifrecentercolumnbox \recentercolumnboxtrue
-\newif\ifrerecentercolumnbox \rerecentercolumnboxtrue
-\newif\ifpackcolumnfloats \packcolumnfloatstrue
-
-\newbox\collectedpagefloats
-\newbox\collectedleftpagefloats
-\newbox\collectedrightpagefloats
+ \resetpagebreak}
-%D The \type {\ifdim} test is needed, because otherwise the
-%D last line of a text end up on top of the baseline instead of
-%D on the baseline, as is the case with preceding pages.
-%D Also, a \type {\vfil} better than a \type {\vfill}.
+\def\page_otr_fill_and_eject_page
+ {\par
+ \ifvmode
+ \vfill
+ \penalty\c_page_otr_eject_penalty
+ \fi
+ \resetpagebreak}
-% to be replaced by \page[now] \page[final] / merged
+\def\page_otr_eject_page
+ {\par
+ \ifvmode
+ \ifdim\pagetotal>\pagegoal \else
+ \normalvfil
+ \fi
+ \penalty\c_page_otr_eject_penalty
+ \fi
+ \resetpagebreak}
-% \def\eject {\par\penalty-\plustenthousand } % == {\par\break} % plain
-% \def\supereject {\par\penalty-\plustwentythousand} % also plain
+\def\page_otr_eject_page_and_flush_inserts % can be an installed one
+ {\par
+ \ifvmode
+ \ifdim\pagetotal>\pagegoal \else
+ \normalvfil
+ \fi
+ \penalty\c_page_otr_super_penalty
+ \fi
+ \resetpagebreak}
-\def\eject {\par\ifvmode\penalty\ejectpenalty\fi\resetpagebreak} % == {\par\break} % plain
-\def\supereject {\par\ifvmode\penalty\superpenalty\fi\resetpagebreak} % also plain
+\def\page_otr_check_for_pending_inserts
+ {\ifnum\outputpenalty>\c_page_otr_super_penalty \else
+ \ifnum\insertpenalties>\zerocount
+ % something is being held over so we force a new page
+ \page_otr_force_another_page
+ \fi
+ \fi}
-\def\doejectpage {\par\ifvmode\ifdim\pagetotal>\pagegoal\else\normalvfil\fi\fi} % pg set to \textheight
-\def\ejectpage {\doejectpage\eject}
-\def\superejectpage{\doejectpage\supereject}
+\def\page_otr_force_another_page
+ {% we should actually remove the dummy line in the otr
+ \hbox to \hsize{}
+ \kern-\topskip
+ \nobreak
+ \vfill
+ \penalty\c_page_otr_super_penalty
+ \resetpagebreak}
-\ifx\bye\undefined \def\bye{\par\vfill\supereject\end} \fi % plain tex command
+\unexpanded\def\bye
+ {\writestatus\m!system{Sorry, you're not done yet, so no goodbye!}}
% floats
-\def\ejectinsert
+\def\page_otr_flush_all_floats
{%\flushnotes already done
- \bgroup
-\ifsomefloatwaiting
- \noftopfloats\plusthousand
- \nofbotfloats\zerocount
- % this is needed in case a float that has been stored
- % ends up at the current page; this border case occurs when
- % the calculated room is 'eps' smaller that the room available
- % when just flushing; so now we have (maybe optional):
- \pagebaselinecorrection % hm, needs checking, not needed when no floats
- % alas, this is tricky but needed (first surfaced in prikkels)
- \doflushfloats
-\fi
- \egroup}
+ \ifsomefloatwaiting
+ \begingroup
+ \noftopfloats\plusthousand
+ \nofbotfloats\zerocount
+ % this is needed in case a float that has been stored
+ % ends up at the current page; this border case occurs when
+ % the calculated room is 'eps' smaller that the room available
+ % when just flushing; so now we have (maybe optional):
+ \pagebaselinecorrection % hm, needs checking, not needed when no floats
+ % alas, this is tricky but needed (first surfaced in prikkels)
+ \doflushfloats
+ \endgroup
+ \fi}
-\def\ejectdummypage
- {\endgraf \ifvmode
- \ejectinsert
+\def\page_otr_insert_dummy_page
+ {\par
+ \ifvmode
+ \page_otr_flush_all_floats
\fixedspace
\vfill
\gotonextpage
\fi}
-\def\beforefinaloutput
- {}
-
-\def\afterfinaloutput
- {%\forgetall
+\def\finaloutput#1#2%
+ {\forgetall
+ \page_boxes_shipout{\page_boxes_constructed_page#1#2}% \hbox removed
\vskip\zeropoint\relax
\ifvoid\normalpagebox \else
\unvbox\normalpagebox
\penalty\outputpenalty
\fi
% not really needed, replaced by \flushsavedfloats
- \ifnum\outputpenalty>\superpenalty \else % better use a proper otr signal
- \dosupereject
- \fi
+ \page_otr_check_for_pending_inserts
% but does not hurt either (we're still in the otr!)
\inpagebodytrue % needed for enabling \blank !
\flushsavedfloats % was \dosetbothinserts; only otr one !
- \setvsize} % this is needed for interacting components, like floats and multicolumns
-
-\def\dofinaloutput#1#2% \vbox: prevents spurious spaces in every..pagebody
- {\forgetall
- \beforefinaloutput
- \the\everybeforeshipout % brrr not in shipout
- \the\pageboundsettings
- \myshipout{\hbox{\vbox{\dopagebody#1#2}}}% is this hbox needed
- \the\everyaftershipout
- \afterfinaloutput}
-
-\def\donofinaloutput#1#2%
- {\forgetall
- \beforefinaloutput
- \the\everybeforeshipout
- \message{[-\the\realpageno]}%
- \setbox\scratchbox\hbox{\dopagebody#1#2}%
- \deadcycles\zerocount
- \setnextrealpageno
- \the\everyaftershipout
- \afterfinaloutput}
-
-% beware: \ifprocessingpages is in use
-
-\ifdefined\doflushspread\else \let\doflushspread\relax \fi % todo
-
-\def\finaloutput#1#2%
- {\ifprocessingpages
- \ifpageselected
- \@EAEAEA\dofinaloutput
- \else
- \@EAEAEA\donofinaloutput
- \fi
- \else
- \ifpageselected
- \@EAEAEA\donofinaloutput
- \else
- \@EAEAEA\dofinaloutput
- \fi
- \fi#1#2%
- \resetselectiepagina
+ \setvsize % this is needed for interacting components, like floats and multicolumns
\doincrementpageboundcounters % should hook into an every
- \checkpagedimensions
- \ifnum\outputpenalty>\superpenalty \else
- \dosupereject
- \fi
+ \page_adapts_synchronize
+ \page_otr_check_for_pending_inserts
\doflushspread
- \doflushpostponedcontent}
+ \page_postponed_blocks_flush}
-\def\dooutput
- {\finaloutput\unvbox\normalpagebox}
+% Can't we get rid of this hackery? It's used in some widgets
+% stuff so probably not.
-\maxdeadcycles=1000
+\newbox\d_page_otr_special
-% this needs a real cleanup
-
-\def\doplaceversiontext#1#2%
- {\doifsomething{#2}
- {\defconvertedcommand\ascii{#2}%
- \space#1:\space\ascii\space
- \!!doneatrue}}
-
-\unexpanded\def\placeversioninfo % nog engels maken
- {\ifcase\conceptmode
- % 0 : nothing
- \or
- % 1 : simple
- \vskip\!!sixpoint
- \hbox to \makeupwidth
- {\infofont
- \v!concept:\space\currentdate
- \hss\reportpagedimensions}%
- \else
- % 2/3 : extensive
- \vskip\!!sixpoint
- \hbox to \makeupwidth
- {\infofont
- \getmessage\m!system{27}:\space\currentdate\space
- \doplaceversiontext\v!project \currentproject
- \doplaceversiontext\v!product \currentproduct
- \doplaceversiontext\v!component\currentcomponent
- \if!!donea\else\space\v!file:\space\jobname\fi
- \hss\reportpagedimensions}%
+\def\page_otr_flush_special_content
+ {\ifvoid\d_page_otr_special \else
+ \box\d_page_otr_special
\fi}
-% tot hier
+\def\page_otr_add_special_content
+ {\dowithnextbox\page_otr_add_special_content_indeed\hbox}
-\def\doversion[#1]%
- {\conceptmode\zerocount
- \overfullrule\zeropoint
- \processaction % \v!final=>
- [#1]
- [ \v!concept=>\conceptmode\plusone, % simple banner
- \v!file=>\conceptmode\plustwo, % full banner
- \v!temporary=>\conceptmode\plusthree % full banner plus
- \overfullrule5\points]} % info in the margin
+\def\page_otr_add_special_content_indeed
+ {\wd\nextbox\zeropoint
+ \ht\nextbox\zeropoint
+ \dp\nextbox\zeropoint
+ \global\setbox\d_page_otr_special\hbox
+ {%\hskip-\maxdimen % not here, fails in acrobat (clips)
+ \box\d_page_otr_special\box\nextbox}}% was \unhbox, is now box again
-\def\version
- {\dosingleargument\doversion}
+\let\flushatshipout\page_otr_add_special_content
-\def\addstatusinfo
- {\ifcase\conceptmode
- \@EA\gobbleoneargument
- \else
- \@EA\doaddstatusinfo
- \fi}
+% \def\dooutput{\finaloutput\unvbox\normalpagebox}
-\def\doaddstatusinfo#1%
- {\setbox#1\vbox to \paperheight
- {\vsmashbox#1\box#1%
- \offinterlineskip
- \vskip\topspace
- \hsize\paperwidth
- %\hfill\hbox{\placetestinfo\hskip.5cm}\vss % obsolete
- \settexthoffset\hskip\texthoffset % brrrr
- \vbox to 1cm{\vss\placeversioninfo\vss}}}
-
-\def\dotestinfo#1#2#3%
- {\ifinpagebody\else\ifnum\conceptmode=\plusthree
- \begingroup
- \defconvertedcommand\ascii{#3}%
- \xdef\extratestinfo
- {#2\space\ascii}%
- \gdef\totaltestinfo
- {\global\setbox#1\vbox
- {\unvbox#1\relax
- \infofont \setupinterlinespace
- \hbox
- {\strut
- \expanded{\doboundtext{\extratestinfo}{12em}{..}}%
- \quad}}}%
- \endgroup
- \ifinner
- \aftergroup\totaltestinfo
- \else
- \totaltestinfo
- \fi
- \fi\fi}
-
-\version[\v!final]
-
-% bewaren tvb documentatie
-%
-% \hbox to \hsize
-% {\en
-% \switchnaarkorps[5pt]%
-% \emergencystretch2em
-% \dimen0=\baselineskip
-% \baselineskip=\dimen0 plus 1pt
-% \hsize=.2\hsize
-% \vsize=2\hsize
-% \ruledvbox to \vsize{\input tufte \par}\hss
-% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth}\hss
-% \ruledvbox to \vsize{\input tufte \par\kern0pt}\hss
-% \ruledvbox to \vsize{\input tufte \par\vfill}\hss
-% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth\vfill}}
-%
-% \hbox to \hsize
-% {\en
-% \switchnaarkorps[5pt]%
-% \emergencystretch2em
-% \dimen0=\baselineskip
-% \baselineskip=\dimen0 plus 1pt
-% \hsize=.18\hsize
-% \vsize=2.5\hsize
-% \setbox0=\vbox{\input tufte\relax}%
-% \ruledvbox to \vsize{\unvcopy0}\hss
-% \ruledvbox to \vsize{\unvcopy0\kern-\dp0}\hss
-% \ruledvbox to \vsize{\unvcopy0\kern0pt}\hss
-% \ruledvbox to \vsize{\unvcopy0\vfill}\hss
-% \ruledvbox to \vsize{\unvcopy0\kern-\dp0\vfill}}
+\maxdeadcycles=1000
\newtoks\afterpage \newtoks\aftereverypage
\newtoks\beforepage \newtoks\beforeeverypage
-\newconstant\showgridstate
-
-\unexpanded\def\showgrid
- {\dosingleempty\doshowgrid}
-
-\def\doshowgrid[#1]%
- {\showgridstate \plusone % downward compatible default
- \gridboxlinemode \plusone
- \gridboxlinenomode\plusone
- \processallactionsinset
- [#1]%
- [ \v!reset=>\showgridstate \zerocount,
- \v!bottom=>\showgridstate \plusone,
- \v!top=>\showgridstate \plustwo,
- \v!none=>\gridboxlinemode \zerocount,
- \v!all=>\gridboxlinemode \plusone,
- \v!lines=>\gridboxlinemode \plustwo,
- \v!frame=>\gridboxlinemode \plusthree,
- \v!nonumber=>\gridboxlinenomode\zerocount,
- \v!right=>\gridboxlinenomode\plusone,
- \v!left=>\gridboxlinenomode\plustwo,
- \v!outer=>\gridboxlinenomode\plusthree]%
- \ifcase\showgridstate
- \let\addtextgridlayer\gobbleoneargument
- \else % 1=bottom 2=top
- \let\addtextgridlayer\doaddtextgridlayer
- \fi}
-
-\definepalet
- [layout]
- [grid=red,
- page=green]
-
-% if really needed for speed we can cache the grid
-
-\let\addtextgridlayer\gobbleoneargument
-
-\def\doaddtextgridlayer#1% to be checked for color and layer
- {\startcolor[layout:grid]%
- \setgridbox\scratchbox\makeupwidth\textheight % todo: check color
- \global\setbox#1\hbox
- {\ifcase\showgridstate\or\or\box#1\hskip-\makeupwidth\fi
- \bgroup % color
- \ifcase\layoutcolumns\else
- \gray
- \setlayoutcomponentattribute\v!grid\v!columns
- \hbox \layoutcomponentboxattribute to \makeupwidth
- {\dorecurse\layoutcolumns
- {\hskip\layoutcolumnwidth
- \ifnum\recurselevel<\layoutcolumns
- \vrule
- \!!height\ht\scratchbox
- \!!depth\dp\scratchbox
- \!!width\layoutcolumndistance
- \fi}}%
- \hskip-\makeupwidth
- \fi
- \setlayoutcomponentattribute\v!grid\v!lines
- \hbox \layoutcomponentboxattribute{\box\scratchbox}%
- \egroup
- \ifcase\showgridstate\or\hskip-\makeupwidth\box#1\fi}%
- \stopcolor}
-
-\def\buildpagebox#1%
- {\setbox#1\vbox to \paperheight
- {\hsize\paperwidth
- \vskip\topspace
- \doifbothsides
- {\hskip\backspace}
- {\hskip\backspace}
- {\hskip\paperwidth \hskip-\backspace \hskip-\makeupwidth}%
- \box#1}%
- \dp#1\zeropoint}
-
-% \newif\ifpagebodyornaments \pagebodyornamentstrue
-%
-% \appendtoks
-% \global\pagebodyornamentstrue
-% \to \everyaftershipout
-
-\newif\ifarrangingpages \arrangingpagesfalse
+\newif\ifarrangingpages \arrangingpagesfalse
\newconstant\pageornamentstate % 0=on 1=one-off 2=always-off
-\def\pagebodyornamentstrue {\pageornamentstate\zerocount} % for a while
-\def\pagebodyornamentsfalse{\pageornamentstate\plusone} % for a while
-
\appendtoks
- \ifcase\pageornamentstate\or
- \pageornamentstate\zerocount
- \fi
+ \ifcase\pageornamentstate \or
+ \pageornamentstate\zerocount
+ \fi
\to \everyaftershipout
-\let\poparrangedpages\relax
-\let\pusharrangedpage\relax
-
-\ifdefined\shiftprintpagebox \else
- \let\shiftprintpagebox\gobbleoneargument
- \let\shiftpaperpagebox\gobbleoneargument
-\fi
+% Mark synchronization
-\ifdefined\registerpageposition \else
- \let\registerpageposition\gobbleoneargument
-\fi
+\newconditional\page_marks_building_successive_pages \settrue\page_marks_building_successive_pages
-\newif\ifsavepagebody \newbox\savedpagebody
+\def\page_marks_synchronize_page#1% box
+ {\dosynchronizemarking[\v!page][#1][\ifconditional\page_marks_building_successive_pages\v!keep\fi]}
-\def\docolumnpagebodymarks#1#2#3#4% first last column box
+\def\page_marks_synchronize_column#1#2#3#4% first last column box
{\ifnum#3=#1\relax
\dosynchronizemarking[\number#3,\v!column:\number#3,\v!first,\v!column:\v!first][#4][]%
\else\ifnum#3=#2\relax
@@ -806,700 +385,131 @@
\dosynchronizemarking[\number#3,\v!column:\number#3 ][#4][]%
\fi\fi}
-% tricky ... we need to retain the last mark
+% Page body building
-\newconditional\buildingsuccessivepages \settrue\buildingsuccessivepages
+\newconditional\c_page_boxes_save_page_body
+\newbox \b_page_boxes_saved_page_body
-% \starttext
-% \dorecurse{3} {
-% \startchapter[title=Chapter #1]
-% \input tufte
-% \dorecurse{4}{\placefigure{Number ##1}{\externalfigure[cow][height=9cm]}}
-% \stopchapter
-% }
-% \stoptext
-
-\def\buildpagebody#1#2%
- {\ifsavepagebody\global\setbox\savedpagebody\fi
- \vbox
- {%\forgetall % igv problemen, check: \boxmaxdepth\maxdimen
+\def\page_boxes_constructed_page_body#1#2%
+ {\ifconditional\c_page_boxes_save_page_body \global\setbox\b_page_boxes_saved_page_body \fi \vbox \bgroup
\boxmaxdepth\maxdimen % new
\dontcomplain
- % marks get done here
- \dosynchronizemarking[\v!page][#2][\ifconditional\buildingsuccessivepages\v!keep\fi]% #2 box
- % the following plugin uses and sets pagebox; beware: this
- % will change and is for my (hh) personal experiments .. takes two
- % arguments
- \constructpagecontent#1#2%
- % the finishing touch
+ \page_marks_synchronize_page{#2}% we could consider doing this for \pagebox (needs testting)
+ \page_boxes_construct_content#1#2% % this one fills pagebox
+ \page_backgrounds_add_to_main \pagebox
+ \page_boxes_apply_offsets \pagebox
+ \page_info_add_to_box \pagebox
\ifcase\pageornamentstate
- \addpagebackground \pagebox
+ \page_backgrounds_add_to_paper \pagebox
\fi
- \registerpageposition\pagebox
+ \registerpageposition \pagebox
\ifarrangingpages
- \shiftpaperpagebox \pagebox % \v!paper
+ \page_boxes_apply_shift_paper \pagebox % \v!paper
\else
- \clippagebox \pagebox
- \page_marks_add_page \pagebox
- \replicatepagebox \pagebox
- \scalepagebox \pagebox
- \mirrorpaperbox \pagebox
- \orientpaperbox \pagebox
- \page_marks_add_more \pagebox
- \centerpagebox \pagebox
- \addprintbackground \pagebox
- \mirrorprintbox \pagebox
- \orientprintbox \pagebox
- \shiftprintpagebox \pagebox % \v!page
- \offsetprintbox \pagebox
- \negateprintbox \pagebox
+ \page_boxes_apply_clip_paper \pagebox
+ \page_marks_add_page \pagebox
+ \page_boxes_apply_replicate \pagebox
+ \page_boxes_apply_scale \pagebox
+ \page_boxes_apply_mirror_paper \pagebox
+ \page_boxes_apply_orientate_paper \pagebox
+ \page_marks_add_more \pagebox
+ \page_boxes_apply_center \pagebox
+ \page_backgrounds_add_to_print \pagebox
+ \page_boxes_apply_mirror_print \pagebox
+ \page_boxes_apply_orientate_print \pagebox
+ \page_boxes_apply_shift_print \pagebox % \v!page
+ \page_boxes_apply_offset \pagebox
+ \page_boxes_apply_negate_print \pagebox
\fi
- \box\pagebox}%
- \ifsavepagebody\copy\savedpagebody\fi}
-
-\ifx\page_marks_add_page\undefined \let\page_marks_add_page\gobbleoneargument \fi
-\ifx\page_marks_add_more\undefined \let\page_marks_add_more\gobbleoneargument \fi
-
-% \setvalue{\??ly\c!method\v!normal}#1#2%
-% {\setbox\pagebox\vbox
-% {\offinterlineskip
-% \ifcase\pageornamentstate
-% \bgroup % else footnotes get inconsistent font/baseline
-% % color/style attributes
-% \offinterlineskip
-% \gettextboxes
-% \egroup
-% \fi
-% \getmainbox#1#2}% including footnotes
-% \ifcase\pageornamentstate
-% \addmainbackground \pagebox
-% \fi
-% \buildpagebox \pagebox
-% \addstatusinfo \pagebox}
-
-\ifx\constructnormalpagecontent\undefined
-
- \def\constructnormalpagecontent#1#2%
- {\setbox\pagebox\vbox
- {\offinterlineskip
- \gettextboxes
- \getmainbox#1#2}% including footnotes
- \addmainbackground\pagebox
- \buildpagebox\pagebox
- \addstatusinfo\pagebox}
-
-\fi
-
-\ifx\constructpagecontent\undefined
- \let\constructpagecontent\constructnormalpagecontent % will be overloaded
-\fi
-
-\def\finishpagebox#1%
- {\ifarrangingpages
- \page_marks_add_more#1%
- \centerpagebox #1%
- \mirrorprintbox #1%
- \orientprintbox #1%
- \offsetprintbox #1%
- \negateprintbox #1%
- \fi}
-
+ \box\pagebox
+ \egroup \ifconditional\c_page_boxes_save_page_body \copy\b_page_boxes_saved_page_body \fi}
+
\appendtoks \restoreouterspacing \to \everybeforepagebody
\appendtoks \restoreglobalbodyfont \to \everybeforepagebody
%appendtoks \restoreouterspacing \to \everybeforepagebody
-\ifx\nestednewbox\undefined \newbox\nestednextbox \fi
-
-\prependtoks \let\nextbox\nestednextbox \to \everybeforepagebody
-
-\def\dopagebody#1#2%
- {\the\everybeforepagebody
- \starttextproperties
-% \setnextsubpageno % nog eens: als in pagina (tbv standaard opmaak)
- \dontshowboxes % dan hier blokkeren en verderop resetten
-% \shipoutfacingpage
- \checkmarginblocks
- \the\beforeeverypage
- \normalexpanded{\global\beforepage\emptytoks\the\beforepage}% \scratchtoks\beforepage\global\beforepage\emptytoks\the\scratchtoks % was \flushtoks\beforepage
- \inpagebodytrue\buildpagebody#1#2%
- \normalexpanded{\global\afterpage \emptytoks\the\afterpage }% \scratchtoks\afterpage \global\afterpage \emptytoks\the\scratchtoks % was \flushtoks\afterpage
- \the\aftereverypage
- \resetpagebreak
- %updatelistreferences % now in aftereverypage
- \resetlayouttextlines % will go to \aftereverypage
- \stoptextproperties
- \the\everyafterpagebody}
-
-\newtoks\pageboundsettings
-
-% \prependtoks \initializepaper \to \pageboundsettings
-
-% not here
-
-\newif\ifpagebreakdisabled \pagebreakdisabledfalse
-
-\newconstant\testpagemethod % todo: \testnewpage[method=,lines=,voffset=]
-\newconstant\testpagetrigger
-
-\def\testpage {\dotripleempty\dotestpage[\plusone ]} %
-\def\testpageonly{\dotripleempty\dotestpage[\plustwo ]} % no penalties added to the mvl
-\def\testpagesync{\dotripleempty\dotestpage[\plusthree]} % force sync
-
-\def\dotestpage[#1][#2][#3]% don't change, only add more methods
- {\relax % needed before \if
- \ifpagebreakdisabled
- \endgraf
- \else
- % new from here
- \ifcase\testpagetrigger
- \endgraf
- \or
- \ifvmode
- \dosomebreak\allowbreak
- \else % indeed?
- \vadjust{\allowbreak}%
- \endgraf
- \fi
- \fi
- % till here
- \ifdim\pagegoal<\maxdimen \relax
- \ifdim\pagetotal<\pagegoal \relax
- \scratchdimen\lineheight
- \multiply\scratchdimen#2\relax
- \advance\scratchdimen \pagetotal
- \ifdim\lastskip<\parskip
- \advance\scratchdimen \parskip
- \fi
- \ifthirdargument
- \advance\scratchdimen#3\relax
- \fi
- \ifcase\testpagemethod
- \ifdim\scratchdimen>.99\pagegoal
- \penalty-\!!tenthousand\relax
- \fi
- \or
- \advance\scratchdimen-\pagegoal
- \ifdim\scratchdimen>-\lineheight
- \penalty-\!!tenthousand\relax
- \fi
- \or
- \getnoflines\pagegoal
- \advance\scratchdimen-\noflines\lineheight \relax
- \ifdim\scratchdimen>-\lineheight
- \penalty-\!!tenthousand\relax
- \fi
- \or % same as 0 but more accurate
- \advance\scratchdimen-10\s!sp\relax
- \ifdim\scratchdimen>\pagegoal
- \penalty-\!!tenthousand\relax
- \fi
- \fi
- \else
- \ifnum#1=\plusthree
- \flushpagesofar
- \fi
- \fi
- \else
- \ifnum#1=\plusone\goodbreak\fi
- \fi
- \fi}
-
-\def\flushpagesofar
- {\endgraf
- \ifdim\pagetotal>\pagegoal
- \ifdim\dimexpr\pagetotal-\pageshrink\relax>\pagegoal
- \goodbreak % \penalty0
- \else
- \page
- \fi
- \else
- \fi}
-
-\def\testcolumn
- {\dodoubleempty\dotestcolumn}
-
-\def\dotestcolumn[#1][#2]%
- {%\relax % needed before \if !
- \endgraf
- \ifdim\pagegoal<\maxdimen \ifdim\pagetotal<\pagegoal % \relax
- \scratchdimen\pagegoal
- \advance\scratchdimen-\pagetotal
- \ifdim\lastskip<\parskip
- \advance\scratchdimen \parskip
- \fi
- \ifsecondargument
- \advance\scratchdimen#2%
- \fi
- \getrawnoflines\scratchdimen % raw !
- % \message{[\number#1>\number\noflines ?}\wait
- \ifnum#1>\noflines
- \column
- \fi
- \else
- \penalty-\!!tenthousand % untested ! ! \column
- \fi \fi}
-
-\ifdefined\resetcurrentstructuremarkswithpage \else
- \let\resetcurrentstructuremarkswithpage\relax
-\fi
-
-\def\page{\pagebreak} % the short form of \pagebreak (mult-com one)
-
-\def\resetpagebreak
- {\global\pagebreakdisabledfalse}
-
-\def\simplifypagebreak
- {\def\dopagebreak[##1]{\goodbreak}}
-
-\def\disablepagebreaks
- {\def\dopagebreak[##1]{}}
-
-\def\executepagebreakhandler#1%
- {\edef\@@pagespecification{#1}%
- \ifcsname\??pe:\@@pagespecification\endcsname
- \csname\??pe:\@@pagespecification\endcsname
- \else\ifcsname\??pe::\@@pagespecification\endcsname
- \executepagebreakhandlers{\csname\??pe::\@@pagespecification\endcsname}%
- \else
- \csname\??pe:\s!unknown\endcsname
- \fi\fi}
-
-\long\def\installpagebreakhandler#1#2%
- {\long\setvalue{\??pe:#1}{#2}}
-
-\unexpanded\def\pagebreak
- {\dosingleempty\dopagebreak}
-
-\def\dopagebreak[#1]% so, page ornaments are reset after a pagebreak command, unless set
- {\bgroup
- \flushnotes
- \edef\prevrealpageno{\the\realpageno}%
- \ifcase\pageornamentstate \or
- % disable reset after shipout
- \global\pageornamentstate\plustwo
- \fi
- \iffirstargument % or if empty i.e. []
- \executepagebreakhandlers{#1}%
- \else % so, no pagebreak when \pagebreak[] ! ! !
- \executepagebreakhandler\v!yes
- \fi
- \ifnum\prevrealpageno<\realpageno
- % there must have been a reason why i added the ifcase
- % but it fails on tests/mkiv/pages/ornaments-001.tex
- % as WS found out so we have to wait till the next side
- % effect shows up
- % \ifcase\pageornamentstate\or
- \global\pageornamentstate\zerocount
- % \fi
- \fi
+\ifdefined\nestednewbox \else \newbox\nestednextbox \fi % hm, still needed?
+
+\prependtoks
+ \let\nextbox\nestednextbox
+\to \everybeforepagebody
+
+\def\page_boxes_constructed_page#1#2%
+ {\vbox\bgroup % intercept spurious spaces
+ \the\everybeforepagebody
+ \starttextproperties
+ \dontshowboxes
+ \checkmarginblocks
+ \the\beforeeverypage
+ \normalexpanded{\global\beforepage\emptytoks\the\beforepage}%
+ \inpagebodytrue
+ \page_boxes_constructed_page_body#1#2%
+ \normalexpanded{\global\afterpage \emptytoks\the\afterpage }%
+ \the\aftereverypage
+ \resetpagebreak
+ \resetlayouttextlines % will go to \aftereverypage
+ \stoptextproperties
+ \the\everyafterpagebody
\egroup}
-\def\executepagebreakhandlers#1%
- {\processcommacommand[#1]\executepagebreakhandler}
-
-\installpagebreakhandler \s!dummy
- {\ejectinsert
- \gotonextpage
- \ejectdummypage}
-
-\installpagebreakhandler \v!frame
- {\page\bgroup\showframe\page[\v!empty]\egroup}
-
-\installpagebreakhandler \s!unknown
- {\doifinstringelse{+}\@@pagespecification
- {\ejectinsert
- \gotonextpage
- \dorecurse\@@pagespecification\ejectdummypage}
- {\doifnumberelse\@@pagespecification
- {\ejectinsert
- \gotonextpage
- \doloop
- {\ifnum\userpageno<\@@pagespecification\relax
- \ejectdummypage
- \else
- \exitloop
- \fi}}
- {}}}
-
-\installpagebreakhandler \s!default
- {} % do nothing if empty
-
-\installpagebreakhandler \v!reset
- {% better not: \global\pageornamentstate\zerocount
- \resetpagebreak}
-
-\installpagebreakhandler \v!disable
- {\global\pagebreakdisabledtrue}
-
-\installpagebreakhandler \v!yes
- {\ifpagebreakdisabled\else
- \ejectinsert
- \gotonextpage
- \ifinsidecolumns % this will move to MUL
- \ejectpage % anders soms geen overgang
- \fi
- \fi}
-
-\installpagebreakhandler \v!makeup % ??
- {\ifpagebreakdisabled\else
- \eject
- \fi}
-
-\installpagebreakhandler \v!blank
- {\ifcase\pageornamentstate
- \global\pageornamentstate\plusone
- \fi}
-
-\installpagebreakhandler \v!no
- {\ifpagebreakdisabled\else
- \dosomebreak\nobreak
- \fi}
+%D Shipout control.
-\installpagebreakhandler \v!preference
- {\ifpagebreakdisabled\else
- \ifinsidecolumns % this will move to MUL
- \dosomebreak\goodbreak
- \else
- \testpage[3][\zeropoint]%
- \fi
- \fi}
-
-\installpagebreakhandler \v!bigpreference
- {\ifpagebreakdisabled\else
- \ifinsidecolumns % this will move to MUL
- \dosomebreak\goodbreak
- \else
- \testpage[5][\zeropoint]%
- \fi
- \fi}
-
-\installpagebreakhandler \v!empty
- {\ejectinsert
- \gotonextpage
- \doifnotvalue{\??tk\v!header\c!state}\v!stop{\setupheader[\c!state=\v!empty]}%
- \doifnotvalue{\??tk\v!footer\c!state}\v!stop{\setupfooter[\c!state=\v!empty]}%
- \ejectdummypage}
-
-\installpagebreakhandler \v!left
- {\ejectinsert
- \gotonextpageX % will become \gotonextpage
- \doifbothsidesoverruled{}{\resetcurrentstructuremarkswithpage\ejectdummypage}{}}
-
-\installpagebreakhandler \v!right
- {\ejectinsert
- \gotonextpageX % will become \gotonextpage
- \doifbothsidesoverruled{}{}{\resetcurrentstructuremarkswithpage\ejectdummypage}}
-
-\installpagebreakhandler \v!even
- {\page
- \doifoddpageelse{\resetcurrentstructuremarkswithpage\ejectdummypage}\donothing}
-
-\installpagebreakhandler \v!odd
- {\page
- \doifoddpageelse\donothing{\resetcurrentstructuremarkswithpage\ejectdummypage}}
-
-\installpagebreakhandler \v!quadruple % not yet ok inside columnsets
- {\ifdoublesided
- \!!counta\realpageno
- \!!countb\realpageno
- \divide\!!counta 4
- \divide\!!countb 2
- \ifnum\!!counta=\!!countb
- \else
- \executepagebreakhandler\v!yes
- \executepagebreakhandler\v!empty
- \executepagebreakhandler\v!empty
- \fi
- \fi}
+\newconditional\c_otr_shipout_enabled \settrue\c_otr_shipout_enabled
-\installpagebreakhandler \v!last
- {\ejectinsert
- \gotonextpageX % will become \gotonextpage
- \relax
- \doifbothsidesoverruled
- {\shipoutfacingpage}
- {}
- {\noheaderandfooterlines \ejectdummypage}%
- \filluparrangedpages}
-
-\installpagebreakhandler \v!lastpage % handy for backpage preceded by empty pages
- {\executepagebreakhandler\v!yes
- \ifdoublesided
- \executepagebreakhandler\v!left
- \executepagebreakhandler\v!empty
- \executepagebreakhandler\v!empty
+\def\page_otr_shipout
+ {\ifconditional\c_otr_shipout_enabled
+ \expandafter\page_otr_shipout_yes
+ \else
+ \expandafter\page_otr_shipout_nop
\fi}
-\installpagebreakhandler \v!start
- {\globallet\shipout\normalshipout}
-
-\installpagebreakhandler \v!stop
- {\globallet\shipout\noshipout}
-
-% nb: \executepagebreakhandler\v!hoofd in other ones
+\let\page_otr_shipout_yes\normalshipout
-\installpagebreakhandler \v!header
- {\doifnotvalue{\??tk\v!header\c!state}\v!stop{\setupheader[\c!state=\v!empty]}}
-
-\installpagebreakhandler \v!footer
- {\doifnotvalue{\??tk\v!footer\c!state}\v!stop{\setupfooter[\c!state=\v!empty]}}
-
-% \definepagebreak
-% [chapter]
-% [yes,header,right]
-%
-% \setuphead
-% [chapter]
-% [page=chapter,
-% header=empty,
-% footer=chapter]
-%
-% \definepagebreak % untested
-% [lastpage]
-% [left,{empty,right},{empty,left}]
-
-% public page handler, beware: definepage already in use (core-ref)
-%
-% \definepagebreak[instance][forsure]
-% \definepagebreak[forsure][yes,+4]
-
-\unexpanded\def\definepagebreak
- {\dodoubleargument\dodefinepagebreak}
-
-\def\dodefinepagebreak[#1][#2]% non recursive, meant for simple mappings
- {\setvalue{\??pe::#1}{#2}}
-
-\long\def\installcolumnbreakhandler#1#2#3% #1=otr-id #2=tag
- {\long\setvalue{\??cn:#1:#2}{#3}}
-
-\unexpanded\def\definecolumnbreak
- {\dodoubleargument\dodefinecolumnbreak}
-
-\def\dodefinecolumnbreak[#1][#2]% non recursive, meant for simple mappings
- {\setvalue{\??cn::#1}{#2}}
-
-%\def\columnbreak
-% {\dosingleempty\docolumnbreak}
-%
-%\def\docolumnbreak[#1]%
-% {\expanded{\nextcolumn[\executeifdefined{\??cn::#1}{#1}]}}
-
-\definecomplexorsimple\columnbreak
-
-\def\simplecolumnbreak
- {\executecolumnbreakhandler\v!yes}
-
-\def\complexcolumnbreak[#1]% if empty, do nothing and avoid processing
- {\doifsomething{#1}{\executecolumnbreakhandlers{#1}}}
-
-\def\executecolumnbreakhandlers#1%
- {\processcommacommand[#1]\executecolumnbreakhandler}
-
-\def\executecolumnbreakhandler#1% here no commalist
- {\edef\@@columnspecification{#1}%
- \doifdefinedelse{\??cn:\OTRidentifier:\@@columnspecification}
- {\getvalue{\??cn:\OTRidentifier:\@@columnspecification}}
- {\doifdefinedelse{\??cn::\@@columnspecification}
- {\executecolumnbreakhandlers{\getvalue{\??cn::\@@columnspecification}}}
- {\getvalue{\??cn:\OTRidentifier:\s!unknown}}}}
-
-%let\nextcolumn\columnbreak
-\let\column \columnbreak
-
-% We don't want spurious last pages (due to left over marks):
-
-\def\noshipout
- {\writestatus\m!system{ignoring further shipouts}%
+\unexpanded\def\page_otr_shipout_nop
+ {\writestatus\m!system{ignoring shipout of real page \the\realpageno}%
\global\advance\realpageno\minusone % else no flush of resources
\dowithnextbox{\deadcycles\zerocount}}
-% \def\doignorerestoftext
-% {\ifarrangingpages \else \ifnum\textlevel>\zerocount \else
-% \globallet\shipout\noshipout
-% \fi \fi}
-%
-% better:
-
-\def\doignorerestoftext
- {\ifarrangingpages \else \ifnum\textlevel=\plusone
- \globallet\shipout\noshipout
- \fi \fi}
-
-\let\ignorerestoftext\donothing
-
-\prependtoks % only ignore in a symmetrical doc
- \globallet\ignorerestoftext\doignorerestoftext
-\to \everystarttext
-
-% \appendtoks
-% \ignorerestoftext
-% \to \everylastshipout
-
-\newif\ifpageselected \pageselectedtrue
-\newif\ifselectingpages \selectingpagesfalse
-\newif\ifprocessingpages\processingpagestrue
-
-\let\pageselection \empty
-\let\currentpageselection\empty
-\let\aftershipout \relax
-\let\beforeshipout \relax
-
-\def\dodobeforeshipout#1%
- {\global\let\beforeshipout\relax
- \csname\??pg#1\c!before\endcsname}
-
-\def\dobeforeshipout
- {\doifsomething\currentpageselection
- {\processcommacommand[\currentpageselection]\dodobeforeshipout}}
-
-\def\dododoaftershipout#1%
- {\global\let\aftershipout\relax
- \global\let\currentpageselection\empty
- \csname\??pg#1\c!after\endcsname}
-
-\def\dodoaftershipout#1%
- {\doifelsevalue{\??pg#1\c!option}\v!doublesided
- {\doifbothsidesoverruled
- {\dododoaftershipout{#1}}
- {\dododoaftershipout{#1}}
- {}}
- {\dododoaftershipout{#1}}}
-
-\def\doaftershipout
- {\doifsomething\currentpageselection
- {\processcommacommand[\currentpageselection]\dodoaftershipout}}
-
-\def\docouplepage[#1][#2]%
- {\getparameters
- [\??pg]
- [\c!before=,
- \c!after=,
- \c!option=,
- #2]%
- \def\docommand##1%
- {\getparameters
- [\??pg##1]
- [\c!before=\@@pgbefore,
- \c!after=\@@pgafter,
- \c!option=\@@pgoption]}%
- \processcommalist[#1]\docommand}%
-
-\def\couplepage
- {\dodoubleargument\docouplepage}
-
-\def\doprocesspage[#1][#2]%
- {\processaction
- [#2]
- [\v!yes=>\global\processingpagestrue,
- \v!no=>\global\processingpagesfalse]%
- \gdef\pageselection{#1}%
- \global\selectingpagestrue
- \global\pageselectedfalse}
-
-\def\processpage
- {\dodoubleargument\doprocesspage}
-
-\def\resetselectiepagina
- {\ifselectingpages
- \doifbothsidesoverruled{\global\pageselectedfalse}{}{\global\pageselectedfalse}%
- \fi}
-
-\newif\ifregistertextareas
-\newif\iftracetextareas
-
-\newbox\registertextbox
-
-% \def\registeredtextarea#1#2#3% #1=lower-dp #2=correct-ht #3=box
-% {\hbox{\box#3}}
-
-\def\enabletextarearegistration{\global\registertextareastrue}
-
-\def\registeredtextarea#1#2#3% #1=lower-dp #2=correct-ht #3=box
- {\hbox\bgroup
- \ifregistertextareas \ifx\registerMPtextarea\undefined \else
- \setbox\registertextbox\emptyhbox
- \wd\registertextbox\wd#3%
- \ht\registertextbox\ht#3%
- \dp\registertextbox\dp#3%
- \ifcase#1\or % 1
- \setbox\registertextbox\hbox{\lower\strutdp\box\registertextbox}%
- \fi
- \ifcase#2\or % 1
- \setbox\registertextbox\hbox{\raise\topskip\hbox{\lower\strutht\box\registertextbox}}%
- \dp\registertextbox\strutdp
- \fi
- \dp\registertextbox\strutdp % needed
- %\setbox\registertextbox\hbox
- % {\iftracetextareas\gray\boxrulewidth2pt\ruledhbox\fi
- % {\registerMPtextarea{\box\registertextbox}}}%
- \setbox\registertextbox\hbox
- {\registerMPtextarea{\box\registertextbox}}%
- \smashbox\registertextbox
- \box\registertextbox
- \fi \fi
- \box#3%
- \egroup}
+% \let\shipout\page_otr_shipout_nop % we don't support direct user \shipouts (weird: this does not work, bug?)
-%D \macros
-%D {setupoppositeplacing,startopposite}
+%D The \type {\processpage} command has become obsolete. It's original
+%D purpose was to flush only parts of a document but nowadays we have
+%D project structure and modes. This is just one of those very early
+%D features that no longer makes sense.
%D
-%D \starttyping
-%D \starttext
-%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test
-%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test
-%D \stoptext
-%D \stoptyping
-
-% Moved from page-mar.tex, made english, cleaned up, but still to be
-% redesigned
-
-\newbox\facingpage
-
-\unexpanded\def\setupoppositeplacing
- {\dodoubleargument\getparameters[\??np]}
-
-\unexpanded\def\startopposite
- {\dowithnextboxcontent
- {\hsize\makeupwidth}%
- {\global\setbox\facingpage\vbox
- {\ifvoid\facingpage
- \@@npbefore
- \else
- \@@npinbetween
- \unvbox\facingpage
- \fi
- \box\nextbox}}%
- \vbox\bgroup}
-
-\unexpanded\def\stopopposite
- {\egroup}
-
-\def\finishfacingpage
- {\ifvoid\facingpage\else
- \global\setbox\facingpage\vbox to \makeupheight
- {\unvbox\facingpage
- \@@npafter
- \vss}%
- \fi}
-
-\def\shipoutfacingpage
- {\doif\@@npstate\v!start
- {\ifvoid\facingpage\else
- \ifnum\realpageno>\plusone
- \bgroup
- \pageornamentstate\plusone
- \finishfacingpage
- \myshipout{\buildpagebody\box\facingpage}%
- \egroup
- \else
- \global\setbox\facingpage\emptybox
- \fi
- \fi}}
-
-\setupoppositeplacing
- [\c!state=\v!start,
- \c!before=,
- \c!inbetween=\blank,
- \c!after=]
+%D The \type {\couplepage} command has become obsolete. It's original
+%D purpose was to provide hooks for printer directives (like choosing
+%D different paper trays).
\protect \endinput
+
+% bewaren tvb documentatie
+%
+% \hbox to \hsize
+% {\en
+% \switchnaarkorps[5pt]%
+% \emergencystretch2em
+% \dimen0=\baselineskip
+% \baselineskip=\dimen0 plus 1pt
+% \hsize=.2\hsize
+% \vsize=2\hsize
+% \ruledvbox to \vsize{\input tufte \par}\hss
+% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth}\hss
+% \ruledvbox to \vsize{\input tufte \par\kern0pt}\hss
+% \ruledvbox to \vsize{\input tufte \par\vfill}\hss
+% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth\vfill}}
+%
+% \hbox to \hsize
+% {\en
+% \switchnaarkorps[5pt]%
+% \emergencystretch2em
+% \dimen0=\baselineskip
+% \baselineskip=\dimen0 plus 1pt
+% \hsize=.18\hsize
+% \vsize=2.5\hsize
+% \setbox0=\vbox{\input tufte\relax}%
+% \ruledvbox to \vsize{\unvcopy0}\hss
+% \ruledvbox to \vsize{\unvcopy0\kern-\dp0}\hss
+% \ruledvbox to \vsize{\unvcopy0\kern0pt}\hss
+% \ruledvbox to \vsize{\unvcopy0\vfill}\hss
+% \ruledvbox to \vsize{\unvcopy0\kern-\dp0\vfill}}
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 66ea7b79a..68337b937 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -24,13 +24,6 @@
\unprotect
-%D First we get rid of the funny \TEX\ offset defaults of one
-%D inch by setting them to zero (actually this is already done
-%D elsewhere but it's good to notice).
-
-\voffset \zeropoint
-\hoffset \zeropoint
-
%D The dimensions related to layout areas are represented by
%D real dimensions.
@@ -75,10 +68,10 @@
%D The next series of dimensions are complemented by left
%D and rights ones.
-\newdimen \margindistance
-\newdimen \edgedistance
-\newdimen \marginwidth
-\newdimen \edgewidth
+\newdimen\margindistance
+\newdimen\edgedistance
+\newdimen\marginwidth
+\newdimen\edgewidth
%D Because a distance does not really makes sense when there
%D is no area, we use a zero distance in case there is no
@@ -86,17 +79,17 @@
%D The horizontal distances are:
-\newdimen \leftedgedistance
-\newdimen \rightedgedistance
-\newdimen \leftmargindistance
-\newdimen \rightmargindistance
+\newdimen\leftedgedistance
+\newdimen\rightedgedistance
+\newdimen\leftmargindistance
+\newdimen\rightmargindistance
%D The vertical distances are:
-\newdimen \topdistance
-\newdimen \headerdistance
-\newdimen \footerdistance
-\newdimen \bottomdistance
+\newdimen\topdistance
+\newdimen\headerdistance
+\newdimen\footerdistance
+\newdimen\bottomdistance
%D We need to calculate the extra distances:
@@ -123,16 +116,15 @@
\appendtoks
\ifx\currentlayout\v!reset
- \let\currentlayout\empty
- \letlayoutparameter\c!state\v!normal % global ?
+ \let\currentlayout\empty
+ \letlayoutparameter\c!state\v!normal % global ?
\fi
\globallet\currentlayout\currentlayout
\to \everysetuplayout
\appendtoks
- \recalculatelayout
- \dochecknextlayout
- \presetcenterpagebox
+ \pages_layouts_synchronize
+ \page_layouts_check_next
\to \everysetuplayout
\def\doiflayoutdefinedelse#1%
@@ -144,7 +136,7 @@
\def\layoutdistance#1#2{\ifdim\zeropoint<#1#2\else\zeropoint\fi}
-\def\setlayoutdimensions
+\def\page_layouts_set_dimensions
{\global\naturalmarginwidth \layoutparameter\c!margin
\global\naturaledgewidth \layoutparameter\c!edge
\global\naturalmargindistance \layoutparameter\c!margindistance
@@ -173,7 +165,7 @@
\global\bottomdistance \layoutdistance\bottomheight \naturalbottomdistance
}
-\def\setlayoutdistances % local in \setreducedvsize
+\def\page_layouts_set_distances % local in \setreducedvsize
{\headerdistance\layoutdistance\headerheight\naturalheaderdistance
\footerdistance\layoutdistance\footerheight\naturalfooterdistance}
@@ -192,7 +184,10 @@
\def\outerspacewidth {\rightorleftpageaction\cutspace\backspace}
\def\innerspacewidth {\rightorleftpageaction\backspace\cutspace}
-\newtoks\extralayoutcalculations \def\calculatelayoutextras{\the\extralayoutcalculations}
+\newtoks\extralayoutcalculations
+
+\def\page_layouts_calculate_extras
+ {\the\extralayoutcalculations}
\newtoks\everyswapmargins % watch the order !
@@ -212,6 +207,9 @@
\swapmacros\innersidetotal \outersidetotal
\to \everyswapmargins
+%D The papersize macros have a long history and we don't want
+%D to change the commands so they keep looking a bit complex.
+
%D \macros
%D {definepapersize}
%D
@@ -221,41 +219,7 @@
%D which case the second argument is an assignment.
%D
%D \showsetup{definepapersize}
-
-\unexpanded\def\definepapersize
- {\dodoubleempty\dodefinepapersize}
-
-\unexpanded\def\definepapersize
- {\dotripleempty\dodefinepapersize}
-
-\def\dodefinepapersize[#1][#2][#3]%
- {\ifsecondargument
- \doifsomething{#1} % to be sure
- {\doifassignmentelse{#2}
- {\getparameters
- [\??pp#1]% geen \c!scale, scheelt hash ruimte
- [\c!width=\@@ppwidth,\c!height=\@@ppheight,\c!offset=\@@ppoffset,#2]}
- {\setvalue{\??pp:1:#1}{#2}%
- \setvalue{\??pp:2:#1}{#3}}}%
- \else
- \getparameters[\??pp][#1]%
- \setuppapersize % hm. this will freeze !
- \fi}
-
-%D For the moment we need to fake this macro.
-
-\ifx\setuppapersize\undefined
- \let\setuppapersize\relax
-\fi
-
-%D We set the defaults to the dimensions of an A4 sheet of
-%D paper.
-
-\definepapersize
- [\c!width=210mm,
- \c!height=297mm,
- \c!offset=\zeropoint]
-
+%D
%D Yet undocumented, let's see if it gets noticed.
%D
%D \starttyping
@@ -276,7 +240,7 @@
%D Page 6. \page
%D \stoptext
%D \stoptyping
-
+%D
%D \macros
%D {setuppaper,setuppapersize}
%D
@@ -288,122 +252,270 @@
%D We keep track of these features with the following
%D variables.
-\newconditional\papermirror \newconditional\printmirror
-\newconstant \paperorientation \newconstant \printorientation
-\newconstant \paperreverse \newconstant \printreverse
-\newconditional\paperlandscape \newconditional\printlandscape
- \newconditional\printnegatecolors
- \newconditional\printdoublesided
+\installcommandhandler \??pp {layouttarget} \??pp % so this is a sort of mix, not really a user command / maybe switch handler
+
+\newconditional\c_page_target_paper_mirror
+\newconstant \c_page_target_paper_orientation
+\newconstant \c_page_target_paper_reverse
+\newconditional\c_page_target_paper_landscape
+\newconditional\c_page_target_paper_negate
+
+\newconditional\c_page_target_print_mirror
+\newconstant \c_page_target_print_orientation
+\newconstant \c_page_target_print_reverse
+\newconditional\c_page_target_print_landscape
+\newconditional\c_page_target_print_negate
+\newconditional\c_page_target_print_doublesided
+
+\let\v_page_target_left_fill \relax
+\let\v_page_target_right_fill \relax
+\let\v_page_target_top_fill \relax
+\let\v_page_target_bottom_fill\relax
+
+\let\papersize \empty
+\let\printpapersize\empty
+
+\def\v_page_target_top {\namedlayouttargetparameter\papersize\c!top }
+\def\v_page_target_bottom {\namedlayouttargetparameter\papersize\c!bottom}
+\def\v_page_target_left {\namedlayouttargetparameter\papersize\c!left }
+\def\v_page_target_right {\namedlayouttargetparameter\papersize\c!right }
+\def\v_page_target_method {\rootlayouttargetparameter \c!method}
+\def\v_page_target_scale {\rootlayouttargetparameter \c!scale }
+\def\v_page_target_nx {\numexpr\rootlayouttargetparameter \c!nx \relax}
+\def\v_page_target_ny {\numexpr\rootlayouttargetparameter \c!ny \relax}
+\def\v_page_target_dx {\dimexpr\rootlayouttargetparameter \c!dx \relax}
+\def\v_page_target_dy {\dimexpr\rootlayouttargetparameter \c!dy \relax}
+\def\v_page_target_width {\dimexpr\rootlayouttargetparameter \c!width \relax}
+\def\v_page_target_height {\dimexpr\rootlayouttargetparameter \c!height \relax}
+\def\v_page_target_topoffset{\dimexpr\rootlayouttargetparameter \c!topoffset\relax}
+\def\v_page_target_backspace{\dimexpr\rootlayouttargetparameter \c!backspace\relax}
+\def\v_page_target_offset {\dimexpr\rootlayouttargetparameter \c!offset \relax}
+
+\def\v_page_target_xy {\numexpr\v_page_target_nx*\v_page_target_ny\relax}
+
+% Normally we will not use this command directly but for now it
+% works out okay. In th efuture we might use more of the related
+% commands.
+
+\setuplayouttarget
+ [% these are rather special
+ \c!nx=1,
+ \c!ny=1,
+ \c!dx=\zeropoint,
+ \c!dy=\zeropoint,
+ \c!topspace=\zeropoint,
+ \c!backspace=\zeropoint,
+ \c!width=\zeropoint,
+ \c!height=\zeropoint,
+ %
+ \c!method=\v!normal,
+ \c!option=\v!max,
+ \c!alternative=\v!normal,
+ %
+ \c!scale=1,
+ \c!offset=\zeropoint,
+ %
+ \c!top=,
+ \c!bottom=,
+ \c!left=,
+ \c!right=,
+ %
+ \c!location=]
+
+% \definepapersize[name][A4][A3]
+% \definepapersize[name][settings]
-\let\papersize\empty \let\printpapersize\empty
+\unexpanded\def\definepapersize
+ {\dotripleempty\define_paper_size}
-\def\paperscale{1}
+\def\define_paper_size[#1][#2][#3]%
+ {\edef\currentlayouttarget{#1}%
+ \ifx\currentlayouttarget\empty
+ % invalid target
+ \else
+ \doifassignmentelse{#2}
+ {\definelayouttarget[#1][#2]}
+ {\setevalue{\??pp:1:#1}{#2}%
+ \setevalue{\??pp:2:#1}{#3}}%
+ \fi}
-\unexpanded\def\setuppaper[#1]%
- {\getparameters[\??pp][\c!paper=,\c!page=,#1]%
- \edef\@@ppxy{\the\numexpr\@@ppnx*\@@ppny\relax}%
- \doifelsenothing\@@pppage
- {\doifelsenothing\@@pppaper
- {} % {\setuppapersize} % added, removed, no need for, too tricky, mag-01 (fixed by freezing pp's)
- {\dodosetuppapersize[\papersize][\@@pppaper]}}
- {\doifelsenothing\@@pppaper
- {\dodosetuppapersize[\@@pppage][\printpapersize]}
- {\dodosetuppapersize[\@@pppage][\@@pppaper]}}}
+\appendtoks
+ \letvalue{\??pp:c:\currentlayouttarget}\relax
+\to \everydefinelayouttarget
+
+\def\page_paper_the_paper_size#1{\ifcsname\??pp:1:#1\endcsname\csname\??pp:1:#1\endcsname\else#1\fi}
+\def\page_paper_the_print_size#1{\ifcsname\??pp:2:#1\endcsname\csname\??pp:2:#1\endcsname\else#1\fi}
+
+% \setuppaper [page=A4,paper=A3] % the k/v variant, changes the current page mapping
+% \setuppapersize[A4][a=b,c=d] % the k/v variant, changes nothing, just settings
+% \setuppapersize[A4][A3] % changes the current page mapping
+
+\let\page_paper_reinstate\relax
+\let\page_paper_restore \relax
\unexpanded\def\setuppapersize
- {\dodoubleempty\dosetuppapersize}
-
-\def\dosetuppapersize[#1][#2]%
- {\doifassignmentelse{#1}
- {\setuppaper[#1]}
- {\doifelsenothing{#2}
- {\expanded{\dodosetuppapersize
- [\executeifdefined{\??pp:1:#1}{#1}]%
- [\executeifdefined{\??pp:2:#1}{#1}]}}
- {\doifassignmentelse{#2}
- {\getparameters[\??pp\executeifdefined{\??pp:1:#1}{#1}][#2]}
- {\expanded{\dodosetuppapersize
- [\executeifdefined{\??pp:1:#1}{#1}]%
- [\executeifdefined{\??pp:1:#2}{#2}]}}}}}
-
-\let\reinstatepapersize\relax
-
-\def\adaptpapersize
- {\global\let\reinstatepapersize\restorepapersize
+ {\dodoubleempty\setup_paper_size}
+
+\unexpanded\def\setup_paper_size[#1][#2]%
+ {\iffirstargument
+ \doifassignmentelse{#1}
+ {\setup_paper_size_settings[#1]}
+ {\doifassignmentelse{#2}
+ {\setup_paper_size_settings_by_name[#1][#2]}
+ {\setup_paper_size_change_size[#1][#2]}}%
+ \else
+ \page_paper_restore
+ \fi}
+
+\unexpanded\def\setup_paper_size_settings[#1]%
+ {\let\currentlayouttarget\empty
+ \setupcurrentlayouttarget[#1]%
+ \edef\tmp_layouttarget_paper{\page_paper_the_paper_size{\layouttargetparameter\c!page }}%
+ \edef\tmp_layouttarget_print{\page_paper_the_print_size{\layouttargetparameter\c!paper}}%
+ \ifx\tmp_layouttarget_paper\empty
+ % forget about it
+ \else
+ \ifx\tmp_layouttarget_print\empty
+ \let\tmp_layouttarget_print\tmp_layouttarget_paper
+ \fi
+ \pages_paper_set_current[\tmp_layouttarget_paper][\tmp_layouttarget_print]%
+ \fi
+ \letlayouttargetparameter\c!page \papersize
+ \letlayouttargetparameter\c!paper\printpapersize}
+
+\unexpanded\def\setup_paper_size_settings_by_name[#1][#2]%
+ {\def\currentlayouttarget{\page_paper_the_paper_size{#1}}%
+ \setuplayouttarget[#2]}
+
+\unexpanded\def\setup_paper_size_change_size[#1][#2]%
+ {\doifelsenothing{#2}
+ {\pages_paper_set_current[#1][#1]}
+ {\pages_paper_set_current[#1][#2]}}
+
+\let\setuppaper\setup_paper_size_settings
+
+\unexpanded\def\adaptpapersize
+ {\global\let\page_paper_reinstate\page_paper_reinstate_indeed
\setuppapersize}
+\unexpanded\def\page_paper_reinstate_indeed
+ {\page_paper_restore
+ \global\let\page_paper_reinstate\relax}
+
\appendtoks
- \reinstatepapersize
- \global\let\reinstatepapersize\relax
+ \page_paper_reinstate
\to \everyaftershipout
-\def\dodosetuppapersize[#1][#2]%
- {\ifsecondargument
- \expanded{\dododosetuppapersize[#1][#2]}%
- \calculatehsizes
- \calculatevsizes
- \recalculatebackgrounds
- \recalculatelayout
- \else\iffirstargument
- \setuppapersize[#1][#2]%
- \else\ifx\papersize\undefined\else
- \restorepapersize
- \fi\fi\fi}
-
-% dimen freeze is a bit tricky, but catches local redundant calls
-% with values where e.g width is defined in terms of \paperwidth
-
-\def\dododosetuppapersize[#1][#2]%
- {\xdef\restorepapersize{\noexpand\setuppapersize[#1][#2]}%
- \dosetuppaperorientation{#1}\paperlandscape\paperorientation\paperreverse\papermirror
- \dosetuppaperorientation{#2}\printlandscape\printorientation\printreverse\printmirror
- \def\docommand##1%
- {\doifsomething{##1}{\doifdefined{\??pp##1\c!width}
- {\global\paperwidth \getvalue{\??pp##1\c!width}%
- \global\paperheight\getvalue{\??pp##1\c!height}%
- \ifinpagebody
- \setevalue{\??pp##1\c!height}{\the\paperheight}%
- \setevalue{\??pp##1\c!width }{\the\paperwidth }%
- \fi
- \calculatepaperoffsets{##1}%
- \xdef\papersize{##1}}}}%
- \processcommacommand[#1]\docommand
- \doifdefinedelse{\??pp#1\c!scale}
- {\edef\paperscale{\getvalue{\??pp#1\c!scale}}}
- {\edef\paperscale{1}}%
- \def\docommand##1%
- {\doifsomething{##1}{\doifdefined{\??pp##1\c!width}
- {\global\printpaperwidth \getvalue{\??pp##1\c!width}%
- \global\printpaperheight\getvalue{\??pp##1\c!height}%
- \ifinpagebody
- \setevalue{\??pp##1\c!height}{\the\printpaperheight}%
- \setevalue{\??pp##1\c!width }{\the\printpaperwidth}%
- \fi
- \xdef\printpapersize{##1}}}}%
- \processcommacommand[#2]\docommand
- \global\setdimentoatleast\paperwidth \onepoint
- \global\setdimentoatleast\paperheight \onepoint
- \global\setdimentoatleast\printpaperwidth \onepoint
- \global\setdimentoatleast\printpaperheight\onepoint
- \ifconditional\paperlandscape
+\unexpanded\def\page_paper_set_restore#1#2%
+ {\xdef\page_paper_restore{\pages_paper_set_current_indeed[#1][#2]}}
+
+\unexpanded\def\pages_paper_set_current[#1][#2]%
+ {\normalexpanded{\pages_paper_set_current_indeed
+ [\page_paper_the_paper_size{#1}]%
+ [\page_paper_the_print_size{#2}]}}
+
+\setvalue{\??pp:1:\v!reset }{\global\setfalse\c_page_target_paper_landscape
+ \global\setfalse\c_page_target_paper_mirror
+ \global\setfalse\c_page_target_paper_negate
+ \global\c_page_target_paper_orientation\uprotationangle
+ \global\c_page_target_paper_reverse \uprotationangle}
+\setvalue{\??pp:1:\v!landscape }{\global\settrue\c_page_target_paper_landscape}
+\setvalue{\??pp:1:\v!mirrored }{\global\settrue\c_page_target_paper_mirror}
+\setvalue{\??pp:1:\v!negative }{\global\settrue\c_page_target_paper_negate}
+\setvalue{\??pp:1:\v!rotated }{\global\c_page_target_paper_orientation\rightrotatioangle
+ \global\c_page_target_paper_reverse \leftrotatioangle}
+\setvalue{\??pp:1:\number\rightrotatioangle}{\global\c_page_target_paper_orientation\rightrotatioangle
+ \global\c_page_target_paper_reverse \leftrotatioangle}
+\setvalue{\??pp:1:\number\downrotatioangle }{\global\c_page_target_paper_orientation\downrotatioangle
+ \global\c_page_target_paper_reverse \zerocount}
+\setvalue{\??pp:1:\number\leftrotatioangle }{\global\c_page_target_paper_orientation\leftrotatioangle
+ \global\c_page_target_paper_reverse \rightrotatioangle}
+
+\setvalue{\??pp:1:\v!reset }{\global\setfalse\c_page_target_print_landscape
+ \global\setfalse\c_page_target_print_mirror
+ \global\setfalse\c_page_target_print_negate
+ \global\c_page_target_print_orientation\uprotationangle
+ \global\c_page_target_print_reverse \uprotationangle}
+\setvalue{\??pp:2:\v!landscape }{\global\settrue\c_page_target_print_landscape}
+\setvalue{\??pp:2:\v!mirrored }{\global\settrue\c_page_target_print_mirror}
+\setvalue{\??pp:2:\v!negative }{\global\settrue\c_page_target_print_negate}
+\setvalue{\??pp:2:\v!rotated }{\global\c_page_target_print_orientation\rightrotatioangle
+ \global\c_page_target_print_reverse \leftrotatioangle}
+\setvalue{\??pp:2:\number\rightrotatioangle}{\global\c_page_target_print_orientation\rightrotatioangle
+ \global\c_page_target_print_reverse \leftrotatioangle}
+\setvalue{\??pp:2:\number\downrotatioangle }{\global\c_page_target_print_orientation\downrotatioangle
+ \global\c_page_target_print_reverse \zerocount}
+\setvalue{\??pp:2:\number\leftrotatioangle }{\global\c_page_target_print_orientation\leftrotatioangle
+ \global\c_page_target_print_reverse \rightrotatioangle}
+
+\def\pages_paper_handle_page_option #1{\ifcsname\??pp:1:#1\endcsname\csname\??pp:1:#1\endcsname\fi}
+\def\pages_paper_handle_print_option#1{\ifcsname\??pp:2:#1\endcsname\csname\??pp:2:#1\endcsname\fi}
+
+\unexpanded\def\pages_paper_identify_target#1%
+ {\ifcsname\??pp:c:#1\endcsname
+ \edef\currentlayouttarget{#1}%
+ \fi}
+
+\unexpanded\def\pages_paper_set_current_indeed[#1][#2]%
+ {\edef\tmp_pages_asked_paper{\v!reset,#1}% can be the restores
+ \edef\tmp_pages_asked_print{\v!reset,#2}%
+ %
+ \page_paper_set_restore\tmp_pages_asked_paper\tmp_pages_asked_print
+ %
+ % locate page target
+ \let\currentlayouttarget\empty
+ \processcommacommand[\tmp_pages_asked_paper]\pages_paper_identify_target
+ \ifx\currentlayouttarget\empty
+ \let\currentlayouttarget\currentpage
+ \fi
+ \global\let\papersize\currentlayouttarget
+ \processcommacommand[\tmp_pages_asked_paper]\pages_paper_handle_page_option
+ \global\paperwidth \layouttargetparameter\c!width \relax
+ \global\paperheight\layouttargetparameter\c!height\relax
+ \ifdim\paperwidth<\onepoint
+ \global\paperwidth\onepoint
+ \fi
+ \ifdim\paperheight<\onepoint
+ \global\paperheight\onepoint
+ \fi
+ \ifconditional\c_page_target_paper_landscape
\doglobal\swapdimens\paperwidth\paperheight
\fi
- \ifconditional\printlandscape
- \doglobal\swapdimens\printpaperwidth\printpaperheight
+ \ifinpagebody % local freeze
+ \normalexpanded{\setlayouttargetparemeter\c!height{\the\paperheight}}%
+ \normalexpanded{\setlayouttargetparemeter\c!width {\the\paperwidth }}%
+ \fi
+ %
+ \pages_paper_set_offsets
+ % locate paper target
+ \processcommacommand[\tmp_pages_asked_print]\pages_paper_identify_target
+ \global\let\printpapersize\currentlayouttarget
+ \processcommacommand[\tmp_pages_asked_print]\pages_paper_handle_print_option
+ \global\printpaperwidth \layouttargetparameter\c!width \relax
+ \global\printpaperheight\layouttargetparameter\c!height\relax
+ \ifdim\printpaperwidth<\onepoint
+ \global\printpaperwidth\paperwidth
+ \fi
+ \ifdim\printpaperheight<\onepoint
+ \global\printpaperheight\paperheight
+ \fi
+ \ifconditional\c_page_target_print_landscape
+ \globalswapdimens\printpaperwidth\printpaperheight
\fi
% this check can be confusing, so we've added the possibility
% to bypass this test: \setuppapersize[option=fit]
- \doif\@@ppoption\v!max % \v!fit is
- {\bgroup
+ \edef\tmp_pages_asked_option{\rootlayouttargetparameter\c!option}%
+ \ifx\tmp_pages_asked_option\v!max % \v!fit is
+ \begingroup
% we need to pre-swap else we get the wrong paper size
- \ifnum\paperorientation=\rightrotatioangle
+ \ifnum\c_page_target_paper_orientation=\rightrotatioangle
\swapdimens\paperwidth\paperheight
- \else\ifnum\paperorientation=\leftrotatioangle
+ \else\ifnum\c_page_target_paper_orientation=\leftrotatioangle
\swapdimens\paperwidth\paperheight
\fi\fi
- \ifnum\printorientation=\rightrotatioangle
+ \ifnum\c_page_target_print_orientation=\rightrotatioangle
\swapdimens\printpaperwidth\printpaperheight
- \else\ifnum\printorientation=\leftrotatioangle
+ \else\ifnum\c_page_target_print_orientation=\leftrotatioangle
\swapdimens\printpaperwidth\printpaperheight
\fi\fi
\ifdim\paperheight>\printpaperheight
@@ -414,54 +526,25 @@
\global\printpaperwidth\paperwidth
\writestatus\m!system{print width forced to paper width}%
\fi
- \egroup}}
-
-\def\dosetuppaperorientation#1#2#3#4#5%
- {\global\setfalse#2%
- \global\setfalse#5%
- \global#3\uprotationangle
- \global#4\uprotationangle
- \global\setfalse\printnegatecolors
- \processallactionsinset
- [#1]
- [ \v!landscape=>\global\settrue#2,
- \v!mirrored=>\global\settrue#5,
- \v!rotated=>\global#3\rightrotatioangle
- \global#4\leftrotatioangle,
- \v!negative=>\global\settrue\printnegatecolors,
- 90=>\global#3\rightrotatioangle
- \global#4\leftrotatioangle,
- 180=>\global#3\downrotatioangle
- \global#4\zerocount,
- 270=>\global#3\leftrotatioangle
- \global#4\rightrotatioangle]}
-
-\ifx\calculatepaperoffsets\undefined
-
- \def\calculatepaperoffsets#1%
- {\scratchdimen\getvalue{\??pp#1\c!offset}%
- \global\advance\paperwidth -2\scratchdimen
- \global\advance\paperheight-2\scratchdimen}
-
-\fi
-
-\let\restorepapersize\relax
+ \endgroup
+ \fi
+ %\writestatus{layout target}{(\the\paperwidth,\the\paperheight) -> (\the\printpaperwidth,\the\printpaperheight)}%
+ \pages_layouts_synchronize}
-\ifx\setups\undefined \unexpanded\def\setups[#1]{\setdefaultpenalties} \fi
+\ifx\pages_paper_set_offsets\undefined
-% \newtoks \everybeforelayout \relax
-% \newtoks \everyafterlayout \relax
+ \def\pages_paper_set_offsets % will move
+ {\global\paperoffset\v_page_target_offset
+ \global\advance\paperwidth -2\paperoffset
+ \global\advance\paperheight-2\paperoffset}
-\def\recalculatelayout
- {\doifsomething{\layoutparameter\c!page\layoutparameter\c!paper}
- {\expanded{\dododosetuppapersize[\layoutparameter\c!page][\layoutparameter\c!paper]}}%
- \dorecalculatelayout}
+\fi
-\ifdefined\docheckgridsnapping \else \let\docheckgridsnapping\relax \fi
+\ifdefined\setups \else \unexpanded\def\setups[#1]{\setdefaultpenalties} \fi % still needed?
+\ifdefined\docheckgridsnapping \else \let\docheckgridsnapping\relax \fi
-\def\dorecalculatelayout
- {%\the\everybeforelayout
- \setups[\layoutparameter\c!preset]%
+\def\pages_layouts_synchronize
+ {\setups[\layoutparameter\c!preset]%
\global\leftmarginwidth \layoutparameter\c!leftmargin
\global\rightmarginwidth\layoutparameter\c!rightmargin
\global\leftedgewidth \layoutparameter\c!leftedge
@@ -472,43 +555,45 @@
\global\topheight \layoutparameter\c!top
\global\backspace \layoutparameter\c!backspace
\global\topspace \layoutparameter\c!topspace
- \setlayoutdimensions % the rest of the `dimensions'
+ \page_layouts_set_dimensions
\docheckgridsnapping
\doprocesslocalsetups{\layoutparameter\c!setups}% depends on gridsnapping !
\simplesetupwhitespace
\simplesetupblank
\setupinterlinespace[\v!reset]% \synchronizegloballinespecs
- \global\cutspace\layoutparameter\c!cutspace
- \relax
- \doifelse{\layoutparameter\c!width}\v!middle
- {\ifdim\cutspace=\zeropoint
- \global\cutspace\backspace
- \fi
- \global\makeupwidth\dimexpr\paperwidth-\backspace-\cutspace\relax}
- {\doifelse{\layoutparameter\c!width}\v!fit
- {\ifdim\cutspace=\zeropoint
- \global\cutspace\backspace
- \fi
- \global\makeupwidth\dimexpr\paperwidth-\cutspace\relax
- \scratchdimen\dimexpr\backspace
- -\leftedgewidth -\leftedgedistance
- -\leftmarginwidth-\leftmargindistance\relax
- \ifdim\scratchdimen<\zeropoint
- \scratchdimen\zeropoint
- \fi
- \global\advance\makeupwidth\dimexpr
- -\rightmargindistance-\rightmarginwidth
- -\rightedgedistance -\rightedgewidth
- -\scratchdimen\relax}
- {\global\makeupwidth\layoutparameter\c!width\relax
- \ifdim\cutspace=\zeropoint
- \global\cutspace\dimexpr\paperwidth-\makeupwidth-\backspace\relax
- % \else
- % A kind of inconsistent specification, but used
- % in for instance s-pre-19.tex; the cutspace is
- % used only for determining some kind of right
- % margin; don't use this in doublesided mode
- \fi}}%
+ \global\cutspace\layoutparameter\c!cutspace\relax
+ \edef\layout_parameter_width{\layoutparameter\c!width}%
+ \ifx\layout_parameter_width\v!middle
+ \ifdim\cutspace=\zeropoint
+ \global\cutspace\backspace
+ \fi
+ \global\makeupwidth\dimexpr\paperwidth-\backspace-\cutspace\relax
+ \else\ifx\layout_parameter_width\v!fit
+ \ifdim\cutspace=\zeropoint
+ \global\cutspace\backspace
+ \fi
+ \global\makeupwidth\dimexpr\paperwidth-\cutspace\relax
+ \scratchdimen\dimexpr\backspace
+ -\leftedgewidth -\leftedgedistance
+ -\leftmarginwidth-\leftmargindistance\relax
+ \ifdim\scratchdimen<\zeropoint
+ \scratchdimen\zeropoint
+ \fi
+ \global\advance\makeupwidth\dimexpr
+ -\rightmargindistance-\rightmarginwidth
+ -\rightedgedistance -\rightedgewidth
+ -\scratchdimen\relax
+ \else
+ \global\makeupwidth\layout_parameter_width\relax
+ \ifdim\cutspace=\zeropoint
+ \global\cutspace\dimexpr\paperwidth-\makeupwidth-\backspace\relax
+ % \else
+ % A kind of inconsistent specification, but used
+ % in for instance s-pre-19.tex; the cutspace is
+ % used only for determining some kind of right
+ % margin; don't use this in doublesided mode
+ \fi
+ \fi\fi
\scratchdimen\layoutparameter\c!bottomspace\relax
%\ifdim\scratchdimen=\zeropoint
% \scratchdimen\topspace
@@ -516,27 +601,30 @@
\global\bottomspace\layoutparameter\c!bottomspace\relax
\global\layoutlines0\number\layoutparameter\c!lines\relax % may be empty
\ifcase\layoutlines
- \doifelse{\layoutparameter\c!height}\v!middle
- {\ifdim\bottomspace=\zeropoint
- \global\bottomspace\topspace
- \fi
- \global\makeupheight\dimexpr\paperheight-\topspace-\bottomspace\relax}
- {\doifelse{\layoutparameter\c!height}\v!fit
- {\ifdim\bottomspace=\zeropoint
- \global\bottomspace\topspace
- \fi
- \global\makeupheight\dimexpr\paperheight-\bottomspace\relax
- \scratchdimen\dimexpr\topspace-\topheight-\topdistance\relax
- \ifdim\scratchdimen<\zeropoint
- \scratchdimen\zeropoint
- \fi
- \global\advance\makeupheight\dimexpr-\bottomdistance-\bottomheight-\scratchdimen\relax}
- {\global\makeupheight\layoutparameter\c!height\relax
- \ifdim\bottomspace=\zeropoint
- \global\bottomspace\dimexpr\paperheight-\makeupheight-\topspace\relax
- \else
- % inconsistent specification
- \fi}}%
+ \edef\layout_parameter_height{\layoutparameter\c!height}%
+ \ifx\layout_parameter_height\v!middle
+ \ifdim\bottomspace=\zeropoint
+ \global\bottomspace\topspace
+ \fi
+ \global\makeupheight\dimexpr\paperheight-\topspace-\bottomspace\relax
+ \else\ifx\layout_parameter_height\v!fit
+ \ifdim\bottomspace=\zeropoint
+ \global\bottomspace\topspace
+ \fi
+ \global\makeupheight\dimexpr\paperheight-\bottomspace\relax
+ \scratchdimen\dimexpr\topspace-\topheight-\topdistance\relax
+ \ifdim\scratchdimen<\zeropoint
+ \scratchdimen\zeropoint
+ \fi
+ \global\advance\makeupheight\dimexpr-\bottomdistance-\bottomheight-\scratchdimen\relax
+ \else
+ \global\makeupheight\layoutparameter\c!height\relax
+ \ifdim\bottomspace=\zeropoint
+ \global\bottomspace\dimexpr\paperheight-\makeupheight-\topspace\relax
+ % \else
+ % inconsistent specification
+ \fi
+ \fi\fi
\else
% beware, when the bodyfont changes (switched) this will change as well; implementing
% a global lineheight is tricky: should we take the bodyfont interlinespace or the one set
@@ -546,39 +634,47 @@
\layoutparameter\c!lines\lineheight-\strutheight+\topskip+
\headerdistance+\headerheight+\footerdistance+\footerheight\relax
\fi
- \backoffset\layoutparameter\c!horoffset
- \topoffset \layoutparameter\c!veroffset
- \global\setdimentoatleast\makeupwidth\onepoint
- \global\setdimentoatleast\makeupheight \onepoint
- % \checkcurrentlayout % here ?
- % \the\everyafterlayout
- \calculatelayoutextras
+ \backoffset\layoutparameter\c!horoffset\relax
+ \topoffset \layoutparameter\c!veroffset\relax
+ \ifdim\makeupwidth<\onepoint
+ \global\makeupwidth\onepoint
+ \fi
+ \ifdim\makeupheight<\onepoint
+ \global\makeupheight\onepoint
+ \fi
+ % \page_layouts_check_next % here ?
+ \page_layouts_calculate_extras
+ \page_target_check_centering
\calculatehsizes
\calculatevsizes
- \calculatepseudocolumns
+ \page_layouts_check_pseudo_columns
\recalculatebackgrounds}
-\def\calculatepseudocolumns
+\def\page_layouts_check_pseudo_columns
{\global\layoutcolumns\layoutparameter\c!columns
\global\layoutcolumndistance\layoutparameter\c!columndistance
\global\layoutcolumnwidth\dimexpr\makeupwidth-\layoutcolumns\layoutcolumndistance+\layoutcolumndistance\relax
- \global\divide\layoutcolumnwidth\layoutcolumns
- \dorecurse\layoutcolumns
- {\setxvalue{\??ly:c:\recurselevel}%
- {\the\numexpr\recurselevel-\plusone\relax\dimexpr\layoutcolumnwidth+\layoutcolumndistance\relax}}}
+ \ifnum\layoutcolumns>\plusone
+ \global\divide\layoutcolumnwidth\layoutcolumns
+ \dorecurse\layoutcolumns\page_layouts_check_pseudo_column
+ \fi}
-%\dorecurse\layoutcolumns
-% {\setxvalue{\??ly:c:\recurselevel}{\the\dimexpr
-% (\numexpr(\recurselevel-1)\dimexpr(\layoutcolumnwidth+\layoutcolumndistance))}}
+\def\page_layouts_check_pseudo_column
+ {\setxvalue{\??ly:c:\recurselevel}%
+ {\the\numexpr\recurselevel-\plusone\relax\dimexpr\layoutcolumnwidth+\layoutcolumndistance\relax}}
+
+\letvalue{\??ly:c:0}\zeropoint
\def\layoutcolumnoffset#1%
- {\executeifdefined{\??ly:c:#1}\zeropoint}
+ {\csname\??ly:c:\ifcsname\??ly:c:#1\endcsname#1\else0\fi\endcsname}
-\def\checklayout
- {\ifdim\makeupheight=\layoutlines\lineheight \else \recalculatelayout \fi}
+\def\pages_layouts_synchronize_at_start
+ {\ifdim\makeupheight=\layoutlines\lineheight \else % weird check
+ \pages_layouts_synchronize
+ \fi}
\appendtoks
- \checklayout
+ \pages_layouts_synchronize_at_start % still needed?
\to \everystarttext
% document:
@@ -587,48 +683,60 @@
%
% \startstandardmakeup[page=blank] ... \stopstandardmakeup
-\def\changetolayout#1%
+\ifdefined\lastpage \else \let\lastpage\!!plusone \fi
+
+\def\page_layouts_change#1%
{%\writestatus\m!layouts{changing to layout #1}%
\xdef\currentlayout{#1}%
- \recalculatelayout}
+ \pages_layouts_synchronize}
-\def\checkcurrentoddlayout
- {\ifcsname\namedlayouthash\v!odd\c!state\endcsname
- \doif{\namedlayoutparameter\v!odd\c!state}\v!start{\changetolayout\v!odd}%
- \fi}
+\let\changetolayout\page_layouts_change % also public
+
+\def\v_real_page_normal {\the\realpageno}
+\def\v_real_page_reverse{-\the\realpageno}
-\def\checkcurrentevenlayout
- {\ifcsname\namedlayouthash\v!even\c!state\endcsname
- \doif{\namedlayoutparameter\v!even\c!state}\v!start{\changetolayout\v!even}%
+\def\v_real_page_odd_or_even
+ {\ifodd\pagenoshift
+ \ifodd\realpageno\v!even\else\v!odd \fi
+ \else
+ \ifodd\realpageno\v!odd \else\v!even\fi
\fi}
-\ifx\lastpage\undefined
- \def\lastpage{1}
-\fi
+\let\v_real_page_current\v!current
-\def\reverserealfolio
- {\ifnum\lastpage>\plusone
- \ifnum\lastpage=\realfolio
- \v!last
- \else\ifnum\plusone=\realfolio
- \v!first
- \else
- \the\numexpr\realfolio-\lastpage\relax
- \fi\fi
+\def\v_real_page_named
+ {\ifnum\lastpage=\realpageno
+ \v!last
+ \else\ifnum\plusone=\realpageno
+ \v!first
\else
- \!!zerocount
- \fi}
+ \s!unknown
+ \fi\fi}
-\def\checkcurrentlayout % public and used in naw, so keep this name
- {\ifcsname\namedlayouthash\realfolio\c!state\endcsname
- \doif{\namedlayoutparameter\realfolio\c!state}\v!start{\changetolayout\realfolio}%
- \else\ifcsname\namedlayouthash\reverserealfolio\c!state\endcsname
- \doif{\namedlayoutparameter\reverserealfolio\c!state}\v!start{\changetolayout\reverserealfolio}%
- \else\ifcsname\namedlayouthash\v!current\c!state\endcsname
- \changetolayout\v!current % no start test ?
+\def\page_layouts_check_default_indeed#1%
+ {\doif{\namedlayoutparameter#1\c!state}\v!start{\page_layouts_change{#1}}}
+
+\def\page_layouts_check_default
+ {\ifcsname\namedlayouthash\v_real_page_normal \c!state\endcsname \page_layouts_check_default_indeed\v_real_page_normal \else
+ \ifcsname\namedlayouthash\v_real_page_reverse \c!state\endcsname \page_layouts_check_default_indeed\v_real_page_revers \else
+ \ifcsname\namedlayouthash\v_real_page_named \c!state\endcsname \page_layouts_check_default_indeed\v_real_page_named \else
+ \ifcsname\namedlayouthash\v_real_page_current \c!state\endcsname \page_layouts_check_default_indeed\v_real_page_current \else
+ \ifcsname\namedlayouthash\v_real_page_odd_or_even\c!state\endcsname \page_layouts_check_default_indeed\v_real_page_odd_or_even\fi\fi\fi\fi\fi}
+
+\def\installlayoutmethod#1#2%
+ {\setgvalue{\??ly:m:#1}{#2}}
+
+\installlayoutmethod\v!default{\page_layouts_check_default}
+\installlayoutmethod\v!normal {\page_layouts_check_default}
+
+\def\page_layouts_check_next
+ {\csname\??ly:m:\ifcsname\??ly:m:\layoutparameter\c!method\endcsname
+ \layoutparameter\c!method
\else
- \doifoddpageelse\checkcurrentoddlayout\checkcurrentevenlayout
- \fi\fi\fi}
+ \v!normal
+ \fi\endcsname}
+
+\let\checkcurrentlayout\page_layouts_check_next % public and used in naw, so this synonym will stay
% inheritance
%
@@ -660,311 +768,166 @@
% \dorecurse{20} {\input knuth \endgraf \input tufte \endgraf}
% \stoptext
-%appendtoks \checkcurrentlayout \to \everyaftershipout % no
-\appendtoks \checkcurrentlayout \to \everystarttext
+% Because we want to keep the set parameters as they are we use some
+% helpers to communicate between the several page building related
+% mechanism.
-\appendtoks
- \dochecknextlayout
-\to \everyaftershipout
-
-% \def\dochecknextlayout
-% {\ifx\currentlayout\v!current
-% % prevent redundant calculations
-% \else
-% \globallet\currentlayout\empty
-% \global\letbeundefined{\??ly\v!current\c!state}%
-% \checkcurrentlayout
-% \fi}
-%
-% this breaks after a standardmakeup
-
-\def\dochecknextlayout{\checkcurrentlayout}
+\appendtoks \page_layouts_check_next \to \everystarttext
+\appendtoks \page_layouts_check_next \to \everyaftershipout
\newconditional\c_page_layouts_location_is_set
\def\page_layouts_location_reset
{\setfalse\c_page_layouts_location_is_set
- \let\v_page_layouts_location_left_fill \relax
- \let\v_page_layouts_location_right_fill \relax
- \let\v_page_layouts_location_top_fill \relax
- \let\v_page_layouts_location_bottom_fill\relax}
-
-\page_layouts_location_reset
+ \let\v_page_target_left_fill \relax
+ \let\v_page_target_right_fill \relax
+ \let\v_page_target_top_fill \relax
+ \let\v_page_target_bottom_fill\relax}
\setvalue{\??ly:\c!location:\v!right }{\settrue\c_page_layouts_location_is_set
- \let\v_page_layouts_location_left_fill \hss}
+ \let\v_page_target_left_fill \hss}
\setvalue{\??ly:\c!location:\v!left }{\settrue\c_page_layouts_location_is_set
- \let\v_page_layouts_location_right_fill \hss}
+ \let\v_page_target_right_fill \hss}
\setvalue{\??ly:\c!location:\v!bottom }{\settrue\c_page_layouts_location_is_set
- \let\v_page_layouts_location_top_fill \vss}
+ \let\v_page_target_top_fill \vss}
\setvalue{\??ly:\c!location:\v!top }{\settrue\c_page_layouts_location_is_set
- \let\v_page_layouts_location_bottom_fill\vss}
+ \let\v_page_target_bottom_fill\vss}
\setvalue{\??ly:\c!location:\v!middle }{\settrue\c_page_layouts_location_is_set
- \let\v_page_layouts_location_left_fill \hss
- \let\v_page_layouts_location_right_fill \hss
- \let\v_page_layouts_location_top_fill \vss
- \let\v_page_layouts_location_bottom_fill\vss}
+ \let\v_page_target_left_fill \hss
+ \let\v_page_target_right_fill \hss
+ \let\v_page_target_top_fill \vss
+ \let\v_page_target_bottom_fill\vss}
\setvalue{\??ly:\c!location:\empty }{\setfalse\c_page_layouts_location_is_set % default also signal to scrn_
- \let\v_page_layouts_location_right_fill \hss
- \let\v_page_layouts_location_bottom_fill\hss}
-\setvalue{\??ly:\c!location:\v!doublesided}{\settrue\printdoublesided}
-\setvalue{\??ly:\c!location:\v!singlesided}{\setfalse\printdoublesided}
+ \let\v_page_target_right_fill \hss
+ \let\v_page_target_bottom_fill\hss}
+\setvalue{\??ly:\c!location:\v!doublesided}{\settrue \c_page_target_print_doublesided}
+\setvalue{\??ly:\c!location:\v!singlesided}{\setfalse\c_page_target_print_doublesided}
-\def\dopresetcenterpagebox#1%
+\def\page_target_check_centering_indeed#1%
{\ifcsname\??ly:\c!location:#1\endcsname\csname\??ly:\c!location:#1\endcsname\fi}
-\def\presetcenterpagebox
- {\setfalse\printdoublesided
+\unexpanded\def\page_target_check_centering
+ {\setfalse\c_page_target_print_doublesided
\page_layouts_location_reset
- \processcommacommand[\layoutparameter\c!location]\dopresetcenterpagebox}
+ \processcommacommand[\layoutparameter\c!location]\page_target_check_centering_indeed}
% installers
-\def\installlayoutmethod#1#2%
- {\setgvalue{\??ly:\c!method:#1}{#2}}
-
-\installlayoutmethod\v!default
- {\checkcurrentlayout}
-
-\installlayoutmethod\v!normal
- {\checkcurrentlayout}
-
-\def\dochecknextlayout
- {\executeifdefined
- {\??ly:\c!method:\layoutparameter\c!method}
- {\getvalue{\??ly:\c!method:\v!normal}}}
-
\def\installlayoutalternative#1#2%
- {\setgvalue{\??ly:\c!alternative:#1}{#2}}
+ {\setgvalue{\??ly:a:#1}{#2}}
-\def\constructnormalpagecontent#1#2% redefined
+\def\page_boxes_construct_content_default#1#2% #1 and #2 will become variables
{\setbox\pagebox\vbox
{\offinterlineskip
- \begingroup
- \dosetlayoutattributes\c!style\c!color
+ \begingroup % needed ?
+ \uselayoutstyleandcolor\c!style\c!color
\offinterlineskip
\gettextboxes
\endgroup
- \getmainbox#1#2}% including footnotes
- \addmainbackground\pagebox
- \buildpagebox\pagebox
- \addstatusinfo\pagebox}
-
-\installlayoutalternative\v!normal
- {\constructnormalpagecontent}
-
-\def\constructpagecontent % overload
- {\executeifdefined
- {\??ly:\c!alternative:\layoutparameter\c!alternative}%
- {\getvalue{\??ly:\c!alternative:\v!normal}}}
-
-\let\@@zaheight\!!zeropoint
-
-\def\dopushpagedimensions
- {\xdef\oldtextheight {\the\textheight }%
- \xdef\oldfooterheight{\the\footerheight}%
- \global\let\@@zaheight\@@zaheight}
-
-\def\dopoppagedimensions
- {\global\textheight \oldtextheight
- \global\footerheight\oldfooterheight
- \recalculatelayout
- \global\let\pushpagedimensions\dopushpagedimensions
- \global\let\poppagedimensions\relax}
-
-\let\poppagedimensions \relax
-\let\pushpagedimensions\dopushpagedimensions
-
-% Elke \csname ... \endcsname wordt ook aangemaakt, dus ook
-% in een test met \doifdefined. Bij veel bladzijden kan dit
-% te veel macro's kosten. Vandaar de set \adaptedpages. Het
-% kost tijd, maar scheelt macro's.
-
-\let\adaptedpages\empty
-
-\def\adaptpagedimensions
- {\ifx\adaptedpages\empty\else
- \adaptpagedimensionsindeed
- \fi}
+ \getmainbox#1#2}}% including footnotes
-\def\adaptpagedimensionsindeed
- {\rawdoifinset\realfolio\adaptedpages
- {\removefromcommalist\realfolio\adaptedpages
- \getvalue{\??za\realfolio}%
- \letbeundefined{\??za\realfolio}}}
+\installlayoutalternative\v!default{\page_boxes_construct_content_default}
+\installlayoutalternative\v!normal {\page_boxes_construct_content_default}
-\def\checkpagedimensions
- {\poppagedimensions
- \adaptpagedimensions}
+\def\page_boxes_construct_content
+ {\csname\??ly:a:\ifcsname\??ly:a:\layoutparameter\c!alternative\endcsname
+ \layoutparameter\c!alternative
+ \else
+ \v!normal
+ \fi\endcsname}
-\def\reportpagedimensions
- {\ifx\poppagedimensions\relax \else
- \space\the\dimexpr\@@zaheight\relax\space-\space
- \fi
- \realfolio}
+%D \macros
+%D {adaptlayout}
-\def\dodoadaptlayout[#1]%
- {\getparameters[\??za][\c!height=,\c!lines=0,#1]%
- \pushpagedimensions
- \ifcase\@@zalines\relax
- \showmessage\m!layouts1{\@@zaheight,\realfolio}%
+\newdimen\page_adepts_pushed_text_height
+\newdimen\page_adepts_pushed_footer_height
+\newdimen\page_adepts_height
+
+\unexpanded\def\adaptlayout
+ {\dodoubleempty\page_adapts_layout}
+
+\def\page_adapts_layout[#1][#2]%
+ {\ifsecondargument
+ \processcommalist[#1]{\page_adapts_layout_register{#2}}%
+ \page_adapts_check
\else
- \showmessage\m!layouts1{\@@zalines\space\v!lines,\realfolio}%
- \def\@@zaheight{\@@zalines\openlineheight}%
- \fi
+ \page_adapts_layout_indeed{#1}%
+ \fi}
+
+\def\page_adapts_layout_register#1#2%
+ {\setgvalue{\??za:#2}{\page_adapts_layout_indeed{#1}}}
+
+\def\page_adapts_layout_indeed#1%
+ {\getparameters[\??za][\c!height=\zeropoint,\c!lines=0,#1]%
+ \page_adepts_push
\doifelse\@@zaheight\v!max
- {\balancedimensions\textheight\footerheight\footerheight}
- {\balancedimensions\textheight\footerheight\@@zaheight}%
- \ifdim\footerheight<\zeropoint
- \global\advance\textheight \footerheight
- \global\footerheight\zeropoint
- \global\xdef\@@zaheight{\layoutparameter\c!footer\space(\v!max)}%
- \fi
+ {\global\page_adepts_height\footerheight}
+ {\global\page_adepts_height\dimexpr
+ \ifnum\@@zalines=\zerocount
+ \@@zaheight
+ \else
+ \@@zalines\openlineheight
+ \fi
+ \relax
+ \ifdim\page_adepts_height>\footerheight
+ \global\page_adepts_height\footerheight
+ \fi}
+ \global\advance\textheight \page_adepts_height
+ \global\advance\footerheight-\page_adepts_height
+ \showmessage\m!layouts1{\the\page_adepts_height,\the\realpageno}%
+ % this will become a better one (do we need insert correction?)
\setvsize
- \global\pagegoal\vsize % nog corrigeren voor insertions ?
+ \global\pagegoal\vsize
+ %
\recalculatebackgrounds
- \global\let\pushpagedimensions\relax
- \global\let\poppagedimensions\dopoppagedimensions}
+ \global\let\page_adepts_push\relax
+ \global\let\page_adepts_pop\page_adepts_pop_indeed}
-\def\doadaptlayout[#1][#2]%
- {\doifelsenothing{#2}
- {\dodoadaptlayout[#1]}
- {\def\docommand##1%
- {\addtocommalist{##1}\adaptedpages
- \setgvalue{\??za##1}{\dodoadaptlayout[#2]}}%
- \processcommalist[#1]\docommand
- \adaptpagedimensions}}
-
-\def\adaptlayout
- {\dodoubleempty\doadaptlayout}
-
-\unexpanded\def\startlayout[#1]%
- {\page
- \pushmacro\currentlayout
- \doiflayoutdefinedelse{#1}{\setuplayout[#1]}\donothing} % {\setuplayout[\currentlayout]}}
-
-\unexpanded\def\stoplayout
- {\page
- \popmacro\currentlayout
- \setuplayout[\currentlayout]}
-
-
-% describe interface
-
-%D Centering the paper area on the print area is determined
-%D by the \type {top}, \type {bottom}, \type {left} and \type
-%D {right} parameters.
-
-\def\centerpagebox#1% we could test for a difference (saves packing)
- {\printpaperwidth \paperscale\printpaperwidth
- \printpaperheight\paperscale\printpaperheight
- \ifdim\printpaperheight>\ht#1\relax
- \donetrue
- \else\ifdim\printpaperwidth>\wd#1\relax
- \donetrue
- \else
- \donefalse
- \fi\fi
- \ifdone
- \setbox#1\vbox to \printpaperheight
- {\@@pptop
- \v_page_layouts_location_top_fill
- \hbox to \printpaperwidth
- {\ifconditional\printdoublesided
- \doifbothsides
- {\@@ppleft \v_page_layouts_location_left_fill \box#1\v_page_layouts_location_right_fill\@@ppright}%
- {\@@ppleft \v_page_layouts_location_left_fill \box#1\v_page_layouts_location_right_fill\@@ppright}%
- {\@@ppright\v_page_layouts_location_right_fill\box#1\v_page_layouts_location_left_fill \@@ppleft }%
- \else
- \@@ppleft \v_page_layouts_location_left_fill \box#1\v_page_layouts_location_right_fill\@@ppright
- \fi}%
- \par
- \v_page_layouts_location_bottom_fill
- \@@ppbottom}%
+\def\page_adapts_check
+ {\ifcsname\??za:\the\realpageno\endcsname
+ \page_adapts_check_indeed
\fi}
-\def\offsetprintbox#1%
- {\ifdim\topoffset=\zeropoint % \relax
- \ifdim\backoffset=\zeropoint
- \donefalse
- \else
- \donetrue
- \fi
- \else
- \donetrue
- \fi
- \ifdone
- \edef\next{\wd#1\the\wd#1\ht#1\the\ht#1\dp#1\the\dp#1}%
- \setbox#1\vbox
- {\offinterlineskip
- \vskip\topoffset
- \hskip\doifbothsides\backoffset\backoffset{-\backoffset}%
- \box#1}%
- \next
- \fi}
+\def\page_adapts_check_indeed
+ {\getvalue{\??za:\the\realpageno}%
+ \letvalue{\??za:\the\realpageno}\relax}
-\def\replicatepagebox#1%
- {\ifnum\layoutparameter\c!nx>\plusone
- \donetrue
- \else\ifnum\layoutparameter\c!ny>\plusone
- \donetrue
- \else
- \donefalse
- \fi\fi
- \ifdone
- \setbox#1\vbox
- {\offinterlineskip
- \dorecurse{\layoutparameter\c!ny}
- {\hbox{\dorecurse{\layoutparameter\c!nx}{\copy#1\hskip\layoutparameter\c!dx}\unskip}%
- \vskip\layoutparameter\c!dy}
- \unskip}%
- \fi}
+\def\page_adepts_push_indeed
+ {\global\page_adepts_pushed_text_height \textheight
+ \global\page_adepts_pushed_footer_height\footerheight}
-\def\orientpagebodybox#1#2#3%
- {\ifnum\number#1\number#2>\zerocount
- \setbox#3\vbox
- {\edef\somerotation{\number\ifdoublesided\ifodd\realpageno#1\else#2\fi\else#1\fi}%
- \dorotatebox\somerotation\hbox{\box#3}}%
- \fi}
+\def\page_adepts_pop_indeed
+ {\global\textheight \page_adepts_pushed_text_height
+ \global\footerheight\page_adepts_pushed_footer_height
+ \pages_layouts_synchronize
+ \global\let\page_adepts_push\page_adepts_push_indeed
+ \global\let\page_adepts_pop\relax}
-\def\orientpaperbox{\orientpagebodybox\paperorientation\paperreverse}
-\def\orientprintbox{\orientpagebodybox\printorientation\printreverse}
+\let\page_adepts_pop \relax
+\let\page_adepts_push\page_adepts_push_indeed
-\def\mirrorpagebodybox#1#2%
- {\ifconditional#1\relax
- \setbox#2\vbox{\domirrorbox\vbox{\box#2}}%
- \fi}
+\unexpanded\def\page_adapts_synchronize % used elsewhere
+ {\page_adepts_pop
+ \page_adapts_check}
-\def\mirrorpaperbox{\mirrorpagebodybox\papermirror}
-\def\mirrorprintbox{\mirrorpagebodybox\printmirror}
-
-\def\scalepagebox#1%
- {\edef\tmp_currentlayout_scale{\layoutparameter\c!scale}%
- \ifdim\tmp_currentlayout_scale\points=\onepoint
- \edef\tmp_currentlayout_sx{\layoutparameter\c!sx}%
- \edef\tmp_currentlayout_sy{\layoutparameter\c!sy}%
- \ifdim\tmp_currentlayout_sx\points=\onepoint
- \ifdim\layoutparameter\c!sy\points=\onepoint
- % no scaling done (and no copying either)
- \else
- \doscalepagebox{#1}\tmp_currentlayout_sx\tmp_currentlayout_sy
- \fi
- \else
- \doscalepagebox{#1}\tmp_currentlayout_sx\tmp_currentlayout_sy
- \fi
- \else
- \doscalepagebox{#1}\tmp_currentlayout_scale\tmp_currentlayout_scale
- \fi}
+\def\page_adapts_status_info % used elsewhere
+ {\ifx\page_adepts_pop\relax \else
+ \space(adept: \the\page_adepts_height)\space
+ \fi
+ \the\realpageno}
+
+%D \macros
+%D {startlayout,stoplayout}
-\def\doscalepagebox#1#2#3%
- {\setbox#1\vbox{\scale[\c!sx=#2,\c!sy=#3]{\box#1}}%
- \paperwidth #2\paperwidth
- \paperheight#3\paperheight}
+\unexpanded\def\startlayout[#1]%
+ {\page
+ \pushmacro\currentlayout
+ \doiflayoutdefinedelse{#1}{\setuplayout[#1]}\donothing} % {\setuplayout[\currentlayout]}}
-\def\negateprintbox#1%
- {\ifconditional\printnegatecolors
- \negatecolorbox{#1}%
- \fi}
+\unexpanded\def\stoplayout
+ {\page
+ \popmacro\currentlayout
+ \setuplayout[\currentlayout]}
% NOG EENS NAGAAN WANNEER NU GLOBAL EN WANNEER NIET
@@ -977,25 +940,10 @@
\def\globalcompensatevsizeheader{\global\advance\textheight-\dimexpr\headerheight+\headerdistance\relax}
\def\globalcompensatevsizefooter{\global\advance\textheight-\dimexpr\footerheight+\footerdistance\relax}
-\def\compensatevsizeheaderzero{\headerheight\zeropoint\setlayoutdistances}
-\def\compensatevsizefooterzero{\footerheight\zeropoint\setlayoutdistances}
+\def\compensatevsizeheaderzero{\headerheight\zeropoint\page_layouts_set_distances}
+\def\compensatevsizefooterzero{\footerheight\zeropoint\page_layouts_set_distances}
-\def\calculatevsizes
- {\textheight\makeupheight
- \doifelselayoutsomeline\v!header\compensatevsizeheader\donothing
- \doifelselayoutsomeline\v!footer\compensatevsizefooter\donothing
- \setvsizemodes
- \resetglobal
- \setvsize}
-
-\def\calculateglobalvsizes
- {\global\textheight\makeupheight
- \doifelselayoutsomeline\v!header\globalcompensatevsizeheader\donothing
- \doifelselayoutsomeline\v!footer\globalcompensatevsizefooter\donothing
- \setvsizemodes
- \setvsize}
-
-\def\setvsizemodes
+\def\page_layouts_set_modes
{\ifzeropt\headerheight
\resetsystemmode\v!header
\else
@@ -1007,7 +955,22 @@
\setsystemmode\v!footer
\fi}
-\def\calculatereducedvsizes
+\def\calculatevsizes % name will change
+ {\textheight\makeupheight
+ \doifelselayoutsomeline\v!header\compensatevsizeheader\donothing
+ \doifelselayoutsomeline\v!footer\compensatevsizefooter\donothing
+ \page_layouts_set_modes
+ \resetglobal
+ \setvsize}
+
+\def\calculateglobalvsizes % name will change
+ {\global\textheight\makeupheight
+ \doifelselayoutsomeline\v!header\globalcompensatevsizeheader\donothing
+ \doifelselayoutsomeline\v!footer\globalcompensatevsizefooter\donothing
+ \page_layouts_set_modes
+ \setvsize}
+
+\def\calculatereducedvsizes % name will change
{\textheight\makeupheight
\doifelselayoutsomeline\v!header\compensatevsizeheader\compensatevsizeheaderzero
\doifelselayoutsomeline\v!footer\compensatevsizefooter\compensatevsizefooterzero}
@@ -1020,25 +983,28 @@
\def\compensatedinnermakeupmargin
{\dimexpr\ifconditional\innermakeupcompensation+\innermakeupmargin\else\zeropoint\fi\relax}
-\def\freezetextwidth % \makeupwidth may be set to \textwidth
- {\textwidth\makeupwidth % which is a tricky but valid value
- \doifsomething{\layoutparameter\c!textwidth}
- {\textwidth\layoutparameter\c!textwidth}% % local
+\def\freezetextwidth % name will change % \makeupwidth may be set to \textwidth
+ {\textwidth\makeupwidth % which is a tricky but valid value
+ \edef\tmp_currentlayout_text_width {\layoutparameter\c!textwidth }%
+ \edef\tmp_currentlayout_text_margin{\layoutparameter\c!textmargin}%
+ \ifx\tmp_currentlayout_text_width\empty \else
+ \textwidth\tmp_currentlayout_text_width % local
+ \fi
\global\innermakeupwidth\textwidth
- \doifelsenothing{\layoutparameter\c!textmargin}
- {\global\innermakeupmargin\zeropoint}
- {\global\innermakeupmargin\layoutparameter\c!textmargin}%
- \global\advance\innermakeupwidth-\dimexpr\innermakeupmargin+\innermakeupmargin\relax
- \advance\textwidth-\dimexpr\innermakeupmargin+\innermakeupmargin\relax} % local
+ \ifx\tmp_currentlayout_text_margin\empty
+ \global\innermakeupmargin\zeropoint
+ \else
+ \global\innermakeupmargin\tmp_currentlayout_text_margin\relax
+ \fi
+ \scratchdimen\dimexpr\innermakeupmargin+\innermakeupmargin\relax
+ \global\advance\innermakeupwidth-\scratchdimen
+ \advance\textwidth-\scratchdimen} % local
-\def\calculatehsizes
+\def\calculatehsizes % name will change
{\freezetextwidth
\sethsize}
-
-% De onderstaande macro voert commando's uit, afhankelijk van
-% het karakter van het paginanummer.
-%
-% \doifoddpageelse{then-commando}{else-commando}
+
+% The next few are better off in page-ini.mkiv
%D When we start at an even page, we need to swap the layout
%D differently. We cannot adapt the real page number, since
@@ -1048,6 +1014,8 @@
% We could use nested if here plus some \@EAEAEA's but but the
% next variant has less expansion which is nicer in tracing.
+% #single #left #right
+
\def\doifoddpageelse {\ifodd\pagenoshift\expandafter\doifoddpageelseyes \else\expandafter\doifoddpageelsenop \fi}
\def\doifoddpageelseyes{\ifodd\realpageno \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments \fi}
\def\doifoddpageelsenop{\ifodd\realpageno \expandafter\firstoftwoarguments \else\expandafter\secondoftwoarguments\fi}
@@ -1079,7 +1047,7 @@
\newdimen\texthoffset
-\def\settexthoffset
+\def\settexthoffset % name will change
{\texthoffset\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}}
% The next hack is too tricky as we may shipout more pages:
@@ -1106,16 +1074,16 @@
% \freezepagestatechecks
% \to \everybeforeshipout
-\def\goleftonpage
+\def\goleftonpage % name will change
{\hskip-\dimexpr\leftmargindistance+\leftmarginwidth+\leftedgedistance+\leftedgewidth\relax}
\def\doifmarginswapelse#1#2%
{\doifbothsides{#1}{#1}{#2}}
-\def\swapmargins
+\def\swapmargins % name will change
{\doifmarginswapelse\relax\doswapmargins}
-\def\doswapmargins
+\def\doswapmargins % name will change
{\let\swapmargins \relax % to prevent local swapping
\let\doswapmargins\relax % to prevent local swapping
\the\everyswapmargins}
@@ -1178,15 +1146,15 @@
%D versions.
\unexpanded\def\startlocallayout
- {\globalpushmacro\restorepapersize
+ {\globalpushmacro\page_paper_restore
\globalpushmacro\currentlayout}
\unexpanded\def\stoplocallayout
{\globalpopmacro\currentlayout
- \globalpopmacro\restorepapersize
- \restorepapersize
- \setuplayout}
-
+ \globalpopmacro\page_paper_restore
+ \page_paper_restore
+ \setuplayout\relax}
+
%D \macros
%D {showprint, showframe, showlayout, showsetups}
%D
@@ -1218,26 +1186,6 @@
%D since they could change while going to a new page,
%D depending on the current font setting.
-\setuppaper % (size) % only used in XY imposition
- [\c!width=\zeropoint,
- \c!height=\zeropoint,
- \c!topspace=\zeropoint,
- \c!backspace=\zeropoint,
- \c!dx=\zeropoint,
- \c!dy=\zeropoint,
- \c!nx=1,
- \c!ny=1,
- \c!alternative=\v!normal,
- \c!method=\v!normal]
-
-\setuppapersize
- [\c!option=\v!max,
- \c!top=,
- \c!bottom=,
- \c!left=,
- \c!right=,
- \c!location=]
-
\setuplayout
[ \c!topspace=.08417508418\paperheight, % 2.5cm
\c!top=\zeropoint,
diff --git a/tex/context/base/page-lin.mkiv b/tex/context/base/page-lin.mkiv
index e70a8148d..4996ad2b1 100644
--- a/tex/context/base/page-lin.mkiv
+++ b/tex/context/base/page-lin.mkiv
@@ -176,11 +176,14 @@
\fi
\mksetuptextlinenumbering}
+% some day commandhandler
+
\def\linenumberparameter#1%
{\csname\??rn\ifcsname\??rn\currentlinenumbering#1\endcsname\currentlinenumbering\fi#1\endcsname}
-\def\linenumberattributes
- {\doattributes{\??rn\ifcsname\??rn\currentlinenumbering\c!style\endcsname\currentlinenumbering\fi}}
+\unexpanded\def\dolinenumberattributes#1#2%
+ {\dousestyleparameter{\linenumberparameter#1}%
+ \dousecolorparameter{\linenumberparameter#2}}
\setuplinenumbering
[\c!conversion=\v!numbers,
@@ -459,11 +462,11 @@
\ifconditional\faketextlinenumber
% we need to reserve space
\else
- \linenumberattributes\c!style\c!color
- {\linenumberparameter\c!command
- {\linenumberparameter\c!left
- \convertnumber{\linenumberparameter\c!conversion}{#3}%
- \linenumberparameter\c!right}}%
+ \dolinenumberattributes\c!style\c!color
+ \linenumberparameter\c!command
+ {\linenumberparameter\c!left
+ \convertnumber{\linenumberparameter\c!conversion}{#3}%
+ \linenumberparameter\c!right}%
\fi
\ifcase\linenumberlocation
\hss % middle
diff --git a/tex/context/base/page-mak.mkvi b/tex/context/base/page-mak.mkvi
index 114a84734..e4899f948 100644
--- a/tex/context/base/page-mak.mkvi
+++ b/tex/context/base/page-mak.mkvi
@@ -99,7 +99,7 @@
\forgetall % else indented flush
\dontcomplain
\global\setbox\page_makeup_box\vbox to \makeupparameter\c!height \bgroup
- \dosetmakeupattributes\c!style\c!color
+ \usemakeupstyleandcolor\c!style\c!color
\hsize\makeupparameter\c!width
\setupalign[\makeupparameter\c!align]%
\doprocesslocalsetups{\makeupparameter\c!setups}% lua(..),xml(...,..),tex(..)
@@ -107,30 +107,10 @@
\let\stopmakeup\page_makeup_stop_yes}
\unexpanded\def\page_makeup_stop_yes
- {\endgraf
- \makeupparameter\c!bottom
- \egroup
- \ifprocessingpages % this will be redone anyway (is this needed at all?)
- \ifpageselected
- \page_makeup_flush_box
- \else
- \page_makeup_wipe_box
- \fi
- \else
- \ifpageselected
- \page_makeup_wipe_box
- \else
- \page_makeup_flush_box
- \fi
- \fi
- \ifselectingpages
- \global\pageselectedfalse
- \fi
+ {\endgraf
+ \makeupparameter\c!bottom
\egroup
- \stoplayout} % includes \page
-
-\def\page_makeup_flush_box
- {\pushpagestate % new
+ \pushpagestate % new
\makeupparameter\c!before
\relax % to be sure we don't enter the \if
\ifdim\ht\page_makeup_box>\vsize
@@ -145,10 +125,9 @@
\ifdoublesided \ifodd\realpageno \else
\getvalue{\??do::\c!doublesided::\makeupparameter\c!doublesided}%
\fi \fi
- \poppagestate} % new
-
-\def\page_makeup_wipe_box
- {\global\box\page_makeup_box\emptybox}
+ \poppagestate % new
+ \egroup
+ \stoplayout} % includes \page
\setvalue{\??do::\c!doublesided::\v!yes}%
{\emptyhbox
@@ -171,8 +150,6 @@
\setuptext [\c!state=\makeupparameter\c!textstate]%
\setupbottom[\c!state=\makeupparameter\c!bottomstate]%
\setuptop [\c!state=\makeupparameter\c!topstate]%
- % this is needed, but no \setuplayout here; fails in texexec --fig=c
- %\recalculatelayout
\to \page_makeup_every_setup
%D The standard page template is defined as follows:
@@ -220,6 +197,10 @@
[\v!page]
[]
+\definemakeup
+ [\v!middle]
+ [\v!standard]
+
% \definelayout[standard]
% \definelayout[text]
diff --git a/tex/context/base/page-mar.mkiv b/tex/context/base/page-mar.mkiv
index 7a091c485..07296f832 100644
--- a/tex/context/base/page-mar.mkiv
+++ b/tex/context/base/page-mar.mkiv
@@ -291,13 +291,13 @@
{\decrement\margincontentlines
\dorecurse\margincontentlines{\savedstrut\endgraf\nointerlineskip}% ! savedstrut
\@@imbefore
- \dostartattributes{\??im\margincontenttag}\c!style\c!color\empty
- \dosetupstrut[\margincontentstrut]% was: \setstrut % yes or no
- \dostarttagged\t!margintextblock\currentmargincontent % margincontenttag
- \begstrut#3\endstrut\endgraf
- \dostoptagged
- \xdef\margincontentstrutheight{\the\strutht}% so that it's known outside the framed
- \dostopattributes
+ \dousestylehashparameter{\??im\margincontenttag}\c!style
+ \dousecolorhashparameter{\??im\margincontenttag}\c!color
+ \dosetupstrut[\margincontentstrut]% was: \setstrut % yes or no
+ \dostarttagged\t!margintextblock\currentmargincontent % margincontenttag
+ \begstrut#3\endstrut\endgraf
+ \dostoptagged
+ \xdef\margincontentstrutheight{\the\strutht}% so that it's known outside the framed
\@@imafter}%
\global \naturalmargincontentheight\ht\scratchbox
\global\advance\naturalmargincontentheight\dp\scratchbox
diff --git a/tex/context/base/page-mbk.mkvi b/tex/context/base/page-mbk.mkvi
index 24f0913b8..7e13bb1b1 100644
--- a/tex/context/base/page-mbk.mkvi
+++ b/tex/context/base/page-mbk.mkvi
@@ -90,7 +90,7 @@
\marginblockparameter\c!inbetween
\fi
\setupalign[\marginblockparameter\c!align]%
- \dosetfloatcaptionattributes\c!style\c!color
+ \usemarginblockstyleandcolor\c!style\c!color
\begstrut
\ignorespaces}
@@ -104,7 +104,7 @@
{\showmessage\m!layouts5\empty
\marginblockparameter\c!before
\bgroup
- \dosetfloatcaptionattributes\c!style\c!color}
+ \usemarginblockstyleandcolor\c!style\c!color}
\def\stop_margin_block_nop
{\egroup
diff --git a/tex/context/base/page-mis.lua b/tex/context/base/page-mis.lua
index d32eb8a00..d220d0a9e 100644
--- a/tex/context/base/page-mis.lua
+++ b/tex/context/base/page-mis.lua
@@ -31,7 +31,7 @@ local function setnextpage()
elseif n > 0 then
-- upcoming page (realpageno)
end
- tex.setcount("global","postponed_page_blocks_next_page",n)
+ tex.setcount("global","page_postponed_blocks_next_page",n)
end
function commands.flushpostponedblocks(page)
diff --git a/tex/context/base/page-mis.mkiv b/tex/context/base/page-mis.mkiv
index 5ab96f0f8..507ab9a2b 100644
--- a/tex/context/base/page-mis.mkiv
+++ b/tex/context/base/page-mis.mkiv
@@ -45,24 +45,24 @@
%D we keep a local cache, especially as we can flush per page.
\newif \ifinpostponing % prevents nesting
-\newcount\postponed_page_blocks_next_page % set at the lua end
+\newcount\page_postponed_blocks_next_page % set at the lua end
\unexpanded\setvalue{\e!start\v!postponing}%
{\bgroup
\obeylines
- \doifnextoptionalelse{\egroup\postponed_page_block_start}{\egroup\postponed_page_block_start[0]}}
+ \doifnextoptionalelse{\egroup\page_postponed_blocks_start}{\egroup\page_postponed_blocks_start[0]}}
\unexpanded\setvalue{\e!stop\v!postponing}%
{\ctxcommand{registerpostponedblock("\currentpostponedpage")}\relax}
-\def\postponed_page_block_start[#1]%
+\def\page_postponed_blocks_start[#1]%
{\edef\currentpostponedpage{#1}%
\dostartbuffer[postponedblock][\e!start\v!postponing][\e!stop\v!postponing]}
% officially we should flush again after a flush as there can be new future pages
% but that will be looked into when we run into it
-\unexpanded\def\postponed_page_block_flush
+\unexpanded\def\page_postponed_blocks_flush
{\bgroup
\inpostponingtrue % for old times sake
\global\pagetotal\zeropoint % here? still needed? (was after flush pagefloats)
@@ -76,28 +76,28 @@
\doflushfloats % new but potential dangerous, maybe we need a classification
\egroup} % of blocks: with and without flush
-\def\doflushpostponedblocks
+\def\page_postponed_blocks_flush_indeed
{\ifinpostponing
% probably a nested flush
- \else\ifnum\postponed_page_blocks_next_page=\zerocount
+ \else\ifnum\page_postponed_blocks_next_page=\zerocount
% nothing in cache
- \else\ifnum\postponed_page_blocks_next_page<\zerocount
+ \else\ifnum\page_postponed_blocks_next_page<\zerocount
% generic cache
- \postponed_page_block_flush
- \else\ifnum\postponed_page_blocks_next_page>\realpageno
+ \page_postponed_blocks_flush
+ \else\ifnum\page_postponed_blocks_next_page>\realpageno
% future content
\else
% pending content
- \postponed_page_block_flush
+ \page_postponed_blocks_flush
\fi\fi\fi\fi}
-\def\doflushpostponedcontent % called in page-one
- {\bgroup
+\def\page_postponed_blocks_flush
+ {\begingroup
\setsystemmode\v!postponing
\the\everytopofpage
%\flushrestfloats
\doflushpagefloats
- \doflushpostponedblocks
- \egroup}
+ \page_postponed_blocks_flush_indeed
+ \endgroup}
\protect \endinput
diff --git a/tex/context/base/page-mrk.mkiv b/tex/context/base/page-mrk.mkiv
index babf7f776..d1552dcfd 100644
--- a/tex/context/base/page-mrk.mkiv
+++ b/tex/context/base/page-mrk.mkiv
@@ -51,7 +51,7 @@
\stopuseMPgraphic
\def\page_marks_add_color
- {\setlayoutcomponentattribute\v!print\v!color
+ {\setlayoutcomponentattribute{\v!print:\v!color}%
\setbox\scratchbox\hbox \layoutcomponentboxattribute\bgroup
\uniqueMPgraphic
{print:color}%
@@ -62,7 +62,7 @@
\hskip-\scratchwidth\box\scratchbox}
\def\page_marks_add_marking
- {\setlayoutcomponentattribute\v!print\v!marking
+ {\setlayoutcomponentattribute{\v!print:\v!marking}%
\setbox\scratchbox\hbox \layoutcomponentboxattribute\bgroup
\uniqueMPgraphic
{print:marking}%
@@ -73,7 +73,7 @@
\hskip-\scratchwidth\box\scratchbox}
\def\page_marks_add_lines
- {\setlayoutcomponentattribute\v!print\v!lines
+ {\setlayoutcomponentattribute{\v!print:\v!lines}%
\setbox\scratchbox\hbox \layoutcomponentboxattribute\bgroup
\uniqueMPgraphic
{print:lines}%
@@ -85,7 +85,7 @@
\hskip-\scratchwidth\box\scratchbox}
\def\page_marks_add_number
- {\setlayoutcomponentattribute\v!print\v!number
+ {\setlayoutcomponentattribute{\v!print:\v!number}%
\setbox\scratchbox\hbox \layoutcomponentboxattribute\bgroup
\useMPgraphic
{print:number}%
@@ -194,70 +194,3 @@
[\c!marking=\v!off]
\protect \endinput
-
-% We keep the old code for while.
-
-% \def\pagecutmarksymbol {\the\realpageno}
-% \def\pagecutmarklength {.5cm}
-% \let\pagecutmarktoptext \empty
-% \let\pagecutmarkbottomtext \empty
-% \def\pagecutmarkoffset {.5\dimexpr\pagecutmarklength\relax}
-%
-% \def\extrapagecutmarkbottomtext
-% {\rlap{\jobname}\hfill\currentdate\space-\space\currenttime\hfill\llap{\realfolio}}
-%
-% \def\makepagecutbox % #1
-% {\let\cutmarksymbol \pagecutmarksymbol
-% \let\cutmarklength \pagecutmarklength
-% \let\cutmarktoptext \pagecutmarktoptext
-% \let\cutmarkbottomtext\pagecutmarkbottomtext
-% \let\cutmarkhoffset \pagecutmarkoffset
-% \let\cutmarkvoffset \pagecutmarkoffset
-% \makecutbox}
-%
-% \newcount\currentpagebox % will be used in more places
-%
-% \def\installpagecutmark #1#2{\setvalue{\??ly:n:\c!marking:#1}{#2}}
-% \def\installpagecolormark#1#2{\setvalue{\??ly:c:\c!marking:#1}{#2}}
-%
-% % \def\addpagecolormarks{\expandcheckedcsname{\??ly:c:\c!marking:}{\layoutparameter\c!marking}\s!unknown}
-% % \def\addpagecutmarks {\expandcheckedcsname{\??ly:n:\c!marking:}{\layoutparameter\c!marking}\s!unknown}
-%
-% \def\addpagecutmarks#1% only at outer when nx/ny > 0
-% {\ifcsname\??ly:n:\c!marking:\layoutparameter\c!marking\endcsname
-% \currentpagebox#1\relax
-% \csname\??ly:n:\c!marking:\layoutparameter\c!marking\endcsname
-% \fi}
-%
-% \def\addpagecolormarks#1%
-% {\ifcsname\??ly:c:\c!marking:\layoutparameter\c!marking\endcsname
-% \currentpagebox#1\relax
-% \ifnum\horizontalcutmarks>\plustwo \def\colormarkoffset{\plusfour}\fi
-% \ifnum\verticalcutmarks >\plustwo \def\colormarkoffset{\plusfour}\fi
-% \csname\??ly:c:\c!marking:\layoutparameter\c!marking\endcsname
-% \fi}
-%
-% \installpagecutmark\v!on
-% {\makepagecutbox\currentpagebox}
-%
-% \installpagecutmark\v!page
-% {\makepagecutbox\currentpagebox}
-%
-% \installpagecutmark\v!empty
-% {\let\pagecutmarksymbol\empty
-% \let\pagecutmarktoptext\empty
-% \let\pagecutmarkbottomtext\empty
-% \makepagecutbox\currentpagebox}
-%
-% \installpagecutmark\v!text
-% {\let\pagecutmarksymbol\empty
-% \let\pagecutmarkbottomtext\extrapagecutmarkbottomtext
-% \makepagecutbox\currentpagebox}
-%
-% \installpagecolormark\v!color
-% {\makepagecutbox\currentpagebox % maybe move this elsewhere
-% \colormarkbox\currentpagebox}
-%
-% \installpagecolormark\v!screen % obsolete (all \v!screen will be removed)
-% {\makepagecutbox\currentpagebox % maybe move this elsewhere
-% \rastermarkbox\currentpagebox}
diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv
index 5dfe47c3d..f00dec89b 100644
--- a/tex/context/base/page-mul.mkiv
+++ b/tex/context/base/page-mul.mkiv
@@ -43,21 +43,13 @@
\newtoks \OTRMULoutput
\def\OTRMULgotonextpage
- {\ejectpage}
+ {\page_otr_eject_page}
\def\OTRMULgotonextpageX % will become obsolete
- {\superejectpage}
+ {\page_otr_eject_page_and_flush_inserts}
% check \count<insert> multiplications
-% some day try this in balancing routine
-%
-% \ifdim\pagetotal>\pagegoal
-% \eject
-% \else
-% \goodbreak
-% \fi
-
%D The following macro's implement a multi||column output
%D routine. The original implementation was based on Donald
%D Knuth's implementation, which was adapted by Craig Platt to
@@ -229,7 +221,8 @@
%D always work.
\def\ejectcolumn
- {\goodbreak\showmessage\m!columns2\empty}
+ {\goodbreak
+ \showmessage\m!columns2\empty}
%D The next macro should never be called so let's deal with it.
%D There were several solutions to these kind of errors. First
@@ -445,16 +438,16 @@
\global\singlecolumnout\output % hm
%\global\output{\global\setbox\precolumnbox\vbox{\unvbox\normalpagebox}}%
%\global\output{\global\setbox\precolumnbox\vbox{\dotopinsertions\unvbox\normalpagebox}}%
- \setoutputroutine{\global\setbox\precolumnbox\vbox{\dotopinsertions\unvbox\normalpagebox}}%
- \eject % no \holdinginserts=1, can make footnote disappear !
+ \page_otf_set_engine_output_routine{\global\setbox\precolumnbox\vbox{\dotopinsertions\unvbox\normalpagebox}}%
+ \page_otr_trigger_output_routine % no \holdinginserts=1, can make footnote disappear !
\global\precolumnboxheight\ht\precolumnbox
%\global\output{\continuousmulticolumnsout}%
- \setoutputroutine{\continuousmulticolumnsout}%
+ \page_otf_set_engine_output_routine{\continuousmulticolumnsout}%
\setcolumnfloats
\dohandleallcolumns
{\global\setbox\currenttopcolumnbox\emptybox}%
\checkbegincolumnfootnotes
- \activateotr{MUL}{ONE}% todo ! ! ! !
+ \page_otr_activate{MUL}{ONE}% todo ! ! ! !
\let\sethsize\setcolumnhsize
\let\setvsize\setcolumnvsize
\sethsize
@@ -495,20 +488,18 @@
\ifbalancecolumns
\ifnum\multicolumnendsyncmethod=\plusone
%\global\output{\continuousmulticolumnsout}%
- \setoutputroutine{\continuousmulticolumnsout}%
+ \page_otf_set_engine_output_routine{\continuousmulticolumnsout}%
\goodbreak
\fi
%\global\output{\balancedmulticolumnsout}%
- \setoutputroutine{\balancedmulticolumnsout}%
+ \page_otf_set_engine_output_routine{\balancedmulticolumnsout}%
\else
\goodbreak
\fi
- \eject % the prevdepth is important, try e.g. toclist in
+ \page_otr_trigger_output_routine % the prevdepth is important, try e.g. toclist in
\prevdepth\zeropoint % columns before some noncolumned text text
- %\global\output\singlecolumnout
- \setoutputroutine{\singlecolumnout}%
- %\global\output{\the\mainoutput}% % % % % todo
- \setoutputroutine{\the\mainoutput}% % % % % todo
+ \page_otf_set_engine_output_routine{\singlecolumnout}%
+ \page_otf_set_engine_output_routine{\page_otr_triggered_output_routine}%
\ifvoid\precolumnbox\else
\unvbox\precolumnbox
\fi
@@ -605,7 +596,7 @@
\dohandleallcolumns
{\mkprocesscolumncontents\currentcolumnbox}%
\dohandleallcolumns
- {\docolumnpagebodymarks\plusone\nofcolumns\mofcolumns\currentcolumnbox}%
+ {\page_marks_synchronize_column\plusone\nofcolumns\mofcolumns\currentcolumnbox}%
\postprocesscolumns
\dohandleallcolumns % \hbox i.v.m. \showcomposition
{\global\setbox\currentcolumnbox\hbox to \localcolumnwidth
@@ -715,8 +706,12 @@
\vskip-\scratchdimen}%
\scratchdimen\noflines\openlineheight
\advance\scratchdimen-\openstrutdepth
+\ifgridsnapping
+ % quick hack (at least it works with itemize)
+\else
\advance\scratchdimen-\openlineheight
\advance\scratchdimen\topskip
+\fi
\ht\columnpagebox\scratchdimen
\dp\columnpagebox\openstrutdepth
% end of mess
@@ -1165,7 +1160,7 @@
\global\setbox\firstcolumnbox\vbox{\unvbox0}%
\fi
%\global\output{\balancingerror}%
- \setoutputroutine{\balancingerror}%
+ \page_otf_set_engine_output_routine{\balancingerror}%
\b@selinebottomtrue % forces depth in separation rule
\flushcolumnedpage\plusone
\multicolumnseject
@@ -1173,7 +1168,7 @@
\def\multicolumnseject
{%\ifdim\pagetotal>\textheight
- % \eject % new, but wrong as fails on mixed-001.tex (wrong pagetotal at this point)
+ % \page_otr_trigger_output_routine % new, but wrong as fails on mixed-001.tex (wrong pagetotal at this point)
%\else
\allowbreak
}%\fi}
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index b1ee82302..cc65a7267 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -20,15 +20,15 @@
% OTRONE: basic single column
-\activateotr{ONE}{} % the default one
+\page_otr_activate{ONE}\empty % the default otr
\newtoks\OTRONEoutput
\def\OTRONEgotonextpage
- {\ejectpage}
+ {\page_otr_eject_page}
\def\OTRONEgotonextpageX % will become obsolete
- {\superejectpage}
+ {\page_otr_eject_page_and_flush_inserts}
\def\OTRONEsethsize
{\global\hsize\textwidth}
@@ -61,10 +61,10 @@
\fi
\fi}
-% can we avoind the extra vboxing here?
+% can we avoid the extra vboxing here?
-\def\OTRONEregisteredtextarea#1%
- {\ifregistertextareas
+\def\OTRONEregisteredtextarea#1% obsolete
+ {\ifconditional\c_page_areas_enabled
\setbox0\vbox{#1}%
\wd0\makeupwidth % somehow a space creeps in
\vbox{\registeredtextarea000}%
@@ -72,115 +72,109 @@
#1%
\fi}
-\def\doOTRONEregisteredtextareaA#1%
- {\ifregistertextareas
- \xypos{pbd:\realfolio:b}% we could save bytes by only saving the y
- \endgraf
- \begingroup
- \scratchdimen\dimexpr\MPy{pbd:\realfolio:b}-\MPy{pbd:\realfolio:e}\relax
- \setbox\scratchbox\emptyhbox
- \wd\scratchbox\makeupwidth
- \ht\scratchbox\scratchdimen
- \vsmash{\registeredtextarea00\scratchbox}%
- \endgroup
- #1%
- \endgraf
- \xypos{pbd:\realfolio:e}%
+% 1 = partial page, 2 = whole page, 3 = partial page
+
+\setnewconstant\kindofpagetextareas\plustwo
+
+\def\OTRONEregisteredtextareaA
+ {\ifconditional\c_page_areas_enabled
+ \expandafter\OTRONEregisteredtextareaAindeed
\else
- #1%
+ \expandafter\firstofoneargument
\fi}
-\def\doOTRONEregisteredtextareaB#1%
- {\ifregistertextareas
- \setbox0\vbox{#1}%
- \wd0\makeupwidth % somehow a space creeps in
- \vbox{\registeredtextarea000}%
+\def\OTRONEregisteredtextareaB
+ {\ifconditional\c_page_areas_enabled
+ \expandafter\OTRONEregisteredtextareaBindeed
\else
- #1%
+ \expandafter\firstofoneargument
\fi}
-\let\OTRONEregisteredtextareaA\firstofoneargument
-\let\OTRONEregisteredtextareaB\firstofoneargument
-
-% 1 = partial page, 2 = whole page, 3 = partial page
-
-\setnewconstant\kindofpagetextareas\plustwo
+\def\OTRONEregisteredtextareaAindeed
+ {\ifcase\kindofpagetextareas
+ \expandafter\firstofoneargument
+ \or % partial page (experimental)
+ \expandafter\page_areas_register_direct
+ \or % whole page (default)
+ \expandafter\firstofoneargument
+ \or % partial page (only works well with no stretch!)
+ \expandafter\page_areas_register_boxed
+ \fi}
-\def\OTRONEdopagecontents#1#2% \box<n> \unvbox<n>
- {\bgroup % niet breedte zetten, kan fractie zijn!
- %
- \donetrue\processnotes{\dochecknote\ifbottomnotes\else\donefalse\fi}%
- \ifcase\kindofpagetextareas
+\def\OTRONEregisteredtextareaBindeed
+ {\ifcase\kindofpagetextareas
+ \expandafter\firstofoneargument
\or % partial page (experimental)
- \let\OTRONEregisteredtextareaA\doOTRONEregisteredtextareaA
+ \expandafter\firstofoneargument
\or % whole page (default)
- \let\OTRONEregisteredtextareaB\doOTRONEregisteredtextareaB
+ \expandafter\page_areas_register_boxed
\or % partial page (only works well with no stretch!)
- \let\OTRONEregisteredtextareaA\doOTRONEregisteredtextareaB
- \fi
- %
- \setbox0\vbox \ifdone to \textheight \fi
- {\edef\currentpagedepth{\the\dp#2}% still to be derived from #1
+ \expandafter\firstofoneargument
+ \fi}
+
+\newdimen\d_page_one_natural_depth
+
+\def\OTRONEdopagecontents#1#2% \box<n> \unvbox<n> % this one will be redone (checked)
+ {\bgroup
+ \notes_check_if_bottom_present
+ \setbox0\vbox \ifconditional\c_notes_bottom_present to \textheight \fi
+ {\d_page_one_natural_depth\dp#2\relax
\dotopinsertions
+ \OTRONEregisteredtextareaA{#1#2}%
\ifgridsnapping
- \OTRONEregisteredtextareaA{#1#2}%
- \vskip-\currentpagedepth\vskip\openstrutdepth
+ \vskip\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax
\prevdepth\openstrutdepth
\dobotinsertions
\vfil
\else\ifr@ggedbottom
- \OTRONEregisteredtextareaA{#1#2}%
- \vskip-\currentpagedepth\vskip\openstrutdepth
+ \vskip\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax
\prevdepth\openstrutdepth
\dobotinsertions
\vfil
\else\ifb@selinebottom
- \OTRONEregisteredtextareaA{#1#2}%
- \kern-\currentpagedepth\kern\maxdepth
+ \kern\dimexpr\maxdepth-\d_page_one_natural_depth\relax
\dobotinsertions
\else
- \OTRONEregisteredtextareaA{#1#2}%
- \dobotinsertions % added
+ \dobotinsertions
\fi\fi\fi
- \fakepagenotes}% was \fakenotes, but wrong! (check with \setupalign[height])
- % we could use the local snapper hier
- \ifdone
+ \fakepagenotes}%
+ \ifconditional\c_notes_bottom_present
\ifgridsnapping
- \ifcase\layoutlines % todo: make macro of this
+ \ifcase\layoutlines
\getrawnoflines\textheight
\else
\noflines\layoutlines
- \fi
- \advance\noflines \minusone
- \scratchdimen\noflines\lineheight
- \advance\scratchdimen \topskip
+ \fi
+ \advance\noflines\minusone
+ \scratchoffset\dimexpr\noflines\lineheight+\topskip\relax
\else
- \scratchdimen\ht0
+ \scratchoffset\ht0
\fi
\else
- \scratchdimen\zeropoint
+ \scratchoffset\zeropoint
\fi
- %
\setbox2\hbox
- {\checksinglecolumnfootnotes
- \lower\scratchdimen
+ {\checksinglecolumnfootnotes % why this check?
+ \lower\scratchoffset
\vbox{\placebottomnotes}}%
\smashbox2% % needed here
- \ifdone
- \ht0\zeropoint
- \fi
\OTRONEregisteredtextareaB
{\vbox to \textheight
- {\box0
- \box2
- \ifdone \else\vfill\fi}}%
+ {\ifconditional\c_notes_bottom_present
+ \ht0\zeropoint
+ \box0
+ \box2
+ \else
+ \box0
+ \box2
+ \vfill
+ \fi}}%
\egroup}
\def\OTRONEfinalsidefloatoutput
{\finaloutput\unvbox\normalpagebox}
-\OTRONEoutput
- {\sidefloatoutput}
+\OTRONEoutput{\page_sides_output_routine} % this will become a command
%D Insertions
@@ -197,7 +191,7 @@
\ifdim\totaltopinserted>\zeropoint\relax
\ifdim\dimexpr\rootfloatparameter\c!nlines\lineheight+\totaltopinserted\relax>\textheight
\showmessage\m!floatblocks8{\rootfloatparameter\c!nlines}%
- \vfilll\eject
+ \page_otr_fill_and_eject_page % was tripple: vfilll
\fi
\fi
\fi
@@ -429,48 +423,8 @@
\doinsertfloatinfo
\dohandlenextfloatindent}
-% \def\OTRONEsomefixdfloat % [#1]
-% {\docheckiffloatfits
-% \ifroomforfloat\else
-% \goodbreak
-% \fi
-% \showmessage\m!floatblocks9\empty
-% \someherefloat} % [#1]
-%
-% better:
-%
-% \dorecurse{50}
-% {[before normal] \input thuan
-% \placefigure{normal}{\framed[height=1cm,width=8cm]{}}
-% \placefigure{normal}{\framed[height=2cm,width=8cm]{}}
-% [before force] \input thuan
-% \placefigure[force]{force}{\framed[height=8cm,width=8cm]{}}}
-
\setnewconstant\fixedfloatmethod\plusthree
-% \def\OTRONEsomefixdfloat % [#1]
-% {\docheckiffloatfits
-% \ifroomforfloat\else
-% \ifzeropt\pagetotal
-% % let's assume that there is room
-% \else
-% \ifcase\fixedfloatmethod
-% % disabled
-% \or % 1 (old method)
-% \goodbreak
-% \or % 2 (safe method)
-% \page
-% \or % 3 (keeps in stream)
-% \vskip\textheight
-% \vskip-\textheight
-% \or % 4 (also keeps in place)
-% \dosomebreak\nobreak
-% \fi
-% \fi
-% \fi
-% \showmessage\m!floatblocks9\empty
-% \someherefloat} % [#1]
-
\def\OTRONEsomefixdfloat % [#1]
{% there is (in mkii) no good way to prevent a break
% so better fail than mess, we can get loose from
@@ -483,8 +437,6 @@
\someelsefloat[\v!here]%
\else
%\checkwaitingfloats{#1}%
- \def\logsidefloat
- {\doinsertfloatinfo}%
\setbox\floatbox\vbox{\box\floatbox}%
\wd\floatbox\floatwidth
\processfirstactioninset
diff --git a/tex/context/base/page-par.mkiv b/tex/context/base/page-par.mkiv
index e1096fdf8..26e306ef5 100644
--- a/tex/context/base/page-par.mkiv
+++ b/tex/context/base/page-par.mkiv
@@ -34,7 +34,10 @@
\def\dodoshowparagraphnumber
{\global\advance\internalparagraphnumber \plusone
\inleftmargin % \tf normalizes em
- {\tf{\doattributes\??ph\c!style\c!color{\the\internalparagraphnumber}}%
+ {\tf
+ \dousestyleparameter\@phstyle
+ \dousecolorparameter\@phcolor
+ \the\internalparagraphnumber
\kern\@@phdistance}}
\def\doshowparagraphnumberA
diff --git a/tex/context/base/page-plg.mkiv b/tex/context/base/page-plg.mkiv
index d008dfb1d..0921682c4 100644
--- a/tex/context/base/page-plg.mkiv
+++ b/tex/context/base/page-plg.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\ifx\pageareabox\undefined \else \endinput \fi
+% \ifx\pageareabox\undefined \else \endinput \fi
\writestatus{loading}{ConTeXt Page Macros / Extra Page Building}
@@ -110,7 +110,7 @@
\unprotect
-\def\constructmakeuppagecontent#1#2%
+\def\page_boxes_construct_content_makeup#1#2%
{\setbox\pagebox\hbox
{\vbox to \textheight
{\offinterlineskip
@@ -137,40 +137,39 @@
\ht\pagebox\paperheight
\dp\pagebox\zeropoint}
-\installlayoutalternative\v!makeup
- {\constructmakeuppagecontent}
+\installlayoutalternative\v!makeup{\page_boxes_construct_content_makeup}
\newbox\pageareabox
\def\pagearea
- {\dotripleempty\dopagearea}
+ {\dotripleempty\page_area}
-\def\dopagearea[#1][#2][#3]%
+\def\page_area[#1][#2][#3]%
{\ifthirdargument
\doifelse{#3}\v!left
- {\dodopagearea{#1}{#2}\c!lefttext}
+ {\page_area_indeed{#1}{#2}\c!lefttext}
{\doifelse{#3}\v!right
- {\dodopagearea{#1}{#2}\c!righttext}
- {\dodopagearea{#1}{#2}\c!middletext}}%
+ {\page_area_indeed{#1}{#2}\c!righttext}
+ {\page_area_indeed{#1}{#2}\c!middletext}}%
\else\ifsecondargument
\doifbothsidesoverruled
- {\dodopagearea{#1}{#2}\c!righttext}
- {\dodopagearea{#1}{#2}\c!righttext}
- {\dodopagearea{#1}{#2}\c!lefttext }%
+ {\page_area_indeed{#1}{#2}\c!righttext}
+ {\page_area_indeed{#1}{#2}\c!righttext}
+ {\page_area_indeed{#1}{#2}\c!lefttext }%
\else
\doif{#1}\v!text % copy due to trial runs in TABLE
{\iftrialtypesetting
\copy\pagebox
\else
\localpositioningfalse
- \addtextbackground\pagebox
- \addtextgridlayer\pagebox
+ \page_backgrounds_add_to_text\pagebox
+ \page_grids_add_to_box\pagebox
\box\pagebox
\fi}%
\fi\fi}
-\def\dodopagearea#1#2#3%
- {\setbox\pageareabox\vbox{\getvalue{\??tk#1#2#3}}%
+\def\page_area_indeed#1#2#3%
+ {\setbox\pageareabox\vbox{\getspecificlayouttext{#1}{#2}{#3}}%
\ifsomebackgroundfound{#1#2}%
\iftrialtypesetting
\box\pageareabox
@@ -188,13 +187,18 @@
% to be done nicely (proper namespacing)
-\setvalue{\??ly\c!method:\v!leftpage }{\getvalue{\??ly\c!method:\v!page}}
-\setvalue{\??ly\c!method:\v!rightpage}{\getvalue{\??ly\c!method:\v!page}}
+\setvalue{\??ly:m:\v!leftpage }{\csname\??ly:m:\v!page\endcsname}
+\setvalue{\??ly:m:\v!rightpage}{\csname\??ly:m:\v!page\endcsname}
-\long\unexpanded\def\startpagelayout
- {\bgroup\catcode\endoflineasciicode\ignorecatcode\dostartpagelayout}
+\unexpanded\def\startpagelayout
+ {\bgroup
+ \catcode\endoflineasciicode\ignorecatcode
+ \start_page_layout}
-\long\def\dostartpagelayout[#1]#2\stoppagelayout
- {\egroup\long\setvalue{\??ly\c!method:#1}{#2}}
+\let\stoppagelayout\relax
+
+\def\start_page_layout[#1]#2\stoppagelayout
+ {\egroup
+ \setvalue{\??ly:m:#1}{#2}}
\protect \endinput
diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv
index 0796dbb2b..9777e433b 100644
--- a/tex/context/base/page-set.mkiv
+++ b/tex/context/base/page-set.mkiv
@@ -437,7 +437,7 @@
\vss
\fi}%
\wd\scratchbox\localcolumnwidth % \textwidth
- \docolumnpagebodymarks{#1}{#2}\recurselevel\scratchbox
+ \page_marks_synchronize_column{#1}{#2}\recurselevel\scratchbox
\ifcase\columndirection
\hskip\OTRSETgetparameter\c!distance\recurselevel\box\scratchbox
\else
@@ -572,7 +572,8 @@
\def\OTRSETsetvsize % snap per sectie (gap here?)
{\ifcollectingcontent \else % can be assigndimen
-\OTRSETskipstart % not that well tested
+ \OTRSETsetcolumnmaxcells % layout can be changed
+ \OTRSETskipstart % not that well tested
\OTRSETcheckinsert % added
\OTRSETsetfreecells\mofcolumns\columnfirstcell
\ifsomefreecolumncells
@@ -625,8 +626,8 @@
% \egroup
% \fi
% % brrr:
-% \ejectinsert
-% \ejectpage
+% \page_otr_flush_all_floats
+% \page_otr_eject_page
% \OTRSETsynchronizehsize} % no \OTRSETsethsize, can be mid smaller (like tabulate)
%
% \installcolumnbreakhandler {SET} \v!forceer
@@ -654,8 +655,8 @@
\installcolumnbreakhandler {SET} \v!local
{\OTRSETcolumnhbreak
- \ejectinsert
- \ejectpage % brrr
+ \page_otr_flush_all_floats
+ \page_otr_eject_page
% no \OTRSETsethsize, can be mid smaller (like tabulate)
% also, this one should be executed at the outer level
% (setting hsize inside otr does not work)
@@ -670,8 +671,8 @@
{\OTRSETcolumnhbreak
\edef\savedmofcolumns{\the\mofcolumns}%
\edef\savedrealpageno{\the\realpageno}%
- \ejectinsert
- \ejectpage % brrr
+ \page_otr_flush_all_floats
+ \page_otr_eject_page
\doloop
{\ifnum\savedmofcolumns=\mofcolumns
\ifnum\savedrealpageno=\realpageno
@@ -688,14 +689,14 @@
{\expanded{\OTRSETgotocolumn[\@@columnspecification]}}
\installcolumnbreakhandler {SET} \v!page
- {\vfill\eject % \doejectpage\eject
+ {\page_otr_fill_and_eject_page
\OTRSETgotonextpage}
\newtoks\OTRSETeverystartofcolumn
\newbox\OTRSETsavedfootnotes
-% \installoutput\OTRSETflushtextsofar % spacing goes wrong
+% \installoutputroutine\OTRSETflushtextsofar % spacing goes wrong
%\def\OTRSETflushtextsofar
% {\ifvoid\normalpagebox \else
@@ -734,7 +735,7 @@
\newskip\lastskipinotr
-\installoutput\doOTRSETflushtextsofar % experimental
+\installoutputroutine\doOTRSETflushtextsofar % experimental
{\ifvoid\normalpagebox\else
\scratchdimen\dp\normalpagebox
\setbox\scratchbox\vbox
@@ -816,7 +817,7 @@
\doOTRSETsetgridcells
{\copy\placeholderboxf}
\mofcolumns\columnfirstcell\plusone\noflines
- {\registeredtextarea1\columnfirstcell\scratchbox}% == \hbox / tricky htcorr == \columnfirstcell
+ {\page_areas_registered_box1\columnfirstcell\scratchbox}% == \hbox / tricky htcorr == \columnfirstcell
\global\columnlastcell\columnfirstcell
\global\advance\columnlastcell \noflines
\global\lastcolumnlastcell\columnlastcell
@@ -1489,7 +1490,7 @@
\definecolumnset[\s!default][\c!n=2] % fallback
\def\OTRSETgotonextpage
- {\vfill\eject
+ {\page_otr_fill_and_eject_page
\relax\ifnum\mofcolumns>\plusone
\OTRSETgotocolumn[\v!last]%
\ifnum\mofcolumns>\plusone
@@ -1515,7 +1516,7 @@
\def\doOTRSETgotoCOLUMN#1%
{\ifnum\mofcolumns=#1\else
- \vfill\eject % \doejectpage\eject
+ \page_otr_fill_and_eject_page
\doloop
{\ifnum\mofcolumns=#1\relax
\exitloop \else \OTRSETdummycolumn
@@ -1594,8 +1595,7 @@
\def\OTRSETdummycolumn
{\verticalstrut
\vskip-\struttotal
- \vfill
- \eject}
+ \page_otr_fill_and_eject_page}
\newcounter\columnsetlevel
\let\currentcolumnset\empty
@@ -1615,7 +1615,7 @@
\globallet\columnsetpage\!!plusone
\def\currentcolumnset{#2}%
\insidecolumnstrue % will be different flag in addition
- \activateotr{SET}{ONE}% andere naam, activate or so
+ \page_otr_activate{SET}{ONE}% andere naam, activate or so
\doifelsenothing{#1}
{\globallet\OTRSETlist\s!default}
{\xdef\OTRSETlist{#1}}%
@@ -1719,7 +1719,7 @@
% inhibit flush of floats !
% todo: nothing if no footnotes, else empty page
\dostepwiserecurse\mofcolumns\nofcolumns\plusone
- {\vskip-\struttotal\verticalstrut\vfill\eject}%
+ {\vskip-\struttotal\verticalstrut\page_otr_fill_and_eject_page}%
\else
\ifnum\mofcolumns>\plusone
\donetrue
@@ -1734,8 +1734,7 @@
\else
% probably todo
\fi
- \vfill
- \eject
+ \page_otr_fill_and_eject_page
% brr, may result in empty page after nicely fit text
% or if left, then lost of first column only text
\ifnum\mofcolumns>\plusone
@@ -1794,10 +1793,13 @@
\fi}%
\OTRSETchecksidefloat}
+\def\OTRSETsetcolumnmaxcells
+ {\getrawnoflines\textheight\xdef\columnmaxcells{\the\noflines}}
+
\def\OTRSETinitializefeatures
{% number of lines
% new: raw
- \getrawnoflines\textheight\xdef\columnmaxcells{\the\noflines}%
+ \OTRSETsetcolumnmaxcells
% direction
\doifelsevalue{\??mc\OTRSETidentifier\c!direction}\v!right
{\columndirection\zerocount}
@@ -1823,7 +1825,7 @@
\ifx\lastskipinotr\undefined \newskip\lastskipinotr \fi
-\installoutput\OTRSETflushpreposttext
+\installoutputroutine\OTRSETflushpreposttext
{\global\setbox\precolumnbox\vbox
{\unvbox\normalpagebox
\global\lastskipinotr\lastskip}%
@@ -1907,7 +1909,7 @@
\ifcase\columnsetlevel\relax
\mofcolumns\plusone
\OTRSETinitializecolumns
- \OTRSETassignwidths
+ \OTRSETassignwidths % already done
\OTRSETsethsize
\fi
\!!counta#2\!!countb#3\docalculatecolumnsetspan
@@ -2030,7 +2032,7 @@
\advance\dimen0 \totaltopinserted\relax
\ifdim\dimen0>\textheight % \vsize %%%%%%%%% \textheight
\showmessage\m!floatblocks8{\rootfloatparameter\c!nlines}%
- \vfilll\eject
+ \page_otr_fill_and_eject_page % was triple: vfilll
\fi
\fi
\fi
diff --git a/tex/context/base/page-sid.mkiv b/tex/context/base/page-sid.mkiv
index 8900608ab..efea19e70 100644
--- a/tex/context/base/page-sid.mkiv
+++ b/tex/context/base/page-sid.mkiv
@@ -15,24 +15,6 @@
\unprotect
-% problem: when too small, side effects; we need to determine the
-% shift earlier so that we can act when shift < size
-%
-% \definefloat[edgefigure]
-% \setupfloat
-% [edgefigure]
-% [rightmargindistance=-\rightmargintotal,
-% leftmargindistance=-\rightmargintotal,
-% default=outer]
-% \starttext
-% \placeedgefigure{}{\framed[width=12cm]{}} \input tufte
-% \placeedgefigure{}{\framed[width=5cm]{}} \input tufte
-% \placeedgefigure{}{\framed[width=4cm]{}} \input tufte
-% \placeedgefigure{}{\framed[width=2cm]{}} \input tufte
-% \stoptext
-
-% todo: dimexpr an dnumexpr
-
% These macro deal with side floats. We started with Daniel
% Comenetz macros as published in TUGBoat Volume 14 (1993),
% No.\ 1: Anchored Figures at Either Margin. I extended and
@@ -40,76 +22,67 @@
% messy module. Therefore, this module badly needs an update
% because it's now a mixture of old and new macros.
-% afhankelijke variabelen
+% Interesting cases where it goes wrong:
%
-% \overgap vervangen door \floatsidetopskip
-% \sidegap vervangen door \floatsideskip
-% \undergap vervangen door \floatsidebottomskip
+% \placefigure[left]{}{} \dorecurse{3}{\input ward } {\par} \input ward
%
-% \prskp vervangen door \ctxparskip
+% Here we get an unwanted carried over hangindent and parindent. A
+% solution is to associate it with the local par node instead. This
+% is something to discuss with Taco as it could be a new luatex
+% feature: explicitly set par properties.
-% toegevoegde macro's/aanroepen
-%
-% \logsidefloat : loginformatie
-% \flushsidefloats : nodig voor koppen
+% Maybe I should just rewrite the lot.
-% recente wijzigingen:
-%
-% namen aangepast: \float... enz. i.p.v. \pic
-
-% Pas op: \EveryPar{\EveryPar{}\margetitel{whatever}}
-% \plaatsfiguur[links]{}{} moet goed gaan. In dat geval
-% begint de tekst terecht wat lager.
-
-\newdimen\sidefloatheight % includes the topskip
-\newdimen\sidefloatwidth
-\newdimen\sidefloathsize
-\newdimen\sidefloatshift
-\newdimen\sidefloatextrashift
-\newdimen\sidefloatvsize \def\nofloatvsize{-1pt }
-\newdimen\sidefloatprogress
-\newdimen\sidefloatpagetotal
-
-\newbox\floatbottom
-
-\newcount\sidefloatsidelines
-\newcount\sidefloatlinesdone
-
-% 1 = backspace
-% 2 = leftedge
-% 3 = leftmargin
-% 4 = leftside
-% 5 = rightside
-% 6 = rightmargin
-% 7 = rightedge
-% 8 = cutspace
-
-\newconstant\sidefloattype
-
-\def\backspacefloat {\global\sidefloattype1 \putsidefloat}
-\def\leftedgefloat {\global\sidefloattype2 \putsidefloat}
-\def\leftmarginfloat {\global\sidefloattype3 \putsidefloat}
-\def\leftfloat {\global\sidefloattype4 \putsidefloat}
-\def\rightfloat {\global\sidefloattype5 \putsidefloat}
-\def\rightmarginfloat {\global\sidefloattype6 \putsidefloat}
-\def\rightedgefloat {\global\sidefloattype7 \putsidefloat}
-\def\cutspacefloat {\global\sidefloattype8 \putsidefloat}
-
-\let\marginfloat \cutspacefloat
-
-\newif\ifroomforfloat
-\newif\iffloatshort
-\newif\iffloatflag
-\newif\iffloatrighteqo
-\newif\iffloatlefteqo
-
-\newdimen\sidefloatleftskip
-\newdimen\sidefloatrightskip
-\newdimen\sidefloatmaximum
-
-\def\checksidefloatshift
+\newdimen \d_page_sides_height % includes the topskip
+\newdimen \d_page_sides_width
+\newdimen \d_page_sides_hsize
+\newdimen \d_page_sides_vsize
+\newdimen \d_page_sides_vsize_reset \d_page_sides_vsize_reset -\onepoint % signal (could be a chardef)
+\newdimen \d_page_sides_progress
+\newdimen \d_page_sides_page_total
+\newdimen \d_page_sides_saved_depth
+
+\newbox \b_page_sides_bottom
+
+\newcount \c_page_sides_lines_done
+\newcount \c_page_sides_checks_done
+\newcount \c_page_sides_n_of_lines
+\newconstant \c_page_sides_float_type
+
+\newconditional \c_page_sides_short
+\newconditional \c_page_sides_flag
+
+\newconditional \c_page_sides_r_eq % messy, needs checking anyway
+\newconditional \c_page_sides_l_eq % messy, needs checking anyway
+
+\newif \ifroomforfloat % shared (will change)
+\newif \iftracesidefloats % public (might change)
+
+\newdimen \sidefloatshift % public
+\newdimen \sidefloatextrashift % public
+\newdimen \sidefloatleftskip % public
+\newdimen \sidefloatrightskip % public
+\newdimen \sidefloatmaximum % public
+
+\def\backspacefloat {\global\c_page_sides_float_type\plusone \page_sides_handle_float}
+\def\leftedgefloat {\global\c_page_sides_float_type\plustwo \page_sides_handle_float}
+\def\leftmarginfloat {\global\c_page_sides_float_type\plusthree\page_sides_handle_float}
+\def\leftfloat {\global\c_page_sides_float_type\plusfour \page_sides_handle_float}
+\def\rightfloat {\global\c_page_sides_float_type\plusfive \page_sides_handle_float}
+\def\rightmarginfloat{\global\c_page_sides_float_type\plussix \page_sides_handle_float}
+\def\rightedgefloat {\global\c_page_sides_float_type\plusseven\page_sides_handle_float}
+\def\cutspacefloat {\global\c_page_sides_float_type\pluseight\page_sides_handle_float}
+
+\let\marginfloat \cutspacefloat
+
+\let\logsidefloat \relax
+
+\def\page_sides_insert_info
+ {\doinsertfloatinfo}
+
+\def\page_sides_apply_horizontal_shift
{\ifdim\sidefloatmaximum>\zeropoint
- \ifcase\sidefloattype
+ \ifcase\c_page_sides_float_type
% invalid
\or
% backspace
@@ -148,12 +121,27 @@
\or
% cutspace
\fi
+ \fi
+ \ifdim\sidefloatshift=\zeropoint \relax
+ \ifnum\c_page_sides_float_type=\plusfour
+ \global\advance\sidefloatshift\sidefloatextrashift
+ \global\sidefloatextrashift\zeropoint
+ \else\ifnum\c_page_sides_float_type=\plusfive
+ \global\advance\sidefloatshift\sidefloatextrashift
+ \global\sidefloatextrashift\zeropoint
+ \fi\fi
+ \else
+ \ifnum\c_page_sides_float_type<\plusfour
+ \global\c_page_sides_float_type\plusfour
+ \else\ifnum\c_page_sides_float_type>\plusfive
+ \global\c_page_sides_float_type\plusfive
+ \fi\fi
\fi}
-\def\setsidefloatskips
+\def\page_sides_set_skips
{\global\sidefloatrightskip\zeropoint
\global\sidefloatleftskip \zeropoint
- \ifcase\sidefloattype
+ \ifcase\c_page_sides_float_type
\or % backspace
\global\sidefloatleftskip\dimexpr
+\rightorleftpageaction \backspace \cutspace
@@ -194,298 +182,229 @@
\ifdim\sidefloatrightskip>\zeropoint \doglobal\advance\sidefloatrightskip\rightskip \fi
\ifdim\sidefloatleftskip >\zeropoint \doglobal\advance\sidefloatleftskip \leftskip \fi}
-% eq is still crap
-
-\ifx\normalleqno\undefined
-
- \let\floatrighteqo=\eqno
- \let\floatleftleqo=\leqno
-
-\else
-
- \let\floatrighteqo=\normaleqno
- \let\floatleftleqo=\normalleqno
-
-\fi
-
-% Watch it even more! In inner, gaat't mis omdat daar
-% pagetotal enz niet zijn aangepast. Inner kan overigens niet
-% betrouwbaar worden getest!
-
-\newif\iftracesidefloats
-
-\def\flushsidefloats
+\def\page_sides_flush_floats
{\par
- \!!heighta\sidefloatvsize
- \advance\!!heighta -\pagetotal
- \ifnum\!!heighta>\zeropoint
- \global\advance\sidefloatvsize -\sidefloatbottomskip
- \ifdim\!!heighta>\zeropoint
- \bgroup
- \let\flushsidefloats\relax
- \forgetall
- \doloop
- {\strut
- \iftracesidefloats
- \color[darkgray]%
- {\baselinerulefalse
- \boxrulewidth.5\points
- \ruledhbox{\strut\kern\sidefloatwidth}}%
- \fi
- \par
- \!!heighta\sidefloatvsize
- \advance\!!heighta -\pagetotal
- \ifdim\!!heighta>\zeropoint
- \ifnum\recurselevel>\plushundred
- \exitloop
- \fi
- \else
- \exitloop
- \fi}%
- \egroup
- \ifdim\parskip>\zeropoint
- \ifdim\sidefloatbottomskip>\parskip
- \nowhitespace
- \vskip\sidefloatbottomskip
- \fi
- \fi
- \else\ifdim\sidefloatbottomskip>\parskip
- \vskip\sidefloatbottomskip
- \fi\fi
+ \ifnum\dimexpr\d_page_sides_vsize-\pagetotal\relax>\zeropoint
+ \page_sides_flush_floats_indeed
\fi
- % not entirely the same as \forgetsidefloats
- \global\sidefloatvsize\nofloatvsize
- % \global\sidefloatsidelines\zerocount % no, we flush before a side float
- \global\floatshortfalse % so this will get lost
% also here if used at all \global\holdinginserts\zerocount
- \global\floatflagfalse}
+ \global\d_page_sides_vsize\d_page_sides_vsize_reset
+ \global\setfalse\c_page_sides_short
+ \global\setfalse\c_page_sides_flag}
+
+\def\page_sides_flush_floats_indeed
+ {\global\advance\d_page_sides_vsize-\sidefloatbottomskip
+ \begingroup
+ \let\page_sides_flush_floats\relax
+ \forgetall
+ \doloop
+ {\strut
+ \iftracesidefloats
+ \color[darkgray]%
+ {\baselinerulefalse
+ \boxrulewidth.5\points
+ \ruledhbox{\strut\kern\d_page_sides_width}}%
+ \fi
+ \par
+ \ifdim\dimexpr\d_page_sides_vsize-\pagetotal\relax>\zeropoint
+ \ifnum\recurselevel>\plushundred % safeguard, sort of deadcycles
+ \exitloop
+ \fi
+ \else
+ \exitloop
+ \fi}%
+ \endgroup
+ \ifdim\parskip>\zeropoint % why this test ?
+ \ifdim\sidefloatbottomskip>\parskip
+ \nowhitespace
+ \vskip\sidefloatbottomskip
+ \fi
+ \fi}
-\def\dochecksidefloatafterpar
- {\dochecksidefloat
+\def\page_sides_check_floats_after_par
+ {\page_sides_check_floats_indeed
\ifdim\oldpagetotal=\pagetotal \else
- \global\let\checksidefloat\dochecksidefloat
- \flushsidefloats
- \global\sidefloatsidelines\zerocount % here !
+ \global\let\page_sides_check_floats\page_sides_check_floats_indeed
+ \page_sides_flush_floats
+ \global\c_page_sides_n_of_lines\zerocount % here !
\fi}
-\def\flushsidefloatsafterpar
+\def\page_sides_flush_floats_after_par
{\xdef\oldpagetotal{\the\pagetotal}%
- \global\let\checksidefloat\dochecksidefloatafterpar}
+ \global\let\page_sides_check_floats\page_sides_check_floats_after_par}
-\def\forgetsidefloats
- {\global\sidefloatvsize\nofloatvsize
- \global\sidefloatsidelines\zerocount
+\def\page_sides_forget_floats
+ {\global\d_page_sides_vsize\d_page_sides_vsize_reset
+ \global\c_page_sides_n_of_lines\zerocount
% also here if used at all \global\holdinginserts\zerocount
- \global\floatshortfalse
- \global\floatflagfalse}
-
-\let\logsidefloat=\relax
-
-\def\pushpenalties % needed ? and right
- {\widowpenalty\plusone
- \clubpenalty\plustwo
- \brokenpenalty\plusone
- \let\pushpenalties\relax
- \edef\poppenalties
- {\widowpenalty \the\widowpenalty
- \clubpenalty \the\clubpenalty
- \brokenpenalty\the\brokenpenalty
- \let\poppenalties\relax}}
-
-% shouldn;t that be:
+ \global\setfalse\c_page_sides_short
+ \global\setfalse\c_page_sides_flag}
+
+\let\page_otr_sides_pop_penalties \relax
+\let\page_otr_sides_push_penalties\relax
+
+% \def\page_otr_sides_push_penalties % needed ? and right
+% {\widowpenalty\plusone
+% \clubpenalty\plustwo
+% \brokenpenalty\plusone
+% \let\page_otr_sides_push_penalties\relax
+% \edef\page_otr_sides_pop_penalties
+% {\widowpenalty \the\widowpenalty
+% \clubpenalty \the\clubpenalty
+% \brokenpenalty\the\brokenpenalty
+% \let\page_otr_sides_pop_penalties\relax}}
+%
+% shouldn't that be:
%
-% \def\pushpenalties % needed?
-% {\let\pushpenalties\relax
-% \edef\poppenalties
+% \def\page_otr_sides_push_penalties % needed?
+% {\let\page_otr_sides_push_penalties\relax
+% \edef\page_otr_sides_pop_penalties
% {\widowpenalty \the\widowpenalty
% \clubpenalty \the\clubpenalty
% \brokenpenalty\the\brokenpenalty
-% \let\poppenalties\relax}%
+% \let\page_otr_sides_pop_penalties\relax}%
% \widowpenalty\plusone
% \clubpenalty\plustwo
% \brokenpenalty\plusone}
-\let\poppenalties=\relax
-
-\def\restorepenalties
- {\ifnum\outputpenalty=\!!tenthousand\else
+\def\page_sides_restore_output_penalty
+ {\ifnum\outputpenalty=\plustenthousand \else
\penalty\outputpenalty
\fi}
-\def\sidefloatoutput
- {\iffloatshort
- \unvbox\normalpagebox
- \setbox\floatbottom\lastbox
- \ifdim\wd\floatbottom>\sidefloathsize
- \penalty-201
- \box\floatbottom
- \else
- \ifvoid\floatbottom
+\def\page_sides_output_routine
+ {\ifconditional\c_page_sides_short
+ \page_sides_output_routine_yes
+ \else
+ \page_sides_output_routine_nop
+ \fi}
+
+\def\page_sides_output_routine_nop
+ {\finalsidefloatoutput % indirect call
+ \global\d_page_sides_vsize\d_page_sides_vsize_reset
+ \global\c_page_sides_n_of_lines\zerocount
+ % we can end up in fig lock, so \global\holdinginserts\zerocount here too ?
+ \page_otr_sides_pop_penalties}
+
+\def\page_sides_output_routine_yes % we need to rework this ... add pagediscards and such
+ {\unvbox\normalpagebox
+ \setbox\b_page_sides_bottom\lastbox
+ \ifdim\wd\b_page_sides_bottom>\d_page_sides_hsize
+ \penalty-201
+ \box\b_page_sides_bottom
+ \else\ifvoid\b_page_sides_bottom
+ \else
+ \page_sides_restore_left_indent
+ \ifdim\wd\b_page_sides_bottom<\d_page_sides_hsize
+ \parskip\zeropoint
+ %\noindent
+ \ifinner\else\vadjust{\penalty\minusone}\fi
+ \ifconditional\c_page_sides_l_eq
+ \global\setfalse\c_page_sides_l_eq
\else
- \restoreleftindent
- \ifdim\wd\floatbottom<\sidefloathsize
- \parskip\zeropoint
- %\noindent
- \ifinner\else\vadjust{\penalty\minusone}\fi
- \iffloatlefteqo
- \global\floatlefteqofalse
- \else
- \global\advance\sidefloathsize -\wd\floatbottom
- \iffloatrighteqo
- \global\floatrighteqofalse
- \else
- \global\divide\sidefloathsize \plustwo
- \fi
- \hskip\sidefloathsize
- \fi
+ \global\advance\d_page_sides_hsize -\wd\b_page_sides_bottom
+ \ifconditional\c_page_sides_r_eq
+ \global\setfalse\c_page_sides_r_eq
+ \else
+ \global\divide\d_page_sides_hsize \plustwo
\fi
- \box\floatbottom
- \restorepenalties
+ \hskip\d_page_sides_hsize
\fi
\fi
- % why was this \global\holdinginserts\zerocount
- \global\floatshortfalse
- \else
- \finalsidefloatoutput % new
- \global\sidefloatvsize\nofloatvsize
- \global\sidefloatsidelines\zerocount
- % we can end up in fig lock, so \global\holdinginserts\zerocount here too ?
- \poppenalties
- \fi}
-
-\def\finalsidefloatoutput% new
- {\finaloutput\unvbox\normalpagebox}
+ \box\b_page_sides_bottom
+ \page_sides_restore_output_penalty
+ \fi\fi
+ % why was this \global\holdinginserts\zerocount
+ \global\setfalse\c_page_sides_short}
-\def\restoreleftindent
- {\relax \ifnum\sidefloattype>4 \else
+\def\page_sides_restore_left_indent
+ {\relax
+ \ifnum\c_page_sides_float_type>\plusfour \else
\parskip\zeropoint % here ?
- \ifdim\sidefloatwidth>\zeropoint % new, see prikkels
+ \ifdim\d_page_sides_width>\zeropoint % new, see prikkels
\noindent
- \ifinner\else\vadjust{\penalty\minusone}\fi
- \hskip\sidefloatwidth\relax
+ \ifinner \else
+ \vadjust{\penalty\minusone}%
+ \fi
+ \hskip\d_page_sides_width\relax
%\else
% we have a margin or edge float
\fi
\fi}
-\ifx\normaleqno\undefined
-
- \def\normaleqno
- {\iffloatshort
- \global\floatrighteqotrue
- \fi
- \floatrighteqo}
-
-\else
-
- \def\eqno
- {\iffloatshort
- \global\floatrighteqotrue
- \fi
- \floatrighteqo}
-
-\fi
-
-% externfiguur -> grid =ja|hoogte|diepte|halveregel|passend -> helemaal in details
-% stelplaatsblokin -> zijuitlijnen=hoogte|diepte|regel|halveregel|grid -> halveregel in 'details'
-
-% replacement for below
+% The clean way:
%
-% \global\setbox\floatbox\hbox % no \hskip, but \kern here
-% {\ifcase\sidefloattype
-% \vbox{#1}%
-% \or % 1
-% \hskip\sidefloatleftshift
-% \hskip\sidefloatshift
-% \vbox{#1}%
-% \kern-\sidefloatextrashift
-% \or % 2
-% \hskip\sidefloatshift
-% \vbox{#1}%
-% \kern-\sidefloatextrashift
-% \or % 3
-% \hskip\sidefloatshift
-% \vbox{#1}%
-% \kern-\sidefloatextrashift
-% \or % 4
-% \hskip\sidefloatleftshift
-% \hskip\sidefloatshift
-% \vbox{#1\removedepth}%
-% \kern-\sidefloatextrashift
-% \or % 5
-% \hskip-\sidefloatextrashift
-% \vbox{#1}%
-% \kern\sidefloatshift
-% \kern\sidefloatrightshift
-% \or % 6
-% \hskip-\sidefloatextrashift
-% \vbox{#1}%
-% \kern\sidefloatshift
-% \or % 7
-% \hskip-\sidefloatextrashift
-% \vbox{#1}%
-% \kern\sidefloatshift
-% \or % 8
-% \hskip-\sidefloatextrashift
-% \vbox{#1}%
-% \kern\sidefloatshift
-% \kern\sidefloatrightshift
-% \fi}%
+% \global\setbox\floatbox\hbox % no \hskip, but \kern here
+% {\ifcase\c_page_sides_float_type
+% \vbox{#1}%
+% \or % 1
+% \hskip\sidefloatleftshift
+% \hskip\sidefloatshift
+% \vbox{#1}%
+% \kern-\sidefloatextrashift
+% \or % 2
+% \hskip\sidefloatshift
+% \vbox{#1}%
+% \kern-\sidefloatextrashift
+% \or % 3
+% \hskip\sidefloatshift
+% \vbox{#1}%
+% \kern-\sidefloatextrashift
+% \or % 4
+% \hskip\sidefloatleftshift
+% \hskip\sidefloatshift
+% \vbox{#1\removedepth}%
+% \kern-\sidefloatextrashift
+% \or % 5
+% \hskip-\sidefloatextrashift
+% \vbox{#1}%
+% \kern\sidefloatshift
+% \kern\sidefloatrightshift
+% \or % 6
+% \hskip-\sidefloatextrashift
+% \vbox{#1}%
+% \kern\sidefloatshift
+% \or % 7
+% \hskip-\sidefloatextrashift
+% \vbox{#1}%
+% \kern\sidefloatshift
+% \or % 8
+% \hskip-\sidefloatextrashift
+% \vbox{#1}%
+% \kern\sidefloatshift
+% \kern\sidefloatrightshift
+% \fi}
%
-% keep this ^
+% The compact way:
-\def\repositionsidefloat#1%
+\def\page_sides_relocate_float#1%
{\global\setbox\floatbox\hbox % no \hskip, but \kern here
- {\ifnum\sidefloattype=\plusfour
+ {\ifnum\c_page_sides_float_type=\plusfour
\hskip\sidefloatleftshift
- \else\ifnum\sidefloattype=\plusone
+ \else\ifnum\c_page_sides_float_type=\plusone
\hskip\sidefloatleftshift
\fi\fi
- \ifnum\sidefloattype>\plusfour
+ \ifnum\c_page_sides_float_type>\plusfour
\hskip-\sidefloatextrashift
\else
\hskip\sidefloatshift
\fi
\vbox{#1\ifnum\sidefloatalign=\plusfour \removedepth\fi}%
- \ifnum\sidefloattype>\plusfour
+ \ifnum\c_page_sides_float_type>\plusfour
\kern\sidefloatshift
\else
\kern-\sidefloatextrashift
\fi
- \ifnum\sidefloattype=8
+ \ifnum\c_page_sides_float_type=\pluseight
\kern\sidefloatrightshift
- \else\ifnum\sidefloattype=\plusfive
+ \else\ifnum\c_page_sides_float_type=\plusfive
\kern\sidefloatrightshift
\fi\fi}}
-\def\putsidefloat#1% grid (4) is rather experimental
- {\par
- \whitespace
- % moved here dec 2001
- {\everypar\emptytoks\forgetall\verticalstrut\vskip-\struttotal}% moved
- \checksidefloatshift
- \ifdim\sidefloatshift=\zeropoint \relax
- \ifnum\sidefloattype=\plusfour
- \global\advance\sidefloatshift\sidefloatextrashift
- \global\sidefloatextrashift\zeropoint
- \else\ifnum\sidefloattype=\plusfive
- \global\advance\sidefloatshift\sidefloatextrashift
- \global\sidefloatextrashift\zeropoint
- \fi\fi
- \else
- \ifnum\sidefloattype<\plusfour
- \global\sidefloattype\plusfour
- \else\ifnum\sidefloattype>\plusfive
- \global\sidefloattype\plusfive
- \fi\fi
- \fi
- \previoussidefloat
- \stallsidefloat
- \repositionsidefloat{#1}%
- \ifnum\sidefloatalign=\plusfour
+\def\page_sides_apply_vertical_shift
+ {\ifnum\sidefloatalign=\plusfour
\getnoflines{\ht\floatbox}%
- \scratchdimen\noflines\lineheight
- \advance\scratchdimen-\strutdepth
+ \scratchdimen\dimexpr\noflines\lineheight-\strutdepth\relax
\getrawnoflines\sidefloattopskip
\advance\scratchdimen\noflines\lineheight
% todo: maybe rounding problem here
@@ -498,9 +417,9 @@
\global\sidefloattopskip\zeropoint
\fi
\scratchdimen
- \ifnum\sidefloattype<\plusfour
+ \ifnum\c_page_sides_float_type<\plusfour
\sidefloattopskip
- \else\ifnum\sidefloattype>\plusfive
+ \else\ifnum\c_page_sides_float_type>\plusfive
\sidefloattopskip
\else
\zeropoint
@@ -521,101 +440,38 @@
\advance\scratchdimen\strutheight
\fi
% new
- \global\sidefloatlinesdone\zerocount
- \ifnum\sidefloatsidelines>\zerocount
- \advance\scratchdimen\sidefloatsidelines\lineheight
+ \global\c_page_sides_lines_done\zerocount
+ \ifnum\c_page_sides_n_of_lines>\zerocount
+ \advance\scratchdimen\c_page_sides_n_of_lines\lineheight
\fi
- % new
- \global\setbox\floatbox\hbox
+ \global\setbox\floatbox\hbox % why extra box
{\vbox
{\vskip\scratchdimen
\nointerlineskip
\box\floatbox
\ifnum\sidefloatalign=\plusfive \vskip-\lineheight \fi}}%
- \ifnum\sidefloattype<\plusfour
+ \ifnum\c_page_sides_float_type<\plusfour
\global\sidefloattopskip\zeropoint
- \else\ifnum\sidefloattype>\plusfive
+ \else\ifnum\c_page_sides_float_type>\plusfive
\global\sidefloattopskip\zeropoint
\fi\fi
- \global\sidefloatdownshift\zeropoint
- \measuresidefloat
- \ifroomforfloat \else
- \vfill\eject % inline \tosssidefloat
- \measuresidefloat
- \stallsidefloat
- \fi
- \setsidefloat}
-
-\def\progresssidefloat
- {\sidefloatprogress\sidefloatvsize
- \advance\sidefloatprogress-\iffloatflag\sidefloatpagetotal\global\floatflagfalse\else\pagetotal\fi}
-
-\def\measuresidefloat
- {\global\floatflagtrue
- \global\sidefloatpagetotal \pagetotal % global
- \ifnum\sidefloattype<\plusfour
- \global \sidefloatwidth \zeropoint
- \else\ifnum\sidefloattype>\plusfive
- \global \sidefloatwidth \zeropoint
- \else
- \global \sidefloatwidth \wd\floatbox
- \global\advance\sidefloatwidth \floatsideskip
- \fi\fi
- \ifdim\sidefloatwidth<\zeropoint
- \global\sidefloatwidth\zeropoint
- \fi
- \global \sidefloathsize \hsize
- \global\advance\sidefloathsize -\sidefloatwidth
- \global \sidefloatheight \ht\floatbox
- \global\advance\sidefloatheight \dp\floatbox
- \global\advance\sidefloatheight \sidefloattopskip
- \global \sidefloatvsize \sidefloatheight
- \global\advance\sidefloatvsize \sidefloatpagetotal
- \dimen0\sidefloatvsize
- \dimen2\pagegoal
- \relax
- \ifcase\sidefloatmethod
- % method 0 : raw
- \or
- % method 1 : safe
- \dimen2 .99\pagegoal
- \or
- % method 2 : tight
- \advance\dimen0 -\onepoint
- \fi
- \relax % really needed ! ! ! !
- \ifdim\dimen0>\dimen2
- \global\roomforfloatfalse
- \else
- \dimen0=\pagegoal
- \advance\dimen0 -\sidefloatvsize
- \ifdim\dimen0<\sidefloatbottomskip
- \global\advance\sidefloatvsize \dimen0
- \global\floatshorttrue
- \pushpenalties
- % why was this \global\holdinginserts\plusone
- \else
- \global\advance\sidefloatvsize \sidefloatbottomskip
- \global\floatshortfalse
- \fi
- \global\roomforfloattrue
- \fi}
+ \global\sidefloatdownshift\zeropoint}
-\def\setsidefloat% nilling everypar saves time and redudant pos's
+\def\page_sides_place_float % nilling everypar saves time and redudant pos's
{% removed here dec 2001
% {\everypar\emptytoks\forgetall\verticalstrut\vskip-\struttotal}%
- \ifnum\sidefloattype=\plusfour \kern\sidefloattopskip \fi
- \ifnum\sidefloattype=\plusfive \kern\sidefloattopskip \fi
- \edef\presidefloatdepth{\the\prevdepth}%
+ \ifnum\c_page_sides_float_type=\plusfour \kern\sidefloattopskip \fi
+ \ifnum\c_page_sides_float_type=\plusfive \kern\sidefloattopskip \fi
+ \d_page_sides_saved_depth\prevdepth
\nointerlineskip
\bgroup
\everypar\emptytoks
\parskip\zeropoint
- \setsidefloatskips
- \logsidefloat
+ \page_sides_set_skips
+ \page_sides_insert_info
\relax
-\lefttoright % \textdir TLT\relax % or \ifconditional\displaylefttoright below (more work)
- \ifcase\sidefloattype
+ \lefttoright % \textdir TLT\relax % or \ifconditional\displaylefttoright below (more work)
+ \ifcase\c_page_sides_float_type
% invalid
\or % backspace
\noindent\llap{\rlap{\box\floatbox}\hskip\sidefloatleftskip}\hfill
@@ -636,161 +492,259 @@
\fi
\egroup
\par
-\ifgridsnapping
- \getrawnoflines\sidefloatheight
- \sidefloatheight=\noflines\lineheight
-\fi
- \kern-\sidefloatheight
+ \ifgridsnapping
+ \getrawnoflines\d_page_sides_height
+ \d_page_sides_height=\noflines\lineheight
+ \fi
+ \kern-\d_page_sides_height
\penalty10001 % oeps, this will change
\normalbaselines
- \prevdepth\presidefloatdepth
+ \prevdepth\d_page_sides_saved_depth
% \noindent
- \resetsidefloatparagraph
+ \page_sides_check_floats_reset
\ignorespaces} % not really needed
-
-\newcount\sidefloatparagraph
-\def\iffirstsidefloatparagraph
- {\ifcase\sidefloatparagraph\or}
+\def\page_sides_analyse_progress
+ {\d_page_sides_progress\d_page_sides_vsize
+ \ifconditional\c_page_sides_flag
+ \advance\d_page_sides_progress-\d_page_sides_page_total
+ \global\setfalse\c_page_sides_flag
+ \else
+ \advance\d_page_sides_progress-\pagetotal
+ \fi}
-% without sidefloat lines
-%
-% \def\setsidefloatparagraph
-% {%\advance\sidefloatprogress \sidefloatbottomskip
-% %\!!counta\sidefloatprogress
-% \scratchdimen\sidefloatprogress
-% \advance\scratchdimen \strutht
-% \advance\scratchdimen -\roundingeps % new, needed in prikkels, prevent rounding errors
-% \!!counta\scratchdimen
-% \divide\!!counta \baselineskip
-% \ifnum\!!counta>0
-% \hangindent \ifnum\sidefloattype>4 -\fi\sidefloatwidth
-% \hangafter-\!!counta
-% \fi
-% \global\advance\sidefloatparagraph \plusone
-% \iftracesidefloats
-% \hskip-\sidefloatwidth
-% \color[darkgray]%
-% {\vrule\!!height.5\points\!!depth.5\points\!!width\sidefloatwidth
-% %\hskip-.25\bodyfontsize\showstruts\strut\hskip.25\bodyfontsize}%
-% \llap{\showstruts\strut\hskip.25\bodyfontsize}}%
-% \fi}
+\def\page_sides_analyse_space
+ {\global\settrue\c_page_sides_flag
+ \global\d_page_sides_page_total \pagetotal % global
+ \ifnum\c_page_sides_float_type<\plusfour
+ \global\d_page_sides_width \zeropoint
+ \else\ifnum\c_page_sides_float_type>\plusfive
+ \global\d_page_sides_width\zeropoint
+ \else
+ \global\d_page_sides_width\dimexpr\wd\floatbox+\floatsideskip\relax
+ \fi\fi
+ \ifdim\d_page_sides_width<\zeropoint
+ \global\d_page_sides_width\zeropoint
+ \fi
+ \global\d_page_sides_hsize \dimexpr\hsize-\d_page_sides_width\relax
+ \global\d_page_sides_height\dimexpr\ht\floatbox+\dp\floatbox+\sidefloattopskip\relax
+ \global\d_page_sides_vsize \dimexpr\d_page_sides_height+\d_page_sides_page_total\relax
+ \dimen0\d_page_sides_vsize
+ \dimen2\pagegoal
+ \relax
+ \ifcase\sidefloatmethod
+ % method 0 : raw
+ \or
+ % method 1 : safe
+ \dimen2 .99\pagegoal
+ \or
+ % method 2 : tight
+ \advance\dimen0 -\onepoint
+ \fi
+ \relax % really needed ! ! ! !
+ \ifdim\dimen0>\dimen2
+ \global\roomforfloatfalse
+ \else
+ \ifdim\dimexpr\pagegoal-\d_page_sides_vsize\relax<\sidefloatbottomskip
+ \global\advance\d_page_sides_vsize \dimen0
+ \global\settrue\c_page_sides_short
+ \page_otr_sides_push_penalties
+ % why was this \global\holdinginserts\plusone
+ \else
+ \global\advance\d_page_sides_vsize \sidefloatbottomskip
+ \global\setfalse\c_page_sides_short
+ \fi
+ \global\roomforfloattrue
+ \fi}
+
+\def\page_sides_prepare_space
+ {\par
+ \whitespace
+ \begingroup
+ \everypar\emptytoks
+ \forgetall
+ \verticalstrut
+ \vskip-\struttotal
+ \endgroup}
+
+\def\page_sides_handle_float#1% grid (4) is rather experimental
+ {\page_sides_prepare_space
+ \page_sides_apply_horizontal_shift
+ \page_sides_check_previous_float
+ \page_sides_inject_dummy_lines
+ \page_sides_relocate_float{#1}%
+ \page_sides_apply_vertical_shift
+ \page_sides_analyse_space
+ \ifroomforfloat \else
+ \page_otr_fill_and_eject_page
+ \page_sides_analyse_space
+ \page_sides_inject_dummy_lines
+ \fi
+ \page_sides_place_float}
+
+\def\page_sides_check_floats_indeed
+ {\page_sides_analyse_progress
+ \ifdim\d_page_sides_progress>\zeropoint
+ \page_sides_check_floats_set
+ \else
+ \page_sides_check_floats_reset
+ \fi
+ \parskip\ctxparskip}
+
+\let\page_sides_check_floats\page_sides_check_floats_indeed
-\def\setsidefloatparagraph
- {%\advance\sidefloatprogress \sidefloatbottomskip
- %\!!counta\sidefloatprogress
- \scratchdimen\sidefloatprogress
- \advance\scratchdimen \strutht
- \advance\scratchdimen -\roundingeps % new, needed in prikkels, prevent rounding errors
+\def\iffirstsidefloatparagraph
+ {\ifcase\c_page_sides_checks_done\or}
+
+\def\page_sides_check_floats_set
+ {\scratchdimen\dimexpr\d_page_sides_progress+\strutht-\roundingeps\relax
\!!counta\scratchdimen
\divide\!!counta \baselineskip\relax
- \ifnum\!!counta>0
- % new from here
- \ifcase\sidefloatsidelines\else
- \ifcase\sidefloatlinesdone
- \global\sidefloatlinesdone\!!counta
+ \ifnum\!!counta>\zerocount
+ % new from here (needs test case, old code)
+ \ifcase\c_page_sides_n_of_lines
+ \else
+ \ifcase\c_page_sides_lines_done
+ \global\c_page_sides_lines_done\!!counta
\else
- \scratchcounter\sidefloatlinesdone
+ \scratchcounter\c_page_sides_lines_done
\advance\scratchcounter-\!!counta
- \global\advance\sidefloatsidelines-\scratchcounter
+ \global\advance\c_page_sides_n_of_lines-\scratchcounter
\fi
\fi
- \ifnum\sidefloatsidelines>\zerocount
+ % hm, when do we get the parshape branch? needs testing
+ \ifnum\c_page_sides_n_of_lines>\zerocount
\scratchtoks\emptytoks
- \scratchcounter\sidefloatsidelines
- \scratchdimen\hsize
- \advance\scratchdimen-\sidefloatwidth
- \dorecurse\sidefloatsidelines
+ \scratchcounter\c_page_sides_n_of_lines
+ \scratchdimen\dimexpr\hsize-\d_page_sides_width\relax
+ \dorecurse\c_page_sides_n_of_lines
{\appendtoks \zeropoint \hsize \to \scratchtoks}%
- \ifnum\!!counta>\sidefloatsidelines
- \advance\!!counta -\sidefloatsidelines\relax
+ \ifnum\!!counta>\c_page_sides_n_of_lines
+ \advance\!!counta -\c_page_sides_n_of_lines\relax
\advance\scratchcounter\!!counta
- \dorecurse\!!counta
- {\ifnum\sidefloattype>\plusfour
- \appendtoks \zeropoint \scratchdimen \to \scratchtoks
+ \dorecurse\!!counta % weird, shouldn't that be scratchcounter
+ {\ifnum\c_page_sides_float_type>\plusfour
+ \appendtoks \zeropoint \scratchdimen \to \scratchtoks
\else
- \appendtoks \sidefloatwidth \scratchdimen \to \scratchtoks
+ \appendtoks \d_page_sides_width\scratchdimen \to \scratchtoks
\fi}%
\fi
- \advance\scratchcounter \plusone
- \parshape \scratchcounter \the\scratchtoks \zeropoint \hsize\relax
+ \parshape
+ \numexpr\scratchcounter+\plusone\relax
+ \the\scratchtoks % \scratchcounter
+ \zeropoint \hsize % \plusone
+ \relax
\else
% new till here
- \hangindent \ifnum\sidefloattype>\plusfour -\fi\sidefloatwidth
+ \hangindent \ifnum\c_page_sides_float_type>\plusfour -\fi\d_page_sides_width
\hangafter-\!!counta
\fi
\fi
- \global\advance\sidefloatparagraph \plusone
+ \global\advance\c_page_sides_checks_done \plusone
\iftracesidefloats
- \hskip-\sidefloatwidth
+ \hskip-\d_page_sides_width
\color[darkgray]%
- {\vrule\!!height.5\points\!!depth.5\points\!!width\sidefloatwidth
- %\hskip-.25\bodyfontsize\showstruts\strut\hskip.25\bodyfontsize}%
+ {\vrule\!!height.5\points\!!depth.5\points\!!width\d_page_sides_width
\llap{\showstruts\strut\hskip.25\bodyfontsize}}%
\fi}
-\def\resetsidefloatparagraph
- {\global\sidefloatparagraph\zerocount}
+\def\page_sides_check_floats_reset
+ {\global\c_page_sides_checks_done\zerocount}
-\def\dochecksidefloat
- {\progresssidefloat
- \ifdim\sidefloatprogress>\zeropoint
- \setsidefloatparagraph
- \else
- \resetsidefloatparagraph
- \fi
- \parskip\ctxparskip}
+\def\page_sides_synchronize_floats
+ {\ifinner \else
+ \page_sides_check_floats
+ \fi}
-\let\checksidefloat\dochecksidefloat
+\def\page_sides_check_previous_float
+ {\page_sides_analyse_progress
+ \ifdim\d_page_sides_progress>\zeropoint \relax
+ \ifconditional\c_page_sides_short
+ \global\setfalse\c_page_sides_short
+ \page_otr_fill_and_eject_page
+ \else
+ \kern\d_page_sides_progress
+ \fi
+ \fi}
-\def\synchronizesidefloats
- {\ifinner \else \checksidefloat \fi}
+\def\page_sides_inject_dummy_lines
+ {\scratchcounter\pageshrink
+ \divide\scratchcounter \baselineskip
+ \advance\scratchcounter \plusone
+ \parskip\zeropoint
+ \dorecurse\scratchcounter{\hbox to \hsize{}}%
+ \kern-\scratchcounter\baselineskip
+ \penalty\zerocount}
+
+% Display math
+%
+% If we need this, it will be redone but redefining
+% these macros does not really work out in the current
+% situation.
+%
+% \ifx\normalleqno\undefined
+%
+% \let\floatrighteqo=\eqno
+% \let\floatleftleqo=\leqno
+%
+% \else
+%
+% \let\floatrighteqo=\normaleqno
+% \let\floatleftleqo=\normalleqno
+%
+% \fi
+%
+% \ifx\normaleqno\undefined
+%
+% \def\normaleqno
+% {\ifconditional\c_page_sides_short
+% \global\settrue\c_page_sides_r_eq
+% \fi
+% \floatrighteqo}
+%
+% \else
+%
+% \def\eqno
+% {\ifconditional\c_page_sides_short
+% \global\settrue\c_page_sides_r_eq
+% \fi
+% \floatrighteqo}
+%
+% \fi
+
+\def\adjustsidefloatdisplaylines
+ {\aftergroup\page_sides_adjust_display_lines}
-\def\doadjustsidefloatdisplaylines
+\def\page_sides_adjust_display_lines
{\par
- % not in mkiv: \vskip-\parskip
\noindent
\ignorespaces}
-\def\adjustsidefloatdisplaylines
- {\aftergroup\doadjustsidefloatdisplaylines}
-
-\def\previoussidefloat
- {\progresssidefloat
- \ifdim\sidefloatprogress>\zeropoint \relax
- \iffloatshort
- \global\floatshortfalse
- \vfill\eject % inline \tosssidefloat
- \else
- \kern\sidefloatprogress
- \fi
- \fi}
+% We need to hook it into the other otr's. This code will be adapted
+% once we rename the callers.
-\def\stallsidefloat
- {\!!counta\pageshrink
- \divide\!!counta \baselineskip
- \advance\!!counta \plusone
- \parskip\zeropoint
- \dorecurse\!!counta{\line{}}%
- \kern-\!!counta\baselineskip
- \penalty\zerocount }
+% \def as they can be redefined!
-% We need to hook it into the other otr's. This code will move.
+\def\checksidefloat {\page_sides_check_floats}
+\def\flushsidefloats {\page_sides_flush_floats}
+\def\flushsidefloatsafterpar{\page_sides_flush_floats_after_par}
+\def\forgetsidefloats {\page_sides_forget_floats}
+\def\synchronizesidefloats {\page_sides_synchronize_floats}
-\let\OTRONEflushsidefloats \flushsidefloats
-\let\OTRONEsynchronizesidefloats\synchronizesidefloats
+\let\OTRONEflushsidefloats \page_sides_flush_floats
+\let\OTRONEsynchronizesidefloats\page_sides_synchronize_floats
% page-set
%
% \let\OTRSETflushsidefloats \forgetsidefloats
% \let\OTRSETsynchronizesidefloats\forgetsidefloats
-
+%
% page-mul
%
% \let\OTRMULflushsidefloats \forgetsidefloats
% \let\OTRMULsynchronizesidefloats\forgetsidefloats
-\registerotrcommand\synchronizesidefloats % \def\synchronizesidefloats{\OTRcommand\synchronizesidefloats}
-\registerotrcommand\flushsidefloats % \def\flushsidefloats {\OTRcommand\flushsidefloats}
+\registerotrcommand\synchronizesidefloats
+\registerotrcommand\flushsidefloats
\protect \endinput
diff --git a/tex/context/base/page-spr.mkiv b/tex/context/base/page-spr.mkiv
index 6035f992a..33bd6ff16 100644
--- a/tex/context/base/page-spr.mkiv
+++ b/tex/context/base/page-spr.mkiv
@@ -26,7 +26,7 @@
\def\normalsettextpagecontent#1#2#3% #2 and #3 will disappear
{\setbox#1\hbox
- {\setlayoutcomponentattribute\v!page\v!text
+ {\setlayoutcomponentattribute{\v!page:\v!text}%
\vbox \layoutcomponentboxattribute to \textheight
{\offinterlineskip
\freezetextwidth
diff --git a/tex/context/base/page-txt.mkiv b/tex/context/base/page-txt.mkiv
deleted file mode 100644
index 57f391f7c..000000000
--- a/tex/context/base/page-txt.mkiv
+++ /dev/null
@@ -1,801 +0,0 @@
-%D \module
-%D [ file=page-txt, % copied from main-001,
-%D version=1997.03.31,
-%D title=\CONTEXT\ Page Macros,
-%D subtitle=Texts,
-%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.
-
-% where we can do some mkiv cleanup
-
-% \setuplayouttext in manual
-
-\writestatus{loading}{ConTeXt Page Macros / Texts}
-
-\unprotect
-
-%D Interfacing between this and other modules is handled by
-%D the following macros. The current state of a text line
-%D (header, footer, etc.) is checked by:
-%D
-%D \starttyping
-%D \resetlayouttextlines
-%D \stoptyping
-%D
-%D The main text box is finished by the following macro:
-%D
-%D \starttyping
-%D \getmainbox <box> <\vbox|\unvbox>
-%D \stoptyping
-%D
-%D The text lines are collected with:
-%D
-%D \starttyping
-%D \gettextboxes
-%D \stoptyping
-%D
-%D It is possible to extens the default content of the text
-%D areas by appending content to the following token list
-%D registers:
-
-\newtoks\toptextcontent \newtoks\leftedgetextcontent
-\newtoks\headertextcontent \newtoks\leftmargintextcontent
-\newtoks\footertextcontent \newtoks\rightmargintextcontent
-\newtoks\bottomtextcontent \newtoks\rightedgetextcontent
-
-\newtoks\texttextcontent
-
-%D \macros
-%D {setuptop, setupheader, setuptext,
-%D setupfooter, setupbottom}
-%D
-%D The macros in this module sometimes look a bit more complicated
-%D than needed, which is a direct result of the fact that their
-%D ancestors are quite old and upward compatibility is a must.
-%D
-%D \showsetup{setuptop}
-%D \showsetup{setupheader}
-%D \showsetup{setuptext}
-%D \showsetup{setupfooter}
-%D \showsetup{setupbottom}
-
-\unexpanded\def\setuplayouttext
- {\dotripleempty\dosetuplayouttext}
-
-\def\dosetuplayouttext[#1][#2][#3]% beware, non global
- {\ifthirdargument
- \getparameters[\??tk#1#2][#3]%
- \else
- %\getparameters[\??tk#1\v!text][#2]%
- \edef\previoustextstate{\csname\??tk#1\c!state\endcsname}%
- \getparameters[\??tk#1][#2]%
- \edef\currenttextstate{\csname\??tk#1\c!state\endcsname}%
- \ifx\currenttextstate\previoustextstate
- % no change in state
- \else
- %\checkcurrentlayout % no
- % speed optimization (calculating backgrounds takes time)
- \doifcommon{\previoustextstate,\currenttextstate}{\v!high,\v!none}
- {\calculatevsizes
- \recalculatebackgrounds}%
- \fi
- \fi}
-
-\unexpanded\def\setuptop {\dotripleempty\dosetuplayouttext[\v!top]}
-\unexpanded\def\setupheader {\dotripleempty\dosetuplayouttext[\v!header]}
-\unexpanded\def\setuptext {\dotripleempty\dosetuplayouttext[\v!text]}
-\unexpanded\def\setupfooter {\dotripleempty\dosetuplayouttext[\v!footer]}
-\unexpanded\def\setupbottom {\dotripleempty\dosetuplayouttext[\v!bottom]}
-
-%D \macros
-%D {noheaderandfooterlines,notopandbottomlines}
-%D
-%D Although not really needed, the following shortcuts
-%D sometimes come in handy.
-%D
-%D \showsetup{noheaderandfooterlines}
-%D \showsetup{notopandbottomlines}
-
-\def\noheaderandfooterlines
- {\setupheader[\c!state=\v!empty]%
- \setupfooter[\c!state=\v!empty]}
-
-\def\notopandbottomlines
- {\setuptop [\c!state=\v!empty]%
- \setupbottom[\c!state=\v!empty]}
-
-%D \macros
-%D {setuptoptexts, setupheadertexts, setuptexttexts,
-%D setupfootertexts, setupbottomtexts}
-%D
-%D The next macros take one or more arguments. The exact setup
-%D depends on the number of arguments. Although not that
-%D intuitive, the current scheme evolved out of the original.
-%D When margin and edge texts as well as middle texts showed
-%D up, the current odd|/|even scheme surfaced.
-%D
-%D \showsetup{setuptoptexts}
-%D \showsetup{setupheadertexts}
-%D \showsetup{setuptexttexts}
-%D \showsetup{setupfootertexts}
-%D \showsetup{setupbottomtexts}
-
-\unexpanded\def\setuptoptexts {\dosixtupleempty\dosetuptexts[\v!top ]}
-\unexpanded\def\setupheadertexts {\dosixtupleempty\dosetuptexts[\v!header ]}
-\unexpanded\def\setuptexttexts {\dosixtupleempty\dosetuptexts[\v!text ]}
-\unexpanded\def\setupfootertexts {\dosixtupleempty\dosetuptexts[\v!footer ]}
-\unexpanded\def\setupbottomtexts {\dosixtupleempty\dosetuptexts[\v!bottom ]}
-
-%D The left, right and center variables can also be set
-%D directly using the previously discussed macros.
-
-\def\dosetuptexts[#1][#2][#3][#4][#5][#6]%
- {\ifsixthargument
- \setvalue{\??tk#1#2\c!lefttext}%
- {\dodoubletexts{#1}{#2}%
- {\c!leftstyle \c!leftcolor \c!leftwidth }{#3}%
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#6}}%
- \setvalue{\??tk#1#2\c!righttext}%
- {\dodoubletexts{#1}{#2}%
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#4}%
- {\c!leftstyle \c!leftcolor \c!leftwidth }{#5}}%
- \else\iffifthargument
- \setvalue{\??tk#1\v!text\c!lefttext}%
- {\dodoubletexts{#1}\v!text
- {\c!leftstyle \c!leftcolor \c!leftwidth }{#2}%
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#5}}%
- \setvalue{\??tk#1\v!text\c!righttext}%
- {\dodoubletexts{#1}\v!text
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#3}%
- {\c!leftstyle \c!leftcolor \c!leftwidth }{#4}}%
- \else\iffourthargument
- \setvalue{\??tk#1#2\c!lefttext}%
- {\dodoubletexts{#1}{#2}
- {\c!leftstyle\c!leftcolor\c!leftwidth}{#3}%
- {\c!leftstyle\c!leftcolor\c!leftwidth}{#3}}%
- \setvalue{\??tk#1#2\c!righttext}%
- {\dodoubletexts{#1}{#2}
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#4}%
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#4}}%
- \else\ifthirdargument
- \setvalue{\??tk#1\v!text\c!lefttext}%
- {\dodoubletexts{#1}\v!text
- {\c!leftstyle\c!leftcolor\c!leftwidth}{#2}%
- {\c!leftstyle\c!leftcolor\c!leftwidth}{#2}}%
- \setvalue{\??tk#1\v!text\c!righttext}%
- {\dodoubletexts{#1}\v!text
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#3}%
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#3}}%
- \else\ifsecondargument % new
- \letvalueempty{\??tk#1\v!text\c!lefttext}%
- \letvalueempty{\??tk#1\v!text\c!righttext}%
- \setvalue{\??tk#1\v!text\c!middletext}{\dosingletexts{#1}\v!text\c!style\c!color\c!width{#2}}%
- \else
- \dosixtupleempty\dosetuptexts[#1][\v!text ][][][][]%
- \dosixtupleempty\dosetuptexts[#1][\v!margin][][][][]%
- \dosixtupleempty\dosetuptexts[#1][\v!edge ][][][][]%
- \fi\fi\fi\fi\fi}
-
-%D Left and right texts are swapped on odd and even pages, but
-%D only when double sided typesetting is enabled.
-
-\def\dodoubletexts{\doifoddpageelse\dodoubletextsodd\dodoubletextseven}
-
-\def\dodoubletextsodd #1#2#3#4#5#6{\dosingletexts{#1}{#2}#3{#4}} % #3 => provides three arguments
-\def\dodoubletextseven#1#2#3#4#5#6{\dosingletexts{#1}{#2}#5{#6}} % #5 => provides three arguments
-
-%D The next macro will be cleaned up and made less messy and
-%D dependent.
-
-\unexpanded\def\placetextlinestrut#1%
- {\doifvalue{#1\c!strut}\v!yes{\setstrut\strut}}
-
-\def\dosingletexts#1#2#3#4#5#6%
- {\bgroup
- \defconvertedargument\ascii{#6}% no longer \defconvertedargument, this also does not permit \v!pagenumber (i.e. v!)
- \ifx\ascii\empty\else
- \dostartattributes{\??tk#1#2}#3#4\empty
- \placetextlinestrut{\??tk#1}% here !
- \doifelsemarking\ascii
- {\dolimitatetexts{\??tk#1#2#5}{\getmarking[\ascii][\v!first]}}%
- {\ifcsname\??tk->\ascii\endcsname
- \csname\??tk->\ascii\endcsname
- \else
- % #6{}{}{} -> {} needed for macros that look
- % ahead, like \uniqueMPgraphic
- \ignorecrlf\dolimitatetexts{\??tk#1#2#5}{#6{}{}{}}%
- \fi}%
- \dostopattributes
- \fi
- \egroup}
-
-\setvalue{\??tk->\v!pagenumber}{\placelocationpagenumber}
-\setvalue{\??tk->\v!date }{\currentdate}
-
-%D When specified, the texts are automatically limited in
-%D length.
-
-\def\dolimitatetexts#1#2%
- {\doifelsevaluenothing{#1}{#2}{\limitatetext{#2}{\csname#1\endcsname}{\unknown}}}
-
-%D The placement of text is hooked into the token lists
-%D associated to the area at hand.
-
-\appendtoks \placelayouttextline\v!top \topheight \to \toptextcontent
-\appendtoks \placelayouttextline\v!header\headerheight \to \headertextcontent
-\appendtoks \placelayouttextline\v!text \textheight \to \texttextcontent
-\appendtoks \placelayouttextline\v!footer\footerheight \to \footertextcontent
-\appendtoks \placelayouttextline\v!bottom\bottomheight \to \bottomtextcontent
-
-%D Texts can be disabled, moved up and ignored, depending in
-%D the \type {status} variable. This is handled by the next
-%D couple of macros.
-
-% \def\settextlinestatus#1%
-% {\edef\textlinestatus{\csname\??tk#1\c!state\endcsname}}
-
-\def\settextlinestatus#1%
- {\ifcase0\csname\??tk#1\c!n\endcsname\relax
- \edef\textlinestatus{\csname\??tk#1\c!state\endcsname}%
- \else
- \setxvalue{\??tk#1\c!n}{\the\numexpr\csname\??tk#1\c!n\endcsname-1}%
- \let\textlinestatus\v!stop
- \fi}
-
-\appendtoks
- \doifinset\v!header\floatspecification{\setxvalue{\??tk\v!header\c!n}{1}}%
- \doifinset\v!footer\floatspecification{\setxvalue{\??tk\v!footer\c!n}{1}}%
-\to \everybeforeflushedpagefloat
-
-\def\resettextlinestatus#1% postpone
- {\expandafter\gdef\csname\??tk#1\s!reset\endcsname{\global\expandafter\let\csname\??tk#1\c!state\endcsname\v!normal}}
-
-\unexpanded\def\placelayouttextline#1% #2
- {\settextlinestatus#1%
- \csname\??tk::\ifcsname\??tk::\textlinestatus\endcsname\textlinestatus\else\s!unknown\fi\endcsname#1} % {#2}
-
-\def\doifelselayouttextline#1% shown or not
- {\edef\!!stringa{\csname\??tk#1\c!state\endcsname}%
- \ifx\!!stringa\v!normal
- \@EA\firstoftwoarguments
- \else\ifx\!!stringa\v!start
- \@EAEAEA\firstoftwoarguments
- \else
- \@EAEAEA\secondoftwoarguments
- \fi\fi}
-
-\def\doifelselayoutsomeline#1% present or not
- {\edef\!!stringa{\csname\??tk#1\c!state\endcsname}%
- \ifx\!!stringa\v!none
- \@EA\secondoftwoarguments
- \else\ifx\!!stringa\v!high
- \@EAEAEA\secondoftwoarguments
- \else
- \@EAEAEA\firstoftwoarguments
- \fi\fi}
-
-% \doplacelayouttextline does the actual placement (when a non-zero height)
-
-\newconditional\resyncaftertextline
-
-% there is no need for {#1} etc since we use symbolic names
-
-\setvalue{\??tk::\v!normal}{\doplacelayouttextline}
-\setvalue{\??tk::\empty }{\doplacelayouttextline}
-
-\setvalue{\??tk::\v!none }#1#2{}
-\setvalue{\??tk::\v!stop }#1#2{}
-
-\setvalue{\??tk::\v!high}#1#2%
- {\global\settrue\resyncaftertextline
- \resettextlinestatus#1}
-
-\setvalue{\??tk::\v!empty}#1#2%
- {\resettextlinestatus#1}
-
-\setvalue{\??tk::\v!start}#1#2%
- {\resettextlinestatus#1%
- \doplacelayouttextline#1#2}
-
-\setvalue{\??tk::\v!nomarking}#1#2%
- {\bgroup
- \resettextlinestatus#1%
- \settrue\inhibitgetmarking
- \let\dogetmarking\nogetmarking % obsolete in new marking mechanism
- \doplacelayouttextline#1#2%
- \egroup}
-
-\setvalue{\??tk::\s!unknown}#1#2%
- {\global\settrue\resyncaftertextline
- \bgroup % new
- \resettextlinestatus#1%
- \csname\??tk#1\textlinestatus\endcsname
- \csname\??tk#1\v!text \textlinestatus\endcsname
- \csname\??tk#1\v!margin\textlinestatus\endcsname
- \csname\??tk#1\v!edge \textlinestatus\endcsname
- \doplacelayouttextline#1#2%
- \egroup}
-
-%D The following macro has to be called after a page
-%D is flushed.
-
-\def\resetlayouttextline#1%
- {\csname\??tk#1\s!reset\endcsname
- \global\expandafter\let\csname\??tk#1\s!reset\endcsname\relax}
-
-\def\resetlayouttextlines
- {\resetlayouttextline\v!top
- \resetlayouttextline\v!header
- \resetlayouttextline\v!text
- \resetlayouttextline\v!footer
- \resetlayouttextline\v!bottom
- \ifconditional\resyncaftertextline
- \calculateglobalvsizes
- \recalculatebackgrounds
- \global\setfalse\resyncaftertextline
- \fi}
-
-% \settext[header][text][middle][xxx][yyy]
-
-\def\settextcontent
- {\doquintupleempty\dosettextcontent}
-
-\def\dosettextcontent[#1][#2][#3][#4][#5]% header text middle text/text
- {\iffifthargument
- \setvalue{\??tk#1#2\executeifdefined{:\c!text:#3:}\c!middletext}%
- {\dodoubletexts{\??tk#1}{#2}%
- {\c!leftstyle \c!leftcolor \c!leftwidth }{#4}%
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#5}}%
- \else\iffourthargument
- \setvalue{\??tk#1#2\executeifdefined{:\c!text:#3:}\c!middletext}%
- {\dodoubletexts{\??tk#1}{#2}%
- {\c!leftstyle \c!leftcolor \c!leftwidth }{#4}%
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#4}}%
- \else\ifthirdargument
- \setvalue{\??tk#1#2\c!middletext}%
- {\dodoubletexts{\??tk#1}{#2}%
- {\c!leftstyle \c!leftcolor \c!leftwidth }{#3}%
- {\c!rightstyle\c!rightcolor\c!rightwidth}{#3}}%
- \fi\fi\fi}
-
-\def\resettextcontent
- {\dotripleempty\doresettextcontent}
-
-\def\doresettextcontent[#1][#2][#3]% header text middle
- {\ifthirdargument
- \letvalueempty{\??tk#1#2\executeifdefined{:\c!text:#3:}\c!middletext}%
- \else\ifsecondargument
- \letvalueempty{\??tk#1#2\c!lefttext}%
- \letvalueempty{\??tk#1#2\c!middletext}%
- \letvalueempty{\??tk#1#2\c!righttext}%
- \fi\fi}
-
-\let\settext \settextcontent % downward compatibility
-\let\resettext\resettextcontent % downward compatibility
-
-\letvalue{:\c!middle:\c!text:}\c!middletext
-\letvalue{:\c!left :\c!text:}\c!lefttext
-\letvalue{:\c!right :\c!text:}\c!righttext
-
-%D The next series of macros is not that easy to read,
-%D because they hook into the main page building macros. By
-%D using token list registers for the text content, we can
-%D easily hook in other code, like menu generators.
-%D
-%D Beware: the token lists are always expanded, also when the
-%D height of an area is zero. This is because reset actions can
-%D be part of them.
-
-\newbox\scratchpagebox
-
-% \newbox\collectedprepagecontent % only for delayed stuff
-
-% \def\flushcollectedpagecontent
-% {\ifvoid\collectedprepagecontent \else
-% \smashbox\collectedprepagecontent
-% \box\collectedprepagecontent
-% \fi}
-
-% \def\delaytillpageisflushhed#1%
-% {\global\setbox\collectedprepagecontent\hbox
-% {\ifvoid\collectedprepagecontent \else
-% \unhbox\collectedprepagecontent
-% \fi % ignore and remove not really needed
-% \ignorespaces#1\removeunwantedspaces}}
-
-\def\gettextboxes
- {\ifcase\pageornamentstate
- \dogettextboxes
- \fi}
-
-\def\dogettextboxes
- {\setbox\scratchpagebox\vbox
- {\dontcomplain
- \calculatereducedvsizes
- \swapmargins
- \offinterlineskip
-% \flushcollectedpagecontent
- \vskip\dimexpr-\topheight-\topdistance\relax
- \the\toptextcontent
- \vskip\dimexpr\topheight+\topdistance\relax
- \the\headertextcontent
- \vskip\dimexpr\headerheight+\headerdistance\relax
- \placepositionanchors
- \vskip-\textheight
- \the\texttextcontent
- \vskip\textheight
- \the\everyendoftextbody
- \vskip\footerdistance
- \the\footertextcontent
- \vskip\dimexpr\footerheight+\bottomdistance\relax
- \the\bottomtextcontent
- \vskip\bottomheight
- \vfilll}%
- \smashbox\scratchpagebox
- \box\scratchpagebox}
-
-\def\getmainbox#1#2%
- {\setbox\scratchpagebox\vbox
- {\offinterlineskip % na \paginaletter !
- \calculatereducedvsizes
- \calculatehsizes
- \swapmargins
- \vskip\dimexpr\headerheight+\headerdistance+\layoutparameter\c!textdistance\relax
- \dontleavehmode
- % \dosetanchor{text}% failed experiment
- \hbox to \makeupwidth
- {\bgroup
- \swapmargins
- \goleftonpage
- \ifdim\leftedgewidth>\zeropoint
- \the\leftedgetextcontent
- \hskip\leftedgewidth
- \fi
- \hskip\leftedgedistance
- \ifdim\leftmarginwidth>\zeropoint
- \the\leftmargintextcontent
- \hskip\leftmarginwidth
- \fi
- \hskip\leftmargindistance
- \egroup
- \mkprocesspagecontents{#2}%
- \settextpagecontent\scratchpagebox{#1}{#2}%
- \addtextbackground\scratchpagebox
- \addtextgridlayer\scratchpagebox
- \box\scratchpagebox
- \bgroup
- \hskip\rightmargindistance
- \ifdim\rightmarginwidth>\zeropoint
- \the\rightmargintextcontent
- \hskip\rightmarginwidth
- \fi
- \hskip\rightedgedistance
- \ifdim\rightedgewidth>\zeropoint
- \the\rightedgetextcontent
- \hskip\rightedgewidth
- \fi
- \egroup
- \hss}}%
- \smashbox\scratchpagebox
- \box\scratchpagebox}
-
-%D The main text area has to be combined with some additional
-%D (tracing) information.
-
-% will be stored as normal and overloaded in page-lyr and later in
-% page-spr we overload the the stored version .. evenatually i will
-% clear up the experimental mess
-
-\def\settextpagecontent#1#2#3% #2 and #3 will disappear
- {\setbox#1\hbox to \makeupwidth
- {\hss % so don't change this
- \setlayoutcomponentattribute\v!page\v!text
- \vbox \layoutcomponentboxattribute to \textheight
- {\offinterlineskip
- \freezetextwidth
- \hsize\textwidth % local variant of \sethsize
- \boxmaxdepth\maxdepth
- \noindent % content can be < \hsize
- \dopagecontents#2#3}%
- \hss}%
- \dp#1\zeropoint}
-
-%D The placement of a whole line is handled by the next two
-%D macros. These are hooked into the general purpose token
-%D list registers mentioned before.
-
-\def\ignoredlinebreak{\unskip\space\ignorespaces}
-
-\def\doplacelayouttextline#1#2%
- {\let\currentlayouttextline#1%
- \ifdim#2>\zeropoint\relax % prevents pagenumbers when zero height
- \doplacelayouttextlineindeed{#2}%
- \fi}
-
-\def\doplacelayouttextlineindeed#1%
- {\goleftonpage
- \hbox
- {\setbox\scratchpagebox\vbox to #1
- {\vsize#1\relax
- \normalbaselines
- \let\\\ignoredlinebreak
- \let\crlf\ignoredlinebreak
- \csname\??tk\currentlayouttextline\c!before\endcsname
- \doifbothsidesoverruled\dodoplacelayouttextlineright\dodoplacelayouttextlineright\dodoplacelayouttextlineleft
- \csname\??tk\currentlayouttextline\c!after\endcsname
- \kern\zeropoint}% keep the \dp, beware of \vtops, never change this!
- \dp\scratchpagebox\zeropoint
- \box\scratchpagebox}%
- \vskip-#1\relax}
-
-\def\dodoplacelayouttextlineright{\dodoplacelayouttextline\c!lefttext \c!middletext\c!righttext\zerocount\plusone}
-\def\dodoplacelayouttextlineleft {\dodoplacelayouttextline\c!righttext\c!middletext\c!lefttext \plusone\zerocount}
-
-\def\dodoplacelayouttextline#1#2#3#4#5% \hsize toegevoegd, \hss's niet meer wijzigen
- {\hbox
- {\ifdim\leftedgewidth>\zeropoint
- \dododoplacelayouttextline\leftedgewidth\currentlayouttextline\v!edge{\thelayoutleftedgeline#1}%
- \hskip\leftedgedistance
- \fi
- \ifdim\leftmarginwidth>\zeropoint
- \dododoplacelayouttextline\leftmarginwidth\currentlayouttextline\v!margin{\thelayoutleftmarginline#1#4}%
- \hskip\leftmargindistance
- \fi
- \ifdim\makeupwidth>\zeropoint
- \dododoplacelayouttextline\makeupwidth\currentlayouttextline\v!text{\thelayouttextline#1#2#3#4#5}%
- \fi
- \ifdim\rightmarginwidth>\zeropoint
- \hskip\rightmargindistance
- \dododoplacelayouttextline\rightmarginwidth\currentlayouttextline\v!margin{\thelayoutrightmarginline#3#5}%
- \fi
- \ifdim\rightedgewidth>\zeropoint
- \hskip\rightedgedistance
- \dododoplacelayouttextline\rightedgewidth\currentlayouttextline\v!edge{\thelayoutrightedgeline#3}%
- \fi}}
-
-\def\thelayoutleftedgeline#1%
- {\hss\csname\??tk\currentlayouttextline\v!edge#1\endcsname}%
-
-\def\thelayoutrightedgeline#1%
- {\csname\??tk\currentlayouttextline\v!edge#1\endcsname\hss}
-
-\def\thelayoutleftmarginline#1#2%
- {\hbox to \leftmarginwidth{\hss\csname\??tk\currentlayouttextline\v!margin#1\endcsname}%
- \hskip-\leftmarginwidth
- \hbox to \leftmarginwidth{\hss\ifcase#2\or\csname\??tk\currentlayouttextline\v!margin\c!margintext\endcsname\fi}}
-
-\def\thelayoutrightmarginline#1#2%
- {\hbox to \rightmarginwidth{\csname\??tk\currentlayouttextline\v!margin#1\endcsname\hss}%
- \hskip-\rightmarginwidth
- \hbox to \rightmarginwidth{\ifcase#2\or\csname\??tk\currentlayouttextline\v!margin\c!margintext\endcsname\fi\hss}}
-
-\def\thelayoutedgetextline{\csname\??tk\currentlayouttextline\v!text\c!marginedgetext\endcsname}
-
-\def\thelayouttextline#1#2#3#4#5%
- {\hbox to \makeupwidth{\ifcase#4\or\@@nmpre\thelayoutedgetextline\fi\csname\??tk\currentlayouttextline\v!text#1\endcsname\hss}%
- \hskip-\makeupwidth
- \hbox to \makeupwidth{\hss\csname\??tk\currentlayouttextline\v!text#2\endcsname\hss}%
- \hskip-\makeupwidth
- \hbox to \makeupwidth{\hss\csname\??tk\currentlayouttextline\v!text#3\endcsname\ifcase#5\or\@@nmpos\thelayoutedgetextline\fi}}
-
-\def\dododoplacelayouttextline#1#2#3#4%
- {\vbox % to \vsize
- {\hsize#1\relax
- \csname\??tk#2#3\c!before\endcsname
- \setlayoutcomponentattribute#2#3%
- \hbox \layoutcomponentboxattribute to #1{#4}%
- \csname\??tk#2#3\c!after\endcsname}}
-
-%D Although it is far better to use backgrounds for this
-%D purpose, one can add a rule in the following way. This
-%D method makes the rules disappear in case of an empty text
-%D line. Consider this a feature.
-%D
-%D \starttyping
-%D \setupheadertexts[left][right]
-%D
-%D \setupheader[text][after=\hrule,style=bold]
-%D
-%D \starttext
-%D \input tufte \page
-%D \setupheader[state=empty]
-%D \input tufte \page
-%D \stoptext
-%D \stoptyping
-
-%D The next twosome will be done differently (using an
-%D existing auxiliary macro).
-
-% \def\@@nmpre#1{\setbox0\hbox{#1}\ifdim\wd0=\zeropoint\else\unhbox0\tfskip\fi}
-% \def\@@nmpos#1{\setbox0\hbox{#1}\ifdim\wd0=\zeropoint\else\tfskip\unhbox0\fi}
-
-% cleaner
-%
-% \def\@@nmpre#1{\doiftext{#1}{{#1}\tfskip}}
-% \def\@@nmpos#1{\doiftext{#1}{\tfskip{#1}}}
-%
-% newer
-%
-% \def\@@nmprepos#1#2#3#4#5%
-% {\doifelsenothing\@@nmwidth
-% {\doiftext{#5}{#1{#5}#2}}
-% {\doiftext{#5}{\hbox to \@@nmwidth{#3{#5}#4}}}}
-%
-% \def\@@nmpre{\@@nmprepos\empty\tfskip\relax\hss}
-% \def\@@nmpos{\@@nmprepos\tfskip\empty\hss\relax}
-%
-% faster
-
-\def\@@nmpre#1%
- {\begingroup
- \setbox\scratchbox\normalhbox{\settrialtypesetting\ignorespaces#1\removeunwantedspaces}%
- \ifzeropt\wd\scratchbox\else
- \doifelsenothing\@@nmwidth
- {\box\scratchbox\tfskip}
- {\hbox to \@@nmwidth{\box\scratchbox\hss}}%
- \fi
- \endgroup}
-
-\def\@@nmpos#1%
- {\begingroup
- \setbox\scratchbox\normalhbox{\settrialtypesetting\ignorespaces#1\removeunwantedspaces}%
- \ifzeropt\wd\scratchbox\else
- \doifelsenothing\@@nmwidth
- {\tfskip\box\scratchbox}
- {\hbox to \@@nmwidth{\hss\box\scratchbox}}%
- \fi
- \endgroup}
-
-%D This code will move to \type {page-flt.tex}.
-
-\appendtoks \placerightmarginblock \hskip-\rightmarginwidth \to \rightmargintextcontent
-\appendtoks \placeleftmarginblock \hskip-\leftmarginwidth \to \leftmargintextcontent
-
-%D The next hook will later be used for keeping track of
-%D positions, i.e.\ it will provide a proper (page
-%D dependent) reference point.
-
-\ifx\undefined\placepositionanchors
- \unexpanded\def\placepositionanchors{\vskip\textheight}
-\fi
-
-%D \macros
-%D {definetext}
-%D
-%D Some macros ago, we implemented the \type {status} option
-%D \type {unknown}. This one is used to take care of
-%D symbolic texts handlers.
-%D
-%D \showsetup{definetext}
-%D
-%D The next example demonstrates how we can use this
-%D mechanism to provide page (event) dependent text lines.
-%D
-%D \starttyping
-%D \definetext[chapter][footer][pagenumber]
-%D \setuphead[chapter][header=high,footer=chapter]
-%D \setupheadertexts[pagenumber]
-%D \setupfootertexts[left][right]
-%D \chapter{eerste} \dorecurse{20}{\input tufte \relax}
-%D \chapter{tweede} \dorecurse{20}{\input tufte \relax}
-%D \stoptyping
-
-\unexpanded\def\definetext
- {\doseventupleempty\dodefinetext}
-
-\def\dodefinetext[#1][#2][#3][#4][#5][#6][#7]%
- {\ifseventhargument
- \setvalue{\??tk#2#3#1}{\dosixtupleempty\dosetuptexts[#2][#3][#4][#5][#6][#7]}%
- \else\ifsixthargument
- \setvalue{\??tk #2#1}{\dosixtupleempty\dosetuptexts[#2][#3][#4][#5][#6]}%
- \else\iffifthargument
- \setvalue{\??tk#2#3#1}{\dosixtupleempty\dosetuptexts[#2][#3][#4][#5]}%
- \else\iffourthargument
- \setvalue{\??tk #2#1}{\dosixtupleempty\dosetuptexts[#2][#3][#4]}%
- \else
- \setvalue{\??tk #2#1}{\dosixtupleempty\dosetuptexts[#2][#3]}%
- \fi\fi\fi\fi}
-
-%D The rest of this file is dedicated to setting up the
-%D texts. This code is not that impressive.
-
-\setupheadertexts [\v!text] [] []
-\setupheadertexts [\v!margin] [] []
-\setupheadertexts [\v!edge] [] []
-
-\setupfootertexts [\v!text] [] []
-\setupfootertexts [\v!margin] [] []
-\setupfootertexts [\v!edge] [] []
-
-\setuptexttexts [\v!text] [] []
-\setuptexttexts [\v!margin] [] []
-\setuptexttexts [\v!edge] [] []
-
-\setupbottomtexts [\v!text] [] []
-\setupbottomtexts [\v!margin] [] []
-\setupbottomtexts [\v!edge] [] []
-
-\setuptoptexts [\v!text] [] []
-\setuptoptexts [\v!margin] [] []
-\setuptoptexts [\v!edge] [] []
-
-% alternative
-%
-% \def\resetlayouttekst%
-% {\dodoubleempty\doresetlayouttekst}
-%
-% \def\doresetlayouttekst[#1][#2]%
-% {\ifsecondargument
-% \dodoresetlayouttekst[#1][#2]%
-% \else
-% \dodoresetlayouttekst[#1][\v!tekst]%
-% \fi}
-%
-% \def\dodoresetlayouttekst[#1][#2]%
-% {...}
-%
-% \def\docommand#1%
-% {\resetlayouttekst[#1][\v!tekst]%
-% \resetlayouttekst[#1][\v!marge]%
-% \resetlayouttekst[#1][\v!rand]}
-
-%D We combine a lot of similar settings in a macro that
-%D we will later dispose.
-
-\def\dodocommand[#1][#2]%
- {\getparameters
- [\??tk#1#2]
- [%\c!state=\v!normal, % moved
- \c!before=,% both global and local are used
- \c!after=,% both global and local are used
- \c!strut=,% the local one, not (yet) used
- \c!style=\csname\??tk#1\c!style\endcsname,% hm, got lost
- \c!color=\csname\??tk#1\c!color\endcsname,% hm, got lost
- \c!lefttext=,
- \c!middletext=,
- \c!righttext=,
- \c!marginedgetext=,
- \c!margintext=,
- \c!width=]%
- \inheritparameter[\??tk#1#2][\c!leftstyle ][\c!style ]%
- \inheritparameter[\??tk#1#2][\c!rightstyle][\c!style ]%
- \inheritparameter[\??tk#1#2][\c!leftcolor ][\c!color ]%
- \inheritparameter[\??tk#1#2][\c!rightcolor][\c!color ]%
- \inheritparameter[\??tk#1#2][\c!leftwidth ][\c!width]%
- \inheritparameter[\??tk#1#2][\c!rightwidth][\c!width]}
-
-\def\docommand#1%
- {\dodocommand[#1][\v!text]%
- \dodocommand[#1][\v!margin]%
- \dodocommand[#1][\v!edge]}
-
-\docommand\v!top
-\docommand\v!header
-\docommand\v!footer
-\docommand\v!text
-\docommand\v!bottom
-
-\let\docommand \relax
-\let\dodocommand\relax
-
-%D While the header and footer lines are moved away from the
-%D main text, the top and bottom lines are centered.
-
-\setuptop [\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
-\setupheader[\c!state=\v!normal,\c!n=0,\c!before=, \c!after=\vss,\c!strut=\v!yes]
-\setuptext [\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
-\setupfooter[\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=, \c!strut=\v!yes]
-\setupbottom[\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
-
-\setuptop [\c!style=,\c!color=]
-\setupheader[\c!style=,\c!color=]
-\setuptext [\c!style=,\c!color=]
-\setupfooter[\c!style=,\c!color=]
-\setupbottom[\c!style=,\c!color=]
-
-\protect \endinput
diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi
new file mode 100644
index 000000000..7d89f7d8e
--- /dev/null
+++ b/tex/context/base/page-txt.mkvi
@@ -0,0 +1,922 @@
+% macros=mkvi
+
+%D \module
+%D [ file=page-txt, % copied from main-001,
+%D version=1997.03.31,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Texts,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Texts}
+
+\unprotect
+
+\newtoks\toptextcontent \newtoks\leftedgetextcontent
+\newtoks\headertextcontent \newtoks\leftmargintextcontent
+\newtoks\footertextcontent \newtoks\rightmargintextcontent
+\newtoks\bottomtextcontent \newtoks\rightedgetextcontent
+
+\newtoks\texttextcontent
+
+%D \macros
+%D {setuptop, setupheader, setuptext,
+%D setupfooter, setupbottom}
+%D
+%D The macros in this module sometimes look a bit more complicated
+%D than needed, which is a direct result of the fact that their
+%D ancestors are quite old and upward compatibility is a must.
+%D
+%D \showsetup{setuptop}
+%D \showsetup{setupheader}
+%D \showsetup{setuptext}
+%D \showsetup{setupfooter}
+%D \showsetup{setupbottom}
+
+\installcommandhandler \??tk {layoutelement} \??tk
+
+% \appendtoks
+% \resetlayoutelementparameter\c!lefttext % resolves better
+% \resetlayoutelementparameter\c!middletext
+% \resetlayoutelementparameter\c!righttext
+% \to \everydefinelayoutelement
+
+\definelayoutelement[\v!top ]
+\definelayoutelement[\v!header]
+\definelayoutelement[\v!text ]
+\definelayoutelement[\v!footer]
+\definelayoutelement[\v!bottom]
+
+\definelayoutelement[\v!top :\v!text] [\v!text] [\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!header:\v!text] [\v!text] [\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!text :\v!text] [\v!text] [\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!footer:\v!text] [\v!text] [\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!bottom:\v!text] [\v!text] [\c!lefttext=,\c!middletext=,\c!righttext=]
+
+\definelayoutelement[\v!top :\v!margin][\v!margin][\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!header:\v!margin][\v!margin][\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!text :\v!margin][\v!margin][\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!footer:\v!margin][\v!margin][\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!bottom:\v!margin][\v!margin][\c!lefttext=,\c!middletext=,\c!righttext=]
+
+\definelayoutelement[\v!top :\v!edge] [\v!edge] [\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!header:\v!edge] [\v!edge] [\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!text :\v!edge] [\v!edge] [\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!footer:\v!edge] [\v!edge] [\c!lefttext=,\c!middletext=,\c!righttext=]
+\definelayoutelement[\v!bottom:\v!edge] [\v!edge] [\c!lefttext=,\c!middletext=,\c!righttext=]
+
+\unexpanded\def\setuplayouttext
+ {\dotripleempty\setup_layout_text}
+
+\def\setup_layout_text[#vertical][#horizontal][#settings]%
+ {\ifthirdargument
+ \setuplayoutelement[#vertical:#horizontal][#settings]%
+ \else
+ \setuplayoutelement[#vertical][#horizontal]%
+ \fi}
+
+\appendtoks
+ \ifx\currentlayoutelement\empty\else
+ \synchronize_current_layout_element\currentlayoutelement % brr, can be vertical:horizontal
+ \fi
+\to \everysetuplayoutelement
+
+\def\reset_layout_element_status#vertical%
+ {\expandafter\gdef\csname\??tk:r:#vertical\endcsname{\set_layout_element_status_normal#vertical}}
+
+\def\set_layout_element_status_normal#vertical%
+ {\global\expandafter\let\csname\namedlayoutelementhash#vertical\c!state\endcsname\v!normal
+ \global\expandafter\let\csname\??tk:r:#vertical\endcsname\relax
+ \synchronize_current_layout_element{#vertical}}
+
+\def\synchronize_current_layout_element#vertical%
+ {\xdef\previoustextstate{\getvalue{\??tk:x:#vertical}}%
+ \edef\currenttextstate {\namedlayoutelementparameter{#vertical}\c!state}%
+ %\writestatus{>>}{[#vertical:\currenttextstate/\previoustextstate]}%
+ \ifx\currenttextstate\previoustextstate \else
+ \synchronize_current_layout_element_indeed{#vertical}%
+ \fi}
+
+\def\synchronize_current_layout_element_indeed#vertical%
+ {\ifx\currenttextstate \v!high \calculatevsizes\recalculatebackgrounds \else
+ \ifx\previoustextstate\v!high \calculatevsizes\recalculatebackgrounds \else
+ \ifx\currenttextstate \v!none \calculatevsizes\recalculatebackgrounds \else
+ \ifx\previoustextstate\v!none \calculatevsizes\recalculatebackgrounds \fi\fi\fi\fi
+ \letgvalue{\??tk:x:#vertical}\currenttextstate}
+
+\unexpanded\def\setuptop {\dotripleempty\setup_layout_text[\v!top ]}
+\unexpanded\def\setupheader{\dotripleempty\setup_layout_text[\v!header]}
+\unexpanded\def\setuptext {\dotripleempty\setup_layout_text[\v!text ]}
+\unexpanded\def\setupfooter{\dotripleempty\setup_layout_text[\v!footer]}
+\unexpanded\def\setupbottom{\dotripleempty\setup_layout_text[\v!bottom]}
+
+%D \macros
+%D {noheaderandfooterlines,notopandbottomlines}
+%D
+%D Although not really needed, the following shortcuts
+%D sometimes come in handy.
+%D
+%D \showsetup{noheaderandfooterlines}
+%D \showsetup{notopandbottomlines}
+
+\def\noheaderandfooterlines
+ {\setuplayoutelement[\v!header][\c!state=\v!empty]%
+ \setuplayoutelement[\v!footer][\c!state=\v!empty]}
+
+\def\notopandbottomlines
+ {\setuplayoutelement[\v!top ][\c!state=\v!empty]%
+ \setuplayoutelement[\v!bottom][\c!state=\v!empty]}
+
+%D \macros
+%D {setuptoptexts, setupheadertexts, setuptexttexts,
+%D setupfootertexts, setupbottomtexts}
+%D
+%D The next macros take one or more arguments. The exact setup
+%D depends on the number of arguments. Although not that
+%D intuitive, the current scheme evolved out of the original.
+%D When margin and edge texts as well as middle texts showed
+%D up, the current odd|/|even scheme surfaced.
+%D
+%D \showsetup{setuptoptexts}
+%D \showsetup{setupheadertexts}
+%D \showsetup{setuptexttexts}
+%D \showsetup{setupfootertexts}
+%D \showsetup{setupbottomtexts}
+
+\unexpanded\def\setuptoptexts {\dosixtupleempty\setup_texts[\v!top ]}
+\unexpanded\def\setupheadertexts{\dosixtupleempty\setup_texts[\v!header ]}
+\unexpanded\def\setuptexttexts {\dosixtupleempty\setup_texts[\v!text ]}
+\unexpanded\def\setupfootertexts{\dosixtupleempty\setup_texts[\v!footer ]}
+\unexpanded\def\setupbottomtexts{\dosixtupleempty\setup_texts[\v!bottom ]}
+
+% todo: \setuplayoutelementtext
+
+% An alternative approach is to have more variables but that does not
+% make the code less complex (probably more).
+
+\def\setup_texts[#vertical][#horizontal][#a][#b][#c][#d]%
+ {\ifsixthargument
+ \edef\currentlayoutelement{#vertical:#horizontal}%
+ \setlayoutelementparameter\c!lefttext
+ {\process_layout_element_double
+ \c!leftstyle \c!leftcolor \c!leftwidth {#a}%
+ \c!rightstyle\c!rightcolor\c!rightwidth{#d}}%
+ \setlayoutelementparameter\c!righttext
+ {\process_layout_element_double
+ \c!rightstyle\c!rightcolor\c!rightwidth{#b}%
+ \c!leftstyle \c!leftcolor \c!leftwidth {#c}}%
+ \else\iffifthargument
+ \edef\currentlayoutelement{#vertical:\v!text}%
+ \setlayoutelementparameter\c!lefttext
+ {\process_layout_element_double
+ \c!leftstyle \c!leftcolor \c!leftwidth {#horizontal}%
+ \c!rightstyle\c!rightcolor\c!rightwidth{#c}}%
+ \setlayoutelementparameter\c!righttext
+ {\process_layout_element_double
+ \c!rightstyle\c!rightcolor\c!rightwidth{#a}%
+ \c!leftstyle \c!leftcolor \c!leftwidth {#b}}%
+ \else\iffourthargument
+ \edef\currentlayoutelement{#vertical:#horizontal}%
+ \doifelsenothing{\detokenize{#a}}
+ {\resetlayoutelementparameter\c!lefttext}
+ {\setlayoutelementparameter\c!lefttext
+ {\process_layout_element_double
+ \c!leftstyle\c!leftcolor\c!leftwidth{#a}%
+ \c!leftstyle\c!leftcolor\c!leftwidth{#a}}}%
+ \doifelsenothing{\detokenize{#b}}
+ {\resetlayoutelementparameter\c!righttext}
+ {\setlayoutelementparameter\c!righttext
+ {\process_layout_element_double
+ \c!rightstyle\c!rightcolor\c!rightwidth{#b}%
+ \c!rightstyle\c!rightcolor\c!rightwidth{#b}}}%
+ \else\ifthirdargument
+ \edef\currentlayoutelement{#vertical:\v!text}%
+ \doifelsenothing{\detokenize{#horizontal}}
+ {\resetlayoutelementparameter\c!lefttext}
+ {\setlayoutelementparameter\c!lefttext
+ {\process_layout_element_double
+ \c!leftstyle\c!leftcolor\c!leftwidth{#horizontal}%
+ \c!leftstyle\c!leftcolor\c!leftwidth{#horizontal}}}%
+ \doifelsenothing{\detokenize{#a}}
+ {\resetlayoutelementparameter\c!righttext}
+ {\setlayoutelementparameter\c!righttext
+ {\process_layout_element_double
+ \c!rightstyle\c!rightcolor\c!rightwidth{#a}%
+ \c!rightstyle\c!rightcolor\c!rightwidth{#a}}}%
+ \else\ifsecondargument
+ \edef\currentlayoutelement{#vertical:\v!text}%
+ \resetlayoutelementparameter\c!lefttext
+ \resetlayoutelementparameter\c!righttext
+ \doifelsenothing{\detokenize{#horizontal}}
+ {\resetlayoutelementparameter\c!middletext}
+ {\setlayoutelementparameter\c!middletext
+ {\process_layout_element_single\c!style\c!color\c!width{#horizontal}}}%
+ \else
+ \edef\currentlayoutelement{#vertical:\v!text}%
+ \resetlayoutelementparameter\c!lefttext
+ \resetlayoutelementparameter\c!righttext
+ \resetlayoutelementparameter\c!middletext
+ \edef\currentlayoutelement{#vertical:\v!margin}%
+ \resetlayoutelementparameter\c!lefttext
+ \resetlayoutelementparameter\c!righttext
+ \resetlayoutelementparameter\c!middletext
+ \edef\currentlayoutelement{#vertical:\v!edge}%
+ \resetlayoutelementparameter\c!lefttext
+ \resetlayoutelementparameter\c!righttext
+ \resetlayoutelementparameter\c!middletext
+ \fi\fi\fi\fi\fi}
+
+% \def\setup_texts[#vertical][#horizontal][#a][#b][#c][#d]%
+% {\ifsixthargument
+% \edef\currentlayoutelement{#vertical:#horizontal}%
+% \setlayoutelementparameter\c!lefttext
+% {\process_layout_element_double
+% \c!leftstyle \c!leftcolor \c!leftwidth {#a}%
+% \c!rightstyle\c!rightcolor\c!rightwidth{#d}}%
+% \setlayoutelementparameter\c!righttext
+% {\process_layout_element_double
+% \c!rightstyle\c!rightcolor\c!rightwidth{#b}%
+% \c!leftstyle \c!leftcolor \c!leftwidth {#c}}%
+% \else\iffifthargument
+% \sixthargumenttrue
+% \setup_texts[#vertical][\v!text][#horizontal][#a][#b][#c]%
+% \else\iffourthargument
+% \edef\currentlayoutelement{#vertical:#horizontal}%
+% \doifelsenothing{\detokenize{#a}}
+% {\resetlayoutelementparameter\c!lefttext}
+% {\setlayoutelementparameter\c!lefttext
+% {\process_layout_element_double
+% \c!leftstyle\c!leftcolor\c!leftwidth{#a}%
+% \c!leftstyle\c!leftcolor\c!leftwidth{#a}}}%
+% \doifelsenothing{\detokenize{#b}}
+% {\resetlayoutelementparameter\c!righttext}
+% {\setlayoutelementparameter\c!righttext
+% {\process_layout_element_double
+% \c!rightstyle\c!rightcolor\c!rightwidth{#b}%
+% \c!rightstyle\c!rightcolor\c!rightwidth{#b}}}%
+% \else\ifthirdargument
+% \fourthargumenttrue
+% \setup_texts[#vertical][\v!text][#horizontal][#horizontal][][]%
+% \else\ifsecondargument
+% \edef\currentlayoutelement{#vertical:\v!text}%
+% \resetlayoutelementparameter\c!lefttext
+% \resetlayoutelementparameter\c!righttext
+% \doifelsenothing{\detokenize{#horizontal}}
+% {\resetlayoutelementparameter\c!middletext}
+% {\setlayoutelementparameter\c!middletext
+% {\process_layout_element_single\c!style\c!color\c!width{#horizontal}}}%
+% \else
+% \edef\currentlayoutelement{#vertical:\v!text}%
+% \resetlayoutelementparameter\c!lefttext
+% \resetlayoutelementparameter\c!righttext
+% \resetlayoutelementparameter\c!middletext
+% \edef\currentlayoutelement{#vertical:\v!margin}%
+% \resetlayoutelementparameter\c!lefttext
+% \resetlayoutelementparameter\c!righttext
+% \resetlayoutelementparameter\c!middletext
+% \edef\currentlayoutelement{#vertical:\v!edge}%
+% \resetlayoutelementparameter\c!lefttext
+% \resetlayoutelementparameter\c!righttext
+% \resetlayoutelementparameter\c!middletext
+% \fi\fi\fi\fi\fi}
+
+%D Left and right texts are swapped on odd and even pages, but
+%D only when double sided typesetting is enabled.
+
+\unexpanded\def\process_layout_element_double
+ {\doifoddpageelse
+ \process_layout_element_double_odd
+ \process_layout_element_double_even}
+
+\def\process_layout_element_double_odd #lstyle#lstyle#lwidth#lcontent#rstyle#rcolor#rwidth#rcontent%
+ {\process_layout_element_single#lstyle#lstyle#lwidth{#lcontent}}
+
+\def\process_layout_element_double_even#lstyle#lstyle#lwidth#lcontent#rstyle#rcolor#rwidth#rcontent%
+ {\process_layout_element_single#rstyle#rcolor#rwidth{#rcontent}}
+
+%D The next macro will be cleaned up and made less messy and
+%D dependent.
+
+\unexpanded\def\process_layout_element_single#style#color#width#content%
+ {\edef\layout_element_content{\detokenize{#content}}%
+ \ifx\layout_element_content\empty
+ % should not happen too often
+ \else
+ \process_layout_element_single_indeed#style#color#width{#content}%
+ \fi}
+
+\setvalue{\??tk:s:\v!yes}{\setstrut\strut} % maybe more variants
+
+\def\process_layout_element_single_indeed#style#color#width#content%
+ {\begingroup
+ \uselayoutelementstyleandcolor#style#color%
+ \csname\??tk:s:\layoutelementparameter\c!strut\endcsname
+ \ifcsname\??tk:p:\layout_element_content\endcsname
+ \csname\??tk:p:\layout_element_content\endcsname
+ \else
+ \edef\currentlayoutelementwidth{\layoutelementparameter#width}%
+ \ifx\currentlayoutelementwidth\empty
+ \expandafter\process_layout_element_single_normal
+ \else
+ \expandafter\process_layout_element_single_limited
+ \fi{#content}%
+ \fi
+ \endgroup}
+
+% {}{}{} prevents lookahead issues ... this will go away
+
+\def\process_layout_element_single_normal#content%
+ {\doifelsemarking\layout_element_content
+ {\getmarking[\layout_element_content][\v!first]}
+ {\ignorecrlf#content{}{}{}}}
+
+\def\process_layout_element_single_limited#content%
+ {\doifelsemarking\ascii
+ {\limitatetext{\getmarking[\layout_element_content][\v!first]}\currentlayoutelementwidth\unknown}
+ {\ignorecrlf\limitatetext{#content{}{}{}}\currentlayoutelementwidth\unknown}}
+
+\setvalue{\??tk:p:\v!pagenumber}{\place_layout_page_number}
+\setvalue{\??tk:p:\v!date }{\currentdate}
+
+%D When specified, the texts are automatically limited in
+%D length.
+
+\def\limitate_layout_element_text#width%
+ {\edef\currentlayoutelementwidth{\layoutelementparameter#width}%
+ \ifx\currentlayoutelementwidth\empty
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\limitate_layout_element_text_indeed
+ \fi}
+
+\def\limitate_layout_element_text_indeed#content%
+ {\limitatetext{#content}\currentlayoutelementwidth\unknown}
+
+%D The placement of text is hooked into the token lists
+%D associated to the area at hand.
+
+\appendtoks \place_layout_text_line\v!top \topheight \to \toptextcontent
+\appendtoks \place_layout_text_line\v!header\headerheight \to \headertextcontent
+\appendtoks \place_layout_text_line\v!text \textheight \to \texttextcontent
+\appendtoks \place_layout_text_line\v!footer\footerheight \to \footertextcontent
+\appendtoks \place_layout_text_line\v!bottom\bottomheight \to \bottomtextcontent
+
+%D Texts can be disabled, moved up and ignored, depending in
+%D the \type {status} variable. This is handled by the next
+%D couple of macros.
+
+\newcount\layout_element_state_n
+
+\def\set_layout_element_status#vertical%
+ {\layout_element_state_n=0\namedlayoutelementparameter#vertical\c!n\relax
+ \ifcase\layout_element_state_n
+ \edef\textlinestatus{\namedlayoutelementparameter#vertical\c!state}%
+ \else
+ \setxvalue{\namedlayoutelementhash#vertical\c!n}{\the\numexpr\layout_element_state_n+\minusone}%
+ \let\textlinestatus\v!stop
+ \fi}
+
+\appendtoks
+ \doifinset\v!header\floatspecification{\setxvalue{\namedlayoutelementhash\v!header\c!n}{1}}%
+ \doifinset\v!footer\floatspecification{\setxvalue{\namedlayoutelementhash\v!footer\c!n}{1}}%
+\to \everybeforeflushedpagefloat
+
+\unexpanded\def\place_layout_text_line#vertical%
+ {\set_layout_element_status#vertical%
+ \csname\??tk:l:\ifcsname\??tk:l:\textlinestatus\endcsname\textlinestatus\else\s!unknown\fi\endcsname#vertical}
+
+\unexpanded\def\doifelselayouttextline#vertical% shown or not
+ {\edef\currentlayoutelementstate{\namedlayoutelementparameter{#vertical}\c!state}%
+ \ifx\currentlayoutelementstate\v!normal
+ \expandafter\firstoftwoarguments
+ \else\ifx\currentlayoutelementstate\v!start
+ \doubleexpandafter\firstoftwoarguments
+ \else
+ \doubleexpandafter\secondoftwoarguments
+ \fi\fi}
+
+\unexpanded\def\doifelselayoutsomeline#vertical% present or not
+ {\edef\currentlayoutelementstate{\namedlayoutelementparameter{#vertical}\c!state}%
+ \ifx\currentlayoutelementstate\v!none
+ \expandafter\secondoftwoarguments
+ \else\ifx\currentlayoutelementstate\v!high
+ \doubleexpandafter\secondoftwoarguments
+ \else
+ \doubleexpandafter\firstoftwoarguments
+ \fi\fi}
+
+\newconditional\resyncaftertextline
+
+\setvalue{\??tk:l:\v!normal}{\place_layout_text_line_indeed}
+\setvalue{\??tk:l:\empty }{\place_layout_text_line_indeed}
+
+\letvalue{\??tk:l:\v!none}\gobbletwoarguments
+\letvalue{\??tk:l:\v!stop}\gobbletwoarguments
+
+\setvalue{\??tk:l:\v!high}#vertical#height%
+ {\global\settrue\resyncaftertextline
+ \reset_layout_element_status#vertical}
+
+\setvalue{\??tk:l:\v!empty}#vertical#height%
+ {\reset_layout_element_status#vertical}
+
+\setvalue{\??tk:l:\v!start}#vertical#height%
+ {\reset_layout_element_status#vertical%
+ \place_layout_text_line_indeed#vertical#height}
+
+\setvalue{\??tk:l:\v!nomarking}#vertical#height%
+ {\bgroup
+ \reset_layout_element_status#vertical%
+ \settrue\inhibitgetmarking
+ \let\dogetmarking\nogetmarking % obsolete in new marking mechanism
+ \place_layout_text_line_indeed#vertical#height%
+ \egroup}
+
+\setvalue{\??tk:l:\s!unknown}#vertical#height%
+ {\global\settrue\resyncaftertextline
+ \begingroup % new
+ \reset_layout_element_status#vertical%
+ \csname\namedlayoutelementhash#vertical\textlinestatus\endcsname
+ \csname\namedlayoutelementhash#vertical\v!text \textlinestatus\endcsname
+ \csname\namedlayoutelementhash#vertical\v!margin\textlinestatus\endcsname
+ \csname\namedlayoutelementhash#vertical\v!edge \textlinestatus\endcsname
+ \place_layout_text_line_indeed#vertical#height%
+ \endgroup}
+
+%D The following macro has to be called after a page
+%D is flushed.
+
+\def\resetlayouttextlines % public
+ {\csname\??tk:r:\v!top \endcsname
+ \csname\??tk:r:\v!header\endcsname
+ \csname\??tk:r:\v!text \endcsname
+ \csname\??tk:r:\v!footer\endcsname
+ \csname\??tk:r:\v!bottom\endcsname
+ \ifconditional\resyncaftertextline
+ \calculateglobalvsizes
+ \recalculatebackgrounds
+ \global\setfalse\resyncaftertextline
+ \fi}
+
+% \settext[header][text][middle][xxx][yyy]
+
+\def\settextcontent
+ {\doquintupleempty\set_text_content}
+
+\def\set_text_content[#vertical][#horizontal][#one][#two][#three]% header text middle text/text
+ {\iffifthargument
+ \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\executeifdefined{\??tk:c:\c!text:#one}\c!middletext}%
+ {\process_layout_element_double
+ \c!leftstyle \c!leftcolor \c!leftwidth {#two}%
+ \c!rightstyle\c!rightcolor\c!rightwidth{#three}}%
+ \else\iffourthargument
+ \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\executeifdefined{\??tk:c:\c!text:#one}\c!middletext}%
+ {\process_layout_element_double
+ \c!leftstyle \c!leftcolor \c!leftwidth {#two}%
+ \c!rightstyle\c!rightcolor\c!rightwidth{#two}}%
+ \else\ifthirdargument
+ \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\c!middletext}%
+ {\process_layout_element_double
+ \c!leftstyle \c!leftcolor \c!leftwidth {#one}%
+ \c!rightstyle\c!rightcolor\c!rightwidth{#one}}%
+ \fi\fi\fi}
+
+\def\resettextcontent
+ {\dotripleempty\reset_text_content}
+
+\def\reset_text_content[#vertical][#horizontal][#tag]% header text middle
+ {\edef\currentlayoutelement{#vertical:#horizontal}%
+ \ifthirdargument
+ \letvalueempty{\layoutelementhash\executeifdefined{\??tk:c:\c!text:#tag}\c!middletext}%
+ \else\ifsecondargument
+ \resetlayoutelementparameter\c!lefttext
+ \resetlayoutelementparameter\c!middletext
+ \resetlayoutelementparameter\c!righttext
+ \fi\fi}
+
+\letvalue{\??tk:c:\c!middle:\c!text}\c!middletext
+\letvalue{\??tk:c:\c!left :\c!text}\c!lefttext
+\letvalue{\??tk:c:\c!right :\c!text}\c!righttext
+
+%D The placement of a whole line is handled by the next two
+%D macros. These are hooked into the general purpose token
+%D list registers mentioned before.
+
+\def\ignoredlinebreak{\unskip\space\ignorespaces}
+
+\def\place_layout_text_line_indeed#vertical#height%
+ {\let\currentlayouttextline#vertical%
+ \ifdim#height>\zeropoint\relax % prevents pagenumbers when zero height
+ \place_layout_text_line_left_or_right{#height}%
+ \fi}
+
+\def\place_layout_text_line_left_or_right#height%
+ {\goleftonpage
+% \hbox{%
+ \setbox\layout_element_box\vbox to #height
+ {\vsize#height\relax
+ \normalbaselines
+ \let\\\ignoredlinebreak
+ \let\crlf\ignoredlinebreak
+ \namedlayoutelementparameter\currentlayouttextline\c!before
+ \doifbothsidesoverruled
+ \place_layout_text_line_right
+ \place_layout_text_line_right
+ \place_layout_text_line_left
+ \namedlayoutelementparameter\currentlayouttextline\c!after
+ \kern\zeropoint}% keep the \dp, beware of \vtops, never change this!
+ \dp\layout_element_box\zeropoint
+ \box\layout_element_box
+% }%
+ \vskip-#height\relax}
+
+\let\extra_at_margin_left \plusone
+\let\extra_at_margin_right\plustwo
+
+\let\place_layout_extra_text_left \relax % historic
+\let\place_layout_extra_text_right\relax % historic
+
+\def\place_layout_text_line_right
+ {\hbox
+ {\ifdim\leftedgewidth>\zeropoint
+ \place_left_edge_layout_element\c!lefttext
+ \fi
+ \ifdim\leftmarginwidth>\zeropoint
+ \place_left_margin_layout_element\c!lefttext\extra_at_margin_left
+ \fi
+ \ifdim\makeupwidth>\zeropoint
+ \place_text_body_layout_element\c!lefttext\c!middletext\c!righttext\extra_at_margin_left
+ \fi
+ \ifdim\rightmarginwidth>\zeropoint
+ \place_right_margin_layout_element\c!righttext\extra_at_margin_left
+ \fi
+ \ifdim\rightedgewidth>\zeropoint
+ \place_right_edge_layout_element\c!lefttext
+ \fi}}
+
+\def\place_layout_text_line_left
+ {\hbox
+ {\ifdim\leftedgewidth>\zeropoint
+ \place_left_edge_layout_element\c!righttext
+ \fi
+ \ifdim\leftmarginwidth>\zeropoint
+ \place_left_margin_layout_element\c!righttext\extra_at_margin_right
+ \fi
+ \ifdim\makeupwidth>\zeropoint
+ \place_text_body_layout_element\c!righttext\c!middletext\c!lefttext\extra_at_margin_right
+ \fi
+ \ifdim\rightmarginwidth>\zeropoint
+ \place_right_margin_layout_element\c!lefttext\extra_at_margin_right
+ \fi
+ \ifdim\rightedgewidth>\zeropoint
+ \place_right_edge_layout_element\c!righttext
+ \fi}}
+
+\def\place_left_edge_layout_element#parameter%
+ {\edef\currentlayoutelement{\currentlayouttextline:\v!edge}%
+ \place_left_edge_layout_element_indeed\leftedgewidth
+ {\hss\layoutelementparameter#parameter}%
+ \hskip\leftedgedistance}
+
+\def\place_left_margin_layout_element#parameter#extrastate%
+ {\edef\currentlayoutelement{\currentlayouttextline:\v!margin}%
+ \place_left_edge_layout_element_indeed\leftmarginwidth
+ {\hbox to \leftmarginwidth{\hss\layoutelementparameter#parameter}%
+ \ifnum#extrastate=\extra_at_margin_left
+ \hskip-\leftmarginwidth
+ \hbox to \leftmarginwidth{\hss\layoutelementparameter\c!margintext}%
+ \fi}%
+ \hskip\leftmargindistance}
+
+\def\place_text_body_layout_element#left#middle#right#extrastate%
+ {\edef\currentlayoutelement{\currentlayouttextline:\v!text}%
+ \place_left_edge_layout_element_indeed\makeupwidth
+ {\hbox to \makeupwidth{\ifnum#extrastate=\extra_at_margin_left\place_layout_extra_text_left\fi\layoutelementparameter#left\hss}%
+ \hskip-\makeupwidth
+ \hbox to \makeupwidth{\hss\layoutelementparameter#middle\hss}%
+ \hskip-\makeupwidth
+ \hbox to \makeupwidth{\hss\layoutelementparameter#right\ifnum#extrastate=\extra_at_margin_right\place_layout_extra_text_right\fi}}}
+
+\def\place_right_margin_layout_element#parameter#extrastate%
+ {\edef\currentlayoutelement{\currentlayouttextline:\v!margin}%
+ \hskip\rightmargindistance
+ \place_left_edge_layout_element_indeed\rightmarginwidth
+ {\hbox to \rightmarginwidth{\layoutelementparameter#parameter\hss}%
+ \ifnum#extrastate=\extra_at_margin_right
+ \hskip-\rightmarginwidth
+ \hbox to \rightmarginwidth{\layoutelementparameter\c!margintext\hss}%
+ \fi}}
+
+\def\place_right_edge_layout_element#parameter%
+ {\edef\currentlayoutelement{\currentlayouttextline:\v!edge}%
+ \hskip\rightedgedistance
+ \place_left_edge_layout_element_indeed\rightedgewidth
+ {\layoutelementparameter#parameter\hss}}
+
+\def\place_left_edge_layout_element_indeed#width#content%
+ {\vbox % to \vsize
+ {\hsize#1\relax
+ \layoutelementparameter\c!before
+ \setlayoutcomponentattribute\currentlayoutelement
+ \hbox \layoutcomponentboxattribute to #width{#content}%
+ \layoutelementparameter\c!after}}
+
+%D Although it is far better to use backgrounds for this
+%D purpose, one can add a rule in the following way. This
+%D method makes the rules disappear in case of an empty text
+%D line. Consider this a feature.
+%D
+%D \starttyping
+%D \setupheadertexts[left][right]
+%D
+%D \setupheader[text][after=\hrule,style=bold]
+%D
+%D \starttext
+%D \input tufte \page
+%D \setupheader[state=empty]
+%D \input tufte \page
+%D \stoptext
+%D \stoptyping
+
+%D This code will move to \type {page-flt.tex}.
+
+\appendtoks \placerightmarginblock \hskip-\rightmarginwidth \to \rightmargintextcontent
+\appendtoks \placeleftmarginblock \hskip-\leftmarginwidth \to \leftmargintextcontent
+
+%D The next hook will later be used for keeping track of
+%D positions, i.e.\ it will provide a proper (page
+%D dependent) reference point.
+
+\ifx\undefined\placepositionanchors
+ \unexpanded\def\placepositionanchors{\vskip\textheight}
+\fi
+
+%D \macros
+%D {definetext}
+%D
+%D Some macros ago, we implemented the \type {status} option
+%D \type {unknown}. This one is used to take care of
+%D symbolic texts handlers.
+%D
+%D \showsetup{definetext}
+%D
+%D The next example demonstrates how we can use this
+%D mechanism to provide page (event) dependent text lines.
+%D
+%D \starttyping
+%D \definetext[chapter][footer][pagenumber]
+%D \setuphead[chapter][header=high,footer=chapter]
+%D \setupheadertexts[pagenumber]
+%D \setupfootertexts[left][right]
+%D \chapter{eerste} \dorecurse{20}{\input tufte \relax}
+%D \chapter{tweede} \dorecurse{20}{\input tufte \relax}
+%D \stoptyping
+
+\unexpanded\def\definetext
+ {\doseventupleempty\define_text}
+
+\def\define_text[#tag][#vertical][#horizontal][#a][#b][#c][#d]%
+ {\ifseventhargument
+ \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}%
+ {\dosixtupleempty\setup_texts[#vertical][#horizontal][#a][#b][#c][#d]}%
+ \else\ifsixthargument
+ \setvalue{\namedlayoutelementhash{#vertical}#tag}%
+ {\dosixtupleempty\setup_texts[#vertical][#horizontal][#a][#b][#c]}%
+ \else\iffifthargument
+ \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}%
+ {\dosixtupleempty\setup_texts[#vertical][#horizontal][#a][#b]}%
+ \else\iffourthargument
+ \setvalue{\namedlayoutelementhash{#vertical}#tag}%
+ {\dosixtupleempty\setup_texts[#vertical][#horizontal][#a]}%
+ \else
+ \setvalue{\namedlayoutelementhash{#vertical}#tag}%
+ {\dosixtupleempty\setup_texts[#vertical][#horizontal]}%
+ \fi\fi\fi\fi}
+
+%D A few more page breakers:
+
+\installpagebreakhandler \v!empty
+ {\page_otr_flush_all_floats
+ \gotonextpage
+ \doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\v!header][\c!state=\v!empty]}%
+ \doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!empty]}%
+ \page_otr_insert_dummy_page}
+
+\installpagebreakhandler \v!header
+ {\doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\c!state=\v!empty]}}
+
+\installpagebreakhandler \v!footer
+ {\doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\c!state=\v!empty]}}
+
+%D While the header and footer lines are moved away from the
+%D main text, the top and bottom lines are centered.
+
+\setuplayoutelement[\v!top ][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
+\setuplayoutelement[\v!header][\c!state=\v!normal,\c!n=0,\c!before=, \c!after=\vss,\c!strut=\v!yes]
+\setuplayoutelement[\v!text ][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
+\setuplayoutelement[\v!footer][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=, \c!strut=\v!yes]
+\setuplayoutelement[\v!bottom][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
+
+%D Moved here from strc-pag:
+
+% We reset a previous location but only when it has a pagenumber
+% associated. This is a rather messy test but better than the MkII
+% way where we use states and keep settings.
+
+\let\layout_page_number_location \relax
+\let\layout_page_number_location_v\relax
+\let\layout_page_number_location_h\relax
+\let\layout_page_number_location_x\relax
+
+\def\place_layout_page_number % also elsewhere .. beware, not \unexpanded else
+ {\placelocationpagenumber} % test below fails
+
+\def\reset_layout_page_number_location
+ {\ifx\layout_page_number_location_v\relax\else
+ \edef\currentlayoutelement{\layout_page_number_location_v:\layout_page_number_location_h}%
+ \edef\previous_page_number_locator{\detokenizedlayoutelementparameter\layout_page_number_location_x}%
+ \doif{\meaning\previous_page_number_locator}{\meaning\place_layout_page_number}
+ {\resetlayoutelementparameter\layout_page_number_location_x}%
+ \fi}
+
+\def\set_layout_page_number_location
+ {\edef\currentlayoutelement{\layout_page_number_location_v:\layout_page_number_location_h}%
+ \letlayoutelementparameter\layout_page_number_location_x\place_layout_page_number
+ \ifx\layout_page_number_location_x\c!marginedgetext
+ \let\place_layout_extra_text_left \place_layout_page_number_left
+ \let\place_layout_extra_text_right\place_layout_page_number_right
+ \else
+ \let\place_layout_extra_text_left \relax
+ \let\place_layout_extra_text_right\relax
+ \fi}
+
+\def\identify_layout_page_number_location
+ {\let\layout_page_number_location_v\v!footer
+ \let\layout_page_number_location_h\v!text
+ \let\layout_page_number_location_x\c!middletext
+ \processallactionsinset[\@@nmlocation]
+ [ \v!header=>\let\layout_page_number_location_v\v!header,
+ \v!footer=>\let\layout_page_number_location_v\v!footer,
+ \v!middle=>\let\layout_page_number_location_h\v!text
+ \let\layout_page_number_location_x\c!middletext,
+ \v!left=>\let\layout_page_number_location_h\v!text
+ \let\layout_page_number_location_x\c!lefttext,
+ \v!right=>\let\layout_page_number_location_h\v!text
+ \let\layout_page_number_location_x\c!righttext,
+ \v!inleft=>\let\layout_page_number_location_h\v!margin
+ \let\layout_page_number_location_x\c!lefttext,
+ \v!inright=>\let\layout_page_number_location_h\v!margin
+ \let\layout_page_number_location_x\c!righttext,
+ \v!inmargin=>\let\layout_page_number_location_h\v!margin
+ \def\layout_page_number_location_x{\ifdoublesided\c!margintext\else\c!righttext\fi},
+ \v!margin=>\let\layout_page_number_location_h\v!margin
+ \def\layout_page_number_location_x{\ifdoublesided\c!margintext\else\c!righttext\fi},
+ \v!atmargin=>\let\layout_page_number_location_h\v!text
+ \let\layout_page_number_location_x\c!marginedgetext,
+ \v!marginedge=>\let\layout_page_number_location_h\v!text
+ \let\layout_page_number_location_x\c!marginedgetext]}
+
+\unexpanded\def\dosetpagenumberlocation
+ {\ifx\@@nmlocation\layout_page_number_location
+ % unchanged
+ \else
+ \let\layout_page_number_location\@@nmlocation
+ \reset_layout_page_number_location
+ \ifx\@@nmlocation\empty
+ % set otherwise
+ \else
+ \identify_layout_page_number_location
+ \set_layout_page_number_location
+ \fi
+ \fi}
+
+\def\place_layout_page_number_left % historic
+ {\begingroup
+ \setbox\scratchbox\normalhbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}%
+ \ifzeropt\wd\scratchbox\else
+ \doifelsenothing\@@nmwidth
+ {\box\scratchbox\tfskip}
+ {\hbox to \@@nmwidth{\box\scratchbox\hss}}%
+ \fi
+ \endgroup}
+
+\def\place_layout_page_number_right % historic
+ {\begingroup
+ \setbox\scratchbox\normalhbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}%
+ \ifzeropt\wd\scratchbox\else
+ \doifelsenothing\@@nmwidth
+ {\tfskip\box\scratchbox}
+ {\hbox to \@@nmwidth{\hss\box\scratchbox}}%
+ \fi
+ \endgroup}
+
+\dosetpagenumberlocation
+
+% will go to page-box.mkiv
+
+% the next macros will be redone (less boxing)
+
+\newbox\layout_element_box
+
+\def\gettextboxes % will become \place_layout_elements
+ {\ifcase\pageornamentstate
+ \place_layout_elements_indeed
+ \fi}
+
+\def\place_layout_elements_indeed
+ {\setbox\layout_element_box\vbox
+ {\dontcomplain
+ \calculatereducedvsizes
+ \swapmargins
+ \offinterlineskip
+ \vskip\dimexpr-\topheight-\topdistance\relax
+ \the\toptextcontent
+ \vskip\dimexpr\topheight+\topdistance\relax
+ \the\headertextcontent
+ \vskip\dimexpr\headerheight+\headerdistance\relax
+ \placepositionanchors
+ \vskip-\textheight
+ \the\texttextcontent
+ \vskip\textheight
+ \the\everyendoftextbody
+ \vskip\footerdistance
+ \the\footertextcontent
+ \vskip\dimexpr\footerheight+\bottomdistance\relax
+ \the\bottomtextcontent
+ \vskip\bottomheight
+ \vfilll}%
+ \smashbox\layout_element_box
+ \box\layout_element_box}
+
+\def\getmainbox#1#2%
+ {\setbox\layout_element_box\vbox
+ {\offinterlineskip
+ \calculatereducedvsizes
+ \calculatehsizes
+ \swapmargins
+ \vskip\dimexpr\headerheight+\headerdistance+\layoutparameter\c!textdistance\relax
+ \dontleavehmode
+ \hbox to \makeupwidth
+ {\bgroup
+ \swapmargins
+ \goleftonpage
+ \ifdim\leftedgewidth>\zeropoint
+ \the\leftedgetextcontent
+ \hskip\leftedgewidth
+ \fi
+ \hskip\leftedgedistance
+ \ifdim\leftmarginwidth>\zeropoint
+ \the\leftmargintextcontent
+ \hskip\leftmarginwidth
+ \fi
+ \hskip\leftmargindistance
+ \egroup
+ \mkprocesspagecontents{#2}%
+ \settextpagecontent\layout_element_box{#1}{#2}%
+ \page_backgrounds_add_to_text\layout_element_box
+ \page_grids_add_to_box\layout_element_box
+ \box\layout_element_box
+ \bgroup
+ \hskip\rightmargindistance
+ \ifdim\rightmarginwidth>\zeropoint
+ \the\rightmargintextcontent
+ \hskip\rightmarginwidth
+ \fi
+ \hskip\rightedgedistance
+ \ifdim\rightedgewidth>\zeropoint
+ \the\rightedgetextcontent
+ \hskip\rightedgewidth
+ \fi
+ \egroup
+ \hss}}%
+ \smashbox\layout_element_box
+ \box\layout_element_box}
+
+%D The main text area has to be combined with some additional
+%D (tracing) information.
+
+% will be stored as normal and overloaded in page-lyr and later in
+% page-spr we overload the the stored version .. evenatually i will
+% clear up the experimental mess
+
+\def\settextpagecontent#1#2#3% #2 and #3 will disappear
+ {\setbox#1\hbox to \makeupwidth
+ {\hss % so don't change this
+ \setlayoutcomponentattribute{\v!page:\v!text}%
+ \vbox \layoutcomponentboxattribute to \textheight
+ {\offinterlineskip
+ \freezetextwidth
+ \hsize\textwidth % local variant of \sethsize
+ \boxmaxdepth\maxdepth
+ \noindent % content can be < \hsize
+ \dopagecontents#2#3}%
+ \hss}%
+ \dp#1\zeropoint}
+
+\protect \endinput
+
diff --git a/tex/context/base/page-var.mkiv b/tex/context/base/page-var.mkiv
new file mode 100644
index 000000000..1c7fd5b25
--- /dev/null
+++ b/tex/context/base/page-var.mkiv
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=page-var,
+%D version=2011.12.05, % moved from other page-* files
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Variables,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Variables}
+
+\unprotect
+
+% just for temporary moved variables
+
+\protect \endinput
diff --git a/tex/context/base/phys-dim.lua b/tex/context/base/phys-dim.lua
index 9b9b59372..c47821b1c 100644
--- a/tex/context/base/phys-dim.lua
+++ b/tex/context/base/phys-dim.lua
@@ -79,6 +79,8 @@ local padding = P("=")
local plus = P("+")
local minus = P("-")
local space = P(" ")
+local lparent = P("(")
+local rparent = P(")")
local digits = digit^1
@@ -286,6 +288,7 @@ local long_units = {
-- other non-SI units (Table 8)
Bar = "bar",
+ Hg = "mercury",
-- ["Millimetre Of Mercury"] = [[mmHg]],
Angstrom = "angstrom", -- strictly Ångström
["Nautical Mile"] = "nauticalmile",
@@ -443,7 +446,7 @@ local short_suffixes = { -- maybe just raw digit match
local symbol_units = {
Degrees = "degree",
Degree = "degree",
- Deg = "degree",
+ -- Deg = "degree",
["°"] = "degree",
ArcMinute = "arcminute",
["′"] = "arcminute", -- 0x2032
@@ -457,6 +460,7 @@ local symbol_units = {
local packaged_units = {
Micron = "micron",
+ mmHg = "millimetermercury",
}
-- rendering:
@@ -471,8 +475,10 @@ local unitsS = context.unitsS
local unitsO = context.unitsO
local unitsN = context.unitsN
local unitsC = context.unitsC
+local unitsQ = context.unitsQ
local unitsNstart = context.unitsNstart
local unitsNstop = context.unitsNstop
+local unitsNspace = context.unitsNspace
local labels = languages.data.labels
@@ -531,6 +537,8 @@ labels.units = {
ohm = { labels = { en = [[Ω]] } }, -- 0x2126 \textohm
siemens = { labels = { en = [[S]] } },
weber = { labels = { en = [[Wb]] } },
+ mercury = { labels = { en = [[Hg]] } },
+ millimetermercury = { labels = { en = [[mmHg]] } }, -- connected
tesla = { labels = { en = [[T]] } },
henry = { labels = { en = [[H]] } },
celsius = { labels = { en = [[\checkedtextcelsius]] } }, -- 0x2103
@@ -553,7 +561,6 @@ labels.units = {
atomicmassunit = { labels = { en = [[u]] } },
astronomicalunit = { labels = { en = [[ua]] } },
bar = { labels = { en = [[bar]] } },
--- ["Millimetre Of Mercury"] = { labels = { en = [[mmHg]] } },
angstrom = { labels = { en = [[Å]] } }, -- strictly Ångström
nauticalmile = { labels = { en = [[M]] } },
barn = { labels = { en = [[b]] } },
@@ -727,8 +734,10 @@ local function update_parsers() -- todo: don't remap utf sequences
--
nothing = Cc(""),
somespace = somespace,
- nospace = (1-somespace)^0,
- ignore = P(-1),
+ nospace = (1-somespace)^1, -- was 0
+ -- ignore = P(-1),
+ --
+ qualifier = Cs(V("somespace") * (lparent/"") * (1-rparent)^1 * (rparent/"")),
--
somesymbol = V("somespace")
* (p_symbol/dimsym)
@@ -736,9 +745,9 @@ local function update_parsers() -- todo: don't remap utf sequences
somepackaged = V("somespace")
* (V("packaged") / dimpre)
* V("somespace"),
- someunknown = V("somespace")
- * (V("nospace")/unitsU)
- * V("somespace"),
+ -- someunknown = V("somespace")
+ -- * (V("nospace")/unitsU)
+ -- * V("somespace"),
--
combination = V("longprefix") * V("longunit") -- centi meter
+ V("nothing") * V("longunit")
@@ -752,36 +761,45 @@ local function update_parsers() -- todo: don't remap utf sequences
+ (V("longsuffix") * V("combination")) / dimspu
+ (V("combination") * (V("shortsuffix") + V("nothing"))) / dimpus
)
+ * (V("qualifier") / unitsQ)^-1
* V("somespace"),
operator = V("somespace")
* ((V("longoperator") + V("shortoperator")) / dimop)
* V("somespace"),
- snippet = V("somesymbol")
- * V("dimension")
- + V("dimension")
+ snippet = V("dimension")
+ V("somesymbol"),
- unit = V("snippet")^1
- * (V("operator") * V("snippet"))^-1 -- V("snippet")^1 ?
- + V("somesymbol")
- + V("somepackaged")
- + V("someunknown")
- + V("ignore"),
+ unit = (
+ V("snippet")
+ * (V("operator") * V("snippet"))^0
+ + V("somepackaged")
+ )^1,
}
--- lpeg.print(unitparser) -- 20111127: 2384 long
- local number = lpeg.patterns.number
+ -- local number = lpeg.patterns.number
local number = Cs( P("$") * (1-P("$"))^1 * P("$")
+ P([[\m{]]) * (1-P("}"))^1 * P("}")
+ (1-R("az","AZ")-P(" "))^1 -- todo: catch { } -- not ok
) / unitsN
- local p_c_unitdigitparser = (Cc(nil)/unitsNstart) * p_c_dparser * (Cc(nil)/unitsNstop) --
- local c_p_unitdigitparser = (Cc(nil)/unitsNstart) * c_p_dparser * (Cc(nil)/unitsNstop) --
+ local start = Cc(nil) / unitsNstart
+ local stop = Cc(nil) / unitsNstop
+ local space = Cc(nil) / unitsNspace
+
+ local p_c_combinedparser = P { "start",
+ number = start * dleader * (p_c_dparser + number) * stop,
+ rule = V("number")^-1 * unitparser,
+ space = space,
+ start = V("rule") * (V("space") * V("rule"))^0 + V("number")
+ }
- local p_c_combinedparser = dleader * (p_c_unitdigitparser + number)^-1 * unitparser
- local c_p_combinedparser = dleader * (c_p_unitdigitparser + number)^-1 * unitparser
+ local c_p_combinedparser = P { "start",
+ number = start * dleader * (c_p_dparser + number) * stop,
+ rule = V("number")^-1 * unitparser,
+ space = space,
+ start = V("rule") * (V("space") * V("rule"))^0 + V("number")
+ }
return p_c_combinedparser, c_p_combinedparser
end
@@ -798,10 +816,15 @@ function commands.unit(str,p_c)
p_c_parser, c_p_parser = update_parsers()
dirty = false
end
+ local ok
if p_c == v_reverse then
- matchlpeg(p_c_parser,str)
+ ok = matchlpeg(p_c_parser,str)
else
- matchlpeg(c_p_parser,str)
+ ok = matchlpeg(c_p_parser,str)
+ end
+ if not ok then
+ report_units("unable to parse: %s",str)
+ context(str)
end
end
diff --git a/tex/context/base/phys-dim.mkiv b/tex/context/base/phys-dim.mkiv
index b31d746ba..a82badb91 100644
--- a/tex/context/base/phys-dim.mkiv
+++ b/tex/context/base/phys-dim.mkiv
@@ -13,7 +13,7 @@
\registerctxluafile{phys-dim}{}
-% todo: optional space between 'connected' symbols
+% TAGGING NEEDS CHECKING ... WILL DO WHEN PARSER IS OK
\unprotect
@@ -170,9 +170,9 @@
\unexpanded\def\digitsseparatorspace{\hphantom{.}}
\unexpanded\def\digitssignspace {\hphantom{\digitsminus}}
\unexpanded\def\digitshighspace {\hphantom{\digitspositive}}
-\unexpanded\def\digitspower {\digits_raised}
-\unexpanded\def\digitspowerplus #1{\digits_raised{\digitsplus#1}}
-\unexpanded\def\digitspowerminus #1{\digits_raised{\digitsminus#1}}
+\unexpanded\def\digitspower #1{\times10\digits_raised{#1}}
+\unexpanded\def\digitspowerplus #1{\times10\digits_raised{\digitsplus#1}}
+\unexpanded\def\digitspowerminus #1{\times10\digits_raised{\digitsminus#1}}
\unexpanded\def\digitsdigit #1{#1}
\unexpanded\def\normaldigitscommasymbol {,}
@@ -380,12 +380,13 @@
{\setvalue{\??un:2:#1}{#2}}
\unexpanded\def\dounitsspace
- {\edef\currentunitsspace{\unitparameter\c!space}%
+ {\unskip % weird, why is unskip needed
+ \edef\currentunitsspace{\unitparameter\c!space}%
\csname\??un:2:%
\ifcsname\??un:2:\currentunitsspace\endcsname\currentunitsspace\else\v!normal\fi
\endcsname}
-\installunitsspace\v!normal {\unitsbigspace}
+\installunitsspace\v!normal {\unitsmediumspace}
\installunitsspace\v!big {\unitsbigspace}
\installunitsspace\v!medium {\unitsmediumspace}
\installunitsspace\v!small {\unitssmallspace}
@@ -411,7 +412,7 @@
\let\operatorlanguage\unitlanguage
\the\everyunits
%\removeunwantedspaces % not ok yet
- \dosetunitattributes\c!style\c!color
+ \useunitstyleandcolor\c!style\c!color
\edef\currentunitsalternative{\unitparameter\c!alternative}%
\ifmmode
\ifx\currentunitsalternative\v!text
@@ -470,22 +471,45 @@
{\ctxcommand{unit(\!!bs\detokenize{#1}\!!es,"\unitparameter\c!order")}}
\unexpanded\def\unitsPUS#1#2#3{\units_next\prefixtext{#1}\unittext{#2}\unitsraise{\suffixtext{#3}}\c_units_state\plusone} % suffix
-\unexpanded\def\unitsPU #1#2{\units_next\prefixtext{#1}\unittext{#2}\c_units_state\plusthree} % unit
+\unexpanded\def\unitsPU #1#2{\units_next\prefixtext{#1}\unittext{#2}\c_units_state\plusthree} % unit
\unexpanded\def\unitsPS #1#2{\units_next\prefixtext{#1}\unitsraise{\suffixtext{#2}}\c_units_state\plusone} % suffix
\unexpanded\def\unitsUS #1#2{\units_next\unittext{#1}\unitsraise{\suffixtext{#2}}\c_units_state\plusone} % suffix
-\unexpanded\def\unitsP #1{\units_next\prefixtext{#1}1\c_units_state\plusfour} % prefix
-\unexpanded\def\unitsU #1{\units_next\unittext{#1}\c_units_state\plusthree} % unit
+\unexpanded\def\unitsP #1{\units_next\prefixtext{#1}1\c_units_state\plusfour} % prefix
+\unexpanded\def\unitsU #1{\units_next\unittext{#1}\c_units_state\plusthree} % unit
\unexpanded\def\unitsS #1{\units_start{}\unitsraise{\suffixtext{#1}}\c_units_state\plusone} % suffix
-\unexpanded\def\unitsO #1{\units_start\operatortext{#1}\c_units_state\plustwo} % operator
-\unexpanded\def\unitsN #1{\units_start#1\c_units_state\plusfive} % number
-\unexpanded\def\unitsC #1{\removeunwantedspaces\unittext{#1}\c_units_state\plussix} % connected
+\unexpanded\def\unitsO #1{\units_start\operatortext{#1}\c_units_state\plustwo} % operator
+\unexpanded\def\unitsN #1{\units_start#1\c_units_state\plusfive} % number
+\unexpanded\def\unitsC #1{\removeunwantedspaces\unittext{#1}\c_units_state\plussix} % connected
+\unexpanded\def\unitsQ #1{\removeunwantedspaces\unitslower{#1}\c_units_state\zerocount} %
+
+% Fonts can have a celsius and lack a fahrenheit symbol and as we want
+% to be consistent so we check for the counterparts as well. It's slow
+% but ok. Of course we could go virtual instead.
+
+\def\text_fallback_prime {\textacute}
+\def\text_fallback_doubleprime{\textacute\kern-.25em\textacute}
+\def\text_fallback_celsius {°C}
+\def\text_fallback_fahrenheit {°F}
+
+\unexpanded\def\checkedtextprime
+ {\iffontchar\font"2032\relax\iffontchar\font"2033\relax
+ ′\else\text_fallback_prime\fi\else\text_fallback_prime
+ \fi}
+
+\unexpanded\def\checkedtextdoubleprime
+ {\iffontchar\font"2033\relax\iffontchar\font"2032\relax
+ ″\else\text_fallback_doubleprime\fi\else\text_fallback_doubleprime
+ \fi}
-% hm, textacute also not present in some fonts
+\unexpanded\def\checkedtextcelsius
+ {\iffontchar\font"2103\relax\iffontchar\font"2109\relax
+ ℉\else\text_fallback_celsius\fi\else\text_fallback_celsius
+ \fi}
-\unexpanded\def\checkedtextprime {\iffontchar\font"2032′\else\textacute\fi}
-\unexpanded\def\checkedtextdoubleprime{\iffontchar\font"2033″\else\textacute\kern-.25em\textacute\fi}
-\unexpanded\def\checkedtextcelsius {\iffontchar\font"2103℃\else °C\fi}
-\unexpanded\def\checkedtextfahrenheit {\iffontchar\font"2109℉\else °F\fi}
+\unexpanded\def\checkedtextfahrenheit
+ {\iffontchar\font"2109\relax\iffontchar\font"2103\relax
+ ℉\else\text_fallback_fahrenheit\fi\else\text_fallback_fahrenheit
+ \fi}
\setelementnature[unit] [mixed]
\setelementnature[quantity][mixed]
@@ -507,6 +531,9 @@
\fi
\c_units_state\plusfive}
+\unexpanded\def\unitsNspace
+ {\space}
+
\unexpanded\def\unitsN#1%
{\unitsNstart#1\unitsNstop}
diff --git a/tex/context/base/ppchtex.mkiv b/tex/context/base/ppchtex.mkiv
index 33a20fb68..c5993d234 100644
--- a/tex/context/base/ppchtex.mkiv
+++ b/tex/context/base/ppchtex.mkiv
@@ -3396,11 +3396,11 @@ RT##3##4##5=>\processchemicaltextelement{RN}{##3##4##5}{#1}{0}{},
drawoptions (\chemicalattributes) ;
\stopMPdrawing}
-\def\@@dochemicalcolor
- {\doifsomething\@@chemicalcolor{\color[\@@chemicalcolor]}}
+\unexpanded\def\@@dochemicalcolor
+ {\dousecolorparameter\@@chemicalcolor}
-\def\@@dochemicalstyle
- {\doconvertfont\@@chemicalstyle}
+\unexpanded\def\@@dochemicalstyle
+ {\dousestyleparameter\@@chemicalstyle}
\setupchemical
[\c!rulethickness=\linewidth,
diff --git a/tex/context/base/s-fnt-10.mkiv b/tex/context/base/s-fnt-10.mkiv
index a104e6b7d..0d4a608a4 100644
--- a/tex/context/base/s-fnt-10.mkiv
+++ b/tex/context/base/s-fnt-10.mkiv
@@ -135,7 +135,7 @@ end
\page
\egroup}
-% \doifnotmode{demo} {\endinput}
+\doifnotmode{demo} {\endinput}
\starttext
diff --git a/tex/context/base/s-pre-50.tex b/tex/context/base/s-pre-50.tex
index 03c612779..ff3e48631 100644
--- a/tex/context/base/s-pre-50.tex
+++ b/tex/context/base/s-pre-50.tex
@@ -76,7 +76,7 @@
%D Trick. Nowadays we can use streams.
-\installoutput\FlushStep
+\installoutputroutine\FlushStep
{\StartStep\unvbox\normalpagebox\StopStep}
%D Demo.
diff --git a/tex/context/base/scrn-but.mkvi b/tex/context/base/scrn-but.mkvi
index 693996d8a..1a5d0f0f6 100644
--- a/tex/context/base/scrn-but.mkvi
+++ b/tex/context/base/scrn-but.mkvi
@@ -812,41 +812,33 @@
\unexpanded\def\scrn_menu_leftedge
{\hbox to \leftedgewidth \bgroup
\hsize\leftedgewidth
- %\csname\??tk\v!leftedge\c!left\endcsname
\settrue\scrn_menu_zerodimensions
\scrn_menu_insert\v!left
- %\csname\??tk\v!leftedge\c!right\endcsname
\egroup
\hskip-\leftedgewidth}
\unexpanded\def\scrn_menu_rightedge
{\hbox to \rightedgewidth \bgroup
\hsize\rightedgewidth
- %\csname\??tk\v!rightedge\c!left\endcsname
\settrue\scrn_menu_zerodimensions
\scrn_menu_insert\v!right
- %\csname\??tk\v!rightedge\c!right\endcsname
\egroup
\hskip-\rightedgewidth}
-\unexpanded\def\scrn_menu_top % uses \??tk
+\unexpanded\def\scrn_menu_top
{\vbox to \topheight \bgroup
\vsize\topheight
- %\csname\??tk\v!top\c!before\endcsname
\settrue\scrn_menu_zerodimensions
\scrn_menu_insert\v!top
- %\csname\??tk\v!top\c!after\endcsname
\kern\zeropoint
\egroup
\vskip-\topheight}
-\unexpanded\def\scrn_menu_bottom % uses \??tk
+\unexpanded\def\scrn_menu_bottom
{\vbox to \bottomheight \bgroup
\vsize\bottomheight
- %\csname\??tk\v!bottom\c!before\endcsname
\settrue\scrn_menu_zerodimensions
\scrn_menu_insert\v!bottom
- %\csname\??tk\v!bottom\c!after\endcsname
\kern\zeropoint
\egroup
\vskip-\bottomheight}
diff --git a/tex/context/base/scrn-fld.mkvi b/tex/context/base/scrn-fld.mkvi
index 02cf5afca..00c5ff36e 100644
--- a/tex/context/base/scrn-fld.mkvi
+++ b/tex/context/base/scrn-fld.mkvi
@@ -110,7 +110,7 @@
\the\everysetupforms}
\appendtoks
- \ctxcommand{setformsmethod("@@frmethod")}%
+ \ctxcommand{setformsmethod("\@@frmethod")}%
\to \everysetupforms
\setupforms
@@ -128,10 +128,8 @@
\def\scrn_symbols_preset_indeed#tag%
{\doifobjectfoundelse{SYM}{#tag}
{}
- {\settightobject{SYM}{#tag}\hbox{\symbol[#tag]}%
- \flushatshipout
- {\setbox0\hbox{\hskip-\maxdimen\getobject{SYM}{#tag}}%
- \smashbox0\box0}}}
+ {\settightobject{SYM}{#tag}\hbox{\symbol[#tag]}% % todo: set this as immediate xform
+ \page_otr_add_special_content{\hskip-\maxdimen\getobject{SYM}{#tag}}}} % and then force it into the file
\let\dosetfieldsymbol\scrn_symbols_preset_indeed
@@ -140,7 +138,7 @@
\unexpanded\def\definedefaultsymbols % used ?
{\definesymbol[defaultyes][\mathematics{\times}]%
- \definesymbol[defaultno ][\mathematics{\cdot }]}
+ \definesymbol[defaultno] [\mathematics{\cdot }]}
% \def\resetfieldsymbol[#tag]% for experimental usage only
% {\resetobject{SYM}{#tag}}
@@ -219,7 +217,7 @@
\ifx\currentfieldbackgroundcolor\empty\else
\getcolorattributevalue\currentfieldbackgroundcolor\currentfieldbackgroundcolorvalue
\fi
- \dosetfieldbodyattributes\c!style\c!color
+ \usefieldbodystyleandcolor\c!style\c!color
\ctxcommand{insertfield("\currentfieldbody", {
title = "\currentfieldbody",
width = \number\dimexpr\fieldbodyparameter\c!width \relax,
@@ -944,14 +942,14 @@
\getinteractionmenuparameter
\inheritedinteractionmenuframed
\setinteractionmenuparameter
- \dosetinteractionmenuattributes}
+ \useinteractionmenustyleandcolor}
\def\scrn_rollbutton_symbol_b
{\scrn_rollbutton_symbol_indeed
\getbuttonparameter
\inheritedbuttonframed
\setbuttonparameter
- \dosetbuttonattributes}
+ \usebuttonstyleandcolor}
\def\scrn_rollbutton[#tag][#settings]#text[#reference]%
{\dontleavehmode
@@ -991,14 +989,14 @@
\fitfield[rollbutton:\number\scrn_rollbutton_n_button]%
\egroup}
-\unexpanded\def\scrn_rollbutton_symbol_indeed#getparameter#inheritedframed#setparameter#dosetattributes#what#text%
+\unexpanded\def\scrn_rollbutton_symbol_indeed#getparameter#inheritedframed#setparameter#usestyleandcolor#what#text%
{\definecolor[rollover][rollover:#what]%
\doifelse{#what}{n}% ?
{\doifelse{#getparameter\c!alternative}\v!hidden\phantom\hbox}\hbox
{#setparameter\c!framecolor {rollover}%
#setparameter\c!backgroundcolor{rollover}%
#setparameter\c!color {rollover}%
- #inheritedframed{#dosetattributes\c!style\c!color{#text}}}}
+ #inheritedframed{#usestyleandcolor\c!style\c!color{#text}}}}
%D We plug into the menu system
diff --git a/tex/context/base/scrn-ini.mkvi b/tex/context/base/scrn-ini.mkvi
index 3c8ef1321..a5a50cddd 100644
--- a/tex/context/base/scrn-ini.mkvi
+++ b/tex/context/base/scrn-ini.mkvi
@@ -122,27 +122,27 @@
{\ifnum\referencepagestate=\plusone
\edef\askedcontrastcolor{\interactionparameter\c!contrastcolor}%
\ifx\askedcontrastcolor\empty
- \dosetinteractioncolorattribute\c!color
+ \useinteractioncolorparameter\c!color
\else
- \dosetinteractioncolorattribute\c!contrastcolor
+ \useinteractioncolorparameter\c!contrastcolor
\fi
\else % we could just set and if > 0 set again
- \dosetinteractioncolorattribute\c!color
+ \useinteractioncolorparameter\c!color
\fi}
\def\setlocationfont % not grouped !
- {\dosetinteractionfontattribute\c!style}
+ {\useinteractionstyleparameter\c!style}
\def\setlocationattributes % not grouped !
{\ifnum\referencepagestate=\plusone
\edef\askedcontrastcolor{\interactionparameter\c!contrastcolor}%
\ifx\askedcontrastcolor\empty
- \dosetinteractionattributes\c!style\c!color
+ \useinteractionstyleandcolor\c!style\c!color
\else
- \dosetinteractionattributes\c!style\c!contrastcolor
+ \useinteractionstyleandcolor\c!style\c!contrastcolor
\fi
\else % we could just set and if > 0 set again
- \dosetinteractionattributes\c!style\c!color
+ \useinteractionstyleandcolor\c!style\c!color
\fi}
\def\setlocationcolorspec#1% \resolver
diff --git a/tex/context/base/spac-chr.lua b/tex/context/base/spac-chr.lua
index 430996ffd..b8a428aaf 100644
--- a/tex/context/base/spac-chr.lua
+++ b/tex/context/base/spac-chr.lua
@@ -8,6 +8,9 @@ if not modules then modules = { } end modules ['spac-chr'] = {
local byte, lower = string.byte, string.lower
+-- beware: attribute copying is bugged ... there will be a proper luatex helper
+-- for this
+
-- to be redone: characters will become tagged spaces instead as then we keep track of
-- spaceskip etc
@@ -21,6 +24,7 @@ local set_attribute = node.set_attribute
local has_attribute = node.has_attribute
local insert_node_after = node.insert_after
local remove_node = nodes.remove -- ! nodes
+local copy_node_list = node.copy_list
local nodepool = nodes.pool
local tasks = nodes.tasks
@@ -56,28 +60,38 @@ local function inject_quad_space(unicode,head,current,fraction)
if fraction ~= 0 then
fraction = fraction * fontparameters[current.font].quad
end
- head, current = insert_node_after(head,current,new_glue(fraction))
- current.attr = attr
- set_attribute(current,a_character,unicode)
+ local glue = new_glue(fraction)
+-- glue.attr = copy_node_list(attr)
+ glue.attr = attr
+current.attr = nil
+ set_attribute(glue,a_character,unicode)
+ head, current = insert_node_after(head,current,glue)
return head, current
end
local function inject_char_space(unicode,head,current,parent)
local attr = current.attr
local char = fontcharacters[current.font][parent]
- head, current = insert_node_after(head,current,new_glue(char and char.width or fontparameters[current.font].space))
- current.attr = attr
- set_attribute(current,a_character,unicode)
+ local glue = new_glue(char and char.width or fontparameters[current.font].space)
+-- glue.attr = copy_node_list(current.attr)
+ glue.attr = current.attr
+current.attr = nil
+ set_attribute(glue,a_character,unicode)
+ head, current = insert_node_after(head,current,glue)
return head, current
end
local function inject_nobreak_space(unicode,head,current,space,spacestretch,spaceshrink)
local attr = current.attr
- local next = current.next
- head, current = insert_node_after(head,current,new_penalty(10000))
- head, current = insert_node_after(head,current,new_glue(space,spacestretch,spaceshrink))
- current.attr = attr
- set_attribute(current,a_character,unicode)
+ local glue = new_glue(space,spacestretch,spaceshrink)
+ local penalty = new_penalty(10000)
+-- glue.attr = copy_node_list(attr)
+ glue.attr = attr
+current.attr = nil
+-- penalty.attr = attr
+ set_attribute(glue,a_character,unicode)
+ head, current = insert_node_after(head,current,penalty)
+ head, current = insert_node_after(head,current,glue)
return head, current
end
diff --git a/tex/context/base/spac-def.mkiv b/tex/context/base/spac-def.mkiv
index 9c9bdf687..32978076f 100644
--- a/tex/context/base/spac-def.mkiv
+++ b/tex/context/base/spac-def.mkiv
@@ -15,25 +15,33 @@
\unprotect
+\newconstant\c_spac_default_tolerance \c_spac_default_tolerance 1500
+
\def\forgeteverypar
{\everypar{\the\neverypar}}
+% worth trying:
+%
+% \def\forgeteverypar
+% {\everypar\neverypar}
+
\def\forgetparindent
{\forgeteverypar
\indentfirstparagraphtrue % recently added
- \let\currentindentation\v!none
\ctxparindent\zeropoint
- \parindent\zeropoint\relax}
+ \parindent\zeropoint
+ \let\currentindentation\v!none}
\def\forgetparskip
- {\let\currentwhitespace\v!none
- \ctxparskip\zeropoint
- \parskip\zeropoint\relax}
+ {\ctxparskip\zeropoint
+ \parskip\zeropoint
+ \let\currentwhitespace\v!none}
\def\forgetbothskips
- {\tolerance1500
+ {\tolerance\c_spac_default_tolerance
\leftskip\zeropoint
- \rightskip\zeropoint\relax}
+ \rightskip\zeropoint
+ \relax}
\def\forgetspacing
{\emergencystretch\zeropoint}
diff --git a/tex/context/base/spac-fnt.mkiv b/tex/context/base/spac-fnt.mkiv
index ada7c2efc..873641929 100644
--- a/tex/context/base/spac-fnt.mkiv
+++ b/tex/context/base/spac-fnt.mkiv
@@ -13,94 +13,25 @@
\writestatus{loading}{ConTeXt Spacing Macros / Fonts}
-%D For historic reasons here, will move and/or disappear:
+%D For historic reasons we keep the following around but
+%D they are no longer that relevant for \MKIV. The name of
+%D this module is somewhat weird, but it happened that these
+%D macros were defined in a larger one with the same name.
\unprotect
-\newconditional \parbasedattributes % this will change .. old mkii stuff
-
-\def\finishparbasedattributes
- {\ifconditional\parbasedattributes
- \setfalse\parbasedattributes
- \par
- \fi}
-
-\def\dostopparbasedattributes
- {\settrue\parbasedattributes
- \dostopattributes}
-
-\let\dostopattributes\relax % in case these commands end up in an edef
-
-\unexpanded\def\@@dostopattributes
- {\stopcolor
- \finishparbasedattributes
- \endgroup}
-
-\unexpanded\def\@@nostopattributes
- {\finishparbasedattributes
- \endgroup}
-
\unexpanded\def\doattributes#1#2#3#4%
- {\dostartattributes{#1}{#2}{#3}{#4}\dostopattributes}
-
-% An even faster \ETEX\ version:
-
-\unexpanded\def\dostartattributes#1#2#3%
{\begingroup % geen \bgroup, anders in mathmode lege \hbox
- \ifincolor
- \ifcsname#1#3\endcsname
- \let\dostopattributes\@@dostopattributes
- \faststartcolor[\csname#1#3\endcsname]%
- \else
- \let\dostopattributes\@@nostopattributes
- \fi
- \else
- \let\dostopattributes\@@nostopattributes
- \fi
- \ifcsname#1#2\endcsname
- % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname
- \@EA\doconvertfont\csname#1#2\@EA\endcsname
- \fi}
-
-\unexpanded\def\@@dostopattributes
- {\faststopcolor
- \finishparbasedattributes
- \endgroup}
-
-\unexpanded\def\@@nostopattributes
- {\finishparbasedattributes
+ \dousestylehashparameter{#1}{#2}%
+ \dousecolorhashparameter{#1}{#3}%
+ #4%
\endgroup}
-%D Bonus macro, see core-sec.tex
-
-\newconditional\fontattributeisset
-
-\unexpanded\def\dosetfontattribute#1#2%
- {\ifcsname#1#2\endcsname
- \settrue\fontattributeisset % reset is done elsewhere
- \@EA\doconvertfont\csname#1#2\@EA\endcsname
- \fi\empty}
-
-%D Since this happens a lot, and sometimes large arguments
-%D are passed in \type {#4}, we just copy some code:
-
-\unexpanded\def\doattributes#1#2#3#4%
+\unexpanded\def\dostartattributes#1#2#3#4% nothing is done with #4 any longer
{\begingroup % geen \bgroup, anders in mathmode lege \hbox
- \ifincolor
- \ifcsname#1#3\endcsname
- \let\dostopattributes\@@dostopattributes
- \faststartcolor[\csname#1#3\endcsname]%
- \else
- \let\dostopattributes\endgroup
- \fi
- \else
- \let\dostopattributes\endgroup
- \fi
- \ifcsname#1#2\endcsname
- % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname
- \@EA\doconvertfont\csname#1#2\@EA\endcsname
- \fi
- {#4}%
- \dostopattributes}
+ \dousestylehashparameter{#1}{#2}%
+ \dousecolorhashparameter{#1}{#3}}
+
+\let\dostopattributes\endgroup
\protect \endinput
diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv
index e3496e923..2e5884325 100644
--- a/tex/context/base/spac-hor.mkiv
+++ b/tex/context/base/spac-hor.mkiv
@@ -47,7 +47,7 @@
\definecomplexorsimple\setupindenting
-\def\complexsetupindenting[#1]%
+\unexpanded\def\complexsetupindenting[#1]%
{\edef\currentindenting{#1}%
\ifx\currentindenting\empty \else
\doapplycurrentindenting
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index 6cd435e8b..c43e49853 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -17,7 +17,7 @@
\registerctxluafile{spac-ver}{1.001}
-\newskip\blankskip \blankskip=\bigskipamount
+\newskip\blankskip \blankskip=\bigskipamount
\def\skipfactor {.75}
\def\skipgluefactor{.25}
@@ -92,15 +92,15 @@
\dosetupspecifiedinterlinespaceindeed}
\def\dosetupspecifiedinterlinespaceindeed
- {\edef\strutheightfactor {\interlinespaceparameter\c!height}%
- \edef\strutdepthfactor {\interlinespaceparameter\c!depth}%
+ {\edef\strutheightfactor {\interlinespaceparameter\c!height }%
+ \edef\strutdepthfactor {\interlinespaceparameter\c!depth }%
\edef\minimumstrutheight {\interlinespaceparameter\c!minheight}%
- \edef\minimumstrutdepth {\interlinespaceparameter\c!mindepth}%
- \edef\minimumlinedistance{\interlinespaceparameter\c!distance}%
- \edef\normallineheight {\interlinespaceparameter\c!line}%
- \edef\topskipfactor {\interlinespaceparameter\c!top}%
- \edef\maxdepthfactor {\interlinespaceparameter\c!bottom}%
- \edef\baselinegluefactor {\interlinespaceparameter\c!stretch}%
+ \edef\minimumstrutdepth {\interlinespaceparameter\c!mindepth }%
+ \edef\minimumlinedistance{\interlinespaceparameter\c!distance }%
+ \edef\normallineheight {\interlinespaceparameter\c!line }%
+ \edef\topskipfactor {\interlinespaceparameter\c!top }%
+ \edef\maxdepthfactor {\interlinespaceparameter\c!bottom }%
+ \edef\baselinegluefactor {\interlinespaceparameter\c!stretch }%
% often topskip does more bad than good, so:
\ifx\topskipfactor\v!height
\let\topskipfactor\strutheightfactor
@@ -140,8 +140,8 @@
\let\setrelativeinterlinespace\relax
-\newtoks \everysetupglobalinterlinespace
-\newtoks \everysetuplocalinterlinespace
+\newtoks\everysetupglobalinterlinespace
+\newtoks\everysetuplocalinterlinespace
\def\interlinespaceparameter #1{\csname\dointerlinespaceparameter{\??it\currentinterlinespace}#1\endcsname}
\def\dointerlinespaceparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dointerlinespaceparentparameter\csname#1\s!parent\endcsname#2\fi}
@@ -227,19 +227,27 @@
\definecomplexorsimple\setupinterlinespace
-\def\removelastskip % a redefinition of plain
+\def\removelastskip
{\ifvmode\ifdim\lastskip=\zeropoint\else\vskip-\lastskip\fi\fi}
-\def\doifoutervmode#1%
- {\ifvmode\ifinner\else#1\fi\fi}
+\def\doifoutervmode
+ {\ifvmode
+ \ifinner
+ \doubleexpandafter\gobbleoneargument
+ \else
+ \doubleexpandafter\firstofoneargument
+ \fi
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
\def\dosomebreak#1%
{\doifoutervmode
{\scratchskip\lastskip
\removelastskip
- %\leavevmode\type{#1}%
#1\relax
- \ifdim\scratchskip=\zeropoint % else interference with footnotes
+ \ifdim\scratchskip=\zeropoint
+ % avoid interference with footnotes
\else
\vskip\scratchskip
\fi}}
@@ -252,88 +260,11 @@
\ifhmode\endgraf\fi
\ifvmode\nointerlineskip\vskip#1\relax\fi}
-\ifx\smallskip\undefined
-
- \def\smallskip{\vskip\smallskipamount}
- \def\medskip {\vskip\medskipamount}
- \def\bigskip {\vskip\bigskipamount}
-
-\fi
-
-\ifx\allowbreak\undefined
-
- \def\break {\penalty\ifhmode-\plustenthousand\else\ejectpenalty\fi}
- \def\nobreak {\penalty \plustenthousand}
- \def\allowbreak{\penalty \zeropoint}
- \def\filbreak {\par\vfil\penalty-200\vfilneg}
- \def\goodbreak {\par\penalty-500 }
-
-\fi
-
-%D Made slightly more readable:
-
-\ifx\vglue\undefined
-
- \def\vglue {\afterassignment\dovglue\scratchskip=}
- \def\hglue {\afterassignment\dohglue\scratchskip=}
- \def\topglue{\nointerlineskip\vglue-\topskip\vglue}
-
- \def\dovglue
- {\par
- \scratchdimen\prevdepth
- \hrule\!!height\zeropoint
- \nobreak
- \vskip\scratchskip
- \prevdepth\scratchdimen}
-
- \def\dohglue
- {\dontleavehmode % \leavevmode
- \scratchcounter\spacefactor
- \vrule\!!width\zeropoint
- \nobreak
- \hskip\scratchskip
- \spacefactor\scratchcounter}
-
-\fi
-
-\ifx\eject\undefined
-
- \def\eject{\par\break}
-
-\fi
-
-\ifx\supereject\undefined
+\unexpanded\def\smallskip{\vskip\smallskipamount}
+\unexpanded\def\medskip {\vskip\medskipamount}
+\unexpanded\def\bigskip {\vskip\bigskipamount}
- \def\supereject{\par\penalty\superpenalty}
-
-\fi
-
-\ifx\dosupereject\undefined
-
- \def\dosupereject
- {\ifnum\insertpenalties>\zerocount % something is being held over
- \line{}
- \kern-\topskip
- \nobreak
- \vfill\supereject
- \fi}
-
-\fi
-
-%D We adapt plain's \type {\removelastskip} a bit:
-
-\ifx\removelastskip\undefined
-
- \def\removelastskip
- {\ifvmode \ifdim\lastskip=\zeropoint \else
- \vskip-\lastskip
- \fi \fi}
-
-\fi
-
-\ifx\smallbreak\undefined
-
-\def\smallbreak
+\unexpanded\def\smallbreak
{\par
\ifdim\lastskip<\smallskipamount
\removelastskip
@@ -341,7 +272,7 @@
\smallskip
\fi}
-\def\medbreak
+\unexpanded\def\medbreak
{\par
\ifdim\lastskip<\medskipamount
\removelastskip
@@ -349,7 +280,7 @@
\medskip
\fi}
-\def\bigbreak
+\unexpanded\def\bigbreak
{\par
\ifdim\lastskip<\bigskipamount
\removelastskip
@@ -357,18 +288,49 @@
\bigskip
\fi}
-\fi
-
+\unexpanded\def\break {\penalty-\plustenthousand} % can be hmode or vmode
+\unexpanded\def\nobreak {\penalty \plustenthousand} % can be hmode or vmode
+\unexpanded\def\allowbreak{\penalty \zeropoint} % can be hmode or vmode
+\unexpanded\def\goodbreak {\par\penalty-500\relax} % forces vmode
+\unexpanded\def\filbreak {\par\vfil\penalty-200\vfilneg} % forces vmode
+
+%D Made slightly more readable:
+
+\unexpanded\def\vglue {\afterassignment\spacing_vglue_indeed\scratchskip=}
+\unexpanded\def\hglue {\afterassignment\spacing_hglue_indeed\scratchskip=}
+\unexpanded\def\topglue{\nointerlineskip\vglue-\topskip\vglue}
+
+\def\spacing_vglue_indeed
+ {\par
+ \scratchdimen\prevdepth
+ \hrule\!!height\zeropoint
+ \nobreak
+ \vskip\scratchskip
+ \prevdepth\scratchdimen}
+
+\def\spacing_hglue_indeed
+ {\dontleavehmode % \leavevmode
+ \scratchcounter\spacefactor
+ \vrule\!!width\zeropoint
+ \nobreak
+ \hskip\scratchskip
+ \spacefactor\scratchcounter}
+
+%D We adapt plain's \type {\removelastskip} a bit:
+
+\unexpanded\def\removelastskip % also in supp-box
+ {\ifvmode\ifzeropt\lastskip\else\vskip-\lastskip\fi\fi}
+
\newskip\ctxparskip \ctxparskip\zeropoint
\newconditional \flexiblewhitespace \settrue\flexiblewhitespace
-\def\currentwhitespace {\zeropoint}
+\def\currentwhitespace{\zeropoint}
\definecomplexorsimple\setupwhitespace
\def\simplesetupwhitespace
- {\doifnot\currentwhitespace\v!none\dosetupwhitespace}
+ {\doifnot\currentwhitespace\v!none\spacing_setup_whitespace}
\def\complexsetupwhitespace[#1]%
{\edef\nextcurrentwhitespace{#1}%
@@ -376,67 +338,52 @@
\simplesetupwhitespace
\else
\let\currentwhitespace\nextcurrentwhitespace
- \dosetupwhitespace
+ \spacing_setup_whitespace
\fi}
\newconstant\baselinegridmode % option in layout / 1=permit_half_lines
-\def\dosetupwhitespace % quick test for no list
- {\ifcsname\??ws\??ws\currentwhitespace\endcsname
- \csname\??ws\??ws\currentwhitespace\endcsname
+\def\spacing_setup_whitespace % quick test for no list
+ {\ifcsname\??wz:\currentwhitespace\endcsname
+ \csname\??wz:\currentwhitespace\endcsname
\else
- \expandafter\processcommalist\expandafter[\currentwhitespace]\dowhitespacemethod % can be raw
+ \expandafter\processcommalist\expandafter[\currentwhitespace]\spacing_setup_whitespace_method % can be raw
\fi\relax
\ifgridsnapping
- \setfalse\flexiblewhitespace
- \ifdim\ctxparskip>\zeropoint
- \ctxparskip
- \ifcase\baselinegridmode
- \baselineskip % normal ! ! ! ! !!
- \or
- \ifdim\scratchdimen=\baselineskip % maybe range
- \baselineskip % normal ! ! ! ! !!
- \else
- \numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax
- \fi
- \else
- \baselineskip % normal ! ! ! ! !!
- \fi
- \fi
+ \spacing_setup_whitespace_grid
\else
- \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi
+ \spacing_setup_whitespace_normal
\fi
\parskip\ctxparskip}
-\def\dodosetupwhitespace
- {\ifgridsnapping
- \setfalse\flexiblewhitespace
+\def\spacing_setup_whitespace_normal
+ {\ifconditional\flexiblewhitespace \else
\ctxparskip1\ctxparskip
- \ifdim\ctxparskip>\zeropoint
+ \fi}
+
+\def\spacing_setup_whitespace_grid
+ {\setfalse\flexiblewhitespace
+ \ifdim\ctxparskip>\zeropoint
+ \ctxparskip
\ifcase\baselinegridmode
- \ctxparskip\baselineskip % normal ! ! ! ! !!
+ \baselineskip % normal ! ! ! ! !!
\or
\ifdim\scratchdimen=\baselineskip % maybe range
- \ctxparskip\baselineskip % normal ! ! ! ! !!
+ \baselineskip % normal ! ! ! ! !!
\else
- \ctxparskip\numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax
+ \numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax
\fi
\else
- \ctxparskip\baselineskip % normal ! ! ! ! !!
+ \baselineskip % normal ! ! ! ! !!
\fi
- \fi
- \else
- \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi
- \fi
- \parskip\ctxparskip}
-
-\definesystemvariable {ws} % whitespace
+ \fi}
-\unexpanded\def\definewhitespacemethod[#1]#2{\setvalue{\??ws\??ws#1}{#2}}
+\unexpanded\def\definewhitespacemethod[#1]#2{\setvalue{\??wz:#1}{#2}}
\definewhitespacemethod [\v!fix] {}
\definewhitespacemethod [\v!fixed] {\setfalse\flexiblewhitespace}
-\definewhitespacemethod [\v!flexible] {\settrue\flexiblewhitespace}
+\definewhitespacemethod [\v!flexible] {\settrue \flexiblewhitespace}
+
\definewhitespacemethod [\v!line] {\ctxparskip \baselineskip}
\definewhitespacemethod [\v!halfline] {\ctxparskip.5\baselineskip}
\definewhitespacemethod [\v!none] {\ctxparskip \zeropoint}
@@ -444,13 +391,22 @@
\definewhitespacemethod [\v!medium] {\ctxparskip \medskipamount}
\definewhitespacemethod [\v!small] {\ctxparskip \smallskipamount}
-\definewhitespacemethod [\s!default] {\simplesetupwhitespace} % {\stelwitruimteopnieuwin}
+\definewhitespacemethod [\s!default] {\simplesetupwhitespace}
-\def\dowhitespacemethod#1%
- {\ifcsname\??ws\??ws#1\endcsname\csname\??ws\??ws#1\endcsname\else\ctxparskip#1\fi\relax}
+\def\spacing_setup_whitespace_method#1%
+ {\ifcsname\??wz:#1\endcsname
+ \csname\??wz:#1\endcsname
+ \else
+ \ctxparskip#1\fi
+ \relax}
-\def\nowhitespace{\vspacing[\v!nowhite]}
-\def\whitespace {\vspacing[\v!white]}
+% \definewhitespacemethod [\s!unknown] {\ctxparskip\commalistelement\relax}
+%
+% \def\spacing_setup_whitespace_method#1%
+% {\csname\??wz:\ifcsname\??wz:#1\endcsname#1\else\s!unknown\endcsname\relax}
+
+\unexpanded\def\nowhitespace{\vspacing[\v!nowhite]}
+\unexpanded\def\whitespace {\vspacing[\v!white]}
% De onderstaande macro handelt ook de situatie dat er geen
% tekst tussen \start ... \stop is geplaatst. Daartoe wordt de
@@ -461,9 +417,9 @@
\newcount\packeddepth
\unexpanded\def\startpacked
- {\dosingleempty\dostartpacked}
+ {\dosingleempty\spacing_start_packed}
-\def\dostartpacked[#1]% nesting afvangen
+\def\spacing_start_packed[#1]% nesting afvangen
{\global\advance\packeddepth\plusone
\par
\ifnum\packeddepth=\plusone \ifvmode
@@ -519,16 +475,16 @@
\doaroundlinecorrection
\egroup}
-\def\correctwhitespace
+\unexpanded\def\correctwhitespace
{\dowithnextbox
{\startbaselinecorrection
\flushnextbox
\stopbaselinecorrection}%
\vbox}
-
-\def\verticalstrut {\normalvbox{\hsize\zeropoint\forgetall\strut}}
-\def\horizontalstrut{\normalhbox {\strut}}
-
+
+\unexpanded\def\verticalstrut {\normalvbox{\hsize\zeropoint\forgetall\strut}}
+\unexpanded\def\horizontalstrut{\normalhbox {\strut}}
+
% Hieronder volgen enkele instellingen en macro's ten behoeve
% van de interlinie en \strut. De waarden 2.8, 0.07, 0.72 en
% 0.28 zijn ooit eens ontleend aan INRS-TEX en moeten wellicht
@@ -581,15 +537,15 @@
\def\baselinefactor {2.8}
\def\baselinegluefactor {0}
-\def\minimumstrutheight {0pt}
-\def\minimumstrutdepth {0pt}
+\def\minimumstrutheight {\zeropoint}
+\def\minimumstrutdepth {\zeropoint}
\def\normallineheight {\baselinefactor ex}
\def\minimumlinedistance {\lineskip}
-\def\strutheight {0pt}
-\def\strutdepth {0pt}
-\def\strutwidth {0pt}
+\def\strutheight {\zeropoint}
+\def\strutdepth {\zeropoint}
+\def\strutwidth {\zeropoint}
\let\spacingfactor \plusone
@@ -599,19 +555,15 @@
\def\systemtopskipfactor {\topskipfactor}
\def\systemmaxdepthfactor {\maxdepthfactor}
-\ifdefined\globalbodyfontsize\else
- \newdimen\globalbodyfontsize
- \globalbodyfontsize=12pt
+\ifdefined\globalbodyfontsize \else
+ \newdimen\globalbodyfontsize
+ \globalbodyfontsize=12pt
\fi
-\ifdefined\normalizedbodyfontsize\else
- \def\normalizedbodyfontsize{12pt}
+\ifdefined\normalizedbodyfontsize \else
+ \def\normalizedbodyfontsize{12pt}
\fi
-% door een \dimen. Dit is geen probleem omdat (1) de default
-% korpsgrootte 12pt is en (2) de fonts nog niet geladen zijn
-% en de instellingen bij het laden nogmaals plaatsvinden.
-
\def\topskipcorrection
{\simpletopskipcorrection
\vskip-\struttotal
@@ -624,14 +576,14 @@
\vskip-\openstrutheight
\fi}
-\def\settopskip % the extra test is needed for the lbr family
+\unexpanded\def\settopskip % the extra test is needed for the lbr family
{\topskip\systemtopskipfactor\globalbodyfontsize
\ifgridsnapping \else
\ifr@ggedbottom\!!plus5\globalbodyfontsize\fi
\fi
-\ifgridsnapping
- \topskip\zeropoint
-\fi
+ \ifgridsnapping
+ \topskip\zeropoint
+ \fi
\relax % the skip
\topskipgap\topskip
\advance\topskipgap -\openstrutheight\relax
@@ -639,21 +591,21 @@
\ifdim\topskip<\minimumstrutheight
\topskip\minimumstrutheight\relax
\fi
- \else
+ \else
\ifdim\topskip<\strutheightfactor\openlineheight
\topskip\strutheightfactor\openlineheight\relax
\fi
- \fi}
+ \fi}
-\def\setmaxdepth
+\unexpanded\def\setmaxdepth
{\maxdepth\systemmaxdepthfactor\globalbodyfontsize}
-\def\normalbaselines
+\unexpanded\def\normalbaselines
{\baselineskip \normalbaselineskip
\lineskip \normallineskip
\lineskiplimit\normallineskiplimit}
-\def\setnormalbaselines
+\unexpanded\def\setnormalbaselines
{\ifdim\normallineheight>\zeropoint
\lineheight\normallineheight
\fi
@@ -678,13 +630,10 @@
\fi
\normallineskip\minimumlinedistance\relax % \onepoint\relax
\normallineskiplimit\zeropoint\relax
- \normalbaselines
- %\dosetupgridsnapping
- }
+ \normalbaselines}
-\def\spacing#1%
+\unexpanded\def\spacing#1%
{\ifgridsnapping
- %\ifdim#1\points=\onepoint\else\showmessage\m!layouts{11}{\withoutpt\the\dimexpr#1\points\relax}\fi
\let\spacingfactor\plusone
\else
\edef\spacingfactor{#1}%
@@ -722,15 +671,11 @@
%
% \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox}
-\ifx\strutbox\undefined
-
- \newbox\strutbox
+\newbox\strutbox
- \setbox\strutbox\normalhbox{\vrule height8.5pt depth3.5pt width\zeropoint}
+\setbox\strutbox\normalhbox{\vrule height8.5pt depth3.5pt width\zeropoint} % just a start
- \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox}
-
-\fi
+\def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox}
\let\normalstrut\strut
@@ -791,13 +736,13 @@
%D Handy for math (used in mathml):
-\def\charhtstrut
+\unexpanded\def\charhtstrut
{\begingroup
\setcharstrut{GJY}%
\vrule\!!width\zeropoint\!!depth\zeropoint\!!height\strutht
\endgroup}
-\def\chardpstrut
+\unexpanded\def\chardpstrut
{\begingroup
\setcharstrut{gjy}%
\vrule\!!width\zeropoint\!!depth\strutdp\!!height\zeropoint
@@ -810,31 +755,49 @@
\newdimen\tempstrutdimen
-\def\dosetstrut
+% \unexpanded\def\dosetstrut
+% {\let\strut\normalstrut
+% \tempstrutdimen\dimexpr\strutht+\strutdp-\lineheight\relax
+% \ifabsnum\tempstrutdimen<\plustwo
+% % compensate rounding error /- 1sp to avoid too many
+% % 1sp baselineskips in for instance verbatim
+% \strutht\dimexpr\strutht-\tempstrutdimen\relax
+% \fi
+% \edef\strutheight{\the\strutht}% maybe better \number\strutht sp
+% \edef\strutdepth {\the\strutdp}%
+% \ifdim\strutwidth=\zeropoint
+% \dosetstruthide
+% \else
+% \dosetstrutvide
+% \fi
+% \struttotal\dimexpr\strutht+\strutdp\relax}
+
+\unexpanded\def\dosetstrut
{\let\strut\normalstrut
- \tempstrutdimen\dimexpr\strutht+\strutdp-\lineheight\relax
- \ifabsnum\tempstrutdimen<\plustwo
- % compensate rounding error /- 1sp to avoid too many
- % 1sp baselineskips in for instance verbatim
- \strutht\dimexpr\strutht-\tempstrutdimen\relax
+ \ifabsnum\dimexpr\strutht+\strutdp-\lineheight\relax<\plustwo
+ % compensate rounding error /- 1sp to avoid too many
+ % 1sp baselineskips in for instance verbatim
+ \strutht\dimexpr\lineheight-\strutdp\relax
+ \struttotal\lineheight
+ \else
+ \struttotal\dimexpr\strutht+\strutdp\relax
\fi
- \edef\strutheight{\the\strutht}% maybe better \number\strutht sp
+ \edef\strutheight{\the\strutht}%
\edef\strutdepth {\the\strutdp}%
\ifdim\strutwidth=\zeropoint
\dosetstruthide
\else
\dosetstrutvide
- \fi
- \struttotal\dimexpr\strutht+\strutdp\relax}
+ \fi}
-\def\dosetstruthide
+\unexpanded\def\dosetstruthide
{\setbox\strutbox\normalhbox
{\vrule
\!!width \zeropoint
\!!height\strutht
\!!depth \strutdp}}
-\def\dosetstrutvide
+\unexpanded\def\dosetstrutvide
{\setbox\strutbox\normalhbox
{\normalhbox to \zeropoint
{% \hss % new, will be option
@@ -852,12 +815,12 @@
\newbox\emptystrutbox \setbox\emptystrutbox\emptyhbox
-\def\dosetstruthide
+\unexpanded\def\dosetstruthide
{\setbox\strutbox\copy\emptystrutbox
\ht\strutbox\strutht
\dp\strutbox\strutdp}
-\def\strut{\relax\dontleavehmode\copy\strutbox} % still callbacks for \hbox{\strut}
+\unexpanded\def\strut{\relax\dontleavehmode\copy\strutbox} % still callbacks for \hbox{\strut}
\let\normalstrut\strut
@@ -893,7 +856,7 @@
\def\showstruts
{\setteststrut
\settestcrlf}
-
+
\def\setteststrut
{\def\strutwidth{.8pt}%
\setstrut}
@@ -917,7 +880,7 @@
\newsignal\strutsignal \setfalse\sigstruts
-\def\begstrut
+\unexpanded\def\begstrut
{\relax\ifcase\strutht\else
\ifconditional\sigstruts
\noindent\horizontalstrut
@@ -932,11 +895,14 @@
\expandafter \ignorespaces
\fi}
-\def\endstrut
+\unexpanded\def\endstrut
{\relax\ifhmode\ifcase\strutht\else
\ifconditional\sigstruts
\ifdim\lastskip=\strutsignal
- \unskip\unskip\unpenalty\setbox\scratchbox\lastbox
+ \unskip
+ \unskip
+ \unpenalty
+ \setbox\scratchbox\lastbox
\else
\normalpenalty\plustenthousand
\normalhskip\zeropoint
@@ -1040,11 +1006,6 @@
\leavevmode
\fi\fi}
-% We stellen enkele penalties anders in dan Plain TEX:
-%
-% \widowpenalty=\defaultwidowpenalty\relax
-% \clubpenalty =\defaultclubpenalty \relax
-
\def\resetpenalties#1%
{\ifdefined#1%
#1\minusone
@@ -1410,7 +1371,7 @@
{\setbox\nextbox#1%
{\hbox
{\hbox to \zeropoint
- {\setlayoutcomponentattribute\v!grid\v!test
+ {\setlayoutcomponentattribute{\v!grid:\v!test}%
\color[grid:#2]{\ruledhbox \layoutcomponentboxattribute {\fakebox\nextbox}}%
\hss}%
\flushnextbox}}}
@@ -1810,7 +1771,7 @@
\whitespace
\dostarttagged\t!lines\currentlines
\begingroup
- \dosetlinesattributes\c!style\c!color
+ \uselinesstyleandcolor\c!style\c!color
\setupindenting[\linesparameter\c!indenting]%
\setupalign[\linesparameter\c!align]%
\typesettinglinestrue
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 3b3b029d1..0bdc57a12 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 93d4231cb..4cc70bb77 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-blk.mkiv b/tex/context/base/strc-blk.mkiv
index b8f8c6b3a..bb9e7563e 100644
--- a/tex/context/base/strc-blk.mkiv
+++ b/tex/context/base/strc-blk.mkiv
@@ -71,8 +71,8 @@
\doblocksetups\currentblock
\let\doblocksetups\gobbleoneargument
\namedblockparameter\currentblock\c!before
- \dosetfontattribute{\??tb\currentblock}\c!style
- \dosetcolorattribute{\??tb\currentblock}\c!color
+ \dousestylehashparameter{\??tb\currentblock}\c!style
+ \dousecolorhashparameter{\??tb\currentblock}\c!color
\namedblockparameter\currentblock\c!inner
\ignorespaces}
diff --git a/tex/context/base/strc-des.mkiv b/tex/context/base/strc-des.mkiv
index 18467fb41..cd2cbc12f 100644
--- a/tex/context/base/strc-des.mkiv
+++ b/tex/context/base/strc-des.mkiv
@@ -105,11 +105,11 @@
\def\dodescriptionparentparameterhash#1#2%
{\ifx#1\relax\else\dodescriptionparameterhash#1#2\fi}
-\def\dosetdescriptionattributes#1#2% style color
- {\edef\fontattributehash {\descriptionparameterhash#1}%
- \edef\colorattributehash{\descriptionparameterhash#2}%
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
+\def\usedescriptionstyleandcolor#1#2% style color
+ {\edef\currentstyleparameter{\descriptionparameter#1}%
+ \edef\currentcolorparameter{\descriptionparameter#2}%
+ \ifx\currentstyleparameter\empty\else\dousestyleparameter\currentstyleparameter\fi
+ \ifx\currentcolorparameter\empty\else\dousecolorparameter\currentcolorparameter\fi}
% typesetting code
@@ -392,7 +392,7 @@
\dorechecknextindentation}
\def\@@dodescription
- {\dosetdescriptionattributes\c!style\c!color
+ {\usedescriptionstyleandcolor\c!style\c!color
\ignorespaces}
% starters:
@@ -455,10 +455,6 @@
% % % % % % % % % % % %
-% helpers
-
-% todo: \dosetfontattributewithhash \descriptionparameterhash\c!headstyle
-
% setup descriptions
\unexpanded\def\setupdescriptions
@@ -474,6 +470,50 @@
\def\dodosetupdescriptions[#1]% [#2]%
{\getparameters[\??dd#1]} % [#2]}
+\setupdescriptions
+ [\c!location=\v!left,
+ \c!headstyle=\v!bold,
+ \c!titlestyle=\v!bold,
+ \c!style=\v!normal,
+ \c!color=,
+ \c!headcolor=,
+ \c!titlecolor=,
+ %\c!width=8em,
+ %\c!distance=0pt,
+ \c!titledistance=0.5em,
+ \c!hang=,
+ \c!sample=,
+ \c!align=,
+ \c!headalign=,
+ \c!margin=\v!no,
+ \c!before=\blank,
+ \c!inbetween=\blank,
+ \c!after=\blank,
+ \c!indentnext=\v!yes,
+ \c!indenting=\v!never,
+ \c!titleleft=(,
+ \c!titleright=),
+ \c!closesymbol=,
+ \c!closecommand=\wordright,
+ \c!display=\v!yes,
+ \c!command=,
+ \c!titlecommand=]
+
+\setupdescriptions
+ [\c!expansion=\v!no,
+ \c!xmlsetup=,
+ \s!catcodes=,
+ \c!saveinlist=\v!yes]
+
+\setupdescriptions
+ [\c!width=7em,
+ \c!distance=1em]
+
+\setupdescriptions[\c!width:\c!top=\localhsize] % undocumented, only width and distance
+% \setupdescriptions[\c!width:\c!left=7em,\c!distance=1em]
+% \setupdescriptions[\c!width:\c!right=7em,\c!distance=1em]
+% \setupdescriptions[\c!width:\v!hanging=\v!fit] % yes or no
+
% define descriptions
\unexpanded\def\definedescription
@@ -544,7 +584,7 @@
\def\@@dodescriptiontext
{\begingroup
- \dosetdescriptionattributes\c!headstyle\c!headcolor
+ \usedescriptionstyleandcolor\c!headstyle\c!headcolor
\the\everydescription
\descriptionparameter\c!command{\strut\descriptionparameter\c!text\ignorespaces\@@dododescriptiontext}% probably incomplete
\endgroup}
@@ -566,6 +606,24 @@
\getparameters[\??dn][#1]%
\fi}
+\setupenumerations
+ [\c!location=\v!top,
+ \c!text=,
+ \c!way=\v!by\v!text,
+ \c!prefix=\v!no,
+ \c!prefixconnector=.,
+ \c!starter=,
+ \c!stopper=,
+ \c!number=\v!yes, % else description
+ \c!start=0,
+ \s!parent=\??dd]
+
+\setupenumerations
+ [\c!expansion=\v!no,
+ \c!xmlsetup=,
+ \s!catcodes=,
+ \c!saveinlist=\v!yes]
+
% define enumerations
\unexpanded\def\defineenumeration
@@ -711,7 +769,7 @@
\def\doenumerationfullnumber#1% text, title (used in notes) .. todo
{\begingroup
- \dosetdescriptionattributes\c!headstyle\c!headcolor
+ \usedescriptionstyleandcolor\c!headstyle\c!headcolor
\the\everyenumeration
\descriptionparameter\c!command{\strut#1}%
\endgroup}
@@ -720,7 +778,7 @@
{\doif{\descriptionparameter\c!title}\v!yes
{\doifsomething\@@dodoenumerationtext
{\begingroup
- \dosetdescriptionattributes\c!titlestyle\c!titlecolor
+ \usedescriptionstyleandcolor\c!titlestyle\c!titlecolor
\hskip\descriptionparameter\c!titledistance
\descriptionparameter\c!titlecommand
{\descriptionparameter\c!titleleft
@@ -1005,143 +1063,112 @@
\descriptionparameter\c!before
\begingroup
\doincrementsubstructurecounter[\currentdescriptionnumber][\currentdescriptionlevel]%
- \dosetdescriptionattributes\c!headstyle\c!headcolor
+ \usedescriptionstyleandcolor\c!headstyle\c!headcolor
\executeifdefined{\??db:\c!location:\descriptionparameter\c!location}{\descriptionparameter\c!command}{\dodocurrentlabelnumber[#1]}%
\endgroup
\descriptionparameter\c!after}
-
-% to be reimplmented
-
-\unexpanded\def\setupindentations
- {\dodoubleempty\dosetupindentations}
-\def\dosetupindentations[#1][#2]%
- {\ifsecondargument
- \dodoubleargumentwithset\dodosetupindentations[#1][#2]%
- \else
- \dodosetupindentations[][#1]%
- \fi}
+\setuplabels
+ [\s!parent=\??dn]
-\def\dodosetupindentations[#1][#2]%
- {\getparameters[\??ds#1][#2]}
+%D \macros
+%D {defineindentedtext,
+%D setupindentedtext}
+%D
+%D Ok, we keep it but with a different command as it all looks too
+%D much like indentation and indenting. We also assume start/stop
+%D usage or some explicit par.
-\unexpanded\def\defineindenting
- {\dodoubleargumentwithset\dodefineindenting}
+\installcommandhandler \??ds {indentedtext} \??ds
-\def\dodefineindenting[#1][#2]%
- {\copyparameters[\??ds#1][\??ds]
- [\c!text,\c!separator,\c!width,\c!style,\c!color,
- \c!headstyle,\c!sample,\c!before,\c!after,\c!distance]%
- \getparameters[\??ds#1][#2]%
- \setuvalue {#1}{\dododefineindenting{#1}{0}{1}}%
- \setuvalue {\v!sub#1}{\dododefineindenting{#1}{1}{2}}%
- \setuvalue{\v!sub\v!sub#1}{\dododefineindenting{#1}{2}{3}}}
+%D \startbuffer
+%D \defineindentedtext[one][text=one]
+%D \defineindentedtext[two][text=two]
+%D
+%D \one test test \par
+%D \subone test test \par
+%D \subtwo test test \par
+%D \subsubone test test \par
+%D
+%D \startone
+%D test test
+%D \startone
+%D test test
+%D \startone
+%D test test
+%D \stopone
+%D \starttwo
+%D test test
+%D \startone
+%D test test
+%D \stopone
+%D \stoptwo
+%D \stopone
+%D \stopone
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
-\def\dododefineindenting#1#2#3%
+\appendtoks
+ \setuevalue {\e!start\currentindentedtext}{\start_indented_text{\currentindentedtext}\indented_text_nesting}%
+ \setuevalue {\e!stop \currentindentedtext}{\stop_indented_text}%
+ % to be avoided ... might go away
+ \setuevalue {\currentindentedtext}{\indented_text{\currentindentedtext}{0}}%
+ \setuevalue {\v!sub\currentindentedtext}{\indented_text{\currentindentedtext}{1}}%
+ \setuevalue{\v!sub\v!sub\currentindentedtext}{\indented_text{\currentindentedtext}{2}}%
+\to \everydefineindentedtext
+
+\newcount\indented_text_nesting
+\newdimen\indented_text_width
+
+\unexpanded\def\start_indented_text#1#2%
{\par
- \getvalue{\??ds#1\c!before}%
\begingroup
- \doifvaluenothing{\??ds#1\c!sample}
- {\setvalue{\??ds#1\c!sample}{\getvalue{\??ds#1\c!text}}}%
+ \indented_text_nesting#2\relax
+ \edef\currentindentedtext{#1}%
+ \indentedtextparameter\c!before
+ \doifnothing{\indentedtextparameter\c!sample}
+ {\setindentedtextparameter\c!sample{\indentedtextparameter\c!text}}%
\assignwidth
- {\descriptionsheadwidth}
- {\getvalue{\??ds#1\c!width}}
- {\doattributes
- {\??ds#1}\c!headstyle\c!headcolor
- {\getvalue{\??ds#1\c!sample}%
- \spr{\getvalue{\??ds#1\c!separator}}}}
- {\getvalue{\??ds#1\c!distance}}%
- \advance\descriptionsheadwidth \getvalue{\??ds#1\c!distance}%
- \setbox\scratchbox\hbox to \descriptionsheadwidth
- {\doattributes
- {\??ds#1}\c!headstyle\c!headcolor
- {\strut
- \getvalue{\??ds#1\c!text}%
- \hss
- \spr{\getvalue{\??ds#1\c!separator}}%
- \hskip\getvalue{\??ds#1\c!distance}}}%
+ {\indented_text_width}
+ {\indentedtextparameter\c!width}
+ {\useindentedtextstyleandcolor\c!headstyle\c!headcolor
+ \indentedtextparameter\c!sample
+ \spr{\indentedtextparameter\c!separator}}
+ {\indentedtextparameter\c!distance}%
+ \advance\indented_text_width \indentedtextparameter\c!distance
+ \setbox\scratchbox\hbox to \indented_text_width
+ {\useindentedtextstyleandcolor\c!headstyle\c!headcolor
+ \strut
+ \indentedtextparameter\c!text
+ \hss
+ \spr{\indentedtextparameter\c!separator}%
+ \hskip\indentedtextparameter\c!distance}%
\parindent\zeropoint
- \hskip#2\descriptionsheadwidth\indent\box\scratchbox
- \hangindent#3\descriptionsheadwidth
- \doattributes{\??ds#1}\c!style\c!color\empty
- \AfterPar{\endgroup\getvalue{\??ds#1\c!after}}% must be redone
- \GetPar}
-
-\setupdescriptions
- [\c!location=\v!left,
- \c!headstyle=\v!bold,
- \c!titlestyle=\v!bold,
- \c!style=\v!normal,
- \c!color=,
- \c!headcolor=,
- \c!titlecolor=,
- \c!width=8em,
- \c!distance=0pt,
- \c!titledistance=0.5em,
- \c!hang=,
- \c!sample=,
- \c!align=,
- \c!headalign=,
- \c!margin=\v!no,
- \c!before=\blank,
- \c!inbetween=\blank,
- \c!after=\blank,
- \c!indentnext=\v!yes,
- \c!indenting=\v!never,
- \c!titleleft=(,
- \c!titleright=),
- \c!closesymbol=,
- \c!closecommand=\wordright,
- \c!display=\v!yes,
- \c!command=,
- \c!titlecommand=]
-
-% way=bychapter,prefix=yes,prefixsegments=2:2
-
-\setupenumerations
- [\c!location=\v!top,
- \c!text=,
- \c!way=\v!by\v!text,
- \c!prefix=\v!no,
- \c!prefixconnector=.,
- \c!starter=,
- \c!stopper=,
- \c!number=\v!yes, % else description
- \c!start=0,
- \s!parent=\??dd]
-
-\setupdescriptions
- [\c!expansion=\v!no,
- \c!xmlsetup=,
- \s!catcodes=,
- \c!saveinlist=\v!yes]
-
-\setupenumerations
- [\c!expansion=\v!no,
- \c!xmlsetup=,
- \s!catcodes=,
- \c!saveinlist=\v!yes]
-
-\setupdescriptions
- [\c!width=7em,
- \c!distance=1em]
-
-\setupdescriptions[\c!width:\c!top=\localhsize] % undocumented, only width and distance
-% \setupdescriptions[\c!width:\c!left=7em,\c!distance=1em]
-% \setupdescriptions[\c!width:\c!right=7em,\c!distance=1em]
+ \hskip\indented_text_nesting\indented_text_width
+ \advance\indented_text_nesting\plusone
+ \dontleavehmode\box\scratchbox
+ \hangindent\indented_text_nesting\indented_text_width
+ \useindentedtextstyleandcolor\c!style\c!color}
+
+\unexpanded\def\stop_indented_text
+ {\indentedtextparameter\c!after
+ \par
+ \endgroup}
+\let\stopindentedtext\stop_indented_text
-\setuplabels
- [\s!parent=\??dn]
+\unexpanded\def\indented_text#1#2#3\par % no longer clever grabpar trickery
+ {\start_indented_text{#1}{#2}#3\stop_indented_text}
-\setupindentations
+\setupindentedtext
[\c!style=\v!normal,
\c!headstyle=\v!normal,
- \c!color=,
- \c!headcolor=,
+ %\c!color=,
+ %\c!headcolor=,
\c!width=\v!fit,
\c!text=\unknown,
- \c!sample=,
+ %\c!sample=,
\c!before=\blank,
\c!after=\blank,
\c!distance=1em,
diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua
index dec017d6b..14726b7aa 100644
--- a/tex/context/base/strc-doc.lua
+++ b/tex/context/base/strc-doc.lua
@@ -35,8 +35,8 @@ local lists = structures.lists
local counters = structures.counters
local sets = structures.sets
local tags = structures.tags
-local processors = structures.processors
+local processors = typesetters.processors
local applyprocessor = processors.apply
local startapplyprocessor = processors.startapply
local stopapplyprocessor = processors.stopapply
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index 939cb2736..b38642eee 100644
--- a/tex/context/base/strc-flt.mkvi
+++ b/tex/context/base/strc-flt.mkvi
@@ -17,6 +17,8 @@
\unprotect
+% Less globals!
+
%D This module is being converted into a mkvi one.
%D
%D - rename macros
@@ -204,7 +206,8 @@
\unexpanded\def\thecurrentfloatnumbersuffix
{\doifsomething{\floatcaptionparameter\c!suffix}
{\floatcaptionparameter\c!suffixseparator
- \floatcaptionparameter\c!suffix}}
+ \floatcaptionparameter\c!suffix
+ \floatcaptionparameter\c!suffixstopper}}
\unexpanded\def\thecurrentfloatnumber
{\ifnofloatcaption \else \ifnofloatnumber \else
@@ -268,10 +271,10 @@
\noindent
\gdef\lastcaptiontag{\strut\thecurrentfloatnumber}% was xdef ... needs checking
\begingroup
- \dosetfloatcaptionattributes\c!style\c!color
+ \usefloatcaptionstyleandcolor\c!style\c!color
\ifnofloatnumber
\else
- \hbox{\dosetfloatcaptionattributes\c!headstyle\c!headcolor\strut\thecurrentfloatnumber}%
+ \hbox{\usefloatcaptionstyleandcolor\c!headstyle\c!headcolor\strut\thecurrentfloatnumber}%
\ifnofloatcaption \else \ifemptyfloatcaption \else
\doifelsenothing{\floatcaptionparameter\c!spaceinbetween}
{\scratchskip\floatcaptionparameter\c!distance\relax
@@ -283,7 +286,7 @@
\global\float_caption_height\zeropoint
\global\float_caption_depth \zeropoint
\else
- \dosetfloatcaptionattributes\c!textstyle\c!textcolor
+ \usefloatcaptionstyleandcolor\c!textstyle\c!textcolor
\global\float_caption_height\strutheight
\global\float_caption_depth \strutdepth
\begstrut\thecurrentfloatcaption\endstrut\endgraf
@@ -322,7 +325,8 @@
% {\doprocesslocalsetups{\floatcaptionparameter\c!setups}\relax}
\def\check_float_caption_content
- {\ifnofloatcaption \else
+ {\ifnofloatcaption
+ \else
\setbox\float_caption_box\hbox
{\settrialtypesetting
\notesenabledfalse
@@ -394,6 +398,11 @@
\fi
\let\currentfloatcaption\currentfloat}
+\def\float_reset_variables
+ {\global\emptyfloatcaptionfalse
+ \global\nofloatcaptionfalse
+ \global\nofloatnumberfalse}
+
% place
\unexpanded\def\float_place#tag%
@@ -404,7 +413,8 @@
\dodoubleempty\float_place_indeed}
\def\float_place_indeed[#location][#reference]#caption%
- {\edef\floatlocation{#location}%
+ {\float_reset_variables
+ \edef\floatlocation{#location}%
\ifx\floatlocation\empty
\edef\floatlocation{\floatparameter\c!default}% beware of a clash between alignment locations
\fi
@@ -431,7 +441,8 @@
\dosingleempty\float_start_place_indeed}
\def\float_start_place_indeed[#settings]% tricky ... saved not ok yet
- {\edef\savedfloatlocation{\floatcaptionparameter\c!location}%
+ {\float_reset_variables
+ \edef\savedfloatlocation{\floatcaptionparameter\c!location}%
\setupcurrentfloatcaption[\c!location=,\c!reference=,\c!title=,\c!marking=,\c!list=,\c!bookmark=,#settings]%
\edef\floatlocation{\floatcaptionparameter\c!location}%
\setupcurrentfloatcaption[\c!location=\savedfloatlocation]%
@@ -637,7 +648,7 @@
{\global\nofloatcaptiontrue}
{\global\nofloatcaptionfalse}%
\doif{\floatcaptionparameter\c!number}\v!none % new
- {\global\nofloatcaptiontrue}%
+ {\global\nofloatcaptiontrue}%
\ifemptyfloatcaption \ifnofloatnumber
\global\nofloatcaptiontrue
\fi \fi}
@@ -1180,15 +1191,15 @@
\or % automatic
\ifnofloatcaption
\prepare_no_float_caption
- \doglobal\addlocalbackgroundtobox\floatbox
+ \page_backgrounds_add_local_to_box\floatbox % was \doglobal but not needed
\else
% todo: installable maken, variant/method=auto vs macro
\prepare_page_float_caption
- \addlocalbackgroundtobox\float_content_box
+ \page_backgrounds_add_local_to_box\float_content_box
\setbox\float_caption_box\hbox
{\floatcaptionparameter\c!command{\box\float_caption_box}}%
\moveboxontogrid\float_caption_box{\floatcaptionparameter\c!grid}\float_caption_height
- \addlocalbackgroundtobox\float_caption_box
+ \page_backgrounds_add_local_to_box\float_caption_box
\build_float_box
\fi
\or % semi automatic
@@ -1701,7 +1712,7 @@
\dontcomplain
%\showcomposition
\setbox\float_content_box\vbox{\borderedfloatbox}%
- \addlocalbackgroundtobox\float_content_box % no \doglobal
+ \page_backgrounds_add_local_to_box\float_content_box
\ifnofloatcaption
\global\setbox\floatbox\vbox{\box\float_content_box}%
\else
@@ -1709,7 +1720,7 @@
\prepare_side_float_caption
\setbox\float_caption_box\hbox{\floatcaptionparameter\c!command{\box\float_caption_box}}%
\moveboxontogrid\float_caption_box{\floatcaptionparameter\c!grid}\float_caption_height
- \addlocalbackgroundtobox\float_caption_box % no \doglobal
+ \page_backgrounds_add_local_to_box\float_caption_box
\build_side_float_box
\fi
\egroup}
@@ -1768,7 +1779,6 @@
\doifnotinset\v!margin\floatlocation % gaat namelijk nog fout
{\setbox\floatbox\vbox
{\parindent\zeropoint
- \doifconcepttracing{\inleftmargin{\framed{\infofont\the\totalnoffloats}}}%
\box\floatbox}}%
\wd\floatbox\floatwidth
\ifdim\dimexpr\floatheight+\lineheight\relax<\textheight \else
@@ -1780,9 +1790,9 @@
\fi}
\newcounter\noxfloatlocations
-
-\def\dooutput{\sidefloatoutput} % redefinition of \dooutput
-
+
+% \def\dooutput{\sidefloatoutput} % redefinition of \dooutput
+
\definefloat
[\v!figure]
[\v!figures]
diff --git a/tex/context/base/strc-ini.lua b/tex/context/base/strc-ini.lua
index fd25f7d45..923d35f6d 100644
--- a/tex/context/base/strc-ini.lua
+++ b/tex/context/base/strc-ini.lua
@@ -20,21 +20,21 @@ but it does not make sense to store all processdata.
]]--
-local format, concat, match = string.format, table.concat, string.match
+local format, concat = string.format, table.concat
local count = tex.count
-local type, next, tonumber, tostring = type, next, tonumber, tostring
-local lpegmatch, patterns, P, C, Cs = lpeg.match, lpeg.patterns, lpeg.P, lpeg.C, lpeg.Cs
+local type, next, tonumber = type, next, tonumber
local settings_to_array, settings_to_hash = utilities.parsers.settings_to_array, utilities.parsers.settings_to_hash
local allocate = utilities.storage.allocate
-local ctxcatcodes = tex.ctxcatcodes
-local xmlcatcodes = tex.xmlcatcodes
-local notcatcodes = tex.notcatcodes
-local txtcatcodes = tex.txtcatcodes
+local ctxcatcodes = tex.ctxcatcodes
+local xmlcatcodes = tex.xmlcatcodes
+local notcatcodes = tex.notcatcodes
+local txtcatcodes = tex.txtcatcodes
-local trace_processors = false trackers.register("structures.processors", function(v) trace_processors = v end)
+local trace_processors = false
+local report_processors = logs.reporter("processors","structure")
-local report_processors = logs.reporter("structure","processors")
+trackers.register("typesetters.processors", function(v) trace_processors = v end)
-- -- -- namespace -- -- --
@@ -51,7 +51,6 @@ structures.registers = structures.registers or { }
structures.references = structures.references or { }
structures.lists = structures.lists or { }
structures.helpers = structures.helpers or { }
-structures.processors = structures.processors or { }
structures.documents = structures.documents or { }
structures.notes = structures.notes or { }
structures.descriptions = structures.descriptions or { }
@@ -67,6 +66,8 @@ structures.synonyms = structures.synonyms or { }
--~ table.print(structures)
+local processors = typesetters.processors
+
-- -- -- specials -- -- --
-- we can store information and get back a reference; this permits
@@ -220,122 +221,6 @@ end
end
end
--- -- -- processors -- -- -- syntax: processor->data ... not ok yet
-
-local processors = structures.processors
-
-local registered = { }
-
-function processors.register(p)
- registered[p] = true
-end
-
-function processors.reset(p)
- registered[p] = nil
-end
-
---~ local splitter = lpeg.splitat("->",true) -- also support =>
-
-local becomes = P('->')
-local processor = (1-becomes)^1
-local splitter = C(processor) * becomes * Cs(patterns.argument + patterns.content)
-
-function processors.split(str)
- local p, s = lpegmatch(splitter,str)
- if registered[p] then
- return p, s
- else
- return false, str
- end
-end
-
---~ function processors.sprint(catcodes,str,fnc,...) -- not ok: mixed
---~ local p, s = lpegmatch(splitter,str)
---~ local code
---~ if registered[p] then
---~ code = format("\\applyprocessor{%s}{%s}",p,(fnc and fnc(s,...)) or s)
---~ else
---~ code = (fnc and fnc(str,...)) or str
---~ end
---~ if trace_processors then
---~ report_processors("cct: %s, seq: %s",catcodes,code)
---~ end
---~ context.sprint(catcodes,code) -- was: texsprint(catcodes,code)
---~ end
-
-function processors.apply(p,s)
- local str = p
- if s == nil then
- p, s = lpegmatch(splitter,p)
- end
- if p and registered[p] then
- if trace_processors then
- report_processors("known: %s, argument: %s",p,s or "")
- end
- context.applyprocessor(p,s)
- elseif s then
- if trace_processors then
- report_processors("unknown: %s, argument: %s",p or "?",s)
- end
- context(s)
- elseif str then
- if trace_processors then
- report_processors("direct: %s",str)
- end
- context(str)
- end
-end
-
-function processors.startapply(p,s)
- local str = p
- if s == nil then
- p, s = lpegmatch(splitter,p)
- end
- if p and registered[p] then
- if trace_processors then
- report_processors("start: %s",p or "?")
- end
- context.applyprocessor(p)
- context("{")
- return s
- elseif p then
- if trace_processors then
- report_processors("start: %s (unknown)",p)
- end
- context.firstofoneargument()
- context("{")
- return s
- else
- if trace_processors then
- report_processors("start: ? (unset)")
- end
- context.firstofoneargument()
- context("{")
- return str
- end
-end
-
-function processors.stopapply()
- context("}")
- if trace_processors then
- report_processors("stop")
- end
-end
-
-function processors.tostring(str)
- local p, s = lpegmatch(splitter,str)
- if registered[p] then
- return format("\\applyprocessor{%s}{%s}",p,s)
- else
- return str
- end
-end
-
-function processors.stripped(str)
- local p, s = lpegmatch(splitter,str)
- return s or str
-end
-
-- -- -- sets -- -- --
local sets = structures.sets
@@ -409,7 +294,4 @@ end
-- interface
-commands.definestructureset = sets.define
-
-commands.registerstructureprocessor = processors.register
-commands.resetstructureprocessor = processors.reset
+commands.definestructureset = sets.define
diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv
deleted file mode 100644
index c2ccfa493..000000000
--- a/tex/context/base/strc-itm.mkiv
+++ /dev/null
@@ -1,1451 +0,0 @@
-%D \module
-%D [ file=strc-itm,
-%D version=2008.10.20,
-%D title=\CONTEXT\ Structure Macros,
-%D subtitle=Itemgroups,
-%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.
-
-\writestatus{loading}{ConTeXt Structure Macros / Itemgroups}
-
-\registerctxluafile{strc-itm}{1.001}
-
-% this will be reimplemented: \startitem ... \stopitem will be the main macros and
-% \item will then call them
-
-\unprotect
-
-\newconditional\sublistitem \setfalse\sublistitem
-\newconditional\symbollistitem \setfalse\symbollistitem
-\newconditional\headlistitem \setfalse\headlistitem
-\newconditional\introlistitem \setfalse\introlistitem
-\newconditional\randomizeitems \setfalse\randomizeitems
-\newconditional\autointrolistitem \setfalse\autointrolistitem
-\newconditional\optimizelistitem \settrue \optimizelistitem
-\newconditional\packlistitem \setfalse\packlistitem
-\newconditional\paragraphlistitem \setfalse\paragraphlistitem
-\newconditional\textlistitem \setfalse\textlistitem
-\newconditional\firstlistitem \setfalse\firstlistitem
-\newconditional\beforelistitem \setfalse\beforelistitem
-\newconditional\afterlistitem \setfalse\afterlistitem
-\newconditional\nowhitelistitem \setfalse\nowhitelistitem
-\newconditional\joinedlistitem \setfalse\joinedwhitelistitem
-\newconditional\reverselistitem \setfalse\reverselistitem
-\newconditional\continuelistitems \setfalse\continuelistitems
-\newconditional\fittinglistitems \setfalse\fittinglistitems
-\newconditional\indentedfirstlistitem \setfalse\indentedfirstlistitem
-\newconditional\inlinelistitem \setfalse\inlinelistitem
-
-\newcount\noflists
-\newcount\currentnoflists
-\newcount\noflistelements
-\newcount\itemcolumndepth
-\newcount\itemdepth
-% \newcount\maxitemdepth \maxitemdepth=6
-
-\newdimen\itemgrouplistwidth
-\newdimen\itemgroupaskedwidth
-\newbox \itemgroupitembox
-
-\def\currentitemgroupcounter{itemgroup:\currentitemgroup}
-
-\let\currentitemlevel \!!zerocount
-\let\currentitemgroup \empty
-\let\currentnofitems \!!zerocount
-\def\currentitemnumber {\dorawsubstructurecounter[\currentitemgroupcounter][\currentitemlevel]}
-\let\currentrepeatstart \empty
-
-\def\dolistreference
- {\iftrialtypesetting \else % no need for different treatment of \continuelistitems
- \ctxcommand{registeritemgroup("\currentitemgroup",\number\noflistelements,"\getitemparameter\currentitemlevel\c!maxwidth")}%
- \fi}
-
-\def\checkcurrentnofitems % we could do this at the lua end and save a call (i.e. will be dimen and counter)
- {\edef\currentnofitems {\ctxcommand{nofitems("\currentitemgroup",\number\currentnoflists)}}%
- \edef\currentitemmaxwidth{\ctxcommand{maxitemwidth("\currentitemgroup",\number\currentnoflists)}\scaledpoint}}
-
-% todo: \dodosetreference -> \dostructurecountercomponent (to be checked)
-
-\def\dohandleitemreference % we will make a decent number helper
- {\ifx\currentitemreference \empty \else
-\iftrialtypesetting \else
- \setnextinternalreference
- \ctxlua {structures.references.setandgetattribute("\s!full", "\referenceprefix","\currentitemreference",
- {
- metadata = {
- kind = "item",% ?
- catcodes = \the\catcodetable,
- xmlroot = \ifx\currentreferencecoding\s!xml "\xmldocument" \else nil \fi, % only useful when text
- },
- references = {
- internal = \nextinternalreference,
- section = structures.sections.currentid(),
- },
- prefixdata = structures.helpers.simplify {
- prefix = "\structurecounterparameter\currentitemgroupcounter\c!prefix",
- separatorset = "\structurecounterparameter\currentitemgroupcounter\c!prefixseparatorset",
- conversion = \!!bs\structurecounterparameter\currentitemgroupcounter\c!prefixconversion\!!es,
- conversionset = "\structurecounterparameter\currentitemgroupcounter\c!prefixconversionset",
- set = "\structurecounterparameter\currentitemgroupcounter\c!prefixset",
- segments = "\structurecounterparameter\currentitemgroupcounter\c!prefixsegments",
- % segments = "\askedprefixsegments",
- connector = \!!bs\structurecounterparameter\currentitemgroupcounter\c!prefixconnector\!!es,
- },
- numberdata = structures.helpers.simplify {
- numbers = structures.counters.compact("\currentitemgroupcounter",nil,true),
- separatorset = "\structurecounterparameter\currentitemgroupcounter\c!numberseparatorset",
- conversion = "\structurecounterparameter\currentitemgroupcounter\c!numberconversion",
- conversionset = "\structurecounterparameter\currentitemgroupcounter\c!numberconversionset",
- % for the moment no stopper, we need to make references configurable first
- % stopper = \!!bs\structurecounterparameter\currentitemgroupcounter\c!numberstopper\!!es,
- segments = "\structurecounterparameter\currentitemgroupcounter\c!numbersegments",
- },
- })
- }%
- \xdef\currentitemattribute{\number\lastdestinationattribute}%
- \begingroup\attribute\destinationattribute\currentitemattribute\kern\zeropoint\endgroup % todo, apply attribute to symbol
-\fi
- \fi}
-
-% \startitemize[n,packed]
-% \item test \item test \item test
-% \stopitemize
-%
-% \startitemize[n,packed,reverse]
-% \item test \item test \item test
-% \stopitemize
-%
-% \startitemize[n,packed,reverse] \item test \item test \stopitemize
-% \startitemize[continue]
-% \item test \startitemize[n,packed] \item test \item test \stopitemize
-% \item test
-% \item test
-% \stopitemize
-% \startitemize[continue] \item test \stopitemize
-%
-% \startitemize[n,packed] \item test \item test \stopitemize
-% \startitemize[continue] \item test \stopitemize
-% \startitemize[continue] \item test \stopitemize
-
-\def\itemparameter #1#2{\csname\doitemparameter{\??op\currentitemgroup#1}#2\endcsname}
-\def\itemparameterhash#1#2{\doitemparameterhash {\??op\currentitemgroup#1}#2}
-
-
-\def\doitemparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\doitemparentparameter \csname#1\s!parent\endcsname#2\fi}
-\def\doitemparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\doitemparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-
-\def\doitemparentparameter #1#2{\ifx#1\relax\s!empty\else\doitemparameter #1#2\fi}
-\def\doitemparentparameterhash#1#2{\ifx#1\relax \else\doitemparameterhash#1#2\fi}
-
-\def\dosetitemattributes#1#2#3% style color
- {\edef\fontattributehash {\itemparameterhash#1#2}%
- \edef\colorattributehash{\itemparameterhash#1#3}%
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #2\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#3\fi}
-
-\def\setitemparameter #1#2{\@EA \def\csname\??op\currentitemgroup#1#2\endcsname} % #3 -> {#3}
-\def\esetitemparameter#1#2{\@EA\edef\csname\??op\currentitemgroup#1#2\endcsname} % #3 -> {#3}
-\def\xsetitemparameter#1#2{\@EA\xdef\csname\??op\currentitemgroup#1#2\endcsname} % #3 -> {#3}
-\def\letitemparameter #1#2{\@EA \let\csname\??op\currentitemgroup#1#2\endcsname}
-\let\getitemparameter \itemparameter
-
-\def\@@globalitemsymbol #1{\??op\currentitemgroup\c!symbol\s!global#1}
-\def\@@localitemsymbol #1{\??op\currentitemgroup\c!symbol\s!local #1}
-\def\@@currentitemsymbol#1{\??op\currentitemgroup\c!symbol #1}
-
-\def\@@itemcounter{\s!itemcount\currentitemgroup}
-
-% \def\doitembreak#1{\ifconditional\optimizelistitem\ifconditional\textlistitem\else\dosomebreak#1\fi\fi}
-%
-% \def\allowitembreak {\doitembreak\allowbreak}
-% \def\noitembreak {\doitembreak\nobreak}
-% \def\itembreakspecial {\doitembreak\itembreak}
-% \def\noitembreakspecial{\doitembreak\itemnobreak}
-%
-% \def\itembreak {\flushnotes\penalty-5\relax} % -10
-% \def\itemnobreak{\flushnotes\penalty+5\ifinsidecolumns\else00\fi\relax} % +5
-
-\definevspacing[\v!item @0] [penalty:0] % allow
-\definevspacing[\v!item @10000] [penalty:10000] % no
-\definevspacing[\v!item @-5] [penalty:-5]
-\definevspacing[\v!item @5] [penalty:5]
-\definevspacing[\v!item @500] [penalty:500]
-
-\def\doitembreak#1{\ifconditional\optimizelistitem\ifconditional\textlistitem\else#1\fi\fi}
-
-\def\allowitembreak {\doitembreak\itembreakallow}
-\def\noitembreak {\doitembreak\itembreakno}
-\def\itembreakspecial {\doitembreak\itembreak}
-\def\noitembreakspecial{\doitembreak\itemnobreak}
-
-\def\itembreakallow{\vspacing[\v!item @0]}
-\def\itembreakno {\vspacing[\v!item @10000]}
-\def\itembreak {\flushnotes\vspacing[\v!item @-5]}
-\def\itemnobreak {\flushnotes\ifinsidecolumns\vspacing[\v!item @5]\else\vspacing[\v!item @500]\fi}
-
-% cool but wrong:
-%
-% \def\initializeitemgrouplevel#1%
-% {\ifcsname\??op\currentitemgroup#1\s!parent\endcsname
-% % ok
-% \else\ifnum#1>\plusone
-% \setevalue{\??op\currentitemgroup#1\s!parent}{\??op\currentitemgroup\the\numexpr#1-1\relax}%
-% \else
-% \setevalue{\??op\currentitemgroup#1\s!parent}{\??op\currentitemgroup}%
-% \fi\fi}
-%
-% so we have:
-
-\def\initializeitemgrouplevel#1%
- {\ifcsname\??op\currentitemgroup\number#1\s!parent\endcsname
- % ok
- \else
- \setxvalue{\??op\currentitemgroup \c!levels}{\number#1}%
- \setxvalue{\??op\currentitemgroup\number#1\s!parent}{\??op\currentitemgroup}%
- \fi}
-
-\let\currentitemconversionset\empty
-\def\currentitemsymbol {n}
-
-\unexpanded\def\defineitemgroup
- {\dotripleempty\dodefineitemgroup}
-
-\def\dodefineitemgroup[#1][#2][#3]% todo: clone
- {\doifsomething{#1}
- {\pushmacro\currentitemgroup
- \def\currentitemgroup{#1}%
- \setuvalue{\e!start#1}{\startitemgroup[#1]}%
- \setuvalue{\e!stop#1}{\stopitemgroup}%
- \setuvalue{\e!setup#1\e!endsetup}{\setupitemgroup[#1]}% for old times sake
- \doifelsenothing{#2}
- {\getparameters[\??op#1][\s!parent=\??oo,#3]}%
- {\doifassignmentelse{#2}
- {\getparameters[\??op#1][\s!parent=\??oo,#2]}%
- {\getparameters[\??op#1][\s!parent=\??op#2,#3]}}%
- \dorecurse{\itemparameter\empty\c!levels}{\initializeitemgrouplevel\recurselevel}%
- \definestructurecounter[itemgroup:#1]%
- \definestructureconversionset[itemgroup:#1][\currentitemconversionset][\currentitemsymbol]%
- \popmacro\currentitemgroup}}
-
-\newtoks\everysetupitemgroup
-
-\unexpanded\def\setupitemgroups % [#1]
- {\dodoubleargument\getparameters[\??oo]} % [#1]
-
-\def\packitems
- {\ifcase\currentitemlevel \else \settrue\packlistitem \fi}
-
-\def\dosetupitemgroupvariable[#1]% [#2]% niveau instellingen
- {\doifelsenothing{#1}
- {\getparameters[\??op\currentitemgroup\currentitemlevel]}%
- {\getparameters[\??op\currentitemgroup#1]}}
-
-\def\dosetupitemgroupconstant#1%
- {\global\setitemparameter\currentitemlevel\c!maxwidth{0}%
- \processcommacommand[#1]\dodosetupitemgroupconstant} % expansion of #2 is handy for xml
-
-\def\dodosetupitemgroupconstant#1%
- {\edef\itemgroupconstantvalue{#1}%
- \ifx\itemgroupconstantvalue\empty\else
- \splitstring\itemgroupconstantvalue\at*\to\itemgroupfirst\and\itemgroupsecond
- \ifx\itemgroupsecond\empty
- \let\itemgroupsecond\itemgroupfirst
- \let\itemgroupfirst\!!plusone
- \fi
- \ifcsname\??op:::\itemgroupsecond\endcsname\csname\??op:::\itemgroupsecond\endcsname\fi
- \fi}
-
-\setvalue{\??op:::\v!packed }{\packitems}
-\setvalue{\??op:::\v!intro }{\settrue\introlistitem} % here? not set to false
-\setvalue{\??op:::\v!autointro}{\settrue\autointrolistitem}
-\setvalue{\??op:::\v!broad }{\ifx\itemgroupfirst\empty\def\itemgroupfirst{1}\fi
- \letitemparameter\currentitemlevel\c!factor\itemgroupfirst}
-\setvalue{\??op:::\v!text }{\settrue\textlistitem
- \settrue\inlinelistitem
- \settrue\joinedlistitem
- \packitems}
-\setvalue{\??op:::\v!columns }{\packitems}
-\setvalue{\??op:::\v!before }{\settrue\beforelistitem}
-\setvalue{\??op:::\v!after }{\settrue\afterlistitem}
-\setvalue{\??op:::\v!nowhite }{\settrue\nowhitelistitem}
-\setvalue{\??op:::\v!margin }{\setitemparameter\currentitemlevel\c!width{-2em}} % signal
-\setvalue{\??op:::\v!inmargin }{\setitemparameter\currentitemlevel\c!width{-2em}} % signal
-\setvalue{\??op:::\v!atmargin }{\doifnot\currentitemlevel{1}{\setitemparameter\currentitemlevel\c!width{0em}}} % signal
-\setvalue{\??op:::\v!intext }{\settrue\inlinelistitem}
-\setvalue{\??op:::\v!loose }{\setfalse\optimizelistitem}
-\setvalue{\??op:::\v!fit }{\settrue\fittinglistitems}
-\setvalue{\??op:::\v!nofit }{\setfalse\fittinglistitems}
-\setvalue{\??op:::\v!paragraph}{\settrue\paragraphlistitem
- \packitems}
-\setvalue{\??op:::\v!joinedup }{\settrue\joinedlistitem
- \packitems}
-\setvalue{\??op:::\v!serried }{\edef\itemgroupfirst{-\ifx\itemgroupfirst\empty1\else\itemgroupfirst\fi}%
- \letitemparameter\currentitemlevel\c!factor\itemgroupfirst}
-\setvalue{\??op:::\v!stopper }{\letitemparameter\currentitemlevel\c!placestopper\v!yes} % keep {}
-\setvalue{\??op:::\v!unpacked }{\setfalse\packlistitem}
-\setvalue{\??op:::\v!repeat }{\settrue\repeatlistitem}
-\setvalue{\??op:::\v!reverse }{\settrue\reverselistitem}
-\setvalue{\??op:::\v!standard }{\dosetupstandarditemgroup\currentitemlevel}
-
-\def\dosetupstandarditemgroup#1%
- {\getparameters
- [\??op\currentitemgroup#1]
- [\c!width=1.5em,\c!factor=0,\c!distance=.5em,\c!inner=,\c!factor=0,
- \c!beforehead=,\c!afterhead=\blank,\c!before=\blank,\c!inbetween=\blank,\c!after=\blank]}
-
-% \def\packeditemspacing{\empty}
-
-% \setupwhitespace[big]
-% \starttext
-% test \startitemize[joinedup] \item test \item test \stopitemize test \par
-% test \startitemize[joinedup,nowhite] \item test \item test \stopitemize test \par
-% test \startitemize[joinedup,nowhite,before] \item test \item test \stopitemize test \par
-% test \startitemize[joinedup,nowhite,after] \item test \item test \stopitemize test \par
-% \stoptext
-
-\ifdefined\dotagsetitemgroup \else \let\dotagsetitemgroup\relax \fi
-
-\def\itembeforecommand
- {\ifconditional\nowhitelistitem
- \ifconditional\beforelistitem
- \ifcase\currentitemlevel\or\getitemparameter\currentitemlevel\c!before\fi
- \else
- \nowhitespace
- \fi
- \else\ifconditional\joinedlistitem
- % \empty
- \else
- \getitemparameter\currentitemlevel\c!before
- \fi\fi
- \dostarttagged\t!itemgroup\currentitemgroup
- \dotagsetitemgroup}
-
-\def\itemaftercommand
- {\dostoptagged
- \ifconditional\nowhitelistitem
- \ifconditional\afterlistitem
- \ifcase\currentitemlevel\or\getitemparameter\currentitemlevel\c!after\fi
- \else
- \nowhitespace
- \fi
- \else\ifconditional\joinedlistitem
- % \empty
- \else
- \getitemparameter\currentitemlevel\c!after
- \fi\fi}
-
-\def\iteminbetweencommand
- {\ifconditional\nowhitelistitem
- \nowhitespace
- \else\ifconditional\joinedlistitem
- % \empty
- \else
- \getitemparameter\currentitemlevel\c!inbetween
- \fi\fi}
-
-\def\itembeforeheadcommand
- {\ifconditional\nowhitelistitem
- \nowhitespace
- \else\ifconditional\joinedlistitem
- % \empty
- \else
- \getitemparameter\currentitemlevel\c!beforehead
- \fi\fi}
-
-\def\itemafterheadcommand
- {\ifconditional\nowhitelistitem
- \nowhitespace
- \else\ifconditional\joinedlistitem
- % \empty
- \else
- \getitemparameter\currentitemlevel\c!afterhead
- \fi\fi}
-
-\unexpanded\def\dododododosetupitemgroup[#1][#2]% prevent expansion below
- {\doifassignmentelse{#2}%
- {\dosetupitemgroupvariable[#1][#2]}%
- {\setitemparameter{#1}\c!option{#2}}}%
-
-\def\dodododosetupitemgroup[#1][#2]%
- {\doifsomething{#2}
- {\doifelse{#1}\v!each
- {\dorecurse{\itemparameter\empty\c!levels}{\normalexpanded{\dododododosetupitemgroup[\recurselevel]}[#2]}}
- {\normalexpanded{\dododododosetupitemgroup[#1]}[#2]}}}
-
-\def\dododosetupitemgroup[#1][#2]%
- {\doifelsenothing{#2}
- {\doifsomething{#1}
- {\ifcase\currentitemlevel\relax
- \dodododosetupitemgroup[\v!each][#1]%
- \else
- \dodododosetupitemgroup[\currentitemlevel][#1]%
- \fi}}%
- {\doifelsenothing{#1}
- {\ifcase\currentitemlevel\relax
- \dodododosetupitemgroup[\v!each][#2]%
- \else
- \dodododosetupitemgroup[\currentitemlevel][#2]%
- \fi}
- {\dodododosetupitemgroup[#1][#2]}}}
-
-\def\dodosetupitemgroup[#1][#2][#3][#4]%
- {\pushmacro\currentitemgroup
- \def\currentitemgroup{#1}%
- \dododosetupitemgroup[#2][#3]%
- \doifsomething{#4}{\dododosetupitemgroup[#2][#4]}%
- \the\everysetupitemgroup
- \popmacro\currentitemgroup}
-
-\def\dosetupitemgroup[#1][#2][#3][#4]%
- {\def\docommand##1{\dodosetupitemgroup[##1][#2][#3][#4]}%
- \processcommalist[#1]\docommand}
-
-\unexpanded\def\setupitemgroup
- {\doquadrupleempty\dosetupitemgroup}
-
-\def\doadvanceitem
- {\ifconditional\sublistitem\else\ifconditional\symbollistitem\else
- \doincrementsubstructurecounter[\currentitemgroupcounter][\currentitemlevel]%
- \fi\fi}
-
-\def\setitemlevel#1%
- {\ifnum\currentitemlevel>\zerocount
- \settrue\firstlistitem
- \ifconditional\continuelistitems\else
- \dorestartsubstructurecounter[\currentitemgroupcounter][\currentitemlevel]{\the\numexpr\getitemparameter\currentitemlevel\c!start-1\relax}%
- \fi
- \fi}
-
-\unexpanded\def\actualitemnumber
- {\ifconditional\repeatlistitem
- \ifcase\currentitemlevel
- % skip
- \or
- \doactualitemnumber % this could become an option
- \else
- \doactualitemnumber
- \fi
- \else
- \doactualitemnumber
- \fi}
-
-\def\doactualitemnumber
- {\begingroup
- \setupstructurecounter
- [\currentitemgroupcounter]
- [%\c!prefix=\v!no,
- \c!prefix=\getitemparameter\currentitemlevel\c!prefix,
- \c!prefixstopper=\getitemparameter\currentitemlevel\c!prefixstopper,
- \c!prefixseparatorset=\getitemparameter\currentitemlevel\c!prefixseparatorset,
- \c!prefixconversion=\getitemparameter\currentitemlevel\c!prefixconversion,
- \c!prefixconversionset=\getitemparameter\currentitemlevel\c!prefixseparatorset,
- \c!prefixset=\getitemparameter\currentitemlevel\c!prefixset,
- \c!prefixsegments=\getitemparameter\currentitemlevel\c!prefixsegments,
- \c!prefixconnector=\getitemparameter\currentitemlevel\c!prefixconnector,
- \c!criterium=\getitemparameter\currentitemlevel\c!criterium,
- \c!numberorder=\ifconditional\reverselistitem\v!reverse\else\v!normal\fi,
- \c!numberstopper=\expdoif{\getitemparameter\currentitemlevel\c!placestopper}\v!yes{\getitemparameter\currentitemlevel\c!stopper},
- %\c!numberseparatorset=,
- \c!numberconversionset=itemgroup:\currentitemgroup,
- %\c!numberconversion=\currentitemsymbol,
- \c!numbersegments=\ifx\currentrepeatstart\empty\else\currentrepeatstart:\fi\number\currentitemlevel]%
- \convertedstructurecounter[\currentitemgroupcounter]% [\number\currentitemlevel]%
- \dohandleitemreference
- \endgroup}
-
-\def\unknownitemsymbol{?}
-
-\def\setitemmark#1% % en pas op: resets \docommand ; todo: conversionset
- {\doifsymboldefinedelse{#1}
- {\edef\currentitemsymbol{#1}%
- \setxvalue{\@@globalitemsymbol\currentitemlevel}{\currentitemsymbol}%
- \setgvalue{\@@localitemsymbol \currentitemlevel}{\unknownitemsymbol}%
- \def\listitem{\symbol[\currentitemsymbol]}%
- \let\@@opsymbol\empty}%
- {\doifconversiondefinedelse{#1}
- {\edef\currentitemsymbol{#1}%
- \setxvalue{\@@globalitemsymbol\currentitemlevel}{\currentitemsymbol}%
- \setgvalue{\@@localitemsymbol\currentitemlevel }{\actualitemnumber }%
- \def\listitem
- {\ifconditional\textlistitem
- % maybe block stopper here, but one can as well clone an
- % itemgroup then
- \getitemparameter\currentitemlevel\c!lefttext
- \getvalue{\@@localitemsymbol\currentitemlevel}%
- \getitemparameter\currentitemlevel\c!righttext
- \else
- \getitemparameter\currentitemlevel\c!left
- \getvalue{\@@localitemsymbol\currentitemlevel}%
- \getitemparameter\currentitemlevel\c!right
- \fi}%
- \let\@@opsymbol\empty}%
- {}}}
-
-% \def\calculatelistwidth#1% distance deals with 'broad'
-% {\itemgrouplistwidth\getitemparameter#1\c!distance\relax
-% \ifnum\getitemparameter#1\c!factor>\zerocount
-% \ifdim\itemgrouplistwidth=\zeropoint \itemgrouplistwidth=.5em\fi
-% \fi
-% \multiply\itemgrouplistwidth \getitemparameter#1\c!factor
-% \advance \itemgrouplistwidth \getitemparameter#1\c!width\relax}
-
-\def\calculatelistwidth#1%
- {\ifdim\currentitemmaxwidth>\zeropoint
- \itemgrouplistwidth\currentitemmaxwidth
- \else\ifnum\getitemparameter#1\c!factor>\zerocount
- \itemgrouplistwidth\getitemparameter#1\c!step\relax
- \ifdim\itemgrouplistwidth=\zeropoint \itemgrouplistwidth=.5em\fi
- \multiply\itemgrouplistwidth \getitemparameter#1\c!factor
- \advance\itemgrouplistwidth\getitemparameter#1\c!width\relax
- \else
- \itemgrouplistwidth\getitemparameter#1\c!width\relax
- \fi\fi
- \advance\itemgrouplistwidth\getitemparameter#1\c!distance\relax}
-
-% The next conditionals deal with \item \startitemgroup. It
-% looks like a hack to skip back, but that way we preserve
-% the indentation and bullet placement. It's a rather
-% untested feature.
-
-\newconditional\concatnextitem \setfalse\concatnextitem
-\newconditional\autoconcatnextitem \settrue \autoconcatnextitem
-\newsignal \itemsignal
-
-\unexpanded\def\startitemgroup
- {\dotripleempty\dostartitemgroup}
-
-\def\dostartitemgroup[#1][#2][#3]%
- {\bgroup
- \ifnum\currentitemlevel=\zerocount
- \def\currentitemgroup{#1}% no nested mixing of itemgroups
- \fi
- \ifthirdargument
- \dodostartitemgroup[#2][#3]%
- \else
- \doifassignmentelse{#2}
- {\dodostartitemgroup[][#2]}
- {\dodostartitemgroup[#2][]}%
- \fi}
-
-\def\dodostartitemgroup[#1]% [#2]%
- {\relax % prevents lookahead
- \global\advance\itemdepth\plusone
- \initializeitemgrouplevel\itemdepth
- \xdef\currentitemlevel{\number\itemdepth}%
- \edef\itemgroupoptions{\getitemparameter\currentitemlevel\c!option}%
- \ifx\itemgroupoptions\empty
- \edef\itemgroupoptions{#1}%
- \else
- \doifsomething{#1}{\edef\itemgroupoptions{\itemgroupoptions,#1}}%
- \fi
- \normalexpanded{\noexpand\redostartitemgroup[\itemgroupoptions]}}% [#2]
-
-\let\startcollectitems\relax
-\let\stopcollectitems \relax
-
-%D A nice example of a plugin:
-%D
-%D \startbuffer
-%D \startitemize[a,random,packed]
-%D \startitem first \stopitem \startitem second \stopitem
-%D \startitem third \stopitem \startitem fourth \stopitem
-%D \stopitemize
-%D
-%D \startitemize[a,random,packed]
-%D \startitem first \stopitem \startitem second \stopitem
-%D \startitem third \stopitem \startitem fourth \stopitem
-%D \stopitemize
-%D
-%D \startitemize[a,packed]
-%D \startitem first \stopitem \startitem second \stopitem
-%D \startitem third \stopitem \startitem fourth \stopitem
-%D \stopitemize
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-% better collectitems als conditional and a real plugin mechanism (some day)
-
-\@EA\long\@EA\def\@EA\collectitemgroupitem\@EA#\@EA1\csname\e!stop\v!item\endcsname
- {\increment\itemcollectcounter
- \long\setvalue{\v!item*\itemcollectcounter}{\startitemgroupitem#1\stopitemgroupitem}}
-
-\def\flushcollecteditems
- {\ifconditional\randomizeitems
- \getrandomnumber\itemcollectcounternow\plusone\itemcollectcounter
- \else
- \increment\itemcollectcounternow
- \fi
- \doifdefined{\v!item*\itemcollectcounternow}
- {\getvalue{\v!item*\itemcollectcounternow}%
- \letbeundefined{\v!item*\itemcollectcounternow}%
- \increment\itemcollectcounterdone}%
- \ifnum\itemcollectcounterdone<\itemcollectcounter\relax
- \expandafter\flushcollecteditems
- \fi}
-
-\unexpanded\def\stopcollectitems
- {\ifconditional\randomizeitems
- \newcounter\itemcollectcounterdone
- \ifnum\itemcollectcounter>\zerocount
- \@EAEAEA\flushcollecteditems
- \fi
- \fi}
-
-\unexpanded\def\startcollectitems
- {\ifconditional\randomizeitems
- \newcounter\itemcollectcounter
- \letvalue{\e!start\v!item}\collectitemgroupitem
- \fi}
-
-%D End of plugin.
-
-\ifx\startcolumns\undefined \unexpanded\def\startcolumns[#1]{} \fi
-\ifx\stopcolumns \undefined \let\stopcolumns\relax \fi
-
-\def\dosetsymalign#1% hm, we should use one of the core-spa macros or make a helper
- {\processaction
- [#1]
- [ \v!flushleft=>\let\symalignleft\relax,
- \v!right=>\let\symalignleft\relax,
- \v!flushright=>\let\symalignleft\hfill,
- \v!left=>\let\symalignleft\hfill,
- \v!middle=>\let\symalignleft\hfil,
- \v!center=>\let\symalignleft\hfil]}
-
-\let\currentitemindenting\empty
-
-\def\redostartitemgroup[#1][#2]%
- {\setfalse\inlinelistitem % new, no indent (leftskip)
- \setfalse\concatnextitem % new, concat
- \setfalse\txtlistitem
- \ifhmode
- \ifconditional\autoconcatnextitem % new, concat
- \ifdim\lastskip=\itemsignal % new, concat
- \settrue\concatnextitem % new, concat
- \fi % new, concat
- \fi % new, concat
- \ifconditional\textlistitem\else\doifnotinset\v!text{#1}\par\fi % suboptimal
- \fi
- \begingroup
- % new where, ok or not / we should integrate random, intro, continue here
- % beware, the following no longer inherit from the previous level, is this ok?
- \setfalse\reverselistitem
- \setfalse\introlistitem
- \setfalse\autointrolistitem
- \setfalse\beforelistitem
- \setfalse\afterlistitem
- \setfalse\nowhitelistitem
- \setfalse\randomizeitems
- %
- \doifinsetelse\v!intro {#1}{\settrue\introlistitem }{\setfalse\introlistitem }%
- \doifinsetelse\v!random {#1}{\settrue\randomizeitems }{\setfalse\randomizeitems }%
- \doifinsetelse\v!continue{#1}{\settrue\continuelistitems}{\setfalse\continuelistitems}%
- % == \doifinsetelse\v!intro{#1}\settrue\setfalse\introlistitem
-\iftrialtypesetting
- \savestructurecounter[\currentitemgroupcounter]%[\currentitemlevel]% todo: per level
-\fi
- \global\advance\noflists\plusone
- \currentnoflists\noflists
- \noflistelements\zerocount
- \setfalse\headlistitem
- \setfalse\sublistitem
- \setfalse\symbollistitem
- \let\marsymbol\relax
- \globallet\doitemdestination\empty
- \let\symsymbol\empty
- \let\symalignleft\relax
- \the\itemgroupcommands
- \checkcurrentnofitems
- % \getitemparameter\currentitemlevel\empty
- \let\listitem\empty % ** start value
- \doifelsenothing{#1} % iffirstargument
- {\edef\@@opsymbol{\noexpand\getitemparameter\currentitemlevel\noexpand\c!symbol}%
- \letgvalueempty{\@@globalitemsymbol\currentitemlevel}%
- \global\letitemparameter\currentitemlevel\v!continue\empty
- \dosetupitemgroupvariable[\currentitemlevel][#2]}
- {\dosetupitemgroupconstant{#1}%
- \dosetupitemgroupvariable[\currentitemlevel][#2]%
- \ifconditional\continuelistitems
- \edef\@@opsymbol{\executeifdefined{\@@globalitemsymbol\currentitemlevel}{\currentitemlevel}}%
- \getitemparameter\currentitemlevel\v!continue
- \else
- \edef\@@opsymbol{\noexpand\getitemparameter\currentitemlevel\noexpand\c!symbol}%
- \global\setitemparameter\currentitemlevel\v!continue
- {\dosetupitemgroupconstant{#1}%
- \dosetupitemgroupvariable[\currentitemlevel][#2]}%
- \fi
- \def\docommand##1% \setitemmark resets \docommand
- {\doifnot{##1}{0}{\setitemmark{##1}}}%
- % \processcommalist[#1,\@@opsymbol]\docommand
- \processcommalist[#1]\docommand}% ** preset sequence or provided sequence
- % moved to here, after settings
- \ifnum\currentitemlevel=\plusone % NIEUW
- \doadaptleftskip {\getitemparameter\currentitemlevel\c!margin}%
- \doadaptleftskip {\getitemparameter\currentitemlevel\c!leftmargin}%
- \doadaptrightskip{\getitemparameter\currentitemlevel\c!rightmargin}%
- \fi
- \dosetraggedcommand{\getitemparameter\currentitemlevel\c!align}\raggedcommand
- \dosetsymalign{\getitemparameter\currentitemlevel\c!symalign}%
- %\doifsomething{\getitemparameter\currentitemlevel\c!indenting}
- % {\normalexpanded{\noexpand\setupindenting[\v!reset,\v!yes,\getitemparameter\currentitemlevel\c!indenting]}}%
- % {\normalexpanded{\noexpand\setupindenting[\getitemparameter\currentitemlevel\c!indenting]}}%
- %
- \edef\currentitemindenting{\getitemparameter\currentitemlevel\c!indenting}%
- %
- \setitemlevel{#1}% moved to here
- \ifx\listitem\empty
- \setitemmark\@@opsymbol % ** default value
- \ifx\listitem\empty
- \edef\currentitemsymbol{\currentitemlevel}% ** fall back
- \fi
- \fi
- \ifconditional\autointrolistitem\ifnum\prevgraf<3
- \settrue\introlistitem
- \fi\fi
- \ifconditional\paragraphlistitem
- \ifnum\currentitemlevel>\plusone
- \letitemparameter\currentitemlevel\c!inbetween\empty
- \fi
- \fi
- \ifconditional\packlistitem
- \letitemparameter\currentitemlevel\c!inbetween\empty
- \fi
- \doifinset\v!columns{#1}%
- {\ifinsidecolumns\else\ifcase\itemcolumndepth
- \global\itemcolumndepth\currentitemlevel\relax
- \itembeforecommand
- \processfirstactioninset
- [#1]
- [ \v!one=>\setitemparameter\currentitemlevel\c!n{1},
- \v!two=>\setitemparameter\currentitemlevel\c!n{2},
- \v!three=>\setitemparameter\currentitemlevel\c!n{3},
- \v!four=>\setitemparameter\currentitemlevel\c!n{4},
- \v!five=>\setitemparameter\currentitemlevel\c!n{5},
- \s!unknown=>\@EA\!!counta\getitemparameter\currentitemlevel\c!n]%
- \startcolumns
- [\c!n=\getitemparameter\currentitemlevel\c!n,
- \c!height=,
- \c!rule=\v!off,
- \c!balance=\v!yes,
- \c!align=\v!no]%
- \fi\fi}%
- \ifconditional\fittinglistitems
- \ifdim\currentitemmaxwidth>\zeropoint
- \esetitemparameter\currentitemlevel\c!width{\currentitemmaxwidth}%
- \fi
- \fi
- \calculatelistwidth\currentitemlevel
- \ifdim\itemgrouplistwidth>\zeropoint\relax
- \ifconditional\inlinelistitem\else
- \advance\leftskip\itemgrouplistwidth\relax
- \fi
- \fi
- \ifx\currentrepeatstart\empty
- \let\currentitemconversionset\currentitemsymbol
- \else
- \edef\currentitemconversionset{\currentitemconversionset,\currentitemsymbol}%
- \fi
- \startcollectitems}
-
-% test / example
-%
-% \startnarrower[left] \startcolumns[n=3] \startitemize
-% \item \input ward \item \input ward \item \input ward
-% \stopitemize \stopcolumns\stopnarrower \blank
-%
-% \startnarrower[left] \startitemize[columns,three]
-% \item \input ward \item \input ward \item \input ward
-% \stopitemize \stopnarrower \blank
-%
-% \setupitemize[leftmargin=1.5em] \startitemize[columns,three]
-% \item \input ward \item \input ward \item \input ward
-% \stopitemize \blank
-
-\def\dorestoreitemgroup
- {\restorestructurecounter[\currentitemgroupcounter]% [\currentitemlevel]% todo: per level
- \global\advance\noflists\minusone
- \currentnoflists\noflists}
-
-\unexpanded\def\stopitemgroup
- {\stopcollectitems
- \ifconditional\textlistitem
- \removeunwantedspaces\space\ignorespaces
- \else
- \par
- \fi
- \dolistreference
- \ifconditional\firstlistitem
- \else
- \dostoptagged
- \dostoptagged
- \endgroup
- \fi % toegevoegd, eerste \som opent groep
- \ifnum\itemcolumndepth=\currentitemlevel\relax
- \stopcolumns
- \global\itemcolumndepth\zerocount
- \itemaftercommand
- \dontrechecknextindentation
- \else
- \ifnum\currentitemlevel=\plusone
- \allowitembreak
- \itemaftercommand
- \checknextindentation[\getitemparameter\currentitemlevel\c!indentnext]%
- \else
- % nieuw, not yet nobreak handling
- \ifcase\autoitemgroupspacing
- \itemaftercommand
- \or
- \itemaftercommand
- \fi
- \dontrechecknextindentation
- \fi
- \fi
- % new test, needed in sidefloats (surfaced in volker's proceedings)
-\iftrialtypesetting
- \dorestoreitemgroup
-\fi
- \ifconditional\textlistitem % else forgotten
- \endgroup
- \global\advance\itemdepth-\plusone
- \xdef\currentitemlevel{\number\itemdepth}%
- \egroup
- \else
- \endgroup
- \global\advance\itemdepth-\plusone
- \xdef\currentitemlevel{\number\itemdepth}%
- \egroup
- \par
- \fi
- \dorechecknextindentation}
-
-\newtoks\itemgroupcommands
-\newtoks\itemgroupfinalizer
-
-\def\itemgroupitem
- {\the\itemgroupfinalizer
- \doitemgroupitem}
-
-\def\itemgroupnoitem
- {\the\itemgroupfinalizer
- \doitemgroupnoitem}
-
-\def\itemgroupbutton[#1]%
- {\the\itemgroupfinalizer
- \gdef\doitemdestination{#1}%
- \itemgroupitem}
-
-\def\itemgroupdummy
- {\the\itemgroupfinalizer
- \itemgroupsymbol{\strut}\strut}
-
-\def\itemgroupsubitem
- {\the\itemgroupfinalizer
- \settrue\sublistitem
- \itemgroupitem}
-
-\def\itemgroupsymbol#1%
- {\the\itemgroupfinalizer
- \def\symsymbol{#1}%
- \settrue\symbollistitem
- \itemgroupitem}
-
-\def\itemgroupedge#1%
- {\the\itemgroupfinalizer
- \itemgroupsymbol
- {\calculatelistwidth\currentitemlevel
- \hbox to \itemgrouplistwidth
- {#1\hskip\getitemparameter\currentitemlevel\c!distance}}}
-
-\def\itemgrouphead
- {\the\itemgroupfinalizer
- \settrue\headlistitem\doitemgrouphead}
-
-\def\itemgroupitems
- {\the\itemgroupfinalizer
- \dosingleempty\doitemgroupitems}
-
-\def\doitemgroupitems[#1]%
- {\itemgroupedge
- {\dorecurse{0\getitemparameter\currentitemlevel\c!items}{\listitem\hss}%
- \unskip}}
-
-\def\itemgroupmargin#1%
- {\the\itemgroupfinalizer
- \def\marsymbol
- {\llap
- {\dosetitemattributes\currentitemlevel\c!marstyle\c!marcolor{#1}%
- \hskip\leftskip\hskip\leftmargindistance}}%
- \itemgroupitem}
-
-% beware, we don't group (yet) as we want to keep the left/right skip
-%
-% \startitemize
-% \startitem \stopitem
-% some intermediate text that will properly indent
-% \startitem \stopitem
-% \stopitem
-%
-% so we need to keep that property
-
-\appendtoks
- \let\item \itemgroupitem
- \let\noitem\itemgroupnoitem
- \let\itm \itemgroupitem
- \let\but \itemgroupbutton
- \let\nop \itemgroupdummy
-\to \itemgroupcommands
-
-\ifx\currentinterface \v!english \else
-
- \appendtoks
- \letvalue\v!item\itemgroupitem
- \letvalue\v!sub \itemgroupsubitem
- \letvalue\v!sym \itemgroupsymbol
- \letvalue\v!ran \itemgroupedge
- \letvalue\v!head\itemgrouphead
- \letvalue\v!its \itemgroupitems
- \letvalue\v!mar \itemgroupmargin
- \to \itemgroupcommands
-
-\fi
-
-\let\startitemgroupitem\itemgroupitem
-
-\def\stopitemgroupitem
- {\ifconditional\textlistitem
- % nothing
- \else
- \endgraf
- \fi}
-
-\def\startitemgroupitemhead#1%
- {\itemgrouphead#1\par}
-
-\def\stopitemgroupitemhead
- {\ifconditional\textlistitem
- % to be tested
- \else
- \endgraf
- \fi}
-
-\appendtoks
- \let\startitem\startitemgroupitem
- \let\stopitem \stopitemgroupitem
- \let\starthead\startitemgroupitemhead
- \let\stophead \stopitemgroupitemhead
-\to \itemgroupcommands
-
-\ifx\currentinterface \v!english \else
-
- \appendtoks % can be sped up by \csname if needed
- \letvalue{\e!start\v!item}\startitemgroupitem
- \letvalue{\e!stop \v!item}\stopitemgroupitem
- \letvalue{\e!start\v!head}\startitemgroupitemhead
- \letvalue{\e!stop \v!head}\stopitemgroupitemhead
- \to \itemgroupcommands
-
-\fi
-
-\appendtoks
- \let\startspecialitem\startspecialitemgroupitem
- \let\stopspecialitem \stopspecialitemgroupitem
-\to \itemgroupcommands
-
-\unexpanded\def\startspecialitemgroupitem[#1]%
- {\csname\??op:\e!start:\ifcsname#1\endcsname #1\else\v!item\fi\endcsname}
-
-\unexpanded\def\stopspecialitemgroupitem
- {\stopitemgroupitem}
-
-\letvalue{\??op:\e!start:\v!item}\itemgroupitem
-\letvalue{\??op:\e!start:\v!sub }\itemgroupsubitem
-\letvalue{\??op:\e!start:\v!sym }\itemgroupsymbol
-\letvalue{\??op:\e!start:\v!ran }\itemgroupedge
-\letvalue{\??op:\e!start:\v!its }\itemgroupitems
-\letvalue{\??op:\e!start:\v!mar }\itemgroupmargin
-
-% \startitemize
-% \starthead {xx} test \stophead
-% \startitem test \stopitem
-% \startitem test \stopitem
-% \stopitemize
-
-% Sometimes the user demands get pretty weird:
-%
-% \startitemize
-% \item test
-% \item test
-% \headsym{xx} test \par test
-% \stopitemize
-
-% aligned items
-%
-% \startitemize[n,fit,broad][itemalign=flushright]
-% \dorecurse{100}{\item The first item.}
-% \stopitemize
-%
-% \setupitemgroup[itemize][each][fit]
-% \setupitemgroup[itemize][each][distance=.5em,factor=1,itemalign=flushright]
-%
-% \startitemize[n]
-% \dorecurse{100}{\item The first item.}
-% \stopitemize
-
-\appendtoks \let\headsym \itemgroupheadsym \to \itemgroupcommands
-
-\def\itemgroupheadsym#1%
- {\def\symsymbol{#1}%
- \settrue\symbollistitem
- \settrue\headlistitem
- \doitemgrouphead}
-
-% \defineitemgroup[gbitemize]
-% \setupitemgroup[gbitemize][each][headstyle=bold]
-
-% \startgbitemize
-% \txt{italian} some italians like this kind of cross||breed between
-% an itemize and a description
-% \txt{sicilians} i wonder how many sicilian mathematicians do a thesis
-% on the math involved in predicting the next big bang of the vulcano
-% \stopgbitemize
-
-\appendtoks \letvalue\v!txt\itemgrouptext \to \itemgroupcommands
-
-\newconditional\txtlistitem \setfalse\txtlistitem
-
-\def\itemgrouptext#1%
- {\def\symsymbol{#1}%
- \settrue\symbollistitem
- \settrue\txtlistitem
- \itemgroupitem}
-
-\def\dodotxtitem
- {\scratchdimen\wd\itemgroupitembox
- \advance \scratchdimen \getitemparameter\currentitemlevel\c!distance\relax
- \ifdim\scratchdimen>\itemgrouplistwidth
- \advance\scratchdimen -\itemgrouplistwidth
- \else
- \scratchdimen\zeropoint
- \fi
- \llap{\hbox to \itemgrouplistwidth{\ifconditional\sublistitem\llap{+\enspace}\fi\box\itemgroupitembox\hss}}% was: \hfill
- \hskip\scratchdimen}
-
-\def\optimizelistitemsbreak
- {\ifcase\itemcolumndepth \ifconditional\optimizelistitem
- \ifcase \currentnofitems \else
- \ifnum\currentnofitems=\plusthree
- \ifnum\noflistelements>\plusone
- \noitembreakspecial
- \fi
- \else\ifnum\currentnofitems>\plusthree
- \ifnum\noflistelements=\plustwo
- \ifconditional\introlistitem
- \noitembreak
- \else
- \noitembreakspecial
- \fi
- \else\ifnum\currentnofitems=\noflistelements\relax
- \noitembreakspecial
- \else\ifnum\noflistelements>\plustwo
- \itembreakspecial
- \else
- \ifconditional\introlistitem\else\itembreakspecial\fi
- \fi\fi\fi
- \fi\fi
- \fi
- \fi\fi}
-
-\def\dodosubitem
- {\ifconditional\sublistitem\llap{+\enspace}\fi}
-
-\def\dodolapitem
- {\llap
- {\hbox to \itemgrouplistwidth
- {\dodosubitem
- \symalignleft
- \box\itemgroupitembox % can already have a forced widt, only factor handled here
- \hfil
- \hskip\getitemparameter\currentitemlevel\c!distance}}}
-
-\def\dolistitem % evt aantal items opslaan per niveau, scheelt zoeken
- {\ifconditional\textlistitem
- % begin of item
- \else
- \par
- \fi
- \advance\noflistelements\plusone
- \optimizelistitemsbreak
- \setfalse\indentedfirstlistitem
- \ifx\currentitemindenting\empty \else
- \normalexpanded{\noexpand\setupindenting[\v!reset,\v!yes,\currentitemindenting]}%
- \doifnot{\getitemparameter\currentitemlevel\c!alignsymbol}\v!yes
- {\ifindentfirstparagraph\settrue\indentedfirstlistitem\fi}%
- \fi
- \dontleavehmode
- \ifconditional\indentedfirstlistitem
- \hskip-\parindent
- \fi
- \setbox\itemgroupitembox\hbox
- {\ifconditional\headlistitem
- \ifconditional\symbollistitem
- \dosetitemattributes\currentitemlevel\c!symstyle\c!symcolor{\symsymbol}%
- \else
- \dosetitemattributes\currentitemlevel\c!headstyle\c!headcolor{\listitem}%
- \fi
- \else
- \ifconditional\symbollistitem
- \dosetitemattributes\currentitemlevel\c!symstyle\c!symcolor{\symsymbol}%
- \else
- \dosetitemattributes\currentitemlevel\c!style\c!color{\listitem}%
- \fi
- \fi}%
- \doifsomething\doitemdestination
- {\setbox\itemgroupitembox\hbox{\directgotobox{\box\itemgroupitembox}[\doitemdestination]}}%
- \itemgroupaskedwidth\getitemparameter\currentitemlevel\c!width\relax
- \ifconditional\fittinglistitems
- \ifdim\wd\itemgroupitembox>\getitemparameter\currentitemlevel\c!maxwidth sp\relax
- \xsetitemparameter\currentitemlevel\c!maxwidth{\number\wd\itemgroupitembox}%
- \fi
- \ifdim\currentitemmaxwidth>\zeropoint
- \setbox\itemgroupitembox\simplealignedbox
- {\dimexpr\currentitemmaxwidth+\getitemparameter\currentitemlevel\c!distance\relax}
- {\getitemparameter\currentitemlevel\c!itemalign}
- {\box\itemgroupitembox\hskip\getitemparameter\currentitemlevel\c!distance}%
- \fi
- \else\ifdim\itemgroupaskedwidth>\zeropoint
- \doifsomething{\getitemparameter\currentitemlevel\c!itemalign}
- {\setbox\itemgroupitembox\simplealignedbox
- {\dimexpr\itemgroupaskedwidth+\getitemparameter\currentitemlevel\c!distance\relax}
- {\getitemparameter\currentitemlevel\c!itemalign}
- {\box\itemgroupitembox\hskip\getitemparameter\currentitemlevel\c!distance}}%
- \fi\fi
- \globallet\doitemdestination\empty
- % new, prevents loops when symbol is (not yet found) graphic
- \ht\itemgroupitembox\strutheight
- \dp\itemgroupitembox\strutdepth
- % so that content differs per run (esp mp graphics afterwards)
- \checkforrepeatedlistitem
- \ifdim\itemgroupaskedwidth<\zeropoint\relax
- \llap{\ifconditional\sublistitem\llap{+\enspace}\fi\box\itemgroupitembox\hskip\leftmargindistance}%
- \else
- \ifdim\itemgroupaskedwidth=\zeropoint\relax
- \calculatelistwidth1%
- \else
- \calculatelistwidth\currentitemlevel
- \fi
- \ifconditional\textlistitem
- \hbox{\ifconditional\sublistitem+\enspace\fi\box\itemgroupitembox\hskip\interwordspace}\nobreak
- \else\ifconditional\inlinelistitem
- \hbox to \itemgrouplistwidth{\ifconditional\sublistitem\llap{+\enspace}\fi\box\itemgroupitembox\hss}% was: \hfill
- \else\ifconditional\txtlistitem
- \dodotxtitem
- \else
- \dodolapitem
- \fi\fi\fi
- \fi
- \setevalue{\@@currentitemsymbol\currentitemlevel}%
- {\getvalue{\@@localitemsymbol\currentitemlevel}}% still problems with \uchar ?
- %{\noexpand\getvalue{\@@localitemsymbol\currentitemlevel}}% no, spoils subrefs
- \setfalse\headlistitem
- \setfalse\sublistitem
- \setfalse\symbollistitem
- \EveryPar{\ignorespaces}% needed ?
- \ifconditional\indentedfirstlistitem
- \hskip\parindent
- \fi
- \ignorespaces}
-
-% For Wolfgang Schuster
-
-% \startitemize[n,repeat]
-% \noitem \startitemize[a] \item Item 1.a. \item Item 1.b. \stopitemize
-% \noitem \startitemize[a] \item Item 2.a. \item Item 2.b. \stopitemize
-% \stopitemize
-
-\def\donolistitem % reduced \dolistitem
- {\advance\noflistelements\plusone
- \setbox\itemgroupitembox\hbox
- {\dosetitemattributes\currentitemlevel\c!style\c!color{\listitem}}%
- \checkforrepeatedlistitem
- \ignorespaces}
-
-\def\doitemgroupnoitem
- {\let\currentitemreference\empty
- \doadvanceitem\donolistitem}
-
-% For Frank Grieshaber and Mojca Miklavec:
-
-\newconditional\repeatlistitem
-
-\def\checkforrepeatedlistitem
- {\ifconditional\repeatlistitem
- \ifx\currentrepeatstart\empty
- \let\currentrepeatstart\currentitemlevel
- \fi
- \setbox\itemgroupitembox\hbox to \wd\itemgroupitembox{\hskip-\itemgroupaskedwidth\box\itemgroupitembox}% what a hack !
- \fi}
-
-% \startbuffer
-% \item
-% \startitemize[n]
-% \item item 1.1
-% \item item 1.2
-% \startitemize[n] \item item 1.2.1 \item item 1.2.2 \stopitemize
-% \item item 1.3
-% \stopitemize
-% \item
-% \startitemize[n] \item item 2.1 \item item 2.2 \stopitemize
-% \item item 3
-% \startitemize[n] \item item 3.1 \item item 3.2 \stopitemize
-% \item
-% \startitemize[n] \item item 4.1 \item item 4.2 \stopitemize
-% \stopbuffer
-%
-% \startitemize[n,repeat,6*broad,packed] \getbuffer \stopitemize \blank[3*big]
-% \startitemize[n,repeat,packed] \getbuffer \stopitemize \blank[3*big]
-% \setupitemize[each][atmargin][width=3em]
-% \startitemize[n,repeat,packed] \getbuffer \stopitemize
-
-\setnewconstant\autoitemgroupspacing\plustwo % 0 = voor/na, 1=tussen als geen voor 2=(prev)tussen=old/normal
-
-% todo: assume startitem ... stopitem and do an autostopitem .. cleaner for
-% elements
-
-\def\complexdoitemgroupitem[#1]%
- {\def\currentitemreference{#1}%
- \ifconditional\textlistitem
- % begin of item
- \else
- \par
- \fi
- \ifconditional\concatnextitem % new, concat
- \noitembreak % new, concat
- \fi % new, concat
- \doadvanceitem
- \ifconditional\firstlistitem
- \setfalse\firstlistitem
- \begingroup
- \ifcase\currentitemlevel
- \or % 1
- \ifcase\itemcolumndepth
- \ifconditional\introlistitem\noitembreak\fi
- \itembeforecommand
- \ifconditional\introlistitem\noitembreak\fi
- \fi
- \else % 2 en hoger
- \ifconditional\paragraphlistitem \else
- \edef\previtemlevel{\the\numexpr\currentitemlevel-1}%
- \ifcase\autoitemgroupspacing\relax % nieuw
- \itembeforecommand
- \or
- \doifelsenothing\itembeforecommand\itembeforecommand{\getitemparameter\previtemlevel\c!inbetween}%
- \else
- \getitemparameter\previtemlevel\c!inbetween
- \fi
- \fi
- \fi
- \else
-\dostoptagged
-\dostoptagged
- \ifconditional\textlistitem % was bugged: \inlinelistitem
- \ifhmode
- % WS: make the distance between items customizable, think about better default values -> see itemize-1.tex
- \normalexpanded{\doassigntextitemdistance{\getitemparameter\currentitemlevel\c!textdistance}}% HH: moved out and made configurable (sort of)
- \removeunwantedspaces\hskip\textitemdistance\relax
- \fi
- \else
- \iteminbetweencommand
- \fi
- \fi
- \ifconditional\concatnextitem
- \vskip-\dimexpr\lastskip+\lineheight\relax
- \nobreak
- \fi
-\dostarttagged\t!item\empty
-\dostarttagged\t!itemtag\empty
- \dolistitem
-\dostoptagged
- \relax
- \ifconditional\packlistitem
- \setupwhitespace[\v!none]%
- \fi
- \getitemparameter\currentitemlevel\c!inner
- \marsymbol
- \let\marsymbol\relax
-\dostarttagged\t!itemcontent\empty
- \strut % added 11-08-99
- \setfalse\concatnextitem % new, concat
- \nobreak % else problems with intext items
- \hskip\itemsignal % new, concat
- \getitemparameter\currentitemlevel\c!command} % \defaultitemcommand
-
-% \startitemize[text][space=medium]
-% \item one \item two \item three
-% \stopitemize
-
-\setvalue{\??op:\??op:\c!textdistance:\v!none}%
- {\def\textitemdistance{\zeropoint}}
-
-\def\doassigngiventextitemdistance#1%
- {\assignvalue
- {#1}%
- \textitemdistance
- {.5\interwordspace\!!plus.5\emwidth}%
- {\interwordspace \!!plus \emwidth}%
- {\emwidth \!!plus \interwordstretch\!!minus\interwordshrink}}
-
-\unexpanded\def\doassigntextitemdistance#1%
- {\ifcsname\??op:\??op:\c!textdistance:#1\endcsname
- \csname\??op:\??op:\c!textdistance:#1\endcsname
- \else
- \doassigngiventextitemdistance{#1}%
- \fi}
-
-\def\defaultitemcommand
- {\EveryPar{\ignorespaces}% needed ?
- \ignorespaces}
-
-% For Giuseppe "Oblomov" Bilotta, inspired on a suggestion by Taco
-% Hoekwater.
-%
-% \def\MyItemCommand#1{{\bf#1}\quad}
-% \setupitemgroup[itemize][command=\MyItemCommand]
-%
-% \startitemize
-% \item {test} is this okay?
-% \item {test} is this okay?
-% \item {test} is this okay?
-% \stopitemize
-
-% \def\complexitem[#1]#2\par % todo: no two pass data
-% {\startitemgroup[#1]%
-% \complexdoitemgroupitem[]\begstrut#2\endstrut\par
-% \stopitemgroup}
-
-\def\complexitem[#1]#2\par
- {\doifsomethingelse{#1}{\startitemgroup[#1]}{\startitemgroup[\v!itemize]}%
- \startitem#2\stopitem
- \stopitemgroup}
-
-\setvalue{\e!start\v!item}%
- {\startitemgroup[\v!itemize]\startitem
- \setvalue{\e!stop \v!item}{\endgraf\stopitemgroup}} % inside, else overloaded
-
-\definecomplexorsimpleempty\item
-\definecomplexorsimpleempty\doitemgroupitem
-
-% the next solution accepts \head test \type{x{x}x} test ...
-
-\let\doenditemhead\relax
-
-\def\complexdoitemgrouphead[#1]% beter in \complexdosom hangen met een if
- {\ifconditional\firstlistitem\else\allowitembreak\fi
- \ifconditional\packlistitem\else\itembeforeheadcommand\fi
- \ifconditional\firstlistitem\ifconditional\introlistitem\else\ifcase\currentitemlevel % incr in \complexdosom
- \allowitembreak
- \fi\fi\fi
- \complexdoitemgroupitem[#1]%
- \bgroup
- \dosetitemattributes\currentitemlevel\c!headstyle\c!headcolor\empty
- \ignorespaces
- \itemgroupfinalizer{\enditemhead}%
- \let\par\enditemhead} % brrrr but simple anyway
-
-\def\enditemhead
- {\removeunwantedspaces
- \egroup
- \ifconditional\textlistitem
- \space\ignorespaces
- \else
- \par
- \fi
- \noitembreak
- \ifconditional\packlistitem\else\itemafterheadcommand\fi
- \noitembreak
- \noindentation}
-
-\definecomplexorsimpleempty\head
-\definecomplexorsimpleempty\doitemgrouphead
-
-\def\sym#1%
- {\noindent
- \begingroup
- \setbox\scratchbox\hbox{\settrialtypesetting#1}%
- \setbox\scratchbox\hbox
- \ifdim\wd\scratchbox<1em to 1.5\else spread 1\fi em{#1\hfil}%
- \normalexpanded{\box\scratchbox\endgroup\hangindent\the\wd\scratchbox}%
- \ignorespaces}
-
-\setupitemgroups
- [\c!margin=\zeropoint,
- \c!leftmargin=\zeropoint,
- \c!rightmargin=\zeropoint,
- \c!indentnext=\v!yes,
- \c!width=1.5em,
- \c!factor=0,
- \c!distance=.5em,
- %\c!align=\v!normal, % definitely not \v!normal, see mails and
- %\c!align=, % debug reports of David A & Patrick G on context list
- %\c!symalign=,
- %\c!color=,
- %\c!indenting=, % untouched if empty
- %\c!style=,
- \c!marstyle=\c!type, % \c! ???
- %\c!symstyle=,
- %\c!headstyle=,
- %\c!marcolor=,
- %\c!symcolor=,
- %\c!headcolor=,
- %\c!beforehead=,
- \c!afterhead=\blank,
- \c!before=\blank,
- \c!inbetween=\blank,
- \c!after=\blank,
- %\c!stopper=.,
- \c!placestopper=\v!yes,
- \c!stopper=.,
- %\c!inner=,
- \c!n=2,
- \c!items=4,
- \c!levels=10,
- \c!lefttext=(,
- \c!righttext=),
- \c!start=1,
- \c!criterium=\v!all, % permits 0 and negative numbers
- %\c!option=,
- \c!textdistance=\v!big,
- \c!command=\defaultitemcommand,
- \c!indenting=\v!next,
- %\c!alignsymbol=v!no,
- \c!symbol=\currentitemlevel]
-
-% new:
-
-\setupitemgroups
- [\c!step=.5em, % deals with broad
- \c!distance=\zeropoint]
-
-\setupitemgroups
- [\c!prefix=\v!no,
-% \c!prefixstopper=.,
-% \c!prefixseparatorset=,
-% \c!prefixconversion=,
-% \c!prefixconversionset=,
-% \c!prefixset=,
-% \c!prefixsegments=1:100,
- \c!prefixconnector=.,
- %
- \c!numberseparatorset=,
- \c!numberconversionset=,
- \c!numberstopper=.,
- \c!numbersegments=1]
-
-\defineitemgroup [\v!itemize]
-
-\protect \endinput
diff --git a/tex/context/base/strc-itm.mkvi b/tex/context/base/strc-itm.mkvi
new file mode 100644
index 000000000..b92fc031a
--- /dev/null
+++ b/tex/context/base/strc-itm.mkvi
@@ -0,0 +1,1514 @@
+%D \module
+%D [ file=strc-itm,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=Itemgroups,
+%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.
+
+\writestatus{loading}{ConTeXt Structure Macros / Itemgroups}
+
+\registerctxluafile{strc-itm}{1.001}
+
+% todo: check breaks
+% todo: check grouping
+
+% \startitemize[n,packed]
+% \item test \item test \item test
+% \stopitemize
+%
+% \startitemize[n,packed,reverse]
+% \item test \item test \item test
+% \stopitemize
+%
+% \startitemize[n,packed,reverse] \item test \item test \stopitemize
+% \startitemize[continue]
+% \item test \startitemize[n,packed] \item test \item test \stopitemize
+% \item test
+% \item test
+% \stopitemize
+% \startitemize[continue] \item test \stopitemize
+%
+% \startitemize[n,packed] \item test \item test \stopitemize
+% \startitemize[continue] \item test \stopitemize
+% \startitemize[continue] \item test \stopitemize
+%
+% \setupwhitespace[big]
+% \starttext
+% test \startitemize[joinedup] \item test \item test \stopitemize test \par
+% test \startitemize[joinedup,nowhite] \item test \item test \stopitemize test \par
+% test \startitemize[joinedup,nowhite,before] \item test \item test \stopitemize test \par
+% test \startitemize[joinedup,nowhite,after] \item test \item test \stopitemize test \par
+% \stoptext
+%
+% test / example
+%
+% \startnarrower[left] \startcolumns[n=3] \startitemize
+% \item \input ward \item \input ward \item \input ward
+% \stopitemize \stopcolumns\stopnarrower \blank
+%
+% \startnarrower[left] \startitemize[columns,three]
+% \item \input ward \item \input ward \item \input ward
+% \stopitemize \stopnarrower \blank
+%
+% \setupitemize[leftmargin=1.5em] \startitemize[columns,three]
+% \item \input ward \item \input ward \item \input ward
+% \stopitemize \blank
+%
+% beware, we don't group (yet) as we want to keep the left/right skip
+%
+% \startitemize
+% \startitem \stopitem
+% some intermediate text that will properly indent
+% \startitem \stopitem
+% \stopitem
+%
+% so we need to keep that property
+%
+% \startitemize
+% \starthead {xx} test \stophead
+% \startitem test \stopitem
+% \startitem test \stopitem
+% \stopitemize
+%
+% Sometimes the user demands get pretty weird:
+%
+% \startitemize
+% \item test
+% \item test
+% \headsym{xx} test \par test
+% \stopitemize
+%
+% aligned items
+%
+% \startitemize[n,fit,broad][itemalign=flushright]
+% \dorecurse{100}{\item The first item.}
+% \stopitemize
+%
+% \setupitemgroup[itemize][each][fit]
+% \setupitemgroup[itemize][each][distance=.5em,factor=1,itemalign=flushright]
+%
+% \startitemize[n]
+% \dorecurse{100}{\item The first item.}
+% \stopitemize
+%
+% \defineitemgroup[gbitemize]
+% \setupitemgroup[gbitemize][each][headstyle=bold]
+%
+% \startgbitemize
+% \txt{italian} some italians like this kind of cross||breed between
+% an itemize and a description
+% \txt{sicilians} i wonder how many sicilian mathematicians do a thesis
+% on the math involved in predicting the next big bang of the vulcano
+% \stopgbitemize
+%
+% \startitemize[n,repeat]
+% \noitem \startitemize[a] \item Item 1.a. \item Item 1.b. \stopitemize
+% \noitem \startitemize[a] \item Item 2.a. \item Item 2.b. \stopitemize
+% \stopitemize
+%
+% \startbuffer
+% \item
+% \startitemize[n]
+% \item item 1.1
+% \item item 1.2
+% \startitemize[n] \item item 1.2.1 \item item 1.2.2 \stopitemize
+% \item item 1.3
+% \stopitemize
+% \item
+% \startitemize[n] \item item 2.1 \item item 2.2 \stopitemize
+% \item item 3
+% \startitemize[n] \item item 3.1 \item item 3.2 \stopitemize
+% \item
+% \startitemize[n] \item item 4.1 \item item 4.2 \stopitemize
+% \stopbuffer
+%
+% \startitemize[n,repeat,6*broad,packed] \getbuffer \stopitemize \blank[3*big]
+% \startitemize[n,repeat,packed] \getbuffer \stopitemize \blank[3*big]
+% \setupitemize[each][atmargin][width=3em]
+% \startitemize[n,repeat,packed] \getbuffer \stopitemize
+%
+% todo: assume startitem ... stopitem and do an autostopitem .. cleaner for
+% elements
+%
+% \startitemize[text][space=medium]
+% \item one \item two \item three
+% \stopitemize
+%
+% For Giuseppe "Oblomov" Bilotta, inspired on a suggestion by Taco
+% Hoekwater.
+%
+% \def\MyItemCommand#1{{\bf#1}\quad}
+% \setupitemgroup[itemize][command=\MyItemCommand]
+%
+% \startitemize
+% \item {test} is this okay?
+% \item {test} is this okay?
+% \item {test} is this okay?
+% \stopitemize
+
+\unprotect
+
+\newconditional\c_itemgroups_sub
+\newconditional\c_itemgroups_head
+\newconditional\c_itemgroups_intro
+\newconditional\c_itemgroups_randomize
+\newconditional\c_itemgroups_auto_intro
+\newconditional\c_itemgroups_pack
+\newconditional\c_itemgroups_paragraph
+\newconditional\c_itemgroups_text
+\newconditional\c_itemgroups_text_saved
+\newconditional\c_itemgroups_first
+\newconditional\c_itemgroups_before
+\newconditional\c_itemgroups_after
+\newconditional\c_itemgroups_nowhite
+\newconditional\c_itemgroups_joined
+\newconditional\c_itemgroups_reverse
+\newconditional\c_itemgroups_continue
+\newconditional\c_itemgroups_fitting
+\newconditional\c_itemgroups_indented_first
+\newconditional\c_itemgroups_inline
+\newconditional\c_itemgroups_columns
+\newconditional\c_itemgroups_concat
+\newconditional\c_itemgroups_txt
+\newconditional\c_itemgroups_repeat
+
+% 0 = before/after
+% 1 = between unless before
+% 2 = between
+
+\newconstant \c_itemgroups_spacing_mode \c_itemgroups_spacing_mode\plustwo
+\newconditional\c_itemgroups_optimize \settrue\c_itemgroups_optimize
+\newconditional\c_itemgroups_auto_concat \settrue\c_itemgroups_auto_concat
+
+\newsignal \d_itemgroups_signal
+
+\newbox \b_itemgroups
+
+\newdimen \d_itemgroups_list_width
+\newdimen \d_itemgroups_asked_width
+
+\newdimen \d_itemgroups_max_width % multipass
+\newcount \c_itemgroups_max_items % multipass
+
+\newcount \c_itemgroups_n_of_lists
+\newcount \c_itemgroups_n_of_items
+\newcount \c_itemgroups_nesting
+\newcount \c_itemgroups_column_depth
+
+\def \v_itemgroups_counter {itemgroup:\currentparentitemgroup}
+
+\let \m_itemgroups_repeat_start \empty
+\let \m_itemgroups_conversion_set \empty
+\def \m_itemgroups_item_symbol {n}
+\def \v_itemgroups_unknown_symbol {?}
+
+\let \m_itemgroups_indenting \empty
+\let \m_itemgroups_destination \empty
+
+\let \currentitemlevel \!!zerocount % public
+\def \currentnofitems {\the\c_itemgroups_max_items}
+\def \currentitemnumber {\dorawsubstructurecounter[\v_itemgroups_counter][\currentitemlevel]} % public
+
+\newtoks \itemgroupcommands % maybe public
+
+\def\itemgroups_register_status
+ {\iftrialtypesetting \else
+ \ctxcommand{registeritemgroup("\currentitemgroup",\number\c_itemgroups_n_of_items,"\itemgroupparameter\c!maxwidth")}%
+ \fi}
+
+\def\itemgroups_check_n_of_items % we could do this at the lua end and save a call (i.e. will be dimen and counter)
+ {\c_itemgroups_max_items\ctxcommand{nofitems("\currentitemgroup",\number\c_itemgroups_n_of_lists)}\relax
+ \d_itemgroups_max_width\ctxcommand{maxitemwidth("\currentitemgroup",\number\c_itemgroups_n_of_lists)}\scaledpoint
+ \edef\currentnofitems{\the\c_itemgroups_max_items}}
+
+% todo: \dodosetreference -> \dostructurecountercomponent (to be checked)
+
+\def\itemgroups_insert_reference % we will make a decent number helper
+ {\iftrialtypesetting \else \ifx\currentitemreference \empty \else
+ \itemgroups_insert_reference_indeed
+ \fi \fi}
+
+\def\itemgroups_insert_reference_indeed
+ {\setnextinternalreference
+ \ctxlua {structures.references.setandgetattribute("\s!full", "\referenceprefix","\currentitemreference",
+ {
+ metadata = {
+ kind = "item",% ?
+ catcodes = \the\catcodetable,
+ xmlroot = \ifx\currentreferencecoding\s!xml "\xmldocument" \else nil \fi, % only useful when text
+ },
+ references = {
+ internal = \nextinternalreference,
+ section = structures.sections.currentid(),
+ },
+ prefixdata = structures.helpers.simplify {
+ prefix = "\structurecounterparameter\v_itemgroups_counter\c!prefix",
+ separatorset = "\structurecounterparameter\v_itemgroups_counter\c!prefixseparatorset",
+ conversion = \!!bs\structurecounterparameter\v_itemgroups_counter\c!prefixconversion\!!es,
+ conversionset = "\structurecounterparameter\v_itemgroups_counter\c!prefixconversionset",
+ set = "\structurecounterparameter\v_itemgroups_counter\c!prefixset",
+ segments = "\structurecounterparameter\v_itemgroups_counter\c!prefixsegments",
+ % segments = "\askedprefixsegments",
+ connector = \!!bs\structurecounterparameter\v_itemgroups_counter\c!prefixconnector\!!es,
+ },
+ numberdata = structures.helpers.simplify {
+ numbers = structures.counters.compact("\v_itemgroups_counter",nil,true),
+ separatorset = "\structurecounterparameter\v_itemgroups_counter\c!numberseparatorset",
+ conversion = "\structurecounterparameter\v_itemgroups_counter\c!numberconversion",
+ conversionset = "\structurecounterparameter\v_itemgroups_counter\c!numberconversionset",
+ % for the moment no stopper, we need to make references configurable first
+ % stopper = \!!bs\structurecounterparameter\v_itemgroups_counter\c!numberstopper\!!es,
+ segments = "\structurecounterparameter\v_itemgroups_counter\c!numbersegments",
+ },
+ })
+ }%
+ \xdef\currentitemattribute{\number\lastdestinationattribute}%
+ \begingroup
+ \attribute\destinationattribute\currentitemattribute
+ \kern\zeropoint % signal
+ \endgroup}
+
+%D Defining and setup:
+
+\installcommandhandler \??op {itemgroup} \??op
+
+\let\setupitemgroups\setupitemgroup
+
+\appendtoks
+ \setuevalue{\e!start\currentitemgroup}{\startitemgroup[\currentitemgroup]}%
+ \setuevalue{\e!stop \currentitemgroup}{\stopitemgroup}%
+ \setuevalue{\e!setup\currentitemgroup\e!endsetup}{\setupitemgroup[\currentitemgroup]}% obsolete
+% \let\currentparentitemgroup\currentitemgroup
+% \definestructurecounter[\v_itemgroups_counter]%
+% \definestructureconversionset[\v_itemgroups_counter][\m_itemgroups_conversion_set][\m_itemgroups_item_symbol]%
+\to \everydefineitemgroup
+
+%D Global states
+
+\def\itemgroups_store_continue_state#options#settings%
+ {\setxvalue{\??op:o:\currentitemgroup}{\itemgroups_process_options{#options}}%
+ \setgvalue{\??op:s:\currentitemgroup}{\setupcurrentitemgroup [#settings]}}
+
+\def\itemgroups_fetch_continue_state
+ {\getvalue{\??op:o:\currentitemgroup}%
+ \getvalue{\??op:s:\currentitemgroup}}
+
+\def\itemgroups_reset_continue_state
+ {\letgvalue{\??op:o:\currentitemgroup}\relax
+ \letgvalue{\??op:s:\currentitemgroup}\relax}
+
+\definevspacing[\v!item @0] [penalty:0] % allow
+\definevspacing[\v!item @10000] [penalty:10000] % no
+\definevspacing[\v!item @-5] [penalty:-5]
+\definevspacing[\v!item @5] [penalty:5]
+\definevspacing[\v!item @500] [penalty:500]
+
+\def\itemgroups_insert_break_when_needed#break%
+ {\ifconditional\c_itemgroups_optimize
+ \ifconditional\c_itemgroups_text \else
+ #break\relax
+ \fi
+ \fi}
+
+\def\itemgroups_insert_breakallow {\itemgroups_insert_break_when_needed\itemgroups_insert_breakallow_indeed}
+\def\itemgroups_insert_breakno {\itemgroups_insert_break_when_needed\itemgroups_insert_breakno_indeed }
+\def\itemgroups_insert_break {\itemgroups_insert_break_when_needed\itemgroups_insert_break_indeed }
+\def\itemgroups_insert_nobreak {\itemgroups_insert_break_when_needed\itemgroups_insert_nobreak_indeed }
+
+\def\itemgroups_insert_breakallow_indeed{\vspacing[\v!item @0]}
+\def\itemgroups_insert_breakno_indeed {\vspacing[\v!item @10000]}
+\def\itemgroups_insert_break_indeed {\flushnotes
+ \vspacing[\v!item @-5]}
+\def\itemgroups_insert_nobreak_indeed {\flushnotes
+ \ifinsidecolumns
+ \vspacing[\v!item @5]%
+ \else
+ \vspacing[\v!item @500]%
+ \fi}
+
+\unexpanded\def\itemgroups_process_options#options%
+ {\processcommacommand[#options]\itemgroups_process_option} % expansion of options is handy for xml
+
+\def\itemgroups_process_option#option%
+ {\edef\itemgroupconstantvalue{#option}%
+ \ifx\itemgroupconstantvalue\empty\else
+ \splitstring\itemgroupconstantvalue\at*\to\itemgroupfirst\and\itemgroupsecond
+ \ifx\itemgroupsecond\empty
+ \let\itemgroupsecond\itemgroupfirst
+ \let\itemgroupfirst\!!plusone
+ \fi
+ \ifcsname\??op:k:\itemgroupsecond\endcsname
+ \csname\??op:k:\itemgroupsecond\endcsname
+ \else
+ \itemgroups_set_symbol\itemgroupconstantvalue
+ \fi
+ \fi}
+
+\def\itemgroups_process_set_option_pack
+ {\ifcase\c_itemgroups_nesting \else
+ \settrue\c_itemgroups_pack
+ \fi}
+
+\setvalue{\??op:k:\!!zerocount}{} % ignore 0
+\setvalue{\??op:k:\v!packed }{\itemgroups_process_set_option_pack}
+\setvalue{\??op:k:\v!intro }{\settrue\c_itemgroups_intro} % here? not set to false
+\setvalue{\??op:k:\v!autointro}{\settrue\c_itemgroups_auto_intro}
+\setvalue{\??op:k:\v!broad }{\ifx\itemgroupfirst\empty
+ \let\itemgroupfirst\!!plusone
+ \fi
+ \letitemgroupparameter\c!factor\itemgroupfirst}
+\setvalue{\??op:k:\v!text }{\settrue\c_itemgroups_text
+ \settrue\c_itemgroups_inline
+ \settrue\c_itemgroups_joined
+ \itemgroups_process_set_option_pack}
+\setvalue{\??op:k:\v!columns }{\itemgroups_process_set_option_pack}
+\setvalue{\??op:k:\v!before }{\settrue\c_itemgroups_before}
+\setvalue{\??op:k:\v!after }{\settrue\c_itemgroups_after}
+\setvalue{\??op:k:\v!nowhite }{\settrue\c_itemgroups_nowhite}
+\setvalue{\??op:k:\v!margin }{\setitemgroupparameter\c!width{-2em}} % signal
+\setvalue{\??op:k:\v!inmargin }{\setitemgroupparameter\c!width{-2em}} % signal
+\setvalue{\??op:k:\v!atmargin }{\ifnum\c_itemgroups_nesting>\plusone
+ \setitemgroupparameter\c!width{0em}%
+ \fi} % signal
+\setvalue{\??op:k:\v!intext }{\settrue\c_itemgroups_inline}
+\setvalue{\??op:k:\v!loose }{\setfalse\c_itemgroups_optimize}
+\setvalue{\??op:k:\v!fit }{\settrue\c_itemgroups_fitting}
+\setvalue{\??op:k:\v!nofit }{\setfalse\c_itemgroups_fitting}
+\setvalue{\??op:k:\v!paragraph}{\settrue\c_itemgroups_paragraph
+ \itemgroups_process_set_option_pack}
+\setvalue{\??op:k:\v!joinedup }{\settrue\c_itemgroups_joined
+ \itemgroups_process_set_option_pack}
+\setvalue{\??op:k:\v!serried }{\edef\itemgroupfirst{-\ifx\itemgroupfirst\empty1\else\itemgroupfirst\fi}%
+ \letitemgroupparameter\c!factor\itemgroupfirst}
+\setvalue{\??op:k:\v!stopper }{\letitemgroupparameter\c!placestopper\v!yes} % keep {}
+\setvalue{\??op:k:\v!unpacked }{\setfalse\c_itemgroups_pack}
+\setvalue{\??op:k:\v!repeat }{\settrue\c_itemgroups_repeat}
+\setvalue{\??op:k:\v!reverse }{\settrue\c_itemgroups_reverse}
+\setvalue{\??op:k:\v!columns }{\settrue\c_itemgroups_columns}
+\setvalue{\??op:k:\v!one }{\letitemgroupparameter\c!n\plusone}
+\setvalue{\??op:k:\v!two }{\letitemgroupparameter\c!n\plustwo}
+\setvalue{\??op:k:\v!three }{\letitemgroupparameter\c!n\plusthree}
+\setvalue{\??op:k:\v!four }{\letitemgroupparameter\c!n\plusfour}
+\setvalue{\??op:k:\v!five }{\letitemgroupparameter\c!n\plusfive}
+\setvalue{\??op:k:\v!standard }{\setupcurrentitemgroup
+ [\c!width=1.5em,\c!factor=0,\c!distance=.5em,\c!inner=,\c!factor=0,%
+ \c!beforehead=,\c!afterhead=\blank,%
+ \c!before=\blank,\c!inbetween=\blank,\c!after=\blank]}
+
+\def\itemgroups_initialize_local
+ {\setfalse\c_itemgroups_inline
+ \setfalse\c_itemgroups_concat
+ \setfalse\c_itemgroups_txt
+ %
+ \setfalse\c_itemgroups_reverse
+ \setfalse\c_itemgroups_intro
+ \setfalse\c_itemgroups_auto_intro
+ \setfalse\c_itemgroups_before
+ \setfalse\c_itemgroups_after
+ \setfalse\c_itemgroups_nowhite
+ \setfalse\c_itemgroups_randomize
+ \setfalse\c_itemgroups_intro
+ \setfalse\c_itemgroups_continue
+ % this will be a constant
+ \setfalse\c_itemgroups_head
+ \setfalse\c_itemgroups_sub
+ \setfalse\c_itemgroups_columns
+ % to be checked
+ \let\m_itemgroups_destination\empty
+ \let\itemgroups_used_symbol\empty % ** start value
+ \let\itemgroups_margin_symbol\empty
+ \let\itemgroups_extra_symbol\empty
+ %
+ \global\letitemgroupparameter\c!maxwidth\!!zerocount
+ }
+
+\setvalue{\??op:1:\v!intro }{\settrue\c_itemgroups_intro }
+\setvalue{\??op:1:\v!random }{\settrue\c_itemgroups_randomize}
+\setvalue{\??op:1:\v!continue}{\settrue\c_itemgroups_continue }
+
+\def\itemgroups_preset_stage_one#options%
+ {\processcommacommand[#options]\itemgroups_preset_stage_one_indeed}
+
+\def\itemgroups_preset_stage_one_indeed#option%
+ {\ifcsname\??op:1:#option\endcsname
+ \csname\??op:1:#option\endcsname
+ \fi}
+
+\ifdefined\dotagsetitemgroup \else \let\dotagsetitemgroup\relax \fi
+
+\def\itemgroups_tag_start_group
+ {\dostarttagged\t!itemgroup\currentitemgroup
+ \dotagsetitemgroup}
+
+\def\itemgroups_tag_stop_group
+ {\dostoptagged}
+
+\def\itemgroups_before_command
+ {\ifconditional\c_itemgroups_nowhite
+ \ifconditional\c_itemgroups_before
+ \ifcase\c_itemgroups_nesting\or\itemgroupparameter\c!before\fi
+ \else
+ \nowhitespace
+ \fi
+ \else\ifconditional\c_itemgroups_joined
+ % \empty
+ \else
+ \itemgroupparameter\c!before
+ \fi\fi}
+
+\def\itemgroups_after_command
+ {\ifconditional\c_itemgroups_nowhite
+ \ifconditional\c_itemgroups_after
+ \ifcase\c_itemgroups_nesting\or\itemgroupparameter\c!after\fi
+ \else
+ \nowhitespace
+ \fi
+ \else\ifconditional\c_itemgroups_joined
+ % \empty
+ \else
+ \itemgroupparameter\c!after
+ \fi\fi}
+
+\def\itemgroups_between_command
+ {\ifconditional\c_itemgroups_nowhite
+ \nowhitespace
+ \else\ifconditional\c_itemgroups_joined
+ % \empty
+ \else
+ \itemgroupparameter\c!inbetween
+ \fi\fi}
+
+\def\itemgroups_before_head_command
+ {\ifconditional\c_itemgroups_nowhite
+ \nowhitespace
+ \else\ifconditional\c_itemgroups_joined
+ % \empty
+ \else
+ \itemgroupparameter\c!beforehead
+ \fi\fi}
+
+\def\itemgroups_after_head_command
+ {\ifconditional\c_itemgroups_nowhite
+ \nowhitespace
+ \else\ifconditional\c_itemgroups_joined
+ % \empty
+ \else
+ \itemgroupparameter\c!afterhead
+ \fi\fi}
+
+% compatible setup command:
+
+\let\normal_setup_itemgroup\setupitemgroup
+
+\unexpanded\def\setupitemgroup
+ {\doquadrupleempty\itemgroups_setup}
+
+\def\itemgroups_setup[#category][#levels][#options][#settings]% category level|each options|settings settings|options
+ {\edef\itemgroups_setup_what{#levels}%
+ \iffourthargument
+ \ifx\itemgroups_setup_what\v!each
+ \itemgroups_setup_each{#category}{#options}%
+ \itemgroups_setup_each{#category}{#settings}%
+ \else
+ \itemgroups_setup_list{#levels}{#category}{#options}%
+ \itemgroups_setup_list{#levels}{#category}{#settings}%
+ \fi
+ \else\ifthirdargument
+ \ifx\itemgroups_setup_what\v!each
+ \itemgroups_setup_each{#category}{#options}%
+ \else
+ \itemgroups_setup_list{#levels}{#category}{#options}%
+ \fi
+ \else\ifsecondargument
+ \itemgroups_setup_each{#category}{#levels}%
+ \else
+ \normal_setup_itemgroup[#category]% == settings
+ \fi\fi\fi}
+
+% can be made a bit faster
+
+\def\itemgroups_setup_each#category#whatever%
+ {\doifassignmentelse{#whatever}
+ {\normal_setup_itemgroup[#category][#whatever]}
+ {\normal_setup_itemgroup[#category][\c!option={#whatever}]}}
+
+\def\itemgroups_setup_list_level_a#category#whatever#level%
+ {\normal_setup_itemgroup[#category:#level][\c!option={#whatever}]}
+
+\def\itemgroups_setup_list_level_b#category#whatever#level%
+ {\normal_setup_itemgroup[#category:#level][#whatever]}
+
+\def\itemgroups_setup_list#subcategories#category#whatever%
+ {\doifassignmentelse{#whatever}
+ {\processcommalist[#subcategories]{\itemgroups_setup_list_level_a{#category}{#whatever}}}
+ {\processcommalist[#subcategories]{\itemgroups_setup_list_level_b{#category}{#whatever}}}}
+
+\def\itemgroups_increment_item_counter
+ {\ifconditional\c_itemgroups_sub \else \ifx\itemgroups_extra_symbol\empty
+ \doincrementsubstructurecounter[\v_itemgroups_counter][\currentitemlevel]%
+ \fi\fi}
+
+\unexpanded\def\itemgroups_insert_item_counter
+ {\ifconditional\c_itemgroups_repeat
+ \ifcase\c_itemgroups_nesting
+ % skip
+ \or
+ \itemgroups_insert_item_counter_indeed % this could become an option
+ \else
+ \itemgroups_insert_item_counter_indeed
+ \fi
+ \else
+ \itemgroups_insert_item_counter_indeed
+ \fi}
+
+\def\itemgroups_insert_item_counter_indeed
+ {\begingroup
+ \setupstructurecounter
+ [\v_itemgroups_counter]
+ [%\c!prefix=\v!no,
+ \c!prefix=\itemgroupparameter\c!prefix,
+ \c!prefixstopper=\itemgroupparameter\c!prefixstopper,
+ \c!prefixseparatorset=\itemgroupparameter\c!prefixseparatorset,
+ \c!prefixconversion=\itemgroupparameter\c!prefixconversion,
+ \c!prefixconversionset=\itemgroupparameter\c!prefixseparatorset,
+ \c!prefixset=\itemgroupparameter\c!prefixset,
+ \c!prefixsegments=\itemgroupparameter\c!prefixsegments,
+ \c!prefixconnector=\itemgroupparameter\c!prefixconnector,
+ \c!criterium=\itemgroupparameter\c!criterium,
+ \c!numberorder=\ifconditional\c_itemgroups_reverse\v!reverse\else\v!normal\fi,
+ \c!numberstopper=\expdoif{\itemgroupparameter\c!placestopper}\v!yes{\itemgroupparameter\c!stopper},
+ %\c!numberseparatorset=,
+ \c!numberconversionset=itemgroup:\currentparentitemgroup,
+ %\c!numberconversion=\m_itemgroups_item_symbol,
+ \c!numbersegments=\ifx\m_itemgroups_repeat_start\empty\else\m_itemgroups_repeat_start:\fi\currentitemlevel]%
+ \convertedstructurecounter[\v_itemgroups_counter]% [\number\currentitemlevel]%
+ \itemgroups_insert_reference
+ \endgroup}
+
+\def\itemgroups_set_symbol#symbol%
+ {\edef\itemgroups_tmp_symbol{#symbol}%
+ \ifx\itemgroups_tmp_symbol\empty \else
+ \doifsymboldefinedelse\itemgroups_tmp_symbol
+ \itemgroups_set_symbol_symbol
+ {\doifconversiondefinedelse\itemgroups_tmp_symbol
+ \itemgroups_set_symbol_conversion
+ \donothing}%
+ \fi}
+
+\def\itemgroups_set_symbol_symbol
+ {\let\m_itemgroups_item_symbol\itemgroups_tmp_symbol
+ \itemgroups_store_global_symbol\m_itemgroups_item_symbol
+ \itemgroups_store_local_symbol\v_itemgroups_unknown_symbol
+ \let\itemgroups_used_symbol\itemgroups_set_symbol_symbol_item
+ \let\itemgroups_asked_symbol\empty}
+
+\def\itemgroups_set_symbol_conversion
+ {\let\m_itemgroups_item_symbol\itemgroups_tmp_symbol
+ \itemgroups_store_global_symbol\m_itemgroups_item_symbol
+ \itemgroups_store_local_symbol\itemgroups_insert_item_counter
+ \let\itemgroups_used_symbol\itemgroups_set_symbol_conversion_item
+ \let\itemgroups_asked_symbol\empty}
+
+\def\itemgroups_set_symbol_symbol_item
+ {\symbol[\m_itemgroups_item_symbol]}
+
+\def\itemgroups_set_symbol_conversion_item
+ {\ifconditional\c_itemgroups_text
+ % maybe block stopper here, but one can as well clone an itemgroup then
+ \itemgroupparameter\c!lefttext
+ \itemgroups_fetch_local_symbol
+ \itemgroupparameter\c!righttext
+ \else
+ \itemgroupparameter\c!left
+ \itemgroups_fetch_local_symbol
+ \itemgroupparameter\c!right
+ \fi}
+
+\def\itemgroups_calculate_list_width#level%
+ {\let\savedcurrentitemgroup\currentitemgroup
+ \edef\currentitemgroup{\currentparentitemgroup:\number#level}%
+ \ifdim\d_itemgroups_max_width>\zeropoint
+ \d_itemgroups_list_width\d_itemgroups_max_width
+ \else\ifnum\itemgroupparameter\c!factor>\zerocount
+ \d_itemgroups_list_width\itemgroupparameter\c!step\relax
+ \ifdim\d_itemgroups_list_width=\zeropoint \d_itemgroups_list_width=.5em\fi
+ \multiply\d_itemgroups_list_width \itemgroupparameter\c!factor
+ \advance\d_itemgroups_list_width\itemgroupparameter\c!width\relax
+ \else
+ \d_itemgroups_list_width\itemgroupparameter\c!width\relax
+ \fi\fi
+ \advance\d_itemgroups_list_width\itemgroupparameter\c!distance\relax
+ \let\currentitemgroup\savedcurrentitemgroup}
+
+\unexpanded\def\startitemgroup
+ {\dotripleempty\itemgroups_start}
+
+\def\itemgroups_start[#category][#options][#settings]%
+ {\begingroup % (1)
+ \def\currentitemgroup{#category}% no nested mixing of itemgroups
+ \let\currentparentitemgroup\currentitemgroup
+ \global\advance\c_itemgroups_nesting\plusone
+ \def\currentitemlevel{\number\c_itemgroups_nesting}%
+ \normalexpanded{\chaintocurrentitemgroup{\currentparentitemgroup:\currentitemlevel}}%
+ \edef\currentitemgroup{\currentparentitemgroup:\currentitemlevel}%
+ %
+ \ifthirdargument
+ \itemgroups_start_indeed[#options][#settings]%
+ \else\ifsecondargument
+ \doifassignmentelse{#options}
+ {\itemgroups_start_indeed[][#options]}
+ {\itemgroups_start_indeed[#options][]}%
+ \else
+ \itemgroups_start_indeed[][]%
+ \fi\fi}
+
+\def\itemgroups_start_indeed[#options][#settings]%
+ {\edef\itemgroupoptions{\itemgroupparameter\c!option}%
+ \edef\itemgroupextraoptions{#options}%
+ \ifx\itemgroupoptions\empty
+ \let\itemgroupoptions\itemgroupextraoptions
+ \else\ifx\itemgroupextraoptions\empty
+ % ok
+ \else
+ \edef\itemgroupoptions{\itemgroupoptions,\itemgroupextraoptions}%
+ \fi\fi
+ \redostartitemgroup{#settings}}
+
+\let\startcollectitems\relax
+\let\stopcollectitems \relax
+
+\ifdefined\startcolumns \else \unexpanded\def\startcolumns[#settings]{} \fi
+\ifdefined\stopcolumns \else \unexpanded\def\stopcolumns {} \fi
+
+\letvalue{\??op:a:\v!flushleft }\relax
+\letvalue{\??op:a:\v!right }\relax
+\letvalue{\??op:a:\v!flushright}\hfill
+\letvalue{\??op:a:\v!left }\hfill
+\letvalue{\??op:a:\v!middle }\hfil
+\letvalue{\??op:a:\v!center }\hfil
+
+\def\itemgroups_left_sym_filler
+ {\csname\??op:a:\itemgroupparameter\c!symalign\endcsname}
+
+% symbols + states
+
+\def\itemgroups_store_global_symbol#symbol%
+ {\letgvalue{\??op:g:\currentitemlevel}#symbol}
+
+\def\itemgroups_store_local_symbol#symbol%
+ {\letgvalue{\??op:l:\currentitemlevel}#symbol}
+
+\def\itemgroups_fetch_global_symbol
+ {\getvalue{\??op:g:\currentitemlevel}}
+
+\def\itemgroups_fetch_local_symbol
+ {\getvalue{\??op:l:\currentitemlevel}}
+
+\def\itemgroups_setup_symbol_default
+ {\edef\itemgroups_asked_symbol{\itemgroupparameter\c!symbol}%
+ \itemgroups_store_global_symbol\empty}
+
+\def\itemgroups_setup_symbol_continue
+ {\ifcsname\??op:g:\currentitemlevel\endcsname
+ \let\itemgroups_asked_symbol\itemgroups_fetch_global_symbol
+ \else
+ \let\itemgroups_asked_symbol\currentitemlevel
+ \fi}
+
+\def\itemgroups_setup_symbol_asked
+ {\edef\itemgroups_asked_symbol{\itemgroupparameter\c!symbol}}
+
+\unexpanded\def\redostartitemgroup#settings% k/v
+ {\begingroup % (2)
+ \the\itemgroupcommands
+ \let\c_itemgroups_text_saved\c_itemgroups_text
+ \itemgroups_initialize_local
+ \itemgroups_preset_stage_one\itemgroupoptions
+ \ifhmode
+ \ifconditional\c_itemgroups_auto_concat
+ \ifdim\lastskip=\d_itemgroups_signal
+ \settrue\c_itemgroups_concat
+ \fi
+ \fi
+ \ifconditional\c_itemgroups_text_saved \else
+ \ifconditional\c_itemgroups_text \else
+ \par
+ \fi
+ \fi
+ \fi
+ \iftrialtypesetting
+ \savestructurecounter[\v_itemgroups_counter]%
+ \fi
+ \global\advance\c_itemgroups_n_of_lists\plusone
+ \c_itemgroups_n_of_items\zerocount
+ \itemgroups_check_n_of_items
+ \ifx\itemgroupoptions\empty
+ \itemgroups_setup_symbol_default
+ \itemgroups_reset_continue_state
+ \setupcurrentitemgroup[#settings]%
+ \else
+ \itemgroups_process_options\itemgroupoptions
+ \setupcurrentitemgroup[#settings]%
+ \ifconditional\c_itemgroups_continue
+ \itemgroups_setup_symbol_continue
+ \itemgroups_fetch_continue_state
+ \else
+ \itemgroups_setup_symbol_asked
+ \itemgroups_store_continue_state\itemgroupoptions{#settings}%
+ \fi
+ \fi
+ \ifnum\c_itemgroups_nesting=\plusone % NIEUW
+ \doadaptleftskip {\itemgroupparameter\c!margin}%
+ \doadaptleftskip {\itemgroupparameter\c!leftmargin}%
+ \doadaptrightskip{\itemgroupparameter\c!rightmargin}%
+ \fi
+ \dosetraggedcommand{\itemgroupparameter\c!align}\raggedcommand
+ \edef\m_itemgroups_indenting{\itemgroupparameter\c!indenting}%
+ \ifnum\c_itemgroups_nesting>\zerocount
+ \settrue\c_itemgroups_first
+ \ifconditional\c_itemgroups_continue \else
+ \dorestartsubstructurecounter
+ [\v_itemgroups_counter]%
+ [\currentitemlevel]%
+ {\the\numexpr\itemgroupparameter\c!start-\plusone\relax}%
+ \fi
+ \fi
+ \ifx\itemgroups_used_symbol\empty
+ \itemgroups_set_symbol\itemgroups_asked_symbol % ** default value
+ \ifx\itemgroups_used_symbol\empty
+ \let\m_itemgroups_item_symbol\currentitemlevel % ** fall back
+ \fi
+ \fi
+ \ifconditional\c_itemgroups_auto_intro\ifnum\prevgraf<\plusthree
+ \settrue\c_itemgroups_intro
+ \fi\fi
+ \ifconditional\c_itemgroups_paragraph
+ \ifnum\c_itemgroups_nesting>\plusone
+ \letitemgroupparameter\c!inbetween\empty
+ \fi
+ \fi
+ \ifconditional\c_itemgroups_pack
+ \letitemgroupparameter\c!inbetween\empty
+ \fi
+ \ifconditional\c_itemgroups_columns
+ \ifinsidecolumns\else\ifcase\c_itemgroups_column_depth
+ \global\c_itemgroups_column_depth\c_itemgroups_nesting % global ?
+ \itemgroups_before_command
+ \itemgroups_tag_start_group
+ \itemgroups_start_columns
+ \fi\fi
+ \fi
+ \ifconditional\c_itemgroups_fitting
+ \ifdim\d_itemgroups_max_width>\zeropoint
+ \letitemgroupparameter\c!width\d_itemgroups_max_width
+ \fi
+ \fi
+ \itemgroups_calculate_list_width\c_itemgroups_nesting
+ \ifdim\d_itemgroups_list_width>\zeropoint\relax
+ \ifconditional\c_itemgroups_inline\else
+ \advance\leftskip\d_itemgroups_list_width\relax
+ \fi
+ \fi
+ \ifx\m_itemgroups_repeat_start\empty
+ \let\m_itemgroups_conversion_set\m_itemgroups_item_symbol
+ \else
+ \edef\m_itemgroups_conversion_set{\m_itemgroups_conversion_set,\m_itemgroups_item_symbol}%
+ \fi
+ \d_itemgroups_asked_width\itemgroupparameter\c!width\relax
+ \startcollectitems}
+
+\def\itemgroups_start_columns
+ {\startcolumns
+ [\c!n=\itemgroupparameter\c!n,
+ \c!height=,
+ \c!rule=\v!off,
+ \c!balance=\v!yes,
+ \c!align=\v!no]}
+
+\def\itemgroups_stop_columns
+ {\stopcolumns}
+
+\unexpanded\def\stopitemgroup
+ {\stopcollectitems
+ \ifconditional\c_itemgroups_text
+ \removeunwantedspaces
+ \space
+ \ignorespaces
+ \else
+ \par
+ \fi
+ \itemgroups_register_status
+ \ifconditional\c_itemgroups_first \else
+ \dostoptagged
+ \dostoptagged
+ % \endgroup % (3)
+ \fi
+ \ifnum\c_itemgroups_column_depth=\c_itemgroups_nesting\relax
+ \itemgroups_stop_columns
+ \global\c_itemgroups_column_depth\zerocount % global ?
+ \itemgroups_tag_stop_group
+ \itemgroups_after_command
+ \dontrechecknextindentation
+ \else\ifnum\c_itemgroups_nesting=\plusone
+ \itemgroups_insert_breakallow
+ \itemgroups_tag_stop_group
+ \itemgroups_after_command
+ \checknextindentation[\itemgroupparameter\c!indentnext]%
+ \else
+ % nieuw, not yet nobreak handling
+ \itemgroups_tag_stop_group
+ \ifcase\c_itemgroups_spacing_mode
+ \itemgroups_after_command
+ \or
+ \itemgroups_after_command
+ \fi
+ \dontrechecknextindentation
+ \fi\fi
+ % new test, needed in sidefloats (surfaced in volker's proceedings)
+ \iftrialtypesetting
+ \restorestructurecounter[\v_itemgroups_counter]%
+ \global\advance\c_itemgroups_n_of_lists\minusone
+ \fi
+ \global\advance\c_itemgroups_nesting\minusone
+ \xdef\currentitemlevel{\number\c_itemgroups_nesting}%
+ \endgroup % (2)
+ \endgroup % (1)
+ \ifconditional\c_itemgroups_text \else
+ \par % hm, already done
+ \fi
+ \dorechecknextindentation}
+
+% The items.
+
+\unexpanded\def\startitemgroupitem
+ {\dosingleempty\itemgroups_start_item}
+
+\def\itemgroups_start_item_first
+ {\setfalse\c_itemgroups_first
+ % \begingroup % (3)
+ \ifcase\c_itemgroups_nesting
+ % 0
+ \or
+ \itemgroups_start_item_first_one % 1
+ \else
+ \itemgroups_start_item_first_two % 2+
+ \fi}
+
+\def\itemgroups_start_item_first_one
+ {\ifcase\c_itemgroups_column_depth
+ \ifconditional\c_itemgroups_intro\itemgroups_insert_breakno\fi
+ \itemgroups_before_command
+ \itemgroups_tag_start_group
+ \ifconditional\c_itemgroups_intro\itemgroups_insert_breakno\fi
+ \fi}
+
+\def\itemgroups_start_item_first_two
+ {\ifconditional\c_itemgroups_paragraph\else
+ \edef\previtemlevel{\the\numexpr\c_itemgroups_nesting-\plusone}%
+ \ifcase\c_itemgroups_spacing_mode
+ \itemgroups_before_command
+ \or
+ \doifelsenothing\itemgroups_before_command % should possibly expand to empty
+ {\nameditemgroupparameter{\currentparentitemgroup:\previtemlevel}\c!inbetween}%
+ \itemgroups_before_command
+ \else
+ \nameditemgroupparameter{\currentparentitemgroup:\previtemlevel}\c!inbetween
+ \fi
+ \itemgroups_tag_start_group
+ \fi}
+
+\def\itemgroups_start_item_next
+ {\dostoptagged % ok? what do we stop here?
+ \dostoptagged % ok? what do we stop here?
+ \ifconditional\c_itemgroups_text
+ \ifhmode
+ % WS: make the distance between items customizable, think about better default values -> see itemize-1.tex
+ \itemgroups_set_text_item_distance% HH: moved out and made configurable (sort of)
+ \removeunwantedspaces
+ \hskip\textitemdistance\relax
+ \fi
+ \else
+ \itemgroups_between_command
+ \fi}
+
+\unexpanded\def\itemgroups_start_item[#reference]% we can reuse more
+ {\def\currentitemreference{#reference}%
+ \ifconditional\c_itemgroups_text
+ % begin of item
+ \else
+ \par
+ \fi
+ \ifconditional\c_itemgroups_concat
+ \itemgroups_insert_breakno
+ \fi
+ \itemgroups_increment_item_counter
+ \ifconditional\c_itemgroups_first
+ \itemgroups_start_item_first
+ \else
+ \itemgroups_start_item_next
+ \fi
+ \ifconditional\c_itemgroups_concat
+ \vskip-\dimexpr\lastskip+\lineheight\relax
+ \nobreak
+ \setfalse\c_itemgroups_concat
+ \fi
+ \dostarttagged\t!item\empty
+ \dostarttagged\t!itemtag\empty
+ \itemgroups_insert_item
+ \dostoptagged
+ \ifconditional\c_itemgroups_pack
+ \setupwhitespace[\v!none]%
+ \fi
+ \itemgroupparameter\c!inner % will become obsolete (better use setups)
+ \itemgroups_margin_symbol
+ \let\itemgroups_margin_symbol\relax
+ \dostarttagged\t!itemcontent\empty
+ \strut
+ \nobreak % else problems with intext items
+ \hskip\d_itemgroups_signal % concat
+ \itemgroupparameter\c!command}
+
+\unexpanded\def\stopitemgroupitem
+ {\ifconditional\c_itemgroups_text
+ % nothing
+ \else
+ \endgraf
+ \fi}
+
+\unexpanded\def\startitemgrouphead
+ {\dosingleempty\itemgroups_start_head}
+
+\unexpanded\def\itemgroups_start_head[#reference]%
+ {\ifconditional\c_itemgroups_first \else
+ \itemgroups_insert_breakallow
+ \fi
+ \ifconditional\c_itemgroups_pack \else
+ \itemgroups_before_head_command
+ \fi
+ \ifconditional\c_itemgroups_first
+ \ifconditional\c_itemgroups_intro \else
+ \ifcase\c_itemgroups_nesting
+ \itemgroups_insert_breakallow
+ \fi
+ \fi
+ \fi
+ \itemgroups_start_item[#reference]%
+ \groupedcommand\itemgroups_start_head_indeed\itemgroups_stop_head_indeed}
+
+\unexpanded\def\stopitemgrouphead
+ {\stopitemgroupitem}
+
+\unexpanded\def\itemgroups_start_head_indeed
+ {\useitemgroupstyleandcolor\c!headstyle\c!headcolor\ignorespaces}
+
+\unexpanded\def\itemgroups_stop_head_indeed
+ {\removeunwantedspaces
+ \ifconditional\c_itemgroups_text
+ \space
+ \ignorespaces
+ \else
+ \par
+ \fi
+ \itemgroups_insert_breakno
+ \ifconditional\c_itemgroups_pack\else\itemgroups_after_head_command\fi
+ \itemgroups_insert_breakno
+ \noindentation}
+
+% Simple commands.
+
+\unexpanded\def\itemgroups_start_do_item
+ {\startitemgroupitem}
+
+\unexpanded\def\itemgroups_start_no_item % ?
+ {\startitemgroupitem}
+
+\unexpanded\def\itemgroups_start_button[#destination]%
+ {\edef\m_itemgroups_destination{#destination}%
+ \startitemgroupitem}
+
+\unexpanded\def\itemgroups_start_symbol#text%
+ {\def\itemgroups_extra_symbol{#text}%
+ \startitemgroupitem}
+
+\unexpanded\def\itemgroups_start_dummy
+ {\itemgroups_start_symbol\strut\strut}
+
+\unexpanded\def\itemgroups_start_subitem
+ {\settrue\c_itemgroups_sub
+ \startitemgroupitem}
+
+\unexpanded\def\itemgroups_start_edge#text%
+ {\itemgroups_start_symbol
+ {\itemgroups_calculate_list_width\c_itemgroups_nesting
+ \hbox to \d_itemgroups_list_width
+ {#text\hskip\itemgroupparameter\c!distance}}}
+
+\unexpanded\def\itemgroups_start_margin#text%
+ {\def\itemgroups_margin_symbol
+ {\llap
+ {\begingroup
+ \useitemgroupstyleandcolor\c!marstyle\c!marcolor
+ #text% keep em/ex local
+ \endgroup
+ \hskip\dimexpr\leftskip+\leftmargindistance\relax}}%
+ \startitemgroupitem}
+
+\unexpanded\def\itemgroups_start_text#text%
+ {\def\itemgroups_extra_symbol{#text}%
+ \settrue\c_itemgroups_txt
+ \startitemgroupitem}
+
+\unexpanded\def\itemgroup_start_head
+ {\settrue\c_itemgroups_head
+ \startitemgrouphead}
+
+\unexpanded\def\itemgroups_start_items
+ {\dosingleempty\itemgroups_start_items}
+
+\unexpanded\def\itemgroups_start_items[#whatever]% something got lost
+ {\itemgroups_start_edge
+ {\dorecurse{0\itemgroupparameter\c!items}{\itemgroups_used_symbol\hss}%
+ \unskip}}
+
+\unexpanded\def\startspecialitemgroupitem[#name]%
+ {\csname\??op:\e!start:\ifcsname#name\endcsname#name\else\v!item\fi\endcsname}
+
+\unexpanded\def\stopspecialitemgroupitem
+ {\stopitemgroupitem}
+
+\letvalue{\??op:\e!start:\v!item}\itemgroups_start_do_item
+\letvalue{\??op:\e!start:\v!sub }\itemgroups_start_subitem
+\letvalue{\??op:\e!start:\v!sym }\itemgroups_start_symbol
+\letvalue{\??op:\e!start:\v!ran }\itemgroups_start_edge
+\letvalue{\??op:\e!start:\v!its }\itemgroups_start_items
+\letvalue{\??op:\e!start:\v!mar }\itemgroups_start_margin
+
+\def\optimizelistitemsbreak
+ {\ifcase\c_itemgroups_column_depth \ifconditional\c_itemgroups_optimize
+ \ifcase \c_itemgroups_max_items \else
+ \ifnum\c_itemgroups_max_items=\plusthree
+ \ifnum\c_itemgroups_n_of_items>\plusone
+ \itemgroups_insert_nobreak
+ \fi
+ \else\ifnum\c_itemgroups_max_items>\plusthree
+ \ifnum\c_itemgroups_n_of_items=\plustwo
+ \ifconditional\c_itemgroups_intro
+ \itemgroups_insert_breakno
+ \else
+ \itemgroups_insert_nobreak
+ \fi
+ \else\ifnum\c_itemgroups_max_items=\c_itemgroups_n_of_items\relax
+ \itemgroups_insert_nobreak
+ \else\ifnum\c_itemgroups_n_of_items>\plustwo
+ \itemgroups_insert_break
+ \else
+ \ifconditional\c_itemgroups_intro\else\itemgroups_insert_break\fi
+ \fi\fi\fi
+ \fi\fi
+ \fi
+ \fi\fi}
+
+\def\itemgroups_handle_text_item
+ {\scratchdimen\wd\b_itemgroups
+ \advance \scratchdimen \itemgroupparameter\c!distance\relax
+ \ifdim\scratchdimen>\d_itemgroups_list_width
+ \advance\scratchdimen -\d_itemgroups_list_width
+ \else
+ \scratchdimen\zeropoint
+ \fi
+ \llap{\hbox to \d_itemgroups_list_width{\ifconditional\c_itemgroups_sub\llap{+\enspace}\fi\box\b_itemgroups\hss}}% was: \hfill
+ \hskip\scratchdimen}
+
+\def\itemgroups_handle_lapped_item_positive
+ {\llap
+ {\hbox to \d_itemgroups_list_width
+ {\ifconditional\c_itemgroups_sub
+ \llap{+\enspace}%
+ \fi
+ \itemgroups_left_sym_filler
+ \box\b_itemgroups % can already have a forced widt, only factor handled here
+ \hfil
+ \hskip\itemgroupparameter\c!distance}}}
+
+\def\itemgroups_handle_lapped_item_negative
+ {\llap
+ {\ifconditional\c_itemgroups_sub
+ \llap{+\enspace}%
+ \fi
+ \box\b_itemgroups
+ \hskip\leftmargindistance}}
+
+\def\itemgroups_handle_groups_text_item
+ {\hbox
+ {\ifconditional\c_itemgroups_sub
+ +\enspace
+ \fi
+ \box\b_itemgroups
+ \hskip\interwordspace}%
+ \nobreak}
+
+\def\itemgroups_handle_groups_inline_item
+ {\hbox to \d_itemgroups_list_width
+ {\ifconditional\c_itemgroups_sub
+ \llap{+\enspace}%
+ \fi
+ \box\b_itemgroups
+ \hss}} % was: \hfill
+
+\unexpanded\def\itemgroups_start_head_sym#text%
+ {\def\itemgroups_extra_symbol{#text}%
+ \settrue\c_itemgroups_head
+ \itemgroups_start_head}
+
+\def\itemgroups_make_symbol_box
+ {\setbox\b_itemgroups\hbox
+ {\ifconditional\c_itemgroups_head
+ \ifx\itemgroups_extra_symbol\empty
+ \useitemgroupstyleandcolor\c!headstyle\c!headcolor
+ \itemgroups_used_symbol
+ \else
+ \useitemgroupstyleandcolor\c!symstyle\c!symcolor
+ \itemgroups_extra_symbol
+ \let\itemgroups_extra_symbol\empty
+ \fi
+ \else
+ \ifx\itemgroups_extra_symbol\empty
+ \useitemgroupstyleandcolor\c!style\c!color
+ \itemgroups_used_symbol
+ \else
+ \useitemgroupstyleandcolor\c!symstyle\c!symcolor
+ \itemgroups_extra_symbol
+ \let\itemgroups_extra_symbol\empty
+ \fi
+ \fi}}
+
+\def\itemgroups_make_fitting_box
+ {\ifdim\wd\b_itemgroups>\itemgroupparameter\c!maxwidth\scaledpoint\relax % brr, sp
+ \normalexpanded{\global\setitemgroupparameter{\c!maxwidth}{\number\wd\b_itemgroups}}%
+ \fi
+ \ifdim\d_itemgroups_max_width>\zeropoint
+ \setbox\b_itemgroups\simplealignedbox
+ {\dimexpr\d_itemgroups_max_width+\itemgroupparameter\c!distance\relax}
+ {\itemgroupparameter\c!itemalign}
+ {\box\b_itemgroups\hskip\itemgroupparameter\c!distance}%
+ \fi}
+
+\def\itemgroups_make_aligned_box
+ {\doifsomething{\itemgroupparameter\c!itemalign}
+ {\setbox\b_itemgroups\simplealignedbox
+ {\dimexpr\d_itemgroups_asked_width+\itemgroupparameter\c!distance\relax}
+ {\itemgroupparameter\c!itemalign}
+ {\box\b_itemgroups\hskip\itemgroupparameter\c!distance}}}
+
+\def\itemgroups_make_destination_box
+ {\iftrialtypesetting \else \ifx\m_itemgroups_destination\empty \else
+ \setbox\b_itemgroups\hbox{\directgotobox{\box\b_itemgroups}[\m_itemgroups_destination]}%
+ \fi\fi}
+
+\def\itemgroups_check_indenting
+ {\setfalse\c_itemgroups_indented_first
+ \ifx\m_itemgroups_indenting\empty \else
+ \normalexpanded{\setupindenting[\v!reset,\v!yes,\m_itemgroups_indenting]}%
+ \ifindentfirstparagraph
+ \doifnot{\itemgroupparameter\c!alignsymbol}\v!yes
+ {\settrue\c_itemgroups_indented_first}%
+ \fi
+ \fi}
+
+\def\itemgroups_check_for_repeated
+ {\ifconditional\c_itemgroups_repeat
+ \ifx\m_itemgroups_repeat_start\empty
+ \let\m_current_itemgroups_start\currentitemlevel
+ \fi
+ \setbox\b_itemgroups\hbox to \wd\b_itemgroups
+ {\hskip-\d_itemgroups_asked_width
+ \box\b_itemgroups}% what a hack !
+ \fi}
+
+\def\itemgroups_insert_item
+ {\ifconditional\c_itemgroups_text
+ % begin of item
+ \else
+ \par
+ \fi
+ \advance\c_itemgroups_n_of_items\plusone
+ \optimizelistitemsbreak
+ \itemgroups_check_indenting
+ \dontleavehmode
+ \ifconditional\c_itemgroups_indented_first
+ \hskip-\parindent
+ \fi
+ \itemgroups_make_symbol_box
+ \itemgroups_make_destination_box
+ \ifconditional\c_itemgroups_fitting
+ \itemgroups_make_fitting_box
+ \else\ifdim\d_itemgroups_asked_width>\zeropoint
+ \itemgroups_make_aligned_box
+ \fi\fi
+ \let\m_itemgroups_destination\empty
+ \ht\b_itemgroups\strutheight % just in case a symbols is not yet available in
+ \dp\b_itemgroups\strutdepth % the current run (more a mkii mp side artifact)
+ \itemgroups_check_for_repeated
+ \ifdim\d_itemgroups_asked_width<\zeropoint\relax
+ \itemgroups_handle_lapped_item_negative
+ \else
+ \ifdim\d_itemgroups_asked_width=\zeropoint\relax
+ \itemgroups_calculate_list_width\plusone
+ \else
+ \itemgroups_calculate_list_width\c_itemgroups_nesting
+ \fi
+ \ifconditional\c_itemgroups_text
+ \itemgroups_handle_groups_text_item
+ \else\ifconditional\c_itemgroups_inline
+ \itemgroups_handle_groups_inline_item
+ \else\ifconditional\c_itemgroups_txt
+ \itemgroups_handle_text_item
+ \else
+ \itemgroups_handle_lapped_item_positive
+ \fi\fi\fi
+ \fi
+ \setfalse\c_itemgroups_head
+ \setfalse\c_itemgroups_sub
+ \ifconditional\c_itemgroups_indented_first
+ \hskip\parindent
+ \fi
+ \ignorespaces}
+
+\def\itemgroups_start_item_nop
+ {\let\currentitemreference\empty
+ \itemgroups_increment_item_counter
+ \advance\c_itemgroups_n_of_items\plusone
+ \setbox\b_itemgroups\hbox
+ {\useitemgroupstyleandcolor\c!style\c!color
+ \itemgroups_used_symbol}%
+ \itemgroups_check_for_repeated
+ \ignorespaces}
+
+\setvalue{\??op:d:\c!textdistance:\v!none}%
+ {\let\m_itemgroups_text_distance\zeropoint}
+
+\unexpanded\def\itemgroups_set_text_item_distance
+ {\edef\m_itemgroups_text_distance{\itemgroupparameter\c!textdistance}%
+ \ifx\m_itemgroups_text_distance\empty
+ %
+ \else\ifcsname\??op:d:\c!textdistance:\m_itemgroups_text_distance\endcsname
+ \csname\??op:d:\c!textdistance:\m_itemgroups_text_distance\endcsname
+ \else
+ \itemgroups_set_text_item_distance_indeed
+ \fi\fi}
+
+\def\itemgroups_set_text_item_distance_indeed
+ {\assignvalue
+ \m_itemgroups_text_distance
+ \m_itemgroups_text_distance
+ {.5\interwordspace\!!plus.5\emwidth}%
+ {\interwordspace \!!plus \emwidth}%
+ {\emwidth \!!plus \interwordstretch\!!minus\interwordshrink}}
+
+\unexpanded\def\itemgroups_default_command
+ {\EveryPar{\ignorespaces}% needed ?
+ \ignorespaces}
+
+%D Special case:
+
+\unexpanded\def\itemgroups_head#text\par
+ {\startitemgrouphead{#text}}
+
+%D The local commands:
+
+\appendtoks
+ \let\item \itemgroups_start_do_item
+ \let\noitem \itemgroups_start_no_item
+ \let\itm \itemgroups_start_do_item
+ \let\but \itemgroups_start_button
+ \let\nop \itemgroups_start_dummy
+ \let\txt \itemgroups_start_text
+ \let\head \itemgroups_head
+ \let\headsym \itemgroups_start_head_sym
+ \let\starthead \startitemgrouphead
+ \let\startitem \startitemgroupitem
+ \let\stopitem \stopitemgroupitem
+ \let\starthead \startitemgrouphead
+ \let\stophead \stopitemgroupitemhead
+ \let\startspecialitem\startspecialitemgroupitem
+ \let\stopspecialitem \stopspecialitemgroupitem
+\to \itemgroupcommands
+
+\ifx\currentinterface \v!english \else
+
+ \appendtoks
+ \expandafter\let\csname\v!item \endcsname\itemgroups_start_do_item
+ \expandafter\let\csname\v!sub \endcsname\itemgroups_start_subitem
+ \expandafter\let\csname\v!sym \endcsname\itemgroups_start_symbol
+ \expandafter\let\csname\v!ran \endcsname\itemgroups_start_edge
+ \expandafter\let\csname\v!head \endcsname\itemgroups_head
+ \expandafter\let\csname\v!its \endcsname\itemgroups_start_items
+ \expandafter\let\csname\v!mar \endcsname\itemgroups_start_margin
+ \expandafter\let\csname\v!txt \endcsname\itemgroups_start_text
+ \expandafter\let\csname\e!start\v!item\endcsname\startitemgroupitem
+ \expandafter\let\csname\e!stop \v!item\endcsname\stopitemgroupitem
+ \expandafter\let\csname\e!start\v!head\endcsname\startitemgrouphead
+ \expandafter\let\csname\e!stop \v!head\endcsname\stopitemgrouphead
+ \to \itemgroupcommands
+
+\fi
+
+%D A nice example of a plugin:
+%D
+%D \startbuffer
+%D \startitemize[a,random,packed]
+%D \startitem first \stopitem \startitem second \stopitem
+%D \startitem third \stopitem \startitem fourth \stopitem
+%D \stopitemize
+%D
+%D \startitemize[a,random,packed]
+%D \startitem first \stopitem \startitem second \stopitem
+%D \startitem third \stopitem \startitem fourth \stopitem
+%D \stopitemize
+%D
+%D \startitemize[a,packed]
+%D \startitem first \stopitem \startitem second \stopitem
+%D \startitem third \stopitem \startitem fourth \stopitem
+%D \stopitemize
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+% better collectitems als conditional and a real plugin mechanism (some day)
+
+\newcount\c_itemgroups_collected_stored
+\newcount\c_itemgroups_collected_done
+\newcount\c_itemgroups_collected_current
+
+\@EA\def\@EA\itemgroups_collected_store\@EA#\@EA1\csname\e!stop\v!item\endcsname % use grabuntil
+ {\advance\c_itemgroups_collected_stored\plusone
+ \setvalue{\??op:x:\number\c_itemgroups_collected_stored}{\startitemgroupitem#1\stopitemgroupitem}}
+
+\def\itemgroups_collected_flush
+ {\ifconditional\c_itemgroups_randomize
+ \getrandomcount\c_itemgroups_collected_current\plusone\c_itemgroups_collected_stored
+ \else
+ \advance\c_itemgroups_collected_current\plusone
+ \fi
+ \doifdefined{\??op:x:\number\c_itemgroups_collected_current}
+ {\getvalue{\??op:x:\number\c_itemgroups_collected_current}%
+ \letbeundefined{\??op:x:\number\c_itemgroups_collected_current}%
+ \advance\c_itemgroups_collected_done\plusone}%
+ \ifnum\c_itemgroups_collected_done<\c_itemgroups_collected_stored
+ \expandafter\itemgroups_collected_flush
+ \fi}
+
+\unexpanded\def\stopcollectitems
+ {\ifconditional\c_itemgroups_randomize
+ \c_itemgroups_collected_done \zerocount
+ \c_itemgroups_collected_current\zerocount
+ \ifnum\c_itemgroups_collected_stored>\zerocount
+ \doubleexpandafter\itemgroups_collected_flush
+ \fi
+ \fi}
+
+\unexpanded\def\startcollectitems
+ {\ifconditional\c_itemgroups_randomize
+ \c_itemgroups_collected_stored\zerocount
+ \letvalue{\e!start\v!item}\itemgroups_collected_store
+ \fi}
+
+%D Left-overs:
+
+\unexpanded\def\item
+ {\itemgroups_item_alone}
+
+\def\itemgroups_item_alone[#category]#text\par
+ {\doifsomethingelse{#category}{\startitemgroup[#category]}{\startitemgroup[\v!itemize]}%
+ \startitem#text\stopitem
+ \stopitemgroup}
+
+\unexpanded\def\head
+ {\itemgroups_head_alone}
+
+\def\itemgroups_head_alone[#category]#head\par#body\par
+ {\doifsomethingelse{#category}{\startitemgroup[#category]}{\startitemgroup[\v!itemize]}%
+ \starthead{#head}#body\stophead
+ \stopitemgroup}
+
+\setuvalue{\e!start\v!item}%
+ {\startitemgroup[\v!itemize]%
+ \startitemgroupitem
+ \setuvalue{\e!stop\v!item}{\stopitemgroupitem\stopitemgroup}}
+
+% \def\sym#text%
+% {\noindent
+% \begingroup
+% \setbox\scratchbox\hbox{\settrialtypesetting#text}%
+% \setbox\scratchbox\hbox\ifdim\wd\scratchbox<1em to 1.5\else spread 1\fi em{#text\hfil}%
+% \normalexpanded{\box\scratchbox\endgroup\hangindent\the\wd\scratchbox}%
+% \ignorespaces}
+
+%D End of plugin.
+
+\setupitemgroup
+ [\c!margin=\zeropoint,
+ \c!leftmargin=\zeropoint,
+ \c!rightmargin=\zeropoint,
+ \c!indentnext=\v!yes,
+ \c!width=1.5em,
+ \c!factor=0,
+ %\c!distance=.5em, % is now:
+ \c!step=.5em, % deals with broad
+ \c!distance=\zeropoint,
+ %\c!align=\v!normal, % definitely not \v!normal !
+ %\c!symalign=,
+ %\c!color=,
+ %\c!indenting=, % untouched if empty
+ %\c!style=,
+ \c!marstyle=\v!type,
+ %\c!symstyle=,
+ %\c!headstyle=,
+ %\c!marcolor=,
+ %\c!symcolor=,
+ %\c!headcolor=,
+ %\c!beforehead=,
+ \c!afterhead=\blank,
+ \c!before=\blank,
+ \c!inbetween=\blank,
+ \c!after=\blank,
+ %\c!stopper=.,
+ \c!placestopper=\v!yes,
+ \c!stopper=.,
+ %\c!inner=,
+ \c!n=2,
+ \c!items=4,
+ \c!levels=10,
+ \c!lefttext=(,
+ \c!righttext=),
+ \c!start=1,
+ \c!criterium=\v!all, % permits 0 and negative numbers
+ %\c!option=,
+ \c!textdistance=\v!big,
+ \c!command=\itemgroups_default_command,
+ \c!indenting=\v!next,
+ %\c!alignsymbol=v!no,
+ \c!symbol=\currentitemlevel,
+ \c!prefix=\v!no,
+ %\c!prefixstopper=.,
+ %\c!prefixseparatorset=,
+ %\c!prefixconversion=,
+ %\c!prefixconversionset=,
+ %\c!prefixset=,
+ %\c!prefixsegments=1:100,
+ \c!prefixconnector=.,
+ \c!numberseparatorset=,
+ \c!numberconversionset=,
+ \c!numberstopper=.,
+ \c!numbersegments=1]
+
+\defineitemgroup
+ [\v!itemize]
+
+\protect \endinput
diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv
index eb7b699a2..6d7622a6a 100644
--- a/tex/context/base/strc-lst.mkiv
+++ b/tex/context/base/strc-lst.mkiv
@@ -25,9 +25,9 @@
\installframedcommandhandler \??li {list} \??li
-\def\donestedlistattributes#1#2% will change
- {\dosetlistattributes#1#2%
- \ifx\colorattributehash\empty \else
+\def\usenestedliststyleandcolor#1#2% will change
+ {\useliststyleandcolor#1#2%
+ \ifx\currentcolorparameter\empty \else
\resetinteractionparameter\c!color
\resetinteractionparameter\c!contrastcolor
\fi}
@@ -434,12 +434,13 @@
\setsystemmode \v!list
\fi}
-\unexpanded\def\systemsuppliedchapter {\getvalue{\v!chapter}} % brrr
-\unexpanded\def\systemsuppliedtitle {\getvalue{\v!title}} % brrr
+\unexpanded\def\systemsuppliedchapter {\getvalue{\v!chapter}} % obsolete
+\unexpanded\def\systemsuppliedtitle {\getvalue{\v!title}} % obsolete
\def\dodocompletelist[#1][#2][#3]% enkelvoud, meervoud, instellingen
- {\normalexpanded{\systemsuppliedtitle[#2]{\noexpand\headtext{#2}}}% expansion needed for v! vs french !
- \doplacelist[#1][#3]}
+ {\normalexpanded{\startnamedsection[\v!title][\c!title=\headtext{#2},\c!reference=#2]}%
+ \doplacelist[#1][#3]%
+ \stopnamedsection}
\def\docompletelist[#1][#2]%
{\dodocompletelist[#1][#1][#2]}
@@ -636,17 +637,17 @@
\domakelistelement\v!all{#2}\hbox
{\doif{\listparameter\c!headnumber}\v!yes
{\domakelistelement\v!sectionnumber{#2}\hbox
- {\donestedlistattributes\c!numberstyle\c!numbercolor
+ {\usenestedliststyleandcolor\c!numberstyle\c!numbercolor
{\listparameter\c!numbercommand{\currentlistsymbol}}}}%
\domakelistelement\v!text{#2}\hbox
- {\donestedlistattributes\c!textstyle\c!textcolor
+ {\usenestedliststyleandcolor\c!textstyle\c!textcolor
{\let\\=\newlineinlist
\dontconvertfont
\listparameter\c!textcommand{#4}}}%
\doif{\listparameter\c!pagenumber}\v!yes
{\doifsomething{#5}
{\domakelistelement\v!pagenumber{#2}\hbox
- {\donestedlistattributes\c!pagestyle\c!pagecolor
+ {\usenestedliststyleandcolor\c!pagestyle\c!pagecolor
{\listparameter\c!pagecommand{#5}}}}}}}%
#8}%
\listparameter\c!after}
@@ -691,12 +692,12 @@
\hsize\localhsize
\hbox to \hsize
{\forgetall
- \dosetlistattributes\c!style\c!color
+ \useliststyleandcolor\c!style\c!color
\!!widthb\hsize
\doifelse{\listparameter\c!headnumber}\v!yes
{\setbox2\hbox \ifdim\!!widtha>\zeropoint to \!!widtha \fi
{\domakelistelement\v!sectionnumber{#2}\hbox
- {\donestedlistattributes\c!numberstyle\c!numbercolor
+ {\usenestedliststyleandcolor\c!numberstyle\c!numbercolor
{\listparameter\c!numbercommand{\currentlistsymbol}}%
\hfill}}}
{\!!widtha\zeropoint
@@ -708,7 +709,7 @@
{\hbox \ifdim\listwidth>\zeropoint to \listwidth\fi
{\hfill
\domakelistelement\v!pagenumber{#2}\hbox
- {\donestedlistattributes\c!pagestyle\c!pagecolor
+ {\usenestedliststyleandcolor\c!pagestyle\c!pagecolor
{\listparameter\c!pagecommand{#5}}}}}}}%
\vbox
{\hsize\!!widthb
@@ -743,7 +744,7 @@
\hskip\dimen2
\domakelistelement\v!text{#2}\firstofoneargument
{\bgroup
- \donestedlistattributes\c!textstyle\c!textcolor
+ \usenestedliststyleandcolor\c!textstyle\c!textcolor
{\let\\=\newlineinlist
\dontconvertfont
%\listparameter\c!textcommand{#4}}%
@@ -808,7 +809,7 @@
{\doif{\listparameter\c!pagenumber}\v!yes
{\doifsomething{#5}
{\domakelistelement\v!pagenumber{#2}\hbox
- {\donestedlistattributes\c!pagestyle\c!pagecolor
+ {\usenestedliststyleandcolor\c!pagestyle\c!pagecolor
{\listparameter\c!pagecommand{#5}}}}}}%
%% \domakelistelement\v!all{#2}\firstofoneargument{%
\doif{\listparameter\c!headnumber}\v!yes
@@ -819,7 +820,7 @@
\hbox
{\listparameter\c!left
\domakelistelement\v!sectionnumber{#2}\hbox
- {\donestedlistattributes\c!numberstyle\c!numbercolor
+ {\usenestedliststyleandcolor\c!numberstyle\c!numbercolor
{\listparameter\c!numbercommand{\currentlistsymbol}}}%
\listparameter\c!right
\hskip.5em}%
@@ -827,7 +828,7 @@
\fi}%
\tolerance3500 % niet zomaar veranderen
%% \domakelistelement\v!text{#2}\firstofoneargument{%
- \donestedlistattributes\c!textstyle\c!textcolor
+ \usenestedliststyleandcolor\c!textstyle\c!textcolor
{\let\\=\newlineinlist
\dontconvertfont
%\listparameter\c!textcommand{#4}}%
@@ -874,7 +875,7 @@
\domakelistelement\v!all{#4}{#2}%
{\let\\=\newlineinlist
#1% in case E nils the strut (still needed?)
- \dosetlistattributes\c!style\c!color
+ \usesetliststyleandcolor\c!style\c!color
\ignorespaces\dontconvertfont\setstrut
\begstrut
\limitatedlistentry{#6}%
@@ -962,8 +963,9 @@
\dosetlistmode}
\def\docompletecombinedlist[#1][#2]%
- {\normalexpanded{\systemsuppliedtitle[#1]{\noexpand\headtext{#1}}}% expansion due to v! vs french !
- \doplacecombinedlist[#1][#2]}
+ {\normalexpanded{\startnamedsection[\v!title][\c!title={\headtext{#1}},\c!reference=#1]}%
+ \doplacecombinedlist[#1][#2]%
+ \stopnamedsection}
% lists that have a number/title are kind of generic and can share code
@@ -1001,56 +1003,5 @@
segments = "\listparameter\c!numbersegments",
} )}%
\dostoptagged}
-
-% new and yet undocumented (used in cocoa qa), temporarily disabled in mkiv
-%
-% \setupremaininglistlength
-% [left=\hss nog~,right=~ingangen]
-%
-% \resetremaininglistlength
-% [section][settings]
-%
-% \placelist
-% [section]
-% [before=\showremaininglistlength]
-%
-% \dorecurse{100}{\section{hans}}
-%
-% \definesystemvariable {ll} % ListLength
-%
-% \unexpanded\def\setupremaininglistlength[#1]%
-% {\getparameters[\??ll][#1]%
-% \globallet\listlengthcounter\!!zerocount}
-%
-% \setupremaininglistlength
-% [\c!left=\hss,\c!right=,\c!number=\v!yes,
-% \c!before=\blank,\c!after=\page,
-% \c!style=\v!smallnormal,\c!color=]
-%
-% \def\resetremaininglistlength
-% {\dodoubleempty\doresetremaininglistlength}
-%
-% \def\doresetremaininglistlength[#1][#2]%
-% {\determinelistcharacteristics[#1][#2]%
-% \xdef\listlengthcounter{\number\utilitylistlength}}
-%
-% \def\showremaininglistlength
-% {\bgroup
-% \ifnum\listlengthcounter>\plusone
-% \setbox\scratchbox\vbox
-% {\@@llbefore\par\horizontalstrut\par\horizontalstrut\par\@@llafter}%
-% \scratchdimen\pagetotal
-% \advance\scratchdimen \ht\scratchbox
-% \advance\scratchdimen \dp\scratchbox
-% \ifdim\scratchdimen>\pagegoal
-% \@@llbefore
-% \nobreak\hbox to \hsize
-% {\doifnot\@@llnumber\v!yes{\let\listlengthcounter\empty}%
-% \doattributes\??ll\c!style\c!color{\@@llleft\listlengthcounter\@@llright}}
-% \@@llafter
-% \fi
-% \fi
-% \doglobal\decrement\listlengthcounter\relax
-% \egroup}
\protect \endinput
diff --git a/tex/context/base/strc-mar.mkiv b/tex/context/base/strc-mar.mkiv
index a1160c73a..5ae23ac75 100644
--- a/tex/context/base/strc-mar.mkiv
+++ b/tex/context/base/strc-mar.mkiv
@@ -48,18 +48,6 @@
\def\domarkingparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\domarkingparentparameter\csname#1\s!parent\endcsname#2\fi}
\def\domarkingparentparameter#1#2{\ifx#1\relax\s!empty\else\domarkingparameter#1#2\fi}
-% \def\markingparameterhash #1{\domarkingparameterhash{\??mk\currentmarking}#1}
-% \def\domarkingparameterhash #1#2{\ifcsname#1#2\endcsname#1\else\expandafter\domarkingparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-% \def\domarkingparentparameterhash#1#2{\ifx#1\relax\else\domarkingparameterhash#1#2\fi}
-%
-% \def\detokenizedmarkingparameter#1{\detokenize\expandafter\expandafter\expandafter{\csname\??mk\currentmarking#1\endcsname}}
-%
-% \def\dosetmarkingattributes#1#2% style color
-% {\edef\fontattributehash {\markingparameterhash#1}%
-% \edef\colorattributehash{\markingparameterhash#2}%
-% \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
-% \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
-
\newconditional\inhibitgetmarking
\newconditional\inhibitsetmarking
\newtoks \everymarking
diff --git a/tex/context/base/strc-mat.mkiv b/tex/context/base/strc-mat.mkiv
index a782e292f..095afb0bb 100644
--- a/tex/context/base/strc-mat.mkiv
+++ b/tex/context/base/strc-mat.mkiv
@@ -210,7 +210,7 @@
{\rm % nodig ?
\doif{\formulaparameter\c!location}\v!right{\hskip\formulaparameter\c!distance}%
\formulaparameter\c!numbercommand
- {\dosetformulaattributes\c!numberstyle\c!numbercolor
+ {\useformulastyleandcolor\c!numberstyle\c!numbercolor
\strut
\formulaparameter\c!left
\namedtaggedlabeltexts
diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv
index a1aec9ab5..e026a5986 100644
--- a/tex/context/base/strc-not.mkiv
+++ b/tex/context/base/strc-not.mkiv
@@ -98,7 +98,7 @@
{\def\doprocesssomenote##1{\edef\currentnote{##1}\let\currentdescription\currentnote#1}%
\the\tobeprocessednotes}
-%D Notes have their own paremater handlers. The complication here
+%D Notes have their own parameter handlers. The complication here
%D is that we use descriptions to typeset the note, so we have several
%D resolvers.
@@ -119,11 +119,11 @@
\def\detokenizednoteparameter#1{\detokenize\expandafter\expandafter\expandafter{\csname\??vn#1\endcsname}}
-\def\dosetnoteattributes#1#2% style color
- {\edef\fontattributehash {\noteparameterhash#1}%
- \edef\colorattributehash{\noteparameterhash#2}%
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
+\def\usenotestyleandcolor#1#2% style color
+ {\edef\currentstyleparameter{\noteparameter#1}%
+ \edef\currentcolorparameter{\noteparameter#2}%
+ \ifx\currentstyleparameter\empty\else\dousestyleparameter\currentstyleparameter\fi
+ \ifx\currentcolorparameter\empty\else\dousecolorparameter\currentcolorparameter\fi}
\def\setnoteparameter#1{\dosetvalue{\??vn\currentnote}{#1}}
@@ -507,17 +507,18 @@
\global\skip\currentnoteins\ht\scratchbox
\endgroup}
-% \def\checknotes % no longer needed
-% {\processnotes\dochecknote}
-%
-% \def\checknotedistances
-% {\processnotes\dosetnotedistance}
-%
-% fails but not that much needed anyway:
-%
-% \appendtoks
-% \checknotedistances
-% \to \everyglobalbodyfont
+%D A fast checker for bottom notes being used:
+
+\newconditional\c_notes_bottom_present
+
+\def\notes_check_if_bottom_present_indeed
+ {\ifnum\noteparameter\s!notepos=\plustwo
+ \settrue\c_notes_bottom_present
+ \fi}
+
+\def\notes_check_if_bottom_present
+ {\setfalse\c_notes_bottom_present
+ \processnotes{\ifconditional\c_notes_bottom_present\else\notes_check_if_bottom_present_indeed\fi}}
% D When \type{n} exceeds~1, footnotes are typeset in
% D multi||columns, using the algoritm presented on page~397
@@ -794,13 +795,13 @@
\def\docurrentnoteenumerationfullnumber
{\noteparameter\c!numbercommand
- {\dosetnoteattributes\c!numberstyle\c!numbercolor
+ {\usenotestyleandcolor\c!numberstyle\c!numbercolor
\ctxlua{structures.notes.number("\currentnote",\currentdescriptionnumberentry)}%
\domovednote\currentdescription\currentdescriptionnumberentry\v!nextpage\v!previouspage}}
\def\docurrentnoteenumerationsymbol
{\noteparameter\c!numbercommand
- {\dosetnoteattributes\c!numberstyle\c!numbercolor
+ {\usenotestyleandcolor\c!numberstyle\c!numbercolor
\descriptionparameter\c!symbol
\domovednote\currentdescription\currentdescriptionnumberentry\v!nextpage\v!previouspage}}
@@ -933,7 +934,7 @@
\egroup}
\def\dodonotesymbol#1%
- {\noteparameter\c!textcommand{\dosetnoteattributes\c!textstyle\c!textcolor#1}}
+ {\noteparameter\c!textcommand{\usenotestyleandcolor\c!textstyle\c!textcolor#1}}
%D Normally footnotes are saved as inserts that are called upon
%D as soon as the pagebody is constructed. The footnote
@@ -1331,15 +1332,6 @@
%D \neverypar {...\postponenotes}
%D \stoptyping
%D
-%D and
-%D
-%D \starttyping
-%D \def\ejectinsert%
-%D {...
-%D \flushnotes
-%D ...}
-%D \stoptyping
-%D
%D We can use \type{\neverypar} because in most commands
%D sensitive to footnote gobbling we disable \type{\everypar}
%D in favor for \type{\neverypar}. In fact, this footnote
diff --git a/tex/context/base/strc-pag.lua b/tex/context/base/strc-pag.lua
index 95851d1f0..460d4ff00 100644
--- a/tex/context/base/strc-pag.lua
+++ b/tex/context/base/strc-pag.lua
@@ -19,7 +19,6 @@ local structures = structures
local helpers = structures.helpers
local sections = structures.sections
local pages = structures.pages
-local processors = structures.processors
local sets = structures.sets
local counters = structures.counters
@@ -28,6 +27,7 @@ local counterdata = counters.data
local variables = interfaces.variables
local context = context
+local processors = typesetters.processors
local applyprocessor = processors.apply
local startapplyprocessor = processors.startapply
local stopapplyprocessor = processors.stopapply
diff --git a/tex/context/base/strc-pag.mkiv b/tex/context/base/strc-pag.mkiv
index bd8308096..8a6f463e4 100644
--- a/tex/context/base/strc-pag.mkiv
+++ b/tex/context/base/strc-pag.mkiv
@@ -316,12 +316,17 @@
\trackingmarginnotesfalse
\fi
\fi
+ \recalculatebackgrounds
\dosetpagenumberlocation
\to \everysetuppagenumbering
-\appendtoks
- \ifdefined \recalculatebackgrounds \recalculatebackgrounds \fi
-\to \everysetuppagenumbering
+\ifdefined \recalculatebackgrounds \else
+ \let\recalculatebackgrounds\relax
+\fi
+
+\ifdefined \dosetpagenumberlocation \else
+ \let\dosetpagenumberlocation\relax
+\fi
\def\flushfinallayoutpage
{\doifsomething\@@nmpage{\doifnot\@@nmpage\v!no{\page[\@@nmpage]}}}
@@ -329,42 +334,6 @@
% The numbered location handler is there because we need to be downward
% compatible. So, in fact there can be multiple handlers active at the
% same time, but only the current one does something.
-%
-% thsi code might move to page-txt
-
-\newcount\currentpagenumberlocation
-
-\def\dosetpagenumberlocation
- {\advance\currentpagenumberlocation\plusone
- \ifx\@@nmlocation\empty \else
- \let\@@pagenumbervlocation\v!footer
- \let\@@pagenumberhlocation\v!text
- \let\@@pagenumberxlocation\c!middletext
- \normalexpanded{\noexpand\processallactionsinset[\@@nmlocation]}
- [ \v!header=>\let\@@pagenumbervlocation\v!header,
- \v!footer=>\let\@@pagenumbervlocation\v!footer,
- \v!middle=>\let\@@pagenumberhlocation\v!text \let\@@pagenumberxlocation\c!middletext,
- \v!left=>\let\@@pagenumberhlocation\v!text \let\@@pagenumberxlocation\c!lefttext,
- \v!right=>\let\@@pagenumberhlocation\v!text \let\@@pagenumberxlocation\c!righttext,
- \v!inleft=>\let\@@pagenumberhlocation\v!margin\let\@@pagenumberxlocation\c!lefttext,
- \v!inright=>\let\@@pagenumberhlocation\v!margin\let\@@pagenumberxlocation\c!righttext,
- \v!inmargin=>\let\@@pagenumberhlocation\v!margin\def\@@pagenumberxlocation{\ifdoublesided\c!margintext\else\c!righttext\fi},
- \v!margin=>\let\@@pagenumberhlocation\v!margin\def\@@pagenumberxlocation{\ifdoublesided\c!margintext\else\c!righttext\fi},
- \v!atmargin=>\let\@@pagenumberhlocation\v!text \let\@@pagenumberxlocation\c!marginedgetext,
- \v!marginedge=>\let\@@pagenumberhlocation\v!text \let\@@pagenumberxlocation\c!marginedgetext]%
- \normalexpanded{\noexpand\setspecificlayouttext
- {\@@pagenumbervlocation}{\@@pagenumberhlocation}{\@@pagenumberxlocation}%
- {\noexpand\doplacepagenumberatlocation{\number\currentpagenumberlocation}}}%
- \fi}
-
-\def\setspecificlayouttext#1#2#3#4{\setvalue{\??tk#1#2#3}{#4}} % weird place
-
-\appendtoks
- \dosetpagenumberlocation
-\to \everyinitializepagecounters
-
-\def\doplacepagenumberatlocation#1%
- {\ifnum#1=\currentpagenumberlocation\relax\expandafter\placelocationpagenumber\fi}
% Rendering:
@@ -372,7 +341,11 @@
{\ifnum\userpagenumberstate=\plustwo
\ifnum\overallpagenumberstate=\plusone
\doif\@@nmstrut\v!yes\strut
- \@@nmcommand{\doattributes\??nm\c!style\c!color{\@@nmleft\labeltexts\v!pagenumber{\prefixedpagenumber}\@@nmright}}%
+ \begingroup
+ \dousestyleparameter\@@nmstyle
+ \dousecolorparameter\@@nmcolor
+ \@@nmcommand{\@@nmleft\labeltexts\v!pagenumber{\prefixedpagenumber}\@@nmright}%
+ \endgroup
\fi
\fi}
diff --git a/tex/context/base/strc-prc.lua b/tex/context/base/strc-prc.lua
deleted file mode 100644
index b1a1fb0a9..000000000
--- a/tex/context/base/strc-prc.lua
+++ /dev/null
@@ -1,9 +0,0 @@
-if not modules then modules = { } end modules ['strc-prc'] = {
- version = 1.001,
- comment = "companion to strc-prc.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- code will move from strc-ini to here
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi
index dfb31d066..b80016e52 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/tex/context/base/strc-ref.mkvi
@@ -995,11 +995,11 @@
\edef\currentreferenceformattype {\referenceformatparameter\c!type }%
\edef\currentreferenceformatsetups {\referenceformatparameter\c!setups }%
\edef\currentreferenceformatautocase{\referenceformatparameter\c!autocase}%
- \dosetreferenceformatattributes \c!style \c!color
- \ifx\fontattributehash\empty \else
+ \usereferenceformatstyleandcolor\c!style\c!color
+ \ifx\currentstyleparameter\empty \else
\resetinteractionparameter\c!style
\fi
- \ifx\colorattributehash\empty \else
+ \ifx\currentcolorparameter\empty \else
\resetinteractionparameter\c!contrastcolor
\resetinteractionparameter\c!color
\fi
@@ -1358,8 +1358,8 @@
\unexpanded\def\url[#label]% move \hyphenatedurl to lua end (is already lua)
{\dontleavehmode
\begingroup
- \dosetfontattribute\??ur\c!style
- \dosetcolorattribute\??ur\c!color
+ \dousestyleparameter\@@urstyle
+ \dousecolorparameter\@@urcolor
\hyphenatedurl{\ctxcommand{geturl("#label")}}%
\endgroup}
@@ -1397,8 +1397,8 @@
{#content}
\def\dofromurlliteral#content% called at the lua end
- {\dosetfontattribute \??ur\c!style
- \dosetcolorattribute\??ur\c!color
+ {\dousestyleparameter\@@urstyle
+ \dousecolorparameter\@@urcolor
\hyphenatedurl{#content}}
\let\dofromfiledescription\dofromurldescription
@@ -1441,8 +1441,8 @@
\def\program[#name]% incompatible, more consistent, hardy used anyway
{\dontleavehmode
\begingroup
- \dosetfontattribute\??pr\c!style
- \dosetcolorattribute\??pr\c!color
+ \dousestyleparameter\@@prstyle
+ \dousecolorparameter\@@prcolor
\ctxlua{structures.references.programs.get("#name","\@@pralternative","\@@prspace")}%
\endgroup}
diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua
index 523309a5f..6da58345b 100644
--- a/tex/context/base/strc-reg.lua
+++ b/tex/context/base/strc-reg.lua
@@ -24,13 +24,13 @@ local helpers = structures.helpers
local sections = structures.sections
local documents = structures.documents
local pages = structures.pages
-local processors = structures.processors
local references = structures.references
local mappings = sorters.mappings
local entries = sorters.entries
local replacements = sorters.replacements
+local processors = typesetters.processors
local splitprocessor = processors.split
local variables = interfaces.variables
diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv
index 4871b40ce..35f764a75 100644
--- a/tex/context/base/strc-reg.mkiv
+++ b/tex/context/base/strc-reg.mkiv
@@ -46,7 +46,9 @@
% \index[pageclass::] {textclass::entry}
% \index[pageclass::key]{textclass::entry}
-%D Parameters:
+%D Parameters ... we set up levels so we need a slightly different command handler here .. okay, we
+%D can use the childs for that ... but then we need to tweak the name in order to distinguis:
+%D register -> register:1 (i.e. prefix)
\let\currentregister\empty
@@ -63,11 +65,11 @@
\def\doregisterparentparameter #1#2{\ifx#1\relax\s!empty\else\doregisterparameter #1{#2}\fi}
\def\doregisterparentparameterhash#1#2{\ifx#1\relax \else\doregisterparameterhash#1{#2}\fi}
-\def\dosetregisterattributes#1#2% style color
- {\edef\fontattributehash {\registerparameterhash#1}%
- \edef\colorattributehash{\registerparameterhash#2}%
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
+\def\useregisterstyleandcolor#1#2% style color
+ {\edef\currentstyleparameter{\registerparameter#1}%
+ \edef\currentcolorparameter{\registerparameter#2}%
+ \ifx\currentstyleparameter\empty\else\dousestyleparameter\currentstyleparameter\fi
+ \ifx\currentcolorparameter\empty\else\dousecolorparameter\currentcolorparameter\fi}
%D Setup:
@@ -538,10 +540,10 @@
{\iffirstargument
\begingroup
\edef\currentregister{#1}%
- % the expansion is needed because we don't want \v!'s in the tuo file (french)
- \normalexpanded{\systemsuppliedchapter[\currentregister]{\noexpand\headtext{\currentregister}}}%
+ \normalexpanded{\startnamedsection[\v!chapter][\c!title={\headtext{\currentregister}},reference=\currentregister]}%
\placeregister[\currentregister][#2]%
\page[\v!yes]%
+ \stopnamedsection
\endgroup
\fi}
@@ -597,7 +599,7 @@
{\registerparameter\c!before
% bugged, why does leftskip gets set: \vskip\lineheight\goodbreak\vskip-\lineheight
\begingroup
- \dosetregisterattributes\c!style\c!color
+ \useregisterstyleandcolor\c!style\c!color
\dontleavehmode
\strut
\iflocation
@@ -614,7 +616,7 @@
\setvalue{\??id:\c!indicator:b}#1% will be shared with a
{\registerparameter\c!before
\begingroup
- \dosetregisterattributes\c!style\c!color
+ \useregisterstyleandcolor\c!style\c!color
\dontleavehmode
\strut
\iflocation
@@ -651,7 +653,7 @@
{\endgraf
\begingroup
\dostarttagged\t!registerentries\empty
- \dosetregisterattributes\c!textstyle\c!textcolor
+ \useregisterstyleandcolor\c!textstyle\c!textcolor
\advance\leftskip\numexpr#1-1\relax\dimexpr\registerparameter\c!distance\relax
\hangindent\registerparameter\c!distance\hangafter\plusone}
@@ -676,7 +678,7 @@
{\begingroup
\dostarttagged\t!registerpages\empty
\setfalse\registerpagedone
- \dosetregisterattributes\c!pagestyle\c!pagecolor}
+ \useregisterstyleandcolor\c!pagestyle\c!pagecolor}
\unexpanded\def\stopregisterpages
{\dostoptagged
@@ -687,7 +689,7 @@
\begingroup
\setfalse\registerpagedone
\dostarttagged\t!registerpage\empty
- \dosetregisterattributes\c!pagestyle\c!pagecolor}
+ \useregisterstyleandcolor\c!pagestyle\c!pagecolor}
\unexpanded\def\stopregisterseewords
{\dostoptagged
diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv
index b212f5b39..c08db36d5 100644
--- a/tex/context/base/strc-ren.mkiv
+++ b/tex/context/base/strc-ren.mkiv
@@ -31,37 +31,37 @@
\edef\askedheadinterlinespace{\headparameter\c!interlinespace}%
\ifx\askedheadinterlinespace\empty
% here the interline space is only set when style sets no space
- \setfalse\fontattributeisset
+ \setfalse\fontattributeisset % use the currentfontparameter state instead
\setfalse\interlinespaceisset
- \dosetheadattributes\c!style\c!color
+ \useheadstyleandcolor\c!style\c!color
\ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else
\setupinterlinespace
\fi \fi
- \setfalse\fontattributeisset \dosetheadattributes#1#2%
+ \setfalse\fontattributeisset \useheadstyleandcolor#1#2%
\ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else
\setupinterlinespace
\fi \fi
\else
% here the set interline space overloads any other set space in the style
\setfalse\fontattributeisset
- \dosetheadattributes\c!style\c!color
+ \useheadstyleandcolor\c!style\c!color
\ifconditional\fontattributeisset
\dosetupcheckedinterlinespace\askedheadinterlinespace
\fi
\setfalse\fontattributeisset
- \dosetheadattributes#1#2%
+ \useheadstyleandcolor#1#2%
\ifconditional\fontattributeisset
\dosetupcheckedinterlinespace\askedheadinterlinespace
\fi
\fi
\else
\setfalse\fontattributeisset
- \dosetheadattributes\c!style\c!color
+ \useheadstyleandcolor\c!style\c!color
\ifconditional\fontattributeisset
\setupspacing
\fi
\setfalse\fontattributeisset
- \dosetheadattributes#1#2%
+ \useheadstyleandcolor#1#2%
\ifconditional\fontattributeisset
\setupspacing
\fi
@@ -154,7 +154,7 @@
\setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \headreferenceattributes
{\dosetlocalgridsnapping{\headparameter\c!internalgrid}%
\doresettructureheadnumbercontent
- \dosetheadfontattribute\c!style
+ \useheadstyleparameter\c!style
\setinlineheadreferenceattributes
\headparameter\c!command{}{\doplaceheadtextcomponent\getheadtitle}}%
\fi
@@ -171,7 +171,7 @@
\docheckheadreference
\setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \headreferenceattributes
{\dosetlocalgridsnapping{\headparameter\c!internalgrid}%
- \dosetheadfontattribute\c!style
+ \useheadstyleparameter\c!style
\setinlineheadreferenceattributes
\headparameter\c!command{\doplaceheadnumbercomponent\getheadnumber}{\doplaceheadtextcomponent\getheadtitle}}%
\fi
@@ -296,9 +296,9 @@
\edef\currentheadgridsnapping{\headparameter\c!grid}%
\ifconditional\headisdisplay
\ifx\currentheadgridsnapping\empty\else
- \dosetheadattributes\c!style\c!color
+ \useheadstyleandcolor\c!style\c!color
\setupinterlinespace
- \dosetheadattributes\c!textstyle\c!textcolor
+ \useheadstyleandcolor\c!textstyle\c!textcolor
\setupinterlinespace
\fi
\fi
diff --git a/tex/context/base/strc-rsc.lua b/tex/context/base/strc-rsc.lua
index aa969569a..a90f577e3 100644
--- a/tex/context/base/strc-rsc.lua
+++ b/tex/context/base/strc-rsc.lua
@@ -104,8 +104,8 @@ references.splitcomponent = splitcomponent
-- test code:
-- inspect(splitreference([[component:::inner]]))
--- print(splitprefix([[component:::inner]]))
--- print(splitprefix([[component:inner]]))
+-- inspect(splitprefix([[component:::inner]]))
+-- inspect(splitprefix([[component:inner]]))
-- inspect(splitreference([[ ]]))
-- inspect(splitreference([[ inner ]]))
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index 1747031fc..7216bf162 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -131,6 +131,20 @@
{\setevalue\currenthead{\dohandleheadnop[\currenthead]}}%
\to \everysetuphead
+\let\currentnamedsection\empty
+
+\unexpanded\def\startnamedsection
+ {\dotripleempty\startnamedsection}
+
+\def\dostartnamedsection[#1]% [#2][#3]
+ {\pushmacro\currentnamedsection
+ \edef\currentnamedsection{#1}%
+ \dostarthead[#1]} % [#2][#3]
+
+\unexpanded\def\stopnamedsection
+ {\normalexpanded{\dostophead[\currentnamedsection]}%
+ \popmacro\currentnamedsection}
+
% structure sections (the parents of chapter etc)
\let\firstsectionname\empty
@@ -336,6 +350,8 @@
{\setfalse\headisdisplay}
{\settrue \headisdisplay}}
+\newmode\v!sectionnumber
+
\def\dosettructureheadnumbercontent
{\setsystemmode \v!sectionnumber
\settrue\headshownumber} % why ?
@@ -361,7 +377,7 @@
% {\normalexpanded{\noexpand\setmarking[\currenthead]{\currentstructurelistnumber}}}
\unexpanded\def\setheadmarking % li:: so that we can use \marking[section]{Taco needed this}
- {\normalexpanded{\noexpand\setmarking[\currenthead]{li::\currentstructurelistnumber}}}
+ {\normalexpanded{\setmarking[\currenthead]{li::\currentstructurelistnumber}}}
\let\deepstructurenumbercommand\relax
\let\deepstructuretitlecommand \relax
@@ -433,8 +449,8 @@
\unexpanded\def\setupheadcomponentfont#1#2%
{\dontconvertfont
- \dosetheadattributes\c!style\c!color
- \dosetheadattributes#1#2%
+ \useheadstyleandcolor\c!style\c!color
+ \useheadstyleandcolor#1#2%
\setupinterlinespace}
\fi
diff --git a/tex/context/base/strc-syn.mkiv b/tex/context/base/strc-syn.mkiv
index 571eccd8e..7a9d5d3dd 100644
--- a/tex/context/base/strc-syn.mkiv
+++ b/tex/context/base/strc-syn.mkiv
@@ -51,35 +51,9 @@
\globallet#3\s!tex
\fi}
-\let\currentsynonym\empty
+\installsimplecommandhandler \??sm {synonym} \??sm
-\def\synonymparameter #1{\csname\dosynonymparameter{\??sm\currentsynonym}#1\endcsname}
-\def\synonymparameterhash#1{\dosynonymparameterhash {\??sm\currentsynonym}#1}
-
-\def\dosynonymparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dosynonymparentparameter \csname#1\s!parent\endcsname#2\fi}
-\def\dosynonymparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\dosynonymparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-
-\def\dosynonymparentparameter #1#2{\ifx#1\relax\s!empty\else\dosynonymparameter #1#2\fi}
-\def\dosynonymparentparameterhash#1#2{\ifx#1\relax \else\dosynonymparameterhash#1#2\fi}
-
-\unexpanded\def\dosetsynonymattributes#1#2% style color
- {\edef\fontattributehash {\synonymparameterhash#1}%
- \edef\colorattributehash{\synonymparameterhash#2}%
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
-
-\newtoks\everysetupsynonyms
-
-\unexpanded\def\setupsynonyms
- {\dodoubleargument\dosetupsynonyms}
-
-\def\dosetupsynonyms[#1][#2]%
- {\ifsecondargument
- \getparameters[\??sm#1][#2]%
- \else
- \getparameters[\??sm][#1]%
- \fi
- \the\everysetupsynonyms}
+\let\setupsynonyms\setupsynonym
\setupsynonyms
[\c!state=\v!start,
@@ -106,7 +80,8 @@
{\doquadrupleempty\dodefinesynonyms}
\def\dodefinesynonyms[#1][#2][#3][#4]% name plural \meaning \use
- {\iffourthargument
+ {\edef\currentsynonym{#1}%
+ \iffourthargument
\unexpanded\def#4##1{\doinsertsynonym{#1}{##1}}% name tag
\ifthirdargument
\unexpanded\def#3##1{\doinsertsynonymmeaning{#1}{##1}}% \meaning
@@ -118,10 +93,10 @@
\fi
\setuvalue{#1}{\definesynonym[\v!yes][#1]}% \name
\fi
- \getparameters[\??sm#1][\s!parent=\??sm,\s!single={#1},\s!multi={#2}]%
+ \checksynonymparent
+ \setupcurrentsynonym[\s!single={#1},\s!multi={#2}]%
\presetheadtext[#2=\Word{#2}]% changes the \if...argument
- %\ctxlua{structures.synonyms.define('#1')}%
- \setvalue{\e!setup #2\e!endsetup}{\dodoubleargument\getparameters[\??sm#1]}% to be obsolete
+ \setvalue{\e!setup #2\e!endsetup}{\setupsynonym[#1]}% obsolete definition
\setvalue{\e!place \e!listof#2}{\placelistofsynonyms[#1]}% accepts extra argument
\setvalue{\e!complete\e!listof#2}{\completelistofsynonyms[#1]}}
@@ -167,7 +142,7 @@
\unexpanded\def\doinsertsynonymmeaning#1#2% name tag
{\begingroup
\def\currentsynonym{#1}%
- \dosetsynonymattributes\c!textstyle\c!textcolor
+ \usesynonymstyleandcolor\c!textstyle\c!textcolor
\synonymparameter\c!textcommand{\ctxlua{structures.synonyms.meaning("#1","#2")}}%
\endgroup}
@@ -177,7 +152,7 @@
\def\currentsynonymtag{#2}%
\dostarttagged\t!synonym\currentsynonym
\dotagsynonym
- \dosetsynonymattributes\c!synonymstyle\c!synonymcolor
+ \usesynonymstyleandcolor\c!synonymstyle\c!synonymcolor
\synonymparameter\c!synonymcommand{\ctxlua{structures.synonyms.synonym("#1","#2")}}%
\dostoptagged
\normalexpanded{\endgroup\synonymparameter\c!next}}
@@ -200,8 +175,6 @@
\c!inbetween=\synonymparameter\c!inbetween,
\c!after=\synonymparameter\c!after,
\c!indentnext=\synonymparameter\c!indentnext,
-% \c!headstyle=\synonymparameter\c!headstyle,
-% \c!headcolor=\synonymparameter\c!headcolor,
\c!headstyle=\synonymparameter\c!textstyle,
\c!headcolor=\synonymparameter\c!textcolor,
\c!style=,
@@ -221,9 +194,10 @@
\def\docompletelistofsynonyms[#1][#2]%
{\edef\currentsynonym{#1}%
- \normalexpanded{\systemsuppliedchapter[#1]{\noexpand\headtext{\synonymparameter\s!multi}}}%
+ \normalexpanded{\startnamedsection[\v!chapter][\c!title={\headtext{\synonymparameter\s!multi}},\c!reference=#1]}%
\doplacelistofsynonyms[#1][#2]%
- \page[\v!yes]}
+ \page
+ \stopnamedsection}
\let\startsynonymoutput \relax
\let\stopsynonymoutput \relax
@@ -231,41 +205,11 @@
\let\stopsynonymsection \relax
\unexpanded\def\synonymentry#1#2#3#4%
-% {\syndef{\dosetsynonymattributes\c!textstyle\c!textcolor#2}#3\par}
-% {\startsyndef{#2}#3\stopsyndef}
{\syndef{#3}#4\par}
-
-\let\currentsorting\empty
-
-% we can share if we also have synonymprefix = so
-
-\def\sortingparameter #1{\csname\dosortingparameter{\??so\currentsorting}#1\endcsname}
-\def\sortingparameterhash#1{\dosortingparameterhash {\??so\currentsorting}#1}
-\def\dosortingparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dosortingparentparameter \csname#1\s!parent\endcsname#2\fi}
-\def\dosortingparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\dosortingparentparameterhash\csname#1\s!parent\endcsname#2\fi}
+%D Sorting (a simplified version of synonym).
-\def\dosortingparentparameter #1#2{\ifx#1\relax\s!empty\else\dosortingparameter #1#2\fi}
-\def\dosortingparentparameterhash#1#2{\ifx#1\relax \else\dosortingparameterhash#1#2\fi}
-
-\def\dosetsortingattributes#1#2% style color
- {\edef\fontattributehash {\sortingparameterhash#1}%
- \edef\colorattributehash{\sortingparameterhash#2}%
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
-
-\newtoks\everysetupsorting
-
-\unexpanded\def\setupsorting
- {\dodoubleargument\dosetupsorting}
-
-\def\dosetupsorting[#1][#2]%
- {\ifsecondargument
- \getparameters[\??so#1][#2]%
- \else
- \getparameters[\??so][#1]%
- \fi
- \the\everysetupsorting}
+\installsimplecommandhandler \??so {sorting} \??so
\setupsorting
[\c!state=\v!start,
@@ -284,7 +228,8 @@
% if #3=\relax or \v!none, then no command but still protected
\def\dodefinesorting[#1][#2][#3]%
- {\ifthirdargument
+ {\edef\currentsorting{#1}%
+ \ifthirdargument
\doifnot{#3}\v!none
{\ifx#3\relax \else
\unexpanded\def#3##1{\doinsertsort{#1}{##1}}%
@@ -293,10 +238,10 @@
\else
\setuvalue{#1}{\definesort[\v!yes][#1]}%
\fi
- \getparameters[\??so#1][\s!parent=\??so,\s!multi={#2}]%
+ \checksortingparent
+ \setupcurrentsorting[\s!multi={#2}]%
\presetheadtext[#2=\Word{#2}]% after \ifthirdargument -)
- %\ctxlua{structures.synonyms.define('#1')}%
- \setvalue{\e!setup #2\e!endsetup}{\dodoubleargument\getparameters[\??so#1]}% to be obsolete
+ \setvalue{\e!setup #2\e!endsetup}{\setupsorting[#1]}% obsolete definition
\setvalue{\e!place \e!listof#2}{\placelistofsorts[#1]}%
\setvalue{\e!complete\e!listof#2}{\completelistofsorts[#1]}}
@@ -338,7 +283,7 @@
\def\currentsortingtag{#2}%
\dostarttagged\t!sorting\currentsorting
\dotagsorting
- \dosetsortingattributes\c!style\c!color
+ \usesortingstyleandcolor\c!style\c!color
\ctxlua{structures.synonyms.synonym("#1","#2")}%
\dostoptagged
\normalexpanded{\endgroup\sortingparameter\c!next}}
@@ -374,9 +319,10 @@
\def\docompletelistofsorts[#1][#2]%
{\edef\currentsorting{#1}%
- \normalexpanded{\systemsuppliedchapter[#1]{\noexpand\headtext{\sortingparameter\s!multi}}}%
+ \normalexpanded{\startnamedsection[\v!chapter][\c!title={\headtext{\sortingparameter\s!multi}},\c!reference=#1]}%
\doplacelistofsorts[#1][#2]%
- \page[\v!yes]}
+ \page
+ \stopnamedsection}
\let\startsortingoutput \relax
\let\stopsortingoutput \relax
@@ -385,42 +331,8 @@
\def\sortingentry#1#2#3#4% #4 is meaning but empty here
{\doifelsenothing{\sortingparameter\c!command}
- {\begingroup\dosetsortingattributes\c!style\c!color#3\endgroup\par} % todo
+ {\begingroup\usesortingstyleandcolor\c!style\c!color#3\endgroup\par} % todo
{\sortingparameter\c!command{#1}{#2}{#3}}}
-
-%D Here we define a support macro that can sort simple comma
-%D separated lists. It's a multi-list variant of a prototype
-%D written by Taco.
-
-% \def\mkloadsortedlist#1% class
-% {\bgroup
-% \getvalue{\s!set#1}%
-% \ctxlua{structures.synonyms.process('#1')}%
-% \getvalue{\s!reset#1}%
-% \egroup}
-
-% \def\processlistofsorts[#1]%
-% {\mkloadsortedlist{#1}}
-
-% \newcounter\nofsortedalphalists
-
-% \def\sortalphacommacommand#1%
-% {\begingroup
-% \doglobal\increment\nofsortedalphalists
-% \edef\currentsortedalphalist{alpha:\nofsortedalphalists}%
-% \definesorting[\currentsortedalphalist][\currentsortedalphalist]%
-% \processcommacommand[#1]{\getvalue\currentsortedalphalist}%
-% \global\let\sortedcommalist\empty
-% \def\makesortedlist##1{\doglobal\appendtocommalist{##1}\sortedcommalist}%
-% \setupsorting[\currentsortedalphalist][\c!criterium=\v!all,\c!command=\makesortedlist]%
-% \processlistofsorts[\currentsortedalphalist]%
-% \endgroup
-% \dodoglobal\let#1\sortedcommalist}
-
-% \starttext
-% \def\whatever{a,b,q,d,r,f} \sortalphacommacommand\whatever \whatever \endgraf
-% \def\whatever{ax,bx,qx,dx,rx,fx} \sortalphacommacommand\whatever \whatever \endgraf
-% \stoptext
%D Presets.
@@ -436,17 +348,6 @@
\definesorting
[\v!logo]
[\v!logos]
- % no [\logogram]
-
-% As we now have \unit in the core, this now happens in m-units:
-%
-% \definesynonyms
-% [\v!unit]
-% [\v!units]
-% [\unitmeaning]
-%
-% \setupsynonyms
-% [\v!unit]
-% [\c!synonymcommand=\dimension]
+% [\logogram] % no
\protect \endinput
diff --git a/tex/context/base/strc-tag.mkiv b/tex/context/base/strc-tag.mkiv
index 335065c8b..7c4042348 100644
--- a/tex/context/base/strc-tag.mkiv
+++ b/tex/context/base/strc-tag.mkiv
@@ -142,11 +142,11 @@
\definesystemattribute[tagged][public]
\definesystemattribute[image] [public]
-\def\setelementbackendtag{\dodoubleargument\dosetelementbackendtag}
-\def\setelementnature {\dodoubleargument\dosetelementnature}
+\unexpanded\def\setelementbackendtag{\dodoubleargument\dosetelementbackendtag}
+\unexpanded\def\setelementnature {\dodoubleargument\dosetelementnature}
-\def\dosetelementbackendtag[#1][#2]{\ctxcommand{settagproperty("#1","backend","#2")}}
-\def\dosetelementnature [#1][#2]{\ctxcommand{settagproperty("#1","nature", "#2")}}
+\unexpanded\def\dosetelementbackendtag[#1][#2]{\ctxcommand{settagproperty("#1","backend","#2")}}
+\unexpanded\def\dosetelementnature [#1][#2]{\ctxcommand{settagproperty("#1","nature", "#2")}}
% todo: indirect macro for trialtypesetting
@@ -165,11 +165,11 @@
\unexpanded\def\dodostopelement
{\ctxcommand{stoptag()}}
+% beware: making this one unexpanded spoils tables (noalign problem)
+
\unexpanded\def\nonostartelement[#1][#2]{}
\unexpanded\def\nonostopelement {}
-% beware: making this one unexpanded spoils tables (noalign problem)
-
\def\dodostarttagged{\iftrialtypesetting\expandafter\nododostarttagged\else\expandafter\dododostarttagged\fi}
\def\dodostoptagged {\iftrialtypesetting\expandafter\nododostoptagged \else\expandafter\dododostoptagged \fi}
@@ -185,26 +185,28 @@
\def\nododostarttagged#1#2{}
\def\nododostoptagged {}
+% end of beware
+
\newtoks\everysetupstructure
-\def\setupstructure[#1]%
+\unexpanded\def\setupstructure[#1]%
{\getparameters[\??el][#1]%
\the\everysetupstructure}
-\def\doenableelements
+\unexpanded\def\doenableelements
{\setuplanguage[\s!default][\s!righthyphenchar="AD]% for the moment here
\let\startelement\dostartelement
\let\stopelement \dostopelement}
-\def\dodisableelements
+\unexpanded\def\dodisableelements
{\let\startelement\renostartelement
\let\stopelement \nonostopelement}
-\def\doenabletagged
+\unexpanded\def\doenabletagged
{\let\dostarttagged\dodostarttagged
\let\dostoptagged \dodostoptagged }
-\def\dodisabletagged
+\unexpanded\def\dodisabletagged
{\let\dostarttagged\nododostarttagged
\let\dostoptagged \nododostoptagged }
@@ -248,14 +250,19 @@
\dostoptagged
\to \everystoptext
+\appendtoks
+ \dodisableelements
+ \dodisabletagged
+\to \everypagebody
+
% \doifinelementelse{structure:section} {yes} {no}
% \doifinelementelse{structure:chapter} {yes} {no}
% \doifinelementelse{division:*-structure:chapter} {yes} {no}
-\def\doifinelementelse#1%
+\unexpanded\def\doifinelementelse#1%
{\ctxcommand{testcase(structures.atlocation("#1"))}}
-\def\taggedlabeltexts#1#2#3% experimental: label, numberdetail, numbercontent
+\unexpanded\def\taggedlabeltexts#1#2#3% experimental: label, numberdetail, numbercontent
{\begingroup
\dostarttagged\t!label{#1}%
\labeltexts{#1}%
@@ -267,7 +274,7 @@
\dostoptagged
\endgroup}
-\def\namedtaggedlabeltexts#1#2#3#4#5% experimental: labeltag label numbertag numberdetail numbercontent
+\unexpanded\def\namedtaggedlabeltexts#1#2#3#4#5% experimental: labeltag label numbertag numberdetail numbercontent
{\begingroup
\dostarttagged{#1}{#2}%
\labeltexts{#2}%
@@ -298,7 +305,7 @@
%D \stoptext
%D \stoptyping
-\def\settaggedmetadata[#1]%
+\unexpanded\def\settaggedmetadata[#1]%
{\ctxlua{structures.tags.registermetadata(\!!bs#1\!!es)}}
\protect
diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv
index a874ae43b..f261bbb9b 100644
--- a/tex/context/base/supp-box.mkiv
+++ b/tex/context/base/supp-box.mkiv
@@ -2328,7 +2328,6 @@
{\dorecurse5{\unskip\unkern\unpenalty}}
\unexpanded\def\removelastskip % \ifvmode the plain tex one \fi
-% {\ifvmode\ifdim\lastskip=\zeropoint\else\vskip-\lastskip\fi\fi}
{\ifvmode\ifzeropt\lastskip\else\vskip-\lastskip\fi\fi}
%D \macros
@@ -2381,8 +2380,8 @@
%D New:
-\def\setdimentoatleast#1#2%
- {\ifdim#1>\zeropoint\else#1=#2\fi}
+\def\setdimentoatleast#1#2{\ifdim#1>\zeropoint\else#1=#2\fi}
+\def\setdimentoatmost #1#2{\ifdim#1>#2\relax \else#1=#2\fi}
%D And even rawer:
diff --git a/tex/context/base/supp-mat.mkiv b/tex/context/base/supp-mat.mkiv
index 9049472bd..e4cfd13e5 100644
--- a/tex/context/base/supp-mat.mkiv
+++ b/tex/context/base/supp-mat.mkiv
@@ -61,29 +61,32 @@
\let\startdmath \Ustartdisplaymath % obsolete, less safe
\let\stopdmath \Ustopmath % obsolete, less safe
-\long\def\mathematics#1{\relax \ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
-\long\def\displaymath#1{\noindent \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi}
-\long\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
+\unexpanded\def\mathematics#1{\relax \ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
+\unexpanded\def\displaymath#1{\noindent \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi}
+\unexpanded\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
+\unexpanded\def\textmath #1{\dontleavehmode\ifmmode#1\else\begingroup\everymath\emptytoks\normalstartimath#1\normalstopimath\endgroup\fi} % \mathsurround\zeropoint
\let\m\mathematics % unexpanded?
\let\stopmathmode\relax
-\unexpanded\def\startmathmode % cannot be used nested
- {\relax\ifmmode
- \let\stopmathmode\relax
- \else
- \normalstartimath\let\stopmathmode\normalstopimath
- \fi}
+% \unexpanded\def\startmathmode % cannot be used nested
+% {\relax\ifmmode
+% \let\stopmathmode\relax
+% \else
+% \normalstartimath\let\stopmathmode\normalstopimath
+% \fi}
\unexpanded\def\startmathmode % nested variant
{\relax\ifmmode
- \begingroup\let\stopmathmode\endgroup
+ \begingroup
+ \let\stopmathmode\endgroup
\else
- \normalstartimath\let\stopmathmode\normalstopimath
+ \normalstartimath
+ \let\stopmathmode\normalstopimath
\fi}
-\def\nomathematics#1%
+\unexpanded\def\nomathematics#1%
{\relax\ifmmode\hbox{#1}\else#1\fi}
\let\math\mathematics
diff --git a/tex/context/base/symb-imp-mis.mkiv b/tex/context/base/symb-imp-mis.mkiv
index 1037ba542..d2657512f 100644
--- a/tex/context/base/symb-imp-mis.mkiv
+++ b/tex/context/base/symb-imp-mis.mkiv
@@ -16,17 +16,18 @@
%D We predefine some common symbols and conversions that will
%D be understood by many commands. The \type {\mathematics}
%D is no longer needed, although only math fonts might have
-%D these symbols.
+%D these symbols. The \type {\textmath} macro is twice as
+%D efficient.
\definesymbol [\v!none] []
-\definesymbol [bullet] [\mathematics{\bullet}]
-\definesymbol [dash] [\mathematics{-}]
-\definesymbol [star] [\mathematics{\star}]
-\definesymbol [triangle] [\mathematics{\triangleright}]
-\definesymbol [circle] [\mathematics{\circ}]
-\definesymbol [square] [\mathematics{\square}]
-\definesymbol [diamond] [\mathematics{\diamond}]
+\definesymbol [bullet] [\textmath\bullet]
+\definesymbol [dash] [\textmath-]
+\definesymbol [star] [\textmath\star]
+\definesymbol [triangle] [\textmath\triangleright]
+\definesymbol [circle] [\textmath\circ]
+\definesymbol [square] [\textmath\square]
+\definesymbol [diamond] [\textmath\diamond]
% I'm not sure about this ... I dislike the small bullet. So we provide
% it as variant: \type {\setupsymbolset[text]}. Also, we want to be
@@ -49,9 +50,9 @@
\stopsymbolset
-\definesymbol [smallcircle] [\hbox{\raise.1ex\hbox{\mathematics{\scriptscriptstyle\bigcirc}}}]
-\definesymbol [medcircle] [\hbox{\raise.1ex\hbox{\mathematics{\scriptstyle \bigcirc}}}]
-\definesymbol [bigcircle] [\mathematics{\bigcirc}]
+\definesymbol [smallcircle] [\hbox{\raise.1ex\hbox{\textmath{\scriptscriptstyle\bigcirc}}}]
+\definesymbol [medcircle] [\hbox{\raise.1ex\hbox{\textmath{\scriptstyle \bigcirc}}}]
+\definesymbol [bigcircle] [\textmath{\bigcirc}]
\definesymbol [1] [\symbol{bullet}]
\definesymbol [2] [\symbol{dash}]
diff --git a/tex/context/base/symb-ini.mkiv b/tex/context/base/symb-ini.mkiv
index 182840ed5..c58429074 100644
--- a/tex/context/base/symb-ini.mkiv
+++ b/tex/context/base/symb-ini.mkiv
@@ -84,13 +84,16 @@
\newif\ifnosymbol \newtoks\everysymbol
\def\dodosymbol#1#2% \relax's prevent lookahead problems
- {\nosymbolfalse{\the\everysymbol\csname\??ss:#1:#2\endcsname\relax}\relax}
+ {\nosymbolfalse
+ \begingroup
+ \the\everysymbol
+ \csname\??ss:#1:#2\endcsname\relax
+ \endgroup}
\letvalue{\??ss:}\firstofoneargument
\def\directsymbol#1#2% no \relax, there can be an argument, see lists
- {%\executeifdefined{\??ss:#1:#2}\firstofoneargument}
- \csname\??ss:\ifcsname\??ss:#1:#2\endcsname#1:#2\fi\endcsname}
+ {\csname\??ss:\ifcsname\??ss:#1:#2\endcsname#1:#2\fi\endcsname}
% We support both:
%
@@ -109,11 +112,15 @@
\secondargumentfalse
\donormalsymbol[#3][]}
+% \doifinsymbolset{#1}{#2}{\dodosymbol{#1}{#2}}
+
\def\donormalsymbol[#1][#2]%
{\nosymboltrue
\ifsecondargument
\edef\currentsymbol{#2}%
- \doifinsymbolset{#1}{#2}{\dodosymbol{#1}{#2}}%
+ \ifcsname\??ss:#1:#2\endcsname
+ \dodosymbol{#1}{#2}%
+ \fi
\else
\edef\currentsymbol{#1}%
\fi
@@ -124,13 +131,23 @@
\fi
\fi}
+% \doifinsymbolset{#1}\currentsymbol{\dodosymbol{#1}\currentsymbol}
+
\def\fetchsymbol#1%
{\ifnosymbol
- \doifinsymbolset{#1}\currentsymbol{\dodosymbol{#1}\currentsymbol}%
+ \ifcsname\??ss:#1:\currentsymbol\endcsname
+ \dodosymbol{#1}\currentsymbol
+ \fi
\fi}
+% \doifinsymbolsetelse\empty{#1}{\dodosymbol\empty}\firstofoneargument{#1}}
+
\def\redosymbol#1%
- {\doifinsymbolsetelse\empty{#1}{\dodosymbol\empty}\firstofoneargument{#1}}
+ {\ifcsname\??ss::#1\endcsname
+ \dodosymbol\empty{#1}%
+ \else
+ #1%
+ \fi}
%D \macros
%D {definefiguresymbol}
diff --git a/tex/context/base/syst-aux.lua b/tex/context/base/syst-aux.lua
index a585ed8b2..7fd25d6ab 100644
--- a/tex/context/base/syst-aux.lua
+++ b/tex/context/base/syst-aux.lua
@@ -6,12 +6,47 @@ if not modules then modules = { } end modules ['syst-aux'] = {
license = "see context related readme files"
}
+local settings_to_array = utilities.parsers.settings_to_array
+local concat = table.concat
+
+local setvalue = context.setvalue
+
function commands.getfirstcharacter(str)
local first, rest = utf.match(str,"(.?)(.*)$")
- context.setvalue("firstcharacter",first)
- context.setvalue("remainingcharacters",rest)
+ setvalue("firstcharacter",first)
+ setvalue("remainingcharacters",rest)
end
function commands.doiffirstcharelse(chr,str)
commands.doifelse(utf.sub(str,1,1) == chr)
end
+
+-- function commands.addtocommalist(list,item)
+-- if list == "" then
+-- context(item)
+-- else
+-- context("%s,%s",list,item) -- using tex.print is some 10% faster
+-- end
+-- end
+--
+-- function commands.removefromcommalist(list,item)
+-- if list == "" then
+-- context(item)
+-- else
+-- -- okay, using a proper lpeg is probably faster
+-- -- we could also check for #l = 1
+-- local l = settings_to_array(list)
+-- local t, n = { }
+-- for i=1,#l do
+-- if l[i] ~= item then
+-- n = n + 1
+-- t[n] = item
+-- end
+-- end
+-- if n == 0 then
+-- context(item)
+-- else
+-- context(concat(list,","))
+-- end
+-- end
+-- end
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index 74887a3bb..598813275 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -14,9 +14,11 @@
%D Some of the macros will move to syst-obs as they might become
%D obsolete once we've redone the bibliography module. Of course
%D the handy helpers will stay.
-
-% no longs
-% more unexpanded
+%D
+%D There are some references to \LUA\ variants here but these concern
+%D (often old) experiments, moved from local test modules to here,
+%D cleaned up, but not really used. After all it's not that urgent
+%D and replacing helpers is a delicate process. Don't depend on it.
\registerctxluafile{syst-aux}{1.001}
@@ -685,7 +687,7 @@
\def\re_do_if_in_set {\expandafter\do_check_if_item_in_set \!!stringb,],\relax}
\def\re_do_if_not_in_set {\expandafter\do_check_if_item_not_in_set \!!stringb,],\relax}
-\def\doifinsetelse#1% make this two step too
+\unexpanded\def\doifinsetelse#1% make this two step too
{\edef\!!stringa{#1}%
\ifx\!!stringa\empty
\expandafter\thirdofthreearguments
@@ -701,7 +703,7 @@
\expandafter\re_do_if_in_set_else
\fi}
-\def\doifinset#1%
+\unexpanded\def\doifinset#1%
{\edef\!!stringa{#1}%
\ifx\!!stringa\empty
\expandafter\gobbletwoarguments
@@ -717,7 +719,7 @@
\expandafter\re_do_if_in_set
\fi}
-\def\doifnotinset#1%
+\unexpanded\def\doifnotinset#1%
{\edef\!!stringa{#1}%
\ifx\!!stringa\empty
\expandafter\secondoftwoarguments
@@ -877,9 +879,9 @@
{\def\do_common_check{\expandafter\do_check_if_common_else_two\!!stringb,],\relax}%
\expandafter\do_check_if_common_else_one\!!stringa,],\relax}
-\def\doifcommonelse{\do_do_if_common_else\firstoftwoarguments\secondoftwoarguments}
-\def\doifcommon {\do_do_if_common_else\firstofoneargument \gobbleoneargument }
-\def\doifnotcommon {\do_do_if_common_else\gobbleoneargument \firstofoneargument }
+\unexpanded\def\doifcommonelse{\do_do_if_common_else\firstoftwoarguments\secondoftwoarguments}
+\unexpanded\def\doifcommon {\do_do_if_common_else\firstofoneargument \gobbleoneargument }
+\unexpanded\def\doifnotcommon {\do_do_if_common_else\gobbleoneargument \firstofoneargument }
%D \macros
%D {processcommalist,processcommacommand,quitcommalist,
@@ -3311,8 +3313,8 @@
% maybe reserve special zero and plusone
-\def\settrue #1{\let#1\zerocount}
-\def\setfalse#1{\let#1\plusone}
+\unexpanded\def\settrue #1{\let#1\zerocount}
+\unexpanded\def\setfalse#1{\let#1\plusone }
\let\newconditional\setfalse
\let\ifconditional \ifcase
@@ -4887,30 +4889,30 @@
%D
%D The faster alternatives are:
-\def\appendtocommalist#1#2%
+\unexpanded\def\appendtocommalist#1#2%
{\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}
-\def\prependtocommalist#1#2%
+\unexpanded\def\prependtocommalist#1#2%
{\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}
-\def\addtocommalist#1#2% {item} \cs
+\unexpanded\def\addtocommalist#1#2% {item} \cs
{\rawdoifinsetelse{#1}#2\resetglobal
{\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}}
-\def\pretocommalist#1#2% {item} \cs
+\unexpanded\def\pretocommalist#1#2% {item} \cs
{\rawdoifinsetelse{#1}#2\resetglobal
{\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}}
-\def\robustdoifinsetelse#1#2%
+\unexpanded\def\robustdoifinsetelse#1#2%
{\edef\!!stringa{\detokenize\expandafter{\normalexpanded{#1}}}%
\edef\!!stringb{\detokenize\expandafter{\normalexpanded{#2}}}%
\rawdoifinsetelse\!!stringa\!!stringb}
-\def\robustaddtocommalist#1#2% {item} \cs
+\unexpanded\def\robustaddtocommalist#1#2% {item} \cs
{\robustdoifinsetelse{#1}#2\resetglobal
{\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}}
-\def\robustpretocommalist#1#2% {item} \cs
+\unexpanded\def\robustpretocommalist#1#2% {item} \cs
{\robustdoifinsetelse{#1}#2\resetglobal
{\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}}
@@ -4924,7 +4926,7 @@
\def\bcleanedupcommalist#1#2\relax{\if#1,\else#1\fi#2}
\def\acleanedupcommalist#1,,#2\relax{#1}
-\def\removefromcommalist#1#2% to be sped up
+\unexpanded\def\removefromcommalist#1#2% to be sped up
{\rawdoifinsetelse{#1}#2%
{\normalexpanded{\noexpand\xsplitstring\noexpand#2{#1}}%
\dodoglobal\edef#2%
@@ -4935,6 +4937,12 @@
\fi}}
\resetglobal}
+% \unexpanded\def\addtocommalist#1#2% upto 3 times slower
+% {\dodoglobal\edef#2{\ctxcommand{addtocommalist(\!!bs#1\!!es,\!!bs#2\!!es)}}}
+%
+% \unexpanded\def\removefromcommalist#1#2% faster and more robust
+% {\dodoglobal\edef#2{\ctxcommand{addtocommalist(\!!bs#1\!!es,\!!bs#2\!!es)}}}
+
%D \macros
%D {substituteincommalist}
%D
@@ -5100,16 +5108,23 @@
\def\numberofpoints #1{\the\numexpr\dimexpr#1\relax/\maxcard\relax}
%D \macros
-%D {swapdimens,swapcounts,swapmacros}
+%D {swapdimens,swapcounts,swapmacros,
+%D globalswapdimens,globalswapcounts,globalswapmacros}
%D
%D Simple but effective are the next two macros. There name
-%D exactly states their purpose. The \type{\scratchdimen} and
-%D \type{\!!stringa} can only be swapped when being the first
-%D argument.
+%D exactly states their purpose.
-\def\swapdimens#1#2{\scratchdimen #1\redoglobal #1#2\dodoglobal #2\scratchdimen}
-\def\swapcounts#1#2{\scratchcounter#1\redoglobal #1#2\dodoglobal #2\scratchcounter}
-\def\swapmacros#1#2{\let\!!stringa #1\redoglobal\let#1#2\dodoglobal\let#2\!!stringa}
+\newdimen\swapped_dimen
+\newcount\swapped_count
+\let \swapped_macro\relax
+
+\unexpanded\def\swapdimens#1#2{\swapped_dimen #1\relax#1#2\relax#2\swapped_dimen}
+\unexpanded\def\swapcounts#1#2{\swapped_count #1\relax#1#2\relax#2\swapped_count}
+\unexpanded\def\swapmacros#1#2{\let\swapped_macro#1\let #1#2\let #2\swapped_macro}
+
+\unexpanded\def\globalswapdimens#1#2{\swapped_dimen #1\global #1#2\global #2\swapped_dimen}
+\unexpanded\def\globalswapcounts#1#2{\swapped_count #1\global #1#2\global #2\swapped_count}
+\unexpanded\def\globalswapmacros#1#2{\let\swapped_macro#1\global\let#1#2\global\let#2\swapped_macro}
%D \macros
%D {pushmacro,popmacro}
@@ -5533,55 +5548,55 @@
\expandafter\firstoftwoarguments
\fi}
-%D \macros
-%D {adaptdimension,balancedimensions}
-%D
-%D Again we introduce some macros that are closely related to
-%D an interface aspect of \CONTEXT. The first command can be
-%D used to adapt a \DIMENSION.
-%D
-%D \starttyping
-%D \adaptdimension {dimension} {value}
-%D \stoptyping
-%D
-%D When the value is preceed by a \type{+} or minus, the
-%D dimension is advanced accordingly, otherwise it gets the
-%D value.
-
-\def\doadaptdimension#1#2\\#3\\%
- {\if#1+%
- \dodoglobal\advance
- \else\if#1-%
- \dodoglobal\advance
- \else
- \dodoglobal
- \fi\fi
- #3 #1#2\relax}
-
-\def\adaptdimension#1#2%
- {\expandafter\doadaptdimension#2\\#1\\}
-
-%D A second command takes two \DIMENSIONS. Both are adapted,
-%D depending on the sign of the given value.
-%D maat. This time we take the value as it is, and don't look
-%D explicitly at the preceding sign.
-%D
-%D \starttyping
-%D \balancedimensions {dimension 1} {dimension 2} {value}
-%D \stoptyping
-%D
-%D When a positive value is given, the first dimension is
-%D incremented, the second ond is decremented. A negative value
-%D has the opposite result.
-
-\def\balancedimensions#1#2#3%
- {\scratchdimen#3\relax
- \redoglobal\advance#1 \scratchdimen
- \dodoglobal\advance#2 -\scratchdimen}
-
-%D Both commands can be preceded by \type{\doglobal}. Here we
-%D use \type{\redo} first, because \type{\dodo} resets the
-%D global character.
+% %D \macros
+% %D {adaptdimension,balancedimensions}
+% %D
+% %D Again we introduce some macros that are closely related to
+% %D an interface aspect of \CONTEXT. The first command can be
+% %D used to adapt a \DIMENSION.
+% %D
+% %D \starttyping
+% %D \adaptdimension {dimension} {value}
+% %D \stoptyping
+% %D
+% %D When the value is preceed by a \type{+} or minus, the
+% %D dimension is advanced accordingly, otherwise it gets the
+% %D value.
+%
+% \def\doadaptdimension#1#2\\#3\\%
+% {\if#1+%
+% \dodoglobal\advance
+% \else\if#1-%
+% \dodoglobal\advance
+% \else
+% \dodoglobal
+% \fi\fi
+% #3 #1#2\relax}
+%
+% \def\adaptdimension#1#2%
+% {\expandafter\doadaptdimension#2\\#1\\}
+%
+% %D A second command takes two \DIMENSIONS. Both are adapted,
+% %D depending on the sign of the given value.
+% %D maat. This time we take the value as it is, and don't look
+% %D explicitly at the preceding sign.
+% %D
+% %D \starttyping
+% %D \balancedimensions {dimension 1} {dimension 2} {value}
+% %D \stoptyping
+% %D
+% %D When a positive value is given, the first dimension is
+% %D incremented, the second ond is decremented. A negative value
+% %D has the opposite result.
+%
+% \def\balancedimensions#1#2#3%
+% {\scratchdimen#3\relax
+% \redoglobal\advance#1 \scratchdimen
+% \dodoglobal\advance#2 -\scratchdimen}
+%
+% %D Both commands can be preceded by \type{\doglobal}. Here we
+% %D use \type{\redo} first, because \type{\dodo} resets the
+% %D global character.
%D \macros
%D {processseparatedlist}
@@ -6718,7 +6733,7 @@
\newcount\featuretest
-\def\testfeature#1#2%
+\unexpanded\def\testfeature#1#2%
{\def\dotestfeature
{\advance\featuretest \plusone
\ifnum\featuretest>#1\else#2\expandafter\dotestfeature\fi}%
@@ -6734,11 +6749,14 @@
\wait
\egroup}
-\def\showtimer#1%
+\unexpanded\def\showtimer#1%
{\writestatus{runtime}{\elapsedseconds\space s / #1}}
-\def\testfeatureonce#1#2%
- {\let\wait\relax\testfeature{#1}{#2}\end}
+\unexpanded\def\testfeatureonce#1#2%
+ {\begingroup
+ \let\wait\relax
+ \testfeature{#1}{#2}%
+ \endgroup}
%D \macros
%D {freezedimenmacro}
diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv
index 46f08854c..df18f5307 100644
--- a/tex/context/base/syst-ini.mkiv
+++ b/tex/context/base/syst-ini.mkiv
@@ -331,13 +331,14 @@
\newbox \scratchboxone \newbox \scratchboxtwo \newbox \scratchboxthree
%D \macros
-%D {scratchwidth, scratchheight, scratchdepth}
+%D {scratchwidth, scratchheight, scratchdepth, scratchoffset}
%D
%D A few more scratch dimensions:
\newdimen\scratchwidth
\newdimen\scratchheight
\newdimen\scratchdepth
+\newdimen\scratchoffset
%D More allocations:
@@ -825,25 +826,25 @@
% new after 1.10, watch the change in prefix
-\bindprimitive quitvmode ptexquitvmode
-\bindprimitive noligatures ptexnoligatures
-\bindprimitive setrandomseed ptexsetrandomseed
-\bindprimitive uniformdeviate ptexuniformdeviate
+% \bindprimitive quitvmode ptexquitvmode
+% \bindprimitive noligatures ptexnoligatures
+% \bindprimitive setrandomseed ptexsetrandomseed
+% \bindprimitive uniformdeviate ptexuniformdeviate
-\bindprimitive quitvmode pdfquitvmode
-\bindprimitive noligatures pdfnoligatures
-\bindprimitive setrandomseed pdfsetrandomseed
-\bindprimitive uniformdeviate pdfuniformdeviate
+% \bindprimitive quitvmode pdfquitvmode
+% \bindprimitive noligatures pdfnoligatures
+% \bindprimitive setrandomseed pdfsetrandomseed
+% \bindprimitive uniformdeviate pdfuniformdeviate
-\bindprimitive resettimer pdfresettimer
-\bindprimitive elapsedtime pdfelapsedtime
+% \bindprimitive resettimer pdfresettimer
+% \bindprimitive elapsedtime pdfelapsedtime
% new per 1.40
-\bindprimitive ifprimitive ifpdfprimitive
-\bindprimitive primitive pdfprimitive
-\bindprimitive ifabsdim ifpdfabsdim
-\bindprimitive ifabsnum ifpdfabsnum
+% \bindprimitive ifprimitive ifpdfprimitive
+% \bindprimitive primitive pdfprimitive
+% \bindprimitive ifabsdim ifpdfabsdim
+% \bindprimitive ifabsnum ifpdfabsnum
\ifnum\texengine=\xetexengine \else % this test might disappear some day
diff --git a/tex/context/base/tabl-ltb.mkiv b/tex/context/base/tabl-ltb.mkiv
index 44f1d2c14..91bca6262 100644
--- a/tex/context/base/tabl-ltb.mkiv
+++ b/tex/context/base/tabl-ltb.mkiv
@@ -245,29 +245,10 @@
\hbox \ifcase\linetablemode \or to\scratchdimen \fi \bgroup
\ifcase\alignmentswitch\hss\or\hss\fi
\fi
- \dostartattributes{\??lec\number\linetablecolumn}\c!style\c!color\empty
+ \dousestylehashparameter{\??lec\number\linetablecolumn}\c!style
+ \dousecolorhashparameter{\??lec\number\linetablecolumn}\c!color
\begstrut \ignorespaces}
-% \unexpanded\def\stoplinetablecell
-% {\unskip \endstrut
-% \dostopattributes
-% \ifcase\linetablemode
-% \endgraf
-% \else
-% \ifcase\alignmentswitch\else\hss\fi
-% \fi
-% \egroup
-% \hskip\linetablecparameter\c!rightoffset
-% \egroup
-% \iflinetablepreroll
-% \box\scratchbox
-% \else
-% \doif{\linetablecparameter\c!background}\v!color
-% {\backgroundline[\linetablecparameter\c!backgroundcolor]}%
-% {\box\scratchbox}%
-% \fi
-% \egroup}
-
\newconditional\linetableautoheight \settrue\linetableautoheight
\unexpanded\def\stoplinetablecell
@@ -299,44 +280,6 @@
\fi
\egroup}
-% \unexpanded\def\stoplinetablecell
-% {\unskip \endstrut
-% \dostopattributes
-% \ifcase\linetablemode
-% \endgraf
-% \else
-% \ifcase\alignmentswitch\else\hss\fi
-% \fi
-% \egroup
-% \hskip\linetablecparameter\c!rightoffset
-% \egroup
-% \iflinetablepreroll
-% \box\scratchbox
-% \else
-% \doifelse{\linetablecparameter\c!background}\v!color
-% {\ifconditional\linetableautoheight
-% % \hbox{\blackrule
-% % [ \c!color=\linetablecparameter\c!backgroundcolor,
-% % \c!height=\linetablerparameter{x\c!height},
-% % \c!depth=\linetablerparameter{x\c!depth},
-% % \c!width=\wd\scratchbox]%
-% % \hskip-\wd\scratchbox\box\scratchbox}%
-% \dp\scratchbox\linetablerparameter{x\c!depth}%
-% \ht\scratchbox\linetablerparameter{x\c!height}%
-% \framed
-% [\c!offset=\v!overlay,
-% \c!frameoffset=.5\linewidth,
-% \c!leftframe=\v!off,\c!rightframe=\v!off,
-% \c!background=\v!color,
-% \c!backgroundcolor=\linetablecparameter\c!backgroundcolor%
-% ]{\box\scratchbox}%
-% \else
-% \backgroundline[\linetablecparameter\c!backgroundcolor]{\box\scratchbox}%
-% \fi}%
-% {\box\scratchbox}%
-% \fi
-% \egroup}
-
\def\savelinetablepart
{\global\setbox\tablebox\linetablepart
\ifnum\linetablepart=\zerocount
@@ -391,15 +334,14 @@
\unexpanded\def\startlinetablepart
{\global\linetablesubcol\zerocount
\setbox\scratchbox\hbox\bgroup
- \doconvertfont{\linetablerparameter\c!style}%
- \startcolor[\linetablerparameter\c!color]%
+ \dousestyleparameter{\linetablerparameter\c!style}%
+ \dousecolorparameter{\linetablerparameter\c!color}%
\ignorespaces}
\unexpanded\def\stoplinetablepart
{\ifnum\linetablepart>\zerocount
\unskip \unskip % remove last intercolumn skip (distance+fill)
\fi
- \stopcolor
\egroup
\iflinetablepreroll \else
\ifcase\linetablepart
diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv
index aa44e7942..fa1e121f1 100644
--- a/tex/context/base/tabl-ntb.mkiv
+++ b/tex/context/base/tabl-ntb.mkiv
@@ -131,7 +131,7 @@
\def\bTBLCELL % why not \doinhibitblank
{\inhibitblank
\dotagTABLEcell
- \doconvertfont\tbltblstyle\empty
+ \dousestyleparameter\tbltblstyle
\everypar{\tbltblleft\delayedbegstrut}}
\def\eTBLCELL
diff --git a/tex/context/base/tabl-xtb.lua b/tex/context/base/tabl-xtb.lua
index b753560c6..2dd53accd 100644
--- a/tex/context/base/tabl-xtb.lua
+++ b/tex/context/base/tabl-xtb.lua
@@ -212,14 +212,14 @@ function xtables.set_reflow_width()
local fixedcolumns = data.fixedcolumns
local fixedrows = data.fixedrows
if dimensionstate == 1 then
-if width > fixedcolumns[c] then -- how about a span here?
- fixedcolumns[c] = width
-end
+ if width > fixedcolumns[c] then -- how about a span here?
+ fixedcolumns[c] = width
+ end
elseif dimensionstate == 2 then
fixedrows[r] = height
elseif dimensionstate == 3 then
- fixedrows[r] = width
- fixedcolumns[c] = height
+ fixedrows[r] = height -- width
+ fixedcolumns[c] = width -- height
else -- probably something frozen, like an image -- we could parse the list
if width <= data.criterium_h and height >= data.criterium_v then
if width > fixedcolumns[c] then -- how about a span here?
diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua
index fb3a7a6f7..c1d890276 100644
--- a/tex/context/base/trac-log.lua
+++ b/tex/context/base/trac-log.lua
@@ -403,6 +403,7 @@ local real, user, sub
function logs.start_page_number()
real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+-- real, user, sub = 0, 0, 0
end
local timing = false
diff --git a/tex/context/base/type-lucidanova.mkiv b/tex/context/base/type-lucidanova.mkiv
index 2b2c2af0e..b0b080839 100644
--- a/tex/context/base/type-lucidanova.mkiv
+++ b/tex/context/base/type-lucidanova.mkiv
@@ -15,57 +15,53 @@
\starttypescriptcollection[lucidanova]
- \starttypescript [\s!math] [lucidanova]
- \definefontsynonym [MathRoman] [\s!file:LucidaMath.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lucidanova-math]
- \definefontsynonym [MathRomanBold] [\s!file:LucidaMath-Demi.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lucidanova-math]
+ \starttypescript [\s!math] [lucidanova,lucidaot,otlucida]
+ \definefontsynonym [MathRoman] [\s!file:LucidaBrightMathOT.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lucidanova-math]
+ \definefontsynonym [MathRomanBold] [\s!file:LucidaBrightMathOT-Demi.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lucidanova-math]
\stoptypescript
- \starttypescript [\s!serif] [lucidanova]
- \definefontsynonym [\s!Serif] [\s!file:LucidaBright.otf]
- \definefontsynonym [\s!SerifBold] [\s!file:LucidaBright-Demi.otf]
- \definefontsynonym [\s!SerifItalic] [\s!file:LucidaBright-Italic.otf]
- \definefontsynonym [\s!SerifBoldItalic] [\s!file:LucidaBright-DemiItalic.otf]
+ \starttypescript [\s!serif] [lucidanova,lucidaot,otlucida]
+ \definefontsynonym [\s!Serif] [\s!file:LucidaBrightOT.otf]
+ \definefontsynonym [\s!SerifBold] [\s!file:LucidaBrightOT-Demi.otf]
+ \definefontsynonym [\s!SerifItalic] [\s!file:LucidaBrightOT-Italic.otf]
+ \definefontsynonym [\s!SerifBoldItalic] [\s!file:LucidaBrightOT-DemiItalic.otf]
\definefontsynonym [\s!SerifSlanted] [\s!SerifItalic]
\definefontsynonym [\s!SerifBoldSlanted] [\s!SerifBoldItalic]
\stoptypescript
- \starttypescript [\s!sans] [lucidanova]
- \definefontsynonym [\s!Sans] [\s!file:LucidaSans.otf]
- \definefontsynonym [\s!SansBold] [\s!file:LucidaSans-Bold.otf]
- \definefontsynonym [\s!SansItalic] [\s!file:LucidaSans-Oblique.otf]
- \definefontsynonym [\s!SansBoldItalic] [\s!file:LucidaSans-BoldOblique.otf]
+ \starttypescript [\s!sans] [lucidanova,lucidaot,otlucida]
+ \definefontsynonym [\s!Sans] [\s!file:LucidaSansOT.otf]
+ \definefontsynonym [\s!SansBold] [\s!file:LucidaSansOT-Bold.otf]
+ \definefontsynonym [\s!SansItalic] [\s!file:LucidaSansOT-Oblique.otf]
+ \definefontsynonym [\s!SansBoldItalic] [\s!file:LucidaSansOT-BoldOblique.otf]
\definefontsynonym [\s!SansSlanted] [\s!MonoItalic]
\definefontsynonym [\s!SansBoldSlanted] [\s!MonoBoldItalic]
\stoptypescript
- \starttypescript [\s!mono] [lucidanova]
- \definefontsynonym [\s!Mono] [\s!file:LucidaSansTypewriter.otf]
- \definefontsynonym [\s!MonoBold] [\s!file:LucidaSansTypewriter-Bold.otf]
- \definefontsynonym [\s!MonoItalic] [\s!file:LucidaSansTypewriter-Oblique.otf]
- \definefontsynonym [\s!MonoBoldItalic] [\s!file:LucidaSansTypewriter-BoldOblique.otf]
+ \starttypescript [\s!mono] [lucidanova,lucidaot,otlucida]
+ \definefontsynonym [\s!Mono] [\s!file:LucidaSansTypewriterOT.otf]
+ \definefontsynonym [\s!MonoBold] [\s!file:LucidaSansTypewriterOT-Bold.otf]
+ \definefontsynonym [\s!MonoItalic] [\s!file:LucidaSansTypewriterOT-Oblique.otf]
+ \definefontsynonym [\s!MonoBoldItalic] [\s!file:LucidaSansTypewriterOT-BoldOblique.otf]
\definefontsynonym [\s!MonoSlanted] [\s!MonoItalic]
\definefontsynonym [\s!MonoBoldSlanted] [\s!MonoBoldItalic]
\stoptypescript
- \starttypescript [handwriting] [lucidanova]
+ \starttypescript [handwriting] [lucidanova,lucidaot,otlucida]
\definefontsynonym [LucidaHandwriting] [\s!name:LucidaHandwriting-Italic]
\definefontsynonym [Handwriting] [LucidaHandwriting]
\stoptypescript
- \starttypescript [lucidanova]
+ \starttypescript [lucidanova,lucidaot,otlucida]
%\loadfontgoodies[lucidanova-math]
- \definetypeface [lucidanova] [rm] [\s!serif] [lucidanova] [\s!default] [\s!features=\s!default]
- \definetypeface [lucidanova] [ss] [\s!sans] [lucidanova] [\s!default] [\s!features=\s!default]
- \definetypeface [lucidanova] [tt] [\s!mono] [lucidanova] [\s!default] [\s!features=\s!none]
- \definetypeface [lucidanova] [mm] [\s!math] [lucidanova] [\s!default]
+ \definetypeface [\typescriptone] [rm] [\s!serif] [lucidanova] [\s!default] [\s!features=\s!default]
+ \definetypeface [\typescriptone] [ss] [\s!sans] [lucidanova] [\s!default] [\s!features=\s!default]
+ \definetypeface [\typescriptone] [tt] [\s!mono] [lucidanova] [\s!default] [\s!features=\s!none]
+ \definetypeface [\typescriptone] [mm] [\s!math] [lucidanova] [\s!default]
+ % for the moment here:
+ \setupmathrendering[\typescriptone][it=italic]
\stoptypescript
- % for the moment here:
-
- \setupmathrendering
- [lucidanova]
- [it=italic]
-
\stoptypescriptcollection
\endinput
diff --git a/tex/context/base/typo-ini.lua b/tex/context/base/typo-ini.lua
index 40fe7dfaa..c45d29664 100644
--- a/tex/context/base/typo-ini.lua
+++ b/tex/context/base/typo-ini.lua
@@ -7,3 +7,5 @@ if not modules then modules = { } end modules ['typo-ini'] = {
}
-- nothing yet
+
+typesetters = typesetters or { }
diff --git a/tex/context/base/typo-mar.mkiv b/tex/context/base/typo-mar.mkiv
index c9218ace2..9bbf2a214 100644
--- a/tex/context/base/typo-mar.mkiv
+++ b/tex/context/base/typo-mar.mkiv
@@ -187,7 +187,7 @@
\ifcsname\currentmarginframedhash\s!parent\endcsname
\setbox\nextbox\hbox \currentmarginreference \bgroup
\the\everymargindatacontent
- \dosetmargindataattributes\c!style\c!color
+ \usemargindatastyleandcolor\c!style\c!color
\setupcurrentmarginframed[\c!location=\v!normal,#textparameters]%
\inheritedmarginframedframed\bgroup
\ifx\currentmargindatastrut\empty \else
@@ -202,7 +202,7 @@
\ifx\currentmargindatawidth\empty
\setbox\nextbox\hbox \currentmarginreference \bgroup
\the\everymargindatacontent
- \dosetmargindataattributes\c!style\c!color
+ \usemargindatastyleandcolor\c!style\c!color
\ifx\currentmargindatastrut\empty \else
\dosetupstrut[\currentmargindatastrut]%
\fi
@@ -214,7 +214,7 @@
\setbox\nextbox\hbox \currentmarginreference \bgroup
\vtop \bgroup
\the\everymargindatacontent
- \dosetmargindataattributes\c!style\c!color
+ \usemargindatastyleandcolor\c!style\c!color
\hsize\currentmargindatawidth
\raggedcommand
\ifx\currentmargindatastrut\empty \else
diff --git a/tex/context/base/typo-par.mkiv b/tex/context/base/typo-par.mkiv
index 196585324..fa0f71117 100644
--- a/tex/context/base/typo-par.mkiv
+++ b/tex/context/base/typo-par.mkiv
@@ -49,7 +49,7 @@
%D \placeinitial \input ward \par \input ward \placeinitial \input tufte
%D \stoptyping
-\installsimplecommandhandler \??dc {initial}
+\installsimplecommandhandler \??dc {initial} \??dc
\appendtoks
\checkinitialparent % this might become automatic
@@ -78,7 +78,7 @@
\begingroup
\edef\currentinitial{#1}%
\begingroup
- \dosetinitialcolorattribute\c!color
+ \useinitialcolorparameter\c!color
\ctxlua{typesetters.paragraphs.droppers.set {
location = "\initialparameter\c!location",
enabled = true,
@@ -95,7 +95,7 @@
\begingroup
\doifelsenothing{\initialparameter\c!style}
{\definedfont[\initialparameter\s!font]}
- {\initialparameter\c!style}%
+ {\useinitialstyleparameter\c!style}%
\ctxlua{typesetters.paragraphs.droppers.freeze()}%
\endgroup
\endgroup
diff --git a/tex/context/base/typo-prc.lua b/tex/context/base/typo-prc.lua
new file mode 100644
index 000000000..bb965ff66
--- /dev/null
+++ b/tex/context/base/typo-prc.lua
@@ -0,0 +1,126 @@
+if not modules then modules = { } end modules ['typo-prc'] = {
+ version = 1.001,
+ comment = "companion to typo-prc.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- moved from strc-ini.lua
+
+
+local format = string.format
+local lpegmatch, patterns, P, C, Cs = lpeg.match, lpeg.patterns, lpeg.P, lpeg.C, lpeg.Cs
+
+-- processors: syntax: processor->data ... not ok yet
+
+typesetters.processors = typesetters.processors or { }
+local processors = typesetters.processors
+
+local trace_processors = false
+local report_processors = logs.reporter("processors")
+local registered = { }
+
+trackers.register("typesetters.processors", function(v) trace_processors = v end)
+
+function processors.register(p)
+ registered[p] = true
+end
+
+function processors.reset(p)
+ registered[p] = nil
+end
+
+--~ local splitter = lpeg.splitat("->",true) -- also support =>
+
+local becomes = P('->')
+local processor = (1-becomes)^1
+local splitter = C(processor) * becomes * Cs(patterns.argument + patterns.content)
+
+function processors.split(str)
+ local p, s = lpegmatch(splitter,str)
+ if registered[p] then
+ return p, s
+ else
+ return false, str
+ end
+end
+
+function processors.apply(p,s)
+ local str = p
+ if s == nil then
+ p, s = lpegmatch(splitter,p)
+ end
+ if p and registered[p] then
+ if trace_processors then
+ report_processors("known: %s, argument: %s",p,s or "")
+ end
+ context.applyprocessor(p,s)
+ elseif s then
+ if trace_processors then
+ report_processors("unknown: %s, argument: %s",p or "?",s)
+ end
+ context(s)
+ elseif str then
+ if trace_processors then
+ report_processors("direct: %s",str)
+ end
+ context(str)
+ end
+end
+
+function processors.startapply(p,s)
+ local str = p
+ if s == nil then
+ p, s = lpegmatch(splitter,p)
+ end
+ if p and registered[p] then
+ if trace_processors then
+ report_processors("start: %s",p or "?")
+ end
+ context.applyprocessor(p)
+ context("{")
+ return s
+ elseif p then
+ if trace_processors then
+ report_processors("start: %s (unknown)",p)
+ end
+ context.firstofoneargument()
+ context("{")
+ return s
+ else
+ if trace_processors then
+ report_processors("start: ? (unset)")
+ end
+ context.firstofoneargument()
+ context("{")
+ return str
+ end
+end
+
+function processors.stopapply()
+ context("}")
+ if trace_processors then
+ report_processors("stop")
+ end
+end
+
+function processors.tostring(str)
+ local p, s = lpegmatch(splitter,str)
+ if registered[p] then
+ return format("\\applyprocessor{%s}{%s}",p,s)
+ else
+ return str
+ end
+end
+
+function processors.stripped(str)
+ local p, s = lpegmatch(splitter,str)
+ return s or str
+end
+
+-- interface
+
+commands.registerstructureprocessor = processors.register
+commands.resetstructureprocessor = processors.reset
+
diff --git a/tex/context/base/strc-prc.mkiv b/tex/context/base/typo-prc.mkvi
index a9bab1c18..3bb743b8b 100644
--- a/tex/context/base/strc-prc.mkiv
+++ b/tex/context/base/typo-prc.mkvi
@@ -1,5 +1,5 @@
%D \module
-%D [ file=strc-prc,
+%D [ file=typo-prc,
%D version=2008.10.20,
%D title=\CONTEXT\ Structure Macros,
%D subtitle=Processors,
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\writestatus{loading}{ConTeXt Structure Macros / Processors}
+\writestatus{loading}{ConTeXt Typesetting Macros / Processors}
-\registerctxluafile{strc-prc}{1.001}
+\registerctxluafile{typo-prc}{1.001}
\unprotect
@@ -44,41 +44,46 @@
%D Valid keys for defining a processor are \type {style}, \type {color}, \type {left},
%D \type {right}, and \type {command} (the given command takes one argument).
-\unexpanded\def\defineprocessor
- {\dodoubleargument\dodefineprocessor}
+\installcommandhandler \??po {processor} \??po
-\def\dodefineprocessor[#1][#2]%
- {\ifsecondargument
- \letbeundefined{\??po#1\c!command}%
- \ctxcommand{registerstructureprocessor("#1")}%
- \getparameters[\??po#1][\c!style=,\c!color=,\c!left=,\c!right=,#2]%
- \else
- \letbeundefined{\??po#1\c!style}%
- \ctxcommand{resetstructureprocessor("#1")}%
- \fi}
+\appendtoks
+ \letvalue{\??po\currentprocessor\s!check}\relax
+ \ctxcommand{registerstructureprocessor("\currentprocessor")}% global, but it permits using processor that are yet undefined
+\to \everydefineprocessor
%D The following command can be used by users but normally it will be
%D invoked behind the screens. After all, processor prefixes need to
-%D be split off first.
+%D be split off first. At the \LUA\ end we do check for a processor
+%D being registered anyway.
-\unexpanded\def\applyprocessor#1%
- {\ifcsname\??po#1\c!style\endcsname
- \expandafter\dodoapplyprocessor
+\unexpanded\def\applyprocessor#tag%
+ {\def\currentprocessor{#tag}%
+ \ifcsname\??po\currentprocessor\s!check\endcsname
+ \expandafter\apply_processor
\else
- \expandafter\secondoftwoarguments
- \fi{#1}}
+ \expandafter\firstofoneargument
+ \fi}
+
+\def\apply_processor
+ {\doifelse{\processorparameter\c!state}\v!stop
+ \firstofoneargument
+ \apply_processor_indeed}
-\def\dodoapplyprocessor#1#2%
+\def\apply_processor_indeed#content%
{\begingroup
- \dostartattributes{\??po#1}\c!style\c!color
- \csname\??po#1\c!left\endcsname
- \ifcsname\??po#1\c!command\endcsname
- \csname\??po#1\c!command\endcsname{#2}%
- \else
- #2%
- \fi
- \csname\??po#1\c!right\endcsname
- \dostopattributes
+ \useprocessorstyleandcolor\c!style\c!color
+ \processorparameter\c!left
+ \processorparameter\c!command{#content}%
+ \processorparameter\c!right
\endgroup}
+%D \startbuffer
+%D \defineprocessor[first] [style=bold]
+%D \defineprocessor[last] [first] [color=red]
+%D
+%D \applyprocessor{first}{hans} \applyprocessor{last}{hagen}
+%D \stopbuffer
+%D
+%D \typebuffer \start \blank \getbuffer \blanl \stop
+
\protect \endinput
diff --git a/tex/context/base/xtag-exp.mkii b/tex/context/base/xtag-exp.mkii
index 60345677d..9ecfcc5b1 100644
--- a/tex/context/base/xtag-exp.mkii
+++ b/tex/context/base/xtag-exp.mkii
@@ -13,6 +13,8 @@
\writestatus{loading}{ConTeXt XML Macros / Expansion}
+\ifnum\texengine=\luatexengine \endinput \fi
+
\unprotect
%D Files
diff --git a/tex/context/interface/cont-cs.xml b/tex/context/interface/cont-cs.xml
index 0128912b6..bd7dadddf 100644
--- a/tex/context/interface/cont-cs.xml
+++ b/tex/context/interface/cont-cs.xml
@@ -3275,9 +3275,9 @@
</cd:arguments>
</cd:command>
- <cd:command name="setupindentations" file="core-des.tex">
+ <cd:command name="setupindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="nastavodsazeni"/>
+ <cd:string value="setupindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1" optional="yes" list="yes">
@@ -3316,16 +3316,16 @@
</cd:arguments>
</cd:command>
- <cd:command name="defineindenting" file="core-des.tex">
+ <cd:command name="defineindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="definujodsazovani"/>
+ <cd:string value="defineindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1">
<cd:constant type="cd:name"/>
</cd:keywords>
<cd:assignments n="2" list="yes">
- <cd:inherit name="nastavodsazeni" n="2"/>
+ <cd:inherit name="setupindentedtext" n="2"/>
</cd:assignments>
</cd:arguments>
</cd:command>
diff --git a/tex/context/interface/cont-de.xml b/tex/context/interface/cont-de.xml
index 00acf3d2a..7b120082e 100644
--- a/tex/context/interface/cont-de.xml
+++ b/tex/context/interface/cont-de.xml
@@ -3275,9 +3275,9 @@
</cd:arguments>
</cd:command>
- <cd:command name="setupindentations" file="core-des.tex">
+ <cd:command name="setupindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="stelleeinzuegein"/>
+ <cd:string value="setupindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1" optional="yes" list="yes">
@@ -3316,16 +3316,16 @@
</cd:arguments>
</cd:command>
- <cd:command name="defineindenting" file="core-des.tex">
+ <cd:command name="defineindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="definiereeinzug"/>
+ <cd:string value="defineindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1">
<cd:constant type="cd:name"/>
</cd:keywords>
<cd:assignments n="2" list="yes">
- <cd:inherit name="stelleeinzuegein" n="2"/>
+ <cd:inherit name="setupindentedtext" n="2"/>
</cd:assignments>
</cd:arguments>
</cd:command>
diff --git a/tex/context/interface/cont-en.xml b/tex/context/interface/cont-en.xml
index 0d017867c..a20ac37da 100644
--- a/tex/context/interface/cont-en.xml
+++ b/tex/context/interface/cont-en.xml
@@ -3275,9 +3275,9 @@
</cd:arguments>
</cd:command>
- <cd:command name="setupindentations" file="core-des.tex">
+ <cd:command name="setupindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="setupindentations"/>
+ <cd:string value="setupindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1" optional="yes" list="yes">
@@ -3316,16 +3316,16 @@
</cd:arguments>
</cd:command>
- <cd:command name="defineindenting" file="core-des.tex">
+ <cd:command name="defineindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="defineindenting"/>
+ <cd:string value="defineindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1">
<cd:constant type="cd:name"/>
</cd:keywords>
<cd:assignments n="2" list="yes">
- <cd:inherit name="setupindentations" n="2"/>
+ <cd:inherit name="setupindentedtext" n="2"/>
</cd:assignments>
</cd:arguments>
</cd:command>
diff --git a/tex/context/interface/cont-fr.xml b/tex/context/interface/cont-fr.xml
index 195a9a603..bfb5c82f4 100644
--- a/tex/context/interface/cont-fr.xml
+++ b/tex/context/interface/cont-fr.xml
@@ -3275,9 +3275,9 @@
</cd:arguments>
</cd:command>
- <cd:command name="setupindentations" file="core-des.tex">
+ <cd:command name="setupindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="reglealineas"/>
+ <cd:string value="setupindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1" optional="yes" list="yes">
@@ -3316,16 +3316,16 @@
</cd:arguments>
</cd:command>
- <cd:command name="defineindenting" file="core-des.tex">
+ <cd:command name="defineindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="definitcompoalinea"/>
+ <cd:string value="defineindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1">
<cd:constant type="cd:name"/>
</cd:keywords>
<cd:assignments n="2" list="yes">
- <cd:inherit name="reglealineas" n="2"/>
+ <cd:inherit name="setupindentedtext" n="2"/>
</cd:assignments>
</cd:arguments>
</cd:command>
diff --git a/tex/context/interface/cont-it.xml b/tex/context/interface/cont-it.xml
index 315cf2023..2ede93e69 100644
--- a/tex/context/interface/cont-it.xml
+++ b/tex/context/interface/cont-it.xml
@@ -3275,9 +3275,9 @@
</cd:arguments>
</cd:command>
- <cd:command name="setupindentations" file="core-des.tex">
+ <cd:command name="setupindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="impostarientri"/>
+ <cd:string value="setupindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1" optional="yes" list="yes">
@@ -3316,16 +3316,16 @@
</cd:arguments>
</cd:command>
- <cd:command name="defineindenting" file="core-des.tex">
+ <cd:command name="defineindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="definiscirientro"/>
+ <cd:string value="defineindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1">
<cd:constant type="cd:name"/>
</cd:keywords>
<cd:assignments n="2" list="yes">
- <cd:inherit name="impostarientri" n="2"/>
+ <cd:inherit name="setupindentedtext" n="2"/>
</cd:assignments>
</cd:arguments>
</cd:command>
diff --git a/tex/context/interface/cont-nl.xml b/tex/context/interface/cont-nl.xml
index 6be62c459..f60efa79e 100644
--- a/tex/context/interface/cont-nl.xml
+++ b/tex/context/interface/cont-nl.xml
@@ -3275,9 +3275,9 @@
</cd:arguments>
</cd:command>
- <cd:command name="setupindentations" file="core-des.tex">
+ <cd:command name="setupindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="steldoorspringenin"/>
+ <cd:string value="stelingesprongentextin"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1" optional="yes" list="yes">
@@ -3316,16 +3316,16 @@
</cd:arguments>
</cd:command>
- <cd:command name="defineindenting" file="core-des.tex">
+ <cd:command name="defineindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="doorspringen"/>
+ <cd:string value="definieeringesprongentext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1">
<cd:constant type="cd:name"/>
</cd:keywords>
<cd:assignments n="2" list="yes">
- <cd:inherit name="steldoorspringenin" n="2"/>
+ <cd:inherit name="stelingesprongentextin" n="2"/>
</cd:assignments>
</cd:arguments>
</cd:command>
diff --git a/tex/context/interface/cont-pe.xml b/tex/context/interface/cont-pe.xml
index d138017db..b4e221171 100644
--- a/tex/context/interface/cont-pe.xml
+++ b/tex/context/interface/cont-pe.xml
@@ -3275,9 +3275,9 @@
</cd:arguments>
</cd:command>
- <cd:command name="setupindentations" file="core-des.tex">
+ <cd:command name="setupindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="بارگذاری‌تورفتگیها"/>
+ <cd:string value="setupindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1" optional="yes" list="yes">
@@ -3316,16 +3316,16 @@
</cd:arguments>
</cd:command>
- <cd:command name="defineindenting" file="core-des.tex">
+ <cd:command name="defineindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="تعریف‌تورفتگی"/>
+ <cd:string value="defineindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1">
<cd:constant type="cd:name"/>
</cd:keywords>
<cd:assignments n="2" list="yes">
- <cd:inherit name="بارگذاری‌تورفتگیها" n="2"/>
+ <cd:inherit name="setupindentedtext" n="2"/>
</cd:assignments>
</cd:arguments>
</cd:command>
diff --git a/tex/context/interface/cont-ro.xml b/tex/context/interface/cont-ro.xml
index daaac6183..1dbc8fb85 100644
--- a/tex/context/interface/cont-ro.xml
+++ b/tex/context/interface/cont-ro.xml
@@ -3275,9 +3275,9 @@
</cd:arguments>
</cd:command>
- <cd:command name="setupindentations" file="core-des.tex">
+ <cd:command name="setupindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="seteazaaliniate"/>
+ <cd:string value="setupindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1" optional="yes" list="yes">
@@ -3316,16 +3316,16 @@
</cd:arguments>
</cd:command>
- <cd:command name="defineindenting" file="core-des.tex">
+ <cd:command name="defineindentedtext" file="strc-des.tex">
<cd:sequence>
- <cd:string value="definestealiat"/>
+ <cd:string value="defineindentedtext"/>
</cd:sequence>
<cd:arguments>
<cd:keywords n="1">
<cd:constant type="cd:name"/>
</cd:keywords>
<cd:assignments n="2" list="yes">
- <cd:inherit name="seteazaaliniate" n="2"/>
+ <cd:inherit name="setupindentedtext" n="2"/>
</cd:assignments>
</cd:arguments>
</cd:command>
diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml
index 8d16ac92c..9a8c04170 100644
--- a/tex/context/interface/keys-cs.xml
+++ b/tex/context/interface/keys-cs.xml
@@ -1178,7 +1178,7 @@
<cd:command name='defineframedtext' value='definujoramovanytext'/>
<cd:command name='definehbox' value='definujhbox'/>
<cd:command name='definehead' value='definujnadpis'/>
- <cd:command name='defineindenting' value='definujodsazovani'/>
+ <cd:command name='defineindentedtext' value='defineindentedtext'/>
<cd:command name='defineinmargin' value='defineinmargin'/>
<cd:command name='defineinteractionmenu' value='definujinterakcnimenu'/>
<cd:command name='defineitemgroup' value='defineitemgroup'/>
@@ -1489,7 +1489,7 @@
<cd:command name='setupheads' value='nastavnadpisy'/>
<cd:command name='setupheadtext' value='nastavtexthlavicky'/>
<cd:command name='setuphyphenmark' value='nastavdelitko'/>
- <cd:command name='setupindentations' value='nastavodsazeni'/>
+ <cd:command name='setupindentedtext' value='setupindentedtext'/>
<cd:command name='setupindenting' value='nastavodsazovani'/>
<cd:command name='setupinmargin' value='nastavmarginalie'/>
<cd:command name='setupinteraction' value='nastavinterakci'/>
diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml
index d07188d44..17afd73d0 100644
--- a/tex/context/interface/keys-de.xml
+++ b/tex/context/interface/keys-de.xml
@@ -1178,7 +1178,7 @@
<cd:command name='defineframedtext' value='definiereumrahmtertext'/>
<cd:command name='definehbox' value='definierehbox'/>
<cd:command name='definehead' value='definiereueberschrift'/>
- <cd:command name='defineindenting' value='definiereeinzug'/>
+ <cd:command name='defineindentedtext' value='defineindentedtext'/>
<cd:command name='defineinmargin' value='defineinmargin'/>
<cd:command name='defineinteractionmenu' value='definiereinteraktionsmenue'/>
<cd:command name='defineitemgroup' value='defineitemgroup'/>
@@ -1489,7 +1489,7 @@
<cd:command name='setupheads' value='stelleueberschriftenein'/>
<cd:command name='setupheadtext' value='stelleueberschrifttextein'/>
<cd:command name='setuphyphenmark' value='stellebindestrichein'/>
- <cd:command name='setupindentations' value='stelleeinzuegein'/>
+ <cd:command name='setupindentedtext' value='setupindentedtext'/>
<cd:command name='setupindenting' value='stelleeinziehenein'/>
<cd:command name='setupinmargin' value='stelleinmarginalieein'/>
<cd:command name='setupinteraction' value='stelleinteraktionein'/>
diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml
index ea942caf1..f256cf061 100644
--- a/tex/context/interface/keys-en.xml
+++ b/tex/context/interface/keys-en.xml
@@ -1178,7 +1178,7 @@
<cd:command name='defineframedtext' value='defineframedtext'/>
<cd:command name='definehbox' value='definehbox'/>
<cd:command name='definehead' value='definehead'/>
- <cd:command name='defineindenting' value='defineindenting'/>
+ <cd:command name='defineindentedtext' value='defineindentedtext'/>
<cd:command name='defineinmargin' value='defineinmargin'/>
<cd:command name='defineinteractionmenu' value='defineinteractionmenu'/>
<cd:command name='defineitemgroup' value='defineitemgroup'/>
@@ -1489,7 +1489,7 @@
<cd:command name='setupheads' value='setupheads'/>
<cd:command name='setupheadtext' value='setupheadtext'/>
<cd:command name='setuphyphenmark' value='setuphyphenmark'/>
- <cd:command name='setupindentations' value='setupindentations'/>
+ <cd:command name='setupindentedtext' value='setupindentedtext'/>
<cd:command name='setupindenting' value='setupindenting'/>
<cd:command name='setupinmargin' value='setupinmargin'/>
<cd:command name='setupinteraction' value='setupinteraction'/>
diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml
index b2f025ea8..02e8a1acf 100644
--- a/tex/context/interface/keys-fr.xml
+++ b/tex/context/interface/keys-fr.xml
@@ -1178,7 +1178,7 @@
<cd:command name='defineframedtext' value='defineframedtext'/>
<cd:command name='definehbox' value='definithbox'/>
<cd:command name='definehead' value='definittete'/>
- <cd:command name='defineindenting' value='definitcompoalinea'/>
+ <cd:command name='defineindentedtext' value='defineindentedtext'/>
<cd:command name='defineinmargin' value='definitdansmarge'/>
<cd:command name='defineinteractionmenu' value='definitmenuinteraction'/>
<cd:command name='defineitemgroup' value='defineitemgroup'/>
@@ -1489,7 +1489,7 @@
<cd:command name='setupheads' value='regletetes'/>
<cd:command name='setupheadtext' value='regletextetete'/>
<cd:command name='setuphyphenmark' value='reglemarquagehyphenation'/>
- <cd:command name='setupindentations' value='reglealineas'/>
+ <cd:command name='setupindentedtext' value='setupindentedtext'/>
<cd:command name='setupindenting' value='reglecomposeenalinea'/>
<cd:command name='setupinmargin' value='regledansmarge'/>
<cd:command name='setupinteraction' value='regleinteraction'/>
diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml
index 20b8670d0..7e5108f5c 100644
--- a/tex/context/interface/keys-it.xml
+++ b/tex/context/interface/keys-it.xml
@@ -1178,7 +1178,7 @@
<cd:command name='defineframedtext' value='definiscitestoincorniciato'/>
<cd:command name='definehbox' value='definiscihbox'/>
<cd:command name='definehead' value='definiscitesta'/>
- <cd:command name='defineindenting' value='definiscirientro'/>
+ <cd:command name='defineindentedtext' value='defineindentedtext'/>
<cd:command name='defineinmargin' value='defineinmargin'/>
<cd:command name='defineinteractionmenu' value='definiscimenuinterazione'/>
<cd:command name='defineitemgroup' value='defineitemgroup'/>
@@ -1489,7 +1489,7 @@
<cd:command name='setupheads' value='impostateste'/>
<cd:command name='setupheadtext' value='impostatestointestazioni'/>
<cd:command name='setuphyphenmark' value='impostasegnosillabazione'/>
- <cd:command name='setupindentations' value='impostarientri'/>
+ <cd:command name='setupindentedtext' value='setupindentedtext'/>
<cd:command name='setupindenting' value='impostarientro'/>
<cd:command name='setupinmargin' value='impostainmargine'/>
<cd:command name='setupinteraction' value='impostainterazione'/>
diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml
index c78377078..896d30984 100644
--- a/tex/context/interface/keys-nl.xml
+++ b/tex/context/interface/keys-nl.xml
@@ -1178,7 +1178,7 @@
<cd:command name='defineframedtext' value='definieerkadertekst'/>
<cd:command name='definehbox' value='definieerhbox'/>
<cd:command name='definehead' value='definieerkop'/>
- <cd:command name='defineindenting' value='doorspringen'/>
+ <cd:command name='defineindentedtext' value='definieeringesprongentext'/>
<cd:command name='defineinmargin' value='definieerinmarge'/>
<cd:command name='defineinteractionmenu' value='definieerinteractiemenu'/>
<cd:command name='defineitemgroup' value='definieeritemgroep'/>
@@ -1489,7 +1489,7 @@
<cd:command name='setupheads' value='stelkoppenin'/>
<cd:command name='setupheadtext' value='stelkoptekstin'/>
<cd:command name='setuphyphenmark' value='stelkoppeltekenin'/>
- <cd:command name='setupindentations' value='steldoorspringenin'/>
+ <cd:command name='setupindentedtext' value='stelingesprongentextin'/>
<cd:command name='setupindenting' value='stelinspringenin'/>
<cd:command name='setupinmargin' value='stelinmargein'/>
<cd:command name='setupinteraction' value='stelinteractiein'/>
diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml
index 88b4f56ae..af0e47992 100644
--- a/tex/context/interface/keys-pe.xml
+++ b/tex/context/interface/keys-pe.xml
@@ -1178,7 +1178,7 @@
<cd:command name='defineframedtext' value='تعریف‌متن‌قالبی'/>
<cd:command name='definehbox' value='تعریف‌جعبه‌‌افقی'/>
<cd:command name='definehead' value='تعریف‌سر'/>
- <cd:command name='defineindenting' value='تعریف‌تورفتگی'/>
+ <cd:command name='defineindentedtext' value='defineindentedtext'/>
<cd:command name='defineinmargin' value='تعریف‌درون‌حاشیه'/>
<cd:command name='defineinteractionmenu' value='تعریف‌منوی‌پانل'/>
<cd:command name='defineitemgroup' value='تعریف‌گروه‌آیتم'/>
@@ -1489,7 +1489,7 @@
<cd:command name='setupheads' value='بارگذاری‌سرها'/>
<cd:command name='setupheadtext' value='بارگذاری‌متن‌سر'/>
<cd:command name='setuphyphenmark' value='بارگذاری‌نشانه‌شکستن'/>
- <cd:command name='setupindentations' value='بارگذاری‌تورفتگیها'/>
+ <cd:command name='setupindentedtext' value='setupindentedtext'/>
<cd:command name='setupindenting' value='بارگذاری‌تورفتگی'/>
<cd:command name='setupinmargin' value='بارگذاری‌درون‌حاشیه'/>
<cd:command name='setupinteraction' value='بارگذاری‌پانل'/>
diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml
index c4061a5c4..a4cb10529 100644
--- a/tex/context/interface/keys-ro.xml
+++ b/tex/context/interface/keys-ro.xml
@@ -1178,7 +1178,7 @@
<cd:command name='defineframedtext' value='definestetextinconjurat'/>
<cd:command name='definehbox' value='definestehbox'/>
<cd:command name='definehead' value='definesteantet'/>
- <cd:command name='defineindenting' value='definestealiat'/>
+ <cd:command name='defineindentedtext' value='defineindentedtext'/>
<cd:command name='defineinmargin' value='defineinmargin'/>
<cd:command name='defineinteractionmenu' value='definestemeniuinteractiune'/>
<cd:command name='defineitemgroup' value='defineitemgroup'/>
@@ -1489,7 +1489,7 @@
<cd:command name='setupheads' value='seteazatitluri'/>
<cd:command name='setupheadtext' value='seteazatexttitlu'/>
<cd:command name='setuphyphenmark' value='seteazaliniesilabe'/>
- <cd:command name='setupindentations' value='seteazaaliniate'/>
+ <cd:command name='setupindentedtext' value='setupindentedtext'/>
<cd:command name='setupindenting' value='seteazaaliniat'/>
<cd:command name='setupinmargin' value='seteazamarginal'/>
<cd:command name='setupinteraction' value='seteazainteractiunea'/>