summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/font-ini.mkiv52
-rw-r--r--tex/context/base/m-steps.tex4
-rw-r--r--tex/context/base/mult-cld.lua94
-rw-r--r--tex/context/base/mult-cld.mkiv6
-rw-r--r--tex/context/base/node-tra.lua2
-rw-r--r--tex/context/base/page-com.mkiv116
-rw-r--r--tex/context/base/page-imp.mkiv675
-rw-r--r--tex/context/base/page-ini.mkiv4
-rw-r--r--tex/context/base/page-lay.mkiv1
-rw-r--r--tex/context/base/page-sel.mkiv347
-rw-r--r--tex/context/base/supp-box.lua51
-rw-r--r--tex/context/base/supp-box.mkii2
-rw-r--r--tex/context/base/supp-box.mkiv605
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
17 files changed, 821 insertions, 1146 deletions
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 480b99dff..105d85ad6 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2010.12.09 12:11}
+\newcontextversion{2010.12.10 15:15}
%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.mkiv b/tex/context/base/context.mkiv
index 9ed4161a6..a7fcb8651 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -247,6 +247,8 @@
\loadmarkfile{strc-blk}
\loadmarkfile{page-imp}
+\loadmarkfile{page-sel} % optional
+\loadmarkfile{page-com} % optional
\loadmarkfile{scrn-int}
\loadmarkfile{scrn-men}
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index 2836c355e..a4e0f470b 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2010.12.09 12:11}
+\edef\contextversion{2010.12.10 15:15}
%D For those who want to use this:
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 29b95aeb1..70ea02a36 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -1737,23 +1737,49 @@
% some day we can do an auto-fam if needed
+% \def\checkmathbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined)
+% {%\message{!m #1 #2 #3!}% #1 #2 #3 = signal
+% %ifcsname #2\endcsname\else\setugvalue {#2}{\setcurrentfontalternative {#2}}\fi % \mr \mb
+% \ifcsname #1\endcsname\else\setugvalue {#1}{\setcurrentfontstyle {#1}}\fi} % \mm
+
+% \def\checktextbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined)
+% {%\message{!t #1 #2 #3!}%
+% \ifcsname #1#3\endcsname\else\setugvalue {#1#3}{\setcurrentfontstylesize {#1}{#3}}\fi % \rma
+% \ifcsname #2#3\endcsname\else\setugvalue {#2#3}{\setcurrentfontalternativesize {#2}{#3}}\fi % \sla
+% \ifcsname #1#2#3\endcsname\else\setugvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}\fi % \rmsla
+% \ifcsname #1\endcsname\else\setugvalue {#1}{\setcurrentfontstyle {#1}}\fi % \rm
+% \ifcsname #2\endcsname\else\setugvalue {#2}{\setcurrentfontalternative {#2}}\fi % \sl
+% \ifcsname #1\c!x\endcsname\else\setugvalue {#1\c!x}{\setcurrentfontxstylealternative {#1}}\fi % \rmx
+% \ifcsname#1\c!xx\endcsname\else\setugvalue{#1\c!xx}{\setcurrentfontxxstylealternative {#1}}\fi % \rmxx
+% \ifcsname #2\c!x\endcsname\else\setugvalue {#2\c!x}{\setcurrentfontxalternative {#2}}\fi % \slx
+% \ifcsname#2\c!xx\endcsname\else\setugvalue{#2\c!xx}{\setcurrentfontxxalternative {#2}}\fi % \slxx
+% \ifcsname #1#2\endcsname\else\setugvalue {#1#2}{\setcurrentfontstylealternative {#1}{#2}}\fi} % \rmsl
+
\def\checkmathbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined)
{%\message{!m #1 #2 #3!}% #1 #2 #3 = signal
- %ifcsname #2\endcsname\else\setugvalue {#2}{\setcurrentfontalternative {#2}}\fi % \mr \mb
- \ifcsname #1\endcsname\else\setugvalue {#1}{\setcurrentfontstyle {#1}}\fi} % \mm
+ %setugvalue {#2}{\setcurrentfontalternative {#2}}% % \mr \mb
+ \setugvalue {#1}{\setcurrentfontstyle {#1}}} % \mm
\def\checktextbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined)
- {%\message{!t #1 #2 #3!}%
- \ifcsname #1#3\endcsname\else\setugvalue {#1#3}{\setcurrentfontstylesize {#1}{#3}}\fi % \rma
- \ifcsname #2#3\endcsname\else\setugvalue {#2#3}{\setcurrentfontalternativesize {#2}{#3}}\fi % \sla
- \ifcsname #1#2#3\endcsname\else\setugvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}\fi % \rmsla
- \ifcsname #1\endcsname\else\setugvalue {#1}{\setcurrentfontstyle {#1}}\fi % \rm
- \ifcsname #2\endcsname\else\setugvalue {#2}{\setcurrentfontalternative {#2}}\fi % \sl
- \ifcsname #1\c!x\endcsname\else\setugvalue {#1\c!x}{\setcurrentfontxstylealternative {#1}}\fi % \rmx
- \ifcsname#1\c!xx\endcsname\else\setugvalue{#1\c!xx}{\setcurrentfontxxstylealternative {#1}}\fi % \rmxx
- \ifcsname #2\c!x\endcsname\else\setugvalue {#2\c!x}{\setcurrentfontxalternative {#2}}\fi % \slx
- \ifcsname#2\c!xx\endcsname\else\setugvalue{#2\c!xx}{\setcurrentfontxxalternative {#2}}\fi % \slxx
- \ifcsname #1#2\endcsname\else\setugvalue {#1#2}{\setcurrentfontstylealternative {#1}{#2}}\fi} % \rmsl
+ {%\message{!t #1 #2 #3!}% % beware, some can be defined already
+ \setugvalue {#1#3}{\setcurrentfontstylesize {#1}{#3}}% % \rma
+ \setugvalue {#2#3}{\setcurrentfontalternativesize {#2}{#3}}% % \sla
+ \setugvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}% % \rmsla
+ \ifcsname\s!normal#1\endcsname % text/math check
+ \expandafter\let\csname#1\expandafter\endcsname\csname\s!normal#1\endcsname
+ \else
+ \setugvalue {#1}{\setcurrentfontstyle {#1}}% % \rm
+ \fi
+ \ifcsname\s!normal#2\endcsname % text/math check
+ \expandafter\let\csname#2\expandafter\endcsname\csname\s!normal#2\endcsname
+ \else
+ \setugvalue {#2}{\setcurrentfontalternative {#2}}% % \sl
+ \fi
+ \setugvalue {#1\c!x}{\setcurrentfontxstylealternative {#1}}% % \rmx
+ \setugvalue{#1\c!xx}{\setcurrentfontxxstylealternative {#1}}% % \rmxx
+ \setugvalue {#2\c!x}{\setcurrentfontxalternative {#2}}% % \slx
+ \setugvalue{#2\c!xx}{\setcurrentfontxxalternative {#2}}% % \slxx
+ \setugvalue {#1#2}{\setcurrentfontstylealternative {#1}{#2}}} % \rmsl
\def\dodefinedefaultbodyfont[#1][#2][#3]% sizes styles identifier
{\def\dododefinedefaultbodyfont##1%
diff --git a/tex/context/base/m-steps.tex b/tex/context/base/m-steps.tex
index 1f6a37403..55e13b97d 100644
--- a/tex/context/base/m-steps.tex
+++ b/tex/context/base/m-steps.tex
@@ -454,8 +454,8 @@
\ifcase\somestepboxone \box\stepboxone \vskip\@@STPCvoffset \fi
\ifcase\somestepboxtwo \box\stepboxtwo \vskip\scratchdimen \fi
\ifcase\sometextboxtwo \box\textboxtwo \vskip\@@STPCvoffset \fi
- \global\resetbox\stepboxone \global\resetbox\stepboxtwo % needed indeed
- \global\resetbox\textboxone \global\resetbox\textboxtwo % needed indeed
+ \global\setbox\stepboxone\emptybox \global\setbox\stepboxtwo\emptybox % needed indeed
+ \global\setbox\textboxone\emptybox \global\setbox\textboxtwo\emptybox % needed indeed
%\kern-\scratchdimen % no, instead:
\vskip-\lastskip}
\hbox
diff --git a/tex/context/base/mult-cld.lua b/tex/context/base/mult-cld.lua
index 64030724e..416ff247e 100644
--- a/tex/context/base/mult-cld.lua
+++ b/tex/context/base/mult-cld.lua
@@ -39,6 +39,7 @@ local texcount = tex.count
local isnode = node.is_node -- after 0.65 just node.type
local writenode = node.write
+local copynodelist = node.copylist
local ctxcatcodes = tex.ctxcatcodes
local prtcatcodes = tex.prtcatcodes
@@ -54,32 +55,72 @@ local report_cld = logs.new("cld")
local processlines = false experiments.register("context.processlines", function(v) processlines = v end)
-local _stack_, _n_ = { }, 0
+-- for tracing it's easier to have two stacks
-local function _store_(ti)
- _n_ = _n_ + 1
- _stack_[_n_] = ti
- return _n_
+local _stack_f_, _n_f_ = { }, 0
+local _stack_n_, _n_n_ = { }, 0
+
+local function _store_f_(ti)
+ _n_f_ = _n_f_ + 1
+ _stack_f_[_n_f_] = ti
+ return _n_f_
+end
+
+local function _store_n_(ti)
+ _n_n_ = _n_n_ + 1
+ _stack_n_[_n_n_] = ti
+ return _n_n_
+end
+
+local function _flush_f_(n)
+ local sn = _stack_f_[n]
+ if not sn then
+ report_cld("data with id %s cannot be found on stack",n)
+ else
+ local tn = type(sn)
+ if tn == "function" then
+ if not sn() and texcount["@@trialtypesetting"] == 0 then -- @@trialtypesetting is private!
+ _stack_f_[n] = nil
+ else
+ -- keep, beware, that way the stack can grow
+ end
+ else
+ if texcount["@@trialtypesetting"] == 0 then -- @@trialtypesetting is private!
+ writenode(sn)
+ _stack_f_[n] = nil
+ else
+ writenode(copynodelist(sn))
+ -- keep, beware, that way the stack can grow
+ end
+ end
+ end
end
-local function _flush_(n)
- local sn = _stack_[n]
+local function _flush_n_(n)
+ local sn = _stack_n_[n]
if not sn then
report_cld("data with id %s cannot be found on stack",n)
- elseif not sn() and texcount["@@trialtypesetting"] == 0 then -- @@trialtypesetting is private!
- _stack_[n] = nil
+ elseif texcount["@@trialtypesetting"] == 0 then -- @@trialtypesetting is private!
+ writenode(sn)
+ _stack_n_[n] = nil
else
+ writenode(copynodelist(sn))
-- keep, beware, that way the stack can grow
end
end
function context.restart()
- _stack_, _n_ = { }, 0
+ _stack_f_, _n_f_ = { }, 0
+ _stack_n_, _n_n_ = { }, 0
end
-context._stack_ = _stack_
-context._store_ = _store_
-context._flush_ = _flush_
+context._stack_f_ = _stack_f_
+context._store_f_ = _store_f_
+context._flush_f_ = _flush_f_ cldff = _flush_f_
+
+context._stack_n_ = _stack_n_
+context._store_n_ = _store_n_
+context._flush_n_ = _flush_n_ cldfn = _flush_n_
-- Should we keep the catcodes with the function?
@@ -205,7 +246,7 @@ local function writer(parent,command,first,...)
if direct then
if typ == "string" or typ == "number" then
flush(currentcatcodes,ti)
- else
+ else -- node.write
trace_context("error: invalid use of direct in '%s', only strings and numbers can be flushed directly, not '%s'",command,typ)
end
direct = false
@@ -253,7 +294,7 @@ local function writer(parent,command,first,...)
elseif tn == 1 then -- some 20% faster than the next loop
local tj = ti[1]
if type(tj) == "function" then
- flush(currentcatcodes,"[\\mkivflush{",_store_(tj),"}]")
+ flush(currentcatcodes,"[\\cldff{",_store_f_(tj),"}]")
else
flush(currentcatcodes,"[",tj,"]")
end
@@ -261,13 +302,13 @@ local function writer(parent,command,first,...)
for j=1,tn do
local tj = ti[j]
if type(tj) == "function" then
- ti[j] = "\\mkivflush{" .. _store_(tj) .. "}"
+ ti[j] = "\\cldff{" .. _store_f_(tj) .. "}"
end
end
flush(currentcatcodes,"[",concat(ti,","),"]")
end
elseif typ == "function" then
- flush(currentcatcodes,"{\\mkivflush{",_store_(ti),"}}") -- todo: ctx|prt|texcatcodes
+ flush(currentcatcodes,"{\\cldff{",_store_f_(ti),"}}") -- todo: ctx|prt|texcatcodes
elseif typ == "boolean" then
if ti then
-- flush(currentcatcodes,"^^M")
@@ -277,8 +318,8 @@ local function writer(parent,command,first,...)
end
elseif typ == "thread" then
trace_context("coroutines not supported as we cannot yield across boundaries")
- elseif isnode(ti) then
- writenode(ti)
+ elseif isnode(ti) then -- slow
+ flush(currentcatcodes,"{\\cldfn{",_store_n_(ti),"}}")
else
trace_context("error: '%s' gets a weird argument '%s'",command,tostring(ti))
end
@@ -288,7 +329,7 @@ end
local generics = { } context.generics = generics
local function indexer(parent,k)
- local c = "\\" .. (generics[k] or k)
+ local c = "\\" .. tostring(generics[k] or k)
local f = function(first,...)
if first == nil then
flush(currentcatcodes,c)
@@ -322,7 +363,7 @@ local function caller(parent,f,a,...)
end
elseif typ == "function" then
-- ignored: a ...
- flush(currentcatcodes,"{\\mkivflush{",_store_(f),"}}") -- todo: ctx|prt|texcatcodes
+ flush(currentcatcodes,"{\\cldff{",_store_f_(f),"}}") -- todo: ctx|prt|texcatcodes
elseif typ == "boolean" then
if f then
if a ~= nil then
@@ -343,8 +384,9 @@ local function caller(parent,f,a,...)
end
elseif typ == "thread" then
trace_context("coroutines not supported as we cannot yield across boundaries")
- elseif isnode(f) then
- writenode(f)
+ elseif isnode(f) then -- slow
+ -- writenode(f)
+ flush(currentcatcodes,"\\cldfn{",_store_n_(f),"}")
else
trace_context("error: 'context' gets a weird argument '%s'",tostring(f))
end
@@ -367,7 +409,7 @@ local nofflushes = 0
statistics.register("traced context", function()
if nofwriters > 0 or nofflushes > 0 then
- return format("writers: %s, flushes: %s, maxstack: %s",nofwriters,nofflushes,_n_)
+ return format("writers: %s, flushes: %s, maxstack: %s",nofwriters,nofflushes,_n_f_)
end
end)
@@ -482,7 +524,7 @@ local function indexer(parent,k)
return f
end
-local function caller(parent,...)
+local function caller(parent,...) -- todo: nodes
local a = { ... }
return function()
return context(unpack(a))
@@ -573,7 +615,7 @@ local function caller(parent,f,a,...)
end
elseif typ == "function" then
-- ignored: a ...
- flush(currentcatcodes,mpdrawing,"{\\mkivflush{",store_(f),"}}")
+ flush(currentcatcodes,mpdrawing,"{\\cldff{",store_(f),"}}")
elseif typ == "boolean" then
-- ignored: a ...
if f then
diff --git a/tex/context/base/mult-cld.mkiv b/tex/context/base/mult-cld.mkiv
index 7fcb96553..97b69b92e 100644
--- a/tex/context/base/mult-cld.mkiv
+++ b/tex/context/base/mult-cld.mkiv
@@ -21,10 +21,14 @@
\unexpanded\def\mkivdefstart #1{\unexpanded\expandafter\def\csname\e!start#1\endcsname}
\unexpanded\def\mkivdefstop #1{\unexpanded\expandafter\def\csname\e!stop #1\endcsname}
\unexpanded\def\mkivdef #1{\unexpanded\expandafter\def\csname #1\endcsname}
- \def\mkivflush #1{\directlua\zerocount{context._flush_(#1)}} % this one will get protected
\unexpanded\def\cldprocessfile#1{\directlua\zerocount{context.runfile("#1")}}
\def\cldcontext #1{\directlua\zerocount{context(#1)}}
\def\cldcommand #1{\directlua\zerocount{context.#1}}
+ \def\mkivflush #1{\directlua\zerocount{context._flush_f_(#1)}} % obsolete
+
+ \def\cldff #1{\directlua\zerocount{cldff(#1)}} % global
+ \def\cldfn #1{\directlua\zerocount{cldfn(#1)}} % global
+
\protect \endinput
diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua
index 27665d60b..d3b71b2b2 100644
--- a/tex/context/base/node-tra.lua
+++ b/tex/context/base/node-tra.lua
@@ -605,7 +605,7 @@ local function toutf(list,result,nofresult,stopcriterium)
end
end
elseif id == disc_code then
- result, nofresult = toutf(n.replace,result,nofresult)
+ result, nofresult = toutf(n.replace,result,nofresult) -- needed?
elseif id == hlist_code or id == vlist_code then
--~ if nofresult > 0 and result[nofresult] ~= " " then
--~ nofresult = nofresult + 1
diff --git a/tex/context/base/page-com.mkiv b/tex/context/base/page-com.mkiv
new file mode 100644
index 000000000..6c6d741a8
--- /dev/null
+++ b/tex/context/base/page-com.mkiv
@@ -0,0 +1,116 @@
+%D \module
+%D [ file=page-com, % moved from page-imp
+%D version=1998.01.15,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Page Comments,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=PRAGMA]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This will become runtime loaded code.
+
+\writestatus{loading}{ConTeXt Page Macros / Page Comments}
+
+\unprotect
+
+%D \macros
+%D {setuppagecomment,startpagecomment}
+%D
+%D This command is not yet documented. Usage:
+%D
+%D \starttyping
+%D \setuppagecomment[state=start,location=right]
+%D
+%D \startpagecomment
+%D \input knuth
+%D \stoppagecomment
+%D \stoptyping
+
+\unexpanded\def\setuppagecomment
+ {\dosingleempty\dosetuppagecomment}
+
+\def\dosetuppagecomment[#1]%
+ {\getparameters[\??pc][#1]%
+ \doifelse\@@pcstate\v!start
+ {\doifinsetelse\@@pclocation{\v!bottom,\v!top}
+ {\setuppapersize[\c!left=\hskip\@@pcoffset]%
+ \edef\@@pcpaperheight{\the\dimexpr\paperheight+\@@pcoffset+\@@pcoffset+\@@pcdistance+\@@pcheight\relax}%
+ \edef\@@pcpaperwidth {\the\dimexpr\paperwidth+\@@pcoffset+\@@pcoffset\relax}%
+ \defineoverlay[\v!pagecomment][\placepagecommentTB]}
+ {\setuppapersize[\c!top=\vskip\@@pcoffset]%
+ \edef\@@pcpaperheight{\the\dimexpr\paperheight+\@@pcoffset+\@@pcoffset\relax}%
+ \edef\@@pcpaperwidth {\the\dimexpr\paperwidth+\@@pcoffset+\@@pcoffset+\@@pcdistance+\@@pcwidth\relax}%
+ \defineoverlay[\v!pagecomment][\placepagecommentLR]}%
+ \processaction
+ [\@@pclocation]
+ [ \v!bottom=>{\setuppapersize[\c!bottom =\vss,\c!top =\vskip\@@pcoffset]},
+ \v!top=>{\setuppapersize[\c!top =\vss,\c!bottom =\vskip\@@pcoffset]},
+ \v!left=>{\setuppapersize[\c!left =\hss,\c!right=\hskip\@@pcoffset]},
+ \v!right=>{\setuppapersize[\c!right=\hss,\c!left =\hskip\@@pcoffset]}]%
+ \definepapersize
+ [\v!pagecomment]
+ [\c!height=\@@pcpaperheight,
+ \c!width=\@@pcpaperwidth]%
+ \let\@@pcprintpapersize\printpapersize
+ \setuppapersize[\papersize][\v!pagecomment]%
+ \setupbackgrounds[\v!paper][\c!background=\v!pagecomment]}
+ {\doif\@@pcstate\v!stop % else initialization invokes backgrounds
+ {% this should be tested first
+ % \normalexpanded{\noexpand\setuppapersize[\papersize][\@@pcprintpapersize]}%
+ \setupbackgrounds[\v!paper][\c!background=]}}}
+
+\def\@@pcprintpapersize{\printpapersize}
+
+\unexpanded\def\placepagecommentTB
+ {\vbox to \printpaperheight
+ {%\forgetall
+ \hsize\printpaperwidth
+ \vskip\@@pcoffset
+ \doifelse\@@pclocation\v!bottom{\vskip\dimexpr\paperheight+\@@pcdistance\relax}\vss
+ \hskip\@@pcoffset
+ \vbox to \@@pcheight
+ {%\forgetall
+ \hsize\paperwidth
+ \ifpagecomment
+ \getbuffer[\v!pagecomment]%
+ \global\pagecommentfalse
+ \fi}%
+ \hfill
+ \doifelse\@@pclocation\v!bottom\vss{\vskip\dimexpr\paperheight+\@@pcdistance\relax}%
+ \vskip\@@pcoffset}}
+
+\unexpanded\def\placepagecommentLR
+ {\hbox to \printpaperwidth
+ {\hskip\@@pcoffset
+ \doifelse\@@pclocation\v!right{\hskip\paperwidth\hskip\@@pcdistance}\hss
+ \vbox to \printpaperheight
+ {%\forgetall
+ \vskip\@@pcoffset
+ \hsize\@@pcwidth
+ \ifpagecomment
+ \getbuffer[\v!pagecomment]%
+ \global\pagecommentfalse
+ \fi
+ \vss}%
+ \doifelse\@@pclocation\v!right\hss{\hskip\paperwidth\hskip\@@pcdistance}%
+ \hskip\@@pcoffset}}
+
+\newif\ifpagecomment
+
+\setvalue{\e!start\v!pagecomment}%
+ {\global\pagecommenttrue
+ \dostartbuffer[\v!pagecomment][\e!start\v!pagecomment][\e!stop\v!pagecomment]}
+
+\setuppagecomment
+ [\c!state=, % \v!stop would invoke background calculation
+ \c!location=\v!bottom,
+ \c!offset=.5cm,
+ \c!distance=.5cm,
+ \c!height=5cm,
+ \c!width=10cm]
+
+\endinput
diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv
index 503768336..e58bac45d 100644
--- a/tex/context/base/page-imp.mkiv
+++ b/tex/context/base/page-imp.mkiv
@@ -23,9 +23,7 @@
%
% \starttext \dorecurse{10}{\input tufte \par} \stoptext
-% to be moved code:
-
-\newif\ifclipprintbox \clipprintboxtrue
+\newif\ifclipprintbox \clipprintboxtrue % todo: conditional
%newif\ifclippagebox \clippageboxtrue
\def\clippedprintbox#1#2% can be made more efficient, see other clipper
@@ -59,7 +57,7 @@
\let\clippagebox \gobbleoneargument
\let\clipprintbox\gobbleoneargument
-
+
% \setuppagenumbering[alternative=doublesided]
% \setupcolors[state=start]
% \setuppapersize[A4][A4,oversized]
@@ -106,7 +104,7 @@
%D This is a user macro (appending to every last shipout is not
%D really user friendly.
-\newtoks \collectedtextdata
+\newtoks\collectedtextdata
\long\unexpanded\def\starttextdata#1\stoptextdata
{\doglobal\appendtoks#1\to\collectedtextdata}
@@ -127,6 +125,7 @@
\def\myshipout#1%
{\beforeshipout % voor de pagebody dus !
\dontshowcomposition
+ \dontcomplain
\executeifdefined{\??pp:\c!method:\@@ppmethod}\gobbleoneargument{#1}%
\setnextrealpageno
\aftershipout}
@@ -155,7 +154,7 @@
\newbox\shipoutscratchbox
-\def\actualshipout#1%
+\def\actualshipout#1% todo: less callbacks
{\global\advance\shippedoutpages\plusone
% this is not resource safe!
\ifx\pagestoshipout\empty
@@ -191,10 +190,8 @@
\fi}%
\smashbox\scratchbox
\shipout\vbox
- {%\forgetall
- \offinterlineskip
- \dontcomplain
- \scratchdimen-1in
+ {\offinterlineskip
+ \scratchdimen-1in % to be done in luatex: zero that one
\vskip\scratchdimen
\hskip\scratchdimen
\hbox % \setbox0=\box.. is nicer
@@ -219,19 +216,16 @@
%D We need a couple of boxes for duplex printing \unknown
\newbox\arrangedpageA \newbox\arrangedpageB
-
-%D \unknown\ and some for simulating big sheets.
-
\newbox\arrangedpageC \newbox\arrangedpageD
\newbox\arrangedpageE \newbox\arrangedpageF
\newbox\arrangedpageG \newbox\arrangedpageH
-\newif\ifswaparranged
-\newif\ifnegatearranged
-\newif\ifmirrorarranged
-\newif\ifdoublearranged
-
-\newif\ifarrangingdisabled
+\newconditional\arrangedswapstate
+\newconditional\arrangednegatestate
+\newconditional\arrangedmirrorstate
+\newconditional\arrangeddoublestate
+\newconditional\arrangingdisabledstate
+\newconditional\arrangedbackgroundstate
\def\arrangedrotationO{0}
\def\arrangedrotationE{0}
@@ -243,66 +237,93 @@
\newcount\arrangedpageX \arrangedpageX\plusone
\newcount\arrangedpageY \arrangedpageY\plusone
-% \newcount\horizontalcutmarks
-% \newcount\verticalcutmarks
-
\def\calculatepaperoffsets#1%
- {\scratchdimen\getvalue{\??pp#1\c!offset}%
- \divide\scratchdimen \arrangedpageX
- \global\advance\paperwidth -2\scratchdimen
- \scratchdimen\getvalue{\??pp#1\c!offset}%
- \divide\scratchdimen \arrangedpageY
- \global\advance\paperheight-2\scratchdimen}
+ {\global\paperoffset\getvalue{\??pp#1\c!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}}
+
+\def\doinstalledarrangedoption#1%
+ {\ifcsname\??pp=>#1\endcsname
+ \csname\??pp=>#1\endcsname
+ \else
+ \checkinstalledpagearrangement{#1}% this installs the arranger
+ \fi}
+
+\doinstallarrangedoption\empty
+ {} % no default and check if empty, we can have ,,,
+
+\doinstallarrangedoption\v!disable
+ {\global\settrue\arrangingdisabledstate}
+
+\doinstallarrangedoption\v!mirrored
+ {\global\settrue\arrangedmirrorstate}
+
+\doinstallarrangedoption\v!doublesided
+ {\global\settrue\arrangeddoublestate}
+
+\doinstallarrangedoption\v!negative
+ {\global\settrue\arrangednegatestate}
+
+\doinstallarrangedoption\v!rotated
+ {\gdef\arrangedrotationO {90}%
+ \gdef\arrangedrotationE{270}%
+ \swapcounts\horizontalcutmarks\verticalcutmarks}
+
+\doinstallarrangedoption{90}
+ {\gdef\arrangedrotationO {90}%
+ \gdef\arrangedrotationE{270}%
+ \swapcounts\horizontalcutmarks\verticalcutmarks}
+
+\doinstallarrangedoption{180}
+ {\gdef\arrangedrotationO{180}%
+ \gdef\arrangedrotationE {0}}
+
+\doinstallarrangedoption{270}
+ {\gdef\arrangedrotationO{270}%
+ \gdef\arrangedrotationE {90}%
+ \swapcounts\horizontalcutmarks\verticalcutmarks}
+
+\doinstallarrangedoption\s!reset
+ {\global\arrangingpagesfalse}
-\newconditional\arrangedbackgroundokay % more ifs -> conditionals
+\doinstallarrangedoption\v!background
+ {\global\settrue\arrangedbackgroundstate}
\unexpanded\def\setuparranging[#1]%
- {\ifarrangingdisabled \else
- \doifelse{#1}\v!disable
- {\global\arrangingdisabledtrue}
- {\global\arrangingdisabledfalse}%
- \global\arrangingpagestrue
- \global\negatearrangedfalse
- \global\mirrorarrangedfalse
- \global\doublearrangedfalse
+ {\ifconditional\arrangingdisabledstate \else
+ %global\setfalse\arrangingdisabledstate
+ \global\arrangingpagestrue % will be conditional
+ \global\setfalse\arrangednegatestate
+ \global\setfalse\arrangedmirrorstate
+ \global\setfalse\arrangeddoublestate
+ \global\setfalse\arrangedswapstate
\gdef\arrangedrotationO{0}%
\gdef\arrangedrotationE{180}%
- \processallactionsinset
- [#1]
- [ \v!mirrored=>\global\mirrorarrangedtrue,
- \v!doublesided=>\global\doublearrangedtrue,
- \v!negative=>\global\negatearrangedtrue,
- \v!rotated=>\gdef\arrangedrotationO {90}\gdef\arrangedrotationE{270},
- 90=>\gdef\arrangedrotationO {90}\gdef\arrangedrotationE{270},
- 180=>\gdef\arrangedrotationO{180}\gdef\arrangedrotationE{0},
- 270=>\gdef\arrangedrotationO{270}\gdef\arrangedrotationE{90},
- \s!reset=>\global\arrangingpagesfalse,
- \v!background=>\global\settrue\arrangedbackgroundokay,
- \s!unknown=>\checkinstalledpagearrangement\commalistelement]%
- % no \s!default=> we can have aaa,,bbb
+ \processcommalist[#1]\doinstalledarrangedoption
\ifx\handlearrangedpage\undefined
\global\arrangingpagesfalse
\fi
- \doifcommonelse{#1}{90,270,\v!rotated}
- {\swapcounts\horizontalcutmarks\verticalcutmarks}{}% ugly solution
\setuppapersize
\fi}
-\def\installpagearrangement #1 %
+\def\installpagearrangement #1 % will lchange, no space
{\setgvalue{\??pp\??pp#1}}
\def\checkinstalledpagearrangement#1% can be empty: aaa,,bbb
{\executeifdefined{\??pp\??pp#1}\donothing}
\def\dosetuparrangement#1#2#3#4#5#6#7#8%
- {\global\arrangedpageX #1%
- \global\arrangedpageY #2%
- \global\arrangedpageT #3%
- \global\horizontalcutmarks#4%
- \global\verticalcutmarks #5%
- \global\let \pusharrangedpage #6%
- \global\let \poparrangedpages #7%
- \global\let \handlearrangedpage#8}
+ {\global\arrangedpageX #1%
+ \global\arrangedpageY #2%
+ \global\arrangedpageT #3%
+ \global\horizontalcutmarks #4%
+ \global\verticalcutmarks #5%
+ \global\let\pusharrangedpage #6%
+ \global\let\poparrangedpages #7%
+ \global\let\handlearrangedpage#8}
\installpagearrangement {\v!normal}
{\global\arrangingpagesfalse}
@@ -355,16 +376,6 @@
{\dosetuparrangement{1}{2}{4}{2}{3}%
\pusharrangedpageTWOTOPSIDE\poparrangedpagesTWOTOPSIDE\handlearrangedpageTOP}
-% \def\filluparrangedpages % beware: \realpageno is 1 ahead
-% {\ifarrangingpages
-% \scratchcounter-\realpageno
-% \divide\scratchcounter \arrangedpageT
-% \multiply\scratchcounter \arrangedpageT
-% \advance\scratchcounter \realpageno
-% \advance\scratchcounter \minusone
-% \dorecurse\scratchcounter{\noheaderandfooterlines\ejectdummypage}%
-% \fi}
-
\def\filluparrangedpages % beware: \realpageno is 1 ahead
{\ifarrangingpages
\scratchcounter\numexpr\realpageno-\plusone\relax
@@ -379,9 +390,7 @@
\def\handlearrangedpageXandY#1#2#3#4#5%
{\global\setbox#5\hbox to \arrangedpageX\paperwidth
{\setbox\scratchbox\vbox to \arrangedpageY\paperheight
- {%\forgetall
- \offinterlineskip
- \dontcomplain
+ {\offinterlineskip
\vskip#4\paperheight
\hskip#3\paperwidth
\dorotatebox{\ifcase#2 0\else180\fi}\hbox{\box#1}%
@@ -399,7 +408,7 @@
\gotonextarrangepage
\ifnum\arrangedrotationO\arrangedrotationE>\zerocount
\setbox#1\vbox
- {\ifdoublearranged
+ {\ifconditional\arrangeddoublestate
\ifodd\arrangeno
\dorotatebox\arrangedrotationO\hbox{\box#1}%
\else
@@ -409,27 +418,30 @@
\dorotatebox\arrangedrotationO\hbox{\box#1}%
\fi}%
\fi
- \ifmirrorarranged
+ \ifconditional\arrangedmirrorstate
\setbox#1\vbox{\domirrorbox\vbox{\box#1}}%
\fi
- \ifnegatearranged
+ \ifconditional\arrangednegatestate
\negatecolorbox{#1}%
\fi
\finishpagebox#1%
- \ifconditional\arrangedbackgroundokay\addprintbackground#1\fi
+ \ifconditional\arrangedbackgroundstate\addprintbackground#1\fi
\actualshipout{\box#1}%
\egroup}
%D The format file can be 16K smaller when we postpone the
%D real arrangments. Some day ...
+\def\reportarrangedpage#1%
+ {\showmessage\m!systems
+ {23}{\the\realpageno.\the\pageno\ifnum\subpageno>0 .\the\subpageno\fi,\number#1}}
+
% TOP
% 32/16/8/4/SIDE
\def\poparrangedpagesAB
{\ifnum\arrangedpageN>\zerocount
- \dontcomplain
\paperwidth\arrangedpageX\paperwidth
\paperheight\arrangedpageY\paperheight
\outputarrangedbox\arrangedpageA
@@ -548,8 +560,7 @@
{\global\ht\arrangedpageA\paperheight
\global\ht\arrangedpageB\paperheight
\global\setbox\arrangedpageA\vbox
- {%\forgetall
- \offinterlineskip\vskip\paperheight
+ {\offinterlineskip\vskip\paperheight
\box\arrangedpageA\box\arrangedpageB}%
\global\setbox\arrangedpageB\box\scratchbox} % ?
@@ -565,16 +576,16 @@
\def\handlearrangedpageTWOUP
{\splitoffarrangedpagesTWO
- \ifswaparranged
+ \ifconditional\arrangedswapstate
\global\setbox\arrangedpageA\hbox
- {\clippedprintbox0\arrangedpageA
- \clippedprintbox1\arrangedpageB}%
- \swaparrangedfalse
+ {\clippedprintbox\zerocount\arrangedpageA
+ \clippedprintbox\plusone \arrangedpageB}%
+ \setfalse\arrangedswapstate
\else
\global\setbox\arrangedpageA\hbox
- {\clippedprintbox0\arrangedpageB
- \clippedprintbox1\arrangedpageA}%
- \swaparrangedtrue
+ {\clippedprintbox\zerocount\arrangedpageB
+ \clippedprintbox\plusone \arrangedpageA}%
+ \settrue\arrangedswapstate
\fi
\global\ht\arrangedpageA\paperheight
\global\setbox\arrangedpageB\box\scratchbox}
@@ -583,29 +594,26 @@
{\splitoffarrangedpagesTWO
\global\ht\arrangedpageA\paperheight
\global\ht\arrangedpageB\paperheight
- \ifswaparranged
+ \ifconditional\arrangedswapstate
\global\setbox\arrangedpageA\vbox
- {%\forgetall
- \offinterlineskip\vskip\paperheight
+ {\offinterlineskip\vskip\paperheight
\box\arrangedpageA\box\arrangedpageB}%
- \swaparrangedfalse
+ \setfalse\arrangedswapstate
\else
\global\setbox\arrangedpageA\vbox
- {%\forgetall
- \offinterlineskip\vskip\paperheight
+ {\offinterlineskip\vskip\paperheight
\box\arrangedpageB\box\arrangedpageA}%
- \swaparrangedtrue
+ \settrue\arrangedswapstate
\fi
\global\setbox\arrangedpageB\box\scratchbox}
\def\poparrangedpagesTWO
{\ifnum\arrangedpageN>\zerocount
- \dontcomplain
- \swaparrangedfalse
+ \setfalse\arrangedswapstate
\doloop
{\handlearrangedpage
\bgroup
- \paperwidth\arrangedpageX\paperwidth
+ \paperwidth \arrangedpageX\paperwidth
\paperheight\arrangedpageY\paperheight
\ht\arrangedpageA\paperheight
\wd\arrangedpageA\paperwidth
@@ -621,8 +629,7 @@
{\global\advance\arrangedpageN\plusone
\reportarrangedpage\arrangedpageN
\global\setbox\arrangedpageB\vbox
- {%\forgetall
- \offinterlineskip
+ {\offinterlineskip
\unvbox\arrangedpageB
\allowbreak
\ht#1\onepoint
@@ -657,8 +664,7 @@
\def\poparrangedpagesAtoH
{\ifnum\arrangedpageN>\zerocount
- \dontcomplain
- \paperwidth\arrangedpageX\paperwidth
+ \paperwidth \arrangedpageX\paperwidth
\paperheight\arrangedpageY\paperheight
\outputarrangedbox\arrangedpageA
\outputarrangedbox\arrangedpageB
@@ -675,7 +681,6 @@
\def\poparrangedpagesAtoD
{\ifnum\arrangedpageN>\zerocount
- \dontcomplain
\paperwidth\arrangedpageX\paperwidth
\paperheight\arrangedpageY\paperheight
\outputarrangedbox\arrangedpageA
@@ -749,10 +754,9 @@
\def\pusharrangedpageXY#1%
{\global\advance\arrangedpageN\plusone
- \reportarrangedpage\arrangedpageN
\global\advance\arrangedpageM\plusone
- \global\setbox\arrangedpageB\hbox
- \ifdim\@@ppwidth>\zeropoint to \@@ppwidth \fi
+ \reportarrangedpage\arrangedpageN
+ \global\setbox\arrangedpageB\hbox \ifdim\@@ppwidth>\zeropoint to \@@ppwidth \fi
{\ifvoid\arrangedpageB\else
\unhbox\arrangedpageB
\ifdim\@@ppdx>\zeropoint \else \hss\fi
@@ -761,8 +765,7 @@
\fi
\box#1}%
\ifnum\arrangedpageM<\arrangedpageX\else
- \global\setbox\arrangedpageA\vbox
- \ifdim\@@ppheight>\zeropoint to \@@ppheight \fi
+ \global\setbox\arrangedpageA\vbox \ifdim\@@ppheight>\zeropoint to \@@ppheight \fi
{\offinterlineskip
\ifvoid\arrangedpageA\else
\unvbox\arrangedpageA
@@ -779,9 +782,8 @@
\def\poparrangedpagesXY
{\ifnum\arrangedpageN>\zerocount
- \dontcomplain
- \paperwidth\arrangedpageX\paperwidth
- \paperheight \arrangedpageY\paperheight
+ \paperwidth \arrangedpageX\paperwidth
+ \paperheight\arrangedpageY\paperheight
\outputarrangedbox\arrangedpageA
\global\arrangedpageN\zerocount
\global\arrangedpageM\zerocount
@@ -823,20 +825,17 @@
\def\dodefinepageshift[#1][#2][#3]%
{\setvalue{\??pt#2:#1}{#3}}
-\letempty \hpageshifts \newcounter\nofhpageshifts
-\letempty \vpageshifts \newcounter\nofvpageshifts
-
-% \let\shiftprintpagebox\gobbleoneargument
-% \let\shiftpaperpagebox\gobbleoneargument
+\letempty\hpageshifts \newcount\nofhpageshifts
+\letempty\vpageshifts \newcount\nofvpageshifts
\def\dogetpageshift#1#2#3% #1=\dimenx #2=\xpageshifts #3=\nofxpageshifts
- {\ifx#2\empty
+ {\ifx#2\empty % we could do this in lua
#1\zeropoint
\else
- \doglobal\increment#3%
+ \global\advance#3\plusone
\getfromcommacommand[#2][#3]%
\ifx\commalistelement\empty
- \globallet#3\!!plusone
+ \global#3\plusone % we cycle
\getfromcommacommand[#2][#3]%
\fi
\ifx\commalistelement\empty
@@ -863,16 +862,10 @@
\def\dosetuppageshift[#1][#2][#3]% page|paper horizontal vertical
{\ifthirdargument % paper=arrange
- \let\hpageshifts\empty
- \let\vpageshifts\empty
- \let\shiftprintpagebox\gobbleoneargument
- \let\shiftpaperpagebox\gobbleoneargument
- \doifdefined{\??pt\v!horizontal:#2}
- {\edef\hpageshifts{\getvalue{\??pt\v!horizontal:#2}}}%
- \doifdefined{\??pt\v!vertical :#3}
- {\edef\vpageshifts{\getvalue{\??pt\v!vertical :#3}}}%
- \doif{#1}\v!page{\let\shiftprintpagebox\shiftpagebox}%
- \doif{#1}\v!paper{\let\shiftpaperpagebox\shiftpagebox}%
+ \edef\hpageshifts{\ifcsname\??pt\v!horizontal:#2\endcsname\csname\??pt\v!horizontal:#2\endcsname}%
+ \edef\vpageshifts{\ifcsname\??pt\v!vertical :#3\endcsname\csname\??pt\v!vertical :#3\endcsname}%
+ \doifelse{#1}\v!page {\let\shiftprintpagebox\shiftpagebox}{\let\shiftprintpagebox\gobbleoneargument}%
+ \doifelse{#1}\v!paper{\let\shiftpaperpagebox\shiftpagebox}{\let\shiftpaperpagebox\gobbleoneargument}%
\else\ifsecondargument
\doifinsetelse{#1}{\v!page,\v!paper}
{\setuppageshift[#1][#2][#2]}
@@ -880,430 +873,6 @@
\else\iffirstargument
\setuppageshift[\v!page][#1][#1]%
\fi\fi\fi}
-
-%D One can (mis)use this mechanism, in close cooperation
-%D with \PDFTEX\ to arrange pages of already produced files.
-%D
-%D \starttyping
-%D \insertpages[file.pdf][1,3][n=30,width=18cm]
-%D \stoptyping
-%D
-%D The pages are inserted in the text area, and even pages
-%D are repositioned according to the width. In this example
-%D empty pages are added after page 1 and 3.
-%D
-%D Selecting pages can be accomplished by:
-%D
-%D \starttyping
-%D \filterpages[file.pdf][1,3,5][n=30,width=18cm]
-%D \stoptyping
-%D
-%D One may pass \type {odd} or \type {even} instead of a
-%D comma separated list. A third alternative is:
-%D
-%D \starttyping
-%D \copypages[file.pdf][n=30,scale=950]
-%D \stoptyping
-%D
-%D This macros inserts the page, according to the settings
-%D provided.
-
-\def\insertpages
- {\dotripleempty\doinsertpages}
-
-\def\doinsertpages[#1][#2][#3]%
- {\doifassignmentelse{#2}
- {\dodoinsertpages[#1][][#2]}
- {\dodoinsertpages[#1][#2][#3]}}
-
-\def\dodoinsertpages[#1][#2][#3]%
- {\bgroup
- \dontcomplain
- \getfiguredimensions[#1]%
- \getparameters[\??ip][\c!n=\noffigurepages,\c!width=\!!zeropoint,#3]%
- \doifinset0{#2}{\emptyhbox\page}%
- \dorecurse\@@ipn
- {\dofilterpage{#1}\recurselevel
- \doifinset\recurselevel{#2}{\emptyhbox\page}}%
- \egroup}
-
-\def\filterpages
- {\dotripleempty\dofilterpages}
-
-\def\dofilterpages[#1][#2][#3]% % \noffigurepages not yet supported
- {\bgroup
- \dontcomplain
- \getfiguredimensions[#1]%
- \getparameters[\??ip][\c!n=\noffigurepages,\c!width=\!!zeropoint,#3]%
- \doifelse{#2}\v!even
- {\dorecurse\@@ipn
- {\ifodd\recurselevel\relax\else\dofilterpage{#1}\recurselevel\fi}}
- {\doifelse{#2}\v!odd
- {\dorecurse\@@ipn
- {\ifodd\recurselevel\relax\dofilterpage{#1}\recurselevel\fi}}
- {\def\dodocommand##1%
- {\ifnum##1>\@@ipn\else\dofilterpage{#1}{##1}\fi}%
- \def\docommand##1%
- {\dowithrange{##1}\dodocommand}%
- \processcommalist[#2]\docommand}}%
- \egroup}
-
-\def\dofilterpage#1#2%
- {\hbox to \textwidth
- {\ifdoublesided\ifdim\@@ipwidth>\zeropoint\relax\ifodd\realpageno\else
- \hfill
- \def\dowithfigure{\hskip-\@@ipwidth}%
- \fi\fi\fi
- \setbox0\hbox
- {\externalfigure[#1][\c!page=#2,\c!height=\textheight]}%
- \wd0\zeropoint
- \box0}
- \page}
-
-\def\copypages
- {\dodoubleempty\docopypages}
-
-\def\docopypages[#1][#2]%
- {\bgroup
- \getfiguredimensions[#1]%
- \getparameters[\??ip]
- [\c!n=\noffigurepages,
- \c!marking=\v!off,
- \c!scale=\!!thousand,
- \c!offset=\!!zeropoint,
- #2]%
- \dorecurse\@@ipn
- {\vbox to \textheight
- {\hsize\textwidth
- \scratchdimen\@@ipoffset
- \centeredbox
- {\doifelse\@@ipmarking\v!on\cuthbox\hbox
- {\ifdim\scratchdimen>\zeropoint\relax
- \advance\vsize -2\scratchdimen
- \advance\hsize -2\scratchdimen
- \externalfigure[#1][\c!page=\recurselevel,#2,\c!scale=,\c!factor=\v!max,\c!offset=\v!overlay]%
- \else
- \externalfigure[#1][\c!page=\recurselevel,#2,\c!offset=\v!overlay]%
- \fi}}}
- \page}
- \egroup}
-
-%D \macros
-%D {combinepages}
-%D
-%D Yet another way of postprocessing is handles by \type
-%D {\combinepages}. This macro builds a matrix of pages from a
-%D file, for example:
-%D
-%D \starttyping
-%D \setuppapersize
-%D [A4][A4] % or [A4,landscape][A4,landscape]
-%D
-%D \setuplayout
-%D [header=0pt,footer=1cm,
-%D backspace=1cm,topspace=1cm,
-%D width=middle,height=middle]
-%D
-%D \setupfootertexts
-%D [presentation---\currentdate\space---\space\pagenumber]
-%D
-%D \starttext
-%D \combinepages[slides][nx=2,ny=3,frame=on]
-%D \stoptext
-%D \stoptyping
-%D
-%D One can influence the way the pages are combined. (This
-%D will be explained some time.)
-
-\def\combinepages
- {\dodoubleempty\docombinepages}
-
-\def\docombinepages[#1][#2]% a=perpag b=free
- {\bgroup
- \dontcomplain
- \getfiguredimensions[#1]%
- \getparameters
- [\??ip]
- [\c!alternative=\v!a,
- \c!n=\noffigurepages,\c!nx=2,\c!ny=2,\c!start=1,\c!stop=\!!maxcard,
- \c!distance=\bodyfontsize,
- \c!bottom=\vfill,\c!top=\vss,
- \c!left=\hss,\c!right=\hss,
- \c!before=\page,\c!after=\page,\c!inbetween=\blank,
- \c!frame=,\c!background=,\c!backgroundcolor=,
- #2]%
- \def\@@ipname{#1}%
- \@@ipbefore
- \expandcheckedcsname{\??ip::\c!alternative:}\@@ipalternative\v!b
- \@@ipafter
- \egroup}
-
-\setvalue{\??ip::\c!alternative:\v!a}%
- {\global\combinedpagescounter\@@ipstart
- \doloop
- {\vbox to \textheight
- {\hsize\textwidth % ? ?
- \scratchdimen\@@ipdistance
- \!!widtha \dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
- \!!heighta\dimexpr(\vsize-\@@ipny\scratchdimen+\scratchdimen)/\@@ipny\relax
- \dorecurse\@@ipny
- {\hbox to \hsize
- {\dorecurse\@@ipnx
- {\vbox to \!!heighta
- {\hsize\!!widtha
- \vsize\!!heighta
- \@@iptop
- \hbox to \hsize
- {\@@ipleft
- \ifnum\combinedpagescounter>\@@ipstop\relax
- \globallet\@@ipn\!!zerocount
- \else\ifnum\combinedpagescounter>\@@ipn \else
- \externalfigure[\@@ipname]
- [\c!object=\v!no,
- \c!page=\number\combinedpagescounter,
- \c!factor=\v!max,
- \c!background=\@@ipbackground,
- \c!backgroundcolor=\@@ipbackgroundcolor,
- \c!frame=\@@ipframe]%
- \fi\fi
- \@@ipright}
- \@@ipbottom}%
- \global\advance\combinedpagescounter\plusone
- \hfil}%
- \hfilneg}
- \vfil}%
- \vfilneg}%
- \page
- \ifnum\combinedpagescounter>\@@ipn \exitloop\fi}}
-
-\setvalue{\??ip::\c!alternative:\v!c}%
- {\global\combinedpagescounter\@@ipstart
- \doloop
- {\vbox to \textheight
- {\hsize\textwidth % ? ?
- \scratchdimen\@@ipdistance
- \!!widtha \dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
- \!!heighta\dimexpr(\vsize-\@@ipny\scratchdimen+\scratchdimen)/\@@ipny\relax
- \hbox to \hsize
- {\dorecurse\@@ipnx
- {\@@ipleft
- \vbox to \textheight
- {\hsize\!!widtha
- {\dorecurse\@@ipny
- {\@@iptop
- \hbox to \hsize
- {\vbox to \!!heighta
- {\hsize\!!widtha
- \vsize\!!heighta
- \ifnum\combinedpagescounter>\@@ipstop\relax
- \globallet\@@ipn\!!zerocount
- \else\ifnum\combinedpagescounter>\@@ipn \else
- \externalfigure[\@@ipname]
- [\c!object=\v!no,
- \c!page=\number\combinedpagescounter,
- \c!factor=\v!max,
- \c!background=\@@ipbackground,
- \c!backgroundcolor=\@@ipbackgroundcolor,
- \c!frame=\@@ipframe]%
- \fi\fi}}
- \global\advance\combinedpagescounter\plusone
- \@@ipbottom}%
- \vfil}%
- \vfilneg}
- \hfil}%
- \hfilneg}}
- \page
- \ifnum\combinedpagescounter>\@@ipn \exitloop\fi}}
-
-\setvalue{\??ip::\c!alternative:\v!horizontal}{\getvalue{\??ip::\c!alternative:\v!a}}
-\setvalue{\??ip::\c!alternative:\v!vertical }{\getvalue{\??ip::\c!alternative:\v!c}}
-
-\setvalue{\??ip::\c!alternative:\v!b}%
- {\global\combinedpagescounter\@@ipstart
- \doloop
- {\startbaselinecorrection
- \scratchdimen\@@ipdistance
- \!!widtha\dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
- \hbox to \hsize
- {\dorecurse\@@ipnx
- {\global\advance\combinedpagescounter\plusone
- \ifnum\combinedpagescounter>\@@ipn \else
- \normalexpanded{\noexpand\externalfigure[\@@ipname]
- [\c!page=\number\combinedpagescounter,
- \c!width=\the\!!widtha,% todo \freezedimenmacro
- \c!background=\@@ipbackground,
- \c!backgroundcolor=\@@ipbackgroundcolor,
- \c!frame=\@@ipframe]}%
- \hfill
- \fi}\hfillneg}%
- \stopbaselinecorrection
- \ifnum\combinedpagescounter<\@@ipn\relax
- \@@ipinbetween
- \else
- \exitloop
- \fi}}
-
-%D \macros
-%D {setuppagecomment,startpagecomment}
-%D
-%D This command is not yet documented. Usage:
-%D
-%D \starttyping
-%D \setuppagecomment[state=start,location=right]
-%D
-%D \startpagecomment
-%D \input knuth
-%D \stoppagecomment
-%D \stoptyping
-
-\unexpanded\def\setuppagecomment
- {\dosingleempty\dosetuppagecomment}
-
-\def\dosetuppagecomment[#1]%
- {\getparameters[\??pc][#1]%
- \doifelse\@@pcstate\v!start
- {\doifinsetelse\@@pclocation{\v!bottom,\v!top}
- {\setuppapersize[\c!left=\hskip\@@pcoffset]%
- \edef\@@pcpaperheight{\the\dimexpr\paperheight+\@@pcoffset+\@@pcoffset+\@@pcdistance+\@@pcheight\relax}%
- \edef\@@pcpaperwidth {\the\dimexpr\paperwidth+\@@pcoffset+\@@pcoffset\relax}%
- \defineoverlay[\v!pagecomment][\placepagecommentTB]}
- {\setuppapersize[\c!top=\vskip\@@pcoffset]%
- \edef\@@pcpaperheight{\the\dimexpr\paperheight+\@@pcoffset+\@@pcoffset\relax}%
- \edef\@@pcpaperwidth {\the\dimexpr\paperwidth+\@@pcoffset+\@@pcoffset+\@@pcdistance+\@@pcwidth\relax}%
- \defineoverlay[\v!pagecomment][\placepagecommentLR]}%
- \processaction
- [\@@pclocation]
- [ \v!bottom=>{\setuppapersize[\c!bottom =\vss,\c!top =\vskip\@@pcoffset]},
- \v!top=>{\setuppapersize[\c!top =\vss,\c!bottom =\vskip\@@pcoffset]},
- \v!left=>{\setuppapersize[\c!left =\hss,\c!right=\hskip\@@pcoffset]},
- \v!right=>{\setuppapersize[\c!right=\hss,\c!left =\hskip\@@pcoffset]}]%
- \definepapersize
- [\v!pagecomment]
- [\c!height=\@@pcpaperheight,
- \c!width=\@@pcpaperwidth]%
- \let\@@pcprintpapersize\printpapersize
- \setuppapersize[\papersize][\v!pagecomment]%
- \setupbackgrounds[\v!paper][\c!background=\v!pagecomment]}
- {\doif\@@pcstate\v!stop % else initialization invokes backgrounds
- {% this should be tested first
- % \normalexpanded{\noexpand\setuppapersize[\papersize][\@@pcprintpapersize]}%
- \setupbackgrounds[\v!paper][\c!background=]}}}
-
-\def\@@pcprintpapersize{\printpapersize}
-
-\unexpanded\def\placepagecommentTB
- {\vbox to \printpaperheight
- {%\forgetall
- \hsize\printpaperwidth
- \vskip\@@pcoffset
- \doifelse\@@pclocation\v!bottom{\vskip\dimexpr\paperheight+\@@pcdistance\relax}\vss
- \hskip\@@pcoffset
- \vbox to \@@pcheight
- {%\forgetall
- \hsize\paperwidth
- \ifpagecomment
- \getbuffer[\v!pagecomment]%
- \global\pagecommentfalse
- \fi}%
- \hfill
- \doifelse\@@pclocation\v!bottom\vss{\vskip\dimexpr\paperheight+\@@pcdistance\relax}%
- \vskip\@@pcoffset}}
-
-\unexpanded\def\placepagecommentLR
- {\hbox to \printpaperwidth
- {\hskip\@@pcoffset
- \doifelse\@@pclocation\v!right{\hskip\paperwidth\hskip\@@pcdistance}\hss
- \vbox to \printpaperheight
- {%\forgetall
- \vskip\@@pcoffset
- \hsize\@@pcwidth
- \ifpagecomment
- \getbuffer[\v!pagecomment]%
- \global\pagecommentfalse
- \fi
- \vss}%
- \doifelse\@@pclocation\v!right\hss{\hskip\paperwidth\hskip\@@pcdistance}%
- \hskip\@@pcoffset}}
-
-\newif\ifpagecomment
-
-\setvalue{\e!start\v!pagecomment}%
- {\global\pagecommenttrue
- \dostartbuffer[\v!pagecomment][\e!start\v!pagecomment][\e!stop\v!pagecomment]}
-
-\setuppagecomment
- [\c!state=, % \v!stop would invoke background calculation
- \c!location=\v!bottom,
- \c!offset=.5cm,
- \c!distance=.5cm,
- \c!height=5cm,
- \c!width=10cm]
-
-% This macro cuts a page into n parts that can be pasted
-% together.
-
-\def\slicepages
- {\dotripleempty\doslicepages}
-
-\def\doslicepages[#1][#2][#3]%
- {\ifthirdargument
- \dodoslicepages[#1][#2][#3]%
- \else
- \dodoslicepages[#1][#2][#2]%
- \fi}
-
-\newcounter\slicedpagenumber
-
-\def\dodoslicepages[#1][#2][#3]%
- {\bgroup
- \dontcomplain
- \globallet\slicedpagenumber\!!zerocount
- \getfiguredimensions[#1]
- \getparameters
- [\??ip]
- [\c!n=1,
- \c!offset=\!!zeropoint,
- \c!hoffset=\!!zeropoint,\c!voffset=\!!zeropoint,
- \c!width=\figurewidth,\c!height=\figureheight,#2]
- \ifnum\@@ipn>\zerocount
- \definepapersize
- [\s!dummy][\c!height=\@@ipheight,\c!width=\@@ipwidth]
- \setuppapersize
- [\s!dummy][\s!dummy]
- \setuplayout
- [\c!backspace=\!!zeropoint,\c!topspace=\!!zeropoint,
- \c!height=\v!middle,\c!width=\v!middle,
- \c!textdistance=\!!zeropoint,
- \c!header=\!!zeropoint,\c!footer=\!!zeropoint]
- \fi
- \dorecurse\noffigurepages
- {\global\let\slicedpagenumber\recurselevel
- \ifnum\@@ipn>\plusone
- \dorecurse\@@ipn
- {\let\xslice\recurselevel
- \dorecurse\@@ipn
- {\let\yslice\recurselevel
- \clip
- [\c!nx=\@@ipn,\c!ny=\@@ipn,\c!x=\xslice,\c!y=\yslice]
- {\scale
- [\c!scale=\@@ipn000]
- {\externalfigure[#1][\c!page=\slicedpagenumber]}}
- \page}}
- \else
- \ifodd\slicedpagenumber\relax
- \getparameters[\??ip][#2]
- \else
- \getparameters[\??ip][#3]
- \fi
- \hskip\@@ipoffset
- \clip
- [\c!hoffset=\@@iphoffset,\c!voffset=\@@ipvoffset,
- \c!height=\@@ipheight,\c!width=\@@ipwidth]
- {\externalfigure[#1][\c!page=\slicedpagenumber]}
- \page
- \fi}
- \egroup}
-% \starttext \slicepages[slice1.pdf][n=3] \stoptext
\protect \endinput
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index aa646cd8d..1315ad869 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -804,10 +804,6 @@
\let\registerpageposition\gobbleoneargument
\fi
-\def\reportarrangedpage#1%
- {\showmessage\m!systems
- {23}{\the\realpageno.\the\pageno\ifnum\subpageno>0 .\the\subpageno\fi,\number#1}}
-
\newif\ifsavepagebody \newbox\savedpagebody
% beware, \??ly is used before defined, i.e. bad module design
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 9b3079d2a..7222d072f 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -42,6 +42,7 @@
\newdimen\paperheight \paperheight = 297mm
\newdimen\paperwidth \paperwidth = 210mm
+\newdimen\paperoffset \paperoffset = 0mm
\newdimen\printpaperheight \printpaperheight = \paperheight
\newdimen\printpaperwidth \printpaperwidth = \paperwidth
diff --git a/tex/context/base/page-sel.mkiv b/tex/context/base/page-sel.mkiv
new file mode 100644
index 000000000..9192d1430
--- /dev/null
+++ b/tex/context/base/page-sel.mkiv
@@ -0,0 +1,347 @@
+%D \module
+%D [ file=page-sel, % moved from page-imp
+%D version=1998.01.15,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Page Selection,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=PRAGMA]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This will become runtime loaded code.
+
+\writestatus{loading}{ConTeXt Page Macros / Page Selection}
+
+\unprotect
+
+%D One can (mis)use this mechanism, in close cooperation
+%D with \PDFTEX\ to arrange pages of already produced files.
+%D
+%D \starttyping
+%D \insertpages[file.pdf][1,3][n=30,width=18cm]
+%D \stoptyping
+%D
+%D The pages are inserted in the text area, and even pages
+%D are repositioned according to the width. In this example
+%D empty pages are added after page 1 and 3.
+%D
+%D Selecting pages can be accomplished by:
+%D
+%D \starttyping
+%D \filterpages[file.pdf][1,3,5][n=30,width=18cm]
+%D \stoptyping
+%D
+%D One may pass \type {odd} or \type {even} instead of a
+%D comma separated list. A third alternative is:
+%D
+%D \starttyping
+%D \copypages[file.pdf][n=30,scale=950]
+%D \stoptyping
+%D
+%D This macros inserts the page, according to the settings
+%D provided.
+
+\def\insertpages
+ {\dotripleempty\doinsertpages}
+
+\def\doinsertpages[#1][#2][#3]%
+ {\doifassignmentelse{#2}
+ {\dodoinsertpages[#1][][#2]}
+ {\dodoinsertpages[#1][#2][#3]}}
+
+\def\dodoinsertpages[#1][#2][#3]%
+ {\bgroup
+ \dontcomplain
+ \getfiguredimensions[#1]%
+ \getparameters[\??ip][\c!n=\noffigurepages,\c!width=\!!zeropoint,#3]%
+ \doifinset0{#2}{\emptyhbox\page}%
+ \dorecurse\@@ipn
+ {\dofilterpage{#1}\recurselevel
+ \doifinset\recurselevel{#2}{\emptyhbox\page}}%
+ \egroup}
+
+\def\filterpages
+ {\dotripleempty\dofilterpages}
+
+\def\dofilterpages[#1][#2][#3]% % \noffigurepages not yet supported
+ {\bgroup
+ \dontcomplain
+ \getfiguredimensions[#1]%
+ \getparameters[\??ip][\c!n=\noffigurepages,\c!width=\!!zeropoint,#3]%
+ \doifelse{#2}\v!even
+ {\dorecurse\@@ipn
+ {\ifodd\recurselevel\relax\else\dofilterpage{#1}\recurselevel\fi}}
+ {\doifelse{#2}\v!odd
+ {\dorecurse\@@ipn
+ {\ifodd\recurselevel\relax\dofilterpage{#1}\recurselevel\fi}}
+ {\def\dodocommand##1{\ifnum##1>\@@ipn\else\dofilterpage{#1}{##1}\fi}%
+ \def\docommand ##1{\dowithrange{##1}\dodocommand}%
+ \processcommalist[#2]\docommand}}%
+ \egroup}
+
+\def\dofilterpage#1#2%
+ {\hbox to \textwidth
+ {\ifdoublesided\ifdim\@@ipwidth>\zeropoint\relax\ifodd\realpageno\else
+ \hfill
+ \def\dowithfigure{\hskip-\@@ipwidth}%
+ \fi\fi\fi
+ \setbox0\hbox
+ {\externalfigure[#1][\c!page=#2,\c!height=\textheight]}%
+ \wd0\zeropoint
+ \box0}
+ \page}
+
+\def\copypages
+ {\dodoubleempty\docopypages}
+
+\def\docopypages[#1][#2]%
+ {\bgroup
+ \getfiguredimensions[#1]%
+ \getparameters[\??ip]
+ [\c!n=\noffigurepages,
+ \c!marking=\v!off,
+ \c!scale=\!!thousand,
+ \c!offset=\!!zeropoint,
+ #2]%
+ \dorecurse\@@ipn
+ {\vbox to \textheight
+ {\hsize\textwidth
+ \scratchdimen\@@ipoffset
+ \centeredbox
+ {\doifelse\@@ipmarking\v!on\cuthbox\hbox
+ {\ifdim\scratchdimen>\zeropoint\relax
+ \advance\vsize -2\scratchdimen
+ \advance\hsize -2\scratchdimen
+ \externalfigure[#1][\c!page=\recurselevel,#2,\c!scale=,\c!factor=\v!max,\c!offset=\v!overlay]%
+ \else
+ \externalfigure[#1][\c!page=\recurselevel,#2,\c!offset=\v!overlay]%
+ \fi}}}
+ \page}
+ \egroup}
+
+%D \macros
+%D {combinepages}
+%D
+%D Yet another way of postprocessing is handles by \type
+%D {\combinepages}. This macro builds a matrix of pages from a
+%D file, for example:
+%D
+%D \starttyping
+%D \setuppapersize
+%D [A4][A4] % or [A4,landscape][A4,landscape]
+%D
+%D \setuplayout
+%D [header=0pt,footer=1cm,
+%D backspace=1cm,topspace=1cm,
+%D width=middle,height=middle]
+%D
+%D \setupfootertexts
+%D [presentation---\currentdate\space---\space\pagenumber]
+%D
+%D \starttext
+%D \combinepages[slides][nx=2,ny=3,frame=on]
+%D \stoptext
+%D \stoptyping
+%D
+%D One can influence the way the pages are combined. (This
+%D will be explained some time.)
+
+\def\combinepages
+ {\dodoubleempty\docombinepages}
+
+\def\docombinepages[#1][#2]% a=perpag b=free
+ {\bgroup
+ \dontcomplain
+ \getfiguredimensions[#1]%
+ \getparameters
+ [\??ip]
+ [\c!alternative=\v!a,
+ \c!n=\noffigurepages,\c!nx=2,\c!ny=2,\c!start=1,\c!stop=\!!maxcard,
+ \c!distance=\bodyfontsize,
+ \c!bottom=\vfill,\c!top=\vss,
+ \c!left=\hss,\c!right=\hss,
+ \c!before=\page,\c!after=\page,\c!inbetween=\blank,
+ \c!frame=,\c!background=,\c!backgroundcolor=,
+ #2]%
+ \def\@@ipname{#1}%
+ \@@ipbefore
+ \expandcheckedcsname{\??ip::\c!alternative:}\@@ipalternative\v!b
+ \@@ipafter
+ \egroup}
+
+\setvalue{\??ip::\c!alternative:\v!a}%
+ {\global\combinedpagescounter\@@ipstart
+ \doloop
+ {\vbox to \textheight
+ {\hsize\textwidth % ? ?
+ \scratchdimen\@@ipdistance
+ \!!widtha \dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
+ \!!heighta\dimexpr(\vsize-\@@ipny\scratchdimen+\scratchdimen)/\@@ipny\relax
+ \dorecurse\@@ipny
+ {\hbox to \hsize
+ {\dorecurse\@@ipnx
+ {\vbox to \!!heighta
+ {\hsize\!!widtha
+ \vsize\!!heighta
+ \@@iptop
+ \hbox to \hsize
+ {\@@ipleft
+ \ifnum\combinedpagescounter>\@@ipstop\relax
+ \globallet\@@ipn\!!zerocount
+ \else\ifnum\combinedpagescounter>\@@ipn \else
+ \externalfigure[\@@ipname]
+ [\c!object=\v!no,
+ \c!page=\number\combinedpagescounter,
+ \c!factor=\v!max,
+ \c!background=\@@ipbackground,
+ \c!backgroundcolor=\@@ipbackgroundcolor,
+ \c!frame=\@@ipframe]%
+ \fi\fi
+ \@@ipright}
+ \@@ipbottom}%
+ \global\advance\combinedpagescounter\plusone
+ \hfil}%
+ \hfilneg}
+ \vfil}%
+ \vfilneg}%
+ \page
+ \ifnum\combinedpagescounter>\@@ipn \exitloop\fi}}
+
+\setvalue{\??ip::\c!alternative:\v!c}%
+ {\global\combinedpagescounter\@@ipstart
+ \doloop
+ {\vbox to \textheight
+ {\hsize\textwidth % ? ?
+ \scratchdimen\@@ipdistance
+ \!!widtha \dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
+ \!!heighta\dimexpr(\vsize-\@@ipny\scratchdimen+\scratchdimen)/\@@ipny\relax
+ \hbox to \hsize
+ {\dorecurse\@@ipnx
+ {\@@ipleft
+ \vbox to \textheight
+ {\hsize\!!widtha
+ {\dorecurse\@@ipny
+ {\@@iptop
+ \hbox to \hsize
+ {\vbox to \!!heighta
+ {\hsize\!!widtha
+ \vsize\!!heighta
+ \ifnum\combinedpagescounter>\@@ipstop\relax
+ \globallet\@@ipn\!!zerocount
+ \else\ifnum\combinedpagescounter>\@@ipn \else
+ \externalfigure[\@@ipname]
+ [\c!object=\v!no,
+ \c!page=\number\combinedpagescounter,
+ \c!factor=\v!max,
+ \c!background=\@@ipbackground,
+ \c!backgroundcolor=\@@ipbackgroundcolor,
+ \c!frame=\@@ipframe]%
+ \fi\fi}}
+ \global\advance\combinedpagescounter\plusone
+ \@@ipbottom}%
+ \vfil}%
+ \vfilneg}
+ \hfil}%
+ \hfilneg}}
+ \page
+ \ifnum\combinedpagescounter>\@@ipn \exitloop\fi}}
+
+\setvalue{\??ip::\c!alternative:\v!horizontal}{\getvalue{\??ip::\c!alternative:\v!a}}
+\setvalue{\??ip::\c!alternative:\v!vertical }{\getvalue{\??ip::\c!alternative:\v!c}}
+
+\setvalue{\??ip::\c!alternative:\v!b}%
+ {\global\combinedpagescounter\@@ipstart
+ \doloop
+ {\startbaselinecorrection
+ \scratchdimen\@@ipdistance
+ \!!widtha\dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
+ \hbox to \hsize
+ {\dorecurse\@@ipnx
+ {\global\advance\combinedpagescounter\plusone
+ \ifnum\combinedpagescounter>\@@ipn \else
+ \normalexpanded{\noexpand\externalfigure[\@@ipname]
+ [\c!page=\number\combinedpagescounter,
+ \c!width=\the\!!widtha,% todo \freezedimenmacro
+ \c!background=\@@ipbackground,
+ \c!backgroundcolor=\@@ipbackgroundcolor,
+ \c!frame=\@@ipframe]}%
+ \hfill
+ \fi}\hfillneg}%
+ \stopbaselinecorrection
+ \ifnum\combinedpagescounter<\@@ipn\relax
+ \@@ipinbetween
+ \else
+ \exitloop
+ \fi}}
+
+% This macro cuts a page into n parts that can be pasted
+% together.
+
+\def\slicepages
+ {\dotripleempty\doslicepages}
+
+\def\doslicepages[#1][#2][#3]%
+ {\ifthirdargument
+ \dodoslicepages[#1][#2][#3]%
+ \else
+ \dodoslicepages[#1][#2][#2]%
+ \fi}
+
+\newcounter\slicedpagenumber
+
+\def\dodoslicepages[#1][#2][#3]%
+ {\bgroup
+ \dontcomplain
+ \globallet\slicedpagenumber\!!zerocount
+ \getfiguredimensions[#1]
+ \getparameters
+ [\??ip]
+ [\c!n=1,
+ \c!offset=\!!zeropoint,
+ \c!hoffset=\!!zeropoint,\c!voffset=\!!zeropoint,
+ \c!width=\figurewidth,\c!height=\figureheight,#2]
+ \ifnum\@@ipn>\zerocount
+ \definepapersize
+ [\s!dummy][\c!height=\@@ipheight,\c!width=\@@ipwidth]
+ \setuppapersize
+ [\s!dummy][\s!dummy]
+ \setuplayout
+ [\c!backspace=\!!zeropoint,\c!topspace=\!!zeropoint,
+ \c!height=\v!middle,\c!width=\v!middle,
+ \c!textdistance=\!!zeropoint,
+ \c!header=\!!zeropoint,\c!footer=\!!zeropoint]
+ \fi
+ \dorecurse\noffigurepages
+ {\global\let\slicedpagenumber\recurselevel
+ \ifnum\@@ipn>\plusone
+ \dorecurse\@@ipn
+ {\let\xslice\recurselevel
+ \dorecurse\@@ipn
+ {\let\yslice\recurselevel
+ \clip
+ [\c!nx=\@@ipn,\c!ny=\@@ipn,\c!x=\xslice,\c!y=\yslice]
+ {\scale
+ [\c!scale=\@@ipn000]
+ {\externalfigure[#1][\c!page=\slicedpagenumber]}}
+ \page}}
+ \else
+ \ifodd\slicedpagenumber\relax
+ \getparameters[\??ip][#2]
+ \else
+ \getparameters[\??ip][#3]
+ \fi
+ \hskip\@@ipoffset
+ \clip
+ [\c!hoffset=\@@iphoffset,\c!voffset=\@@ipvoffset,
+ \c!height=\@@ipheight,\c!width=\@@ipwidth]
+ {\externalfigure[#1][\c!page=\slicedpagenumber]}
+ \page
+ \fi}
+ \egroup}
+
+% \starttext \slicepages[slice1.pdf][n=3] \stoptext
+
+\protect \endinput
diff --git a/tex/context/base/supp-box.lua b/tex/context/base/supp-box.lua
new file mode 100644
index 000000000..49d16ed2a
--- /dev/null
+++ b/tex/context/base/supp-box.lua
@@ -0,0 +1,51 @@
+if not modules then modules = { } end modules ['supp-box'] = {
+ version = 1.001,
+ comment = "companion to supp-box.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- this is preliminary code
+
+local nodecodes = nodes.nodecodes
+
+local disc_code = nodecodes.disc
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+
+local new_penalty = nodes.pool.penalty
+local free_node = node.free
+
+function hyphenatedlist(list)
+ while list do
+ local id = list.id
+ local next = list.next
+ local prev = list.prev
+ if id == disc_code then
+ local hyphen = list.pre
+ if hyphen then
+ local penalty = new_penalty(-500)
+ hyphen.next = penalty
+ penalty.prev = hyphen
+ prev.next = hyphen
+ next.prev = penalty
+ penalty.next = next
+ hyphen.prev = prev
+ list.pre = nil
+ free_node(list)
+ end
+ elseif id == vlist_code or id == hlist_code then
+ hyphenatedlist(list.list)
+ end
+ list = next
+ end
+end
+
+commands.hyphenatedlist = hyphenatedlist
+
+function commands.showhyphenatedinlist(list)
+ commands.writestatus("show hyphens",nodes.listtoutf(list))
+end
+
+-- processisolatedwords
diff --git a/tex/context/base/supp-box.mkii b/tex/context/base/supp-box.mkii
index b09099221..8cdea8620 100644
--- a/tex/context/base/supp-box.mkii
+++ b/tex/context/base/supp-box.mkii
@@ -2855,8 +2855,6 @@
#4%
\fi}
-\endETEX
-
%D \macros
%D {removedepth, obeydepth}
%D
diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv
index 2ccb29149..a66d7b97d 100644
--- a/tex/context/base/supp-box.mkiv
+++ b/tex/context/base/supp-box.mkiv
@@ -11,16 +11,16 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D This module implements some box manipulation macros. Some
-%D are quite simple, some are more advanced and when understood
-%D well, all can be of use.
-
-%D No longer generic, why bother.
-
\writestatus{loading}{ConTeXt Support Macros / Boxes}
\unprotect
+\registerctxluafile{supp-box}{1.001}
+
+%D This module implements some box manipulation macros. Some
+%D are quite simple, some are more advanced and when understood
+%D well, all can be of use.
+%D
%D \macros
%D {strutdp,strutht,strutwd}
%D
@@ -33,19 +33,14 @@
\def\strutdp{\dp\strutbox}
\def\strutht{\ht\strutbox}
\def\strutwd{\wd\strutbox}
-
+
%D \macros
%D {resetbox, emptybox}
%D
%D Let's start with an easy one. The next macro hides the
%D ugly \type {@} in \type {\voidb@x}.
-\ifx\voidbox\undefined \newbox\voidbox \fi
-\ifx\voidb@x\undefined \let\voidb@x\voidbox \fi
-
-\def\emptybox {\box \voidbox}
-\def\unvoidbox {\unhbox\voidbox}
-\def\resetbox#1{\setbox#1\box\voidbox}
+\ifx\voidbox\undefined \newbox\voidbox \fi
%D \macros
%D {nextdepth}
@@ -219,7 +214,7 @@
%D \NC tb \NC \ruledhbox{\smash [tb]{This is some great smashing, isn't it?}} \NC \NR
%D \NC whd \NC \ruledhbox{\smash[whd]{This is some great smashing, isn't it?}} \NC \NR
%D \stoptabulate
-
+
%D \macros
%D {phantom, hphantom, vphantom, mathstrut}
%D
@@ -263,7 +258,7 @@
%D We also define plain's \type {\mathstrut}.
\unexpanded\def\mathstrut{\vphantom{(}}
-
+
%D \macros
%D {getboxheight}
%D
@@ -301,7 +296,7 @@
\def\getboxheight#1\of#2\box#3%
{\def\next{#1\dimexpr\ht\registercount+\dp\registercount\relax}%
\afterassignment\next\registercount=#3}
-
+
%D For a long time the following three macros were part of
%D the grid snapping core module, but it makes more sense to
%D have them here so that users can see them.
@@ -350,48 +345,6 @@
\newcount\noflines
\newdimen\noflinesheight
-% \def\getnoflines {\xdogetnoflines\plusone } % compensated
-% \def\getroundednoflines{\xdogetnoflines\plustwo } % rounded
-% \def\getrawnoflines {\xdogetnoflines\plusthree} % truncated
-%
-% \def\xdogetnoflines#1#2%
-% {\noflinesheight#2\relax
-% \ifzeropt\noflinesheight
-% \noflines\zerocount
-% \else\ifdim\noflinesheight>\zeropoint
-% \ifcase#1\or
-% \advance\noflinesheight-\roundingeps
-% \divide\noflinesheight\openlineheight
-% \noflines\noflinesheight
-% \advance\noflines\plusone
-% \or
-% \advance\noflinesheight\roundingeps
-% \divide\noflinesheight\openlineheight
-% \noflines\noflinesheight
-% \or
-% \advance\noflinesheight\roundingeps
-% \advance\noflinesheight.5\openlineheight
-% \divide\noflinesheight\openlineheight
-% \noflines\noflinesheight
-% \fi
-% \else
-% \ifcase#1\or
-% \advance\noflinesheight\roundingeps
-% \divide\noflinesheight\openlineheight
-% \noflines\noflinesheight
-% \advance\noflines\minusone
-% \or
-% \advance\noflinesheight-\roundingeps
-% \divide\noflinesheight\openlineheight
-% \noflines\noflinesheight
-% \or
-% \advance\noflinesheight-\roundingeps
-% \advance\noflinesheight-.5\openlineheight
-% \divide\noflinesheight\openlineheight
-% \noflines\noflinesheight
-% \fi
-% \fi\fi}
-
\def\getnoflines#1%
{\noflinesheight#1\relax
\ifzeropt\noflinesheight
@@ -475,23 +428,24 @@
%D \determinenoflines{\definedfont[Sans at 40pt]test\\test}
%D \stoptyping
-\def\determinenoflines % can be mkiv'd
+\def\dodeterminenoflines % can be mkiv'd
+ {\beginofshapebox
+ \unvbox\nextbox
+ \endofshapebox
+ % \global\count1\zerocount
+ % \reshapebox{\global\advance\count1\plusone}%
+ % \egroup\noflines\count1 }%
+ \scratchcounter\zerocount
+ \reshapebox{\global\advance\scratchcounter\plusone}%
+ \expandafter\egroup\expandafter\noflines\the\scratchcounter\relax}
+
+\def\determinenoflines
{\bgroup
\forgetall
\let\crlf\endgraf
\let\\\endgraf
- \dowithnextbox
- {\beginofshapebox
- \unvbox\nextbox
- \endofshapebox
- % \global\count1\zerocount
- % \reshapebox{\global\advance\count1\plusone}%
- % \egroup\noflines\count1 }%
- \scratchcounter\zerocount
- \reshapebox{\global\advance\scratchcounter\plusone}%
- \expandafter\egroup\expandafter\noflines\the\scratchcounter\relax
- }\vbox}
-
+ \dowithnextbox{\dodeterminenoflines}\vbox}
+
%D \macros
%D {doiftextelse, doiftext}
%D
@@ -517,7 +471,7 @@
\def\doiftext#1#2%
{\doiftextelse{#1}{#2}\donothing}
-
+
%D \macros
%D {dowithnextbox,nextbox}
%D
@@ -833,8 +787,6 @@
\def\shapesignal{.12345678pt} % or 12345sp
-% todo: in etex lastnode
-
\def\reshapebox#1%
{\doreshapebox
{#1}%
@@ -853,7 +805,7 @@
\else
\setbox\newshapebox\normalvbox
{\unvcopy\oldshapebox
- \resetbox\newshapebox
+ \setbox\newshapebox\emptybox
\shapecounter\zerocount
\doloop{\dodoreshapebox{#1}{#2}{#3}{#4}}}%
\setbox\newshapebox\box\tmpshapebox
@@ -861,59 +813,6 @@
\ifx\originalshapebox\undefined \let\originalshapebox\oldshapebox \fi
-% %D The old traditional tex variant:
-%
-% \def\insertshapesignal
-% {\normalhbox to \shapesignal{\strut\hss}% plus \strut
-% \prevdepth\strutdp} % never \nointerlineskip
-%
-% \def\restoreshapebox % compensates for the signal
-% {\global\setbox\tmpshapebox\vbox{\vskip-\lineheight\unvcopy\oldshapebox}}
-%
-% \def\shapeboxstrut % put this in front if needed !
-% {\vrule\!!width\zeropoint\!!height\ht\shapebox\!!depth\dp\shapebox}
-%
-% \def\dodoreshapebox#1#2#3#4% \shapebox, \shapepenalty, \shapekern, \shapeskip
-% {\ifzeropt\lastskip % \ifdim\lastskip=\zeropoint\relax
-% \ifzeropt\lastkern % \ifdim\lastkern=\zeropoint\relax
-% \ifcase\lastpenalty % \ifnum\lastpenalty=\zerocount
-% \setbox\shapebox\lastbox
-% \ifvoid\shapebox
-% \unskip\unpenalty\unkern
-% \else
-% \ifdim\wd\shapebox=\shapesignal\relax
-% \exitloop
-% \else
-% \shapecounter\zerocount
-% \global\setbox\tmpshapebox\normalvbox{#1\unvbox\tmpshapebox}%
-% \fi
-% \fi
-% \else
-% \shapepenalty\lastpenalty
-% \global\setbox\tmpshapebox\normalvbox{#2\unvbox\tmpshapebox}%
-% \unpenalty
-% \fi
-% \else
-% \shapekern\lastkern
-% \global\setbox\tmpshapebox\normalvbox{#3\unvbox\tmpshapebox}%
-% \unkern
-% \fi
-% \else
-% \shapeskip\lastskip
-% \global\setbox\tmpshapebox\normalvbox{#4\unvbox\tmpshapebox}%
-% \unskip
-% \fi
-% \ifnum\shapecounter>100 % can be less
-% \global\reshapingfailedtrue
-% \message{!!forced exit from shapebox!!}%
-% \restoreshapebox
-% \exitloop
-% \else
-% \advance\shapecounter \plusone
-% \fi}
-%
-% But now that the lastnode bugfixes are wide spread we can use:
-%
% We will turn this into a \MKIV\ variant.
\def\insertshapesignal
@@ -1047,142 +946,47 @@
%D of \type {\normalhbox}, since it manages the height and depth of
%D the line.
-% \def\shapedhbox
-% {\dowithnextbox
-% {\nextboxht\zeropoint
-% \nextboxdp\zeropoint
-% \flushnextbox}
-% \normalhbox}
-
\def\shapedhbox % lines with non strutted dimensions have
{\expanded{\dowithnextbox % interlineskip so if we want the original
{\nextboxht\the\ht\shapebox % spacing, we need to preserve the original
\nextboxdp\the\dp\shapebox % height and depth which is definitely
\noexpand\flushnextbox}} % needed if we apply struts to the 'new'
\normalhbox} % box or do something that changed ist size
-
+
%D \macros
%D {hyphenatedword,
%D hyphenatedpar,
%D hyphenatedfile,
%D dohyphenateword}
%D
-%D The next one is a tricky one. \PLAIN\ \TEX\ provides
-%D \type{\showhyphens} for showing macros on the terminal. When
-%D preparing a long list of words we decided to show the
-%D hyphens, but had to find out that the \PLAIN\ alternative
-%D can hardly be used and|/|or adapted to typesetting. The next
-%D two macros do the job and a little more. First we define the
-%D (slightly adapted) plain variant:
-
-\def\showhyphens#1%
- {\begingroup
- \setbox\scratchbox\vbox
- {\parfillskip\zerocount
- \hsize\maxdimen
- %\tenrm
- \pretolerance\minusone
- \tolerance\minusone
- \hbadness\zerocount
- \showboxdepth\zerocount
- \ #1}%
- \endgroup}
-
-%D The simple command \type{\hyphenatedword} accepts one
-%D argument and gives the hyphenated word. This macro calls for
+%D We no longer use the pure \TEX\ variant. In due time we will
+%D report some more advanced statistics.
%D
%D \starttyping
-%D \dohyphenateword {n} {pre} {word}
+%D \showhyphens{dohyphenatedword}
%D \stoptyping
-%D
-%D The next examples tell more than lots of words:
-%D
-%D \startbuffer
-%D \dohyphenateword{0} {} {dohyphenatedword}
-%D \dohyphenateword{1} {...} {dohyphenatedword}
-%D \dohyphenateword{2} {...} {dohyphenatedword}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D Here, \type{\hyphenatedword{dohyphenatedword}} is the
-%D shorter alternative for the first line.
-%D
-%D \startvoorbeeld
-%D \getbuffer
-%D \stopvoorbeeld
-%D
-%D These macros are slow but effective and not that hard to
-%D program at all.
-\ifx\scantokens\undefined \let\scantokens\firstofoneargument \fi
+\def\doshowhyphenatednextbox
+ {\ctxlua{commands.showhyphenatedinlist(tex.box[\number\nextbox].list)}}
-\def\dohyphenateword#1#2#3%
- {\bgroup
- \setbox\scratchbox\normalhbox
- {\dontcomplain
- \nopenalties % \widowpenalty \clubpenalty \brokenpenalty \doublehyphendemerits \finalhyphendemerits \adjdemerits
- \hyphenpenalty \zerocount
- \exhyphenpenalty\zerocount
- \setbox0\normalvbox
- {\hsize\zeropoint
- \hskip\zeropoint\relax % really needed
- \ifnum#1<\zeropoint
- \obeyspaces
- \obeylines
- \def\obeyedspace{\hskip\zeropoint\hbox to \onepoint{}\hskip\zeropoint}%
- \let\obeyedline \obeyedspace
- \ifcase-#1\or
- \def\next{#3\relax}\scantokens\expandafter{\next}% relax catches lookahead problem
- % also ok: \scantokens{#3}% % as in \hyphenatedword{spanish|?|}
- \or
- \readfile{#3}\donothing\donothing
- \else
- #3%
- \fi
- \else
- #3%
- \fi}%
- \ifnum#1>\zerocount
- \dorecurse{#1}
- {\setbox2\normalhbox
- {\splittopskip\openstrutheight
- \vsplit0 to \baselineskip}}%
- #2%
- \fi
- \doloop
- {\setbox2\normalhbox
- {\splittopskip\openstrutheight
- \vsplit0 to \baselineskip}%
- \setbox2\normalhbox
- {\unhbox2
- \setbox2\lastbox
- \normalvbox
- {\unvbox2
- \setbox2\lastbox
- \normalhbox{\unhbox2}}}%
- \ifnum#1<\zeropoint\ifdim\wd2=\onepoint\space\else\box2\allowbreak\fi\else\box2\fi
- \ifzeropt\ht0 \exitloop\fi}% % \ifdim\ht0=\zeropoint\exitloop\fi}%
- \removeunwantedspaces}%
- \ifnum#1>\zerocount
- \ht\scratchbox\strutht
- \dp\scratchbox\strutdp
- \box\scratchbox
- \else
- \unhbox\scratchbox
- \fi
- \egroup}
-
-\def\hyphenatedword{\dohyphenateword\zerocount\empty}
-\def\hyphenatedpar {\dohyphenateword\minusone \empty}
-\def\hyphenatedfile{\dohyphenateword{-2}\empty}
+\def\showhyphens{\dowithnextbox\doshowhyphenatednextbox\hbox}
-%D You may want to give the following call a try:
+%D The following macros are seldom used but handy for tracing.
%D
%D \starttyping
-%D \hyphenatedpar{\readfile{zapf}{}{}}\endgraf
+%D \hyphenatedword{dohyphenatedword}
+%D \hyphenatedpar {\dorecurse{10}{dohyphenatedword }}
+%D \hyphenatedfile{tufte}
%D \stoptyping
-
+
+\def\dohyphenatednextbox
+ {\ctxlua{commands.hyphenatedlist(tex.box[\number\nextbox])}%
+ \unhbox\nextbox}
+
+\def\hyphenatedword {\dowithnextbox\dohyphenatednextbox \hbox}
+\def\hyphenatedpar {\dowithnextbox\dohyphenatednextbox \hbox}
+\def\hyphenatedfile#1{\dowithnextbox\dohyphenatednextbox \hbox{\readfile{#1}\donothing\donothing}}
+
%D \macros
%D {processtokens}
%D
@@ -1249,7 +1053,7 @@
\let\savedbefore\before
\doprocesstokens#5\lastcharacter
\endgroup}
-
+
%D \macros
%D {doboundtext}
%D
@@ -1273,7 +1077,7 @@
\advance\scratchdimen -\wd0
\ifdim\scratchdimen>\zeropoint\relax#1\fi}%
-\def\doboundtext#1#2#3%
+\def\doboundtext#1#2#3% still used?
{\normalhbox
{\setbox\scratchbox\normalhbox{#1}%
\scratchdimen#2\relax
@@ -1283,7 +1087,7 @@
\handletokens#1\with\dodoboundtext
\fi
\box\scratchbox}}
-
+
%D \macros
%D {limitatetext}
%D
@@ -1479,7 +1283,7 @@
#1%
\fi
\egroup}
-
+
%D \macros
%D {processisolatedwords,
%D betweenisolatedwords,nothingbetweenisolatedwords}
@@ -1644,7 +1448,7 @@
\def\setbetweenisolatedwords#1%
{\gdef\localbetweenisolatedwords{#1}}
-
+
%D \macros
%D {sbox}
%D
@@ -1716,7 +1520,7 @@
\next
\egroup}%
\normalhbox}
-
+
%D \macros
%D {centeredbox, centerednextbox}
%D
@@ -1836,7 +1640,7 @@
\normalvbox to \vsize{\vss\normalhbox to \hsize{\hss\flushnextbox\hss}\vss}%
\egroup}%
\normalhbox}
-
+
%D \macros
%D {setrigidcolumnhsize,rigidcolumnbalance,rigidcolumnlines}
%D
@@ -1994,35 +1798,6 @@
\box\scratchbox
\egroup}
-% % to be done: start halfway a line combined with one line
-% % extra to start with (skip) and one line less than counted.
-%
-% \def\stopvboxtohbox%
-% {\egroup
-% \setbox2=\normalvbox
-% {\forgetall\unhcopy0\par\xdef\globalvhlines{\the\prevgraf}}%
-% \setbox2=\normalvbox
-% {\unvbox2
-% \setbox2=\lastbox
-% \setbox2=\normalhbox{\unhbox2}%
-% \xdef\globalvhwidth{\the\wd2}}%
-% \decrement\globalvhlines
-% \dimen0=\globalvhwidth
-% \dimen0=\normalvboxtohboxfactor\dimen0
-% \advance\dimen0 by \globalvhlines\lineheight
-% \dp0=\zeropoint
-% \ht0=\dimen0
-% %\writestatus{guessed size}
-% % {w:\the\wd0\space\space
-% % b:\the\baselineskip\space
-% % l:\globalvhlines\space
-% % e:\globalvhwidth\space
-% % h:\the\dimen0}%
-% \box0
-% \egroup}
-
-% todo: \scratchbox
-
\def\convertvboxtohbox
{\setvboxtohbox
\makehboxofhboxes
@@ -2037,32 +1812,12 @@
\setbox0\normalhbox{\box2\unhbox0}%
\repeat}
-% \def\makehboxofhboxes
-% {\setbox0\emptyhbox
-% \doloop % \doloop { .. \exitloop .. }
-% {% \dorecurse{3}{\unskip\unpenalty}% get rid of ... (better do this in a shapeloop)
-% \setbox2\lastbox
-% \ifhbox2
-% \setbox0\normalhbox{\box2\unhbox0}%
-% \else
-% \exitloop
-% \fi}}
-
-% \def\flushboxesonly % feed this into \makehboxofhboxes
-% {\dowithnextbox
-% {\beginofshapebox
-% \unvbox\nextbox
-% \endofshapebox
-% \doreshapebox{\box\shapebox}{}{}{}% get rid of penalties etc
-% \innerflushshapebox}
-% \vbox}
-
\def\removehboxes
{\setbox0\lastbox
\ifhbox0
{\removehboxes}\unhbox0
\fi}
-
+
%D \macros
%D {unhhbox}
%D
@@ -2134,7 +1889,7 @@
%D
%D Not that nice a definition, but effective. Note the stretch
%D we've build in the line that connects the two paragraphs.
-
+
%D \macros
%D {doifcontent}
%D
@@ -2184,7 +1939,7 @@
%D
%D Where the last call of course does not show up in this
%D document, but definitely generates a confusing message.
-
+
%D \macros
%D {processboxes}
%D
@@ -2196,7 +1951,7 @@
\def\processboxes#1%
{\bgroup
\def\doprocessbox{#1}% #1 can be redefined halfway
- \resetbox\processbox
+ \setbox\processbox\emptybox
\afterassignment\dogetprocessbox\let\next=}
\def\endprocessboxes
@@ -2237,31 +1992,6 @@
%D
%D \leavevmode\getbuffer
-% \def\dooverlaybox%
-% {\ifhmode\unskip\fi
-% \ifdim\nextboxht>\ht\processbox
-% \setbox\processbox\normalvbox to \nextboxht
-% {\vss\box\processbox\vss}%
-% \else
-% \setbox\nextbox\normalvbox to \ht\processbox
-% {\vss\flushnextbox\vss}%
-% \fi
-% \scratchdimen=\wd
-% \ifdim\nextboxwd>\wd\processbox
-% \nextbox
-% \else
-% \processbox
-% \fi
-% \setbox\processbox=\normalhbox to \scratchdimen
-% {\normalhbox to \scratchdimen{\hss\box\processbox\hss}%
-% \hskip-\scratchdimen
-% \normalhbox to \scratchdimen{\hss\flushnextbox\hss}}}
-%
-% \def\startoverlay%
-% {\bgroup
-% \let\stopoverlay\egroup
-% \processboxes\dooverlaybox}
-
\def\dooverlaybox
{\ifhmode\unskip\fi
\scratchdimen\dp
@@ -2297,36 +2027,6 @@
\let\stopoverlay\relax
-% %D \macros
-% %D {starthspread}
-% %D
-% %D In a similar way we can build a horizontal box, spread
-% %D over the available width.
-% %D
-% %D \startbuffer
-% %D \starthspread
-% %D {hans}
-% %D {ton}
-% %D {oeps}
-% %D \stophspread
-% %D
-% %D \stopbuffer
-% %D
-% %D \typebuffer
-% %D
-% %D shows up as:
-% %D
-% %D \leavevmode\getbuffer
-%
-% \def\dohspread
-% {\flushnextbox
-% \def\dohspread{\hfil\flushnextbox}}
-%
-% \def\starthspread
-% {\normalhbox to \hsize \bgroup
-% \let\stophspread\egroup
-% \processboxes\dohspread}
-
%D \macros
%D {fakebox}
%D
@@ -2350,7 +2050,7 @@
\def\fakebox
{\bgroup
\afterassignment\dofakebox\scratchcounter}
-
+
%D \macros
%D {lbox,rbox,cbox,tbox,bbox}
%D
@@ -2464,7 +2164,7 @@
\@EA\afterassignment\@EA\docommand\@EA\scratchdimen
\fi}%
\docommand}
-
+
%D Some new, still undocumented features:
% limitatetext -> beter {text} als laatste !!
@@ -2502,7 +2202,7 @@
\fi}
\egroup}
\normalvbox}
-
+
%D Some more undocumented macros (used in m-chart).
\newif\iftraceboxplacement % \traceboxplacementtrue
@@ -2536,12 +2236,6 @@
\newdimen\boxhdisplacement
\newdimen\boxvdisplacement
-%\def\rightbox#1%
-% {\normalhbox
-% {\setbox0=\placedbox{#1}%
-% \dimen0=.5\ht0\advance\dimen0 -.5\dp0
-% \boxcursor\hskip\boxoffset\lower\dimen0\box0}}
-
\def\rightbox#1%
{\normalhbox
{\setbox0\placedbox{#1}%
@@ -2550,12 +2244,6 @@
\global\advance\boxvdisplacement-.5\dp0
\boxcursor\hskip\boxhdisplacement\lower\boxvdisplacement\box0}}
-%\def\leftbox#1%
-% {\normalhbox
-% {\setbox0=\placedbox{#1}%
-% \dimen0=.5\ht0\advance\dimen0 -.5\dp0
-% \boxcursor\hskip-\wd0\hskip-\boxoffset\lower\dimen0\box0}}
-
\def\leftbox#1%
{\normalhbox
{\setbox0\placedbox{#1}%
@@ -2565,12 +2253,6 @@
\global\advance\boxvdisplacement-.5\dp0
\boxcursor\hskip\boxhdisplacement\lower\boxvdisplacement\box0}}
-%\def\topbox#1%
-% {\normalhbox
-% {\setbox0=\placedbox{#1}%
-% \dimen0=\boxoffset\advance\dimen0 \dp0
-% \boxcursor\hskip-.5\wd0\raise\dimen0\box0}}
-
\def\topbox#1%
{\normalhbox
{\setbox0\placedbox{#1}%
@@ -2579,12 +2261,6 @@
\global\advance\boxvdisplacement-\boxoffset
\boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
-%\def\bottombox#1%
-% {\normalhbox
-% {\setbox0=\placedbox{#1}%
-% \dimen0=\boxoffset\advance\dimen0 \ht0
-% \boxcursor\hskip-.5\wd0\lower\dimen0\box0}}
-
\def\bottombox#1%
{\normalhbox
{\setbox0\placedbox{#1}%
@@ -2593,13 +2269,6 @@
\global\advance\boxvdisplacement\boxoffset
\boxcursor\hskip\boxhdisplacement\lower\boxvdisplacement\box0}}
-%\def\lefttopbox#1%
-% {\normalhbox
-% {\setbox0=\placedbox{#1}%
-% \dimen0=\boxoffset\advance\dimen0 \dp0
-% \advance\boxoffset\wd0
-% \boxcursor\hskip-\boxoffset\raise\dimen0\box0}}
-
\def\lefttopbox#1%
{\normalhbox
{\setbox0\placedbox{#1}%
@@ -2609,12 +2278,6 @@
\global\advance\boxvdisplacement-\boxoffset
\boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
-%\def\righttopbox#1%
-% {\normalhbox
-% {\setbox0=\placedbox{#1}%
-% \dimen0=\boxoffset\advance\dimen0 \dp0
-% \boxcursor\hskip\boxoffset\raise\dimen0\box0}}
-
\def\righttopbox#1%
{\normalhbox
{\setbox0\placedbox{#1}%
@@ -2623,13 +2286,6 @@
\global\advance\boxvdisplacement-\boxoffset
\boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
-%\def\leftbottombox#1%
-% {\normalhbox
-% {\setbox0=\placedbox{#1}%
-% \dimen0=\boxoffset\advance\dimen0 \ht0
-% \advance\boxoffset\wd0
-% \boxcursor\hskip-\boxoffset\lower\dimen0\box0}}
-
\def\leftbottombox#1%
{\normalhbox
{\setbox0\placedbox{#1}%
@@ -2639,12 +2295,6 @@
\global\advance\boxvdisplacement\boxoffset
\boxcursor\hskip\boxhdisplacement\lower\boxvdisplacement\box0}}
-%\def\rightbottombox#1%
-% {\normalhbox
-% {\setbox0=\placedbox{#1}%
-% \dimen0=\boxoffset\advance\dimen0 \ht0
-% \boxcursor\hskip\boxoffset\lower\dimen0\box0}}
-
\def\rightbottombox#1%
{\normalhbox
{\setbox0\placedbox{#1}%
@@ -2683,7 +2333,7 @@
\global\boxhdisplacement\boxoffset
\global\boxvdisplacement-\boxoffset
\boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
-
+
%D \macros
%D {obox}
%D
@@ -2695,7 +2345,7 @@
{\advance\hsize-#1\advance\hsize-#2\advance\vsize-#3\advance\vsize-#4\relax}
{\forgetall\vbox to \vsize{\vskip#3\hbox to \hsize{\hskip#1\box\nextbox\hss}\vss}\egroup}
\vbox}
-
+
%D \macros
%D {toplinebox}
%D
@@ -2713,7 +2363,7 @@
\flushnextbox
\fi}%
\tbox}
-
+
%D \macros
%D {initializeboxstack,savebox,foundbox}
%D
@@ -2734,60 +2384,6 @@
%D \normalhbox{y:\foundbox{two}{a}} \par
%D \stoptyping
-% we keep it around as a demonstration of good old tex code:
-%
-% \def\@@stackbox{boxstack:b:}
-% \def\@@stackmax{boxstack:m:}
-% \def\@@stacktag{boxstack:t:}
-% \def\@@stacklst{boxstack:l:}
-%
-% \def\initializeboxstack#1%
-% {\ifundefined{\@@stackbox#1}%
-% \@EA\newbox\csname\@@stackbox#1\endcsname
-% \else
-% \global\setbox\csname\@@stackbox#1\endcsname\emptyvbox
-% \def\docommand##1{\global\letbeundefined{\@@stacktag#1:##1}}%
-% \processcommacommand[\getvalue{\@@stacklst#1}]\docommand
-% \fi
-% \letgvalueempty{\@@stacklst#1}%
-% \letgvalue{\@@stackmax#1}\!!zeropoint}
-%
-% \def\savebox#1#2% stack name
-% {\dowithnextbox
-% {\doifdefined{\@@stackbox#1}
-% {\@EA\doglobal\@EA\increment\csname\@@stackmax#1\endcsname
-% \setxvalue{\@@stacktag#1:#2}{\csname\@@stackmax#1\endcsname}%
-% \setxvalue{\@@stacklst#1}{\getvalue{\@@stacklst#1},#2}%
-% \global\setbox\csname\@@stackbox#1\endcsname\normalvbox
-% {\forgetall
-% \setbox\scratchbox\normalvbox{\flushnextbox}
-% \ht\scratchbox\onepoint
-% \dp\scratchbox\zeropoint
-% \unvbox\csname\@@stackbox#1\endcsname
-% \offinterlineskip
-% \allowbreak
-% \box\scratchbox}}}%
-% \normalvbox}
-%
-% \def\foundbox#1#2%
-% {\normalvbox
-% {\doifdefined{\@@stackbox#1}
-% {\doifdefined{\@@stacktag#1:#2}
-% {\setbox\scratchbox\normalvbox
-% {\splittopskip\zeropoint
-% \setbox0\copy\csname\@@stackbox#1\endcsname
-% \dimen0=\getvalue{\@@stacktag#1:#2}\points
-% \advance\dimen0 -\onepoint
-% \setbox2\vsplit0 to \dimen0
-% \ifdim\ht0>\onepoint
-% \setbox0\vsplit0 to \onepoint
-% \fi
-% \unvbox0\setbox0\lastbox\unvbox0}%
-% \unvbox\scratchbox}}}}
-%
-% \def\doifboxelse#1#2%
-% {\doifdefinedelse{\@@stacktag#1:#2}}
-
\def\@@stackbox{@box@}
\def\@@stacklst{@xob@}
@@ -2827,8 +2423,6 @@
#4%
\fi}
-\endETEX
-
%D \macros
%D {removedepth, obeydepth}
%D
@@ -2896,71 +2490,6 @@
\def\raisebox{\doraiselowerbox\raise}
\def\lowerbox{\doraiselowerbox\lower}
-% maybe some day we need this
-%
-% \def\appendvbox#1% % uses \box8
-% {\bgroup
-% \ifdim\prevdepth<\zeropoint
-% \ifdim\pagetotal=\zeropoint
-% \setbox8=\normalvtop{\unvcopy#1}%
-% \hrule\c!!height\zeropoint
-% \kern-\ht8
-% \box#1\relax
-% \else
-% \box#1\relax
-% \fi
-% \else
-% \dimen0=\prevdepth
-% \hrule\c!!height\zeropoint
-% \setbox8=\normalvtop{\unvcopy#1}%
-% \dimen2=\baselineskip
-% \advance\dimen2 by -\dimen0
-% \advance\dimen2 by -\ht8
-% \kern\dimen2
-% \box#1\relax
-% \fi
-% \egroup}
-
-% %D Also new:
-% %D
-% %D \startbuffer
-% %D \normbox[1cm][bba]{m} % b(efore) a(fter) v(box) s(trut) f(rame)
-% %D \normbox[1cm][bba]{m}
-% %D \normbox[1cm][bba]{m}
-% %D \stopbuffer
-% %D
-% %D \typebuffer
-% %D \getbuffer
-%
-% \def\dodonormbox#1#2#3#4#5#6#7%
-% {\doifnumberelse{#1}
-% {\dimen0=#1}{\setbox0=#3{#1}\dimen0=#50}%
-% \doifinstringelse{f}{#2}
-% {\let\next#4}{\let\next#3}%
-% \next to \dimen0
-% {\counttoken b\in#2\to\!!counta\dorecurse{\!!counta}{#6}#6%
-% #7\nextbox
-% \counttoken a\in#2\to\!!counta\dorecurse{\!!counta}{#6}#6}}
-%
-% \def\donormbox[#1][#2]%
-% {\bgroup
-% \doifinstringelse{v}{#2}
-% {\let\next\normalvbox}
-% {\let\next\normalhbox}%
-% \dowithnextbox
-% {\ifvbox\nextbox
-% \let\\=\par
-% \dodonormbox{#1}{#2}\normalvbox\ruledvbox\ht\vfil\unvbox
-% \else
-% \let\\=\space
-% \dodonormbox{#1}{#2}\normalhbox\ruledhbox\wd\hfil\unhbox
-% \fi
-% \egroup}%
-% \next}
-%
-% \def\normbox
-% {\dodoubleempty\donormbox}
-
% vcenter in text, we kunnen vcenter overloaden
\def\halfwaybox
@@ -3020,12 +2549,6 @@
%D
%D A prelude to an extended \TEX:
-% \def\setboxllx #1#2{\bgroup\scratchdimen#2\expanded{\egroup\noexpand\setevalue{b@@x\number#1}{\the\scratchdimen}}}
-% \def\setboxlly #1#2{\bgroup\scratchdimen#2\expanded{\egroup\noexpand\setevalue{b@@y\number#1}{\the\scratchdimen}}}
-%
-% \def\gsetboxllx#1#2{\bgroup\scratchdimen#2\setxvalue{b@@x\number#1}{\the\scratchdimen}\egroup}
-% \def\gsetboxlly#1#2{\bgroup\scratchdimen#2\setxvalue{b@@y\number#1}{\the\scratchdimen}\egroup}
-
\def\setboxllx#1#2{\setevalue{b@@x\number#1}{\the\dimexpr#2\relax}}
\def\setboxlly#1#2{\setevalue{b@@y\number#1}{\the\dimexpr#2\relax}}
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 13a546b5f..4fcd417a7 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 12/09/10 12:11:44
+-- merge date : 12/10/10 15:15:55
do -- begin closure to overcome local limits and interference