summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/anch-pgr.mkiv67
-rw-r--r--tex/context/base/back-pdf.mkiv6
-rw-r--r--tex/context/base/colo-ini.mkiv2
-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.pdfbin4074 -> 4076 bytes
-rw-r--r--tex/context/base/context-version.pngbin106363 -> 106332 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv10
-rw-r--r--tex/context/base/core-def.mkiv1
-rw-r--r--tex/context/base/grph-inc.mkiv23
-rw-r--r--tex/context/base/grph-trf.mkiv939
-rw-r--r--tex/context/base/m-visual.tex2
-rw-r--r--tex/context/base/meta-fig.mkiv2
-rw-r--r--tex/context/base/meta-ini.mkiv741
-rw-r--r--tex/context/base/meta-tex.mkiv121
-rw-r--r--tex/context/base/mlib-pps.mkiv11
-rw-r--r--tex/context/base/mult-aux.mkiv29
-rw-r--r--tex/context/base/mult-de.mkii4
-rw-r--r--tex/context/base/mult-def.lua12
-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-fst.mkiv41
-rw-r--r--tex/context/base/mult-it.mkii4
-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.mkiv11
-rw-r--r--tex/context/base/pack-fen.mkiv80
-rw-r--r--tex/context/base/pack-mrl.mkiv859
-rw-r--r--tex/context/base/pack-rul.mkiv2961
-rw-r--r--tex/context/base/page-imp.mkiv5
-rw-r--r--tex/context/base/page-mar.mkiv808
-rw-r--r--tex/context/base/ppchtex.mkiv6
-rw-r--r--tex/context/base/spac-ver.mkiv11
-rw-r--r--tex/context/base/status-files.pdfbin24684 -> 24079 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin170141 -> 169716 bytes
-rw-r--r--tex/context/base/syst-ini.mkiv1
-rw-r--r--tex/context/base/tabl-tab.mkiv4
-rw-r--r--tex/context/base/trac-vis.mkiv4
-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
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
49 files changed, 3045 insertions, 3780 deletions
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv
index 8d5b87893..a30a2e3eb 100644
--- a/tex/context/base/anch-pgr.mkiv
+++ b/tex/context/base/anch-pgr.mkiv
@@ -374,64 +374,51 @@
{\dodoublegroupempty\positions_mp_graphic_start}
\def\positions_mp_graphic_start#1#2#3\stopMPpositiongraphic % tag list mpcode
- {\setgvalue{MPG:#1}{\positions_mp_graphic_use{#1}{#2}{#3}}}
+ {\setgvalue{\??gp:#1}{\positions_mp_graphic_use{#1}{#2}{#3}}}
\let\stopMPpositiongraphic\relax
\def\positions_mp_graphic_prepare
- {\ifcsname\@@meta self\endcsname\else\letvalue{\@@meta self}\currentposition\fi
- \ifcsname\@@meta from\endcsname\else\letvalue{\@@meta from}\currentposition\fi}
+ {\ifcsname\??gv\currentmpvariableclass:self\endcsname \else
+ \letvalue{\??gv\currentmpvariableclass:self}\currentposition
+ \fi
+ \ifcsname\??gv\currentmpvariableclass:from\endcsname \else
+ \letvalue{\??gv\currentmpvariableclass:from}\currentposition
+ \fi}
\def\positions_mp_graphic_use#1#2#3%
{\begingroup
- \prepareMPvariables{#2}%
+ \mp_prepare_variables{#2}%
\positions_mp_graphic_prepare
- \enableincludeMPgraphics
\startMPcode#3\stopMPcode
\endgroup}
\def\MPpositiongraphic
{\dodoublegroupempty\positions_mp_graphic_direct}
-% \def\positions_mp_graphic_direct#1#2% tag setups
-% {\begingroup
-% \def\@@meta{#1:}%
-% \setupMPvariables[#2]%
-% \positions_mp_graphic_prepare
-% \MPshiftdrawingtrue
-% \def\positions_mp_graphic_direct{\positions_mp_graphic_nested{#2}}% takes two extra arguments
-% \setbox\positiongraphicbox\hbox
-% {\ignorespaces
-% \ifcsname MPM:#1\endcsname \csname MPM:#1\endcsname \else
-% \ifcsname MPG:#1\endcsname \csname MPG:#1\endcsname \fi\fi
-% \removelastspace}%
-% \smashbox\positiongraphicbox
-% \box\positiongraphicbox
-% \endgroup}
-
\def\positions_mp_graphic_direct#1% tag setups
- {\ifcsname MPM:#1\endcsname
- \expandafter\positions_mp_graphic_direct_indeed_mpm
- \else\ifcsname MPG:#1\endcsname
- \doubleexpandafter\positions_mp_graphic_direct_indeed_mpg
+ {\ifcsname\??gq:#1\endcsname % method
+ \expandafter\positions_mp_graphic_direct_indeed_method
+ \else\ifcsname \??gp:#1\endcsname
+ \doubleexpandafter\positions_mp_graphic_direct_indeed_normal
\else
- \doubleexpandafter\positions_mp_graphic_direct_indeed_nop
+ \doubleexpandafter\positions_mp_graphic_direct_indeed_unknown
\fi\fi{#1}}
-\let\positions_mp_graphic_direct_indeed_nop\gobbletwoarguments
+\let\positions_mp_graphic_direct_indeed_unknown\gobbletwoarguments
-\def\positions_mp_graphic_direct_indeed_mpm
- {\positions_mp_graphic_direct_indeed{MPM}}
+\def\positions_mp_graphic_direct_indeed_method
+ {\positions_mp_graphic_direct_indeed\??gq}
-\def\positions_mp_graphic_direct_indeed_mpg
- {\positions_mp_graphic_direct_indeed{MPG}}
+\def\positions_mp_graphic_direct_indeed_normal
+ {\positions_mp_graphic_direct_indeed\??gp}
\def\positions_mp_graphic_direct_indeed#1#2#3% what tag setups
{\begingroup
- \def\@@meta{#2:}% will become a commandhandler
- \setupMPvariables[#3]%
+ \setupMPvariables[#2][#3]%
+ \edef\currentmpvariableclass{#2}%
\positions_mp_graphic_prepare
- \MPshiftdrawingtrue
+ \ignoreMPboxdepth
\def\positions_mp_graphic_direct{\positions_mp_graphic_nested{#3}}% takes two extra arguments
\setbox\positiongraphicbox\hbox
{\ignorespaces\csname#1:#2\endcsname\removelastspace}%
@@ -439,16 +426,16 @@
\box\positiongraphicbox
\endgroup}
-\def\positions_mp_graphic_nested#1#2#3% nesting used in prikkels / pascal
+\def\positions_mp_graphic_nested#1#2#3% nesting used in prikkels / pascal (might go away)
{\begingroup
- \def\@@meta{#2:}%
- \setupMPvariables[#1,#3]%
+ \setupMPvariables[#2][#1,#3]%
+ \edef\currentmpvariableclass{#2}%
\positions_mp_graphic_prepare
- \getvalue{MPG:#2}%
+ \getvalue{\??gp:#2}%
\endgroup}%
-\long\def\startMPpositionmethod#1#2\stopMPpositionmethod
- {\long\setgvalue{MPM:#1}{#2}} % todo: var list here
+\def\startMPpositionmethod#1#2\stopMPpositionmethod
+ {\setgvalue{\??gq:#1}{#2}} % todo: var list here
\let\stopMPpositionmethod\relax
diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv
index f84f83fe5..bd0b12733 100644
--- a/tex/context/base/back-pdf.mkiv
+++ b/tex/context/base/back-pdf.mkiv
@@ -195,10 +195,10 @@
\pdfrestore
\advance\backendtransformlevel\minusone}}}
-\unexpanded\def\dostartclipping#1#2#3% todo (still needed?) (can move to lua)
+\unexpanded\def\dostartclipping#1#2#3%
{\PointsToBigPoints{#2}\width
\PointsToBigPoints{#3}\height
- \grabMPclippath{#1}{1}\width\height{0 0 m \width\space 0 l \width \height l 0 \height l}%
+ \mp_grab_clip_path{#1}\width\height{0 0 m \width\space 0 l \width \height l 0 \height l}%
\pdfliteral{q 0 w \MPclippath\space W n}}
\unexpanded\def\dostopclipping
@@ -271,7 +271,7 @@
\def\doPDFovalcalc#1#2#3%
{\PointsToBigPoints{\dimexpr#1+#2\relax}#3}
-\def\doovalbox#1#2#3#4#5#6#7#8% todo: \scratchdimen/\scatchbox
+\unexpanded\def\doovalbox#1#2#3#4#5#6#7#8% todo: \scratchdimen/\scatchbox
{\forcecolorhack
\bgroup
\dimen0=#4\divide\dimen0 \plustwo
diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv
index a6ed41f84..6c752f3ae 100644
--- a/tex/context/base/colo-ini.mkiv
+++ b/tex/context/base/colo-ini.mkiv
@@ -78,7 +78,7 @@
%D space||saving option.
\newif\iffreezecolors \freezecolorsfalse
-\newif\ifincolor % true if colors enabled
+\newif\ifincolor % not used outside this module
\let\colorlist \empty
\let\currentspotcolor \empty
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index fb902b969..0466969b7 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.12.20 22:24}
+\newcontextversion{2011.12.22 14:43}
%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 c1d171e1c..40cf787a2 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.12.20 22:24}
+\newcontextversion{2011.12.22 14:43}
%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 1ac486ff4..3e856f3ca 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 ef1101611..4069ff91e 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 6a88bb415..45d5a131d 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.12.20 22:24}
+\edef\contextversion{2011.12.22 14:43}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index a3bd91b91..48c8dcea9 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -19,8 +19,11 @@
%D 2004.8.30 the low level interface is english. Watch out and adapt
%D your styles an modules.
+%D The order of loading will change when all modules have been cleaned
+%D up and the dependencies are more consistent.
+
\edef\contextformat {\jobname}
-\edef\contextversion{2011.12.20 22:24}
+\edef\contextversion{2011.12.22 14:43}
%D For those who want to use this:
@@ -64,7 +67,7 @@
\newtoks\contextversiontoks \contextversiontoks\expandafter{\contextversion}
-%D Now the more fundamnetal code gets defined.
+%D Now the more fundamental code gets defined.
\loadmarkfile{norm-ctx}
\loadmarkfile{syst-pln}
@@ -103,7 +106,6 @@
\loadmarkfile{char-act}
\loadmarkfile{mult-ini}
-%loadmarkfile{mult-fst} % obsolete
\loadmarkfile{mult-sys}
\loadmarkfile{mult-def}
\loadmarkfile{mult-chk}
@@ -197,6 +199,7 @@
\loadmkvifile{pack-mis}
\loadmarkfile{pack-rul}
+\loadmarkfile{pack-mrl}
\loadmkvifile{pack-bck}
\loadmarkfile{pack-fen}
@@ -271,7 +274,6 @@
\loadmarkfile{page-lin}
\loadmarkfile{page-par}
-%loadmarkfile{page-mar} % also commented code in anch-pgr.mkiv
\loadmarkfile{typo-pag}
\loadmarkfile{typo-mar}
diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv
index 3a07980cc..13cfd5bc4 100644
--- a/tex/context/base/core-def.mkiv
+++ b/tex/context/base/core-def.mkiv
@@ -39,7 +39,6 @@
\appendtoks \loadoptionfile \to \everyjob % can load files !
\appendtoks \firststagepreloadfonts \to \everyjob
\appendtoks \settopskip \to \everyjob
-\appendtoks \initializeMPgraphics \to \everyjob % after loading system files
\appendtoks \initializemainlanguage \to \everyjob
%appendtoks \MPLIBregister \to \everyjob
\appendtoks \xmlinitialize \to \everyjob
diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv
index b403fa8e1..4c664321a 100644
--- a/tex/context/base/grph-inc.mkiv
+++ b/tex/context/base/grph-inc.mkiv
@@ -227,8 +227,29 @@
\def\docheckfiguremps #1{\doprocessmpslikefigure{#1}}
\def\docheckfiguremprun #1#2{\doprocesstexlikefigure{\useMPrun{#1}{#2}}}
+% \def\doscalefigure
+% {\global\setbox\foundexternalfigure\vbox{\doscalebox\??ef{\dowithfigure{\box\foundexternalfigure}}}}
+
\def\doscalefigure
- {\global\setbox\foundexternalfigure\vbox{\doscalebox\??ef{\dowithfigure{\box\foundexternalfigure}}}}
+ {\global\setbox\foundexternalfigure\vbox{\scale[\v!figure]{\dowithfigure{\box\foundexternalfigure}}}}
+
+% quick hack: chaining \??ef via \s!parent happens when this is also a commandhandler
+
+\definescale
+ [\v!figure]
+ [\c!hfactor =\@@efhfactor ,
+ \c!wfactor =\@@efwfactor ,
+ \c!factor =\@@effactor ,
+ \c!maxwidth =\@@efmaxwidth ,
+ \c!maxheight=\@@efmaxheight,
+ \c!xscale =\@@efxscale ,
+ \c!yscale =\@@efyscale ,
+ \c!scale =\@@efscale ,
+ \c!sx =\@@efsx ,
+ \c!sy =\@@efsy ,
+ \c!width =\@@efwidth ,
+ \c!height =\@@efheight ,
+ \c!lines =\@@eflines ]
\newconditional\testexternalfigureonly
diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv
index 4801a2aa5..2e7e497e2 100644
--- a/tex/context/base/grph-trf.mkiv
+++ b/tex/context/base/grph-trf.mkiv
@@ -1,5 +1,5 @@
%D \module
-%D [ file=grph-fig,
+%D [ file=grph-trf,
%D version=2006.08.26, % overhaul/split of 1997.03.31 core-fig
%D title=\CONTEXT\ Graphic Macros,
%D subtitle=Transformations,
@@ -11,44 +11,55 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D It may be that some functionality got lost. If it concerns
-%D defined features, let me know and it will be sorted out.
-
-%D We will move the calculations to \LUA\ and clean up this
-%D lot anyway.
-
\writestatus{loading}{ConTeXt Graphic Macros / Transformations}
\unprotect
-%D Scaling:
+%D We probably use too many dimens as the width calculations can
+%D go away. Some of this is an inheritance of limited backends
+%D (some supported fractions, some 1000's, some dimentions) so
+%D we calculate all of them. Nowadays scaling is always available
+%D so we could simplify the code. On the other hand, we now get
+%D some extra values for free.
+%D
+%D We could move the calculations to \LUA\ and clean up this
+%D lot anyway. On the other hand, there is some danger of messing
+%D up so it has a real low priority.
-\unexpanded\def\scale{\dodoubleempty\doscalenextbox[\??xy]}
+% local:
-% probably too many dimens / the width calculations can go
-% since we may assume scaling is available (was not true
-% long ago which is why we also calculate the width)
+\newdimen\d_transforms_scale_x_size
+\newdimen\d_transforms_scale_y_size
+\newdimen\d_transforms_scale_x_offset
+\newdimen\d_transforms_scale_y_offset
-\newdimen\scaleboxwidth
-\newdimen\scaleboxheight
-\newdimen\scaleboxdepth
+\newdimen\d_transforms_scale_h_size
+\newdimen\d_transforms_scale_v_size
-\newdimen\scaleboxsizex
-\newdimen\scaleboxsizey
-\newdimen\scaleboxoffsetx
-\newdimen\scaleboxoffsety
+\newconditional\c_transforms_scale_done
+\newconditional\c_transforms_scale_scaling_done
-\newdimen\scaleboxhsize
-\newdimen\scaleboxvsize
+\newdimen\d_transforms_scale_wd
+\newdimen\d_transforms_scale_ht
+\newdimen\d_transforms_scale_dp
% global
-\newdimen\scaleboxdimx \let\figwid \scaleboxdimx
-\newdimen\scaleboxdimy \let\fighei \scaleboxdimy
-\newcount\scaleboxscax \let\figxsca\scaleboxscax
-\newcount\scaleboxscay \let\figysca\scaleboxscay
+\newdimen\d_transforms_scale_used_x_size
+\newdimen\d_transforms_scale_used_y_size
+
+\newcount\c_transforms_scale_used_x_scale
+\newcount\c_transforms_scale_used_y_scale
+
+\newdimen\d_transforms_scale_outer_v_size % we cannot manipulate any global vsize !
-\newdimen\scaleboxoutervsize % we cannot manipulate any global vsize !
+% scratch:
+
+\let\m_transforms_scale_temp \empty
+\let\m_transforms_scale_temp_x\empty
+\let\m_transforms_scale_temp_y\empty
+
+% public:
\let\finalscaleboxxscale \!!plusone
\let\finalscaleboxyscale \!!plusone
@@ -57,380 +68,417 @@
\let\finalscaleboxxfactor\!!hundred
\let\finalscaleboxyfactor\!!hundred
-\newconditional\scaleboxdone
-
-\def\doscalenextbox[#1][#2]%
+% we can let sx/sy win (first check)
+
+\installcommandhandler \??xy {scale} \??xy % we can have instances
+
+\setupscale
+ [\c!sx=1,
+ \c!sy=1,
+ %\c!scale=,
+ %\c!xscale=,
+ %\c!yscale=,
+ %\c!width=,
+ %\c!height=,
+ %\c!lines=,
+ %\c!factor=,
+ %\c!hfactor=,
+ %\c!wfactor=,
+ %\c!grid=,
+ %\c!equalwidth=,
+ %\c!equalheight=,
+ \c!maxwidth=\scaleparameter\c!width,
+ \c!maxheight=\scaleparameter\c!height]
+
+\unexpanded\def\scale{\dodoubleempty\transforms_scale}
+
+% we could have: \freezeparameter\c!scale etc (less backtracking when used multiple)
+
+\def\transforms_scale[#1][#2]%
{\bgroup
- \getparameters
- [#1]
- [\c!scale=,\c!xscale=,\c!yscale=,\c!width=,\c!height=,\c!lines=,
- \c!factor=,\c!hfactor=,\c!wfactor=,\c!grid=,\c!sx=1,\c!sy=1,
- \c!equalwidth=,\c!equalheight=,
- \c!maxwidth=\scaleparameter\c!width,\c!maxheight=\scaleparameter\c!height,
- #2]%
- \dowithnextbox{\dodoscalenextbox{#1}\egroup}\hbox}
-
-\def\doscalebox#1%
- {\bgroup\dowithnextbox{\dodoscalenextbox{#1}\egroup}\hbox}
-
-\let\currentscaletag\??xy
-
-\def\scaleparameter#1%
- {\csname\currentscaletag#1\endcsname}
-
-\def\setscaleparameter#1#2%
- {\setvalue{\currentscaletag#1}{#2}}
-
-\def\dodoscalenextbox#1%
- {\edef\currentscaletag{#1}%
- \doif{\scaleparameter\c!depth}\v!no{\setbox\nextbox\hbox{\raise\nextboxdp\box\nextbox}}% new
- \forgetall
- \dontshowcomposition
- \dontcomplain
- \doscaleboxcalculations
- \doscaleboxindeed
- \doscaleboxposition
- \flushnextbox}
-
-\def\doscaleboxindeed
- {\ifconditional\scaleboxdone
- \scaleboxwidth \finalscaleboxxscale\nextboxwd
- \scaleboxheight\finalscaleboxyscale\nextboxht
- \scaleboxdepth \finalscaleboxyscale\nextboxdp
- \setbox\nextbox\hbox
- {\dostartscaling \finalscaleboxxscale \finalscaleboxyscale
- \smashedbox\nextbox
- \dostopscaling}%
- \nextboxwd\scaleboxwidth
- \nextboxht\scaleboxheight
- \nextboxdp\scaleboxdepth
- \fi}
-
-\def\doscaleboxcalculations
- {\setfalse\scaleboxdone
- % initial final value
+ % this is quite common so we might make this a helper
+ \ifsecondargument
+ \edef\currentscale{#1}%
+ \setupcurrentscale[#2]%
+ \else\iffirstargument
+ \doifassignmentelse{#1}
+ {\let\currentscale\empty
+ \setupcurrentscale[#1]}
+ {\edef\currentscale{#1}}%
+ \else
+ \let\currentscale\empty
+ \fi\fi
+ %
+ \dowithnextboxcs\transforms_scale_finish\hbox}
+
+\def\transforms_scale_finish
+ {%
+ \edef\p_scale {\scaleparameter\c!scale }%
+ \edef\p_xscale {\scaleparameter\c!xscale }%
+ \edef\p_yscale {\scaleparameter\c!yscale }%
+ \edef\p_width {\scaleparameter\c!width }%
+ \edef\p_height {\scaleparameter\c!height }%
+ \edef\p_depth {\scaleparameter\c!depth }%
+ \edef\p_lines {\scaleparameter\c!lines }%
+ \edef\p_factor {\scaleparameter\c!factor }%
+ \edef\p_hfactor {\scaleparameter\c!hfactor }%
+ \edef\p_wfactor {\scaleparameter\c!wfactor }%
+ % \edef\p_grid {\scaleparameter\c!grid }% used once
+ \edef\p_maxwidth {\scaleparameter\c!maxwidth }%
+ \edef\p_maxheight {\scaleparameter\c!maxheight }%
+ \edef\p_sx {\scaleparameter\c!sx }%
+ \edef\p_sy {\scaleparameter\c!sy }%
+ \edef\p_equalwidth {\scaleparameter\c!equalwidth }%
+ \edef\p_equalheight{\scaleparameter\c!equalheight}%
+ %
+ \d_transforms_scale_dp\dp\nextbox
+ \ifx\p_depth\v!no \ifzeropt\d_transforms_scale_dp \else
+ \setbox\nextbox\hbox{\raise\d_transforms_scale_dp\box\nextbox}% new
+ \d_transforms_scale_dp\dp\nextbox
+ \fi \fi
+ \d_transforms_scale_wd\wd\nextbox
+ \d_transforms_scale_ht\ht\nextbox
+ \d_transforms_scale_dp\dp\nextbox
+ %
\global\let\finalscaleboxxscale \!!plusone
\global\let\finalscaleboxyscale \!!plusone
- \xdef \finalscaleboxwidth {\the\nextboxwd}%
- \xdef \finalscaleboxheight{\the\nextboxht}%
+ \xdef \finalscaleboxwidth {\the\d_transforms_scale_wd}%
+ \xdef \finalscaleboxheight{\the\d_transforms_scale_ht}%
\global\let\finalscaleboxxfactor\!!hundred
\global\let\finalscaleboxyfactor\!!hundred
- \ifdim\nextboxht>\zeropoint \ifdim\nextboxwd>\zeropoint
- % hm, still useful? better in lua anyway
- \edef\scaleboxstampa % slow way [can be combined]
- {\scaleparameter\c!scale \scaleparameter\c!xscale \scaleparameter\c!yscale
- \scaleparameter\c!factor\scaleparameter\c!wfactor\scaleparameter\c!hfactor
- \scaleparameter\c!lines \scaleparameter\c!width \scaleparameter\c!height}%
- \edef\scaleboxstampb % fast way [just sx/sy]
- {\scaleparameter\c!sx
- \scaleparameter\c!sy}%
- \edef\scaleboxstampc
- {11}%
- \ifx\scaleboxstampa\empty
- \ifx\scaleboxstampb\scaleboxstampc
- % no scaling, but still check; new, gone again
-% wrong: scaled proportionally as side effect
-% \doifsomething{\scaleparameter\c!maxwidth }{\letvalue{\currentscaletag\c!factor}\v!fit}%
-% \doifsomething{\scaleparameter\c!maxheight}{\letvalue{\currentscaletag\c!factor}\v!fit}%
+ %
+ \forgetall
+ \dontshowcomposition
+ \dontcomplain
+ %
+ \setfalse\c_transforms_scale_done
+ \transforms_scale_calculate
+ \ifconditional\c_transforms_scale_done
+ \transforms_scale_apply
+ \fi
+ \transforms_scale_position
+ %
+ \box\nextbox
+ \egroup}
+
+\def\transforms_scale_apply
+ {\d_transforms_scale_wd\finalscaleboxxscale\d_transforms_scale_wd
+ \d_transforms_scale_ht\finalscaleboxyscale\d_transforms_scale_ht
+ \d_transforms_scale_dp\finalscaleboxyscale\d_transforms_scale_dp
+ \setbox\nextbox\hbox
+ {\dostartscaling \finalscaleboxxscale \finalscaleboxyscale
+ \smashedbox\nextbox
+ \dostopscaling}%
+ \wd\nextbox\d_transforms_scale_wd
+ \ht\nextbox\d_transforms_scale_ht
+ \dp\nextbox\d_transforms_scale_dp}
+
+\def\m_transforms_scale_stamp_c{11}
+
+\def\transforms_scale_calculate
+ {\ifdim\d_transforms_scale_ht>\zeropoint \ifdim\d_transforms_scale_wd>\zeropoint
+ \edef\m_transforms_scale_stamp_a{\p_scale\p_xscale\p_yscale\p_factor\p_wfactor\p_hfactor\p_lines\p_width\p_height}%
+ \edef\m_transforms_scale_stamp_b{\p_sx\p_sy}%
+ \ifx\m_transforms_scale_stamp_a\empty
+ \ifx\m_transforms_scale_stamp_b\m_transforms_scale_stamp_c
+ % no scaling, don't change this (previous attempts failed anyway)
\insidefloattrue % trick
- \dodoscaleboxcalculations
+ \transforms_scale_calculations_yes
\else
- \dosetscalboxsxsy
- \nodoscaleboxcalculations
+ \transforms_scale_check_sx_sy
+ \transforms_scale_calculations_nop
\fi
\else
- \ifx\scaleboxstampb\empty
+ \ifx\m_transforms_scale_stamp_b\empty
% no need to check further
\else
- \dosetscalboxsxsy
+ \transforms_scale_check_sx_sy
\fi
- \dodoscaleboxcalculations
+ \transforms_scale_calculations_yes
\fi
\fi \fi}
-\def\dosetscalboxsxsy
- {\ifdim\scaleparameter\c!sx\onepoint=\onepoint\else
- \setevalue{\currentscaletag\c!width }{\the\dimexpr\scaleparameter\c!sx\wd\nextbox\relax}%
- \fi
- \ifdim\scaleparameter\c!sy\onepoint=\onepoint\else
- \setevalue{\currentscaletag\c!height}{\the\dimexpr\scaleparameter\c!sy\ht\nextbox\relax}%
- \fi}
+\def\transforms_scale_check_sx_sy
+ {\ifdim\p_sx\onepoint=\onepoint\else\edef\p_width {\the\dimexpr\p_sx\d_transforms_scale_wd}\fi
+ \ifdim\p_sy\onepoint=\onepoint\else\edef\p_height{\the\dimexpr\p_sy\d_transforms_scale_ht}\fi}
-\def\doscaleboxrounding#1.#2\relax{#1}
+\def\transforms_scale_rounded#1%
+ {\expandafter\expandafter\expandafter\transforms_scale_rounded_indeed
+ \expandafter\WITHOUTPT\the\dimexpr#1\points*100+32768sp\relax.\relax}
-\def\scaleboxrounding#1%
- {\@EA\@EA\@EA\doscaleboxrounding\@EA\WITHOUTPT\the\dimexpr#1\points*100+32768sp\relax.\relax}
+\def\transforms_scale_rounded_indeed#1.#2\relax{#1}
-\def\nodoscaleboxcalculations
- {\settrue\scaleboxdone
- \xdef\finalscaleboxwidth {\the\dimexpr\scaleparameter\c!sx\wd\nextbox\relax}%
- \xdef\finalscaleboxheight {\the\dimexpr\scaleparameter\c!sy\ht\nextbox\relax}%
- \xdef\finalscaleboxxscale {\scaleparameter\c!sx}%
- \xdef\finalscaleboxyscale {\scaleparameter\c!sy}%
+\def\transforms_scale_calculations_nop
+ {\settrue\c_transforms_scale_done
+ \xdef\finalscaleboxwidth {\the\dimexpr\p_sx\d_transforms_scale_wd\relax}%
+ \xdef\finalscaleboxheight{\the\dimexpr\p_sy\d_transforms_scale_ht\relax}%
+ \glet\finalscaleboxxscale\p_sx
+ \glet\finalscaleboxyscale\p_sy
\ifx\finalscaleboxxscale\empty\let\finalscaleboxxscale\!!plusone\fi
\ifx\finalscaleboxyscale\empty\let\finalscaleboxyscale\!!plusone\fi
- \xdef\finalscaleboxxfactor{\scaleboxrounding\finalscaleboxxscale}%
- \xdef\finalscaleboxyfactor{\scaleboxrounding\finalscaleboxyscale}}
+ \xdef\finalscaleboxxfactor{\transforms_scale_rounded\finalscaleboxxscale}%
+ \xdef\finalscaleboxyfactor{\transforms_scale_rounded\finalscaleboxyscale}}
-\def\dodoscaleboxcalculations
- {\settrue\scaleboxdone
+\def\transforms_scale_calculations_yes
+ {\settrue\c_transforms_scale_done
% initial values
- \scaleboxoffsetx\zeropoint
- \scaleboxoffsety\zeropoint
- \scaleboxsizex \nextboxwd
- \scaleboxsizey \nextboxht % alleen ht wordt geschaald!
+ \d_transforms_scale_x_offset\zeropoint
+ \d_transforms_scale_y_offset\zeropoint
+ \d_transforms_scale_x_size \d_transforms_scale_wd
+ \d_transforms_scale_y_size \d_transforms_scale_ht % alleen ht wordt geschaald!
% final values
- \global\scaleboxdimx \zeropoint % see note * (core-fig)
- \global\scaleboxdimy \zeropoint % see note * (core-fig)
- \scaleboxscax \plusone % see note * (core-fig)
- \scaleboxscay \plusone % see note * (core-fig)
+ \global\d_transforms_scale_used_x_size \zeropoint % see note * (core-fig)
+ \global\d_transforms_scale_used_y_size \zeropoint % see note * (core-fig)
+ \c_transforms_scale_used_x_scale \plusone % see note * (core-fig)
+ \c_transforms_scale_used_y_scale \plusone % see note * (core-fig)
% preparations
- \setfalse\scaleboxscalingdone
- \checkscaleboxsettings
+ \setfalse\c_transforms_scale_scaling_done
+ \transforms_scale_check_parameters
% calculators
% beware, they operate in sequence, and calculate missing dimensions / messy
%setscaleboxbynature % when? needed?
- \ifconditional\scaleboxscalingdone\else\setscaleboxbyfactor \fi
- \ifconditional\scaleboxscalingdone\else\setscaleboxbyscale \fi
- \ifconditional\scaleboxscalingdone\else\setscaleboxbydimension\fi
+ \ifconditional\c_transforms_scale_scaling_done\else\transforms_scale_by_factor \fi
+ \ifconditional\c_transforms_scale_scaling_done\else\transforms_scale_by_scale \fi
+ \ifconditional\c_transforms_scale_scaling_done\else\transforms_scale_by_dimension\fi
% finalizers / to be done (no longer needed this way, clean up)
- \convertscaleboxinsertscale\scaleboxhsize\figx\scaleboxscax\scax
- \convertscaleboxinsertscale\scaleboxvsize\figy\scaleboxscay\scay
+ \transforms_scale_convert_large_scale\d_transforms_scale_h_size\figx\c_transforms_scale_used_x_scale\m_transforms_scale_temp_x
+ \transforms_scale_convert_large_scale\d_transforms_scale_v_size\figy\c_transforms_scale_used_y_scale\m_transforms_scale_temp_y
% used in actual scaling
- \xdef\finalscaleboxwidth {\the\scaleboxdimx}%
- \xdef\finalscaleboxheight {\the\scaleboxdimy}%
- \xdef\finalscaleboxxfactor{\the\scaleboxscax}%
- \xdef\finalscaleboxyfactor{\the\scaleboxscay}%
- \xdef\finalscaleboxxscale {\withoutpt\the\dimexpr\scax\points/\plushundred\relax}%
- \xdef\finalscaleboxyscale {\withoutpt\the\dimexpr\scay\points/\plushundred\relax}}
-
-\setvalue{\??xy:\c!grid:\v!yes }{\getnoflines \fighei\setevalue{\currentscaletag\c!height}{\the\noflines\lineheight}}
-\setvalue{\??xy:\c!grid:\v!height }{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\dimexpr\noflines\lineheight+\strutdepth\relax}}
-\setvalue{\??xy:\c!grid:\v!depth }{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\dimexpr\noflines\lineheight-\strutdepth\relax}}
-\setvalue{\??xy:\c!grid:\v!halfline}{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\dimexpr\noflines\lineheight+.5\lineheight\relax}}
-\setvalue{\??xy:\c!grid:\v!fit }{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\noflines\lineheight}}
+ \xdef\finalscaleboxwidth {\the\d_transforms_scale_used_x_size}%
+ \xdef\finalscaleboxheight {\the\d_transforms_scale_used_y_size}%
+ \xdef\finalscaleboxxfactor{\the\c_transforms_scale_used_x_scale}%
+ \xdef\finalscaleboxyfactor{\the\c_transforms_scale_used_y_scale}%
+ \xdef\finalscaleboxxscale {\withoutpt\the\dimexpr\m_transforms_scale_temp_x\points/\plushundred\relax}%
+ \xdef\finalscaleboxyscale {\withoutpt\the\dimexpr\m_transforms_scale_temp_y\points/\plushundred\relax}}
+
+\setvalue{\??xy:\c!grid:\v!yes }{\getnoflines \d_transforms_scale_used_y_size\edef\p_height{\the\noflines\lineheight}}
+\setvalue{\??xy:\c!grid:\v!height }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight+\strutdepth}}
+\setvalue{\??xy:\c!grid:\v!depth }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight-\strutdepth}}
+\setvalue{\??xy:\c!grid:\v!halfline}{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight+.5\lineheight}}
+\setvalue{\??xy:\c!grid:\v!fit }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\noflines\lineheight}}
\letvalue{\??xy:\c!grid:\empty }\donothing
-\def\checkscaleboxsettings
- {\doifsomething{\scaleparameter\c!maxwidth }% can be defined in itself
- {\setevalue{\currentscaletag\c!maxwidth }{\the\dimexpr\scaleparameter\c!maxwidth \relax}}%
- \doifsomething{\scaleparameter\c!maxheight}% can be defined in itself
- {\setevalue{\currentscaletag\c!maxheight}{\the\dimexpr\scaleparameter\c!maxheight\relax}}%
- \doifsomething{\scaleparameter\c!lines}
- {\setevalue{\currentscaletag\c!height}{\the\dimexpr\scaleparameter\c!lines\lineheight\relax}}%
+\def\transforms_scale_check_parameters % resolve self referencing loops
+ {\ifx\p_maxwidth \empty\else \edef\p_maxwidth {\the\dimexpr\p_maxwidth }\fi
+ \ifx\p_maxheight\empty\else \edef\p_maxheight{\the\dimexpr\p_maxheight }\fi
+ \ifx\p_lines \empty\else \edef\p_height {\the\dimexpr\p_lines\lineheight}\fi
\getvalue{\??xy:\c!grid:\scaleparameter\c!grid}}
-\def\setscaleboxbynature % where ! ! ! ! !
- {\doifsomething{\scaleparameter\c!width }{\global\scaleboxdimx\scaleparameter\c!width }%
- \doifsomething{\scaleparameter\c!height}{\global\scaleboxdimy\scaleparameter\c!height}%
- \doifsomething{\scaleparameter\c!scale } {\scaleboxscax\scaleparameter\c!scale
- \scaleboxscay\scaleparameter\c!scale }%
- \doifsomething{\scaleparameter\c!xscale} {\scaleboxscax\scaleparameter\c!xscale}%
- \doifsomething{\scaleparameter\c!yscale} {\scaleboxscay\scaleparameter\c!yscale}} % oeps, was x
+\def\transforms_scale_by_nature % where ! ! ! ! !
+ {\ifx\p_width \empty\else \global\d_transforms_scale_used_x_size\p_width \fi
+ \ifx\p_height\empty\else \global\d_transforms_scale_used_y_size\p_height\fi
+ \ifx\p_scale \empty\else \c_transforms_scale_used_x_scale\p_scale
+ \c_transforms_scale_used_y_scale\p_scale \fi
+ \ifx\p_xscale\empty\else \c_transforms_scale_used_x_scale\p_xscale\fi
+ \ifx\p_yscale\empty\else \c_transforms_scale_used_y_scale\p_yscale\fi}
% \defineexternalfigure[width-6][factor=auto,maxwidth=\textheight,maxheight=\textwidth]
% \defineexternalfigure[width-7][factor=auto,maxwidth=\textwidth,maxheight=\textheight]
% \placefigure{none}{\rotate[frame=on,offset=overlay]{\externalfigure[t:/sources/cow.pdf][width-6]}} \page
% \placefigure{none}{\framed[frame=on,offset=overlay]{\externalfigure[t:/sources/cow.pdf][width-7]}}
-\def\setscaleboxbyfactor
- {\doifinsetelse{\scaleparameter\c!factor}{\v!max,\v!fit,\v!broad,\v!auto}
- {\doapplyscaleboxsize
- \ifdim\scaleboxsizex>\scaleboxsizey
- \docalculatescaleboxnorm \scaleboxdimx\c!factor\c!maxwidth\hsize\scaleboxhsize
- \docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey
- \else
- \docalculatescaleboxnorm \scaleboxdimy\c!factor\c!maxheight\scaleboxoutervsize\scaleboxvsize
- \docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex
- \fi
- \donetrue}
- {\doifinsetelse{\scaleparameter\c!hfactor}{\v!max,\v!fit,\v!broad,\v!auto}
- {\doapplyscaleboxsize
- \docalculatescaleboxnorm \scaleboxdimy\c!hfactor\c!maxheight\scaleboxoutervsize\scaleboxvsize
- \docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex
- \donetrue}
- {\doifinsetelse{\scaleparameter\c!wfactor}{\v!max,\v!fit,\v!broad,\v!auto}
- {\doapplyscaleboxsize
- \docalculatescaleboxnorm \scaleboxdimx\c!wfactor\c!maxwidth\hsize\scaleboxhsize
- \docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey
- \donetrue}
- {\docalculatescaleboxnorm\scaleboxdimy\c!factor \c!height \textheight\scaleboxvsize
- \docalculatescaleboxnorm\scaleboxdimy\c!hfactor\c!height \textheight\scaleboxvsize
- \docalculatescaleboxnorm\scaleboxdimx\c!wfactor\c!width \hsize \hsize
- \donefalse}}}%
- \ifdone
- \settrue\scaleboxscalingdone
- \ifdim\scaleboxdimx>\scaleboxhsize
- \global\scaleboxdimy\zeropoint \global\scaleboxdimx\scaleboxhsize
- \else\ifdim\scaleboxdimy>\scaleboxvsize
- \global\scaleboxdimx\zeropoint \global\scaleboxdimy\scaleboxvsize
- \fi\fi
- \setscaleboxbydimension
+\def\m_transforms_scale_factor_set{\v!max,\v!fit,\v!broad,\v!auto} % can be an \edef
+
+\def\transforms_scale_by_factor
+ {\doifinsetelse\p_factor\m_transforms_scale_factor_set
+ \transforms_scale_by_factor_a
+ {\doifinsetelse\p_hfactor\m_transforms_scale_factor_set
+ \transforms_scale_by_factor_b
+ {\doifinsetelse\p_wfactor\m_transforms_scale_factor_set
+ \transforms_scale_by_factor_c
+ \transforms_scale_by_factor_d}}}
+
+\def\transforms_scale_by_factor_a
+ {\transforms_scale_apply_size
+ \ifdim\d_transforms_scale_x_size>\d_transforms_scale_y_size
+ \transforms_scale_calculate_norm \d_transforms_scale_used_x_size\p_factor\p_maxwidth\hsize\d_transforms_scale_h_size
+ \transforms_scale_calculate_scales\d_transforms_scale_used_x_size\d_transforms_scale_x_size\d_transforms_scale_used_y_size\d_transforms_scale_y_size
+ \else
+ \transforms_scale_calculate_norm \d_transforms_scale_used_y_size\p_factor\p_maxheight\d_transforms_scale_outer_v_size\d_transforms_scale_v_size
+ \transforms_scale_calculate_scales\d_transforms_scale_used_y_size\d_transforms_scale_y_size\d_transforms_scale_used_x_size\d_transforms_scale_x_size
+ \fi
+ \transforms_scale_by_factor_indeed}
+
+\def\transforms_scale_by_factor_b
+ {\transforms_scale_apply_size
+ \transforms_scale_calculate_norm \d_transforms_scale_used_y_size\p_hfactor\p_maxheight\d_transforms_scale_outer_v_size\d_transforms_scale_v_size
+ \transforms_scale_calculate_scales\d_transforms_scale_used_y_size\d_transforms_scale_y_size\d_transforms_scale_used_x_size\d_transforms_scale_x_size
+ \transforms_scale_by_factor_indeed}
+
+\def\transforms_scale_by_factor_c
+ {\transforms_scale_apply_size
+ \transforms_scale_calculate_norm \d_transforms_scale_used_x_size\p_wfactor\p_maxwidth\hsize\d_transforms_scale_h_size
+ \transforms_scale_calculate_scales\d_transforms_scale_used_x_size\d_transforms_scale_x_size\d_transforms_scale_used_y_size\d_transforms_scale_y_size
+ \transforms_scale_by_factor_indeed}
+
+\def\transforms_scale_by_factor_d
+ {\transforms_scale_calculate_norm\d_transforms_scale_used_y_size\p_factor \p_height \textheight\d_transforms_scale_v_size
+ \transforms_scale_calculate_norm\d_transforms_scale_used_y_size\p_hfactor\p_height \textheight\d_transforms_scale_v_size
+ \transforms_scale_calculate_norm\d_transforms_scale_used_x_size\p_wfactor\p_width \hsize \hsize}
+
+\def\transforms_scale_by_factor_indeed
+ {\settrue\c_transforms_scale_scaling_done
+ \ifdim\d_transforms_scale_used_x_size>\d_transforms_scale_h_size
+ \global\d_transforms_scale_used_y_size\zeropoint
+ \global\d_transforms_scale_used_x_size\d_transforms_scale_h_size
+ \else\ifdim\d_transforms_scale_used_y_size>\d_transforms_scale_v_size
+ \global\d_transforms_scale_used_x_size\zeropoint
+ \global\d_transforms_scale_used_y_size\d_transforms_scale_v_size
+ \fi\fi
+ \transforms_scale_by_dimension}
+
+\def\transforms_scale_by_scale
+ {\edef\m_transforms_scale_temp{\p_scale\p_xscale\p_yscale}%
+ \ifx\m_transforms_scale_temp\empty \else
+ \transforms_scale_apply_scale\d_transforms_scale_used_x_size\d_transforms_scale_x_size\c_transforms_scale_used_x_scale\p_xscale
+ \transforms_scale_apply_scale\d_transforms_scale_used_y_size\d_transforms_scale_y_size\c_transforms_scale_used_y_scale\p_yscale
+ \global\d_transforms_scale_used_x_size\zeropoint
+ \global\d_transforms_scale_used_y_size\zeropoint
+ \ifx\p_maxwidth\empty
+ \ifx\p_maxheight\empty
+ \else
+ \ifdim\d_transforms_scale_y_size>\p_maxheight\relax
+ \global\d_transforms_scale_used_y_size\p_maxheight
+ \fi
+ \fi
+ \else
+ \ifdim\d_transforms_scale_x_size>\p_maxwidth\relax
+ \global\d_transforms_scale_used_x_size\p_maxwidth
+ \fi
+ \fi
\fi}
-\def\setscaleboxbyscale
- {\doifsomething{\scaleparameter\c!scale\scaleparameter\c!xscale\scaleparameter\c!yscale}
- {\doapplyscaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax\c!xscale
- \doapplyscaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay\c!yscale
- \global\scaleboxdimx\zeropoint
- \global\scaleboxdimy\zeropoint
- \doifelsenothing{\scaleparameter\c!maxwidth}
- {\doifsomething{\scaleparameter\c!maxheight}
- {\ifdim\scaleboxsizey>\scaleparameter\c!maxheight\relax
- \global\scaleboxdimy\scaleparameter\c!maxheight
- \fi}}
- {\ifdim\scaleboxsizex>\scaleparameter\c!maxwidth\relax
- \global\scaleboxdimx\scaleparameter\c!maxwidth
- \fi}}}
-
-\def\setscaleboxbydimension
- {\ifdim\scaleboxdimx>\zeropoint
- \ifdim\scaleboxdimy>\zeropoint
- \setscaleboxbydimension_a
+\def\transforms_scale_by_dimension
+ {\ifdim\d_transforms_scale_used_x_size>\zeropoint
+ \ifdim\d_transforms_scale_used_y_size>\zeropoint
+ \transforms_scale_by_dimension_a
\else
- \setscaleboxbydimension_b
+ \transforms_scale_by_dimension_b
\fi
\else
- \ifdim\scaleboxdimy>\zeropoint
- \setscaleboxbydimension_c
+ \ifdim\d_transforms_scale_used_y_size>\zeropoint
+ \transforms_scale_by_dimension_c
\else
- \setscaleboxbydimension_d
+ \transforms_scale_by_dimension_d
\fi
\fi}
-\def\setscaleboxbydimension_a
- {\dosetdimensionscaleboxsize
- {\docalculatescaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay
- \docalculatescaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax}%
- {\docalculatescaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay
- \docalculatescaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax}%
- {\docalculatescaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay
- \docalculatescaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax}}
-
-\def\setscaleboxbydimension_b
- {\dosetdimensionscaleboxsize
- {\docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey}%
- {\docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey}%
- {\docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey}}
-
-\def\setscaleboxbydimension_c
- {\dosetdimensionscaleboxsize
- {\docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex}%
- {\docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex}%
- {\docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex}}
-
-\def\setscaleboxbydimension_d
- {\dosetdimensionscaleboxsize
- {\doapplyscaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax\c!xscale
- \doapplyscaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay\c!yscale}%
- {\docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey}%
- {\docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex}}
-
-\def\dosetdimensionscaleboxsize#1#2#3%
+\def\transforms_scale_by_dimension_a
+ {\transforms_scale_by_dimension_indeed
+ {\transforms_scale_calculate_scale\d_transforms_scale_used_y_size\d_transforms_scale_y_size\c_transforms_scale_used_y_scale
+ \transforms_scale_calculate_scale\d_transforms_scale_used_x_size\d_transforms_scale_x_size\c_transforms_scale_used_x_scale}%
+ {\transforms_scale_calculate_scale\d_transforms_scale_used_y_size\d_transforms_scale_y_size\c_transforms_scale_used_y_scale
+ \transforms_scale_calculate_scale\d_transforms_scale_used_x_size\d_transforms_scale_x_size\c_transforms_scale_used_x_scale}%
+ {\transforms_scale_calculate_scale\d_transforms_scale_used_y_size\d_transforms_scale_y_size\c_transforms_scale_used_y_scale
+ \transforms_scale_calculate_scale\d_transforms_scale_used_x_size\d_transforms_scale_x_size\c_transforms_scale_used_x_scale}}
+
+\def\transforms_scale_by_dimension_b
+ {\transforms_scale_by_dimension_indeed
+ {\transforms_scale_calculate_scales\d_transforms_scale_used_x_size\d_transforms_scale_x_size\d_transforms_scale_used_y_size\d_transforms_scale_y_size}%
+ {\transforms_scale_calculate_scales\d_transforms_scale_used_x_size\d_transforms_scale_x_size\d_transforms_scale_used_y_size\d_transforms_scale_y_size}%
+ {\transforms_scale_calculate_scales\d_transforms_scale_used_x_size\d_transforms_scale_x_size\d_transforms_scale_used_y_size\d_transforms_scale_y_size}}
+
+\def\transforms_scale_by_dimension_c
+ {\transforms_scale_by_dimension_indeed
+ {\transforms_scale_calculate_scales\d_transforms_scale_used_y_size\d_transforms_scale_y_size\d_transforms_scale_used_x_size\d_transforms_scale_x_size}%
+ {\transforms_scale_calculate_scales\d_transforms_scale_used_y_size\d_transforms_scale_y_size\d_transforms_scale_used_x_size\d_transforms_scale_x_size}%
+ {\transforms_scale_calculate_scales\d_transforms_scale_used_y_size\d_transforms_scale_y_size\d_transforms_scale_used_x_size\d_transforms_scale_x_size}}
+
+\def\transforms_scale_by_dimension_d
+ {\transforms_scale_by_dimension_indeed
+ {\transforms_scale_apply_scale\d_transforms_scale_used_x_size\d_transforms_scale_x_size\c_transforms_scale_used_x_scale\p_xscale
+ \transforms_scale_apply_scale\d_transforms_scale_used_y_size\d_transforms_scale_y_size\c_transforms_scale_used_y_scale\p_yscale}%
+ {\transforms_scale_calculate_scales\d_transforms_scale_used_x_size\d_transforms_scale_x_size\d_transforms_scale_used_y_size\d_transforms_scale_y_size}%
+ {\transforms_scale_calculate_scales\d_transforms_scale_used_y_size\d_transforms_scale_y_size\d_transforms_scale_used_x_size\d_transforms_scale_x_size}}
+
+\def\transforms_scale_by_dimension_indeed#1#2#3%
{#1\relax
- \doifsomething{\scaleparameter\c!maxwidth}
- {\ifdim\scaleboxdimx>\scaleparameter\c!maxwidth\relax
- \global\scaleboxdimx\scaleparameter\c!maxwidth
- #2\relax
- \fi}%
- \doifsomething{\scaleparameter\c!maxheight}
- {\ifdim\scaleboxdimy>\scaleparameter\c!maxheight\relax
- \global\scaleboxdimy\scaleparameter\c!maxheight
- #3\relax
- \fi}}
-
-% \def\docalculatescaleboxnorm#1#2#3#4#5% 2 3 parameters (dodo:speedup)
-% {\processaction
-% [\scaleparameter#2]
-% [ \v!max=>\global#1\dimexpr#4\relax,
-% \v!fit=>\global#1\dimexpr#5\relax,
-% \v!broad=>\global#1\dimexpr#5-4\@@exbodyfont\relax,
-% \v!auto=>\doifsomething{\scaleparameter#3}{\global#1\dimexpr\scaleparameter#3\relax},
-% \s!default=>\doifsomething{\scaleparameter#3}{\global#1\dimexpr\scaleparameter#3\relax},
-% \s!unknown=>\global#1\dimexpr\scaleparameter#2\dimexpr\@@exbodyfont/10\relax\relax]}
-
-\def\docalculatescaleboxnorm#1#2% todo: swap 1 and 2 and pass one less
- {\edef\askedscaleboxnorm{\scaleparameter#2}%
- \csname\??ef:n:\ifcsname\??ef:n:\askedscaleboxnorm\endcsname
- \askedscaleboxnorm\else\s!unknown
- \fi\endcsname{#1}}
-
-\setvalue{\??ef:n:\v!max}#1#2#3#4%
- {\global#1#3}
-
-\setvalue{\??ef:n:\v!fit}#1#2#3#4%
- {\global#1#4}
-
-\setvalue{\??ef:n:\v!broad}#1#2#3#4%
- {\global#1\dimexpr#4-4\@@exbodyfont\relax}
-
-\setvalue{\??ef:n:\s!unknown}#1#2#3#4%
- {\global#1\dimexpr\askedscaleboxnorm\dimexpr\@@exbodyfont/10\relax\relax}
-
-\def\docalculatescaleboxnormauto#1#2#3#4%
- {\edef\askedscaleboxnorm{\scaleparameter#2}%
- \ifx\askedscaleboxnorm\empty\else\global#1\askedscaleboxnorm\fi}
-
-\letvalue{\??ef:n:\v!auto }\docalculatescaleboxnormauto
-\letvalue{\??ef:n:\empty }\docalculatescaleboxnormauto
-\letvalue{\??ef:n:\s!default}\docalculatescaleboxnormauto
-
-\def\docalculatescaleboxscales#1#2#3#4%
+ \ifx\p_maxwidth\empty \else
+ \ifdim\d_transforms_scale_used_x_size>\p_maxwidth\relax
+ \global\d_transforms_scale_used_x_size\p_maxwidth
+ #2\relax
+ \fi
+ \fi
+ \ifx\p_maxheight\empty \else
+ \ifdim\d_transforms_scale_used_y_size>\p_maxheight\relax
+ \global\d_transforms_scale_used_y_size\p_maxheight
+ #3\relax
+ \fi
+ \fi}
+
+\def\transforms_scale_calculate_norm#1#2% todo: swap 1 and 2 and pass one less
+ {\csname\??ef:n:\ifcsname\??ef:n:#2\endcsname#2\else\s!unknown\fi\endcsname#1#2}
+
+\setvalue{\??ef:n:\v!max }#1#2#3#4#5{\global#1#4}
+\setvalue{\??ef:n:\v!fit }#1#2#3#4#5{\global#1#5}
+\setvalue{\??ef:n:\v!broad }#1#2#3#4#5{\global#1\dimexpr#5-4\@@exbodyfont\relax}
+\setvalue{\??ef:n:\s!unknown}#1#2#3#4#5{\global#1\dimexpr#2\dimexpr\@@exbodyfont/10\relax\relax} % brr ex
+\setvalue{\??ef:n:\v!auto }#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi}
+\setvalue{\??ef:n:\empty }#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi}
+\setvalue{\??ef:n:\s!default}#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi}
+
+\def\transforms_scale_calculate_scales#1#2#3#4%
{\scratchdimen\dimexpr#1/\dimexpr#2/\plusthousand\relax\relax
- \scaleboxscax\scratchdimen
- \scaleboxscay\scratchdimen
- #3\dimexpr\scaleboxscax\dimexpr#4/\plusthousand\relax\relax}
+ \c_transforms_scale_used_x_scale\scratchdimen
+ \c_transforms_scale_used_y_scale\scratchdimen
+ #3\dimexpr\c_transforms_scale_used_x_scale\dimexpr#4/\plusthousand\relax\relax}
-\def\docalculatescaleboxscale#1#2#3%
+\def\transforms_scale_calculate_scale#1#2#3%
{#3\dimexpr#1/\dimexpr#2/\plusthousand\relax\relax}
-\def\doapplyscaleboxscale#1#2#3#4% $4 = parameter / scale can be empty
- {\ifcase0\scaleparameter#4\relax
- \ifcase0\scaleparameter\c!scale\relax
+\def\transforms_scale_apply_scale#1#2#3#4% #4 = parameter / scale can be empty
+ {\ifcase0#4\relax
+ \ifcase0\p_scale\relax
#3=\plusthousand
\else
- #3=\scaleparameter\c!scale
+ #3=\p_scale
\fi
\else
- #3=\scaleparameter#4%
+ #3=#4%
\fi
\relax % important ! still ?
\global#1\ifnum#3=\plusthousand#2\else\dimexpr#3\dimexpr#2/\plusthousand\relax\relax\fi
\relax}
-\def\doapplyscaleboxsize
- {\doifelsenothing{\scaleparameter\c!maxheight}
- {\scaleboxoutervsize\textheight
- \ifinner
- \scaleboxoutervsize \vsize % \textheight =\vsize
- \scratchdimen\vsize % \scratchdimen=\textheight
- \else\ifinsidefloat
- \scaleboxoutervsize \vsize % \textheight =\vsize
- \scratchdimen\vsize % \scratchdimen=\textheight
- \else\ifinpagebody
- \scaleboxoutervsize \vsize % \textheight =\vsize
- \scratchdimen\vsize % \scratchdimen=\textheight
- \else % hm, there should be an option to force this
- \ifdim\pagegoal<\maxdimen
- \ifdim\pagetotal<\pagegoal
- \scratchdimen\dimexpr\pagegoal-\pagetotal\relax
- \else
- \scratchdimen\scaleboxoutervsize % \textheight
- \fi
- \else
- \scratchdimen\scaleboxoutervsize % \textheight
- \fi
- \fi\fi\fi}
- {\scratchdimen\scaleparameter\c!maxheight
- \scaleboxoutervsize\scratchdimen}%
- \doifelsenothing{\scaleparameter\c!height}
- {\scaleboxvsize\scratchdimen}
- {\scaleboxvsize\scaleparameter\c!height}%
- \doifelsenothing{\scaleparameter\c!width}
- {\scaleboxhsize\hsize}
- {\scaleboxhsize\scaleparameter\c!width}}
-
-\def\convertscaleboxinsertscale#1#2#3#4%
+\def\transforms_scale_apply_size
+ {\ifx\p_maxheight\empty
+ \d_transforms_scale_outer_v_size\textheight
+ \ifinner
+ \d_transforms_scale_outer_v_size \vsize % \textheight =\vsize
+ \scratchdimen\vsize % \scratchdimen=\textheight
+ \else\ifinsidefloat
+ \d_transforms_scale_outer_v_size \vsize % \textheight =\vsize
+ \scratchdimen\vsize % \scratchdimen=\textheight
+ \else\ifinpagebody
+ \d_transforms_scale_outer_v_size \vsize % \textheight =\vsize
+ \scratchdimen\vsize % \scratchdimen=\textheight
+ \else % hm, there should be an option to force this
+ \ifdim\pagegoal<\maxdimen
+ \ifdim\pagetotal<\pagegoal
+ \scratchdimen\dimexpr\pagegoal-\pagetotal\relax
+ \else
+ \scratchdimen\d_transforms_scale_outer_v_size % \textheight
+ \fi
+ \else
+ \scratchdimen\d_transforms_scale_outer_v_size % \textheight
+ \fi
+ \fi\fi\fi
+ \else
+ \scratchdimen\p_maxheight
+ \d_transforms_scale_outer_v_size\scratchdimen
+ \fi
+ \ifx\p_height\empty
+ \d_transforms_scale_v_size\scratchdimen
+ \else
+ \d_transforms_scale_v_size\p_height
+ \fi
+ \ifx\p_width\empty
+ \d_transforms_scale_h_size\hsize
+ \else
+ \d_transforms_scale_h_size\p_width
+ \fi}
+
+\def\transforms_scale_convert_large_scale#1#2#3#4%
{\scratchdimen#1\relax
\ifnum#3=\plusthousand
% == scale 1
@@ -443,9 +491,11 @@
\edef#2{\the\scratchdimen}%
\scratchcounter#3\relax
\ifnum\scratchcounter>\plustenthousand
- \divide\scratchcounter\!!ten \scratchdimen\the\scratchcounter\points
+ \divide\scratchcounter\plusten
+ \scratchdimen\the\scratchcounter\points
\else
- \scratchdimen\the\scratchcounter\points \divide\scratchdimen\!!ten
+ \scratchdimen\the\scratchcounter\points
+ \divide\scratchdimen\plusten
\fi
\edef#4{\withoutpt\the\scratchdimen}}
@@ -454,28 +504,39 @@
% {\externalfigure[mill.png][frame=on,height=3cm,equalwidth=6cm]} {}
% \stopcombination
-\def\doscaleboxposition
- {\doifsomething{\scaleparameter\c!equalwidth}
- {\scratchdimen\scaleparameter\c!equalwidth\relax
- \ifdim\wd\nextbox<\scratchdimen
- \setbox\nextbox\hbox to \scratchdimen{\hss\box\nextbox\hss}%
- \fi}%
- \doifsomething{\scaleparameter\c!equalheight}
- {\scratchdimen\scaleparameter\c!equalheight\relax
- \ifdim\ht\nextbox<\scratchdimen
- \setbox\nextbox\vbox to \scratchdimen{\vss\box\nextbox\vss}%
- \fi}}
-
-\def\fastscale#1%
- {\begingroup
- \ifnum#1=1000\relax
- \setfalse\scaleboxdone
- \else
- \settrue\scaleboxdone
- \edef\finalscaleboxxscale{\withoutpt\the\dimexpr#1pt/1000\relax}%
- \let\finalscaleboxyscale\finalscaleboxxscale
+\def\transforms_scale_position
+ {\ifx\p_equalwidth\empty \else
+ \scratchdimen\p_equalwidth\relax
+ \ifdim\d_transforms_scale_wd<\scratchdimen
+ \setbox\nextbox\hbox to \scratchdimen{\hss\box\nextbox\hss}%
+ \fi
\fi
- \dowithnextbox{\doscaleboxindeed\flushnextbox\endgroup}\hbox}
+ \ifx\p_equalheight\empty \else
+ \scratchdimen\p_equalheight\relax
+ \ifdim\d_transforms_scale_ht<\scratchdimen
+ \setbox\nextbox\vbox to \scratchdimen{\vss\box\nextbox\vss}%
+ \fi
+ \fi}
+
+\unexpanded\def\fastscale#1%
+ {\ifnum#1=1000\relax
+ \expandafter\transforms_fast_scale_nop
+ \else
+ \expandafter\transforms_fast_scale_yes
+ \fi{#1}}
+
+\def\transforms_fast_scale_nop#1%
+ {\hbox}
+
+\def\transforms_fast_scale_yes#1%
+ {\edef\finalscaleboxxscale{\withoutpt\the\dimexpr#1pt/1000\relax}%
+ \let\finalscaleboxyscale\finalscaleboxxscale
+ \dowithnextboxcs\transforms_fast_scale_finish\hbox}
+
+\def\transforms_fast_scale_finish
+ {\transforms_scale_apply
+ \box\nextbox
+ \endgroup}
%D \macros
%D {clip, setupclipping}
@@ -511,66 +572,75 @@
\unexpanded\def\setupclipping
{\dodoubleargument\getparameters[\??cp]}
-\def\clip
- {\dosingleempty\doclip}
+\unexpanded\def\clip
+ {\dosingleempty\transforms_clip}
-\def\doclip[#1]% nb top->bottom left->right
+\def\transforms_clip[#1]% nb top->bottom left->right
{\bgroup
- \getparameters[\??cp][#1]%
- \doifelse\@@cpstate\v!start\dodoclip{\egroup\hbox}}
-
-\def\dodoclip
- {\dowithnextbox
- {\ifdim\@@cpwidth>\zeropoint
- \!!dimena\@@cpwidth
- \!!dimenc\@@cphoffset
- \else
- \!!dimena\nextboxwd
- \divide\!!dimena \@@cpnx
- \!!dimenc\@@cpx\!!dimena
- \advance\!!dimenc -\!!dimena
- \!!dimena\@@cpsx\!!dimena
- \fi
- \relax % sure
- \ifdim\@@cpheight>\zeropoint
- \!!dimenb\@@cpheight
- \!!dimend\nextboxht
- \advance\!!dimend -\@@cpvoffset
- \advance\!!dimend -\!!dimenb
- \else
- \!!dimenb\nextboxht
- \divide\!!dimenb \@@cpny
- \!!dimend-\@@cpy\!!dimenb
- \advance\!!dimend -\@@cpsy\!!dimenb
- \advance\!!dimend \!!dimenb
- \!!dimenb\@@cpsy\!!dimenb
- \advance\!!dimend \nextboxht % dimend !
- \fi
- \setbox\nextbox\hbox % old
- {\advance\!!dimenc -\@@cpleftoffset % new !
- \advance\!!dimend -\@@cpbottomoffset % new ! % - added
- \hskip-\!!dimenc\lower\!!dimend\flushnextbox}% old
- \nextboxwd\zeropoint
- \nextboxht\zeropoint
- \nextboxdp\zeropoint
- \setbox\nextbox\hbox
- {\advance\!!dimena \@@cpleftoffset % new !
- \advance\!!dimena \@@cprightoffset % new !
- \advance\!!dimenb \@@cpbottomoffset % new !
- \advance\!!dimenb \@@cptopoffset % new !
- \dostartclipping\@@cpmp\!!dimena\!!dimenb % old
- \flushnextbox
- \dostopclipping}%
- \setbox\nextbox\hbox % new !
- {\!!dimena-\@@cpleftoffset % new !
- \!!dimenb \@@cpbottomoffset % new ! % - removed
- \hskip\!!dimena\lower\!!dimenb\flushnextbox}% new !
- \nextboxwd\!!dimena
- \nextboxht\!!dimenb
- \nextboxdp\zeropoint
- \flushnextbox
- \egroup}%
- \hbox}
+ \iffirstargument
+ \getparameters[\??cp][#1]%
+ \fi
+ \dowithnextboxcs\transforms_clip_finish\hbox}
+
+\def\transforms_clip_finish
+ {\doifelse\@@cpstate\v!start
+ \transforms_clip_yes_finish
+ \transforms_clip_nop_finish}
+
+\def\transforms_clip_yes_finish
+ {\ifdim\@@cpwidth>\zeropoint
+ \!!dimena\@@cpwidth
+ \!!dimenc\@@cphoffset
+ \else
+ \!!dimena\wd\nextbox
+ \divide\!!dimena \@@cpnx
+ \!!dimenc\@@cpx\!!dimena
+ \advance\!!dimenc -\!!dimena
+ \!!dimena\@@cpsx\!!dimena
+ \fi
+ \relax % sure
+ \ifdim\@@cpheight>\zeropoint
+ \!!dimenb\@@cpheight
+ \!!dimend\ht\nextbox
+ \advance\!!dimend -\@@cpvoffset
+ \advance\!!dimend -\!!dimenb
+ \else
+ \!!dimenb\ht\nextbox
+ \divide\!!dimenb \@@cpny
+ \!!dimend-\@@cpy\!!dimenb
+ \advance\!!dimend -\@@cpsy\!!dimenb
+ \advance\!!dimend \!!dimenb
+ \!!dimenb\@@cpsy\!!dimenb
+ \advance\!!dimend \ht\nextbox % dimend !
+ \fi
+ \setbox\nextbox\hbox % old
+ {\advance\!!dimenc -\@@cpleftoffset % new !
+ \advance\!!dimend -\@@cpbottomoffset % new ! % - added
+ \hskip-\!!dimenc\lower\!!dimend\flushnextbox}% old
+ \wd\nextbox\zeropoint
+ \ht\nextbox\zeropoint
+ \dp\nextbox\zeropoint
+ \setbox\nextbox\hbox
+ {\advance\!!dimena \@@cpleftoffset % new !
+ \advance\!!dimena \@@cprightoffset % new !
+ \advance\!!dimenb \@@cpbottomoffset % new !
+ \advance\!!dimenb \@@cptopoffset % new !
+ \dostartclipping\@@cpmp\!!dimena\!!dimenb % old
+ \box\nextbox
+ \dostopclipping}%
+ \setbox\nextbox\hbox % new !
+ {\!!dimena-\@@cpleftoffset % new !
+ \!!dimenb \@@cpbottomoffset % new ! % - removed
+ \hskip\!!dimena\lower\!!dimenb\flushnextbox}% new !
+ \wd\nextbox\!!dimena
+ \ht\nextbox\!!dimenb
+ \dp\nextbox\zeropoint
+ \box\nextbox
+ \egroup}
+
+\def\transforms_clip_nop_finish
+ {\box\nextbox
+ \egroup}
\setupclipping
[\c!state=\v!start,
@@ -605,26 +675,21 @@
%D \stopbuffer
%D
%D \typebuffer \getbuffer
-
-%D Mirroring.
-\def\domirrorbox % \hbox/\vbox/\vtop
- {\bgroup
- \dowithnextbox
- {\dontshowcomposition
- \scratchdimen\nextboxwd
- % better use an hbox (if no \forgetall, leftskip etc may creep in)
- %\setbox\nextbox\vbox{\forgetall\dostartmirroring\hskip-\nextboxwd\flushnextbox\dostopmirroring}%
- \setbox\nextbox\hbox{\dostartmirroring\hskip-\nextboxwd\flushnextbox\dostopmirroring}%
- \nextboxwd\scratchdimen
- \flushnextbox
- \egroup}}
+%D Mirroring.
\unexpanded\def\mirror
- {\domirrorbox\hbox}
-
-% \setbox0=\hbox{gans}
-% \ruledhbox{\copy0 \schaal[sx=2,sy=2]{\copy0}}
-% \mirror{\ruledhbox{\copy0 \schaal{\box0}}}
+ {\bgroup
+ \dowithnextboxcs\transforms_mirror_finish\hbox}
+
+\def\transforms_mirror_finish
+ {\dontshowcomposition
+ \scratchdimen\wd\nextbox
+ % better use an hbox (if no \forgetall, leftskip etc may creep in)
+ %\setbox\nextbox\vbox{\forgetall\dostartmirroring\hskip-\wd\nextbox\flushnextbox\dostopmirroring}%
+ \setbox\nextbox\hbox{\dostartmirroring\hskip-\wd\nextbox\flushnextbox\dostopmirroring}%
+ \wd\nextbox\scratchdimen
+ \box\nextbox
+ \egroup}
\protect \endinput
diff --git a/tex/context/base/m-visual.tex b/tex/context/base/m-visual.tex
index 502a5c47f..314630e53 100644
--- a/tex/context/base/m-visual.tex
+++ b/tex/context/base/m-visual.tex
@@ -204,7 +204,7 @@
\framed
[\c!width=\dimen0,
\c!height=\dimen2,
- \c!frame=\ifincolor\v!off\else\v!on\fi,
+ \c!frame=\v!off,
\c!background=\v!color,
\c!backgroundcolor=fakeparindentcolor]
{\bf\white#1}}%
diff --git a/tex/context/base/meta-fig.mkiv b/tex/context/base/meta-fig.mkiv
index 38462e192..644501260 100644
--- a/tex/context/base/meta-fig.mkiv
+++ b/tex/context/base/meta-fig.mkiv
@@ -44,7 +44,7 @@
\definefittingpage
[MPpage]
[\c!align=,
- \c!command=\processMPgraphic]
+ \c!command=\mp_process_graphic]
%D \macros
%D {MPfigure}
diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv
index ff3284c6f..2732341d5 100644
--- a/tex/context/base/meta-ini.mkiv
+++ b/tex/context/base/meta-ini.mkiv
@@ -17,95 +17,88 @@
\unprotect
-%D Instead of sharing code with \MKII, I decided to copy
-%D the code. Otherwise maintainance becomes a pain and after all,
-%D the \MKII\ code will not change.
-
-\let \useMETAFUNformattrue\relax \let \useMETAFUNformatfalse\relax
-\let \longMPlinestrue\relax \let \longMPlinesfalse\relax
-\let \runMPgraphicstrue\relax \let \runMPgraphicsfalse\relax
-\let \runMPTEXgraphicstrue\relax \let \runMPTEXgraphicsfalse\relax
-\let \MPstaticgraphictrue\relax \let \MPstaticgraphicfalse\relax
-\let\forceMPTEXgraphictrue\relax \let\forceMPTEXgraphicfalse\relax
-
-\let \obeyMPlines\relax
-\let \forceMPTEXcheck\gobbleoneargument
-\let\maxnofMPgraphics\scratchcounter
-
-\newtoks \MPextensions % mp, once
-\newtoks \MPinitializations % tex, each
-\newtoks \MPuserinclusions % mp, user
-\newtoks \MPfinalizations % mp, user
-\newtoks \everyMPgraphic % mp
-\newtoks \everyMPTEXgraphic % tex
-
-\newif\ifMPrun
-\def\MPruntimefile{mprun}
+\newtoks \t_mp_extensions % mp, once
+\newtoks \t_mp_initializations % tex, each
+\newtoks \t_mp_userinclusions % mp, user
+
+\newtoks \everyMPgraphic % mp % public or not ?
+
+\def\MPruntimefile {mprun}
+\def\currentMPformat {metafun}
+\def\defaultMPgraphicinstance{metafun}
% The next command is, of course, dedicated to Mojca, who
% needs it for gnuplot. Anyway, the whole multiple engine
% mechanism is to keep her gnuplot from interfering.
-\def\startMPdefinitions
- {\dosinglegroupempty\dostartMPdefinitions}
+\unexpanded\def\startMPdefinitions
+ {\dosinglegroupempty\mp_start_definitions}
-\def\dostartMPdefinitions#1#2\stopMPdefinitions
+\def\mp_start_definitions#1#2\stopMPdefinitions
{\edef\currentMPgraphicinstance{#1}%
\ifx\currentMPgraphicinstance\empty
\let\currentMPgraphicinstance\defaultMPgraphicinstance
\fi
- \global\MPinstancetoks\expandafter{\the\MPinstancetoks#2}}
+ \global\t_mp_instance\expandafter{\the\t_mp_instance#2}}
+
+\let\stopMPdefinitions\relax
+
+\unexpanded\def\startMPextensions#1\stopMPextensions
+ {\global\t_mp_extensions\expandafter{\the\t_mp_extensions#1}}
+
+\let\stopMPextensions\relax
+
+\unexpanded\def\startMPinitializations#1\stopMPinitializations
+ {\global\t_mp_initializations\expandafter{\the\t_mp_initializations#1}}
-\def\startMPextensions#1\stopMPextensions
- {\global\MPextensions\expandafter{\the\MPextensions#1}}
+\let\stopMPinitializations\relax
-\def\startMPinitializations#1\stopMPinitializations
- {\global\MPinitializations\expandafter{\the\MPinitializations#1}}
+\unexpanded\def\startMPinclusions
+ {\dosingleempty\mp_start_inclusions}
-\def\startMPinclusions
- {\dosingleempty\dostartMPinclusions}
+\def\mp_start_inclusions[#1]#2\stopMPinclusions
+ {\edef\m_mp_option{#1}%
+ \ifx\m_mp_option\!!plustoken \else
+ \global\t_mp_userinclusions\emptytoks
+ \fi
+ \global\t_mp_userinclusions\expandafter{\the\t_mp_userinclusions#2}}
-\def\dostartMPinclusions[#1]#2\stopMPinclusions
- {\doifnot{#1}{+}{\global\MPuserinclusions\emptytoks}%
- \global\MPuserinclusions\expandafter{\the\MPuserinclusions#2}}
+\let\stopMPinclusions\relax
-\def\MPinclusions
- {\dosingleempty\doMPinclusions}
+\unexpanded\def\MPinclusions
+ {\dosingleempty\mp_inclusions}
-\def\doMPinclusions[#1]#2%
- {\doifnot{#1}{+}{\global\MPuserinclusions\emptytoks}%
- \global\MPuserinclusions\expandafter{\the\MPuserinclusions#2}}
+\def\mp_inclusions[#1]#2%
+ {\edef\m_mp_option{#1}%
+ \ifx\m_mp_option\!!plustoken \else
+ \global\t_mp_userinclusions\emptytoks
+ \fi
+ \global\t_mp_userinclusions\expandafter{\the\t_mp_userinclusions#2}}
-\def\presetMPdefinitions
+\def\mp_preset_definitions
{\edef\overlaywidth {\overlaywidth \space}%
\edef\overlayheight {\overlayheight \space}%
\edef\overlaylinewidth{\overlaylinewidth\space}%
\edef\currentwidth {\the\hsize \space}%
\edef\currentheight {\the\vsize \space}}
-\def\currentMPformat{metafun}
-
-\def\@@MPF{@MPF@}
-
-\def\MPinstancetoks{\csname\@@MPF::\currentMPgraphicinstance\endcsname}
+\def\t_mp_instance{\csname\??gi:t:\currentMPgraphicinstance\endcsname} % token register
\unexpanded\def\defineMPinstance
- {\dodoubleargument\dodefineMPinstance}
+ {\dodoubleargument\mp_define_instance}
-\def\dodefineMPinstance[#1][#2]%
- {\ifcsname\@@MPF::#1\endcsname\else\expandafter\newtoks\csname\@@MPF::#1\endcsname\fi
- \MPinstancetoks\emptytoks % in case we redefine
- \getparameters[\@@MPF#1][\s!format=mpost,\s!extensions=\v!no,\s!initializations=\v!no,#2]}
+\def\mp_define_instance[#1][#2]%
+ {\ifcsname\??gi:t:#1\endcsname\else\expandafter\newtoks\csname\??gi:t:#1\endcsname\fi
+ \t_mp_instance\emptytoks % in case we redefine
+ \getparameters[\??gi#1][\s!format=mpost,\s!extensions=\v!no,\s!initializations=\v!no,#2]}
-\def\resetMPinstance[#1]%
+\unexpanded\def\resetMPinstance[#1]%
{\writestatus\m!metapost{reset will be implemented when needed}}
-\def\defaultMPgraphicinstance{metafun}
-
-\def\splitMPgraphicname[#1]%
- {\dosplitMPgraphicname[#1::::]}
+\def\mp_analyze_graphicname[#1]%
+ {\mp_analyze_graphicname_indeed[#1::::]}
-\def\dosplitMPgraphicname[#1::#2::#3]% instance ::
+\def\mp_analyze_graphicname_indeed[#1::#2::#3]% instance ::
{\edef\currentMPgraphicname{#2}%
\ifx\currentMPgraphicname\empty
\edef\currentMPgraphicname{#1}%
@@ -114,8 +107,8 @@
\edef\currentMPgraphicinstance{#1}%
\fi
\edef\currentMPgraphicformat
- {\ifcsname\@@MPF\currentMPgraphicinstance\s!format\endcsname
- \csname\@@MPF\currentMPgraphicinstance\s!format\endcsname
+ {\ifcsname\??gi\currentMPgraphicinstance\s!format\endcsname
+ \csname\??gi\currentMPgraphicinstance\s!format\endcsname
\else
\defaultMPgraphicinstance
\fi}}
@@ -131,7 +124,7 @@
\def\beginMPgraphicgroup#1%
{\begingroup
- \splitMPgraphicname[#1]}
+ \mp_analyze_graphicname[#1]}
\def\endMPgraphicgroup
{\endgroup}
@@ -139,33 +132,34 @@
\def\MPaskedfigure{false}
\def\currentMPinitializations
- {\ifconditional\includeMPinitializations\the\MPinitializations;\fi\theMPrandomseed;}
+ {\ifconditional\includeMPinitializations\the\t_mp_initializations;\fi\theMPrandomseed;}
\def\currentMPpreamble
- {\ifconditional\includeMPextensions\the\MPextensions;\the\MPuserinclusions;\fi\the\MPinstancetoks;}
+ {\ifconditional\includeMPextensions\the\t_mp_extensions;\the\t_mp_userinclusions;\fi\the\t_mp_instance;}
\def\dostartcurrentMPgraphic
{\begingroup
- \enableincludeMPgraphics
+ \mp_enable_include
\the\everyMPgraphic
- \presetMPdefinitions
+ \mp_preset_definitions
\setMPrandomseed % this has to change
% we need to preexpand the token lists
- \doifelsevalue{\@@MPF\currentMPgraphicinstance\s!extensions}\v!yes
- {\settrue \includeMPextensions\letgvalue{\@@MPF\currentMPgraphicinstance\s!extensions}\v!no}
+ \doifelsevalue{\??gi\currentMPgraphicinstance\s!extensions}\v!yes
+ {\settrue \includeMPextensions
+ \letgvalue{\??gi\currentMPgraphicinstance\s!extensions}\v!no}
{\setfalse\includeMPextensions}%
- \doifelsevalue{\@@MPF\currentMPgraphicinstance\s!initializations}\v!yes
+ \doifelsevalue{\??gi\currentMPgraphicinstance\s!initializations}\v!yes
{\settrue \includeMPinitializations}%
{\setfalse\includeMPinitializations}}
\def\dostopcurrentMPgraphic
- {\global\MPinstancetoks\emptytoks
+ {\global\t_mp_instance\emptytoks
\endgroup}
-\unexpanded\def\processMPgraphic#1% todo: extensions and inclusions outside beginfig
+\unexpanded\def\mp_process_graphic#1% todo: extensions and inclusions outside beginfig
{\dostartcurrentMPgraphic
\forgetall
- \setbox\MPgraphicbox\hbox\bgroup % ; added 20100901 (as in mkii)
+ \setbox\b_mp_graphic\hbox\bgroup % ; added 20100901 (as in mkii)
\normalexpanded{\noexpand\ctxlua{metapost.graphic(
"\currentMPgraphicinstance",
"\currentMPgraphicformat",
@@ -187,53 +181,50 @@
\def\theMPrandomseed{randomseed:=\localMPseed}%
\fi\fi}
-%D To be integrated
-
-\def\@@MPG{@MPG@}
+%D Calling up previously defined graphics.
-\def\doifMPgraphicelse#1%
- {\ifcsname\@@MPG#1\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi}
+\def\includeMPgraphic#1% gets expanded !
+ {\ifcsname\??gm:#1\endcsname
+ \csname\??gm:#1\endcsname ; % ; is safeguard
+ \fi}
-\def\includeMPgraphic#1%
- {\executeifdefined{\@@MPG#1};} % ; if not found
+\unexpanded\def\mp_enable_include % public
+ {\let\mp_handle_use_graphic \thirdofthreearguments
+ \let\mp_handle_reusable_graphic\thirdofthreearguments}
-\def\enableincludeMPgraphics
- {\let\handleuseMPgraphic \thirdofthreearguments
- \let\handlereusableMPgraphic\thirdofthreearguments}
+%D Drawings (stepwise built):
-\newif\ifMPdrawingdone \MPdrawingdonefalse
+\newif\ifMPdrawingdone \MPdrawingdonefalse
-\def\finalizeMPdrawing
+\unexpanded\def\finalizeMPdrawing
{\MPdrawingdonetrue}
\let\MPdrawingdata\empty
-\newif\ifMPshiftdrawing \MPshiftdrawingfalse
-
-\def\resetMPdrawing
- {\globallet\MPdrawingdata\empty
+\unexpanded\def\resetMPdrawing
+ {\global\let\MPdrawingdata\empty
\global\MPdrawingdonefalse}
-\def\pushMPdrawing
+\unexpanded\def\pushMPdrawing
{\globalpushmacro\MPdrawingdata
- \globallet\MPdrawingdata\empty}
+ \global\let\MPdrawingdata\empty}
-\def\popMPdrawing
+\unexpanded\def\popMPdrawing
{\globalpopmacro\MPdrawingdata}
-\def\getMPdrawing
+\unexpanded\def\getMPdrawing
{\ifMPdrawingdone
- \expandafter\processMPgraphic\expandafter{\MPdrawingdata}% is this expansion still needed?
+ \expandafter\mp_process_graphic\expandafter{\MPdrawingdata}% is this expansion still needed?
\fi}
\def\startMPdrawing
- {\dosingleempty\dostartMPdrawing}
+ {\dosingleempty\mp_start_drawing}
-\def\dostartMPdrawing[#1]#2\stopMPdrawing
+\def\mp_start_drawing[#1]#2\stopMPdrawing
{\relax
\bgroup
- \enableincludeMPgraphics
- \presetMPdefinitions % in case #2 has measures
+ \mp_enable_include
+ \mp_preset_definitions % in case #2 has measures
\doifelse{#1}{-}{\convertargument#2\to\asciia}{\def\asciia{#2}}%
\xdef\MPdrawingdata{\MPdrawingdata\asciia}%
\egroup}
@@ -243,36 +234,36 @@
\def\MPdrawing#1%
{\relax
\bgroup
- \enableincludeMPgraphics
- \presetMPdefinitions
+ \mp_enable_include
+ \mp_preset_definitions
\xdef\MPdrawingdata{\MPdrawingdata#1}%
\egroup}
-\let\stopMPclip\relax
+\unexpanded\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less
+ {\setgvalue{\??gm:c:#1}{#2}}
-\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less
- {\setgvalue{MPC:#1}{#2}}
+\let\stopMPclip\relax
-\def\grabMPclippath#1#2#3#4#5% #5 is alternative
+\unexpanded\def\mp_grab_clip_path#1#2#3#4% #4 is alternative (called in backend code)
{\begingroup
- \edef\width {#3\space}\let\overlaywidth \width
- \edef\height{#4\space}\let\overlayheight\height
- \ifcsname MPC:#1\endcsname
+ \edef\width {#2\space}\let\overlaywidth \width
+ \edef\height{#3\space}\let\overlayheight\height
+ \ifcsname\??gm:c:#1\endcsname
\dostartcurrentMPgraphic
\xdef\MPclippath{\normalexpanded{\noexpand\ctxlua{metapost.theclippath(
"\currentMPgraphicinstance",
"\currentMPgraphicformat",
- \!!bs\getvalue{MPC:#1}\!!es,
+ \!!bs\getvalue{\??gm:c:#1}\!!es,
\!!bs\currentMPinitializations\!!es,
\!!bs\currentMPpreamble\!!es
)}}}%
\dostopcurrentMPgraphic
- \ifx\MPclippath\empty\xdef\MPclippath{#5}\fi
+ \ifx\MPclippath\empty
+ \xdef\MPclippath{#4}%
+ \fi
\else
- \xdef\MPclippath{#5}%
+ \xdef\MPclippath{#4}%
\fi
- % #2 : method is obsolete, only pdf now, we can always
- % gsub the result to ps
\endgroup}
%D Since we want lables to follow the document settings, we
@@ -296,26 +287,13 @@
defaultfont:="rm-lmtt10";
\stopMPinitializations
-%D A signal that we're in combines \CONTEXT||\METAFUN mode:
+%D A signal that we're in combined \CONTEXT||\METAFUN mode:
\startMPextensions
string contextversion;
contextversion:="\contextversion";
\stopMPextensions
-%D Some safeguards:
-%D
-%D \starttyping
-%D \appendtoks \cleanupfeatures \to \everyMPgraphic
-%D \stoptyping
-%D
-%D No, we don't want that (else we loose UTF etc).
-
-%D Another one:
-
-\prependtoks \MPstaticgraphictrue \to \everyoverlay
-\prependtoks \MPstaticgraphictrue \to \everypagebody
-
%D \macros
%D {setupMPvariables}
%D
@@ -330,43 +308,102 @@
%D \setupMPvariables[meta:button][size=20pt]
%D \stoptyping
-\def\@@meta{meta:}
+% \startlines
+% \def\xxx{\lineheight} \doprepareMPvariable{xxx} \xxx
+% \def\xxx{2pt} \doprepareMPvariable{xxx} \xxx
+% \def\xxx{2} \doprepareMPvariable{xxx} \xxx
+% \def\xxx{\scratchcounter} \doprepareMPvariable{xxx} \xxx
+% \def\xxx{red} \doprepareMPvariable{xxx} \xxx
+% \def\xxx{0.4} \doprepareMPvariable{xxx} \xxx
+% \stoplines
+
+% currently the inheritance of backgrounds does not work and
+% we might drop it anyway (too messy)
+
+\newbox\b_mp_variable_box
+
+\let \currentmpvariableclass \empty
+\let \m_mp_current_variable \empty
+\let \m_mp_current_variable_template\empty
+
+\def \mp_prepare_variable_default {\MPcolor{black}} % just to be sure we use a color but ...
+\edef\mp_unknown_variable_template {\??gv:\s!unknown}
+
+\letvalue{\??gv:\s!unknown}\empty
\unexpanded\def\setupMPvariables
- {\dodoubleempty\dosetupMPvariables}
+ {\dodoubleempty\mp_setup_variables}
-\def\dosetupMPvariables[#1][#2]%
+\def\mp_setup_variables[#1][#2]%
{\ifsecondargument
- \getrawparameters[#1:][#2]% brr, todo: [\@@meta#1:]
+ \getrawparameters[\??gv#1:][#2]%
\else
- \getrawparameters[\@@meta][#1]%
+ \getrawparameters[\??gv:][#1]%
\fi}
-\let\@@framed\s!unknown
+\unexpanded\def\presetMPvariable
+ {\dodoubleargument\mp_preset_variable}
-\def\MPvariable#1%
- {\csname
- \ifcsname\@@framed\@@meta#1\endcsname\@@framed\fi\@@meta#1%
- \endcsname}
+\def\mp_preset_variable[#1][#2=#3]%
+ {\ifcsname\??gv#1:#2\endcsname \else
+ \setvalue{\??gv#1:#2}{#3}%
+ \fi}
-\let\MPvar\MPvariable
+\def\MPrawvar#1#2% no checking
+ {\csname\??gv#1:#2\endcsname}
-\let\setMPvariables\setupMPvariables
+\def\MPvariable#1% todo: could be a framed chain
+ {\csname\??gv\currentmpvariableclass:#1\endcsname}
-\def\MPrawvar#1#2{\csname#1:#2\endcsname}
+\unexpanded\def\useMPvariables
+ {\dodoubleargument\mp_use_variables}
-\def\presetMPvariable
- {\dodoubleargument\dopresetMPvariable}
+\def\mp_use_variables[#1][#2]%
+ {\edef\currentmpvariableclass{#1}%
+ \mp_prepare_variables{#2}}
-\def\dopresetMPvariable[#1][#2=#3]%
- {\ifcsname#1:#2\endcsname\else\setvalue{#1:#2}{#3}\fi}
+\unexpanded\def\mp_prepare_variables#1%
+ {\processcommalist[#1]\mp_prepare_variable}
-\def\useMPvariables
- {\dodoubleargument\douseMPvariables}
+\unexpanded\def\mp_prepare_variable#1%
+ {\edef\m_mp_current_variable_template
+ {\??gv\currentmpvariableclass:#1}%
+ \edef\m_mp_current_variable
+ {\csname\ifcsname\m_mp_current_variable_template\endcsname
+ \m_mp_current_variable_template\else\mp_unknown_variable_template
+ \fi\endcsname}%
+ \ifx\m_mp_current_variable\empty
+ \expandafter\mp_prepare_variable_nop
+ \else
+ \expandafter\mp_prepare_variable_yes
+ \fi}
+
+\def\mp_prepare_variable_nop
+ {\expandafter \let\csname\m_mp_current_variable_template\endcsname\mp_prepare_variable_default}
+
+\def\mp_prepare_variable_color
+ {\expandafter\edef\csname\m_mp_current_variable_template\endcsname{\MPcolor\m_mp_current_variable}}
+
+\def\mp_prepare_variable_number
+ {\expandafter\edef\csname\m_mp_current_variable_template\endcsname{\number\m_mp_current_variable}}% also accepts 0.number
-\def\douseMPvariables[#1][#2]%
- {\def\@@meta{#1:}%
- \prepareMPvariables{#2}}
+\def\mp_prepare_variable_dimension
+ {\expandafter\edef\csname\m_mp_current_variable_template\endcsname{\the\dimexpr\m_mp_current_variable}}
+
+\def\mp_prepare_variable_yes
+ {\defconvertedcommand\ascii\m_mp_current_variable % otherwise problems
+ \doifcolorelse \ascii % with 2\bodyfontsize
+ {\mp_prepare_variable_color}
+ {\begingroup
+ \setbox\b_mp_variable_box\hbox{\scratchdimen\m_mp_current_variable sp}%
+ \ifzeropt\wd\b_mp_variable_box
+ \endgroup\mp_prepare_variable_number
+ \else
+ \endgroup\mp_prepare_variable_dimension
+ \fi}}
+
+\let\MPvar \MPvariable
+\let\setMPvariables\setupMPvariables
%D \macros
%D {startuniqueMPgraphic, uniqueMPgraphic}
@@ -404,175 +441,161 @@
%D \uniqueMPgraphic{meta:hash}{gap=10pt,angle=30}
%D \stoptyping
-\newcount \MPobjectcounter
-\newbox \MPgraphicbox
-\newconstant\MPboxmode
+\newcount\c_mp_object_counter
+\newbox \b_mp_graphic
% hm, isn't this already done elsewhere?
-\def\doobeyMPboxdepth % mode = 1
- {\setbox\MPgraphicbox\hbox\bgroup
-% \raise\MPlly\onebasepoint\box\MPgraphicbox
- \raise\MPlly\box\MPgraphicbox
- \egroup}
+\unexpanded\def\mp_obey_box_depth
+ {\setbox\b_mp_graphic\hbox\bgroup
+ \raise\MPlly\box\b_mp_graphic
+ \egroup}
-\def\doignoreMPboxdepth % mode = 2
+\unexpanded\def\mp_ignore_box_depth
{\normalexpanded
- {\noexpand\doobeyMPboxdepth
- \wd\MPgraphicbox\the\wd\MPgraphicbox
- \ht\MPgraphicbox\the\ht\MPgraphicbox
- \dp\MPgraphicbox\the\dp\MPgraphicbox}}
-
-\def\doobeyMPboxorigin % mode = 3
- {\setbox\MPgraphicbox\hbox\bgroup
- \hskip\MPllx\raise\MPlly\box\MPgraphicbox
- \egroup}
-
-\def\obeyMPboxdepth {\MPboxmode\plusone}
-\def\ignoreMPboxdepth{\MPboxmode\plustwo}
-\def\obeyMPboxorigin {\MPboxmode\plusthree}
-\def\normalMPboxdepth{\MPboxmode\zerocount}
+ {\mp_obey_box_depth % hence the \unexpanded
+ \wd\b_mp_graphic\the\wd\b_mp_graphic
+ \ht\b_mp_graphic\the\ht\b_mp_graphic
+ \dp\b_mp_graphic\the\dp\b_mp_graphic}}
+
+\unexpanded\def\mp_obey_box_origin
+ {\setbox\b_mp_graphic\hbox\bgroup
+ \hskip\MPllx\raise\MPlly\box\b_mp_graphic
+ \egroup}
-% compatibility hack:
+\unexpanded\def\obeyMPboxdepth {\let\mp_relocate_box\mp_obey_box_depth }
+\unexpanded\def\ignoreMPboxdepth{\let\mp_relocate_box\mp_ignore_box_depth}
+\unexpanded\def\obeyMPboxorigin {\let\mp_relocate_box\mp_obey_box_origin }
+\unexpanded\def\normalMPboxdepth{\let\mp_relocate_box\relax }
-\let\MPshiftdrawingtrue \ignoreMPboxdepth
-\let\MPshiftdrawingfalse\normalMPboxdepth
+\let\mp_relocate_box\relax
\unexpanded\def\placeMPgraphic % the converter also displaces so in fact we revert
- {\ifcase\MPboxmode
- \or % 1
- \doobeyMPboxdepth
- \or % 2
- \doignoreMPboxdepth
- \or % 3
- \doobeyMPboxorigin
- \fi
- \box\MPgraphicbox}
+ {\mp_relocate_box
+ \box\b_mp_graphic}
-\unexpanded\def\reuseMPbox#1#2#3#4#5% space delimiting would save some tokens
+\unexpanded\def\mp_reuse_box#1#2#3#4#5% space delimiting would save some tokens
{\MPllx#2\MPlly#3\MPurx#4\MPury#5%
\hbox{\forcecolorhack\getobject{MP}{#1}}} % else no proper color intent
-\def\handleuniqueMPgraphic#1#2#3% when there are too many, we can store data at the lua end, although,
+\def\mp_handle_unique_graphic#1#2#3% when there are too many, we can store data at the lua end, although,
{\begingroup % when there are that many they're probably not that unique anyway
- \def\@@meta{#1:}%
+ \edef\currentmpvariableclass{#1}%
\extendMPoverlaystamp{#2}% incl prepare
- \ifcsname\@@MPG\overlaystamp:#1\endcsname\else
- \enableincludeMPgraphics % redundant
- \global\advance\MPobjectcounter\plusone
- \setobject{MP}{\number\MPobjectcounter}\hbox{\processMPgraphic{#3}}% was vbox, graphic must end up as hbox
- \setxvalue{\@@MPG\overlaystamp:#1}{\reuseMPbox{\number\MPobjectcounter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
+ \ifcsname\??gm:\overlaystamp:#1\endcsname\else
+ \mp_enable_include % redundant
+ \global\advance\c_mp_object_counter\plusone
+ \setobject{MP}{\number\c_mp_object_counter}\hbox{\mp_process_graphic{#3}}% was vbox, graphic must end up as hbox
+ \setxvalue{\??gm:\overlaystamp:#1}{\mp_reuse_box{\number\c_mp_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
\fi
- \getvalue{\@@MPG\overlaystamp:#1}%
+ \getvalue{\??gm:\overlaystamp:#1}%
\endgroup}
\unexpanded\def\startuniqueMPgraphic
- {\dodoublegroupempty\dostartuniqueMPgraphic}
+ {\dodoublegroupempty\mp_start_unique_graphic}
+
+\def\mp_start_unique_graphic#1#2#3\stopuniqueMPgraphic
+ {\setgvalue{\??gm:#1}{\mp_handle_unique_graphic{#1}{#2}{#3}}}
-\def\dostartuniqueMPgraphic#1#2#3\stopuniqueMPgraphic%
- {\setgvalue{\@@MPG#1}{\handleuniqueMPgraphic{#1}{#2}{#3}}}
+\let\stopuniqueMPgraphic\relax
\unexpanded\def\uniqueMPgraphic
- {\dodoublegroupempty\douniqueMPgraphic}
+ {\dodoublegroupempty\mp_unique_graphic}
-\def\douniqueMPgraphic#1#2%
+\def\mp_unique_graphic#1#2%
{\beginMPgraphicgroup{#1}%
\setupMPvariables[\currentMPgraphicname][#2]%
- \getvalue{\@@MPG\currentMPgraphicname}\empty
+ \getvalue{\??gm:\currentMPgraphicname}\empty
\endMPgraphicgroup}
-\let\stopuniqueMPcode \relax % so that we can use it in \expanded
-
-\def\handleuseMPgraphic#1#2#3%
+\def\mp_handle_use_graphic#1#2#3%
{\begingroup
- \def\@@meta{#1:}%
- \prepareMPvariables{#2}%
- \enableincludeMPgraphics % redundant
- \processMPgraphic{#3}%
+ \edef\currentmpvariableclass{#1}%
+ \mp_prepare_variables{#2}%
+ \mp_enable_include % redundant
+ \mp_process_graphic{#3}%
\endgroup}
\unexpanded\def\startuseMPgraphic
- {\dodoublegroupempty\dostartuseMPgraphic}
+ {\dodoublegroupempty\mp_start_use_graphic}
+
+\def\mp_start_use_graphic#1#2#3\stopuseMPgraphic
+ {\setgvalue{\??gm:#1}{\mp_handle_use_graphic{#1}{#2}{#3}}}
-\def\dostartuseMPgraphic#1#2#3\stopuseMPgraphic
- {\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}}
+\let\stopuseMPgraphic\relax
\unexpanded\def\startusableMPgraphic % redundant but handy
- {\dodoublegroupempty\dostartusableMPgraphic}
+ {\dodoublegroupempty\mp_start_usable_graphic}
-\def\dostartusableMPgraphic#1#2#3\stopusableMPgraphic
- {\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}}
+\def\mp_start_usable_graphic#1#2#3\stopusableMPgraphic
+ {\setgvalue{\??gm:#1}{\mp_handle_use_graphic{#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
+\let\stopusableMPgraphic\relax
-\def\handlereusableMPgraphic#1#2#3%
+\def\mp_handle_reusable_graphic#1#2#3%
{\begingroup
- \def\@@meta{#1:}%
- \prepareMPvariables{#2}%
- \enableincludeMPgraphics % redundant
- \global\advance\MPobjectcounter\plusone
- \setobject{MP}{\number\MPobjectcounter}\hbox{\processMPgraphic{#3}}% was vbox, graphic must end up as hbox
- \setxvalue{\@@MPG#1}{\noexpand\reuseMPbox{\number\MPobjectcounter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
- \getvalue{\@@MPG#1}%
+ \edef\currentmpvariableclass{#1}%
+ \mp_prepare_variables{#2}%
+ \mp_enable_include % redundant
+ \global\advance\c_mp_object_counter\plusone
+ \setobject{MP}{\number\c_mp_object_counter}\hbox{\mp_process_graphic{#3}}% was vbox, graphic must end up as hbox
+ \setxvalue{\??gm:#1}{\mp_reuse_box{\number\c_mp_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
+ \getvalue{\??gm:#1}%
\endgroup}
\unexpanded\def\startreusableMPgraphic
- {\dodoublegroupempty\dostartreusableMPgraphic}
+ {\dodoublegroupempty\mp_start_reusable_graphic}
-\def\dostartreusableMPgraphic#1#2#3\stopreusableMPgraphic
- {\setgvalue{\@@MPG#1}{\handlereusableMPgraphic{#1}{#2}{#3}}}
+\def\mp_start_reusable_graphic#1#2#3\stopreusableMPgraphic
+ {\setgvalue{\??gm:#1}{\mp_handle_reusable_graphic{#1}{#2}{#3}}}
-\let\stopreusableMPgraphic \relax % so that we can use it in \expanded
+\let\stopreusableMPgraphic\relax
\unexpanded\def\useMPgraphic
- {\dodoublegroupempty\douseMPgraphic}
+ {\dodoublegroupempty\mp_use_graphic}
-\def\douseMPgraphic#1#2%
+\def\mp_use_graphic#1#2%
{\beginMPgraphicgroup{#1}%
\doifsomething{#2}{\setupMPvariables[\currentMPgraphicname][#2]}%
- \getvalue{\@@MPG\currentMPgraphicname}\empty
+ \getvalue{\??gm:\currentMPgraphicname}\empty
\endMPgraphicgroup}
\let\reuseMPgraphic \useMPgraphic % we can save a setup here if needed
\let\reusableMPgraphic\reuseMPgraphic % we can save a setup here if needed
-\let\stopuseMPcode \relax % so that we can use it in \expanded
-\let\stopusableMPcode \relax % so that we can use it in \expanded
-\let\stopreusableMPcode \relax % so that we can use it in \expanded
-\let\stopuniqueMPcode \relax % so that we can use it in \expanded
-
-\def\enableincludeMPgraphics
- {\let\handleuseMPgraphic \thirdofthreearguments
- \let\handlereusableMPgraphic\thirdofthreearguments}
+\unexpanded\def\mp_enable_include
+ {\let\mp_handle_use_graphic \thirdofthreearguments
+ \let\mp_handle_reusable_graphic\thirdofthreearguments}
%D \macros
%D {startuniqueMPpagegraphic,uniqueMPpagegraphic}
%D
%D Experimental.
-\def\MPpageprefix{\doifoddpageelse oe:}
+\def\m_mp_page_prefix{\doifoddpageelse oe}
\def\overlaypagestamp
- {\MPpageprefix\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}
+ {\m_mp_page_prefix:\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}
\unexpanded\def\startuniqueMPpagegraphic
- {\dodoublegroupempty\dostartuniqueMPpagegraphic}
+ {\dodoublegroupempty\mp_start_unique_page_graphic}
+
+\def\mp_start_unique_page_graphic#1#2#3\stopuniqueMPpagegraphic % inefficient, double storage
+ {\setgvalue{\??gm:o:#1}{\mp_handle_unique_graphic{o:#1}{#2}{#3}}% % but these also keep the state
+ \setgvalue{\??gm:e:#1}{\mp_handle_unique_graphic{e:#1}{#2}{#3}}} % and meaning will be redefined
-\def\dostartuniqueMPpagegraphic#1#2#3\stopuniqueMPpagegraphic
- {\setgvalue{\@@MPG o:#1}{\handleuniqueMPgraphic{o:#1}{#2}{#3}}%
- \setgvalue{\@@MPG e:#1}{\handleuniqueMPgraphic{e:#1}{#2}{#3}}}
+\let\stopuniqueMPpagegraphic\relax
\unexpanded\def\uniqueMPpagegraphic
- {\dodoublegroupempty\douniqueMPpagegraphic}
+ {\dodoublegroupempty\mp_unique_page_graphic}
-\def\douniqueMPpagegraphic#1#2%
+\def\mp_unique_page_graphic#1#2%
{\beginMPgraphicgroup{#1}%
\let\overlaystamp\overlaypagestamp
- \setupMPvariables[\MPpageprefix\currentMPgraphicname][#2]% prefix is new here
- \getvalue{\@@MPG\MPpageprefix\currentMPgraphicname}{}%
+ \setupMPvariables[\m_mp_page_prefix:\currentMPgraphicname][#2]% prefix is new here
+ \getvalue{\??gm:\m_mp_page_prefix:\currentMPgraphicname}{}%
\endMPgraphicgroup}
-
+
%D One way of defining a stamp is:
%D
%D \starttyping
@@ -585,59 +608,23 @@
%D Since we need to feed \METAPOST\ with expanded dimensions,
%D we introduce a dedicated expansion engine.
-\def\prepareMPvariable#1%
- {\ifcsname\@@framed\@@meta#1\endcsname
- \doprepareMPvariable{\@@framed\@@meta#1}%
- \else
- \doprepareMPvariable{\@@meta#1}%
- \fi}
-
-% \startlines
-% \def\xxx{\lineheight} \doprepareMPvariable{xxx} \xxx
-% \def\xxx{2pt} \doprepareMPvariable{xxx} \xxx
-% \def\xxx{2} \doprepareMPvariable{xxx} \xxx
-% \def\xxx{\scratchcounter} \doprepareMPvariable{xxx} \xxx
-% \def\xxx{red} \doprepareMPvariable{xxx} \xxx
-% \def\xxx{0.4} \doprepareMPvariable{xxx} \xxx
-% \stoplines
-
-\def\doprepareMPvariable#1%
- {\edef\theMPvariable{\getvalue{#1}}%
- \doifelsenothing\theMPvariable
- {\setevalue{#1}{\MPcolor{black}}}
- {\defconvertedcommand\ascii\theMPvariable % otherwise problems
- \doifcolorelse \ascii % with 2\bodyfontsize
- {\setevalue{#1}{\MPcolor\theMPvariable}}
- {% can be aux macro
- \setbox\scratchbox\hbox{\scratchdimen\theMPvariable sp}%
- \ifdim\wd\scratchbox=\zeropoint
- % \scratchcounter\theMPvariable
- % \setevalue{#1}{\the\scratchcounter}%
- % also accepts 0.number :
- \setevalue{#1}{\number\theMPvariable}%
- \else
- \scratchdimen\theMPvariable
- \setevalue{#1}{\the\scratchdimen}%
- \fi}}}
-
%D We redefine \type {\extendMPoverlaystamp} to preprocess
-%D variables using \type {\prepareMPvariable}.
+%D variables using \type {\mp_prepare_variable}.
-\def\doextendMPoverlaystamp#1%
- {\prepareMPvariable{#1}%
- \edef\overlaystamp{\overlaystamp:\MPvariable{#1}}}
+\unexpanded\def\extendMPoverlaystamp#1%
+ {\processcommalist[#1]\mp_extend_overlay_stamp}
-\def\extendMPoverlaystamp#1%
- {\processcommalist[#1]\doextendMPoverlaystamp}
-
-\def\prepareMPvariables#1%
- {\processcommalist[#1]\prepareMPvariable}
+\def\mp_extend_overlay_stamp#1%
+ {\mp_prepare_variable{#1}%
+ \edef\overlaystamp{\overlaystamp:\MPvariable{#1}}}
%D \macros
%D {MPdatafile}
%D
%D We redefine a macro from \type {supp-mps.tex}:
+% This will change ...
+
\def\MPdataMPDfile{\jobname-mpgraph.mpd}
\def\MPdataMPOfile{\jobname-mpgraph.mpo}
\def\MPdataMPYfile{\jobname-mpgraph.mpy}
@@ -649,7 +636,7 @@
def data_mpy_file = "\MPdataMPYfile" enddef ;
\stopMPextensions
-\def\getMPdata
+\unexpanded\def\getMPdata
{\let\MPdata\secondoftwoarguments
\startreadingfile
% \startnointerference % no, else we need to do all data global
@@ -662,19 +649,19 @@
% under a normal catcode regime in order to expand embedded tex macros.
% As usual with buffers, \type {#1} can be a list.
-\def\processMPbuffer
- {\dosingleempty\doprocessMPbuffer}
+\unexpanded\def\processMPbuffer
+ {\dosingleempty\mp_process_buffer}
-\def\doprocessMPbuffer[#1]%
+\def\mp_process_buffer[#1]%
{\beginMPgraphicgroup{#1}%
- \processMPgraphic{\ctxcommand{feedback("\currentMPgraphicname")}}%
+ \mp_process_graphic{\ctxcommand{feedback("\currentMPgraphicname")}}%
\endMPgraphicgroup}
-\def\runMPbuffer
- {\dosingleempty\dorunMPbuffer}
+\unexpanded\def\runMPbuffer
+ {\dosingleempty\mp_run_buffer}
-\def\dorunMPbuffer[#1]% processing only
- {\startnointerference\doprocessMPbuffer[#1]\stopnointerference}
+\def\mp_run_buffer[#1]% processing only
+ {\startnointerference\mp_process_buffer[#1]\stopnointerference}
%D \macros
%D {startMPenvironment, resetMPenvironment}
@@ -682,25 +669,26 @@
%D In order to synchronize the main \TEX\ run and the runs
%D local to \METAPOST, environments can be passed.
-\ifx\everyMPTEXgraphic\undefined
- \newtoks\everyMPTEXgraphic
-\fi
-
-%D A more general way of passing environments is:
-
-\def\startMPenvironment % second arg gobbles spaces, so that reset gives \emptytoks
+\unexpanded\def\startMPenvironment % second arg gobbles spaces, so that reset gives \emptytoks
{\dodoubleempty\dostartMPenvironment}
\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
+ {\edef\m_mp_option{#1}
+ \ifx\m_mp_option\s!reset
+ \resetMPenvironment % reset mp toks
+ \else\ifx\m_mp_option\v!global
+ #3% % use in main doc too
+ \else\ifx\m_mp_option\!!plustoken
+ #3% % use in main doc too
+ \fi\fi\fi
\ctxlua{metapost.tex.set(\!!bs\detokenize{#3}\!!es)}}
-\def\resetMPenvironment
+\let\stopMPenvironment\relax
+
+\unexpanded\def\resetMPenvironment
{\ctxlua{metapost.tex.reset()}}
-\def\useMPenvironmentbuffer[#1]%
+\unexpanded\def\useMPenvironmentbuffer[#1]%
{\ctxlua{metapost.tex.set(buffers.content("#1"))}}
%D This command takes \type {[reset]} as optional
@@ -718,41 +706,44 @@
%D
%D The most simple case:
-\def\startMPcode{\dosinglegroupempty\dostartMPcode}
+\unexpanded\def\startMPcode
+ {\dosinglegroupempty\mp_start_code}
-\def\dostartMPcode
+\def\mp_start_code
{\iffirstargument
- \expandafter\dodostartMPcode
+ \expandafter\mp_start_code_instance
\else
- \expandafter\nodostartMPcode
+ \expandafter\mp_start_code_standard
\fi}
-\def\dodostartMPcode#1#2\stopMPcode
+\def\mp_start_code_instance#1#2\stopMPcode
{\beginMPgraphicgroup{#1::\s!dummy}% name does not matter
- \processMPgraphic{#2}%
+ \mp_enable_include
+ \mp_process_graphic{#2}%
\endMPgraphicgroup}
-\def\nodostartMPcode#1#2\stopMPcode
- {\processMPgraphic{#2}}
+\def\mp_start_code_standard#1#2\stopMPcode
+ {\mp_process_graphic{#2}}
\let\stopMPcode\relax
-\def\MPcode{\dosinglegroupempty\doMPcode}
+\unexpanded\def\MPcode
+ {\dosinglegroupempty\mp_code}
-\def\doMPcode
+\def\mp_code
{\iffirstargument
- \expandafter\dodoMPcode
+ \expandafter\mp_code_instance
\else
- \expandafter\nodoMPcode
+ \expandafter\mp_code_standard
\fi}
-\def\dodoMPcode#1#2%
+\def\mp_code_instance#1#2%
{\beginMPgraphicgroup{#1::\s!dummy}% name does not matter
- \processMPgraphic{#2}%
+ \mp_process_graphic{#2}%
\endMPgraphicgroup}
-\def\nodoMPcode#1#2%
- {\processMPgraphic{#2}}
+\def\mp_code_standard#1% #2
+ {\mp_process_graphic}
% a bit nasty (also needed for compatibility:
@@ -764,7 +755,7 @@
\let\MPruninstance\defaultMPgraphicinstance
-\def\useMPrun#1#2% name n
+\unexpanded\def\useMPrun#1#2% name n
{\begingroup
\def\MPaskedfigure{#2}%
\doifelsenothing{#1}
@@ -772,34 +763,17 @@
{\useMPgraphic{#1}}%
\endgroup}
-\def\startMPrun
- {\dosinglegroupempty\dostartMPrun}
+\unexpanded\def\startMPrun
+ {\dosinglegroupempty\mp_start_run}
-\def\dostartMPrun#1#2\stopMPrun
+\def\mp_start_run#1#2\stopMPrun
{\iffirstargument
\startuseMPgraphic{#1}#2\stopuseMPgraphic
\else
\startuseMPgraphic{mprun}#2\stopuseMPgraphic
\fi}
-% for old time sake
-
-\def\dostartMPgraphic
- {\iffirstargument
- \expandafter\dodostartMPgraphic
- \else
- \expandafter\nodostartMPgraphic
- \fi}
-
-\def\dodostartMPgraphic#1#2\stopMPgraphic
- {\beginMPgraphicgroup{#1::\s!dummy}% name does not matter
- \processMPgraphic{#2}%
- \endMPgraphicgroup}
-
-\def\nodostartMPgraphic#1#2\stopMPcode
- {\processMPgraphic{#2}}
-
-\let\stopMPcode\relax
+\let\stopMPrun\relax
%D The \type {\resetMPenvironment} is a quick way to erase
%D the token list.
@@ -841,19 +815,13 @@
%D \MPbetex {identifier}
%D \stoptyping
-\def\@@MPT{@MPT@}
-
-\def\forceMPTEXgraphic
- {\def\checkMPTEXgraphic##1{\global\MPTEXgraphictrue}}
+\unexpanded\def\setMPtext#1#2% todo : #1 must be made : safe
+ {\defconvertedargument\ascii{#2}%
+ \dodoglobal\letvalue{\??gt:#1}\ascii}
-\def\setMPtext#1#2% todo : #1 must be made : safe
- {%\forceMPTEXgraphic
- \defconvertedargument\ascii{#2}%
- \dodoglobal\letvalue{\@@MPT#1}\ascii}
-
-\def\MPtext #1{\executeifdefined{\@@MPT#1}\empty}
-\def\MPstring #1{"\executeifdefined{\@@MPT#1}\empty"}
-\def\MPbetex #1{btex \executeifdefined{\@@MPT#1}\empty\space etex}
+\def\MPtext #1{\executeifdefined{\??gt:#1}\empty}
+\def\MPstring#1{"\executeifdefined{\??gt:#1}\empty"}
+\def\MPbetex #1{btex \executeifdefined{\??gt:#1}\empty\space etex}
%D In order to communicate conveniently with the \TEX\
%D engine, we introduce some typesetting variables.
@@ -978,19 +946,13 @@
%D can occur. One took me over a day to uncover when
%D processing the screen version of the \METAFUN\ manual.
-%D For my eyes only:
-
-\def\doifelseMPgraphic#1{\doifdefinedelse{\@@MPG#1}}
+\def\doifelseMPgraphic#1%
+ {\ifcsname\??gm :#1\endcsname \expandafter \firstoftwoarguments \else
+ \ifcsname\??gm:o:#1\endcsname \doubleexpandafter\firstoftwoarguments \else
+ \ifcsname\??gm:e:#1\endcsname \tripleexpandafter\firstoftwoarguments \else
+ \tripleexpandafter\secondoftwoarguments \fi\fi\fi}
-%D \macros
-%D {startMPcolor}
-
-\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}}
-
-\let\stopMPcolor\relax
+\let\doifMPgraphicelse\doifelseMPgraphic
%D New:
@@ -1064,28 +1026,27 @@
%D
%D \typebuffer \getbuffer
-\unexpanded\def\usestaticMPfigure
- {\dodoubleempty\dousestaticMPfigure}
-
-\def\dousestaticMPfigure[#1][#2]%
- {\ifsecondargument
- \scale[#2]{\reuseMPgraphic{\@@MPG#1@S@}}%
- \else
- \reuseMPgraphic{\@@MPG#1@S@}%
- \fi}
-
\unexpanded\def\startstaticMPfigure#1#2\stopstaticMPfigure
- {\startreusableMPgraphic{\@@MPG#1@S@}#2\stopreusableMPgraphic}
+ {\startreusableMPgraphic{\??gm:s:#1}#2\stopreusableMPgraphic}
\unexpanded\def\startstaticMPgraphic
- {\dodoublegroupempty\dostartstaticMPgraphic}
+ {\dodoublegroupempty\mp_start_static_graphic}
+
+\def\mp_start_static_graphic#1#2#3\stopstaticMPgraphic
+ {\startreusableMPgraphic{\??gm:s:#1}{#2}#3\stopreusableMPgraphic}
-\def\dostartstaticMPgraphic#1#2#3\stopstaticMPgraphic
- {\setgvalue{\@@MPG#1@S@}{\handlereusableMPgraphic{#1}{#2}{#3}}}
+\let\stopstaticMPfigure \relax
+\let\stopstaticMPgraphic\relax
-%D Needed too.
+\unexpanded\def\usestaticMPfigure
+ {\dodoubleempty\mp_use_static_figure}
-\let\initializeMPgraphics\relax
+\def\mp_use_static_figure[#1][#2]%
+ {\ifsecondargument
+ \scale[#2]{\reuseMPgraphic{\??gm:s:#1}}%
+ \else
+ \reuseMPgraphic{\??gm:s:#1}%
+ \fi}
%D Goody for preventing overflows:
@@ -1144,7 +1105,7 @@
%D
%D Here is a generic setup command:
-\newtoks \everysetupMPgraphics
+\newtoks\everysetupMPgraphics
\unexpanded\def\setupMPgraphics[#1]%
{\getparameters[\??mp][#1]%
diff --git a/tex/context/base/meta-tex.mkiv b/tex/context/base/meta-tex.mkiv
index 6e1beeba6..644db27d9 100644
--- a/tex/context/base/meta-tex.mkiv
+++ b/tex/context/base/meta-tex.mkiv
@@ -16,127 +16,84 @@
\unprotect
% Ok, we support this in MkIV because Mojca kept the pressure on. It
-% looks a bit like a hack.
+% looks a bit like a hack. But in fact this method is obsolete and
+% eventually might go away.
-\long\def\startTeXtexts#1\stopTeXtexts
+\unexpanded\def\startTeXtexts#1\stopTeXtexts
{#1}
-\long\def\TeXtext
- {\dosingleempty\doTeXtext}
+\let\stopTeXtexts\relax
-\long\def\doTeXtext[#1]#2#3% contrary to mkii we don't process yet but we do expand
- {\long\setxvalue{@@st@@::#2}{\noexpand\dodoTeXtext{#1}{#3}}}
+\def\TeXtext
+ {\dosingleempty\mp_textext}
-\long\def\dodoTeXtext#1#2%
+\def\mp_textext[#1]#2#3% contrary to mkii we don't process yet but we do expand
+ {\setxvalue{\??gx:#2}{\mp_textext_indeed{#1}{#3}}}
+
+\unexpanded\def\mp_textext_indeed#1#2%
{\begingroup
- \setbox\nextbox\hbox{\executeifdefined{textext@@#1}\firstofoneargument{#2}}%
- \executeifdefined{textext::#1}{\getvalue{textext::depth}}%
+ \setbox\nextbox\hbox{#2}%
+ \executeifdefined{\??gx:m:#1}{\getvalue{\??gx:m:depth}}%
\box\nextbox
\endgroup}
\def\getTeXtext#1%
- {\getvalue{@@st@@::#1}}
+ {\getvalue{\??gx:#1}}
-\setvalue{textext::d}{\setbox\nextbox\hbox{\lower\dp\nextbox\box\nextbox}} % unchecked
-\setvalue{textext::n}{} % unchecked
+\setvalue{\??gx:m:d}{\setbox\nextbox\hbox{\lower\dp\nextbox\box\nextbox}} % unchecked
+\setvalue{\??gx:m:n}{} % unchecked
-\setvalue {textext::depth}{\getvalue{textext::d}}
-\setvalue{textext::nodepth}{\getvalue{textext::n}}
+\setvalue {\??gx:m:depth}{\getvalue{\??gx:m:d}}
+\setvalue{\??gx:m:nodepth}{\getvalue{\??gx:m:n}}
% \definetextext[framed]{\framed}
%
% \startMPcode
% draw \sometxt[framed]{black} rotated 45 ;
% \stopMPcode
-
-% \unexpanded\def\definetextext[#1]#2{\setvalue{@@st@@[#1]}{#2}\setvalue{@@st@@[#1] }{#2}} % we don't grab spaces after [#1]
-% \long\def\sometxt #1#{\dosometxt{#1}} % grab optional [args]
-% \long\def\dosometxt #1#2{textext.drt("\ifcsname @@st@@#1\endcsname\csname @@st@@#1\endcsname{#2}\else#2\fi")}
-
+%
% But Mojca wanted more! Two arguments.
%
% \definetextext[framed]{\framed}
%
% \startMPcode
% draw \sometxt{This is for} rotated 45 ;
-% draw \sometxt[framed][ss,16pt]{Mojca's};
+% draw \sometxt[framed][foregroundstyle=bold]{Mojca's};
% draw \sometxt[framed]{eyes only!} rotated -45 ;
% \stopMPcode
-% a tex one:
-%
-% \unexpanded\def\definetextext [#1]#2{\setvalue{@@st@@#1}{#2}}
-% \def\sometxt #1#{\dosometxt{#1}}
-% \def\dosometxt #1#2{textext.drt("\dodosometxt#1{#2}")}
-%
-% \unexpanded\def\dodosometxt {\doifnextoptionalelse\dododosometxt\relax}
-% \def\dododosometxt [#1]{\dodododosometxt{#1}}
-% \def\dodododosometxt #1{\doifnextoptionalelse{\dododododosometxt{#1}}{\getsometxt{#1}}}
-% \def\dododododosometxt #1[#2]{\switchtobodyfont[#2]\getsometxt{#1}}
-% \def\getsometxt #1#2{\csname @@st@@#1\endcsname{#2}}
-%
-% or:
-%
-% \unexpanded\def\dodosometxt {\dodoubleempty\dododosometxt}
-% \def\dododosometxt {\ifsecondargument
-% \expandafter\dododosometxtA
-% \else\iffirstargument
-% \expandafter\expandafter\expandafter\dododosometxtB
-% \else
-% \expandafter\expandafter\expandafter\dododosometxtC
-% \fi\fi}
-% \def\dododosometxtA[#1][#2]#3{\getsometxt{#1}{\switchtobodyfont[#2]#3}}
-% \def\dododosometxtB[#1][#2]#3{\getsometxt{#1}{#3}}
-% \def\dododosometxtC[#1][#2]#3{#3}
-% \def\getsometxt #1#2{\csname @@st@@#1\endcsname{#2}}
-%
-% a nicer variant:
-
\unexpanded\def\definetextext[#1]%
{\def\currenttextext{#1}%
- \dosingleempty\dodefinetextext}
-
-\def\dodefinetextext
- {\iffirstargument
- \expandafter\dodefinetextextone
- \else
- \expandafter\dodefinetextextzero
- \fi}
+ \doifnextoptionalelse\mp_define_textext_one\mp_define_textext_zero}
-\def\dodefinetextextone {\setvalue{@@st@@one\currenttextext}}
-\def\dodefinetextextzero[#1]{\setvalue{@@st@@zero\currenttextext}}
+\def\mp_define_textext_one {\setvalue{\??gx:1:\currenttextext}}
+\def\mp_define_textext_zero{\setvalue{\??gx:0:\currenttextext}}
-\def\sometxt#1#%
- {\dosometxt{#1}}
+\def\sometxt#1#{\mp_some_txt{#1}}
-\def\dosometxt#1#2% we need to capture embedded quotes (a bit messy as later on textext is filtered
- {textext.drt("\dodosometxt#1{\ctxlua{metapost.escaped(\!!bs#2\!!es)}}")}
+\def\mp_some_txt#1#2% we need to capture embedded quotes (a bit messy as later on textext is filtered
+ {textext.drt("\mpsometxt#1{\ctxlua{metapost.escaped(\!!bs#2\!!es)}}")}
-\unexpanded\def\dodosometxt
- {\dosingleempty\dododosometxt}
-\def\dododosometxt
- {\iffirstargument
- \expandafter\dosometxtsome
- \else
- \expandafter\dosometxtzero
- \fi}
+\unexpanded\def\mpsometxt % no _ catcode
+ {\doifnextoptionalelse\mp_some_txt_indeed_yes\mp_some_txt_indeed_nop}
-\def\dosometxtsome[#1]%
+\def\mp_some_txt_indeed_yes[#1]%
{\def\currenttextext{#1}%
- \csname @@st@@%
- \ifcsname @@st@@one#1\endcsname one\else
- \ifcsname @@st@@zero#1\endcsname zero\else
- none\fi\fi
+ \csname\??gx:%
+ \ifcsname\??gx:0:#1\endcsname0\else
+ \ifcsname\??gx:1:#1\endcsname1\else
+ ?\fi\fi
\endcsname}
-\def\dosometxtzero[#1]%
+\def\mp_some_txt_indeed_nop
{}
-\def\@@st@@one {\dosingleempty\do@@st@@one}
-\def\do@@st@@one{\csname @@st@@one\currenttextext\endcsname}
-\def\@@st@@zero {\csname @@st@@zero\currenttextext\endcsname}
-\def\@@st@@none {}
+\setvalue{\??gx:?}{}
+\setvalue{\??gx:0}{\csname\??gx:0:\currenttextext\endcsname}
+\setvalue{\??gx:1}{\dosingleempty\mp_gx_one}
+
+\def\mp_gx_one{\csname\??gx:1:\currenttextext\endcsname}
% \definetextext[framed][#1]#2{\framed[width=4cm]{\switchtobodyfont[#1]#2}}
% \definetextext[simple]{\framed[width=8cm]}
@@ -145,7 +102,7 @@
%
% \startMPcode
% draw \sometxt{This is for} rotated 45 ;
-% draw \sometxt [framed] [ss,16pt] {Mojca's};
+% draw \sometxt[framed][ss,16pt] {Mojca's};
% draw \sometxt[framed]{eyes only!} rotated -45 ;
% draw \sometxt[simple]{Quotes "indeed" work!} rotated 180 ;
% \stopMPcode
diff --git a/tex/context/base/mlib-pps.mkiv b/tex/context/base/mlib-pps.mkiv
index f4d5483d3..cebaddb0c 100644
--- a/tex/context/base/mlib-pps.mkiv
+++ b/tex/context/base/mlib-pps.mkiv
@@ -67,10 +67,13 @@
\vbox to \zeropoint\bgroup
\vss
\hbox to \zeropoint \bgroup
- % \scale[\c!sx=#8,\c!sy=#9]{\raise\dp\MPtextbox\box\MPtextbox}\forcecolorhack
- \dostartscaling{#8}{#9}%
- \raise\dp\MPtextbox\box\MPtextbox
- \dostopscaling
+ \scale[\c!sx=#8,\c!sy=#9]{\raise\dp\MPtextbox\box\MPtextbox}%
+ \forcecolorhack % needed ? already in the scale macro
+ % % This gives: LuaTeX warning: Misplaced \pdfrestore .. don't ask me why.
+ %
+ % \dostartscaling{#8}{#9}%
+ % \raise\dp\MPtextbox\box\MPtextbox
+ % \dostopscaling
\hss
\egroup
\egroup
diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv
index 24b1aa6c5..4cef621fd 100644
--- a/tex/context/base/mult-aux.mkiv
+++ b/tex/context/base/mult-aux.mkiv
@@ -167,7 +167,6 @@
\def#8{\ifx#2\empty\else\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi\fi}%
\unexpanded\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}}
-
\unexpanded\def\installparameterhashhandler#1#2%
{\normalexpanded
{\doinstallparameterhashhandler
@@ -348,7 +347,7 @@
\expandafter\noexpand\csname everysetup#2\endcsname
\expandafter\noexpand\csname setupcurrent#2\endcsname}}
-\unexpanded\def\doinstallautosetuphandler#1#2#3#4#5#6%
+\unexpanded\def\doinstallautosetuphandler#1#2#3#4#5#6#7%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dotripleempty#4}%
% \unexpanded\def#6{\getparameters[#1#3:]}%
@@ -360,12 +359,13 @@
\def\docommand####1%
{\edef#3{####1}%
% \getparameters[#1#3:][\s!parent=#1##2,##3]%
- \get_parameters{#1#3:}[\s!parent=#1##2,##3]%
+ \get_parameters{#1#3:}[\s!parent=#1##2,##3]% always sets parent
\the#5}%
\processcommalist[##1]\docommand
\else\ifsecondargument
\def\docommand####1%
{\edef#3{####1}%
+ #7% checks parent and sets if needed
% \getparameters[#1#3:][##2]%
\get_parameters{#1#3:}[##2]%
\the#5}%
@@ -386,7 +386,8 @@
\expandafter\noexpand\csname current#2\endcsname
\expandafter\noexpand\csname d@setup#2\endcsname % sort of public
\expandafter\noexpand\csname everysetup#2\endcsname
- \expandafter\noexpand\csname setupcurrent#2\endcsname}}
+ \expandafter\noexpand\csname setupcurrent#2\endcsname
+ \expandafter\noexpand\csname check#2parent\endcsname}}
\unexpanded\def\installbasicparameterhandler#1#2%
{\installparameterhandler {#1}{#2}%
@@ -394,6 +395,10 @@
\installparametersethandler {#1}{#2}%
\installrootparameterhandler{#1}{#2}}
+\unexpanded\def\installbasicautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
+ {\installbasicparameterhandler{#1}{#2}%
+ \installautosetuphandler {#1}{#2}}
+
\unexpanded\def\installcommandhandler#1#2#3% \??self name \??parent (can be \??self)
{\installbasicparameterhandler{#1}{#2}%
\installdefinehandler {#1}{#2}{#3}%
@@ -480,4 +485,20 @@
\def\showparentchain#1#2%
{\writestatus\m!system{chain: [ \doshowparentchain{#1#2}]}}
+%D Conventions:
+%D
+%D \starttyping
+%D \newcount \c_class_whatever
+%D \newconditional \c_class_whatever
+%D \newconstant \c_class_whatever
+%D \newdimen \d_class_whatever
+%D \newskip \s_class_whatever
+%D \newmuskip \s_class_whatever
+%D \newbox \b_class_whatever
+%D \newtoks \t_class_whatever
+%D
+%D \edef\p_class_whatever{\classparameter\c!whatever}
+%D \edef\m_class_whatever{whatever}
+%D \stoptyping
+
\protect
diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii
index 079a890f5..e6aab7ad5 100644
--- a/tex/context/base/mult-de.mkii
+++ b/tex/context/base/mult-de.mkii
@@ -575,6 +575,7 @@
\setinterfaceconstant{blank}{blanko}
\setinterfaceconstant{blockway}{blockauf}
\setinterfaceconstant{bodyfont}{fliesstext}
+\setinterfaceconstant{boffset}{boffset}
\setinterfaceconstant{bookmark}{bookmark}
\setinterfaceconstant{bottom}{unten}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -765,6 +766,7 @@
\setinterfaceconstant{listtext}{listtext}
\setinterfaceconstant{local}{lokal}
\setinterfaceconstant{location}{platz}
+\setinterfaceconstant{loffset}{loffset}
\setinterfaceconstant{logo}{logo}
\setinterfaceconstant{logos}{logos}
\setinterfaceconstant{marcolor}{beschrfarbe}
@@ -918,6 +920,7 @@
\setinterfaceconstant{rightsubsentence}{rechtersubsatz}
\setinterfaceconstant{righttext}{rechtertext}
\setinterfaceconstant{rightwidth}{rechterbreite}
+\setinterfaceconstant{roffset}{roffset}
\setinterfaceconstant{rotation}{rotation}
\setinterfaceconstant{rule}{linie}
\setinterfaceconstant{rulecolor}{linienfarbe}
@@ -1012,6 +1015,7 @@
\setinterfaceconstant{titleright}{titleright}
\setinterfaceconstant{titlestyle}{titelstil}
\setinterfaceconstant{to}{zu}
+\setinterfaceconstant{toffset}{toffset}
\setinterfaceconstant{tolerance}{toleranz}
\setinterfaceconstant{top}{oben}
\setinterfaceconstant{topdistance}{obenabstand}
diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua
index 23a4a08b5..8430154ed 100644
--- a/tex/context/base/mult-def.lua
+++ b/tex/context/base/mult-def.lua
@@ -9138,6 +9138,18 @@ return {
["pe"]="آفست",
["ro"]="offset",
},
+ ["loffset"]={
+ ["en"]="loffset",
+ },
+ ["roffset"]={
+ ["en"]="roffset",
+ },
+ ["toffset"]={
+ ["en"]="toffset",
+ },
+ ["boffset"]={
+ ["en"]="boffset",
+ },
["openaction"]={
["cs"]="otevriakci",
["de"]="oeffenaktion",
diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii
index 70f2cab42..a646a51c6 100644
--- a/tex/context/base/mult-en.mkii
+++ b/tex/context/base/mult-en.mkii
@@ -575,6 +575,7 @@
\setinterfaceconstant{blank}{blank}
\setinterfaceconstant{blockway}{blockway}
\setinterfaceconstant{bodyfont}{bodyfont}
+\setinterfaceconstant{boffset}{boffset}
\setinterfaceconstant{bookmark}{bookmark}
\setinterfaceconstant{bottom}{bottom}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -765,6 +766,7 @@
\setinterfaceconstant{listtext}{listtext}
\setinterfaceconstant{local}{local}
\setinterfaceconstant{location}{location}
+\setinterfaceconstant{loffset}{loffset}
\setinterfaceconstant{logo}{logo}
\setinterfaceconstant{logos}{logos}
\setinterfaceconstant{marcolor}{marcolor}
@@ -918,6 +920,7 @@
\setinterfaceconstant{rightsubsentence}{rightsubsentence}
\setinterfaceconstant{righttext}{righttext}
\setinterfaceconstant{rightwidth}{rightwidth}
+\setinterfaceconstant{roffset}{roffset}
\setinterfaceconstant{rotation}{rotation}
\setinterfaceconstant{rule}{rule}
\setinterfaceconstant{rulecolor}{rulecolor}
@@ -1012,6 +1015,7 @@
\setinterfaceconstant{titleright}{titleright}
\setinterfaceconstant{titlestyle}{titlestyle}
\setinterfaceconstant{to}{to}
+\setinterfaceconstant{toffset}{toffset}
\setinterfaceconstant{tolerance}{tolerance}
\setinterfaceconstant{top}{top}
\setinterfaceconstant{topdistance}{topdistance}
diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii
index 4d4f3c47e..dd8e69434 100644
--- a/tex/context/base/mult-fr.mkii
+++ b/tex/context/base/mult-fr.mkii
@@ -575,6 +575,7 @@
\setinterfaceconstant{blank}{vide}
\setinterfaceconstant{blockway}{blockway}
\setinterfaceconstant{bodyfont}{policecorps}
+\setinterfaceconstant{boffset}{boffset}
\setinterfaceconstant{bookmark}{marquepage}
\setinterfaceconstant{bottom}{inf}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -765,6 +766,7 @@
\setinterfaceconstant{listtext}{texteliste}
\setinterfaceconstant{local}{local}
\setinterfaceconstant{location}{emplacement}
+\setinterfaceconstant{loffset}{loffset}
\setinterfaceconstant{logo}{logo}
\setinterfaceconstant{logos}{logos}
\setinterfaceconstant{marcolor}{couleurmarquage}
@@ -918,6 +920,7 @@
\setinterfaceconstant{rightsubsentence}{sousphrasedroite}
\setinterfaceconstant{righttext}{textedroit}
\setinterfaceconstant{rightwidth}{largeurdroite}
+\setinterfaceconstant{roffset}{roffset}
\setinterfaceconstant{rotation}{rotation}
\setinterfaceconstant{rule}{ligne}
\setinterfaceconstant{rulecolor}{couleurligne}
@@ -1012,6 +1015,7 @@
\setinterfaceconstant{titleright}{titleright}
\setinterfaceconstant{titlestyle}{styletitre}
\setinterfaceconstant{to}{vers}
+\setinterfaceconstant{toffset}{toffset}
\setinterfaceconstant{tolerance}{tolerance}
\setinterfaceconstant{top}{sup}
\setinterfaceconstant{topdistance}{distancesup}
diff --git a/tex/context/base/mult-fst.mkiv b/tex/context/base/mult-fst.mkiv
deleted file mode 100644
index e9d7c0b22..000000000
--- a/tex/context/base/mult-fst.mkiv
+++ /dev/null
@@ -1,41 +0,0 @@
-%D \module
-%D [ file=mult-fst,
-%D version=2006.08.16,
-%D title=\CONTEXT\ Multilingual Macros,
-%D subtitle=Speed Up,
-%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.
-
-% And so, after a few years of keeping this potentially dangerous
-% speedup in cont-exp, we now move it to the kernel: the next
-% patch is 30\% faster on main interface (seconds) (9->7 sec on
-% 1 million calls). Another speed up is still under testing.
-
-\unprotect
-
-\startinterface english
-
- \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\gdef\csname#1#2\endcsname}
- \def\docopyvalue#1#2#3{\@EA\def \csname#1#3\@EA\endcsname\@EA{\csname#2#3\endcsname}}
-
- \def\setinterfaceconstant#1#2%
- {\ctxlua{interfaces.setconstant("#1","#2")}%
- \setvalue{\c!prefix!#1}{#1}}
-
- \def\setinterfacevariable#1#2%
- {\ctxlua{interfaces.setvariable("#1","#2")}%
- \setvalue{\v!prefix!#1}{#2}}
-
- \def\interfaced#1{#1}
-
-\stopinterface
-
-\protect \endinput
diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii
index 9747dfddc..f562b3e21 100644
--- a/tex/context/base/mult-it.mkii
+++ b/tex/context/base/mult-it.mkii
@@ -575,6 +575,7 @@
\setinterfaceconstant{blank}{rigovuoto}
\setinterfaceconstant{blockway}{blockway}
\setinterfaceconstant{bodyfont}{fonttesto}
+\setinterfaceconstant{boffset}{boffset}
\setinterfaceconstant{bookmark}{segnalibro}
\setinterfaceconstant{bottom}{fondo}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -765,6 +766,7 @@
\setinterfaceconstant{listtext}{listtext}
\setinterfaceconstant{local}{locale}
\setinterfaceconstant{location}{luogo}
+\setinterfaceconstant{loffset}{loffset}
\setinterfaceconstant{logo}{logo}
\setinterfaceconstant{logos}{loghi}
\setinterfaceconstant{marcolor}{coloremarcatura}
@@ -918,6 +920,7 @@
\setinterfaceconstant{rightsubsentence}{sottofrasedestra}
\setinterfaceconstant{righttext}{testodestro}
\setinterfaceconstant{rightwidth}{ampiezzadestra}
+\setinterfaceconstant{roffset}{roffset}
\setinterfaceconstant{rotation}{rotazione}
\setinterfaceconstant{rule}{linea}
\setinterfaceconstant{rulecolor}{colorelinea}
@@ -1012,6 +1015,7 @@
\setinterfaceconstant{titleright}{titleright}
\setinterfaceconstant{titlestyle}{stiletitolo}
\setinterfaceconstant{to}{verso}
+\setinterfaceconstant{toffset}{toffset}
\setinterfaceconstant{tolerance}{tolleranza}
\setinterfaceconstant{top}{cima}
\setinterfaceconstant{topdistance}{distanzacima}
diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii
index 9b3e146c8..965a92aae 100644
--- a/tex/context/base/mult-nl.mkii
+++ b/tex/context/base/mult-nl.mkii
@@ -575,6 +575,7 @@
\setinterfaceconstant{blank}{blanko}
\setinterfaceconstant{blockway}{blokwijze}
\setinterfaceconstant{bodyfont}{korps}
+\setinterfaceconstant{boffset}{boffset}
\setinterfaceconstant{bookmark}{bookmark}
\setinterfaceconstant{bottom}{onder}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -765,6 +766,7 @@
\setinterfaceconstant{listtext}{lijsttekst}
\setinterfaceconstant{local}{lokaal}
\setinterfaceconstant{location}{plaats}
+\setinterfaceconstant{loffset}{loffset}
\setinterfaceconstant{logo}{logo}
\setinterfaceconstant{logos}{logos}
\setinterfaceconstant{marcolor}{markleur}
@@ -918,6 +920,7 @@
\setinterfaceconstant{rightsubsentence}{rechtersubzin}
\setinterfaceconstant{righttext}{rechtertekst}
\setinterfaceconstant{rightwidth}{rechterbreedte}
+\setinterfaceconstant{roffset}{roffset}
\setinterfaceconstant{rotation}{rotatie}
\setinterfaceconstant{rule}{lijn}
\setinterfaceconstant{rulecolor}{lijnkleur}
@@ -1012,6 +1015,7 @@
\setinterfaceconstant{titleright}{titelrechts}
\setinterfaceconstant{titlestyle}{titelletter}
\setinterfaceconstant{to}{aan}
+\setinterfaceconstant{toffset}{toffset}
\setinterfaceconstant{tolerance}{tolerantie}
\setinterfaceconstant{top}{boven}
\setinterfaceconstant{topdistance}{bovenafstand}
diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii
index 766ba89a8..08b4f1533 100644
--- a/tex/context/base/mult-pe.mkii
+++ b/tex/context/base/mult-pe.mkii
@@ -575,6 +575,7 @@
\setinterfaceconstant{blank}{خالی}
\setinterfaceconstant{blockway}{راه‌بلوک}
\setinterfaceconstant{bodyfont}{قلم‌بدنه}
+\setinterfaceconstant{boffset}{boffset}
\setinterfaceconstant{bookmark}{چوبخط}
\setinterfaceconstant{bottom}{پایین}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -765,6 +766,7 @@
\setinterfaceconstant{listtext}{متن‌لیست}
\setinterfaceconstant{local}{موضعی}
\setinterfaceconstant{location}{مکان}
+\setinterfaceconstant{loffset}{loffset}
\setinterfaceconstant{logo}{آرم}
\setinterfaceconstant{logos}{آرمها}
\setinterfaceconstant{marcolor}{رنگ‌حاش}
@@ -918,6 +920,7 @@
\setinterfaceconstant{rightsubsentence}{زیرجمله‌راست}
\setinterfaceconstant{righttext}{متن‌راست}
\setinterfaceconstant{rightwidth}{عرض‌راست}
+\setinterfaceconstant{roffset}{roffset}
\setinterfaceconstant{rotation}{دوران}
\setinterfaceconstant{rule}{خط}
\setinterfaceconstant{rulecolor}{رنگ‌خط}
@@ -1012,6 +1015,7 @@
\setinterfaceconstant{titleright}{عنوان‌راست}
\setinterfaceconstant{titlestyle}{سبک‌عنوان}
\setinterfaceconstant{to}{به}
+\setinterfaceconstant{toffset}{toffset}
\setinterfaceconstant{tolerance}{بردباری}
\setinterfaceconstant{top}{بالا}
\setinterfaceconstant{topdistance}{فاصله‌بالا}
diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii
index 3daadd0c8..8fafc2ca3 100644
--- a/tex/context/base/mult-ro.mkii
+++ b/tex/context/base/mult-ro.mkii
@@ -575,6 +575,7 @@
\setinterfaceconstant{blank}{blanc}
\setinterfaceconstant{blockway}{blockway}
\setinterfaceconstant{bodyfont}{fonttext}
+\setinterfaceconstant{boffset}{boffset}
\setinterfaceconstant{bookmark}{semncarte}
\setinterfaceconstant{bottom}{jos}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -765,6 +766,7 @@
\setinterfaceconstant{listtext}{listtext}
\setinterfaceconstant{local}{local}
\setinterfaceconstant{location}{locatie}
+\setinterfaceconstant{loffset}{loffset}
\setinterfaceconstant{logo}{logo}
\setinterfaceconstant{logos}{logos}
\setinterfaceconstant{marcolor}{culoaremarcaj}
@@ -918,6 +920,7 @@
\setinterfaceconstant{rightsubsentence}{subpropozitiedreapta}
\setinterfaceconstant{righttext}{textdreapta}
\setinterfaceconstant{rightwidth}{marginedreapta}
+\setinterfaceconstant{roffset}{roffset}
\setinterfaceconstant{rotation}{rotatie}
\setinterfaceconstant{rule}{rigla}
\setinterfaceconstant{rulecolor}{culoarerigla}
@@ -1012,6 +1015,7 @@
\setinterfaceconstant{titleright}{titleright}
\setinterfaceconstant{titlestyle}{stiltitlu}
\setinterfaceconstant{to}{catre}
+\setinterfaceconstant{toffset}{toffset}
\setinterfaceconstant{tolerance}{toleranta}
\setinterfaceconstant{top}{sus}
\setinterfaceconstant{topdistance}{distantasus}
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index b36a43ead..261ae240d 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -444,6 +444,9 @@
\let\onerealpoint\onepoint % needed for latex
+\def\!!plustoken {+}
+\def\!!minustoken{-}
+
% D Another optimization is:
%
% \let\points\onepoint
@@ -559,7 +562,15 @@
\definesystemvariable {fw} % simpleFonts by Wolfgang
\definesystemvariable {fx} % FoXet
\definesystemvariable {gr} % GRid
+\definesystemvariable {gm} % Graphic Metapost
+\definesystemvariable {gi} % Graphic Instance
+\definesystemvariable {gt} % Graphic Text
+\definesystemvariable {gv} % Graphic Variable
+\definesystemvariable {gp} % Graphic Position
+\definesystemvariable {gq} % Graphic Position Method
+\definesystemvariable {gx} % Graphic TeX Text
\definesystemvariable {ha} % HAng
+\definesystemvariable {hf} % Helpers Framed
\definesystemvariable {hl} % HighLight
\definesystemvariable {hs} % HSpace
\definesystemvariable {ht} % HiddenText
diff --git a/tex/context/base/pack-fen.mkiv b/tex/context/base/pack-fen.mkiv
index 63c5659e4..722d8fed7 100644
--- a/tex/context/base/pack-fen.mkiv
+++ b/tex/context/base/pack-fen.mkiv
@@ -28,62 +28,70 @@
\unprotect
\def\installleftframerenderer#1#2%
- {\setvalue{l\@@frame@@\v!on#1}{\whateverleftframe{#2}}%
- \expandafter\let\csname l\@@frame@@\v!off#1\expandafter\endcsname\csname l\@@frame@@\v!on#1\endcsname}
+ {\setvalue{\??hf l\v!on#1}{\whateverleftframe{#2}}%
+ \expandafter\let\csname\??hf l\v!off#1\expandafter\endcsname\csname\??hf l\v!on#1\endcsname}
\def\installrightframerenderer#1#2%
- {\setvalue{r\@@frame@@\v!on#1}{\whateverrightframe{#2}}%
- \expandafter\let\csname r\@@frame@@\v!off#1\expandafter\endcsname\csname r\@@frame@@\v!on#1\endcsname}
+ {\setvalue{\??hf r\v!on#1}{\whateverrightframe{#2}}%
+ \expandafter\let\csname\??hf r\v!off#1\expandafter\endcsname\csname\??hf r\v!on#1\endcsname}
\def\installtopframerenderer#1#2%
- {\setvalue{t\@@frame@@\v!on#1}{\whatevertopframe{#2}}%
- \expandafter\let\csname t\@@frame@@\v!off#1\expandafter\endcsname\csname t\@@frame@@\v!on#1\endcsname}
+ {\setvalue{\??hf t\v!on#1}{\whatevertopframe{#2}}%
+ \expandafter\let\csname\??hf t\v!off#1\expandafter\endcsname\csname\??hf t\v!on#1\endcsname}
\def\installbottomframerenderer#1#2%
- {\setvalue{b\@@frame@@\v!on#1}{\whateverbottomframe{#2}}%
- \expandafter\let\csname b\@@frame@@\v!off#1\expandafter\endcsname\csname b\@@frame@@\v!on#1\endcsname}
+ {\setvalue{\??hf b\v!on#1}{\whateverbottomframe{#2}}%
+ \expandafter\let\csname\??hf b\v!off#1\expandafter\endcsname\csname\??hf b\v!on#1\endcsname}
-\def\setinstalledframedimensions
- {\edef\overlaywidth {\the\frameddimenwd\space}%
- \edef\overlayheight{\the\dimexpr\frameddimenht+\frameddimendp\relax\space}%
- \edef\overlaydepth {\the\frameddimendp\space}%
- \edef\overlaycolor {\framedparameter\c!backgroundcolor}%
- \edef\overlaylinecolor{\framedparameter\c!framecolor}%
- \edef\overlaylinewidth{\the\ruledlinewidth}}
+\ifdefined \framed_overlay_initialize_indeed
-\newbox\specialframebox
+ \let\installedframedimensions\framed_overlay_initialize_indeed
+
+\else
+
+ \def\setinstalledframedimensions
+ {\edef\overlaywidth {\the\frameddimenwd\space}%
+ \edef\overlayheight {\the\dimexpr\frameddimenht+\frameddimendp\relax\space}%
+ \edef\overlaydepth {\the\frameddimendp\space}%
+ \edef\overlaycolor {\framedparameter\c!backgroundcolor}%
+ \edef\overlaylinecolor{\framedparameter\c!framecolor}%
+ \edef\overlaylinewidth{\the\ruledlinewidth}}
+
+\fi
+
+\newbox\b_framed_rendered
\def\whateverleftframe#1%
{\setinstalledframedimensions
- \setbox\specialframebox\vbox to \overlayheight{\vss#1\vss}%
- \setbox\specialframebox\hbox to \zeropoint{\box\specialframebox\hss}%
- \ht\specialframebox\zeropoint
- \dp\specialframebox\zeropoint
- \box\specialframebox}
+ \setbox\b_framed_rendered\vbox to \overlayheight{\vss#1\vss}%
+ \setbox\b_framed_rendered\hbox to \zeropoint{\box\b_framed_rendered\hss}%
+ \ht\b_framed_rendered\zeropoint
+ \dp\b_framed_rendered\zeropoint
+ \box\b_framed_rendered}
\def\whateverrightframe#1%
{\setinstalledframedimensions
- \setbox\specialframebox\vbox to \overlayheight{\vss#1\vss}%
- \setbox\specialframebox\hbox to \zeropoint{\hss\box\specialframebox}%
- \ht\specialframebox\zeropoint
- \dp\specialframebox\zeropoint
- \box\specialframebox}
+ \setbox\b_framed_rendered\vbox to \overlayheight{\vss#1\vss}%
+ \setbox\b_framed_rendered\hbox to \zeropoint{\hss\box\b_framed_rendered}%
+ \ht\b_framed_rendered\zeropoint
+ \dp\b_framed_rendered\zeropoint
+ \box\b_framed_rendered}
\def\whatevertopframe#1%
{\setinstalledframedimensions
- \setbox\specialframebox\hbox to \overlaywidth{\hss#1\hss}%
- \setbox\specialframebox\vbox to \zeropoint{\box\specialframebox\vss}%
- \ht\specialframebox\zeropoint
- \dp\specialframebox\zeropoint
- \box\specialframebox
+ \setbox\b_framed_rendered\hbox to \overlaywidth{\hss#1\hss}%
+ \setbox\b_framed_rendered\vbox to \zeropoint{\box\b_framed_rendered\vss}%
+ \ht\b_framed_rendered\zeropoint
+ \dp\b_framed_rendered\zeropoint
+ \box\b_framed_rendered
\nointerlineskip}
\def\whateverbottomframe#1%
{\setinstalledframedimensions
- \setbox\specialframebox\hbox to \overlaywidth{\hss#1\hss}%
- \setbox\specialframebox\vbox to \zeropoint{\vss\box\specialframebox}%
- \ht\specialframebox\zeropoint
- \dp\specialframebox\zeropoint
- \box\specialframebox}
+ \setbox\b_framed_rendered\hbox to \overlaywidth{\hss#1\hss}%
+ \setbox\b_framed_rendered\vbox to \zeropoint{\vss\box\b_framed_rendered}%
+ \ht\b_framed_rendered\zeropoint
+ \dp\b_framed_rendered\zeropoint
+ \box\b_framed_rendered}
\protect \endinput
diff --git a/tex/context/base/pack-mrl.mkiv b/tex/context/base/pack-mrl.mkiv
new file mode 100644
index 000000000..bc6fec2bb
--- /dev/null
+++ b/tex/context/base/pack-mrl.mkiv
@@ -0,0 +1,859 @@
+%D \module
+%D [ file=pack-mrl, % was pack-rul/core-rul,
+%D version=1998.10.16,
+%D title=\CONTEXT\ Packaging Macros,
+%D subtitle=More Rules,
+%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 Packaging Macros / More Rules}
+
+%D This module needs an overhaul.
+
+\unprotect
+
+%D \macros
+%D {setupblackrules}
+%D
+%D The graphic capabilities of \TEX\ do not go beyond simple
+%D filled rules, except of course when using specials. Let's
+%D start with a warning: using this commands is far more slower
+%D than using the \TEX\ primitives \type{\hrule} and
+%D \type{\vrule}, but they save us some tokens. The
+%D characteristics of these rule drawing command can be set by:
+%D
+%D \showsetup{setupblackrules}
+
+\unexpanded\def\setupblackrules
+ {\dodoubleargument\getparameters[\??bj]}
+
+%D \macros
+%D {blackrule}
+%D
+%D The simple command draws only one rule. Its optional
+%D argument can be used to specify the dimensions. By setting
+%D the width, height or depth to \type {max}, one gets the
+%D natural dimensions.
+%D
+%D \showsetup{blackrule}
+
+\definecomplexorsimple\blackrule
+
+\unexpanded\def\complexblackrule[#1]%
+ {\hbox\bgroup\getparameters[\??bj][#1]\domakeblackrule\egroup}
+
+\unexpanded\def\simpleblackrule
+ {\hbox\bgroup\domakeblackrule\egroup}
+
+\def\domakeblackrule
+ {\doif\@@bjwidth \v!max{\def\@@bjwidth {1em}}%
+ \doif\@@bjheight\v!max{\setstrut\let\setstrut\relax\def\@@bjheight{\strutht}}%
+ \doif\@@bjdepth \v!max{\setstrut\def\@@bjdepth {\strutdp}}%
+ \startcolor[\@@bjcolor]% can be made faster, just direct attr
+ \vrule
+ \!!width \@@bjwidth
+ \!!height\@@bjheight
+ \!!depth \@@bjdepth
+ \stopcolor}
+
+%D \macros
+%D {blackrules}
+%D
+%D One can call for a sequence of black rules, if needed
+%D equally spaced over the given width.
+%D
+%D \showsetup{blackrules}
+%D
+%D The two alternative calls are therefore:
+%D
+%D \startbuffer
+%D Tell me, is this according to the \blackrules[n=6]?
+%D These \blackrules[alternativevariant=b,n=10,distance=.2em,width=4cm] are quite clear.
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D or:
+%D
+%D \startlines
+%D \getbuffer
+%D \stoplines
+%D
+%D We could of course have implemented this macro using
+%D \type{\leaders}, but this would probably have taken more
+%D tokens.
+
+\def\doblackrules[#1]%
+ {\hbox\bgroup
+ \getparameters[\??bj][#1]%
+ \!!widtha\@@bjwidth
+ \!!widthb\@@bjdistance
+ \doif\@@bjalternative\c!b
+ {\scratchcounter\@@bjn
+ \ifnum\scratchcounter=\plusone
+ \!!widthb\zeropoint
+ \else
+ \advance\scratchcounter \minusone
+ \advance\!!widtha -\scratchcounter\!!widthb
+ \divide \!!widtha \@@bjn
+ \fi}%
+ \startcolor[\@@bjcolor]%
+ \dorecurse\@@bjn
+ {\vrule
+ \!!width \!!widtha
+ \!!height\@@bjheight
+ \!!depth \@@bjdepth
+ \hskip\!!widthb}%
+ \unskip
+ \stopcolor
+ \egroup}
+
+\unexpanded\def\blackrules
+ {\dosingleempty\doblackrules}
+
+%D The next commands can be used to draw margin rules. We
+%D support two methods: \marginrule{one for in||line use} and
+%D one that acts on a paragraph. Drawing a margin rule is
+%D rather straightforward because we can use the commands that
+%D put text in the margin.
+
+\def\dodrawmarginrule
+ {\setbox\scratchbox\hbox
+ {\vrule\!!depth\strutdepth\!!height\strutheight\!!width\@@karulethickness}%
+ \smashbox\scratchbox % no \vsmash !!!
+ \box\scratchbox}
+
+\def\drawmarginrule
+ {\strut\inleft{\dodrawmarginrule}}
+
+%D \macros
+%D {marginrule}
+%D
+%D The first method gobbles words and simply puts a bar in the
+%D margin. This method is not entirely robust.
+%D
+%D \showsetup{marginrule}
+
+\definecomplexorsimple\marginrule
+
+\def\simplemarginrule
+ {\let\processword\drawmarginrule
+ \processwords}
+
+\def\complexmarginrule[#1]%
+ {\ifnum#1<\@@kalevel\relax \else
+ \def\@@kadefaultwidth{#1}%
+ \expandafter\simplemarginrule
+ \fi}
+
+%D We need an auxiliary variable
+
+\def\@@kadefaultwidth{1}
+
+%D \macros
+%D {setupmarginrules}
+%D
+%D This macro definitions show us that we can pass an optional
+%D level, which is matched against the previous set one. The
+%D level can be set up with
+%D
+%D \showsetup{setupmarginrules}
+
+\unexpanded\def\setupmarginrules
+ {\dodoubleargument\getparameters[\??ka]}
+
+%D \macros
+%D {startmarginrule}
+%D
+%D The second method collects text and reformats it afterwards,
+%D using the shapebox macros. We prevent local margin rules.
+%D
+%D \showsetup{startmarginrule}
+
+\definecomplexorsimple\startmarginrule
+
+\def\simplestartmarginrule
+ {\bgroup
+ \let\drawmarginrule\relax
+ \let\stopmarginrule\dostopmarginrule
+ \beginofshapebox}
+
+\def\complexstartmarginrule[#1]%
+ {\bgroup
+ \let\drawmarginrule\relax
+ \ifnum#1<\@@kalevel\relax
+ \let\stopmarginrule\egroup
+ \else
+ \def\@@kadefaultwidth{#1}%
+ \let\stopmarginrule\dostopmarginrule
+ \expandafter\beginofshapebox
+ \fi}
+
+\def\dostopmarginrule
+ {\endofshapebox
+ \reshapebox
+ {\hbox{\inleftmargin{\dodrawmarginrule}\box\shapebox}}%
+ \flushshapebox
+ \egroup}
+
+%D \startbuffer
+%D \setupmarginrules[level=5]
+%D
+%D \startmarginrule[1]
+%D First we set the level at~5. Next we typeset this first
+%D paragraph as a level~1 one. As expected no rule show up.
+%D \stopmarginrule
+%D
+%D \startmarginrule[5]
+%D The second paragraph is a level~5 one. As we can see here,
+%D the marginal rule gets a width according to its level.
+%D \stopmarginrule
+%D
+%D \startmarginrule[8]
+%D It will of course be no surprise that this third paragraph
+%D has a even thicker margin rule. This behavior can be
+%D overruled by specifying the width explictly.
+%D \stopmarginrule
+%D \stopbuffer
+%D
+%D In next example we show most features. Watch the rule
+%D thickness adapting itself to the level.
+%D
+%D \startexample
+%D \getbuffer
+%D \stopexample
+%D
+%D We just said:
+%D
+%D \typebuffer
+
+%D \macros
+%D {vl, hl}
+%D
+%D The command \type{\vl} draws a vertical rule \vl\ with strut
+%D dimensions, multiplied with the factor specified in the
+%D optional argument. The height and depth are clipped \vl[3]
+%D to the baselinedistance. Its horizontal counterpart
+%D \type{\hl} draws a horizontal rule \hl\ with a width of 1em,
+%D multiplied with the optional factor. The horizontal rule is
+%D drawn on top of the baseline.
+%D
+%D \showsetup{vl}
+%D \showsetup{hl}
+
+\def\dovlwdhtdp#1#2#3%
+ {\bgroup
+ \setbox\scratchbox\hbox
+ {\vrule
+ \!!width #1\linewidth
+ \!!height#2\strutht
+ \!!depth #3\strutdp}%
+ \dp\scratchbox\strutdp
+ \ht\scratchbox\strutht
+ \box\scratchbox
+ \egroup}
+
+\def\complexvl[#1]%
+ {\dovlwdhtdp\plusone{#1}{#1}}
+
+\def\complexhl[#1]%
+ {\hbox
+ {\vrule
+ \!!width #1\s!em
+ \!!height\linewidth
+ \!!depth \zeropoint}}
+
+\definecomplexorsimple\vl \def\simplevl{\complexvl[1]}
+\definecomplexorsimple\hl \def\simplehl{\complexhl[1]}
+
+%D \macros
+%D {hairline, thinrule, thinrules, setupthinrules}
+%D
+%D Drawing thin lines can of course easily be accomplished by
+%D the \TEX\ primitives \type{\hrule} and \type{\vrule}. The
+%D next few macros however free us from some specifications.
+%D
+%D \startbuffer
+%D some text
+%D
+%D \hairline
+%D
+%D some more text
+%D
+%D \thinrule
+%D
+%D more and more text
+%D
+%D hi \thinrule\ there
+%D
+%D and then the final text
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D becomes
+%D
+%D \startexample
+%D \getbuffer
+%D \stopexample
+%D
+%D So we've got
+%D
+%D \showsetup{hairline}
+%D \showsetup{thinrule}
+%D
+%D Both can be set up with:
+%D
+%D \showsetup{setupthinrules}
+%D
+%D We also have
+%D
+%D \showsetup{thinrules}
+%D
+%D which looks like: \thinrules[n=2]
+
+\newconstant\ruletype
+
+\def\thinrule
+ {\strut
+ \bgroup
+ \ruletype\plusone
+ \processaction
+ [\@@dlalternative]
+ [ \v!a=>\ruletype\zerocount,% no line
+ %\v!b=>\ruletype\plusone ,% height/depth
+ \v!c=>\ruletype\plustwo ,% topheight/botdepth
+ % 11=>\ruletype\plusone ,% fallback for backgrounds
+ 0=>\ruletype\zerocount,% compatible with backgrounds
+ % 1=>\ruletype\plusone ,% compatible with backgrounds
+ 2=>\ruletype\plustwo ]% compatible with backgrounds
+ \doifsomething\@@dlrulethickness
+ {\linewidth\@@dlrulethickness}%
+ \ifdim\linewidth=\zeropoint
+ \ruletype\zerocount
+ \else
+ \doifnot\@@dlframe\v!on{\ruletype\zerocount}%
+ \fi
+ \ifnum\ruletype=\plusone
+ \doif\@@dlheight\v!max{\let\@@dlheight\!!plusone}%
+ \doif\@@dldepth \v!max{\let\@@dldepth \!!plusone}%
+ \else
+ \let\@@dlheight\!!plusone
+ \let\@@dldepth\!!plusone
+ \fi
+ \freezedimensionwithunit\@@dlheight\strutht
+ \freezedimensionwithunit\@@dldepth\strutdp
+ \divide\linewidth \plustwo
+ \doifelse\@@dlbackground\v!color
+ {\startcolor[\@@dlbackgroundcolor]%
+ \ifnum\ruletype=\plustwo % prevent overshoot due to rounding
+ \leaders
+ \hrule
+ \!!height\dimexpr\@@dlheight-.5\linewidth\relax
+ \!!depth \dimexpr\@@dldepth -.5\linewidth\relax
+ \hfill
+ \else
+ \leaders
+ \hrule
+ \!!height\@@dlheight
+ \!!depth \@@dldepth
+ \hfill
+ \fi
+ \stopcolor
+ \ifcase\ruletype
+ % no rule
+ \or
+ \startcolor[\@@dlcolor]%
+ \hfillneg
+ \leaders\hrule\!!height\linewidth\!!depth\linewidth\hfill
+ \stopcolor
+ \or
+ \startcolor[\@@dlcolor]%
+ \hfillneg\leaders\hrule\!!height\dimexpr-\@@dldepth+\linewidth\relax\!!depth\@@dldepth\hfill
+ \hfillneg\leaders\hrule\!!height\@@dlheight\!!depth\dimexpr-\@@dlheight+\linewidth\relax\hfill
+ \stopcolor
+ \fi}
+ {\ifcase\ruletype \else
+ \startcolor[\@@dlcolor]%
+ \leaders\hrule\!!height\@@dlheight\!!depth\@@dldepth\hfill
+ \stopcolor
+ \fi}%
+ \strut
+ \carryoverpar\egroup}
+
+\def\hairline
+ {\endgraf
+ \thinrule
+ \endgraf}
+
+\def\dosetupthinrules[#1]%
+ {\getparameters[\??dl][#1]}
+
+\unexpanded\def\setupthinrules
+ {\dosingleargument\dosetupthinrules}
+
+\def\dothinrules[#1]%
+ {\bgroup
+ \dosetupthinrules[#1]%
+ \@@dlbefore
+ \assignvalue\@@dlinterlinespace\@@dlinterlinespace{1.0}{1.5}{2.0}%
+ \spacing\@@dlinterlinespace
+ \dorecurse\@@dln
+ {\ifnum\recurselevel=\@@dln \dothinrulesnobreak \else
+ \ifnum\recurselevel=2 \dothinrulesnobreak \fi\fi
+ \thinrule
+ \ifnum\recurselevel<\@@dln\relax
+ % test needed, else messed up whitespace
+ \ifx\@@dlinbetween\empty
+ \softbreak
+ \else
+ \endgraf
+ \nowhitespace
+ \@@dlinbetween
+ \fi
+ \fi}%
+ \doifelsenothing\@@dlafter
+ {\carryoverpar\egroup}
+ {\@@dlafter\egroup}}
+
+\def\thinrules
+ {\dosingleempty\dothinrules}
+
+%D A couple of examples are given below.
+%D
+%D \startbuffer
+%D \setupthinrules[n=3,inbetween=,color=gray]
+%D
+%D test test \thinrules\ test test \par
+%D test test \thinrules [color=green] test test \par
+%D test test \thinrules [height=max, depth=max] test test \par
+%D
+%D \setupthinrules[height=.9,depth=.9]
+%D
+%D test test \thinrules\ test test \par
+%D test test \thinrules [alternativevariant=b] test test \par
+%D test test \thinrules [alternativevariant=c] test test \par
+%D test test \thinrules [alternativevariant=c,inbetween=\vskip2ex] test test \par
+%D \stopbuffer
+%D
+%D \typebuffer {\getbuffer}
+%D
+%D There are a couple of alternative ways to visualize rules
+%D using backgrounds. At first sight these may look strange,
+%D but they make sense in educational settings. The
+%D alternatives are more or less compatible with the more
+%D advanced \METAPOST\ based implementation.
+%D
+%D \startbuffer[a]
+%D \setupthinrules
+%D [n=2,
+%D backgroundcolor=gray ,
+%D rulethickness=1pt,
+%D colorkleur=donkerblauw,
+%D after=\blank,
+%D before=\blank]
+%D \stopbuffer
+%D
+%D \typebuffer[a]
+%D
+%D \startbuffer[b]
+%D \thinrules[alternativevariant=a]
+%D \thinrules[alternativevariant=b]
+%D \thinrules[alternativevariant=c]
+%D \stopbuffer
+%D
+%D \typebuffer[b] \getbuffer[a,b]
+%D
+%D \startbuffer[b]
+%D \thinrules[alternativevariant=a,background=color]
+%D \thinrules[alternativevariant=b,background=color]
+%D \thinrules[alternativevariant=c,background=color]
+%D \stopbuffer
+%D
+%D \typebuffer[b] \getbuffer[a,b]
+%D
+%D \startbuffer[b]
+%D \thinrules[alternativevariant=a,height=.8,depth=.8,background=color]
+%D \thinrules[alternativevariant=b,height=.8,depth=.8,background=color]
+%D \thinrules[alternativevariant=c,height=.8,depth=.8,background=color]
+%D \stopbuffer
+%D
+%D \typebuffer[b] \getbuffer[a,b]
+
+%D \macros
+%D {optimizethinrules}
+%D
+%D By saying \type {\thinrulestrue} or \type {-false}, we
+%D can influence the way dangling lines are handled.
+
+\newif\ifoptimizethinrules \optimizethinrulestrue
+
+\def\dothinrulesnobreak
+ {\ifoptimizethinrules\penalty500\fi}
+
+%D \macros
+%D {textrule, starttextrule, setuptextrules}
+%D
+%D Putting rules before and after a paragraph is very space
+%D sensitive, but the next command handles that quite well. It
+%D comes in two disguises:
+%D
+%D \startbuffer
+%D \textrule[top]{fragments}
+%D \input reich
+%D \textrule
+%D \stopbuffer
+%D
+%D \start \typebuffer \getbuffer \stop
+%D
+%D \startbuffer
+%D \setuptextrules
+%D [width=90pt,distance=12pt,rulecolor=blue,
+%D bodyfont=small,style=\sc,color=red]
+%D
+%D \starttextrule{Ship Building Tools}
+%D \nl \setuptolerance[tolerant] \input materie
+%D \stoptextrule
+%D \stopbuffer
+%D
+%D \bgroup \typebuffer \getbuffer \egroup
+%D
+%D \startbuffer
+%D \setuptextrules
+%D [location=inmargin,
+%D bodyfont=small,style=slantedbold]
+%D
+%D \starttextrule{wonderful}
+%D \input tufte
+%D \stoptextrule
+%D \stopbuffer
+%D
+%D \bgroup \typebuffer \getbuffer \egroup
+%D
+%D The formal definition of these commands is:
+%D
+%D \showsetup{textrule}
+%D \showsetup{starttextrule}
+%D \showsetup{setuptextrules}
+%D
+%D The implementation looks a bit complicated due to the
+%D optional arguments.
+
+\unexpanded\def\setuptextrules
+ {\dodoubleargument\getparameters[\??tl]}
+
+\def\complextextrule[#1]% if needed we can make it installable
+ {\let\next\dobottomtextrule
+ \processaction
+ [#1]
+ [ \v!top=>\let\next\dotoptextrule,
+ \v!middle=>\let\next\domiddletextrule,
+ \v!bottom=>\let\next\dobottomtextrule]%
+ \dosinglegroupempty\next}
+
+\definecomplexorsimple\textrule
+
+\def\simpletextrule
+ {\dosinglegroupempty\dounknowntextrule}
+
+\def\docomplextextrule#1%
+ {\bgroup
+ \advance\hsize\dimexpr-\rightskip-\leftskip\relax
+ \setbox\scratchbox\hbox to \hsize
+ {\dimen4\dimexpr .5ex+.5\linewidth\relax
+ \dimen6\dimexpr-.5ex+.5\linewidth\relax
+ \doifsomething{#1}
+ {\doifelse\@@tllocation\v!inmargin
+ {\llap
+ {\dousestyleparameter\@tlstyle
+ \dousecolorparameter\@tlcolor
+ #1%
+ \hskip\leftmargindistance}}
+ {\color[\@@tlrulecolor]
+ {\vrule\!!height\dimen4\!!depth\dimen6\!!width\@@tlwidth}%
+ \hbox spread 2\dimexpr\@@tldistance\relax
+ {\hss
+ \dousestyleparameter\@tlstyle
+ \dousecolorparameter\@tlcolor
+ \strut#1%
+ \hss}}}%
+ \color[\@@tlrulecolor]
+ {\leaders\hrule\!!height\dimen4\!!depth\dimen6\hfill}}%
+ \ht\scratchbox\strutht
+ \dp\scratchbox\strutdp
+ \noindent\box\scratchbox
+%\nobreak\verticalstrut\kern-\struttotal
+% evt \witruimte
+ \egroup}
+
+\def\dotoptextrule#1%
+ {\page[\v!preference] % interferes
+ %\whitespace % no
+ \@@tlbefore
+ \docomplextextrule{#1}%
+% todo, option: \doifnothing{#1}{\ruledvskip-.5ex}
+ \nowhitespace
+ \@@tlinbetween
+ \endgraf}
+
+\def\dodobottomtextrule#1#2%
+ {\ifhmode
+ \endgraf
+ \fi
+ \dimen0\strutdp
+ \ifdim\prevdepth>\strutdp\else % was <\strutdp
+ \ifdim\prevdepth>\zeropoint
+ \advance\dimen0 -\prevdepth
+ \fi
+ \fi
+ \advance\dimen0 .5ex
+ \vskip\dimen0
+% ==
+% \vskip\dimexpr \strutdp + .5ex
+% \ifdim\prevdepth>\strutdp\else\ifdim\prevdepth>\zeropoint-\prevdepth\fi\fi\relax
+%
+ \@@tlinbetween
+ \doifelsenothing{#2}
+ {\bgroup
+ \advance\hsize\dimexpr-\rightskip-\leftskip\relax
+ \nointerlineskip
+ \moveleft-\leftskip\vbox
+ {\color[\@@tlrulecolor]
+ {\hrule\!!depth\linewidth\!!height\zeropoint\!!width\hsize}}%
+ \egroup}
+ {\docomplextextrule{#2}}%
+ \ifvmode\prevdepth\zeropoint\fi
+ #1%
+ \page[\v!preference]}
+
+\def\dobottomtextrule
+ {\dodobottomtextrule\@@tlafter}
+
+\def\domiddletextrule
+ {\dodobottomtextrule\@@tlinbetween}
+
+\def\dounknowntextrule
+ {\iffirstargument
+ \@EA\dotoptextrule
+ \else
+ \@EA\dobottomtextrule\@EA\empty
+ \fi}
+
+%D The grouped commands also supports bodyfont switching:
+
+\unexpanded\def\starttextrule#1%
+ {\bgroup
+ \def\dounknowntextrule{\domiddletextrule}
+ \dotoptextrule{#1}
+ \bgroup
+ \doifsomething\@@tlbodyfont{\switchtobodyfont[\@@tlbodyfont]}}
+
+\unexpanded\def\stoptextrule
+ {\par
+ \egroup
+ \dobottomtextrule\empty
+ \egroup}
+
+%D \macros
+%D {fillinrules, setupfillinrules}
+%D
+%D The next few commands do not really deserve a place in a
+%D core module, because they deal with specific typography.
+%D Nevertheless I decided to make them part of the core,
+%D because they permit us to make questionaires. Let's start
+%D with some examples.
+%D
+%D \fillinrules[n=2,width=fit]{first}
+%D \fillinrules[n=2,width=broad]{first}
+%D \fillinrules[n=2,width=3cm]{first}
+%D \fillinrules[n=2,width=3cm,distance=.5em,separator=:]{first}
+%D \fillinrules[n=2]{first}{last}
+%D \fillintext{first}{last} \input reich \par
+%D
+%D The main command is \type{\fillinrules}. This command takes
+%D one and an optional second argument and sets a paragraph with
+%D empty visualized lines.
+%D
+%D \showsetup{fillinrules}
+%D \showsetup{setupfillinrules}
+
+\unexpanded\def\setupfillinrules
+ {\dodoubleargument\getparameters[\??il]}
+
+\definecomplexorsimpleempty\fillinrules
+
+\def\complexfillinrules[#1]%
+ {\def\docomplexfillinrules##1##2%
+ {\dodocomplexfillinrules[#1]{##1}{##2}{\thinrules
+ [\c!n=\@@iln,\c!interlinespace=\@@ilinterlinespace,\c!before=,\c!after=]}}%
+ \dodoublegroupempty\docomplexfillinrules}
+
+\def\dodocomplexfillinrules[#1]#2#3#4%
+ {\endgraf
+ \@@ilbefore
+ \begingroup
+ \setupfillinrules[#1]%
+ \noindent
+ \doifsomething{#2}
+ {\doifelse\@@ilwidth\v!fit
+ {\let\@@ildistance\!!zeropoint
+ \hbox}
+ {\doifelse\@@ilwidth\v!broad
+ {\hbox}
+ {\hbox to \@@ilwidth}}%
+ \bgroup
+ \dousestyleparameter\@@ilstyle
+ \dousecolorparameter\@@ilcolor
+ \strut#2\hfill\@@ilseparator\hskip\@@ildistance
+ \egroup}%
+ %\hangindent=\wd0\relax % tzt hang=yes,n
+ %\parindent=\hangindent
+ %\box0\relax
+ \setupwhitespace[\v!big]%
+ \ignorespaces
+ #4%
+ \doifsomething{#3}
+ {\kern\@@ildistance
+ \dousestyleparameter\@@ilstyle
+ \dousecolorparameter\@@ilcolor
+ #3\strut}%
+ \endgroup
+ \endgraf
+ \@@ilafter}
+
+%D \macros
+%D {fillintext}
+%D
+%D To provide compatible layouts when texts and lines are
+%D mixed, one can typeset a paragraph by using the command
+%D \type{\fillintext}.
+%D
+%D \showsetup{fillintext}
+
+\definecomplexorsimpleempty\fillintext
+
+\def\complexfillintext[#1]% rather rough, using an \unhbox is suboptimal
+ {\def\docomplexfillintext##1##2%
+ {\dowithnextbox
+ {\dodocomplexfillinrules[#1]{##1}{\hfill##2}{\unhbox\nextbox\unskip}}%
+ \hbox\bgroup\let\par\egroup\ignorespaces}%
+ \dodoublegroupempty\docomplexfillintext}
+
+%D \macros
+%D {fillinline, setupfillinlines}
+%D
+%D Another member of the family takes care of putting a (often
+%D small) rule after a piece of text, like
+%D
+%D \startbuffer
+%D \fillinline \input reich \par
+%D \fillinline[margin=0cm] \input reich \par
+%D \stopbuffer
+%D
+%D \startexample
+%D \getbuffer
+%D \stopexample
+%D
+%D which was typeset by saying:
+%D
+%D \typebuffer
+%D
+%D The two commands that take care of this are:
+%D
+%D \showsetup{fillinline}
+%D \showsetup{setupfillinlines}
+
+\unexpanded\def\setupfillinlines
+ {\dodoubleargument\getparameters[\??iv]}
+
+\definecomplexorsimpleempty\fillinline
+
+\def\complexfillinline[#1]%
+ {%\endgraf % interferes with \definedescription cum suis
+ \@@ivbefore
+ \begingroup
+ \setupfillinlines[#1]%
+ \advance\rightskip \@@ivmargin
+ \parfillskip\zeropoint
+ \def\par % very dangerous
+ {\let\par\endgraf % -)
+ \ifhmode\unskip\hfill\fi
+ \scratchdimen\dimexpr\@@ivwidth-\@@ivdistance\relax
+ \ifdim\scratchdimen>\@@ivmargin\else\expandafter\rlap\fi
+ {\kern\@@ivdistance
+ \vrule
+ \!!width \scratchdimen
+ \!!height.5\linewidth
+ \!!depth .5\linewidth}%
+ \endgraf % !
+ \endgroup
+ \endgraf % !
+ \@@ilafter}}
+
+%D Will move up:
+
+
+\setupblackrules
+ [\c!n=3,
+ \c!width=1em,
+ \c!height=1ex,
+ \c!depth=\!!zeropoint,
+ \c!alternative=\c!a,
+ \c!distance=.25ex,
+ \c!color=]
+
+\setupmarginrules
+ [\c!level=0,
+ \c!rulethickness=\@@kadefaultwidth\linewidth]
+
+\setupthinrules
+ [\c!interlinespace=\v!small,
+ \c!n=3,
+ \c!before=,
+ \c!inbetween={\blank[\v!white]},
+ \c!after=,
+ \c!color=,
+ \c!height=.5\linewidth,
+ \c!depth=.5\linewidth,
+ \c!frame=\v!on, % compatible with textbackgrounds
+ \c!alternative=\v!b,
+ \c!backgroundcolor=,
+ \c!background=,
+ \c!rulethickness=]
+
+\setuptextrules
+ [\c!location=\v!left,
+ \c!before=\blank,
+ \c!after=\blank,
+ \c!inbetween=,
+ \c!width=2em,
+ \c!style=\v!bold,
+ \c!color=,
+ \c!rulecolor=,
+ \c!bodyfont=,
+ \c!distance=.5em]
+
+\setupfillinrules
+ [\c!width=\v!broad,
+ \c!distance=1em,
+ \c!before=\blank,
+ \c!after=\blank,
+ \c!n=1,
+ \c!interlinespace=\v!small,
+ \c!separator=,
+ \c!style=\v!normal,
+ \c!color=]
+
+\setupfillinlines
+ [\c!width=3cm,
+ \c!margin=\@@ivwidth,
+ \c!distance=1em,
+ \c!before=\blank,
+ \c!after=\blank]
+
+\protect \endinput
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index a7af6b50c..e7620b43e 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -13,31 +13,19 @@
\writestatus{loading}{ConTeXt Packaging Macros / Ruled Content}
-% eventually this will use the commandhandler code (same trick as with itemize)
-% rulethickness push/pop will go
+%D The code here is expanded lots of time as framed is used in
+%D many places. This is why the code here is (and gets) optimized
+%D as much as possible. Also, by avoiding packaging and expansion
+%D we also keep tracing reasonable. For instance, multiple stacked
+%D backgrounds can slow down a run if not optimized this way.
-%D redo framedtexts like framedcontent (parameter stuff)
-
-%D After a few months testing this solution is now added
-%D to the core. This introduces a possible incompatibility
-%D between \MKII\ and \MKIV\ but for the better.
+% eventually this will use the commandhandler code (same trick as
+% with itemize)
\registerctxluafile{pack-rul}{1.001}
-% old off new
-% 4 lines oeps : 3.6 2.8 3.0
-% tufte 7.5 4.1 4.3
-
\unprotect
-%D We have removed the rather old and out dated raster methods. They
-%D have not been used for ages. You can still find the old code in
-%D the \MKII\ counterpart of this module.
-
-%D This module is rather optimized so sometimes readability has been
-%D sacrisfied for speed. This is because the framing mechanism is used
-%D all over the place.
-
%D \macros
%D {linewidth, setuplinewidth}
%D
@@ -53,99 +41,260 @@
\newdimen\linewidth
-\def\dosetuplinewidth[#1]%
- {\assigndimension{#1}\linewidth{.2\points}{.4\points}{.6\points}}
-
\unexpanded\def\setuplinewidth
- {\dosingleargument\dosetuplinewidth}
+ {\dosingleargument\framed_setup_line_width}
-%D \macros
-%D {ruledlinewidth, inheritruledlinewidth}
-%D
-%D Inside framed boxed we will use a private dimensions. As
-%D an option one can let the linewidth inherit its value from
-%D this one.
-
-\newdimen\ruledlinewidth \newif\ifinheritruledlinewidth
+\def\framed_setup_line_width[#1]%
+ {\assigndimension{#1}\linewidth{.2\points}{.4\points}{.6\points}}
%D \macros
%D {setupscreens}
%D
-%D The previous macro uses a predefined constant
-%D \type{\@@rsfactor}. This factor can be set by:
+%D Sort of obsolete:
%D
%D \showsetup{setupscreens}
\unexpanded\def\setupscreens
{\dodoubleargument\getparameters[\??rs]}
-%D We will communicate through module specific variables, current
-%D framed parameters and some reserved dimension registers.
+%D The parameter handler:
-\newdimen \frameddimenwd
-\newdimen \frameddimenht
-\newdimen \frameddimendp
+\let\currentframed\s!unknown % brrr must have a value
-%D We don't have to stick to a \TEX\ drawn rule, but
-%D also can use rounded or even fancier shapes, as we will
-%D see later on.
+% \def\framedparameter #1{\csname\doframedparameter\currentframed{#1}\endcsname}
+% \def\framedparameterhash#1{\doframedparameterhash \currentframed#1}
-\def\dofilledbox
- {\bgroup
- \edef\@@framedfilledmod{\framedparameter\c!backgroundcorner}%
- \ifx\@@framedfilledmod\v!rectangular
- \dofilledlinedbox
- \else\ifzeropt\dimexpr\framedparameter\c!backgroundradius\relax % just in case of .x\bodyfontsize
- \dofilledlinedbox
- \else
- \dofilledroundbox
- \fi\fi
- \egroup}
+\def\framedparameter #1{\csname\ifcsname\currentframed#1\endcsname\currentframed#1\else\expandafter\doframedparentparameter\csname\currentframed\s!parent\endcsname{#1}\fi\endcsname}
+\def\framedparameterhash#1{\ifcsname\currentframed#1\endcsname\currentframed\else\expandafter\doframedparentparameterhash\csname\currentframed\s!parent\endcsname#1\fi}
-\def\dophantombox
- {\hphantom{\dofilledbox}}
+\def\doframedparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\doframedparentparameter \csname#1\s!parent\endcsname{#2}\fi}
+\def\doframedparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\doframedparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-\def\dofilledlinedbox
- {\vrule\!!width\frameddimenwd\!!height\frameddimenht\!!depth\frameddimendp\relax}%
+\def\doframedparentparameter #1#2{\ifx#1\relax\s!empty\else\doframedparameter #1{#2}\fi}
+\def\doframedparentparameterhash#1#2{\ifx#1\relax \else\doframedparameterhash#1#2\fi}
-\def\dostrokedroundbox
- {\doif{\framedparameter\c!frame}\v!on\dodostrokedroundbox}
+\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\dodostrokedroundbox
- {\bgroup
- \edef\ovalmod{\framedparameter\c!framecorner}%
- \ifx\ovalmod\v!round
- \let\ovalmod\!!zerocount
+\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}
+
+% \unexpanded\def\installsomebackground#1#2{\inheritlocalframed[\??ma#1#2][\??od]}
+
+\let\normalframedparameter \framedparameter
+\let\normalframedparameterhash\framedparameterhash
+
+\def\framed_initialize#1% will be inlined
+ {\inframedtrue
+ \edef\currentframed{#1}%
+ \let\framedparameter \normalframedparameter
+ \let\framedparameterhash\normalframedparameterhash}
+
+\def\installinheritedframed#1%
+ {\normalexpanded{\doinstallinheritedframed
+ \expandafter\noexpand\csname current#1\endcsname
+ \expandafter\noexpand\csname #1parameter\endcsname
+ \expandafter\noexpand\csname #1parameterhash\endcsname
+ \expandafter\noexpand\csname do#1parameter\endcsname
+ \expandafter\noexpand\csname do#1parentparameter\endcsname
+ \expandafter\noexpand\csname do#1rootparameter\endcsname
+ \expandafter\noexpand\csname inherited#1framed\endcsname
+ \noexpand\??oi}} % if needed we can have a variant
+
+\unexpanded\def\doinstallinheritedframed#1#2#3#4#5#6#7#8%
+ {\def#5##1##2{\ifx##1\relax#6{##2}\else#4##1{##2}\fi}%
+ \def#6##1{\ifcsname#8##1\endcsname#8##1\else\s!empty\fi}%
+ \unexpanded\def#7%
+ {\bgroup
+ \bgroup
+ \inframedtrue
+ \let\currentframed #1% not used (more for tracing)
+ \let\framedparameter #2%
+ \let\framedparameterhash#3%
+ \framed_process_indeed}}
+
+\unexpanded\def\installframedcommandhandler#1#2#3%
+ {\installcommandhandler{#1}{#2}{#3}%
+ \installinheritedframed{#2}}
+
+\unexpanded\def\installframedautocommandhandler#1#2#3%
+ {\installautocommandhandler{#1}{#2}{#3}%
+ \installinheritedframed{#2}}
+
+\unexpanded\def\installsimpleframedcommandhandler#1#2#3%
+ {\installsimplecommandhandler{#1}{#2}{#3}%
+ \installinheritedframed{#2}}
+
+% for regular framed
+
+\getparameters
+ [\??oi]
+ [\c!width=\v!fit,
+ \c!height=\v!broad,
+ %\c!lines=,
+ \c!offset=0.25ex, % \defaultframeoffset
+ \c!empty=\v!no,
+ \c!frame=\v!on,
+ %\c!topframe=,
+ %\c!bottomframe=,
+ %\c!leftframe=,
+ %\c!rightframe=,
+ \c!radius=.5\bodyfontsize,
+ \c!rulethickness=\linewidth,
+ \c!corner=\v!rectangular,
+ \c!depth=\zeropoint,
+ %\c!foregroundcolor=,
+ %\c!foregroundstyle=,
+ %\c!background=,
+ %\c!backgroundscreen=,
+ %\c!backgroundcolor=,
+ \c!backgroundoffset=\zeropoint,
+ %\c!framecolor=,
+ \c!frameoffset=\zeropoint,
+ \c!backgroundcorner=\framedparameter\c!corner,
+ \c!backgroundradius=\framedparameter\c!radius,
+ \c!backgrounddepth=\framedparameter\c!depth,
+ \c!framecorner=\framedparameter\c!corner,
+ \c!frameradius=\framedparameter\c!radius,
+ \c!framedepth=\framedparameter\c!depth,
+ %\c!component=,
+ %\c!align=,
+ \c!bottom=\vss,
+ %\c!top=,
+ \c!strut=\v!yes,
+ \c!autostrut=\v!yes,
+ \c!location=\v!normal,
+ %\c!orientation=,
+ \c!autowidth=\v!yes,
+ %\c!setups=
+]
+
+% for backgrounds
+
+\getparameters
+ [\??od] % for fast version
+ [\c!frame=\v!off,
+ \c!depth=\zeropoint,
+ \c!offset=\v!overlay,
+ %\c!component=,
+ \c!radius=.5\bodyfontsize,
+ \c!rulethickness=\linewidth,
+ \c!corner=\v!rectangular,
+ \c!backgroundoffset=\zeropoint,
+ \c!frameoffset=\zeropoint,
+ \c!backgroundcorner=\framedparameter\c!corner,
+ \c!backgroundradius=\framedparameter\c!radius,
+ \c!backgrounddepth=\framedparameter\c!depth,
+ \c!framecorner=\framedparameter\c!corner,
+ \c!frameradius=\framedparameter\c!radius,
+ \c!framedepth=\framedparameter\c!depth,
+ \c!location=\v!normal]
+
+%D We will communicate through module specific variables, current
+%D framed parameters and some reserved dimension registers.
+
+\newdimen\d_framed_target_wd
+\newdimen\d_framed_target_ht
+\newdimen\d_framed_target_dp
+\newdimen\d_framed_linewidth
+
+\let\p_framed_frame \empty % \framedparameter\c!frame
+\let\p_framed_backgroundoffset\empty
+\let\p_framed_foregroundstyle \empty
+\let\p_framed_autostrut \empty
+\let\p_framed_location \empty
+\let\p_framed_orientation \empty
+\let\p_framed_autowidth \empty
+\let\p_framed_franalyze \empty
+\let\p_framed_backgroundcorner\empty
+\let\p_framed_backgroundradius\empty
+\let\p_framed_framecorner \empty
+\let\p_framed_frameradius \empty
+\let\p_framed_lines \empty
+\let\p_framed_empty \empty
+\let\p_framed_backgroundcolor \empty
+\let\p_framed_backgroundscreen\empty
+\let\p_framed_framecolor \empty
+\let\p_framed_component \empty
+\let\p_framed_background \empty
+\let\p_framed_rulethickness \empty
+\let\p_framed_foregroundcolor \empty
+\let\p_framed_setups \empty
+
+%D We don't have to stick to a \TEX\ drawn rule, but also can use rounded
+%D or even fancier shapes, as we will see later on.
+
+\def\framed_filled_box
+ {\edef\p_framed_backgroundcorner{\framedparameter\c!backgroundcorner}%
+ \ifx\p_framed_backgroundcorner\v!rectangular
+ \framed_filled_box_normal
\else
- \edef\ovalmod{\number\ovalmod}%
- \fi
- \edef\ovalwid{\the\frameddimenwd}%
- \edef\ovalhei{\the\frameddimenht}%
- \edef\ovaldep{\the\frameddimendp}%
- \edef\ovallin{\the\dimexpr\ruledlinewidth}%
- \edef\ovalrad{\the\dimexpr\framedparameter\c!frameradius}%
- \let\ovalstr\!!plusone
- \let\ovalfil\!!zerocount
- \doovalbox\ovalwid\ovalhei\ovaldep\ovallin\ovalrad\ovalstr\ovalfil\ovalmod
- \egroup}
+ \framed_filled_box_radius
+ \fi}
-\def\dofilledroundbox
- {\bgroup
- \edef\ovalmod{\framedparameter\c!backgroundcorner}%
- \ifx\ovalmod\v!round
- \let\ovalmod\!!zerocount
+\def\framed_filled_box_normal
+ {\vrule
+ \!!width \d_framed_target_wd
+ \!!height\d_framed_target_ht
+ \!!depth \d_framed_target_dp
+ \relax}
+
+\def\framed_filled_box_radius
+ {\edef\p_framed_backgroundradius{\framedparameter\c!backgroundradius}%
+ \ifzeropt\dimexpr\p_framed_backgroundradius\relax % just in case of .x\bodyfontsize
+ \framed_filled_box_normal
\else
- \edef\ovalmod{\number\ovalmod}%
- \fi
- \edef\ovalwid{\the\frameddimenwd}%
- \edef\ovalhei{\the\frameddimenht}%
- \edef\ovaldep{\the\frameddimendp}%
- \edef\ovallin{\the\dimexpr\ruledlinewidth\relax}%
- \edef\ovalrad{\the\dimexpr\framedparameter\c!backgroundradius\relax}%
- \let\ovalstr\!!zerocount
- \let\ovalfil\!!plusone
- \doovalbox\ovalwid\ovalhei\ovaldep\ovallin\ovalrad\ovalstr\ovalfil\ovalmod
- \egroup}
+ \framed_filled_box_round
+ \fi}
+
+\def\framed_filled_box_round
+ {\normalexpanded{\doovalbox
+ {\the\d_framed_target_wd}%
+ {\the\d_framed_target_ht}%
+ {\the\d_framed_target_dp}%
+ {\the\dimexpr\d_framed_linewidth\relax}%
+ {\the\dimexpr\p_framed_backgroundradius\relax}%
+ {0}%
+ {1}%
+ {\ifx\p_framed_backgroundcorner\v!round0\else\number\p_framed_backgroundcorner\fi}%
+ }}
+
+\def\framed_stroked_box
+ {\edef\p_framed_framecorner{\framedparameter\c!framecorner}%
+ \ifx\p_framed_framecorner\v!rectangular
+ \framed_stroked_box_normal
+ \else
+ \framed_stroked_box_radius
+ \fi}
+
+\def\framed_stroked_box_radius
+ {\edef\p_framed_frameradius{\framedparameter\c!frameradius}%
+ \ifzeropt\dimexpr\p_framed_frameradius\relax % just in case of .x\bodyfontsize
+ \framed_stroked_box_normal
+ \else
+ \ifx\p_framed_frame\v!on
+ \framed_stroked_box_round
+ \fi
+ \fi}
+
+% \framed_stroked_box_normal % later
+
+\def\framed_stroked_box_round
+ {\normalexpanded{\doovalbox
+ {\the\d_framed_target_wd}%
+ {\the\d_framed_target_ht}%
+ {\the\d_framed_target_dp}%
+ {\the\dimexpr\d_framed_linewidth\relax}%
+ {\the\dimexpr\p_framed_frameradius\relax}%
+ {1}%
+ {0}%
+ {\ifx\p_framed_framecorner\v!round0\else\number\p_framed_framecorner\fi}%
+ }}
% a lot of weird corners
%
@@ -196,30 +345,27 @@
%D The oval box is drawn using a special macro, depending on
%D the driver in use.
-\def\dograybox % avoid black rules when no gray
- {\doifelsenothing{\framedparameter\c!backgroundscreen}
- {\dophantombox}
- {\raster[\framedparameter\c!backgroundscreen]{\dofilledbox}}}
+\def\framed_background_box_gray % avoid black rules when no gray
+ {\edef\p_framed_backgroundscreen{\framedparameter\c!backgroundscreen}%
+ \ifx\p_framed_backgroundscreen\empty \else
+ \framed_background_box_gray_indeed
+ \fi}
+
+\def\framed_background_box_gray_indeed
+ {\raster[\p_framed_backgroundscreen]{\framed_filled_box}} % can be more direct but who cares
%D It won't be a surprise that we not only provide gray boxes,
%D but also colored ones. Here it is:
-\def\dobackgroundcolorbox
- {\hbox{\faststartcolor[\framedbackgroundcolor]\dofilledbox\faststopcolor}}
- %{\hbox{\doactivatecolor\framedbackgroundcolor\dofilledbox}}
-
-\def\docolorbox % can be more of \color[] -> \faststartcolor in mkiv
- {\ifincolor
- \edef\framedbackgroundcolor{\framedparameter\c!backgroundcolor}%
- \ifx\framedbackgroundcolor\empty
- \dophantombox
- \else
- \doifcolorelse\framedbackgroundcolor\dobackgroundcolorbox\dophantombox
- \fi
- \else
- \dophantombox
+\def\framed_background_box_color % can be more of \color[] -> \faststartcolor in mkiv
+ {\edef\p_framed_backgroundcolor{\framedparameter\c!backgroundcolor}%
+ \ifx\p_framed_backgroundcolor\empty \else
+ \doifcolor\p_framed_backgroundcolor\framed_background_box_color_indeed
\fi}
+\def\framed_background_box_color_indeed
+ {\hbox{\doactivatecolor\p_framed_backgroundcolor\framed_filled_box}}
+
%D \macros
%D {defineoverlay, doifoverlayelse, overlayoffset,
%D overlaywidth, overlayheight, overlaydepth,
@@ -280,11 +426,11 @@
\def\overlaywidth {\the\hsize\space} % We preset the variables
\def\overlayheight {\the\vsize\space} % to some reasonable default
-\let\overlaydepth \!!zeropoint % values. The attributes
-\let\overlayoffset \!!zeropoint % of the frame can be (are)
-\let\overlaycolor \empty % set somewhere else.
-\let\overlaylinewidth \!!zeropoint %
-\let\overlaylinecolor \empty %
+\def\overlaydepth {0pt } % values. The attributes
+\let\overlayoffset \overlaydepth % of the frame can be (are)
+\let\overlaylinewidth \overlaydepth % set somewhere else.
+\let\overlaycolor \empty
+\let\overlaylinecolor \empty
%D The next register is used to initialize overlays.
@@ -294,150 +440,176 @@
%D can contain text and be executed under an regime where
%D interlineskip is off).
-\appendtoks \oninterlineskip \to \everyoverlay
+\appendtoks
+ \oninterlineskip
+\to \everyoverlay
+
+\prependtoks
+ \hsize\overlaywidth
+ \vsize\overlayheight
+\to \everyoverlay
\unexpanded\def\defineoverlay
- {\dodoubleargument\dodefineoverlay}
+ {\dodoubleargument\framed_define_overlay}
-\def\dodefineoverlay[#1][#2]%
- {\def\docommand##1{\setvalue{\??ov##1}{\executedefinedoverlay{##1}{#2}}}%
- \processcommalist[#1]\docommand}
+\def\framed_define_overlay[#1][#2]%
+ {\def\framed_define_overlay_indeed##1{\setvalue{\??ov##1}{\executedefinedoverlay{##1}{#2}}}%
+ \processcommalist[#1]\framed_define_overlay_indeed}
-\prependtoks
- \hsize\overlaywidth
- \vsize\overlayheight
-\to\everyoverlay
-
-\long\def\executedefinedoverlay#1#2%
- {\bgroup
+\unexpanded\def\executedefinedoverlay#1#2% we can share the definitions
+ {\bgroup % redundant grouping
+ \setbox\scratchbox\hbox\bgroup
+ \ifzeropt\d_framed_target_dp
+ \the\everyoverlay#2% saves wrapping (and lua call)
+ \else
+ \lower\d_framed_target_dp
+ \hbox{\the\everyoverlay#2}%
+ \fi
+ \egroup
\setlayoutcomponentattribute{\v!overlay:#1}%
- \edef\overlaywidth {\the\frameddimenwd\space}%
- \edef\overlayheight{\the\dimexpr\frameddimenht+\frameddimendp\relax\space}%
- \edef\overlaydepth {\the\frameddimendp\space}%
- \edef\overlaycolor {\framedparameter\c!backgroundcolor}%
- %\edef\overlaycorner{\framedparameter\c!backgroundcorner}%
- %\edef\overlayradius{\framedparameter\c!backgroundradius}%
- \let\overlayoffset\backgroundoffset % we steal this one
- \setbox\scratchbox\hbox{\lower\overlaydepth\hbox{\the\everyoverlay#2}}%
\setbox\scratchbox\hbox \layoutcomponentboxattribute
- {\hskip-.5\dimexpr\wd\scratchbox-\overlaywidth \relax
- \raise-.5\dimexpr\ht\scratchbox-\frameddimenht\relax % not overlayheight !
+ {\kern -.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \overlaywidth
+ \raise-.5\dimexpr\ht\scratchbox-\d_framed_target_ht\relax % not \overlayheight !
\box\scratchbox}%
- \wd\scratchbox\frameddimenwd
- \ht\scratchbox\frameddimenht
- \dp\scratchbox\frameddimendp
+ \wd\scratchbox\d_framed_target_wd
+ \ht\scratchbox\d_framed_target_ht
+ \dp\scratchbox\d_framed_target_dp
\box\scratchbox
\egroup}
%D \macros
%D {overlayfakebox}
-\def\overlayfakebox
+\unexpanded\def\overlayfakebox
{\hbox
{\setbox\scratchbox\emptyhbox
\wd\scratchbox\overlaywidth
\ht\scratchbox\overlayheight
\box\scratchbox}}
-%D The empty case is:
-
-\let\executeoverlay\gobblesevenarguments
-
%D For testing we provide:
-\def\doifoverlayelse#1%
+\def\doifoverlayelse#1% only tests external overlays
{\ifcsname\??ov#1\endcsname
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
-%D We predefine two already familiar backgrounds:
-
-\setvalue{\??ov\v!screen}{\dograybox }
-\setvalue{\??ov\v!color }{\docolorbox}
-
-% %D After all these preparations, the background macro does no
-% %D bring to many surprises. One has to keep in mind that this
-% %D macro starts up a call chain, depending on the background
-% %D one needs:
-% %D
-% %D \startitemize[packed]
-% %D \item a raster, color or user defined shape
-% %D \item square or round corners
-% %D \item a \TEX\ or driver based method
-% %D \stopitemize
-% %D
-% %D The macro can be extended by adding commands to the token
-% %D list register \type {\everybackgroundbox}. For this
-% %D purpose, the name of the current background is available in
-% %D \type {\currentbackgound}.
-
%D The content of the box will be (temporary) saved in a box. We
%D also have an extra box for backgrounds.
-\newbox\framebox
-\newbox\extraframebox
+\newbox\b_framed_normal
+\newbox\b_framed_extra
\newtoks\everybackgroundbox
\let\currentbackground\empty
-\def\dodobackgroundbox
+\def\framed_process_background
+ {\ifcsname\??ov:\currentbackground\endcsname
+ \framed_process_background_indeed_internal
+ \else\ifcsname\??ov\currentbackground\endcsname
+ \framed_process_background_indeed_external
+ \fi\fi}
+
+\def\framed_process_background_indeed_internal % : in name
{\bgroup
- \ifcsname\??ov\currentbackground\endcsname
- \the\everybackgroundbox
- \setbox\extraframebox\hbox{\vbox{\moveleft\backgroundoffset\hbox{\csname\??ov\currentbackground\endcsname}}}%
- \wd\extraframebox\zeropoint % \backgroundwidth
- \ht\extraframebox\backgroundheight
- \dp\extraframebox\backgrounddepth
- \box\extraframebox % \hskip-\backgroundwidth
- \fi
+ \setbox\b_framed_extra\hbox{%\bgroup
+ \ifzeropt\framedbackgroundoffset
+ \csname\??ov:\currentbackground\endcsname
+ \else
+ \kern-\framedbackgroundoffset
+ \hbox{\csname\??ov:\currentbackground\endcsname}%
+ \fi
+ }%\egroup
+ \wd\b_framed_extra\zeropoint
+ \ht\b_framed_extra\framedbackgroundheight
+ \dp\b_framed_extra\framedbackgrounddepth
+ \box\b_framed_extra
\egroup}
-\def\dododobackgroundbox#1,#2% #2 gobbles spaces
+\def\framed_process_background_indeed_external
+ {\framed_overlay_initialize
+ \bgroup
+ \setbox\b_framed_extra\hbox{%\bgroup
+ \ifzeropt\framedbackgroundoffset
+ \csname\??ov\currentbackground\endcsname
+ \else
+ \kern-\framedbackgroundoffset
+ \hbox{\csname\??ov\currentbackground\endcsname}%
+ \fi
+ }%\egroup
+ \wd\b_framed_extra\zeropoint
+ \ht\b_framed_extra\framedbackgroundheight
+ \dp\b_framed_extra\framedbackgrounddepth
+ \box\b_framed_extra
+ \egroup}
+
+\def\framed_process_backgrounds#1,#2% #2 gobbles spaces (we could avoid one catch if we have nextbackground)
{\edef\currentbackground{#1}%
- \ifx\currentbackground\s!unknown\else % use $ instead of s!unknown
- \dodobackgroundbox\expandafter\dododobackgroundbox
+ \ifx\currentbackground\s!unknown\else
+ \framed_process_background
+ \expandafter\framed_process_backgrounds
\fi#2}
-\let\backgroundoffset\!!zeropoint
-\let\backgrounddepth \!!zeropoint
-\def\backgroundwidth {\the\hsize}
-\def\backgroundheight{\the\vsize}
+% beware, a backgroundbox can be empty which is another reason
+% why we set the width to zero instead of back-skipping
+
+\newdimen\framedbackgroundwidth
+\newdimen\framedbackgroundheight
+\newdimen\framedbackgrounddepth
+\newdimen\framedbackgroundoffset
-\def\normalforegroundbox% fuzzy but needed hack, this \vss, otherwise
- {\vbox to \backgroundheight{\vss\box\framebox\vss}}% vertical shift
+\def\framed_background_box_content% fuzzy but needed hack, this \vss, otherwise
+ {\vbox to \framedbackgroundheight{\vss\box\b_framed_normal\vss}} % vertical shift \backgroundheight
-\def\dobackedbox
- {\setbox\framebox\vbox
- {\framedforgetall
+\def\framed_add_background
+ {\setbox\b_framed_normal\hbox % was vbox
+ {\framed_forgetall % can be relaxed
\boxmaxdepth\maxdimen
- \frameddimenwd\dimexpr\wd\framebox+2\!!framedbackgroundoffset\relax
- \frameddimenht\dimexpr\ht\framebox+ \!!framedbackgroundoffset\relax
- \frameddimendp\dimexpr\dp\framebox+ \!!framedbackgroundoffset+\framedparameter\c!backgrounddepth\relax
- \edef\backgroundoffset{\the\!!framedbackgroundoffset}%
- \edef\backgroundwidth {\the\wd\framebox}%
- \edef\backgroundheight{\the\ht\framebox}%
- \edef\backgrounddepth {\the\dp\framebox}%
- \edef\overlaylinecolor{\framedparameter\c!framecolor}%
- \edef\overlaylinewidth{\the\ruledlinewidth}%
- %\edef\foregroundbox{\box#1}%
- \edef\component{\framedparameter\c!component}%
- \ifx\component\empty
+ \framedbackgroundoffset\d_framed_backgroundoffset
+ \framedbackgroundwidth \wd\b_framed_normal
+ \framedbackgroundheight\ht\b_framed_normal
+ \framedbackgrounddepth \dp\b_framed_normal
+ \d_framed_target_wd\dimexpr\framedbackgroundwidth +2\framedbackgroundoffset\relax
+ \d_framed_target_ht\dimexpr\framedbackgroundheight+ \framedbackgroundoffset\relax
+ \d_framed_target_dp\dimexpr\framedbackgrounddepth + \framedbackgroundoffset+\framedparameter\c!backgrounddepth\relax
+ \let\framed_overlay_initialize\framed_overlay_initialize_indeed
+ \ifx\p_framed_component\empty
\resetlayoutcomponentattribute
\else
- \setlayoutcomponentattribute{\v!background:\component}%
+ \setlayoutcomponentattribute{\v!background:\p_framed_component}%
\fi
- \let\foregroundbox\normalforegroundbox
- \hbox \layoutcomponentboxattribute to \backgroundwidth % width in case 'foreground' is used as overlay
- {\expandafter\dododobackgroundbox\framedbackground,\s!unknown,\relax % hm, messy .. look into it
- \box\framebox\hss}}}
+ \let\foregroundbox\framed_background_box_content
+ \hbox \layoutcomponentboxattribute to \framedbackgroundwidth\bgroup % width in case 'foreground' is used as overlay
+ \the\everybackgroundbox % moved
+ \expandafter\framed_process_backgrounds\p_framed_background,\s!unknown,\relax % hm, messy .. look into it
+ \box\b_framed_normal
+ \hss
+ \egroup}}
+
+\def\framed_overlay_initialize_indeed
+ {%\writestatus{!!!!}{<<<<<}%
+ \edef\overlaywidth {\the\d_framed_target_wd\space}%
+ \edef\overlayheight {\the\dimexpr\d_framed_target_ht+\d_framed_target_dp\relax\space}%
+ \edef\overlaydepth {\the\d_framed_target_dp\space}%
+ \edef\overlaycolor {\framedparameter\c!backgroundcolor}% let ?
+ \edef\overlaylinecolor{\framedparameter\c!framecolor}% only needed for layers
+ \edef\overlaylinewidth{\the\d_framed_linewidth\space}%
+ %\edef\overlaycorner {\framedparameter\c!backgroundcorner}%
+ %\edef\overlayradius {\framedparameter\c!backgroundradius}%
+ \edef\overlayoffset {\the\framedbackgroundoffset\space}% \backgroundoffset % we steal this one
+ \let\framed_overlay_initialize\relax}
%D One can explictly insert the foreground box. For that
%D purpose we introduce the overlay \type {foreground}.
+%D
+%D We predefine two already familiar backgrounds:
-\defineoverlay[\v!foreground][\foregroundbox]
+\letvalue{\??ov:\v!screen }\framed_background_box_gray
+\letvalue{\??ov:\v!color }\framed_background_box_color
+\letvalue{\??ov:\v!foreground}\framed_background_box_content % replaces: \defineoverlay[\v!foreground][\foregroundbox]
%D We can specify overlays as a comma separated list of
%D overlays, a sometimes handy feature.
@@ -448,112 +620,94 @@
%D by \TEX\ itself, the latter one depends on the driver. This
%D macro also support a negative offset.
-\def\dooutlinebox % we needed to move the color command in order to apply attributes properly
- {\setbox\framebox\vbox % rules on top of box
- {\frameddimenwd\dimexpr\wd\framebox+2\!!framedframeoffset\relax
- \frameddimenht\dimexpr\ht\framebox+ \!!framedframeoffset\relax
- \frameddimendp\dimexpr\dp\framebox+ \!!framedframeoffset+\framedparameter\c!framedepth\relax
- \ifdim\frameddimendp<\zeropoint
- \advance\frameddimenht \frameddimendp
- \scratchdimen-\frameddimendp
- \frameddimendp\zeropoint
+\def\framed_add_outline
+ {\setbox\b_framed_normal\hbox % rules on top of box
+ {\d_framed_target_wd\dimexpr\wd\b_framed_normal+2\d_framed_frameoffset\relax
+ \d_framed_target_ht\dimexpr\ht\b_framed_normal+ \d_framed_frameoffset\relax
+ \d_framed_target_dp\dimexpr\dp\b_framed_normal+ \d_framed_frameoffset+\framedparameter\c!framedepth\relax
+ \ifdim\d_framed_target_dp<\zeropoint
+ \advance\d_framed_target_ht \d_framed_target_dp
+ \scratchdimen-\d_framed_target_dp
+ \d_framed_target_dp\zeropoint
\else
\scratchdimen\zeropoint
\fi
- \setbox\extraframebox\hbox
- {\doifsomething{\framedparameter\c!framecolor}{\color[\framedparameter\c!framecolor]}{\dostrokedbox}}%
- \setbox\extraframebox\hbox
- {\raise\scratchdimen\vbox
- {\moveleft\!!framedframeoffset
- \box\extraframebox}}%
- \wd\extraframebox\wd\framebox
- \ht\extraframebox\ht\framebox
- \dp\extraframebox\dp\framebox
- \hbox{\box\framebox\hskip-\wd\extraframebox\box\extraframebox}}}
-
-\def\dostrokedbox
- {\edef\@@framedcornermod{\framedparameter\c!framecorner}%
- \ifx\@@framedcornermod\v!rectangular
- \dostrokedlinedbox
- \else\ifzeropt\dimexpr\framedparameter\c!frameradius\relax % just in case of .x\bodyfontsize
- \dostrokedlinedbox
- \else
- \dostrokedroundbox
- \fi\fi}
-
-
-\def\dostrokedlinedbox % will move to pack-rul
+ \edef\overlaylinecolor{\framedparameter\c!framecolor}% twice, also in background
+ \setbox\b_framed_extra\hbox
+ {\kern-\d_framed_frameoffset
+ \raise\scratchdimen
+ \hbox{\ifx\overlaylinecolor\empty\else\doactivatecolor\overlaylinecolor\fi\framed_stroked_box}}%
+ \wd\b_framed_extra\wd\b_framed_normal
+ \ht\b_framed_extra\ht\b_framed_normal
+ \dp\b_framed_extra\dp\b_framed_normal
+ \wd\b_framed_normal\zeropoint
+ \box\b_framed_normal
+ \box\b_framed_extra}}
+
+\def\framed_stroked_box_normal
{\setbox\scratchbox\emptyhbox
- \wd\scratchbox\frameddimenwd
- \ht\scratchbox\frameddimenht
- \dp\scratchbox\frameddimendp
+ \wd\scratchbox\d_framed_target_wd
+ \ht\scratchbox\d_framed_target_ht
+ \dp\scratchbox\d_framed_target_dp
\setbox\scratchbox\vbox \bgroup
- \csname t\@@frame@@\framedparameter\c!frame\framedparameter\c!topframe \endcsname
-\nointerlineskip % new (needed for fences), maybe \offinterlineskip
+ \csname \??hf t\p_framed_frame\framedparameter\c!topframe \endcsname
+ \nointerlineskip % new (needed for fences)
\hbox \bgroup
- \csname l\@@frame@@\framedparameter\c!frame\framedparameter\c!leftframe \endcsname
+ \csname \??hf l\p_framed_frame\framedparameter\c!leftframe \endcsname
\box\scratchbox
- \csname r\@@frame@@\framedparameter\c!frame\framedparameter\c!rightframe \endcsname
+ \csname \??hf r\p_framed_frame\framedparameter\c!rightframe \endcsname
\egroup
-\nointerlineskip % new (needed for fences)
- \csname b\@@frame@@\framedparameter\c!frame\framedparameter\c!bottomframe\endcsname
+ \nointerlineskip % new (needed for fences)
+ \csname \??hf b\p_framed_frame\framedparameter\c!bottomframe\endcsname
\egroup
- \wd\scratchbox\frameddimenwd
- \ht\scratchbox\frameddimenht
- \dp\scratchbox\frameddimendp
+ \wd\scratchbox\d_framed_target_wd
+ \ht\scratchbox\d_framed_target_ht
+ \dp\scratchbox\d_framed_target_dp
\box\scratchbox}
-\def\@@frame@@{@@frame@@}
-
-\def\@@frame@@trule{\hrule\!!height\ruledlinewidth\kern-\ruledlinewidth}
-\def\@@frame@@brule{\kern-\ruledlinewidth\hrule\!!height\ruledlinewidth}
-\def\@@frame@@rrule{\kern-\ruledlinewidth\vrule\!!width\ruledlinewidth}
-\def\@@frame@@lrule{\vrule\!!width\ruledlinewidth\kern-\ruledlinewidth}
+\def\framed_t_rule{\hrule\!!height\d_framed_linewidth\kern-\d_framed_linewidth}
+\def\framed_b_rule{\kern-\d_framed_linewidth\hrule\!!height\d_framed_linewidth}
+\def\framed_r_rule{\kern-\d_framed_linewidth\vrule\!!width\d_framed_linewidth}
+\def\framed_l_rule{\vrule\!!width\d_framed_linewidth\kern-\d_framed_linewidth}
-\letvalue{t\@@frame@@\v!on \v!on}\@@frame@@trule
-\letvalue{t\@@frame@@\v!off\v!on}\@@frame@@trule
-\letvalue{t\@@frame@@\v!on }\@@frame@@trule
+\letvalue{\??hf t\v!on \v!on}\framed_t_rule
+\letvalue{\??hf t\v!off\v!on}\framed_t_rule
+\letvalue{\??hf t\v!on }\framed_t_rule
-\letvalue{b\@@frame@@\v!on \v!on}\@@frame@@brule
-\letvalue{b\@@frame@@\v!off\v!on}\@@frame@@brule
-\letvalue{b\@@frame@@\v!on }\@@frame@@brule
+\letvalue{\??hf b\v!on \v!on}\framed_b_rule
+\letvalue{\??hf b\v!off\v!on}\framed_b_rule
+\letvalue{\??hf b\v!on }\framed_b_rule
-\letvalue{l\@@frame@@\v!on \v!on}\@@frame@@lrule
-\letvalue{l\@@frame@@\v!off\v!on}\@@frame@@lrule
-\letvalue{l\@@frame@@\v!on }\@@frame@@lrule
+\letvalue{\??hf l\v!on \v!on}\framed_l_rule
+\letvalue{\??hf l\v!off\v!on}\framed_l_rule
+\letvalue{\??hf l\v!on }\framed_l_rule
-\letvalue{r\@@frame@@\v!on \v!on}\@@frame@@rrule
-\letvalue{r\@@frame@@\v!off\v!on}\@@frame@@rrule
-\letvalue{r\@@frame@@\v!on }\@@frame@@rrule
+\letvalue{\??hf r\v!on \v!on}\framed_r_rule
+\letvalue{\??hf r\v!off\v!on}\framed_r_rule
+\letvalue{\??hf r\v!on }\framed_r_rule
% no overlapping rules
-\def\@@frame@@trules{\hbox{\kern\ruledlinewidth\vrule\!!width\dimexpr\frameddimenwd-2\ruledlinewidth\relax\!!height\ruledlinewidth}\nointerlineskip\kern-\ruledlinewidth}
-\def\@@frame@@brules{\kern-\ruledlinewidth\nointerlineskip\hbox{\kern\ruledlinewidth\vrule\!!width\dimexpr\frameddimenwd-2\ruledlinewidth\relax\!!height\ruledlinewidth}}
-\def\@@frame@@rrules{\kern-\ruledlinewidth\vrule\!!height\dimexpr\frameddimenht-\ruledlinewidth\relax\!!depth-\ruledlinewidth\!!width\ruledlinewidth}
-\def\@@frame@@lrules{\vrule\!!height\dimexpr\frameddimenht-\ruledlinewidth\relax\!!depth-\ruledlinewidth\!!width\ruledlinewidth\kern-\ruledlinewidth}
+\def\framed_t_rules{\hbox{\kern\d_framed_linewidth\vrule\!!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\!!height\d_framed_linewidth}\nointerlineskip\kern-\d_framed_linewidth}
+\def\framed_b_rules{\kern-\d_framed_linewidth\nointerlineskip\hbox{\kern\d_framed_linewidth\vrule\!!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\!!height\d_framed_linewidth}}
+\def\framed_r_rules{\kern-\d_framed_linewidth\vrule\!!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\!!depth-\d_framed_linewidth\!!width\d_framed_linewidth}
+\def\framed_l_rules{\vrule\!!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\!!depth-\d_framed_linewidth\!!width\d_framed_linewidth\kern-\d_framed_linewidth}
-% small is relatively new
+\letvalue{\??hf t\v!small\v!small}\frame_t_rules
+\letvalue{\??hf t\v!off \v!small}\frame_t_rules
+\letvalue{\??hf t\v!small }\frame_t_rules
-\letvalue{t\@@frame@@\v!small\v!small}\@@frame@@trules
-\letvalue{t\@@frame@@\v!off \v!small}\@@frame@@trules
-\letvalue{t\@@frame@@\v!small }\@@frame@@trules
+\letvalue{\??hf b\v!small\v!small}\frame_b_rules
+\letvalue{\??hf b\v!off \v!small}\frame_b_rules
+\letvalue{\??hf b\v!small }\frame_b_rules
-\letvalue{b\@@frame@@\v!small\v!small}\@@frame@@brules
-\letvalue{b\@@frame@@\v!off \v!small}\@@frame@@brules
-\letvalue{b\@@frame@@\v!small }\@@frame@@brules
+\letvalue{\??hf l\v!small\v!small}\frame_l_rules
+\letvalue{\??hf l\v!off \v!small}\frame_l_rules
+\letvalue{\??hf l\v!small }\frame_l_rules
-\letvalue{l\@@frame@@\v!small\v!small}\@@frame@@lrules
-\letvalue{l\@@frame@@\v!off \v!small}\@@frame@@lrules
-\letvalue{l\@@frame@@\v!small }\@@frame@@lrules
-
-\letvalue{r\@@frame@@\v!small\v!small}\@@frame@@rrules
-\letvalue{r\@@frame@@\v!off \v!small}\@@frame@@rrules
-\letvalue{r\@@frame@@\v!small }\@@frame@@rrules
-
-%D I condidered using the low level support command
-%D \type{\ruledhbox}, but this would slow down processing by a
-%D factor~3.
+\letvalue{\??hf r\v!small\v!small}\frame_r_rules
+\letvalue{\??hf r\v!off \v!small}\frame_r_rules
+\letvalue{\??hf r\v!small }\frame_r_rules
% \framed
% [width=4cm,height=3cm,rulethickness=3mm,
@@ -577,20 +731,15 @@
% todo : \c_framed_hasoffset
% faster : \let\c_framed_hasoffset\falseconditional
-\newif\ifboxhasoffset
-\newif\ifboxhaswidth
-\newif\ifboxhasheight
-\newif\ifboxhasformat
-\newif\ifboxhasstrut
-\newif\ifboxisoverlaid
-\newif\ifboxhasframe
-\newif\ifdelayedstrut
-\newif\ifboxhasextraoffset
-
-%D We also need a few \DIMENSIONS:
-
-\newdimen\@@localoffset
-\newdimen\@@globalwidth
+\newconditional\c_framed_has_offset
+\newconditional\c_framed_has_width
+\newconditional\c_framed_has_height
+\newconditional\c_framed_has_format
+\newconditional\c_framed_has_strut
+\newconditional\c_framed_is_overlaid
+\newconditional\c_framed_has_frame
+\newconditional\c_framed_has_extra_offset
+\newconditional\c_framed_text_location_none
%D \macros
%D {framed, setupframed}
@@ -623,16 +772,16 @@
{\bgroup
\advance\framednesting\plusone
\expandafter\let\csname\??ol:\the\framednesting\s!parent\endcsname\??ol
- \dodoubleempty\dolocalframed[\??ol:\the\framednesting]}
+ \dodoubleempty\framed_process[\??ol:\the\framednesting]}
\unexpanded\def\startframed
- {\dosingleempty\dostartframed}
+ {\dosingleempty\framed_start_framed}
-\def\dostartframed[#1]%
+\def\framed_start_framed[#1]%
{\bgroup
\advance\framednesting\plusone
\expandafter\let\csname\??ol:\the\framednesting\s!parent\endcsname\??ol
- \dolocalframed[\??ol:\the\framednesting][#1]%
+ \framed_process[\??ol:\the\framednesting][#1]%
\bgroup}
\let\stopframed\egroup
@@ -644,7 +793,7 @@
{\bgroup
\advance\framednesting\plusone
\expandafter\let\csname\??ol:\the\framednesting\s!parent\endcsname\??ol
- \dolocalframed[\??ol:\the\framednesting]}
+ \framed_process[\??ol:\the\framednesting]}
% we can consider setting the parent of the regular framed to
% something else in the otr so that we isolate it there
@@ -690,31 +839,34 @@
\unexpanded\def\fastlocalframed[#1]#2[#3]#4% 3-4
{\bgroup
- \doinitializeframed{#1}%
- \setbox\framebox\hbox{#4}%
- \getparameters[\@@framed][#3]% no \expanded !
- \!!framedframeoffset\framedparameter\c!frameoffset
- \edef\@@framedbackgroundoffset{\framedparameter\c!backgroundoffset}%
- \ifx\@@framedbackgroundoffset\v!frame
- \!!framedbackgroundoffset\!!framedframeoffset
- \else
- \!!framedbackgroundoffset\@@framedbackgroundoffset
- \fi
+ \framed_initialize{#1}%
+ \setbox\b_framed_normal\hbox{#4}%
+ \getparameters[\currentframed][#3]% no \expanded !
+ \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}% also used in backgrounds
+ \d_framed_frameoffset\framedparameter\c!frameoffset\relax % also used in backgrounds
+ \edef\p_framed_frame{\framedparameter\c!frame}%
+ \edef\p_framed_background{\framedparameter\c!background}%
% not here, in calling macro: setups
- \removeframedboxdepth
- \edef\@@localframing {\framedparameter\c!frame}%
- \ifx\@@localframing\v!overlay \else \ifx\@@localframing\v!none \else
- \edef\framedrulethickness{\framedparameter\c!rulethickness}%
- \ifx\framedrulethickness\empty\else
- \ruledlinewidth\framedrulethickness\relax
- \ifinheritruledlinewidth\linewidth\ruledlinewidth\fi
+ \framed_remove_depth
+ \ifx\p_framed_frame\v!overlay \else \ifx\p_framed_frame\v!none \else
+ \ifx\p_framed_rulethickness\empty\else
+ \d_framed_linewidth\p_framed_rulethickness\relax
\fi
- \dooutlinebox % real or invisible frame
+ \framed_add_outline % real or invisible frame
\fi \fi
- \edef\framedbackground{\framedparameter\c!background}%
- \ifx\framedbackground\empty\else\dobackedbox\fi
- \restoreframedboxdepth
- \box\framebox
+ \ifx\p_framed_background\empty \else
+ \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}%
+ \d_framed_backgroundoffset
+ \ifx\p_framed_backgroundoffset\v!frame
+ \d_framed_frameoffset
+ \else
+ \p_framed_backgroundoffset
+ \fi
+ \edef\p_framed_component{\framedparameter\c!component}%
+ \framed_add_background
+ \fi
+ \framed_restore_depth
+ \box\b_framed_normal
\egroup}
%D The next macro uses a box and takes its natural width and
@@ -722,145 +874,34 @@
\def\localbackgroundframed#1#2#3% namespace component box
{\bgroup
- \doinitializeframed{#1}%
- \expandafter\def\csname\@@framed\c!component\endcsname{#2}% watch out: hard coded @@framed
- \setbox\framebox\box#3%
- \!!framedframeoffset\framedparameter\c!frameoffset
- \edef\@@framedbackgroundoffset{\framedparameter\c!backgroundoffset}%
- \ifx\@@framedbackgroundoffset\v!frame
- \!!framedbackgroundoffset\!!framedframeoffset
- \else
- \!!framedbackgroundoffset\@@framedbackgroundoffset
- \fi
- \edef\framedbackground {\framedparameter\c!background}%
- \edef\framedrulethickness{\framedparameter\c!rulethickness}%
- \edef\@@localframing {\framedparameter\c!frame}%
- \ifx\@@localframing\v!overlay \else \ifx\@@localframing\v!none \else
- \ifx\framedrulethickness\empty\else
- \ruledlinewidth\framedrulethickness\relax
- \ifinheritruledlinewidth\linewidth\ruledlinewidth\fi
+ \framed_initialize{#1}%
+ \setbox\b_framed_normal\box#3%
+ \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}% also used in backgrounds
+ \d_framed_frameoffset\framedparameter\c!frameoffset\relax % also used in backgrounds
+ \edef\p_framed_frame{\framedparameter\c!frame}%
+ \edef\p_framed_background{\framedparameter\c!background}%
+ \ifx\p_framed_frame\v!overlay \else \ifx\p_framed_frame\v!none \else
+ \ifx\p_framed_rulethickness\empty \else
+ \d_framed_linewidth\p_framed_rulethickness\relax
\fi
- \dooutlinebox % real or invisible frame
+ \framed_add_outline % real or invisible frame
\fi \fi
- \ifx\framedbackground\empty\else\dobackedbox\fi
- \box\framebox
+ \ifx\p_framed_background\empty \else
+ \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}%
+ \d_framed_backgroundoffset
+ \ifx\p_framed_backgroundoffset\v!frame
+ \d_framed_frameoffset
+ \else
+ \p_framed_backgroundoffset
+ \fi
+ \edef\p_framed_component{#2}%
+ \framed_add_background
+ \fi
+ \box\b_framed_normal
\egroup}
-%D Before we go into details, we present (and implement) the
-%D main framing routine. I saw no real reason for splitting the
-%D next two macros into smaller pieces. The content will be
-%D collected in a horizontal or vertical box with fixed or free
-%D dimensions and specific settings concerning aligment and
-%D offsets.
-%D
-%D In the first few lines, we pre||expand the frame and
-%D background offsets. We do so, because the can be defined in
-%D terms of the main offset. However, see for instance page
-%D backgrounds, when \type {#2} sets the offset to \type
-%D {overlay}, both offsets become invalid.
-%D
-%D Because it is used so often the he next macro is (and
-%D looks) rather optimized.
-
-% eventually all will ue the commandhandler but now we have a
-% hybrid (with and without colon)
-
\let\postprocessframebox\relax
-\let\@@framed\s!unknown
-
-\def\framedparameter #1{\csname\doframedparameter\@@framed{#1}\endcsname}
-\def\framedparameterhash#1{\doframedparameterhash \@@framed#1}
-
-\def\doframedparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\doframedparentparameter \csname#1\s!parent\endcsname{#2}\fi}
-\def\doframedparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\doframedparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-
-\def\doframedparentparameter #1#2{\ifx#1\relax\s!empty\else\doframedparameter #1{#2}\fi}
-\def\doframedparentparameterhash#1#2{\ifx#1\relax \else\doframedparameterhash#1#2\fi}
-
-\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\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}
-
-\let\normalframedparameter \framedparameter
-\let\normalframedparameterhash\framedparameterhash
-
-\def\doinitializeframed#1% will be inlined
- {\inframedtrue
- \edef\@@framed{#1}%
- \let\framedparameter \normalframedparameter
- \let\framedparameterhash\normalframedparameterhash}
-
-% defaults, kind of isolated now
-
-\getparameters
- [\??oi]
- [\c!width=\v!fit,
- \c!height=\v!broad,
- %\c!lines=,
- \c!offset=0.25ex, % \defaultframeoffset
- \c!empty=\v!no,
- \c!frame=\v!on,
- %\c!topframe=,
- %\c!bottomframe=,
- %\c!leftframe=,
- %\c!rightframe=,
- \c!radius=.5\bodyfontsize,
- \c!rulethickness=\linewidth,
- \c!corner=\v!rectangular,
- \c!depth=\zeropoint,
- %\c!foregroundcolor=,
- %\c!foregroundstyle=,
- %\c!background=,
- %\c!backgroundscreen=,
- %\c!backgroundcolor=,
- \c!backgroundoffset=\zeropoint,
- %\c!framecolor=,
- \c!frameoffset=\zeropoint,
- \c!backgroundcorner=\framedparameter\c!corner,
- \c!backgroundradius=\framedparameter\c!radius,
- \c!backgrounddepth=\framedparameter\c!depth,
- \c!framecorner=\framedparameter\c!corner,
- \c!frameradius=\framedparameter\c!radius,
- \c!framedepth=\framedparameter\c!depth,
- %\c!component=,
- %\c!align=,
- \c!bottom=\vss,
- %\c!top=,
- \c!strut=\v!yes,
- \c!autostrut=\v!yes,
- \c!location=\v!normal,
- %\c!orientation=,
- \c!autowidth=\v!yes,
- %\c!setups=
-]
-
-\getparameters
- [\??od] % for fast version
- [\c!frame=\v!off,
- \c!depth=\zeropoint,
- \c!offset=\v!overlay,
- %\c!component=,
- \c!radius=.5\bodyfontsize,
- \c!rulethickness=\linewidth,
- \c!corner=\v!rectangular,
- \c!backgroundoffset=\zeropoint,
- \c!frameoffset=\zeropoint,
- \c!backgroundcorner=\framedparameter\c!corner,
- \c!backgroundradius=\framedparameter\c!radius,
- \c!backgrounddepth=\framedparameter\c!depth,
- \c!framecorner=\framedparameter\c!corner,
- \c!frameradius=\framedparameter\c!radius,
- \c!framedepth=\framedparameter\c!depth,
- \c!location=\v!normal]
-
%D A nice example by Aditya:
%D
%D \starttyping
@@ -872,78 +913,38 @@
%D \defineframed[test][hoffset=1cm]
%D \stoptyping
-\newdimen\!!framedwidth
-\newdimen\!!framedheight
-\newdimen\!!framedscratch % so that users can use \scratchdimen
-\newdimen\!!framedframeoffset
-\newdimen\!!framedbackgroundoffset
-
-\let\setextraframedoffsets \relax
-\let\applyextraframedoffsets\relax
+\newdimen\d_framed_width
+\newdimen\d_framed_height
+\newdimen\d_framed_frameoffset
+\newdimen\d_framed_backgroundoffset
+\newdimen\d_framed_local_offset
% todo: protect local \framednames
\unexpanded\def\localframed
{\bgroup
- \dodoubleempty\dolocalframed}
+ \dodoubleempty\framed_process}
-\unexpanded\def\dolocalframed[#1][#2]% assumes a \dodoubleempty (slows down), also should have leading \bgroup
+\unexpanded\def\framed_process[#1][#2]% assumes a \dodoubleempty (slows down), also should have leading \bgroup
{\bgroup
- \doinitializeframed{#1}%
+ \framed_initialize{#1}%
\ifsecondargument % faster
- \getparameters[\@@framed][#2]% here !
+ \getparameters[\currentframed][#2]% here !
\fi
- \dodolocalframed}
+ \framed_process_indeed}
\unexpanded\def\directlocalframed[#1]% no optional
{\bgroup
\bgroup
- \doinitializeframed{#1}%
- \dodolocalframed}
+ \framed_initialize{#1}%
+ \framed_process_indeed}
\unexpanded\def\localframedwithsettings[#1][#2]% no checking (so no spaces between)
{\bgroup
\bgroup
- \doinitializeframed{#1}%
- \getparameters[\@@framed][#2]% here !
- \dodolocalframed}
-
-% will probably move
-
-\def\installinheritedframed#1%
- {\normalexpanded{\doinstallinheritedframed
- \expandafter\noexpand\csname current#1\endcsname
- \expandafter\noexpand\csname #1parameter\endcsname
- \expandafter\noexpand\csname #1parameterhash\endcsname
- \expandafter\noexpand\csname do#1parameter\endcsname
- \expandafter\noexpand\csname do#1parentparameter\endcsname
- \expandafter\noexpand\csname do#1rootparameter\endcsname
- \expandafter\noexpand\csname inherited#1framed\endcsname
- \noexpand\??oi}} % if needed we can have a variant
-
-\unexpanded\def\doinstallinheritedframed#1#2#3#4#5#6#7#8%
- {\def#5##1##2{\ifx##1\relax#6{##2}\else#4##1{##2}\fi}%
- \def#6##1{\ifcsname#8##1\endcsname#8##1\else\s!empty\fi}%
- \unexpanded\def#7%
- {\bgroup
- \bgroup
- \inframedtrue
- \let\@@framed #1% not used (more for tracing)
- \let\framedparameter #2%
- \let\framedparameterhash#3%
- \dodolocalframed}}
-
-\unexpanded\def\installframedcommandhandler#1#2#3%
- {\installcommandhandler{#1}{#2}{#3}%
- \installinheritedframed{#2}}
-
-\unexpanded\def\installframedautocommandhandler#1#2#3%
- {\installautocommandhandler{#1}{#2}{#3}%
- \installinheritedframed{#2}}
-
-\unexpanded\def\installsimpleframedcommandhandler#1#2#3%
- {\installsimplecommandhandler{#1}{#2}{#3}%
- \installinheritedframed{#2}}
+ \framed_initialize{#1}%
+ \getparameters[\currentframed][#2]% here !
+ \framed_process_indeed}
% done
@@ -951,25 +952,23 @@
% we can make macros for the offset, width, and height branches or do an \csname
-\unexpanded\def\dodolocalframed
- {\!!framedframeoffset\framedparameter\c!frameoffset
- \edef\@@framedbackgroundoffset{\framedparameter\c!backgroundoffset}%
- \ifx\@@framedbackgroundoffset\v!frame
- \!!framedbackgroundoffset\!!framedframeoffset
- \else
- \!!framedbackgroundoffset\@@framedbackgroundoffset
- \fi
+\unexpanded\def\framed_process_indeed
+ {\d_framed_frameoffset\framedparameter\c!frameoffset
+ \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}%
+ \d_framed_backgroundoffset
+ \ifx\p_framed_backgroundoffset\v!frame
+ \d_framed_frameoffset
+ \else
+ \p_framed_backgroundoffset
+ \fi
% new, experimental dirty hook
\framedparameter\c!extras
% to get the right spacing
- \edef\!!framedforegroundstyle{\framedparameter\c!foregroundstyle}%
- \ifx\!!framedforegroundstyle\empty\else\dousestyleparameter\!!framedforegroundstyle\fi
+ \edef\p_framed_foregroundstyle{\framedparameter\c!foregroundstyle}%
+ \ifx\p_framed_foregroundstyle\empty\else\dousestyleparameter\p_framed_foregroundstyle\fi
% beware, both the frame and background offset can be overruled
%
- \edef\doframedsetups{\framedparameter\c!setups}%
- \ifx\doframedsetups\empty\else
- \edef\doframedsetups{\noexpand\setups[\doframedsetups]}%
- \fi
+ \edef\p_framed_setups{\framedparameter\c!setups}%
% the next macros are visible
\edef\localoffset{\framedparameter\c!offset}%
\edef\localwidth {\framedparameter\c!width}%
@@ -977,136 +976,132 @@
\edef\localformat{\framedparameter\c!align}%
\edef\localstrut {\framedparameter\c!strut}%
% these are not
- \edef\@@localautostrut {\framedparameter\c!autostrut}%
- \edef\@@localframing {\framedparameter\c!frame}%
- \edef\@@locallocation {\framedparameter\c!location}%
- \edef\@@localorientation{\framedparameter\c!orientation}%
+ \edef\p_framed_autostrut {\framedparameter\c!autostrut}%
+ \edef\p_framed_frame {\framedparameter\c!frame}%
+ \edef\p_framed_location {\framedparameter\c!location}%
+ \edef\p_framed_orientation{\framedparameter\c!orientation}%
%
- \edef\@@localautowidth {\framedparameter\c!autowidth}%
- \edef\@@localfranalyze {\framedparameter\c!fr!analyze}% experimental option
+ \edef\p_framed_autowidth {\framedparameter\c!autowidth}%
+ \edef\p_framed_franalyze {\framedparameter\c!fr!analyze}% experimental option
%
- \ifx\@@localframing\v!overlay % no frame, no offset, no framewidth
- \boxhasframefalse
+ \ifx\p_framed_frame\v!overlay % no frame, no offset, no framewidth
+ \setfalse\c_framed_has_frame
\let\localoffset\v!overlay
- \else\ifx\@@localframing\v!none % no frame, no framewidth
- \boxhasframefalse
+ \else\ifx\p_framed_frame\v!none % no frame, no framewidth
+ \setfalse\c_framed_has_frame
\else
- \boxhasframetrue
+ \settrue\c_framed_has_frame
\fi\fi
- \ifboxhasframe
- \edef\framedrulethickness{\framedparameter\c!rulethickness}%
- \ifx\framedrulethickness\empty\else
- \ruledlinewidth\framedrulethickness\relax
- \ifinheritruledlinewidth\linewidth\ruledlinewidth\fi
+ \ifconditional\c_framed_has_frame
+ \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}%
+ \ifx\p_framed_rulethickness\empty\else
+ \d_framed_linewidth\p_framed_rulethickness\relax
\fi
\else
- \ruledlinewidth\zeropoint
+ \d_framed_linewidth\zeropoint
\fi
\ifx\localformat\empty
- \boxhasformatfalse
+ \setfalse\c_framed_has_format
\else
- \boxhasformattrue
+ \settrue\c_framed_has_format
\dosetraggedcommand\localformat % not that fast
- \edef\dobeforeframedbox{\raggedtopcommand\framedparameter\c!top}%
- \edef\doafterframedbox {\framedparameter\c!bottom\raggedbottomcommand}%
\fi
\ifx\localoffset\v!none
- \boxhasoffsetfalse
- \boxhasstrutfalse
- \boxisoverlaidfalse
- \@@localoffset\ruledlinewidth
+ \setfalse\c_framed_has_offset
+ \setfalse\c_framed_has_strut
+ \setfalse\c_framed_is_overlaid
+ \d_framed_local_offset\d_framed_linewidth
\else\ifx\localoffset\v!overlay
- % \ifx\@@localframing\v!no \boxhasframefalse \fi % test first
- \boxhasoffsetfalse
- \boxhasstrutfalse
- \boxisoverlaidtrue
- \@@localoffset\zeropoint
+ % \ifx\p_framed_frame\v!no \setfalse\c_framed_has_frame \fi % test first
+ \setfalse\c_framed_has_offset
+ \setfalse\c_framed_has_strut
+ \settrue \c_framed_is_overlaid
+ \d_framed_local_offset\zeropoint
% \else\ifx\localoffset\v!strut
-% \boxhasoffsetfalse
-% \boxhasstruttrue
-% \boxisoverlaidtrue
-% \@@localoffset\zeropoint
+% \setfalse\c_framed_has_offset
+% \settrue \c_framed_has_strut
+% \settrue \c_framed_is_overlaid
+% \d_framed_local_offset\zeropoint
\else
- \boxhasoffsettrue
- \boxhasstruttrue
- \boxisoverlaidfalse
+ \settrue \c_framed_has_offset
+ \settrue \c_framed_has_strut
+ \setfalse\c_framed_is_overlaid
\ifx\localoffset\v!default % new per 2-6-2000
\let\localoffset\defaultframeoffset
- %\expandafter\let\csname\@@framed\c!offset\endcsname\defaultframeoffset
- \letframedparameter\c!offset\defaultframeoffset
+ \letframedparameter\c!offset\defaultframeoffset % brrr
\else
\let\defaultframeoffset\localoffset
\fi
- \@@localoffset\dimexpr\localoffset+\ruledlinewidth\relax
+ \d_framed_local_offset\dimexpr\localoffset+\d_framed_linewidth\relax
\fi\fi % \fi
- \!!framedheight\zeropoint
- \!!framedwidth \zeropoint
+ \d_framed_height\zeropoint
+ \d_framed_width \zeropoint
\ifx\localwidth\empty % fallback to fit
- \ifboxhasformat
- \boxhaswidthtrue
- \!!framedwidth\hsize
+ \ifconditional\c_framed_has_format
+ \settrue\c_framed_has_width
+ \d_framed_width\hsize
\else
- \boxhaswidthfalse
+ \setfalse\c_framed_has_width
\fi
\else\ifx\localwidth\v!fit
- \ifboxhasformat
- \boxhaswidthtrue
- \!!framedwidth\hsize
+ \ifconditional\c_framed_has_format
+ \settrue\c_framed_has_width
+ \d_framed_width\hsize
\else
- \boxhaswidthfalse
+ \setfalse\c_framed_has_width
\fi
\else\ifx\localwidth\v!fixed % equals \v!fit but no shapebox
- \ifboxhasformat
- \boxhaswidthtrue
- \!!framedwidth\hsize
+ \ifconditional\c_framed_has_format
+ \settrue\c_framed_has_width
+ \d_framed_width\hsize
\else
- \boxhaswidthfalse
+ \setfalse\c_framed_has_width
\fi
\else\ifx\localwidth\v!broad
- \boxhaswidthtrue
- \!!framedwidth\hsize
+ \settrue\c_framed_has_width
+ \d_framed_width\hsize
\else\ifx\localwidth\v!local
- \boxhaswidthtrue
+ \settrue\c_framed_has_width
\setlocalhsize
- \!!framedwidth\localhsize
+ \d_framed_width\localhsize
\else
- \boxhaswidthtrue
- \!!framedwidth\localwidth
+ \settrue\c_framed_has_width
+ \d_framed_width\localwidth
\fi\fi\fi\fi\fi
\ifx\localheight\empty % fallback to fit
- \boxhasheightfalse
+ \setfalse\c_framed_has_height
\else\ifx\localheight\v!fit
- \boxhasheightfalse % no longer: \boxhasstrutfalse
+ \setfalse\c_framed_has_height
\else\ifx\localheight\v!broad
- \boxhasheightfalse
+ \setfalse\c_framed_has_height
\else
- \boxhasheighttrue
- \!!framedheight\localheight
+ \settrue\c_framed_has_height
+ \d_framed_height\localheight
\fi\fi\fi
- \ifboxhasheight
+ \ifconditional\c_framed_has_height
% obey user set height, also downward compatible
\else
- \edef\@@framedlines{\framedparameter\c!lines}%
- \ifx\@@framedlines\empty\else
- \ifcase\@@framedlines\else
- \!!framedheight\@@framedlines\lineheight
- \edef\localheight{\the\!!framedheight}%
- \boxhasheighttrue
+ \edef\p_framed_lines{\framedparameter\c!lines}%
+ \ifx\p_framed_lines\empty\else
+ \ifcase\p_framed_lines\else
+ \d_framed_height\p_framed_lines\lineheight
+ \edef\localheight{\the\d_framed_height}%
+ \settrue\c_framed_has_height
\fi
\fi
\fi
% this is now an option: width=local
%
- % \ifdim\!!framedwidth=\hsize
+ % \ifdim\d_framed_width=\hsize
% \parindent\zeropoint
% \setlocalhsize
- % \!!framedwidth\localhsize
+ % \d_framed_width\localhsize
% \fi
% i.e. disable (colsetbackgroundproblemintechniek)
- \advance\!!framedwidth -2\@@localoffset
- \advance\!!framedheight -2\@@localoffset
+ \advance\d_framed_width -2\d_framed_local_offset
+ \advance\d_framed_height -2\d_framed_local_offset
\ifx\localstrut\v!no
- \boxhasstrutfalse
+ \setfalse\c_framed_has_strut
\else\ifx\localstrut\v!global
\setstrut
\else\ifx\localstrut\v!local
@@ -1114,7 +1109,7 @@
\else
\setstrut
\fi\fi\fi
- \ifboxhasstrut
+ \ifconditional\c_framed_has_strut
\let\localbegstrut\begstrut
\let\localendstrut\endstrut
\let\localstrut \strut
@@ -1122,12 +1117,12 @@
\let\localbegstrut\pseudobegstrut % was: \relax
\let\localendstrut\pseudoendstrut % was: \relax
\let\localstrut \pseudostrut % was: \relax
- %\ifboxhasheight\ifdim\!!framedheight<\strutht % saveguard
+ %\ifconditional\c_framed_has_height\ifdim\d_framed_height<\strutht % saveguard
% \let\localbegstrut\relax % but not that
% \let\localstrut \relax % save after all
%\fi\fi
\fi
- \ifx\@@localautostrut\v!yes
+ \ifx\p_framed_autostrut\v!yes
\let\delayedbegstrut\relax
\let\delayedendstrut\relax
\let\delayedstrut \relax
@@ -1139,64 +1134,66 @@
\let\localendstrut \relax
\let\localstrut \relax
\fi
- \ifboxhasheight
- \let\\\vboxednewline
- \ifboxhaswidth
- \let\hairline\vboxedhairline
- \ifboxhasformat
- \let\next\doformatboxSomeFormat
+ \ifconditional\c_framed_has_height
+ \let\\\framed_vboxed_newline
+ \ifconditional\c_framed_has_width
+ \let\hairline\framed_vboxed_hairline
+ \ifconditional\c_framed_has_format
+ \let\next\framed_format_format_yes
\else
- \let\next\doformatboxNoFormat
+ \let\next\framed_format_format_nop
\fi
\else
- \let\hairline\hboxedhairline
- \ifboxhasformat
- \let\next\doformatboxHeight
+ \let\hairline\framed_hboxed_hairline
+ \ifconditional\c_framed_has_format
+ \let\next\framed_format_format_height
\else
- \let\next\doformatboxVSize
+ \let\next\framed_format_format_vsize
\fi
\fi
\else
- \ifboxhaswidth
- \ifboxhasformat
- \let\hairline\vboxedhairline
- \let\\\vboxednewline
- \let\next\doformatboxWidth
+ \ifconditional\c_framed_has_width
+ \ifconditional\c_framed_has_format
+ \let\hairline\framed_vboxed_hairline
+ \let\\\framed_vboxed_newline
+ \let\next\framed_format_format_width
\else
- \let\hairline\hboxedhairline
- \let\\\hboxednewline
- \let\next\doformatboxHSize
+ \let\hairline\framed_hboxed_hairline
+ \let\\\framed_hboxed_newline
+ \let\next\framed_format_format_hsize
\fi
\else
- \let\hairline\hboxedhairline
- \let\\\hboxednewline
- \let\next\doformatboxNoSize
+ \let\hairline\framed_hboxed_hairline
+ \let\\\framed_hboxed_newline
+ \let\next\framed_format_format_no_size
\fi
\fi
- \setextraframedoffsets
- \edef\framedbackground{\framedparameter\c!background}%
- \ifx\framedbackground\empty
- \let\framedforgetall\forgetall
+ \framed_check_extra_offsets
+ \edef\p_framed_background{\framedparameter\c!background}%
+ \ifx\p_framed_background\empty
+ \let\framed_forgetall\forgetall
\else
- \let\framedforgetall\relax
+ \let\framed_forgetall\relax
\forgetall
\fi
- \edef\framedwidth {\ifdim\!!framedwidth >\zeropoint\the\!!framedwidth \else\!!zeropoint\fi}% a new feature, visible for user
- \edef\framedheight{\ifdim\!!framedheight>\zeropoint\the\!!framedheight\else\!!zeropoint\fi}% a new feature, visible for user
- \edef\framedoffset{\the\dimexpr\ifboxhasoffset\localoffset\else\zeropoint\fi}%
- \@@startframedorientation
- \afterassignment\dodowithframebox
- \setbox\framebox\next}
+ \edef\framedwidth {\ifdim\d_framed_width >\zeropoint\the\d_framed_width \else\!!zeropoint\fi}% a new feature, visible for user
+ \edef\framedheight{\ifdim\d_framed_height>\zeropoint\the\d_framed_height\else\!!zeropoint\fi}% a new feature, visible for user
+ \edef\framedoffset{\the\dimexpr\ifconditional\c_framed_has_offset\localoffset\else\zeropoint\fi}%
+ \ifx\p_framed_orientation\empty
+ \let\framed_stop_orientation\relax
+ \else
+ \framed_start_orientation
+ \fi
+ \afterassignment\framed_restart
+ \setbox\b_framed_normal\next}
-\def\dowithframebox
- {% moved : \let\postprocessframebox\relax
- \finishlocalframed}
+\let\framed_stop_orientation\relax
-\def\dodowithframebox
- {\aftergroup\dowithframebox}
+\def\framed_restart
+ {\aftergroup\framed_finish}
-\let\doafterframedbox \relax
-\let\dobeforeframedbox\relax
+\def\framed_do_top {\raggedtopcommand\framedparameter\c!top}
+\def\framed_do_bottom{\framedparameter\c!bottom\raggedbottomcommand}
%D Carefull analysis of this macro will learn us that not all
%D branches in the last conditionals can be encountered, that
@@ -1247,134 +1244,146 @@
%D ...,bottom=\kern0pt,...
%D \stoptyping
-% experiment ... \@@localfranalyze -> we could support 'first' as location key
+% experiment ... \p_framed_franalyze -> we could support 'first' as location key
% option but then we will always do an analysis and reimplement the location
% options (btw, beware of location settings of derived functionality that bleed
% into this
-\def\finishlocalframeda
+\def\framed_finish_a
{\ifreshapeframebox
- \doreshapeframedbox
- \else\ifx\@@localfranalyze\v!yes
- \doanalyzeframedbox
+ \framed_reshape_process
+ \else\ifx\p_framed_franalyze\v!yes
+ \framed_reshape_analyze
\else
- \resetshapeframebox
+ \framed_reshape_reset
\fi\fi
- \boxhaswidthfalse}
+ \setfalse\c_framed_has_width}
-\def\finishlocalframedb
- {\ifx\@@localfranalyze\v!yes
- \doanalyzeframedbox
+\def\framed_finish_b
+ {\ifx\p_framed_franalyze\v!yes
+ \framed_reshape_analyze
\else
- \resetshapeframebox
+ \framed_reshape_reset
\fi
- \boxhaswidthfalse}
+ \setfalse\c_framed_has_width}
-\def\finishlocalframedc
- {\ifx\@@localfranalyze\v!yes
- \doanalyzeframedbox
+\def\framed_finish_c
+ {\ifx\p_framed_franalyze\v!yes
+ \framed_reshape_analyze
\else
- \resetshapeframebox
+ \framed_reshape_reset
\fi}
-\unexpanded\def\finishlocalframed
+\unexpanded\def\framed_finish
{\dontshowcomposition
- \@@stopframedorientation % hm, wrong place ! should rotate the result (after reshape)
- \handleframedlocator\c!before\@@locallocation
- \ifboxhasformat
- \ifx\@@localautowidth\v!force
- \finishlocalframeda
+ \framed_stop_orientation % hm, wrong place ! should rotate the result (after reshape)
+ \framed_locator_before\p_framed_location
+ \ifconditional\c_framed_has_format
+ \ifx\p_framed_autowidth\v!force
+ \framed_finish_a
\else\ifx\localwidth\v!fit
- \ifx\@@localautowidth\v!yes
- \finishlocalframeda
+ \ifx\p_framed_autowidth\v!yes
+ \framed_finish_a
\else
- \finishlocalframedb
+ \framed_finish_b
\fi
\else\ifx\localwidth\v!fixed
- \finishlocalframedb
+ \framed_finish_b
\else
- \finishlocalframedc
+ \framed_finish_c
\fi\fi\fi
\ifconditional\boxcontentneedsprocessing
- \mkdoprocessboxcontents\framebox
+ \mkdoprocessboxcontents\b_framed_normal
\fi
\else
- \finishlocalframedc
+ \framed_finish_c
\fi
- \ifboxhaswidth
- \wd\framebox\!!framedwidth
+ \ifconditional\c_framed_has_width
+ \wd\b_framed_normal\d_framed_width
\fi
- \ifboxhasheight
- \ht\framebox\!!framedheight
+ \ifconditional\c_framed_has_height
+ \ht\b_framed_normal\d_framed_height
\fi
- \doif{\framedparameter\c!empty}\v!yes\dosetfakedframebox
- \ifboxhasextraoffset
- \applyextraframedoffsets
+ \edef\p_framed_empty{\framedparameter\c!empty}%
+ \ifx\p_framed_empty\v!yes
+ \framed_fake_box
\fi
- \ifboxhasoffset
- \dooffsetframebox
+ %
+ \d_framed_applied_offset
+ \ifconditional\c_framed_is_overlaid
+ \zeropoint
+ \else
+ \d_framed_linewidth
+ \fi
+ \ifconditional\c_framed_has_offset
+ \advance\d_framed_applied_offset\localoffset
\fi
- \ifboxisoverlaid \else
- \dolocateframebox
+ \ifconditional\c_framed_has_extra_offset
+ \framed_apply_extra_offsets % includes \d_framed_applied_offset
+ \else
+ \ifzeropt\d_framed_applied_offset
+ \else
+ \framed_widen_box
+ \fi
\fi
+ %
\ifx\postprocessframebox\relax \else
\let\next\postprocessframebox
\let\postprocessframebox\relax % prevent nesting
- \next\framebox
+ \next\b_framed_normal
\fi
\iftrialtypesetting
% new
\else
- \ifboxhasframe % real or invisible frame
- \dooutlinebox
+ \ifconditional\c_framed_has_frame % real or invisible frame
+ \framed_add_outline
\fi
- \ifx\framedbackground\empty \else
- \dobackedbox
+ \ifx\p_framed_background\empty \else
+ \edef\p_framed_component{\framedparameter\c!component}%
+ \framed_add_background
\fi
\fi
- \handleframedlocator\c!after\@@locallocation
- \box\framebox
+ \framed_locator_after\p_framed_location
+ \box\b_framed_normal
\global\frameddimensionstate % global so to be used directly afterwards !
- \ifboxhaswidth
- \ifboxhasheight \plusthree \else \plusone \fi
+ \ifconditional\c_framed_has_width
+ \ifconditional\c_framed_has_height \plusthree \else \plusone \fi
\else
- \ifboxhasheight \plustwo \else \zerocount \fi
+ \ifconditional\c_framed_has_height \plustwo \else \zerocount \fi
\fi
\egroup
\egroup}
\newconstant\frameddimensionstate % global state: 0=unknown 1=width 2=height 3=both
-\def\dosetfakedframebox
+\def\framed_fake_box
{\setbox\scratchbox\emptyhbox
- \wd\scratchbox\wd\framebox
- \ht\scratchbox\ht\framebox
- \dp\scratchbox\dp\framebox
- \setbox\framebox\box\scratchbox}
-
-% test: (saves one forgetall)
-%
-% \edef\framedbackground{\framedparameter\c!background}%
-% \ifx\framedbackground\empty
-% \let\framedforgetall\forgetall
-% \else
-% \let\framedforgetall\relax
-% \forgetall
-% \fi
+ \wd\scratchbox\wd\b_framed_normal
+ \ht\scratchbox\ht\b_framed_normal
+ \dp\scratchbox\dp\b_framed_normal
+ \setbox\b_framed_normal\box\scratchbox}
\def\installframedlocator#1#2#3%
- {\setvalue{\??oi:\c!location:\c!before:#1}{#2}%
- \setvalue{\??oi:\c!location:\c!after :#1}{#3}}
+ {\setvalue{\??hf:b:#1}{#2}%
+ \setvalue{\??hf:a:#1}{#3}}
+
+\def\framed_locator_before#1%
+ {\csname\??hf:b:#1\endcsname}
-\def\handleframedlocator#1#2%
- {\csname\??oi:\c!location:#1:#2\endcsname}
+\def\framed_locator_after#1%
+ {\csname\??hf:a:#1\endcsname}
+
+\newdimen\d_framed_locator_ht
+\newdimen\d_framed_locator_dp
\def\doprelocframedbox#1%
- {\scratchdimen\dimexpr#1+\ruledlinewidth\relax
- \ifboxhasoffset
- \advance\scratchdimen \framedparameter\c!offset
- \fi
- \scratchskip\dimexpr\ht\framebox-\scratchdimen\relax}
+ {\d_framed_locator_ht\dimexpr
+ #1+\d_framed_linewidth
+ \ifconditional\c_framed_has_offset
+ +\framedparameter\c!offset
+ \fi
+ \relax
+ \d_framed_locator_dp\dimexpr\ht\b_framed_normal-\d_framed_locator_ht\relax}
% \ruledhbox
% {A
@@ -1400,99 +1409,100 @@
\installframedlocator \v!hanging % best with strut=no
{}
- {\dp\framebox\ht\framebox
- \ht\framebox\zeropoint}
+ {\dp\b_framed_normal\ht\b_framed_normal
+ \ht\b_framed_normal\zeropoint}
\installframedlocator \v!depth
{}
- {\ht\framebox\dimexpr\ht\framebox-\strutdp\relax
- \dp\framebox\strutdp
- \box\framebox}
+ {\ht\b_framed_normal\dimexpr\ht\b_framed_normal-\strutdp\relax
+ \dp\b_framed_normal\strutdp
+ \box\b_framed_normal}
\installframedlocator \v!height
{}
- {\dp\framebox\dimexpr\ht\framebox-\strutht\relax
- \ht\framebox\strutht
- \box\framebox}
+ {\dp\b_framed_normal\dimexpr\ht\b_framed_normal-\strutht\relax
+ \ht\b_framed_normal\strutht
+ \box\b_framed_normal}
\installframedlocator \v!high
{}
{\doprelocframedbox\strutht
- \setbox\framebox\hbox{\lower\scratchskip\box\framebox}%
- \ht\framebox\strutht
- \dp\framebox\strutdp
- \hbox{\box\framebox}}
+ \setbox\b_framed_normal\hbox{\lower\d_framed_locator_dp\box\b_framed_normal}%
+ \ht\b_framed_normal\strutht
+ \dp\b_framed_normal\strutdp
+ \hbox{\box\b_framed_normal}}
\installframedlocator \v!line
{}
- {\setbox\framebox\hbox{\lower.5\ht\framebox\box\framebox}%
- \ht\framebox.5\lineheight
- \dp\framebox.5\lineheight
- \hbox{\box\framebox}}
+ {\setbox\b_framed_normal\hbox{\lower.5\ht\b_framed_normal\box\b_framed_normal}%
+ \ht\b_framed_normal.5\lineheight
+ \dp\b_framed_normal.5\lineheight
+ \hbox{\box\b_framed_normal}}
\installframedlocator \v!low
{}
{\doprelocframedbox\strutdp
- \setbox\framebox\hbox{\lower\scratchdimen\box\framebox}%
- \ht\framebox\strutht
- \dp\framebox\strutdp
- \box\framebox}
+ \setbox\b_framed_normal\hbox{\lower\d_framed_locator_ht\box\b_framed_normal}%
+ \ht\b_framed_normal\strutht
+ \dp\b_framed_normal\strutdp
+ \box\b_framed_normal}
\installframedlocator \v!top
{}
{\doprelocframedbox\strutht
- \setbox\framebox\hbox{\lower\scratchskip\box\framebox}%
- \ht\framebox\scratchdimen
- \dp\framebox\scratchskip
- \hbox{\box\framebox}}
+ \setbox\b_framed_normal\hbox{\lower\d_framed_locator_dp\box\b_framed_normal}%
+ \ht\b_framed_normal\d_framed_locator_ht
+ \dp\b_framed_normal\d_framed_locator_dp
+ \hbox{\box\b_framed_normal}}
\installframedlocator \v!middle
{}
- {\scratchdimen.5\ht\framebox
- \setbox\framebox\hbox{\lower\scratchdimen\box\framebox}%
- \ht\framebox\scratchdimen
- \dp\framebox\scratchdimen
- \hbox{\box\framebox}}
+ {\scratchdimen.5\ht\b_framed_normal
+ \setbox\b_framed_normal\hbox{\lower\scratchdimen\box\b_framed_normal}%
+ \ht\b_framed_normal\d_framed_locator_ht
+ \dp\b_framed_normal\d_framed_locator_ht
+ \hbox{\box\b_framed_normal}}
\installframedlocator \v!lohi
- {\handleframedlocator\c!before\v!middle}
- {\handleframedlocator\c!after \v!middle}
+ {\framed_locator_before\v!middle}
+ {\framed_locator_after \v!middle}
\installframedlocator \v!bottom
{}
{\doprelocframedbox\strutdp
- \setbox\framebox\hbox{\lower\scratchdimen\box\framebox}%
- \ht\framebox\scratchskip
- \dp\framebox\scratchdimen
- \hbox{\box\framebox}}
+ \setbox\b_framed_normal\hbox{\lower\d_framed_locator_ht\box\b_framed_normal}%
+ \ht\b_framed_normal\d_framed_locator_dp
+ \dp\b_framed_normal\d_framed_locator_ht
+ \hbox{\box\b_framed_normal}}
\installframedlocator \v!keep % retains height/depth
- {\removeframedboxdepth}
- {\restoreframedboxdepth}
+ {\framed_remove_depth}
+ {\framed_restore_depth}
% also used in fastlocalframed
-\newdimen\originalframedwd
-\newdimen\originalframedht
-\newdimen\originalframeddp
-
-\def\removeframedboxdepth
- {\originalframedwd\wd\framebox
- \originalframedht\ht\framebox
- \originalframeddp\dp\framebox
- \ifzeropt\originalframeddp\else\setbox\framebox\hbox{\raise\originalframeddp\box\framebox}\fi
- \wd\framebox\originalframedwd
- \ht\framebox\dimexpr\originalframedht+\originalframeddp\relax
- \dp\framebox\zeropoint}
+\newdimen\d_framed_original_wd
+\newdimen\d_framed_original_ht
+\newdimen\d_framed_original_dp
-\def\restoreframedboxdepth
- {\ifzeropt\originalframeddp\else\setbox\framebox\hbox{\lower\originalframeddp\box\framebox}\fi
- \wd\framebox\originalframedwd
- \ht\framebox\originalframedht
- \dp\framebox\originalframeddp}
+\def\framed_remove_depth
+ {\d_framed_original_wd\wd\b_framed_normal
+ \d_framed_original_ht\ht\b_framed_normal
+ \d_framed_original_dp\dp\b_framed_normal
+ \ifzeropt\d_framed_original_dp\else
+ \setbox\b_framed_normal\hbox{\raise\d_framed_original_dp\box\b_framed_normal}%
+ \fi
+ \wd\b_framed_normal\d_framed_original_wd
+ \ht\b_framed_normal\dimexpr\d_framed_original_ht+\d_framed_original_dp\relax
+ \dp\b_framed_normal\zeropoint}
-% \let\@@startframedorientation\relax
-% \let\@@stopframedorientation \relax
+\def\framed_restore_depth
+ {\ifzeropt\d_framed_original_dp \else
+ \setbox\b_framed_normal\hbox{\lower\d_framed_original_dp\box\b_framed_normal}%
+ \fi
+ \wd\b_framed_normal\d_framed_original_wd
+ \ht\b_framed_normal\d_framed_original_ht
+ \dp\b_framed_normal\d_framed_original_dp}
% \framed[width=12cm,height=3cm,orientation=0]{\input ward\relax}
% \framed[width=12cm,height=3cm,orientation=90]{\input ward\relax}
@@ -1502,40 +1512,45 @@
% \framed[width=12cm,height=3cm,orientation=-180]{\input ward\relax}
% \framed[width=12cm,height=3cm,orientation=-270]{\input ward\relax}
-\def\@@startframedorientation
- {\let\@@stopframedorientation \relax
- \ifx\@@localorientation\empty\else
- \ifcase\@@localorientation\else
- \scratchcounter\@@localorientation
- \divide\scratchcounter\plustwo
- \ifodd\scratchcounter
- \swapmacros\framedwidth \framedheight
- \swapmacros\localwidth \localheight
- \swapdimens\!!framedheight\!!framedwidth
- \def\@@stopframedorientation{\@@dostopframedorientation\plusone}%
- \else
- \def\@@stopframedorientation{\@@dostopframedorientation\zerocount}%
- \fi
+\def\framed_start_orientation
+ {\ifcase\p_framed_orientation\else
+ \let\framed_stop_orientation\relax
+ \else
+ \scratchcounter\p_framed_orientation % weird .. why
+ \divide\scratchcounter\plustwo
+ \ifodd\scratchcounter
+ \swapmacros\framedwidth\framedheight
+ \swapmacros\localwidth\localheight
+ \swapdimens\d_framed_height\d_framed_width
+ \let\framed_stop_orientation\framed_stop_orientation_odd
+ \else
+ \let\framed_stop_orientation\framed_stop_orientation_even
\fi
\fi}
-\def\@@dostopframedorientation#1%
- {\ifcase#1\else
- \swapmacros\framedwidth \framedheight
- \swapmacros\localwidth \localheight
- \swapdimens\!!framedheight\!!framedwidth
- \fi
- \setbox\framebox\hbox{\dorotatebox\@@localorientation\hbox{\box\framebox}}}
+\def\framed_stop_orientation_odd
+ {\swapmacros\framedwidth\framedheight
+ \swapmacros\localwidth\localheight
+ \swapdimens\d_framed_height\d_framed_width
+ \framed_stop_orientation_even}
+
+\def\framed_stop_orientation_even
+ {\setbox\b_framed_normal\hbox{\dorotatebox\p_framed_orientation\hbox{\box\b_framed_normal}}}
%D The last conditional takes care of the special situation of
%D in||line \inframed[height=3cm]{framed} boxes. Such boxes have
%D to be \inframed{aligned} with the running text.
-\def\doinframed[#1]% we could omit #1] but readibility ...
- {\framed[\c!location=\v!low,#1]}
-
\unexpanded\def\inframed
- {\dosingleempty\doinframed}
+ {\dosingleempty\framed_inline}
+
+% \def\framed_inline[#1]%
+% {\framed[\c!location=\v!low,#1]}
+%
+% or:
+
+\def\framed_inline[%
+ {\framed[\c!location=\v!low,}
%D When we set \type{empty} to \type{yes}, we get
%D ourselves a frame and/or background, but no content, so
@@ -1581,26 +1596,27 @@
%D Still better is the next alternative, if only because it
%D takes care of setting the super- and subscripts styles
-\newcount\mframedstyle
+\newcount\c_framed_mstyle
+
+\unexpanded\def\mframed {\dosingleempty\framed_math_display}
+\unexpanded\def\inmframed{\dosingleempty\framed_math_inline }
-\def\doinlinemframed[#1]#2%
+\def\framed_math_inline[#1]#2%
{\begingroup
- \mframedstyle\mathstyle\relax
- \inframed[#1]{\Ustartmath\triggermathstyle\mframedstyle#2\Ustopmath}%
+ \c_framed_mstyle\mathstyle
+ \inframed[#1]{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
\endgroup}
-\def\funnymathstrut{\Ustartmath\triggermathstyle\mframedstyle\vphantom{(}\Ustopmath}
+\unexpanded\def\funnymathstrut
+ {\Ustartmath\triggermathstyle\c_framed_mstyle\vphantom{(}\Ustopmath}
-\def\dodisplaymframed[#1]#2%
+\def\framed_math_display[#1]#2%
{\begingroup
- \mframedstyle\mathstyle\relax
+ \c_framed_mstyle\mathstyle
\let\normalstrut\funnymathstrut
- \framed[#1]{\Ustartmath\triggermathstyle\mframedstyle#2\Ustopmath}%
+ \framed[#1]{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
\endgroup}
-\def\mframed {\dosingleempty\dodisplaymframed}
-\def\inmframed{\dosingleempty\doinlinemframed }
-
%D So instead of the rather versatile \type {\framed}, we ue
%D the \type {\mframed}.
%D
@@ -1645,12 +1661,44 @@
%D putting rules around boxes, inserting offsets and aligning
%D text. Each step is handled by separate macros.
-\def\dowidenframebox#1%
- {\setbox\framebox\vbox
- {\kern#1\hbox{\kern#1\box\framebox\kern#1}\kern#1}}
+\newdimen\d_framed_applied_offset
+\newdimen\d_framed_loffset
+\newdimen\d_framed_roffset
+\newdimen\d_framed_toffset
+\newdimen\d_framed_boffset
+
+\def\framed_check_extra_offsets
+ {\setfalse\c_framed_has_extra_offset
+ \d_framed_loffset\framedparameter\c!loffset
+ \d_framed_roffset\framedparameter\c!roffset
+ \d_framed_toffset\framedparameter\c!toffset
+ \d_framed_boffset\framedparameter\c!boffset
+ \relax
+ \ifzeropt\d_framed_loffset\else \advance\d_framed_width -\d_framed_loffset \settrue\c_framed_has_extra_offset \fi
+ \ifzeropt\d_framed_roffset\else \advance\d_framed_width -\d_framed_roffset \settrue\c_framed_has_extra_offset \fi
+ \ifzeropt\d_framed_toffset\else \advance\d_framed_height-\d_framed_toffset \settrue\c_framed_has_extra_offset \fi
+ \ifzeropt\d_framed_boffset\else \advance\d_framed_height-\d_framed_boffset \settrue\c_framed_has_extra_offset \fi}
+
+\def\framed_apply_extra_offsets
+ {\setbox\b_framed_normal\vbox\bgroup
+ \advance\d_framed_toffset\d_framed_applied_offset
+ \advance\d_framed_boffset\d_framed_applied_offset
+ \advance\d_framed_loffset\d_framed_applied_offset
+ \advance\d_framed_roffset\d_framed_applied_offset
+ \kern\d_framed_toffset
+ \hbox\bgroup
+ \kern\d_framed_loffset
+ \box\b_framed_normal
+ \kern\d_framed_roffset
+ \egroup
+ \kern\d_framed_boffset
+ \egroup}
-\def\dooffsetframebox{\dowidenframebox\localoffset}
-\def\dolocateframebox{\dowidenframebox\ruledlinewidth}
+\def\framed_widen_box
+ {\setbox\b_framed_normal\vbox
+ {\kern\d_framed_applied_offset
+ \hbox{\kern\d_framed_applied_offset\box\b_framed_normal\kern\d_framed_applied_offset}%
+ \kern\d_framed_applied_offset}}
%D Let's hope that the next few examples show us enough of
%D what needs to be done by the auxiliary macros.
@@ -1736,9 +1784,6 @@
\expandafter\nodoformatonelinerbox
\fi}
-% \def\dodoformatonelinerbox % we could even have a special one
-% {\dowithnextboxcontentcs\ignorespaces\dododoformatonelinerbox\hbox}
-
\def\dodoformatonelinerbox
{\afterassignment\redoformatonelinerbox
\setbox\nextbox\hbox}
@@ -1759,45 +1804,60 @@
%D The handlers:
-\def\framedforgetall{\forgetall}
+\def\framed_forgetall{\forgetall}
-\def\setframedforegroundcolor
- {\edef\!!framedforegroundcolor{\framedparameter\c!foregroundcolor}%
- \ifx\!!framedforegroundcolor\empty\else\dousecolorparameter\!!framedforegroundcolor\fi}
+% test: (saves one forgetall)
+%
+% \edef\framedbackground{\framedparameter\c!background}%
+% \ifx\framedbackground\empty
+% \let\framed_forgetall\forgetall
+% \else
+% \let\framed_forgetall\relax
+% \forgetall
+% \fi
+
+\def\framed_set_foregroundcolor
+ {\edef\p_framed_foregroundcolor{\framedparameter\c!foregroundcolor}%
+ \ifx\p_framed_foregroundcolor\empty\else\dousecolorparameter\p_framed_foregroundcolor\fi}
+
+\def\framed_do_setups
+ {\ifx\p_framed_setups\empty \else
+ \setups[\p_framed_setups]%
+ \fi}
-\def\doformatboxSomeFormat
- {\vbox to \!!framedheight
+\def\framed_format_format_yes
+ {\vbox to \d_framed_height
\bgroup
\let\postprocessframebox\relax
- \framedforgetall
+ \framed_forgetall
\iftrialtypesetting \else
- \setframedforegroundcolor
+ \framed_set_foregroundcolor
\fi
\oninterlineskip
- \hsize\!!framedwidth
- \vsize\!!framedheight
- \doframedsetups
+ \hsize\d_framed_width
+ \vsize\d_framed_height
+ \framed_do_setups
\raggedcommand
- \dobeforeframedbox
+ \framed_do_top
\bgroup
\localbegstrut
\aftergroup\localendstrut
- \aftergroup\doafterframedbox
+ \aftergroup\framed_do_bottom
\aftergroup\egroup
\doformatonelinerbox}
-\def\doformatboxNoFormat
- {\vbox to \!!framedheight
+\def\framed_format_format_nop
+ {\vbox to \d_framed_height
\bgroup
\let\postprocessframebox\relax
- \framedforgetall
+ \framed_forgetall
\iftrialtypesetting \else
- \setframedforegroundcolor
+ \framed_set_foregroundcolor
\fi
\oninterlineskip
- \hsize\!!framedwidth
- \vsize\!!framedheight
- \doframedsetups
+ \hsize\d_framed_width
+ \vsize\d_framed_height
+ \framed_do_setups
\raggedcenter
\vss
\bgroup
@@ -1807,16 +1867,16 @@
\aftergroup\egroup
\doformatonelinerbox}
-\def\doformatboxHeight
- {\vbox to \!!framedheight
+\def\framed_format_format_height
+ {\vbox to \d_framed_height
\bgroup
\let\postprocessframebox\relax
- \framedforgetall
+ \framed_forgetall
\iftrialtypesetting \else
- \setframedforegroundcolor
+ \framed_set_foregroundcolor
\fi
\oninterlineskip
- \doframedsetups
+ \framed_do_setups
\raggedcommand
\vss
\bgroup
@@ -1826,36 +1886,36 @@
\localbegstrut
\doformatonelinerbox}
-\def\doformatboxWidth
+\def\framed_format_format_width
{\vbox
\bgroup
\let\postprocessframebox\relax
- \framedforgetall
+ \framed_forgetall
\iftrialtypesetting \else
- \setframedforegroundcolor
+ \framed_set_foregroundcolor
\fi
\oninterlineskip
- \hsize\!!framedwidth
- \doframedsetups
+ \hsize\d_framed_width
+ \framed_do_setups
\raggedcommand
- \dobeforeframedbox
+ \framed_do_top
\bgroup
\localbegstrut
\aftergroup\localendstrut
- \aftergroup\doafterframedbox
+ \aftergroup\framed_do_bottom
\aftergroup\egroup
\doformatonelinerbox}
-\def\doformatboxVSize
- {\vbox to \!!framedheight
+\def\framed_format_format_vsize
+ {\vbox to \d_framed_height
\bgroup
\let\postprocessframebox\relax
- \framedforgetall
+ \framed_forgetall
\iftrialtypesetting \else
- \setframedforegroundcolor
+ \framed_set_foregroundcolor
\fi
- \vsize\!!framedheight
- \doframedsetups
+ \vsize\d_framed_height
+ \framed_do_setups
\vss
\bgroup
\aftergroup\vss
@@ -1866,15 +1926,15 @@
\localstrut
\doformatonelinerbox}
-\def\doformatboxHSize
- {\hbox to \!!framedwidth
+\def\framed_format_format_hsize
+ {\hbox to \d_framed_width
\bgroup
\let\postprocessframebox\relax
- \framedforgetall
+ \framed_forgetall
\iftrialtypesetting \else
- \setframedforegroundcolor
+ \framed_set_foregroundcolor
\fi
- \doframedsetups
+ \framed_do_setups
\hss
\localstrut
\bgroup
@@ -1882,19 +1942,17 @@
\aftergroup\egroup
\doformatonelinerbox}
-\def\doformatboxNoSize
+\def\framed_format_format_no_size
{\hbox
\bgroup
\iftrialtypesetting \else
- \setframedforegroundcolor
+ \framed_set_foregroundcolor
\fi
\let\postprocessframebox\relax
- \doframedsetups
+ \framed_do_setups
\localstrut
\doformatonelinerbox}
-\let\doframedsetups\relax
-
%D On the next page we show some examples of how these macros
%D come into action. The examples show us how
%D \type {fit}, \type {broad} dimensions influence the
@@ -1965,7 +2023,7 @@
\newdimen\framedmaxwidth
\newdimen\framedaveragewidth
-\def\resetshapeframebox
+\def\framed_reshape_reset
{\framednoflines \zerocount
\framedfirstheight \zeropoint
\framedlastdepth \zeropoint
@@ -1973,12 +2031,8 @@
\framedmaxwidth \zeropoint
\framedaveragewidth\zeropoint}
-\let\framedboxwidth \!!zeropoint
-\let\framedboxheight\!!zeropoint
-\let\framedboxdepth \!!zeropoint
-
-\def\doreshapeframedbox{\ifvbox\framebox\ctxcommand{doreshapeframedbox(\number\framebox)}\fi}
-\def\doanalyzeframedbox{\ifvbox\framebox\ctxcommand{doanalyzeframedbox(\number\framebox)}\fi}
+\def\framed_reshape_process{\ifvbox\b_framed_normal\ctxcommand{doreshapeframedbox(\number\b_framed_normal)}\fi}
+\def\framed_reshape_analyze{\ifvbox\b_framed_normal\ctxcommand{doanalyzeframedbox(\number\b_framed_normal)}\fi}
% torture test / strange case (much depth) / method 2 needed
%
@@ -2048,41 +2102,6 @@
%D \egroup
%D \stoppostponing
-%D When typesetting the framed box inline, we have to keep the
-%D baseline intact outside as well as inside the framed box.
-
-\def\doinlineframedbox
- {\scratchdimen\dimexpr\strutdp+\ruledlinewidth\relax
- \ifboxhasoffset
- \advance\scratchdimen \framedparameter\c!offset
- \fi
- \setbox\framebox\hbox{\lower\scratchdimen\box\framebox}%
- \ht\framebox\strutht
- \dp\framebox\strutdp
- \box\framebox}
-
-%D We can also lower the box over the natural depth of the
-%D line.
-
-\def\doloweredframedbox
- {\ht\framebox\dimexpr\ht\framebox+\dp\framebox-\strutdp\relax
- \dp\framebox\strutdp
- \box\framebox}
-
-%D Hanging the content is mainly meant for cases like the
-%D following:
-%D
-%D \starttyping
-%D \framed[strut=no]
-%D {\framed[height=2cm,location=hanging]{test}%
-%D \framed[height=1cm,location=hanging]{test}}
-%D \stoptyping
-
-\def\dohangingframedbox % best with strut=no
- {\scratchdimen\dimexpr\ht\framebox+\dp\framebox\relax
- \ht\framebox\zeropoint
- \dp\framebox\scratchdimen}
-
%D We can draw lines from left to right and top to bottom by
%D using the normal \type{\hairline} command. Both directions
%D need a different treatment.
@@ -2103,32 +2122,29 @@
%D possible to the circumstances and act as natural as
%D possible.
-\def\vboxedhairline
+\def\framed_vboxed_hairline
{\bgroup
- \dimen2=\ifboxhasoffset \localoffset \else \zeropoint \fi
- \dimen4=\dimexpr\dimen2+\ruledlinewidth\relax
+ \dimen2=\ifconditional\c_framed_has_offset \localoffset \else \zeropoint \fi
+ \dimen4=\dimexpr\dimen2+\d_framed_linewidth\relax
\setbox0\vbox
{\advance\hsize 2\dimen4
\vskip\dimen2
\hrule
- \!!height\ruledlinewidth
+ \!!height\d_framed_linewidth
\!!depth\zeropoint
\!!width\hsize
\vskip\dimen2}%
- %\endgraf\nointerlineskip\endgraf
- %\moveleft\dimen4\box0
- %\endgraf\nointerlineskip\localbegstrut
\endgraf\obeydepth\nointerlineskip
\moveleft\dimen4\box0
\endgraf\nointerlineskip\localbegstrut % beware, we might kill it in a style using \vskip\lineheight
\egroup} % so this must not be changed
-\def\hboxedhairline % use framed dimen
+\def\framed_hboxed_hairline % use framed dimen
{\bgroup
- \dimen2=\ifboxhasoffset \localoffset \else \zeropoint \fi
- \ifboxhasheight
- \dimen4\dimexpr\localheight/2+\strutdp-2\ruledlinewidth\relax
- \dimen6\dimexpr\localheight/2-\strutdp+2\ruledlinewidth\relax
+ \dimen2=\ifconditional\c_framed_has_offset \localoffset \else \zeropoint \fi
+ \ifconditional\c_framed_has_height
+ \dimen4\dimexpr\localheight/2+\strutdp-2\d_framed_linewidth\relax
+ \dimen6\dimexpr\localheight/2-\strutdp+2\d_framed_linewidth\relax
\else
\dimen4\dimexpr\strutht+\dimen2\relax
\dimen6\dimexpr\strutdp+\dimen2\relax
@@ -2136,7 +2152,7 @@
\unskip
\setbox\scratchbox\hbox
{\hskip\dimen2
- \vrule\!!height\dimen4\!!depth\dimen6\!!width\ruledlinewidth
+ \vrule\!!height\dimen4\!!depth\dimen6\!!width\d_framed_linewidth
\hskip\dimen2}%
\ht\scratchbox\strutht
\dp\scratchbox\strutdp
@@ -2148,10 +2164,10 @@
%D sort of newline signal. In horizontal boxes it expands to a
%D space.
-\unexpanded\def\vboxednewline
+\unexpanded\def\framed_vboxed_newline
{\endgraf\ignorespaces}
-\unexpanded\def\hboxednewline
+\unexpanded\def\framed_hboxed_newline
{\unskip\normalspace\ignorespaces}
%D We can set each rule on or off. The default setting is
@@ -2195,485 +2211,6 @@
%D \egroup
%D \macros
-%D {setupblackrules}
-%D
-%D The graphic capabilities of \TEX\ do not go beyond simple
-%D filled rules, except of course when using specials. Let's
-%D start with a warning: using this commands is far more slower
-%D than using the \TEX\ primitives \type{\hrule} and
-%D \type{\vrule}, but they save us some tokens. The
-%D characteristics of these rule drawing command can be set by:
-%D
-%D \showsetup{setupblackrules}
-
-\unexpanded\def\setupblackrules
- {\dodoubleargument\getparameters[\??bj]}
-
-%D \macros
-%D {blackrule}
-%D
-%D The simple command draws only one rule. Its optional
-%D argument can be used to specify the dimensions. By setting
-%D the width, height or depth to \type {max}, one gets the
-%D natural dimensions.
-%D
-%D \showsetup{blackrule}
-
-\definecomplexorsimple\blackrule
-
-\unexpanded\def\complexblackrule[#1]%
- {\hbox\bgroup\getparameters[\??bj][#1]\domakeblackrule\egroup}
-
-\unexpanded\def\simpleblackrule
- {\hbox\bgroup\domakeblackrule\egroup}
-
-\def\domakeblackrule
- {\doif\@@bjwidth \v!max{\def\@@bjwidth {1em}}%
- \doif\@@bjheight\v!max{\setstrut\let\setstrut\relax\def\@@bjheight{\strutht}}%
- \doif\@@bjdepth \v!max{\setstrut\def\@@bjdepth {\strutdp}}%
- \startcolor[\@@bjcolor]% can be made faster, just direct attr
- \vrule
- \!!width \@@bjwidth
- \!!height\@@bjheight
- \!!depth \@@bjdepth
- \stopcolor}
-
-%D \macros
-%D {blackrules}
-%D
-%D One can call for a sequence of black rules, if needed
-%D equally spaced over the given width.
-%D
-%D \showsetup{blackrules}
-%D
-%D The two alternative calls are therefore:
-%D
-%D \startbuffer
-%D Tell me, is this according to the \blackrules[n=6]?
-%D These \blackrules[alternativevariant=b,n=10,distance=.2em,width=4cm] are quite clear.
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D or:
-%D
-%D \startlines
-%D \getbuffer
-%D \stoplines
-%D
-%D We could of course have implemented this macro using
-%D \type{\leaders}, but this would probably have taken more
-%D tokens.
-
-\def\doblackrules[#1]%
- {\hbox\bgroup
- \getparameters[\??bj][#1]%
- \!!widtha\@@bjwidth
- \!!widthb\@@bjdistance
- \doif\@@bjalternative\c!b
- {\scratchcounter\@@bjn
- \ifnum\scratchcounter=\plusone
- \!!widthb\zeropoint
- \else
- \advance\scratchcounter \minusone
- \advance\!!widtha -\scratchcounter\!!widthb
- \divide \!!widtha \@@bjn
- \fi}%
- \startcolor[\@@bjcolor]%
- \dorecurse\@@bjn
- {\vrule
- \!!width \!!widtha
- \!!height\@@bjheight
- \!!depth \@@bjdepth
- \hskip\!!widthb}%
- \unskip
- \stopcolor
- \egroup}
-
-\unexpanded\def\blackrules
- {\dosingleempty\doblackrules}
-
-%D The next commands can be used to draw margin rules. We
-%D support two methods: \marginrule{one for in||line use} and
-%D one that acts on a paragraph. Drawing a margin rule is
-%D rather straightforward because we can use the commands that
-%D put text in the margin.
-
-\def\dodrawmarginrule
- {\setbox\scratchbox\hbox
- {\vrule\!!depth\strutdepth\!!height\strutheight\!!width\@@karulethickness}%
- \smashbox\scratchbox % no \vsmash !!!
- \box\scratchbox}
-
-\def\drawmarginrule
- {\strut\inleft{\dodrawmarginrule}}
-
-%D \macros
-%D {marginrule}
-%D
-%D The first method gobbles words and simply puts a bar in the
-%D margin. This method is not entirely robust.
-%D
-%D \showsetup{marginrule}
-
-\definecomplexorsimple\marginrule
-
-\def\simplemarginrule
- {\let\processword\drawmarginrule
- \processwords}
-
-\def\complexmarginrule[#1]%
- {\ifnum#1<\@@kalevel\relax \else
- \def\@@kadefaultwidth{#1}%
- \expandafter\simplemarginrule
- \fi}
-
-%D We need an auxiliary variable
-
-\def\@@kadefaultwidth{1}
-
-%D \macros
-%D {setupmarginrules}
-%D
-%D This macro definitions show us that we can pass an optional
-%D level, which is matched against the previous set one. The
-%D level can be set up with
-%D
-%D \showsetup{setupmarginrules}
-
-\unexpanded\def\setupmarginrules
- {\dodoubleargument\getparameters[\??ka]}
-
-%D \macros
-%D {startmarginrule}
-%D
-%D The second method collects text and reformats it afterwards,
-%D using the shapebox macros. We prevent local margin rules.
-%D
-%D \showsetup{startmarginrule}
-
-\definecomplexorsimple\startmarginrule
-
-\def\simplestartmarginrule
- {\bgroup
- \let\drawmarginrule\relax
- \let\stopmarginrule\dostopmarginrule
- \beginofshapebox}
-
-\def\complexstartmarginrule[#1]%
- {\bgroup
- \let\drawmarginrule\relax
- \ifnum#1<\@@kalevel\relax
- \let\stopmarginrule\egroup
- \else
- \def\@@kadefaultwidth{#1}%
- \let\stopmarginrule\dostopmarginrule
- \expandafter\beginofshapebox
- \fi}
-
-\def\dostopmarginrule
- {\endofshapebox
- \reshapebox
- {\hbox{\inleftmargin{\dodrawmarginrule}\box\shapebox}}%
- \flushshapebox
- \egroup}
-
-%D \startbuffer
-%D \setupmarginrules[level=5]
-%D
-%D \startmarginrule[1]
-%D First we set the level at~5. Next we typeset this first
-%D paragraph as a level~1 one. As expected no rule show up.
-%D \stopmarginrule
-%D
-%D \startmarginrule[5]
-%D The second paragraph is a level~5 one. As we can see here,
-%D the marginal rule gets a width according to its level.
-%D \stopmarginrule
-%D
-%D \startmarginrule[8]
-%D It will of course be no surprise that this third paragraph
-%D has a even thicker margin rule. This behavior can be
-%D overruled by specifying the width explictly.
-%D \stopmarginrule
-%D \stopbuffer
-%D
-%D In next example we show most features. Watch the rule
-%D thickness adapting itself to the level.
-%D
-%D \startexample
-%D \getbuffer
-%D \stopexample
-%D
-%D We just said:
-%D
-%D \typebuffer
-
-%D \macros
-%D {vl, hl}
-%D
-%D The command \type{\vl} draws a vertical rule \vl\ with strut
-%D dimensions, multiplied with the factor specified in the
-%D optional argument. The height and depth are clipped \vl[3]
-%D to the baselinedistance. Its horizontal counterpart
-%D \type{\hl} draws a horizontal rule \hl\ with a width of 1em,
-%D multiplied with the optional factor. The horizontal rule is
-%D drawn on top of the baseline.
-%D
-%D \showsetup{vl}
-%D \showsetup{hl}
-
-\def\dovlwdhtdp#1#2#3%
- {\bgroup
- \setbox\scratchbox\hbox
- {\vrule
- \!!width #1\linewidth
- \!!height#2\strutht
- \!!depth #3\strutdp}%
- \dp\scratchbox\strutdp
- \ht\scratchbox\strutht
- \box\scratchbox
- \egroup}
-
-\def\complexvl[#1]%
- {\dovlwdhtdp\plusone{#1}{#1}}
-
-\def\complexhl[#1]%
- {\hbox
- {\vrule
- \!!width #1\s!em
- \!!height\linewidth
- \!!depth \zeropoint}}
-
-\definecomplexorsimple\vl \def\simplevl{\complexvl[1]}
-\definecomplexorsimple\hl \def\simplehl{\complexhl[1]}
-
-%D \macros
-%D {hairline, thinrule, thinrules, setupthinrules}
-%D
-%D Drawing thin lines can of course easily be accomplished by
-%D the \TEX\ primitives \type{\hrule} and \type{\vrule}. The
-%D next few macros however free us from some specifications.
-%D
-%D \startbuffer
-%D some text
-%D
-%D \hairline
-%D
-%D some more text
-%D
-%D \thinrule
-%D
-%D more and more text
-%D
-%D hi \thinrule\ there
-%D
-%D and then the final text
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D becomes
-%D
-%D \startexample
-%D \getbuffer
-%D \stopexample
-%D
-%D So we've got
-%D
-%D \showsetup{hairline}
-%D \showsetup{thinrule}
-%D
-%D Both can be set up with:
-%D
-%D \showsetup{setupthinrules}
-%D
-%D We also have
-%D
-%D \showsetup{thinrules}
-%D
-%D which looks like: \thinrules[n=2]
-
-\newconstant\ruletype
-
-\def\thinrule
- {\strut
- \bgroup
- \ruletype\plusone
- \processaction
- [\@@dlalternative]
- [ \v!a=>\ruletype\zerocount,% no line
- %\v!b=>\ruletype\plusone ,% height/depth
- \v!c=>\ruletype\plustwo ,% topheight/botdepth
- % 11=>\ruletype\plusone ,% fallback for backgrounds
- 0=>\ruletype\zerocount,% compatible with backgrounds
- % 1=>\ruletype\plusone ,% compatible with backgrounds
- 2=>\ruletype\plustwo ]% compatible with backgrounds
- \doifsomething\@@dlrulethickness
- {\linewidth\@@dlrulethickness}%
- \ifdim\linewidth=\zeropoint
- \ruletype\zerocount
- \else
- \doifnot\@@dlframe\v!on{\ruletype\zerocount}%
- \fi
- \ifnum\ruletype=\plusone
- \doif\@@dlheight\v!max{\let\@@dlheight\!!plusone}%
- \doif\@@dldepth \v!max{\let\@@dldepth \!!plusone}%
- \else
- \let\@@dlheight\!!plusone
- \let\@@dldepth\!!plusone
- \fi
- \freezedimensionwithunit\@@dlheight\strutht
- \freezedimensionwithunit\@@dldepth\strutdp
- \divide\linewidth \plustwo
- \doifelse\@@dlbackground\v!color
- {\startcolor[\@@dlbackgroundcolor]%
- \ifnum\ruletype=\plustwo % prevent overshoot due to rounding
- \leaders
- \hrule
- \!!height\dimexpr\@@dlheight-.5\linewidth\relax
- \!!depth \dimexpr\@@dldepth -.5\linewidth\relax
- \hfill
- \else
- \leaders
- \hrule
- \!!height\@@dlheight
- \!!depth \@@dldepth
- \hfill
- \fi
- \stopcolor
- \ifcase\ruletype
- % no rule
- \or
- \startcolor[\@@dlcolor]%
- \hfillneg
- \leaders\hrule\!!height\linewidth\!!depth\linewidth\hfill
- \stopcolor
- \or
- \startcolor[\@@dlcolor]%
- \hfillneg\leaders\hrule\!!height\dimexpr-\@@dldepth+\linewidth\relax\!!depth\@@dldepth\hfill
- \hfillneg\leaders\hrule\!!height\@@dlheight\!!depth\dimexpr-\@@dlheight+\linewidth\relax\hfill
- \stopcolor
- \fi}
- {\ifcase\ruletype \else
- \startcolor[\@@dlcolor]%
- \leaders\hrule\!!height\@@dlheight\!!depth\@@dldepth\hfill
- \stopcolor
- \fi}%
- \strut
- \carryoverpar\egroup}
-
-\def\hairline
- {\endgraf
- \thinrule
- \endgraf}
-
-\def\dosetupthinrules[#1]%
- {\getparameters[\??dl][#1]}
-
-\unexpanded\def\setupthinrules
- {\dosingleargument\dosetupthinrules}
-
-\def\dothinrules[#1]%
- {\bgroup
- \dosetupthinrules[#1]%
- \@@dlbefore
- \assignvalue\@@dlinterlinespace\@@dlinterlinespace{1.0}{1.5}{2.0}%
- \spacing\@@dlinterlinespace
- \dorecurse\@@dln
- {\ifnum\recurselevel=\@@dln \dothinrulesnobreak \else
- \ifnum\recurselevel=2 \dothinrulesnobreak \fi\fi
- \thinrule
- \ifnum\recurselevel<\@@dln\relax
- % test needed, else messed up whitespace
- \ifx\@@dlinbetween\empty
- \softbreak
- \else
- \endgraf
- \nowhitespace
- \@@dlinbetween
- \fi
- \fi}%
- \doifelsenothing\@@dlafter
- {\carryoverpar\egroup}
- {\@@dlafter\egroup}}
-
-\def\thinrules
- {\dosingleempty\dothinrules}
-
-%D A couple of examples are given below.
-%D
-%D \startbuffer
-%D \setupthinrules[n=3,inbetween=,color=gray]
-%D
-%D test test \thinrules\ test test \par
-%D test test \thinrules [color=green] test test \par
-%D test test \thinrules [height=max, depth=max] test test \par
-%D
-%D \setupthinrules[height=.9,depth=.9]
-%D
-%D test test \thinrules\ test test \par
-%D test test \thinrules [alternativevariant=b] test test \par
-%D test test \thinrules [alternativevariant=c] test test \par
-%D test test \thinrules [alternativevariant=c,inbetween=\vskip2ex] test test \par
-%D \stopbuffer
-%D
-%D \typebuffer {\getbuffer}
-%D
-%D There are a couple of alternative ways to visualize rules
-%D using backgrounds. At first sight these may look strange,
-%D but they make sense in educational settings. The
-%D alternatives are more or less compatible with the more
-%D advanced \METAPOST\ based implementation.
-%D
-%D \startbuffer[a]
-%D \setupthinrules
-%D [n=2,
-%D backgroundcolor=gray ,
-%D rulethickness=1pt,
-%D colorkleur=donkerblauw,
-%D after=\blank,
-%D before=\blank]
-%D \stopbuffer
-%D
-%D \typebuffer[a]
-%D
-%D \startbuffer[b]
-%D \thinrules[alternativevariant=a]
-%D \thinrules[alternativevariant=b]
-%D \thinrules[alternativevariant=c]
-%D \stopbuffer
-%D
-%D \typebuffer[b] \getbuffer[a,b]
-%D
-%D \startbuffer[b]
-%D \thinrules[alternativevariant=a,background=color]
-%D \thinrules[alternativevariant=b,background=color]
-%D \thinrules[alternativevariant=c,background=color]
-%D \stopbuffer
-%D
-%D \typebuffer[b] \getbuffer[a,b]
-%D
-%D \startbuffer[b]
-%D \thinrules[alternativevariant=a,height=.8,depth=.8,background=color]
-%D \thinrules[alternativevariant=b,height=.8,depth=.8,background=color]
-%D \thinrules[alternativevariant=c,height=.8,depth=.8,background=color]
-%D \stopbuffer
-%D
-%D \typebuffer[b] \getbuffer[a,b]
-
-%D \macros
-%D {optimizethinrules}
-%D
-%D By saying \type {\thinrulestrue} or \type {-false}, we
-%D can influence the way dangling lines are handled.
-
-\newif\ifoptimizethinrules \optimizethinrulestrue
-
-\def\dothinrulesnobreak
- {\ifoptimizethinrules\penalty500\fi}
-
-%D \macros
%D {startframedtext, setupframedtexts, defineframedtext}
%D
%D The general framing command we discussed previously, is not
@@ -2795,54 +2332,56 @@
\c!margin=\v!standard]
\appendtoks
- \setuevalue{\e!start\currentframedtext}{\dostartframedtext{\currentframedtext}}%
- \setuevalue{\e!stop \currentframedtext}{\dostopframedtext }%
- \setuevalue {\currentframedtext}{\doframedtext {\currentframedtext}}%
+ \setuevalue{\e!start\currentframedtext}{\framed_text_start {\currentframedtext}}%
+ \setuevalue{\e!stop \currentframedtext}{\framed_text_stop }%
+ \setuevalue {\currentframedtext}{\framed_text_direct{\currentframedtext}}%
\to \everydefineframedtext
-\unexpanded\def\dostartframedtext#1%
+\setvalue{\??kd:l:\v!left }{\letframedtextparameter\c!left \relax
+ \letframedtextparameter\c!right\hfill}
+
+\setvalue{\??kd:l:\v!right }{\letframedtextparameter\c!left \hfill
+ \letframedtextparameter\c!right\relax}
+
+\setvalue{\??kd:l:\v!middle}{\letframedtextparameter\c!left \hfill
+ \letframedtextparameter\c!right\hfill}
+
+\setvalue{\??kd:l:\v!none }{\letframedtextparameter\c!left \relax
+ \letframedtextparameter\c!right\relax
+ \settrue\c_framed_text_location_none}
+
+\unexpanded\def\framed_text_start#1%
{\bgroup
\edef\currentframedtext{#1}%
- \dodoubleempty\dodostartframedtext}
+ \dodoubleempty\framed_text_start_indeed}
-\def\dodostartframedtext[#1][#2]%
+\def\framed_text_start_indeed[#1][#2]%
{\doifassignmentelse{#1}
- {\dododostartframedtext[][#1]}
- {\dododostartframedtext[#1][#2]}}
+ {\framed_text_start_continue\empty{#1}}
+ {\framed_text_start_continue{#1}{#2}}}
-\def\dododostartframedtext[#1][#2]% #2 only passed to framed, not to framedtext
+\def\framed_text_start_continue#1#2%
{\setupframedtexts[\currentframedtext][#2]%
\doifsomething{#1}{\setframedtextparameter\c!location{#1}}% does not listen to #3
- \setfalse\framedtextlocationnone
- % somewhat messy ... needs to be redone
- \processaction % \v!low en \v!depth are already taken !
- [\framedtextparameter\c!location]
- [ \v!left=>\letframedtextparameter\c!left \relax
- \letframedtextparameter\c!right\hfill,
- \v!right=>\letframedtextparameter\c!left \hfill
- \letframedtextparameter\c!right\relax,
- \v!middle=>\letframedtextparameter\c!left \hfill
- \letframedtextparameter\c!right\hfill,
- \v!none=>\letframedtextparameter\c!left \relax % new
- \letframedtextparameter\c!right\relax % new
- \settrue\framedtextlocationnone]%
+ \setfalse\c_framed_text_location_none
+ \csname\??kd:l:\framedtextparameter\c!location\endcsname
\resetframedtextparameter\c!location
% removed 06/2001
% \forgetparindent
% added 06/2001 [see demo-bbv]
- \localhsize\hsize \checkframedtext
+ \framed_text_check
% so far
- \setbox\framebox\vbox
+ \setbox\b_framed_normal\vbox
\startboxedcontent
\hsize\localhsize
% \insidefloattrue % ? better
- \normalexpanded{\noexpand\switchtobodyfont[\framedtextparameter\c!bodyfont]}%
+ \normalexpanded{\switchtobodyfont[\framedtextparameter\c!bodyfont]}%
\startcolor[\framedtextparameter\c!color]%
\letframedtextparameter\c!strut\v!no
\inheritedframedtextframed\bgroup
\let\\=\endgraf
\framedtextparameter\c!inner % oud spul
- \doif{\framedtextparameter\c!depthcorrection}\v!on\doftstartdepthcorrection
+ \doif{\framedtextparameter\c!depthcorrection}\v!on\framed_text_start_depth_correction
\doinhibitblank % \blank[\v!disable]% plaatst signal
\setupindenting[\framedtextparameter\c!indenting]%
\useframedtextstyleandcolor\c!style\c!color}
@@ -2853,42 +2392,37 @@
\defineplacement[\??kd][\s!parent=\??kd\currentframedtext]
-\unexpanded\def\dostopframedtext % no \baselinecorrection, see faq docs
+\unexpanded\def\framed_text_stop % no \baselinecorrection, see faq docs
{\endgraf
\removelastskip
- \doif{\framedtextparameter\c!depthcorrection}\v!on\doftstopdepthcorrection
+ \doif{\framedtextparameter\c!depthcorrection}\v!on\framed_text_stop_depth_correction
\stopboxedcontent
\stopcolor
- \ifconditional\framedtextlocationnone
+ \ifconditional\c_framed_text_location_none
\egroup
- \box\framebox
+ \box\b_framed_normal
\else\ifinsidefloat
\egroup
- \box\framebox
+ \box\b_framed_normal
\else
\egroup
- \placement[\??kd][\c!depthcorrection=\v!off]{\box\framebox}%
+ \placement[\??kd][\c!depthcorrection=\v!off]{\box\b_framed_normal}%
\fi\fi
\egroup}
%D We define the general (and original) case by just saying:
-\setfalse\framedtextlocationnone
-
-\def\checkframedtext % messy dependency
- {\ifinsidefloat
- \localhsize\hsize
- \else\ifdim\d_page_sides_vsize>\zeropoint % also possible: \c_page_sides_checks_done>\zeropoint
+\def\framed_text_check % messy dependency
+ {\localhsize\hsize
+ \ifinsidefloat \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
\checksidefloat
\setlocalhsize
- \else
- \localhsize\hsize
- \fi\fi}
+ \fi \fi}
-\def\doftstartdepthcorrection
+\def\framed_text_start_depth_correction
{\bgroup
\ifhmode
\par
@@ -2901,7 +2435,7 @@
\nowhitespace
\fi} % na vskip ! new 20/05/2004, fails with next content being box (\scale{..})
-\def\doftstopdepthcorrection
+\def\framed_text_stop_depth_correction
{\ifhmode
\par
\fi
@@ -2938,13 +2472,13 @@
%D The simple brace (or group) delimited case is typeset
%D slightly different and is not aligned.
-\unexpanded\def\doframedtext#1%
+\unexpanded\def\framed_text_direct#1%
{\bgroup
\edef\currentframedtext{#1}%
- \dosingleempty\dodoframedtext}
+ \dosingleempty\framed_text_start_direct}
-\def\dodoframedtext[#1]% beware!
- {\normalexpanded{\noexpand\switchtobodyfont[\framedtextparameter\c!bodyfont]}%
+\def\framed_text_start_direct[#1]%
+ {\normalexpanded{\switchtobodyfont[\framedtextparameter\c!bodyfont]}%
\letframedtextparameter\c!strut\v!no
\iffirstargument
\setupcurrentframedtext[#1]%
@@ -2955,12 +2489,11 @@
\framedtextparameter\c!inner
\useframedtextstyleandcolor\c!style\c!color
\bgroup
- \aftergroup\docloseframedtext
+ \aftergroup\framed_text_stop_direct
\let\next=}
-\def\docloseframedtext
+\def\framed_text_stop_direct
{\removelastskip
- \dostopattributes
\egroup
\egroup}
@@ -2978,22 +2511,12 @@
%D also simplified the \type {\setupframed} command. There are
%D certainly more places where such improvements can be made.
-% \def\defineframed
-% {\dodoubleempty\dodefineframed}
-%
-% \def\dodefineframed[#1][#2]%
-% {\ifcsname\??ol:#1\endcsname
-% % already defined, keeps settings
-% \else
-% \expandafter\newcount\csname\??ol:#1\endcsname % \the\everypresetframed
-% \fi
-% \getparameters[\??ol#1][\s!parent=\??ol,#2]%
-% \setuvalue{#1}{\doframed[#1]}}% % \the\everydefineframed
-
-\def\defineframed % also inheritance now
- {\dotripleempty\dodefineframed}
-
-\def\dodefineframed[#1][#2][#3]%
+% actually, this can be another command handler .. todo
+
+\def\defineframed
+ {\dotripleempty\framed_define}
+
+\def\framed_define[#1][#2][#3]%
{\ifcsname\??ol:#1\endcsname
% already defined, keeps settings
\else
@@ -3010,20 +2533,20 @@
\else
\getparameters[\??ol#1][\s!parent=\??ol,#2]%
\fi
- \setuvalue{#1}{\doframed[#1]}}% % \the\everydefineframed
+ \setuvalue{#1}{\framed_defined_process[#1]}}% % \the\everydefineframed
-\newcount\crapframedcount
+\newcount\c_framed_crap
-\def\doframed[#1]% official (not much checking, todo: parent)
+\def\framed_defined_process[#1]% official (not much checking, todo: parent)
{\bgroup
\ifcsname\??ol:#1\endcsname
- \expandafter\let\expandafter\tempframedcount\csname\??ol:#1\endcsname
+ \expandafter\let\expandafter\c_framed_temp\csname\??ol:#1\endcsname
\else
- \let\tempframedcount\crapframedcount
+ \let\c_framed_temp\c_framed_crap
\fi
- \advance\tempframedcount\plusone
- \expandafter\def\csname\??ol#1:\the\tempframedcount\s!parent\endcsname{\??ol#1}% \inheritlocalframed
- \dodoubleempty\dolocalframed[\??ol#1:\the\tempframedcount]}
+ \advance\c_framed_temp\plusone
+ \expandafter\def\csname\??ol#1:\the\c_framed_temp\s!parent\endcsname{\??ol#1}% \inheritlocalframed
+ \dodoubleempty\framed_process[\??ol#1:\the\c_framed_temp]}
%D We can do:
%D
@@ -3033,305 +2556,6 @@
%D
%D but the existing one is ok as well (less csname messy too).
-%D \macros
-%D {textrule, starttextrule, setuptextrules}
-%D
-%D Putting rules before and after a paragraph is very space
-%D sensitive, but the next command handles that quite well. It
-%D comes in two disguises:
-%D
-%D \startbuffer
-%D \textrule[top]{fragments}
-%D \input reich
-%D \textrule
-%D \stopbuffer
-%D
-%D \start \typebuffer \getbuffer \stop
-%D
-%D \startbuffer
-%D \setuptextrules
-%D [width=90pt,distance=12pt,rulecolor=blue,
-%D bodyfont=small,style=\sc,color=red]
-%D
-%D \starttextrule{Ship Building Tools}
-%D \nl \setuptolerance[tolerant] \input materie
-%D \stoptextrule
-%D \stopbuffer
-%D
-%D \bgroup \typebuffer \getbuffer \egroup
-%D
-%D \startbuffer
-%D \setuptextrules
-%D [location=inmargin,
-%D bodyfont=small,style=slantedbold]
-%D
-%D \starttextrule{wonderful}
-%D \input tufte
-%D \stoptextrule
-%D \stopbuffer
-%D
-%D \bgroup \typebuffer \getbuffer \egroup
-%D
-%D The formal definition of these commands is:
-%D
-%D \showsetup{textrule}
-%D \showsetup{starttextrule}
-%D \showsetup{setuptextrules}
-%D
-%D The implementation looks a bit complicated due to the
-%D optional arguments.
-
-\unexpanded\def\setuptextrules
- {\dodoubleargument\getparameters[\??tl]}
-
-\def\complextextrule[#1]% if needed we can make it installable
- {\let\next\dobottomtextrule
- \processaction
- [#1]
- [ \v!top=>\let\next\dotoptextrule,
- \v!middle=>\let\next\domiddletextrule,
- \v!bottom=>\let\next\dobottomtextrule]%
- \dosinglegroupempty\next}
-
-\definecomplexorsimple\textrule
-
-\def\simpletextrule
- {\dosinglegroupempty\dounknowntextrule}
-
-\def\docomplextextrule#1%
- {\bgroup
- \advance\hsize\dimexpr-\rightskip-\leftskip\relax
- \setbox\scratchbox\hbox to \hsize
- {\dimen4\dimexpr .5ex+.5\linewidth\relax
- \dimen6\dimexpr-.5ex+.5\linewidth\relax
- \doifsomething{#1}
- {\doifelse\@@tllocation\v!inmargin
- {\llap
- {\dousestyleparameter\@tlstyle
- \dousecolorparameter\@tlcolor
- #1%
- \hskip\leftmargindistance}}
- {\color[\@@tlrulecolor]
- {\vrule\!!height\dimen4\!!depth\dimen6\!!width\@@tlwidth}%
- \hbox spread 2\dimexpr\@@tldistance\relax
- {\hss
- \dousestyleparameter\@tlstyle
- \dousecolorparameter\@tlcolor
- \strut#1%
- \hss}}}%
- \color[\@@tlrulecolor]
- {\leaders\hrule\!!height\dimen4\!!depth\dimen6\hfill}}%
- \ht\scratchbox\strutht
- \dp\scratchbox\strutdp
- \noindent\box\scratchbox
-%\nobreak\verticalstrut\kern-\struttotal
-% evt \witruimte
- \egroup}
-
-\def\dotoptextrule#1%
- {\page[\v!preference] % interferes
- %\whitespace % no
- \@@tlbefore
- \docomplextextrule{#1}%
-% todo, option: \doifnothing{#1}{\ruledvskip-.5ex}
- \nowhitespace
- \@@tlinbetween
- \endgraf}
-
-\def\dodobottomtextrule#1#2%
- {\ifhmode
- \endgraf
- \fi
- \dimen0\strutdp
- \ifdim\prevdepth>\strutdp\else % was <\strutdp
- \ifdim\prevdepth>\zeropoint
- \advance\dimen0 -\prevdepth
- \fi
- \fi
- \advance\dimen0 .5ex
- \vskip\dimen0
-% ==
-% \vskip\dimexpr \strutdp + .5ex
-% \ifdim\prevdepth>\strutdp\else\ifdim\prevdepth>\zeropoint-\prevdepth\fi\fi\relax
-%
- \@@tlinbetween
- \doifelsenothing{#2}
- {\bgroup
- \advance\hsize\dimexpr-\rightskip-\leftskip\relax
- \nointerlineskip
- \moveleft-\leftskip\vbox
- {\color[\@@tlrulecolor]
- {\hrule\!!depth\linewidth\!!height\zeropoint\!!width\hsize}}%
- \egroup}
- {\docomplextextrule{#2}}%
- \ifvmode\prevdepth\zeropoint\fi
- #1%
- \page[\v!preference]}
-
-\def\dobottomtextrule
- {\dodobottomtextrule\@@tlafter}
-
-\def\domiddletextrule
- {\dodobottomtextrule\@@tlinbetween}
-
-\def\dounknowntextrule
- {\iffirstargument
- \@EA\dotoptextrule
- \else
- \@EA\dobottomtextrule\@EA\empty
- \fi}
-
-%D The grouped commands also supports bodyfont switching:
-
-\unexpanded\def\starttextrule#1%
- {\bgroup
- \def\dounknowntextrule{\domiddletextrule}
- \dotoptextrule{#1}
- \bgroup
- \doifsomething\@@tlbodyfont{\switchtobodyfont[\@@tlbodyfont]}}
-
-\unexpanded\def\stoptextrule
- {\par
- \egroup
- \dobottomtextrule\empty
- \egroup}
-
-%D \macros
-%D {fillinrules, setupfillinrules}
-%D
-%D The next few commands do not really deserve a place in a
-%D core module, because they deal with specific typography.
-%D Nevertheless I decided to make them part of the core,
-%D because they permit us to make questionaires. Let's start
-%D with some examples.
-%D
-%D \fillinrules[n=2,width=fit]{first}
-%D \fillinrules[n=2,width=broad]{first}
-%D \fillinrules[n=2,width=3cm]{first}
-%D \fillinrules[n=2,width=3cm,distance=.5em,separator=:]{first}
-%D \fillinrules[n=2]{first}{last}
-%D \fillintext{first}{last} \input reich \par
-%D
-%D The main command is \type{\fillinrules}. This command takes
-%D one and an optional second argument and sets a paragraph with
-%D empty visualized lines.
-%D
-%D \showsetup{fillinrules}
-%D \showsetup{setupfillinrules}
-
-\unexpanded\def\setupfillinrules
- {\dodoubleargument\getparameters[\??il]}
-
-\definecomplexorsimpleempty\fillinrules
-
-\def\complexfillinrules[#1]%
- {\def\docomplexfillinrules##1##2%
- {\dodocomplexfillinrules[#1]{##1}{##2}{\thinrules
- [\c!n=\@@iln,\c!interlinespace=\@@ilinterlinespace,\c!before=,\c!after=]}}%
- \dodoublegroupempty\docomplexfillinrules}
-
-\def\dodocomplexfillinrules[#1]#2#3#4%
- {\endgraf
- \@@ilbefore
- \begingroup
- \setupfillinrules[#1]%
- \noindent
- \doifsomething{#2}
- {\doifelse\@@ilwidth\v!fit
- {\let\@@ildistance\!!zeropoint
- \hbox}
- {\doifelse\@@ilwidth\v!broad
- {\hbox}
- {\hbox to \@@ilwidth}}%
- \bgroup
- \dousestyleparameter\@@ilstyle
- \dousecolorparameter\@@ilcolor
- \strut#2\hfill\@@ilseparator\hskip\@@ildistance
- \egroup}%
- %\hangindent=\wd0\relax % tzt hang=yes,n
- %\parindent=\hangindent
- %\box0\relax
- \setupwhitespace[\v!big]%
- \ignorespaces
- #4%
- \doifsomething{#3}
- {\kern\@@ildistance
- \dousestyleparameter\@@ilstyle
- \dousecolorparameter\@@ilcolor
- #3\strut}%
- \endgroup
- \endgraf
- \@@ilafter}
-
-%D \macros
-%D {fillintext}
-%D
-%D To provide compatible layouts when texts and lines are
-%D mixed, one can typeset a paragraph by using the command
-%D \type{\fillintext}.
-%D
-%D \showsetup{fillintext}
-
-\definecomplexorsimpleempty\fillintext
-
-\def\complexfillintext[#1]% rather rough, using an \unhbox is suboptimal
- {\def\docomplexfillintext##1##2%
- {\dowithnextbox
- {\dodocomplexfillinrules[#1]{##1}{\hfill##2}{\unhbox\nextbox\unskip}}%
- \hbox\bgroup\let\par\egroup\ignorespaces}%
- \dodoublegroupempty\docomplexfillintext}
-
-%D \macros
-%D {fillinline, setupfillinlines}
-%D
-%D Another member of the family takes care of putting a (often
-%D small) rule after a piece of text, like
-%D
-%D \startbuffer
-%D \fillinline \input reich \par
-%D \fillinline[margin=0cm] \input reich \par
-%D \stopbuffer
-%D
-%D \startexample
-%D \getbuffer
-%D \stopexample
-%D
-%D which was typeset by saying:
-%D
-%D \typebuffer
-%D
-%D The two commands that take care of this are:
-%D
-%D \showsetup{fillinline}
-%D \showsetup{setupfillinlines}
-
-\unexpanded\def\setupfillinlines
- {\dodoubleargument\getparameters[\??iv]}
-
-\definecomplexorsimpleempty\fillinline
-
-\def\complexfillinline[#1]%
- {%\endgraf % interferes with \definedescription cum suis
- \@@ivbefore
- \begingroup
- \setupfillinlines[#1]%
- \advance\rightskip \@@ivmargin
- \parfillskip\zeropoint
- \def\par % very dangerous
- {\let\par\endgraf % -)
- \ifhmode\unskip\hfill\fi
- \scratchdimen\dimexpr\@@ivwidth-\@@ivdistance\relax
- \ifdim\scratchdimen>\@@ivmargin\else\expandafter\rlap\fi
- {\kern\@@ivdistance
- \vrule
- \!!width \scratchdimen
- \!!height.5\linewidth
- \!!depth .5\linewidth}%
- \endgraf % !
- \endgroup
- \endgraf % !
- \@@ilafter}}
-
%D New, for the moment private; let's see when GB finds out
%D about this one and its obscure usage. It's used in:
%D
@@ -3367,9 +2591,12 @@
%D
%D \typebuffer
-\def\framedcontentparameter #1{\csname\doframedcontentparameter{\??fc\@@framedcontent}#1\endcsname}
+% to be redone
+
+\def\framedcontentparameter #1{\csname\doframedcontentparameter{\??fc\currentframedcontent}#1\endcsname}
\def\doframedcontentparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\doframedcontentparentparameter\csname#1\s!parent\endcsname#2\fi}
\def\doframedcontentparentparameter#1#2{\ifx#1\relax\s!empty\else\doframedcontentparameter#1#2\fi}
+\def\letframedcontentparameter #1{\expandafter\let\csname\??fc\currentframedcontent#1\endcsname}
\presetlocalframed[\??fc]
@@ -3386,9 +2613,6 @@
%\c!width=\v!fit,
\c!offset=\v!overlay]
-\def\letframedcontentparameter#1%
- {\letvalue{\??fc\@@framedcontent#1}}
-
\unexpanded\def\defineframedcontent
{\dodoubleempty\dodefineframedcontent}
@@ -3403,17 +2627,20 @@
\processcommacommand[#1]\docommand}
\unexpanded\def\startframedcontent
- {\dosingleempty\dostartframedcontent}
+ {\dosingleempty\framed_start_content}
-\def\dostartframedcontent[#1]%
+\def\framed_start_content[#1]%
{\bgroup
- \edef\@@framedcontent{#1}%
- \let\stopframedcontent\egroup
- \doifnot{#1}\v!off{\dodostartframedcontent{#1}}}
+ \edef\currentframedcontent{#1}%
+ \ifx\currentframedcontent\v!off
+ \let\stopframedcontent\egroup
+ \else
+ \let\stopframedcontent\framed_stop_content_indeed
+ \expandafter\framed_start_content_indeed
+ \fi}
-\def\dodostartframedcontent#1%
- {\unexpanded\def\stopframedcontent{\dostopframedcontent{#1}}%
- \setbox\framebox\hbox\bgroup
+\def\framed_start_content_indeed
+ {\setbox\b_framed_normal\hbox\bgroup
\setlocalhsize
\hsize\localhsize
\advance\hsize\dimexpr-\framedcontentparameter\c!leftoffset-\framedcontentparameter\c!rightoffset \relax
@@ -3425,7 +2652,7 @@
\forgetall
\blank[\v!disable]}
-\def\dostopframedcontent#1%
+\def\framed_stop_content_indeed
{\removelastskip
\egroup
\vskip\framedcontentparameter\c!bottomoffset
@@ -3442,7 +2669,7 @@
% plaats ?
\ifdone\startlinecorrection\fi
\framedcontentparameter\c!left % new
- \localframed[\??fc#1]{\box\framebox}%
+ \localframed[\??fc\currentframedcontent]{\box\b_framed_normal}% hm
\framedcontentparameter\c!right % new
\ifdone\stoplinecorrection\fi
\egroup}
@@ -3458,146 +2685,50 @@
\setupframed
[\c!width=\v!fit,
\c!height=\v!broad,
- \c!lines=,
+ %\c!lines=,
\c!offset=0.25ex, % \defaultframeoffset
\c!empty=\v!no,
\c!frame=\v!on,
- \c!topframe=,
- \c!bottomframe=,
- \c!leftframe=,
- \c!rightframe=,
+ %\c!topframe=,
+ %\c!bottomframe=,
+ %\c!leftframe=,
+ %\c!rightframe=,
\c!radius=.5\bodyfontsize,
\c!rulethickness=\linewidth,
\c!corner=\v!rectangular,
\c!depth=\zeropoint,
- \c!foregroundcolor=,
- \c!foregroundstyle=,
- \c!background=,
+ %\c!foregroundcolor=,
+ %\c!foregroundstyle=,
+ %\c!background=,
\c!backgroundscreen=\@@rsscreen,
- \c!backgroundcolor=,
+ %\c!backgroundcolor=,
\c!backgroundoffset=\zeropoint,
- \c!framecolor=,
+ %\c!framecolor=,
\c!frameoffset=\zeropoint,
+ % somewhat messy
\c!backgroundcorner=\framedparameter\c!corner,
\c!backgroundradius=\framedparameter\c!radius,
\c!backgrounddepth=\framedparameter\c!depth,
\c!framecorner=\framedparameter\c!corner,
\c!frameradius=\framedparameter\c!radius,
\c!framedepth=\framedparameter\c!depth,
- \c!component=,
- \c!align=,
+ %
+ %\c!component=,
+ %\c!align=,
\c!bottom=\vss,
- \c!top=,
+ %\c!top=,
\c!autostrut=\v!yes,
\c!location=\v!normal,
- \c!orientation=,
+ %\c!orientation=,
\c!autowidth=\v!yes,
- \c!setups=,
- \c!strut=\v!yes]
-
-\setupscreens
- [%\c!factor=1.0, % obsolete
- %\c!method=\v!external, % obsolete
- \c!screen=0.95]
-
-\setupblackrules
- [\c!n=3,
- \c!width=1em,
- \c!height=1ex,
- \c!depth=\!!zeropoint,
- \c!alternative=\c!a,
- \c!distance=.25ex,
- \c!color=]
-
-\setupmarginrules
- [\c!level=0,
- \c!rulethickness=\@@kadefaultwidth\linewidth]
-
-\setupthinrules
- [\c!interlinespace=\v!small,
- \c!n=3,
- \c!before=,
- \c!inbetween={\blank[\v!white]},
- \c!after=,
- \c!color=,
- \c!height=.5\linewidth,
- \c!depth=.5\linewidth,
- \c!frame=\v!on, % compatible with textbackgrounds
- \c!alternative=\v!b,
- \c!backgroundcolor=,
- \c!background=,
- \c!rulethickness=]
-
-\setuptextrules
- [\c!location=\v!left,
- \c!before=\blank,
- \c!after=\blank,
- \c!inbetween=,
- \c!width=2em,
- \c!style=\v!bold,
- \c!color=,
- \c!rulecolor=,
- \c!bodyfont=,
- \c!distance=.5em]
-
-\setupfillinrules
- [\c!width=\v!broad,
- \c!distance=1em,
- \c!before=\blank,
- \c!after=\blank,
- \c!n=1,
- \c!interlinespace=\v!small,
- \c!separator=,
- \c!style=\v!normal,
- \c!color=]
-
-\setupfillinlines
- [\c!width=3cm,
- \c!margin=\@@ivwidth,
- \c!distance=1em,
- \c!before=\blank,
- \c!after=\blank]
-
-% Experimental extension:
-
-\def\c!loffset{loffset}
-\def\c!roffset{roffset}
-\def\c!toffset{toffset}
-\def\c!boffset{boffset}
-
-\getparameters
- [\??oi]
- [\c!loffset=\zeropoint,
+ %\c!setups=,
+ \c!strut=\v!yes,
+ \c!loffset=\zeropoint,
\c!roffset=\zeropoint,
\c!toffset=\zeropoint,
\c!boffset=\zeropoint]
-\newdimen\!!framedloffset
-\newdimen\!!framedroffset
-\newdimen\!!framedtoffset
-\newdimen\!!framedboffset
-
-\def\setextraframedoffsets
- {\boxhasextraoffsetfalse
- \!!framedloffset\framedparameter\c!loffset
- \!!framedroffset\framedparameter\c!roffset
- \!!framedtoffset\framedparameter\c!toffset
- \!!framedboffset\framedparameter\c!boffset
- \relax
- \ifzeropt\!!framedloffset\else \advance\!!framedwidth -\!!framedloffset \boxhasextraoffsettrue \fi
- \ifzeropt\!!framedroffset\else \advance\!!framedwidth -\!!framedroffset \boxhasextraoffsettrue \fi
- \ifzeropt\!!framedtoffset\else \advance\!!framedheight-\!!framedtoffset \boxhasextraoffsettrue \fi
- \ifzeropt\!!framedboffset\else \advance\!!framedheight-\!!framedboffset \boxhasextraoffsettrue \fi}
-
-\def\applyextraframedoffsets
- {\setbox\framebox\vbox\bgroup
- \vskip\!!framedtoffset
- \hbox\bgroup
- \hskip\!!framedloffset
- \box\framebox
- \hskip\!!framedroffset
- \egroup
- \vskip\!!framedboffset
- \egroup}
+\setupscreens
+ [\c!screen=0.95]
\protect \endinput
diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv
index 6497ba657..b6eebdfcf 100644
--- a/tex/context/base/page-imp.mkiv
+++ b/tex/context/base/page-imp.mkiv
@@ -64,6 +64,11 @@
\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)
+\unexpanded\def\invokepagehandler#1%
+ {\expandcheckedcsname{\??pp:h:}{#1}\v!normal}
+
+\let\pagehandler\invokepagehandler % only provided for downward compatibility
+
\def\page_shipouts_handle
{\csname\??pp:h:\ifcsname\??pp:h:\v_page_target_method\endcsname
\v_page_target_method
diff --git a/tex/context/base/page-mar.mkiv b/tex/context/base/page-mar.mkiv
deleted file mode 100644
index 07296f832..000000000
--- a/tex/context/base/page-mar.mkiv
+++ /dev/null
@@ -1,808 +0,0 @@
-%D \module
-%D [ file=page-mar, % moved here from main-001
-%D version=1997.03.31,
-%D title=\CONTEXT\ Page Macros,
-%D subtitle=Marginal Things,
-%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.
-
-\endinput % obsolete, also commented code in anch-pgr.mkiv
-
-%D Support for margin words is one of the reasons for writing
-%D \CONTEXT. Over time support for marginal content has been
-%D extended en enhanced. Therefore it's always good to watch
-%D out for unexpected side effects.
-
-%D TODO: use parents etc
-
-\writestatus{loading}{ConTeXt Page Macros / Marginal Things}
-
-\unprotect
-
-%D There are three categories and their historically grown meaning is
-%D as follows:
-%D
-%D marginlines: these are flushed relative to the start of a line and
-%D need to be invoked there.
-%D
-%D marginwords: these can be issued in the text flow and will migrate
-%D sidewards; in spite of the name, it can be a paragraph of text as
-%D well, but normally it's words.
-%D
-%D margintexts: these can be set beforehand and are flushed at the
-%D next paragraph of text (of header)
-%D
-%D While these mechanisms were rather separated, they now are slightly
-%D more integrated. Instead of low level instances we now have a mechanism
-%D for defining additional ones.
-
-%D \macros
-%D {inleftedge,inleftmargin,inrightmargin,inrightedge}
-%D
-%D The fast and clean way of putting things in the margin is
-%D using \type{\rlap} or \type{\llap}. Unfortunately these
-%D macro's don't handle indentation, left and right skips. We
-%D therefore embed them in some macro's that (force and)
-%D remove the indentation and restore it afterwards.
-
-\unexpanded\def\definemarginline
- {\dodoubleargument\dodefinemarginline}
-
-\def\dodefinemarginline[#1][#2]%
- {\getparameters
- [\??im\??im#1]
- [\c!location=\v!left,
- \c!distance=\zeropoint,
- \c!width=\leftmarginwidth,
- \c!hoffset=\leftmargindistance,
- \c!command=,
- #2]%
- \setuvalue{#1}{\dohandlemarginline{#1}}}
-
-\def\marginlineparameter#1{\csname\??im\??im\currentmarginline#1\endcsname}
-
-\def\marginlineexecuter#1#2%
- {\dostarttagged\t!margintext\currentmarginline
- \executeifdefined{\??im\??im\currentmarginline#1}{#2}%
- \dostoptagged}
-
-\def\dohandlemarginline#1%#2%
- {\def\currentmarginline{#1}%
- \csname\s!do\??im\??im\executeifdefined{\??im\??im#1\c!location}\v!left\endcsname{#1}}% {#2}
-
-\def\doleftmarginline#1#2% #1 is redundant (we can remove it when we group dohandlemarginline; maybe ...
- {\pushindentation
- \llap
- {\def\currentmarginline{#1}%
- \postsignalrightpage
- \hsize\marginlineparameter\c!width\relax
- \marginlineexecuter\c!command\firstofoneargument{#2}\relax
- \hskip\dimexpr
- +\leftskip
- +\compensatedinnermakeupmargin
- +\marginlineparameter\c!hoffset
- +\marginlineparameter\c!distance
- \relax}%
- \popindentation
- \ignorespaces}
-
-\def\dorightmarginline#1#2% #1 is redundant
- {\pushindentation
- \rlap
- {\def\currentmarginline{#1}%
- \postsignalrightpage
- \hskip\dimexpr
- +\hsize
- -\rightskip
- +\compensatedinnermakeupmargin
- +\marginlineparameter\c!hoffset
- +\marginlineparameter\c!distance
- \relax
- \hsize\marginlineparameter\c!width
- \marginlineexecuter\c!command\firstofoneargument{#2}}%
- \popindentation
- \ignorespaces}
-
-\long\def\installmarginlinehandler#1#2{\setvalue{\s!do\??im\??im#1}{#2}}
-
-\installmarginlinehandler \v!left {\doleftmarginline}
-\installmarginlinehandler \v!right {\dorightmarginline}
-\installmarginlinehandler \v!inner {\presignalrightpage\doifrightpageelse\doleftmarginline \dorightmarginline}
-\installmarginlinehandler \v!outer {\presignalrightpage\doifrightpageelse\dorightmarginline\doleftmarginline }
-
-\definemarginline[inleftmargin] [\c!location=\v!left, \c!width=\leftmarginwidth, \c!distance=\leftmargindistance, \c!hoffset=\zeropoint]
-\definemarginline[inrightmargin][\c!location=\v!right,\c!width=\rightmarginwidth,\c!distance=\rightmargindistance,\c!hoffset=\zeropoint]
-\definemarginline[inleftedge] [\c!location=\v!left, \c!width=\leftedgewidth, \c!distance=\leftedgedistance, \c!hoffset=\leftmargintotal]
-\definemarginline[inrightedge] [\c!location=\v!right,\c!width=\rightedgewidth, \c!distance=\rightedgedistance, \c!hoffset=\rightmargintotal]
-
-\definemarginline[inoutermargin][\c!location=\v!outer,\c!width=\outermarginwidth,\c!distance=\outermargindistance,\c!hoffset=\zeropoint]
-\definemarginline[ininnermargin][\c!location=\v!inner,\c!width=\innermarginwidth,\c!distance=\innermargindistance,\c!hoffset=\zeropoint]
-\definemarginline[inouteredge] [\c!location=\v!outer,\c!width=\outeredgewidth, \c!distance=\outeredgedistance, \c!hoffset=\outermargintotal]
-\definemarginline[ininneredge] [\c!location=\v!inner,\c!width=\inneredgewidth, \c!distance=\inneredgedistance, \c!hoffset=\innermargintotal]
-
-\definemarginline[atleftmargin] [\c!location=\v!left, \c!command=\lrlap,\c!width=\zeropoint,\c!distance=\zeropoint,\c!hoffset=\zeropoint]
-\definemarginline[atrightmargin][\c!location=\v!right,\c!command=\rllap,\c!width=\zeropoint,\c!distance=\zeropoint,\c!hoffset=\zeropoint]
-
-\def\lrlap#1{\llap{\rlap{#1}}}
-\def\rllap#1{\rlap{\hskip\hsize\llap{#1}}}
-
-%D We want to keep things efficient and therefore only handle
-%D situations like:
-%D
-%D \startbuffer
-%D \inleftedge {fine} some text \par
-%D \strut \inleftmargin {fine} some text \par
-%D \noindent \inrightmargin {fine} some text \par
-%D \noindent \strut \inrightedge {fine} some text \par
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D which looks like:
-%D
-%D \bgroup
-%D \getbuffer
-%D \parindent 30pt
-%D \getbuffer
-%D \egroup
-%D
-%D A torture test:
-%D
-%D \starttyping
-%D \def\TestLine#1#2{\backgroundline[#1]{\strut\white\tttf#2~\recurselevel}}
-%D
-%D \startbuffer
-%D \inleftmargin {\TestLine{red} {lm}} test test test \par
-%D \inrightmargin{\TestLine{green} {rm}} test test test \par
-%D \inleftedge {\TestLine{red} {le}} test test test \par
-%D \inrightedge {\TestLine{green} {re}} test test test \par
-%D \inoutermargin{\TestLine{blue} {om}} test test test \par
-%D \ininnermargin{\TestLine{yellow}{im}} test test test \par
-%D \inouteredge {\TestLine{blue} {oe}} test test test \par
-%D \ininneredge {\TestLine{yellow}{ie}} test test test \par
-%D \atleftmargin {\TestLine{red} {alm}} \hfill test \par
-%D \atrightmargin{\TestLine{green} {arm}} test \hfill \par
-%D \stopbuffer
-%D
-%D \dorecurse{40}\getbuffer \page
-%D \stoptyping
-
-%D New, yet undocumented:
-%D
-%D used for pascal:
-%D
-%D \starttyping
-%D \index {test} test \index {west} west \index {rest} rest
-%D
-%D \startnarrower
-%D \placeregister[index][alternative=b,command=\atleftmargin]
-%D \stopnarrower
-%D \stoptyping
-
-% todo: compensate distance when setuplayout[textwidth=..]
-% todo: generalize margin/edge model, now too much duplication
-
-%D The next bunch of macros looks messy which is due to its
-%D multi-purpose character.
-
-\setnewconstant\margincontentdisplacement \zerocount
-\let \margincontentdistance \!!zeropoint
-\let \margincontenthoffset \!!zeropoint
-\def \margincontentlines {1}
-\def \margincontenttag {0}
-\let \margincontentseparator \empty
-\def \margincontentstrutheight {\strutht}
-
-\newcount\margincontentlevel
-\newdimen\margincontentheight
-
-% \installparameterhandler \??im{inmargin}
-% \installparameterhashhandler\??im{inmargin}
-
-\unexpanded\def\setupinmargin
- {\dodoubleempty\dosetupinmargin}
-
-\def\dosetupinmargin[#1][#2]%
- {\ifsecondargument
- \processcommalist[#1]{\dodosetupinmargin[#2]}% becomes [#2]{##1}
- \else
- \getparameters[\??im][#1]%
- \fi}
-
-\def\dodosetupinmargin[#1]#2% [settings]{class}
- {\checkinmargin[#2]%
- \getparameters[\??im#2][#1]%
- % will become an \everyinmarginsetup thing
- \ifcase\executeifdefined{\??im#2\c!sidemethod}{0}\else
- \enableparpositions
- \fi}
-
-\def\checkinmargin[#1]%
- {\ifcsname\??im#1\c!offset\endcsname\else % this offset is related to framed !
- \addtocommalist{#1}\inmargintaglist
- \presetmargintext[#1]%
- \fi}
-
-\def\presetmargintext[#1]%
- {\presetlocalframed
- [\??im#1]% hm, isn't this gone ?
- \getparameters
- [\??im#1]
- [\c!frame=\v!off,
- \c!offset=\v!overlay,
- \c!line=1,
- \c!separator=,
- \c!width=\v!broad,
- \c!distance=, % empty = signal
- \c!hoffset=\zeropoint,
- \c!style=\@@imstyle,
- \c!color=\@@imcolor,
- \c!strut=\@@imstrut,
- \c!location=\@@imlocation,
- \c!align=\@@imalign,
- \c!before=\@@imbefore,
- \c!after=\@@imafter]}
-
-\newdimen\naturalmargincontentheight
-
-\def\makemargintextblock#1#2#3% width l r content
- {\bgroup
- \forgetall % added, else problems with 'center' and nested itemize
- \dontcomplain
- \hsize\getvalue{\??im#1\c!width}\relax
- \doifnumberelse\margincontenttag
- {\ifcase\margincontenttag\relax
- \edef\margincontenttag{#1}% first one is setups id as well
- \fi}
- \donothing
- \doifnumberelse\margincontenttag
- {\ifnum\margincontenttag>25 % to be translated
- \writestatus\m!system{potential margin stack overflow (\margincontenttag)}%
- \fi}
- \donothing
- % we need to preserve {a,b,c} kind of settings
- \let\margincontentalign#1%
- \processallactionsinset
- [\getvalue{\??im\margincontenttag\c!align}]
- [ \v!yes=>\let\margincontentalign#1,
- \v!no=>\let\margincontentalign\v!normal,
- \v!inner=>\let\margincontentalign#1,
- \v!outer=>\let\margincontentalign#2,
- \v!flushright=>\let\margincontentalign\v!left,
- \v!left=>\let\margincontentalign\v!left,
- \v!middle=>\let\margincontentalign\v!middle,
- \v!flushleft=>\let\margincontentalign\v!right,
- \v!right=>\let\margincontentalign\v!right]%
- \doifvaluesomething{\??im\margincontenttag\c!align} % watch {} around set
- {\edef\margincontentalign{{\getvalue{\??im\margincontenttag\c!align},\margincontentalign}}}%
- %
- \expanded{\getparameters[\??im\margincontenttag][\c!align=\margincontentalign]}%
- %
- \edef\margincontentstrut{\getvalue{\??im\margincontenttag\c!strut}}%
- \savestrut %
- \setbox\scratchbox\vbox\localframed
- [\??im\margincontenttag]
- [\c!strut=\v!no,\c!offset=\v!overlay] % strut handled internally
- {\decrement\margincontentlines
- \dorecurse\margincontentlines{\savedstrut\endgraf\nointerlineskip}% ! savedstrut
- \@@imbefore
- \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
- \doif\@@imstack\v!yes
- {\def\overlappingmargin{-20\scaledpoint}% test value, maybe .25\strutboxdp, maybe configurable
- \setbox\scratchbox\vbox{\stackeddown\vbox{\box\scratchbox}}}% new
- \ht\scratchbox\strutht
- \dp\scratchbox\strutdp % nieuw
- \box\scratchbox
- \egroup}
-
-%D The stacker permits constructs like:
-%D
-%D \starttyping
-%D \setupinmargin[stack=yes]
-%D
-%D \inleft{test 1}test\break
-%D \inleft{test 2}test\break
-%D \inleft{test 1}
-%D \input tufte
-%D \inleft{test 1}
-%D \inleft{test 2}
-%D \inleft{test 3}
-%D \input tufte
-%D \inleft{test 1}
-%D \inleft{test 2\endgraf test 3}
-%D \inleft{test 4}
-%D \input tufte
-%D \inleft{test 1}
-%D \inleft{test 2\endgraf test 3}
-%D \inleft{test 4\endgraf test 5\endgraf test 6}
-%D \inleft{test 7\endgraf test 8\endgraf test 9}
-%D \input tufte
-%D \stoptyping
-
-%D This approach permits us to implement a better mechanism
-%D later. We need the \type {\graphicvadjust} in order to
-%D handle:
-%D
-%D \starttyping
-%D \inleft{test} {\red \dorecurse{40}{test }\par}
-%D {\red \inleft{test} \dorecurse{40}{test }\par}
-%D \stoptyping
-%D
-%D The outer margin color is either black or color set as
-%D main text color.
-
-\newif\ifrightmargin % documenteren
-
-\ifx\dopositionmarginbox\undefined
- \def\dopositionmarginbox#1{\graphicvadjust{\box#1}}
-\fi
-
-% watch out, margin dimensions are swapped locally (\swapmargins)
-
-% with \margincontentmethod one can control pagebreaks
-%
-% 0 no break
-% 1 each entry is one line
-% 2 only natural height
-% 3 also stack height
-
-\setnewconstant\margincontentmethod \plusthree % beware: 1 = old method
-\setnewconstant\marginpagecheckmethod \plusone
-\setnewconstant\marginrepositionmethod\plusone
-
-\def\margincontentextralines{1} % old method, play safe
-\def\nofmargincontentlines {0}
-
-\def\doplacemargintext#1#2#3#4%
- {\dontcomplain
- \strut
- \doifsomething{#1}
- {\def\margincontenttag{#1}}%
- \doifinsetelse{\margincontenttag}{\v!left,\v!right} % ugly hack
- {\let \margincontentdistance \empty % signal
- \let \margincontenthoffset \zeropoint}
- {\edef\margincontentdistance{\executeifdefined{\??im\margincontenttag\c!distance }\empty }% signal
- \edef\margincontenthoffset {\executeifdefined{\??im\margincontenttag\c!hoffset }\zeropoint}}%
- \edef\margincontentlines {\executeifdefined{\??im\margincontenttag\c!line }\plusone }%
- \edef\margincontentseparator {\executeifdefined{\??im\margincontenttag\c!separator}\donothing}%
- \setbox\scratchbox\hbox{#4}% % todo: make sure that color stack works
- \ifcase\margincontentmethod
- \scratchdimen\zeropoint
- \or % old method
- \scratchdimen\ht\scratchbox
- \advance\scratchdimen\dp\scratchbox
- \or
- \scratchdimen\naturalmargincontentheight
- \or
- \scratchdimen\naturalmargincontentheight
- \ifx\laststackvmove\undefined\else\global\advance\scratchdimen\laststackvmove\fi
- \fi
- \ifdim\scratchdimen>\margincontentheight
- \global\margincontentheight\scratchdimen
- \fi
- \setbox\scratchbox\hbox
- {#2{\hskip#3\strut
- \ifcase\margincontentdisplacement
- % normal, move strutheight up
- \scratchdimen\strutdp
- \advance\scratchdimen \margincontentstrutheight
- \advance\scratchdimen -\strutht
- \raise\scratchdimen
- \or
- % low, obey vadjust
- \fi
- \box\scratchbox}}%
- \ht\scratchbox\zeropoint
- \dp\scratchbox\zeropoint
- \gdef\margincontentstrutheight{\the\strutht}%
- %\graphicvadjust{\box\scratchbox}} % fails in high math lines, let it be
- %\hbox{\lower\strutdp\box\scratchbox}} % alas, wrong lapping, therefore useless
- \dopositionmarginbox\scratchbox}
-
-\def\domarginblockskip#1%
- {\doifelsenothing\margincontentdistance
- {\hskip\dimexpr
- +\margincontenthoffset
- +\compensatedinnermakeupmargin
- +\csname\??im#1\c!distance\endcsname
- \relax}
- {\hskip\dimexpr
- +\margincontenthoffset
- +\compensatedinnermakeupmargin
- +\margincontentdistance
- \relax}%
- \relax}
-
-\def\doleftmarginblock#1#2%
- {\doplacemargintext{#1}\llap\zeropoint
- {\llap{\placemargincontentseparator}%
- \makemargintextblock\v!left\v!right{#2}%
- \domarginblockskip\v!left}}
-
-\def\dorightmarginblock#1#2%
- {\doplacemargintext{#1}\rlap\hsize
- {\hskip\textwidth\hskip-\hsize % new: hsize correction
- \domarginblockskip\v!right
- \makemargintextblock\v!right\v!left{#2}%
- \rlap{\placemargincontentseparator}}}
-
-\unexpanded\def\placemargincontentseparator
- {\ifnum\margincontentlevel>\zerocount
- \ifx\margincontentseparator\empty\else
- \bgroup
- \scratchdimen\margincontentlines\lineheight
- \advance\scratchdimen -\lineheight
- \lower\scratchdimen\hbox{\margincontentseparator}%
- \egroup
- \fi
- \fi}
-
-\newbox\marginconstructbox
-
-\def\doinmarginswapped#1#2#3#4%
- {\iffirstsidefloatparagraph\nowhitespace\fi % zo laat mogelijk
- \setbox\marginconstructbox\hbox\bgroup % prevents page break in the middle of construction
- \startsignalrightpage
- \doifswappedrightpageelse
- {\rightmargintrue #2}
- {\rightmarginfalse#1}
- {#3}% setups
- {#4}% content
- \stopsignalrightpage
- \egroup
- \unhbox\marginconstructbox}
-
-% history made this a bit complicated, the +/- was needed before
-% we had enough mem/hash to do the page correction
-
-\edef\inmargintaglist{+,-,\v!low,\v!left,\v!right,\v!inner,\v!outer}
-
-% the problem is that we need to keep downward compatibility
-% with respect to the first argument thing a reference or a
-% directive; the alternative is to force users to pass a
-% directive along with a reference; anyhow, as long as one
-% does not use references that have the same name as a
-% directive we can use the (slow) alternative
-
-\def\doinmargin[#1][#2][#3][#4][#5]% #6 #7
- {\expanded{\doifinsetelse{#4}{\inmargintaglist}}
- {\dodoinmargin[#1][#2][#3][#4][#5]}
- {\dodoinmargin[#1][#2][#3][][#4]}}
-
-\unexpanded\def\defineinmargin
- {\doquadrupleempty\dodefineinmargin}
-
-\def\dodefineinmargin[#1][#2][#3][#4]%
- {\doifassignmentelse{#4}
- {\setupinmargin[#1][#4]%
- \setvalue{#1}{\indentation\doquintupleempty\doinmargin[#2][#3][#1]}}
- {\setvalue{#1}{\indentation\doquintupleempty\doinmargin[#2][#3][#4]}}}
-
-\defineinmargin [inleft] [\v!left] [\v!normal] % takes left settings
-\defineinmargin [inright] [\v!right] [\v!normal] % takes right settings
-\defineinmargin [ininner] [\v!inner] [\v!normal] % takes left/right settings
-\defineinmargin [inouter] [\v!outer] [\v!normal] % takes left/right settings
-\defineinmargin [inmargin] [\@@imlocation] [\v!normal] % takes left/right settings
-\defineinmargin [inother] [\@@imlocation] [\v!reverse] % takes left/right settings
-
-\def\inothermargin{\inother}
-
-%D This permits definitions like:
-%D
-%D \starttyping
-%D \defineinmargin [SomePlace] [inner] [normal] [distance=1cm]
-%D \defineinmargin [SomePlace] [inner] [normal] [SomePlace] \setupinmargin[SomePlace][distance=1cm]
-%D \defineinmargin [MyPlace] [inner] [normal] [SomePlace]
-%D \defineinmargin [YourPlace] [inner] [normal] [SomePlace]
-%D \stoptyping
-%D
-%D A torture test:
-%D
-%D \starttyping
-%D \startbuffer
-%D \inleft {\TestLine{red} {l}} test test test \par
-%D \inright {\TestLine{green} {r}} test test test \par
-%D \inmargin {\TestLine{blue} {m}} test test test \par
-%D \inothermargin{\TestLine{yellow} {x}} test test test \par
-%D \ininner {\TestLine{cyan} {i}} test test test \par
-%D \inouter {\TestLine{magenta}{o}} test test test \par
-%D \stopbuffer
-%D
-%D \dorecurse{80}\getbuffer \page
-%D \stoptyping
-%D
-%D and
-%D
-%D \starttyping
-%D \defineinmargin [InOuterA] [outer] [normal] [distance=0cm]
-%D \defineinmargin [InOuterB] [outer] [normal] [distance=1cm]
-%D \defineinmargin [InOuterC] [outer] [normal] [distance=2cm,line=2]
-%D
-%D \startbuffer
-%D \InOuterA{\TestLine{red} {A}} test test test \par
-%D \InOuterB{\TestLine{green}{B}} test test test \par
-%D \InOuterC{\TestLine{blue} {C}} test test test \par
-%D \stopbuffer
-%D
-%D \dorecurse{80}\getbuffer \page
-%D
-%D \dorecurse{10}{\inleft {one} test \inleft {two} test } \page
-%D
-%D \start
-%D \margintext {one} \margintext {two} \input thuan \par
-%D \setupinmargin[1][line=3,distance=1cm]
-%D \margintext [1]{one}
-%D \margintext [2]{two}
-%D \input thuan \page
-%D \stop
-%D
-%D \setupinmargin[3][location=inner,distance=1cm]
-%D \setupinmargin[4][location=outer,distance=2cm]
-%D
-%D % \setupinmargin[left] [line=2]
-%D % \setupinmargin[right][line=2]
-%D
-%D \dorecurse
-%D {10}
-%D {\margintext {\kern3cm\TestLine{blue}{none}}
-%D \margintext[3] {\TestLine{darkgray}{3}}
-%D \margintext[4] {\TestLine{darkgray}{4}}
-%D \margintext[left] {\TestLine{red} {left}}
-%D \margintext[right]{\TestLine{green} {right}}
-%D \margintext[inner]{\TestLine{cyan} {inner}}
-%D \margintext[outer]{\TestLine{magenta} {outer}}
-%D \input thuan \endgraf}
-%D
-%D \dorecurse{10}{\margintext{test\\test\\test} \input thuan \endgraf}
-%D \stoptyping
-
-% Test case:
-%
-% \setuppagenumbering[alternative=doublesided] \setupwhitespace[medium]
-%
-% \placefigure[right]{}{\externalfigure[dummy][width=2cm]}
-% \input tufte \inothermargin{test} \input tufte
-
-% test first
-%
-% setupsystem[random=1235]
-%
-% \setupinmargin[left][sidemethod=3]
-% \dorecurse{10}{test \fakewords{20}{40} test \inleft{test\\test} test \fakewords{20}{40} \par}
-% \page
-% \setupinmargin[left][sidemethod=4]
-% \dorecurse{40}{test \fakewords{50}{80} test \inleft{test\\test} \par}
-% \page
-
-\def\dodoinmargin[#1][#2][#3][#4][#5]#6%
- {\bgroup
- % old stuff, a bit tricky, but now interfaced
- \edef\currentmargincontent{#1}%
- \marginrepositionmethod\executeifdefined{\??im\currentmargincontent\c!sidemethod }\plusone
- \margincontentmethod \executeifdefined{\??im\currentmargincontent\c!textmethod }\plusthree
- \marginpagecheckmethod \executeifdefined{\??im\currentmargincontent\c!splitmethod}\plusone
- % so far
- \forgetall % otherwise sidefloat problems, added 2005/07/20, maybe dangerous
- \postponenotes % group is (somehow) needed
- \doifinsetelse\v!low{#4}
- {\margincontentdisplacement\plusone}
- {\margincontentdisplacement\zerocount}%
- \doif\v!reverse{#2}
- {\swapmacros\dorightmarginblock\doleftmarginblock}%
- \processaction
- [#1]
- [ \v!left=>\let\next\doleftmarginblock, % no swapping
- \v!right=>\let\next\dorightmarginblock, % no swapping
- \v!inner=>\def\next{\doinmarginswapped\dorightmarginblock\doleftmarginblock },
- \v!outer=>\def\next{\doinmarginswapped\doleftmarginblock \dorightmarginblock},
- \s!unknown=>\ifdoublesided
- \doifcommonelse{+,-}{#4}
- {\def\next{\doinmarginswapped\dorightmarginblock\doleftmarginblock }}
- {\def\next{\doinmarginswapped\doleftmarginblock \dorightmarginblock}}%
- \else
- \let\next\doleftmarginblock
- \fi]%
- \next{#3}{#6}%
- \pagereference[#5]% naar binnen ! ! ! !
- \flushnotes
- \egroup % don't forget the group
- \ignorespaces}
-
-% dit zijn voorlopig lokale commando's / vervallen
-%
-% \def\woordinmarge {\indentation\doquintupleempty\doinmargin[\@@implaats][\inleftmargin][\inrightmarge]}
-%
-% \def\woordinlinker {\inleftmargin } % vervallen
-% \def\woordinrechter{\inrechtermarge} % vervallen
-
-% Some day: \definemarking[\v!margetitel]
-
-%D Now come the margin text collectors. The collected content is
-%D flushed at every paragraph by the following macro. Note for
-%D myself: here the location (plaats) is no longer a tag (number).
-
-%D These are now all the same (long ago they had different
-%D implementations, somewhere in Sork time if I remember
-%D right).
-
-\def\margintext {\dodoubleempty\domargincontent}
-\def\marginword {\margintext}
-\def\margintitle{\margintext} % txt mark as well
-
-\newtoks\collectedmargintexts % so .. delayed!
-\newconditional\margintextcollected
-
-\def\domargincontent[#1][#2]#3% we used to check for #2/#1 being number, no longer now
- {\global\settrue\margintextcollected
- \global\let\flushmargincontents\doflushmargincontents
- \edef\margincontenttag{#1}%
- \ifx\margincontenttag\empty
- \global\advance\margincontentlevel\plusone
- \edef\margincontenttag{\number\margincontentlevel}%
- \fi
- \checkinmargin[\margincontenttag]%
- \doglobal \appendetoks
- \noexpand \checkinmargin[\margincontenttag]%
- \noexpand \doinmargin[\executeifdefined{\??im\margincontenttag\c!location}\@@imlocation][\v!normal][\margincontenttag][\margincontenttag][#2]%
- \to \collectedmargintexts
- \doglobal \appendtoks
- {#3}% argument to previously appended \doinmargin
- \to \collectedmargintexts}
-
-\def\doflushmargincontents % plural
- {\ifconditional\margintextcollected
- \expandafter\flushmargincontentsindeed
- \fi}
-
-\let\flushmargincontents\relax
-
-\def\flushmargincontentsindeed % links + rechts
- {\bgroup
- \forgetall
- \global\margincontentheight\zeropoint
- \startsignalrightpage
- \the\collectedmargintexts
- \signalrightpage
- \stopsignalrightpage
- \resetmargincontent
- % dirty tricks
- \ifcase\margincontentmethod
- \donefalse
- \else\ifinsidecolumns % brrrr
- \donetrue % how fuzzy
- \else\ifdim\margincontentheight>\lineheight\relax
- \donetrue % how dirty
- \else
- \donefalse % how needed
- \fi\fi\fi
- \savemargincontentlines
- \ifdone
- \advance\margincontentheight \margincontentextralines\lineheight
- \ifdim\pagegoal>\pagetotal
- \bgroup % preserve \margincontentheight
- \advance\margincontentheight \pagetotal
- \ifdim\margincontentheight>\pagegoal
- \egroup
- \ifcase\marginpagecheckmethod
- % disabled
- \or
- \setmargincontentpenalties
- \or
- % potentially dangerous, maybe better a \goodbreak; the problem is that
- % there can be a penalty there, which we then overload and we also introduce
- % nasty side effects, so, we drop this option
- % \vadjust pre {\page}%
- \fi
- \else
- \egroup
- \fi
- \fi
- \else % We need the above because interlinepenalties overrule vadjusted \nobreaks.
- % a bit dangerous
- \vadjust{\nobreak}%
- \fi
- \global\let\flushmargincontents\relax
- \egroup}
-
-\def\setmargincontentpenalties
- {\getnoflines\margincontentheight
- \keeplinestogether\noflines}
-
-\def\savemargincontentlines
- {\bgroup
- \advance\margincontentheight \margincontentextralines\lineheight % 1 by default
- \getnoflines\margincontentheight
- \xdef\nofmargincontentlines{\the\noflines}%
- \egroup}
-
-\def\fillupmargincontentlines % etex ! ! !
- {\endgraf
- \begingroup
- \scratchcounter\numexpr\nofmargincontentlines-\prevgraf\relax\relax
- \ifnum\scratchcounter>\zerocount
- \forgetall\dorecurse\scratchcounter{\nobreak\crlf}%
- \fi
- \endgroup}
-
-% Yet undocumented, for a manual flush in for instance headers.
-
-\def\resetmargincontent
- {\global\margincontentlevel\zerocount
- \global\setfalse\margintextcollected
- \global\collectedmargintexts\emptytoks}
-
-\unexpanded\def\placemargincontent
- {\ifconditional\margintextcollected % was level check
- \bgroup
- \redoconvertfont % !!
- %\setfalse\graphicvadjustmode % not used
- \flushmargincontentsindeed
- \egroup
- \fi}
-
-% For old times sake (i use it in project styles) we provide
-
-\unexpanded\def\placemargintexts {\placemargincontent}
-\def\resetmargetitels {\resetmargincontent}
-\def\margewoordpositie{\margewoord} % obsolete, now no longer range
-
-% but never use them yourself since they may disappear.
-
-\def\oplinker#1%
- {\strut
- \graphicvadjust
- {\dontcomplain
- \setbox\scratchbox\vtop{\forgetall\strut#1}%
- \getboxheight\scratchdimen\of\box\scratchbox
- \vskip-\scratchdimen % waarom stond hier een \ ?
- \box\scratchbox}}
-
-\setupinmargin
- [\c!style=\v!bold,
- \c!color=,
- \c!strut=\v!auto,
- \c!location=\v!both,
- \c!align=\v!inner,
- \c!stack=\v!no,
- \c!before=,
- \c!after=]
-
-\setupinmargin
- [\v!left]
- [\c!distance=\leftmargindistance,
- \c!width=\leftmarginwidth,
- %\c!align=\v!left, % no
- \c!location=\v!left]
-
-\setupinmargin
- [\v!right]
- [\c!distance=\rightmargindistance,
- \c!width=\rightmarginwidth,
- %\c!align=\v!right, % no
- \c!location=\v!right]
-
-% bonus needed when [inner/outer] is used as tag
-
-\setupinmargin[\v!inner][\c!location=\v!inner,\c!align=\v!inner]
-\setupinmargin[\v!outer][\c!location=\v!outer,\c!align=\v!inner]
-
-% more efficient (5K less fotmat file)
-%
-% \letvalue{\??im\v!inner\c!location}\v!inner \letvalue{\??im\v!inner\c!align}\v!inner
-% \letvalue{\??im\v!outer\c!location}\v!outer \letvalue{\??im\v!outer\c!align}\v!inner
-
-\protect \endinput
diff --git a/tex/context/base/ppchtex.mkiv b/tex/context/base/ppchtex.mkiv
index c5993d234..7bba6f539 100644
--- a/tex/context/base/ppchtex.mkiv
+++ b/tex/context/base/ppchtex.mkiv
@@ -12,6 +12,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+\endinput
+
% option=test => boxes
% dummy => file
% final => file / local run
@@ -471,7 +473,7 @@
\endpspicture
\or
\resetchemicalcoordinates
- \setbox2\hbox{\MPshiftdrawingtrue\MPstaticgraphictrue\getMPdrawing}%
+ \setbox2\hbox{\ignoreMPboxdepth\getMPdrawing}%
\wd2=\!!zeropoint
\ht2=\!!zeropoint
\dp2=\!!zeropoint
@@ -512,7 +514,7 @@
\put {\box\chemicalsymbols} at 0 0 % elders
\ifMPdrawingdone
\resetchemicalcoordinates
- \setbox2\hbox{\MPshiftdrawingtrue\MPstaticgraphictrue\getMPdrawing}%
+ \setbox2\hbox{\ignoreMPboxdepth\getMPdrawing}%
\wd2=\!!zeropoint
\ht2=\!!zeropoint
\dp2=\!!zeropoint
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index a8c683d4e..35095085f 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -860,6 +860,8 @@
%D \NC \NC a normal strut \NC {\showstruts\setupstrut\strut} \NC \NR
%D \stoptabulate
+%D Beware: using an unknown value results in char struts.
+
\unexpanded\def\setupstrut
{\dosingleempty\spacing_setup_strut}
@@ -870,6 +872,13 @@
\setcharstrut{#1}%
\fi}
+\def\synchronizestrut#1% no [] parsing, faster for internal
+ {\ifcsname\??ut:#1\endcsname
+ \csname\??ut:#1\endcsname
+ \else
+ \setcharstrut{#1}%
+ \fi}
+
\unexpanded\def\showstruts
{\setteststrut
\settestcrlf}
@@ -999,7 +1008,7 @@
%D Keyword based strutting:
\letvalue{\??ut:\v!yes }\setstrut % \setvalue{\??ut:\v!yes }{\setstrut}
-\setvalue{\??ut:\v!auto }\setautostrut % \setvalue{\??ut:\v!auto }{\setautostrut}
+\letvalue{\??ut:\v!auto }\setautostrut % \setvalue{\??ut:\v!auto }{\setautostrut}
\letvalue{\??ut:\v!no }\setnostrut % \setvalue{\??ut:\v!no }{\setnostrut}
\letvalue{\??ut:\v!cap }\setcapstrut % \setvalue{\??ut:\v!cap }{\setcapstrut}
\letvalue{\??ut:\v!fit }\setfontstrut % \setvalue{\??ut:\v!fit }{\setfontstrut}
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 7e2f7b240..b597325e1 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 9e33d0c09..87ecffba8 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv
index a5127a0ab..62aff5f3f 100644
--- a/tex/context/base/syst-ini.mkiv
+++ b/tex/context/base/syst-ini.mkiv
@@ -242,6 +242,7 @@
\normalprotected\def\newconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1}
\normalprotected\def\setnewconstant#1{\ifdefined#1\let#1\undefined\fi\newcount#1#1} % just a number
+\normalprotected\def\setconstant {} % dummy
% maybe setconstant with check
diff --git a/tex/context/base/tabl-tab.mkiv b/tex/context/base/tabl-tab.mkiv
index 421a9d0ba..c71198f05 100644
--- a/tex/context/base/tabl-tab.mkiv
+++ b/tex/context/base/tabl-tab.mkiv
@@ -2173,7 +2173,7 @@
\def\dolocaltablesetup
{\@@ticommands\relax
- \expanded{\switchtobodyfont[\@@tibodyfont]}% expanded ?
+ \doifsomething\@@tibodyfont{\switchtobodyfont[\@@tibodyfont]}%
\tablelinethicknessunit\dimexpr\@@tirulethickness/\tablelinethicknessfactor\relax
\doifelse\@@tiheight\v!strut
{\let\tablestrutheightfactor\tablestrutheightfactor}
@@ -2250,7 +2250,7 @@
\c!rulethickness=\linewidth,
\c!rulecolor=,
\c!distance=\v!medium,
- \c!bodyfont=\the\bodyfontsize,
+ \c!bodyfont=,
\c!commands=,
\c!background=\v!screen,
\c!backgroundscreen=\@@rsscreen,
diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv
index 64a08e22a..e906bb50d 100644
--- a/tex/context/base/trac-vis.mkiv
+++ b/tex/context/base/trac-vis.mkiv
@@ -517,8 +517,8 @@
\ht#2\tractempheight
\dp#2\tractempdepth}
-\def\colormarkbox {\ifincolor\@EA\docolormarkbox\else\@EA\gobbletwoarguments\fi\plusone } % #1
-\def\rastermarkbox{\ifincolor\@EA\docolormarkbox\else\@EA\gobbletwoarguments\fi\zerocount} % #1
+\def\colormarkbox {\docolormarkbox\plusone } % #1
+\def\rastermarkbox{\docolormarkbox\zerocount} % #1
%D \macros
%D {showwhatsits, dontshowwhatsits}
diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml
index 963fe5c6e..fe13663f2 100644
--- a/tex/context/interface/keys-cs.xml
+++ b/tex/context/interface/keys-cs.xml
@@ -581,6 +581,7 @@
<cd:constant name='blank' value='prazdny'/>
<cd:constant name='blockway' value='dobloku'/>
<cd:constant name='bodyfont' value='zakladnifont'/>
+ <cd:constant name='boffset' value='boffset'/>
<cd:constant name='bookmark' value='zalozka'/>
<cd:constant name='bottom' value='spodek'/>
<cd:constant name='bottomafter' value='bottomafter'/>
@@ -771,6 +772,7 @@
<cd:constant name='listtext' value='listtext'/>
<cd:constant name='local' value='lokalne'/>
<cd:constant name='location' value='misto'/>
+ <cd:constant name='loffset' value='loffset'/>
<cd:constant name='logo' value='logo'/>
<cd:constant name='logos' value='loga'/>
<cd:constant name='marcolor' value='barvaznacky'/>
@@ -924,6 +926,7 @@
<cd:constant name='rightsubsentence' value='podvetavpravo'/>
<cd:constant name='righttext' value='textvpravo'/>
<cd:constant name='rightwidth' value='sirkavpravo'/>
+ <cd:constant name='roffset' value='roffset'/>
<cd:constant name='rotation' value='rotace'/>
<cd:constant name='rule' value='linka'/>
<cd:constant name='rulecolor' value='barvalinky'/>
@@ -1018,6 +1021,7 @@
<cd:constant name='titleright' value='titleright'/>
<cd:constant name='titlestyle' value='styltitulek'/>
<cd:constant name='to' value='na'/>
+ <cd:constant name='toffset' value='toffset'/>
<cd:constant name='tolerance' value='tolerance'/>
<cd:constant name='top' value='vrsek'/>
<cd:constant name='topdistance' value='vzdalenostvrsku'/>
diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml
index ec36abc0d..b7e891e58 100644
--- a/tex/context/interface/keys-de.xml
+++ b/tex/context/interface/keys-de.xml
@@ -581,6 +581,7 @@
<cd:constant name='blank' value='blanko'/>
<cd:constant name='blockway' value='blockauf'/>
<cd:constant name='bodyfont' value='fliesstext'/>
+ <cd:constant name='boffset' value='boffset'/>
<cd:constant name='bookmark' value='bookmark'/>
<cd:constant name='bottom' value='unten'/>
<cd:constant name='bottomafter' value='bottomafter'/>
@@ -771,6 +772,7 @@
<cd:constant name='listtext' value='listtext'/>
<cd:constant name='local' value='lokal'/>
<cd:constant name='location' value='platz'/>
+ <cd:constant name='loffset' value='loffset'/>
<cd:constant name='logo' value='logo'/>
<cd:constant name='logos' value='logos'/>
<cd:constant name='marcolor' value='beschrfarbe'/>
@@ -924,6 +926,7 @@
<cd:constant name='rightsubsentence' value='rechtersubsatz'/>
<cd:constant name='righttext' value='rechtertext'/>
<cd:constant name='rightwidth' value='rechterbreite'/>
+ <cd:constant name='roffset' value='roffset'/>
<cd:constant name='rotation' value='rotation'/>
<cd:constant name='rule' value='linie'/>
<cd:constant name='rulecolor' value='linienfarbe'/>
@@ -1018,6 +1021,7 @@
<cd:constant name='titleright' value='titleright'/>
<cd:constant name='titlestyle' value='titelstil'/>
<cd:constant name='to' value='zu'/>
+ <cd:constant name='toffset' value='toffset'/>
<cd:constant name='tolerance' value='toleranz'/>
<cd:constant name='top' value='oben'/>
<cd:constant name='topdistance' value='obenabstand'/>
diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml
index d7ba6ea65..d351f511b 100644
--- a/tex/context/interface/keys-en.xml
+++ b/tex/context/interface/keys-en.xml
@@ -581,6 +581,7 @@
<cd:constant name='blank' value='blank'/>
<cd:constant name='blockway' value='blockway'/>
<cd:constant name='bodyfont' value='bodyfont'/>
+ <cd:constant name='boffset' value='boffset'/>
<cd:constant name='bookmark' value='bookmark'/>
<cd:constant name='bottom' value='bottom'/>
<cd:constant name='bottomafter' value='bottomafter'/>
@@ -771,6 +772,7 @@
<cd:constant name='listtext' value='listtext'/>
<cd:constant name='local' value='local'/>
<cd:constant name='location' value='location'/>
+ <cd:constant name='loffset' value='loffset'/>
<cd:constant name='logo' value='logo'/>
<cd:constant name='logos' value='logos'/>
<cd:constant name='marcolor' value='marcolor'/>
@@ -924,6 +926,7 @@
<cd:constant name='rightsubsentence' value='rightsubsentence'/>
<cd:constant name='righttext' value='righttext'/>
<cd:constant name='rightwidth' value='rightwidth'/>
+ <cd:constant name='roffset' value='roffset'/>
<cd:constant name='rotation' value='rotation'/>
<cd:constant name='rule' value='rule'/>
<cd:constant name='rulecolor' value='rulecolor'/>
@@ -1018,6 +1021,7 @@
<cd:constant name='titleright' value='titleright'/>
<cd:constant name='titlestyle' value='titlestyle'/>
<cd:constant name='to' value='to'/>
+ <cd:constant name='toffset' value='toffset'/>
<cd:constant name='tolerance' value='tolerance'/>
<cd:constant name='top' value='top'/>
<cd:constant name='topdistance' value='topdistance'/>
diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml
index 8f8bc73ee..0facadd4b 100644
--- a/tex/context/interface/keys-fr.xml
+++ b/tex/context/interface/keys-fr.xml
@@ -581,6 +581,7 @@
<cd:constant name='blank' value='vide'/>
<cd:constant name='blockway' value='blockway'/>
<cd:constant name='bodyfont' value='policecorps'/>
+ <cd:constant name='boffset' value='boffset'/>
<cd:constant name='bookmark' value='marquepage'/>
<cd:constant name='bottom' value='inf'/>
<cd:constant name='bottomafter' value='bottomafter'/>
@@ -771,6 +772,7 @@
<cd:constant name='listtext' value='texteliste'/>
<cd:constant name='local' value='local'/>
<cd:constant name='location' value='emplacement'/>
+ <cd:constant name='loffset' value='loffset'/>
<cd:constant name='logo' value='logo'/>
<cd:constant name='logos' value='logos'/>
<cd:constant name='marcolor' value='couleurmarquage'/>
@@ -924,6 +926,7 @@
<cd:constant name='rightsubsentence' value='sousphrasedroite'/>
<cd:constant name='righttext' value='textedroit'/>
<cd:constant name='rightwidth' value='largeurdroite'/>
+ <cd:constant name='roffset' value='roffset'/>
<cd:constant name='rotation' value='rotation'/>
<cd:constant name='rule' value='ligne'/>
<cd:constant name='rulecolor' value='couleurligne'/>
@@ -1018,6 +1021,7 @@
<cd:constant name='titleright' value='titleright'/>
<cd:constant name='titlestyle' value='styletitre'/>
<cd:constant name='to' value='vers'/>
+ <cd:constant name='toffset' value='toffset'/>
<cd:constant name='tolerance' value='tolerance'/>
<cd:constant name='top' value='sup'/>
<cd:constant name='topdistance' value='distancesup'/>
diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml
index e4a2707df..d28cacba1 100644
--- a/tex/context/interface/keys-it.xml
+++ b/tex/context/interface/keys-it.xml
@@ -581,6 +581,7 @@
<cd:constant name='blank' value='rigovuoto'/>
<cd:constant name='blockway' value='blockway'/>
<cd:constant name='bodyfont' value='fonttesto'/>
+ <cd:constant name='boffset' value='boffset'/>
<cd:constant name='bookmark' value='segnalibro'/>
<cd:constant name='bottom' value='fondo'/>
<cd:constant name='bottomafter' value='bottomafter'/>
@@ -771,6 +772,7 @@
<cd:constant name='listtext' value='listtext'/>
<cd:constant name='local' value='locale'/>
<cd:constant name='location' value='luogo'/>
+ <cd:constant name='loffset' value='loffset'/>
<cd:constant name='logo' value='logo'/>
<cd:constant name='logos' value='loghi'/>
<cd:constant name='marcolor' value='coloremarcatura'/>
@@ -924,6 +926,7 @@
<cd:constant name='rightsubsentence' value='sottofrasedestra'/>
<cd:constant name='righttext' value='testodestro'/>
<cd:constant name='rightwidth' value='ampiezzadestra'/>
+ <cd:constant name='roffset' value='roffset'/>
<cd:constant name='rotation' value='rotazione'/>
<cd:constant name='rule' value='linea'/>
<cd:constant name='rulecolor' value='colorelinea'/>
@@ -1018,6 +1021,7 @@
<cd:constant name='titleright' value='titleright'/>
<cd:constant name='titlestyle' value='stiletitolo'/>
<cd:constant name='to' value='verso'/>
+ <cd:constant name='toffset' value='toffset'/>
<cd:constant name='tolerance' value='tolleranza'/>
<cd:constant name='top' value='cima'/>
<cd:constant name='topdistance' value='distanzacima'/>
diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml
index 16853ed49..2d742834d 100644
--- a/tex/context/interface/keys-nl.xml
+++ b/tex/context/interface/keys-nl.xml
@@ -581,6 +581,7 @@
<cd:constant name='blank' value='blanko'/>
<cd:constant name='blockway' value='blokwijze'/>
<cd:constant name='bodyfont' value='korps'/>
+ <cd:constant name='boffset' value='boffset'/>
<cd:constant name='bookmark' value='bookmark'/>
<cd:constant name='bottom' value='onder'/>
<cd:constant name='bottomafter' value='bottomafter'/>
@@ -771,6 +772,7 @@
<cd:constant name='listtext' value='lijsttekst'/>
<cd:constant name='local' value='lokaal'/>
<cd:constant name='location' value='plaats'/>
+ <cd:constant name='loffset' value='loffset'/>
<cd:constant name='logo' value='logo'/>
<cd:constant name='logos' value='logos'/>
<cd:constant name='marcolor' value='markleur'/>
@@ -924,6 +926,7 @@
<cd:constant name='rightsubsentence' value='rechtersubzin'/>
<cd:constant name='righttext' value='rechtertekst'/>
<cd:constant name='rightwidth' value='rechterbreedte'/>
+ <cd:constant name='roffset' value='roffset'/>
<cd:constant name='rotation' value='rotatie'/>
<cd:constant name='rule' value='lijn'/>
<cd:constant name='rulecolor' value='lijnkleur'/>
@@ -1018,6 +1021,7 @@
<cd:constant name='titleright' value='titelrechts'/>
<cd:constant name='titlestyle' value='titelletter'/>
<cd:constant name='to' value='aan'/>
+ <cd:constant name='toffset' value='toffset'/>
<cd:constant name='tolerance' value='tolerantie'/>
<cd:constant name='top' value='boven'/>
<cd:constant name='topdistance' value='bovenafstand'/>
diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml
index 9c6d37174..de6f6aa6b 100644
--- a/tex/context/interface/keys-pe.xml
+++ b/tex/context/interface/keys-pe.xml
@@ -581,6 +581,7 @@
<cd:constant name='blank' value='خالی'/>
<cd:constant name='blockway' value='راه‌بلوک'/>
<cd:constant name='bodyfont' value='قلم‌بدنه'/>
+ <cd:constant name='boffset' value='boffset'/>
<cd:constant name='bookmark' value='چوبخط'/>
<cd:constant name='bottom' value='پایین'/>
<cd:constant name='bottomafter' value='bottomafter'/>
@@ -771,6 +772,7 @@
<cd:constant name='listtext' value='متن‌لیست'/>
<cd:constant name='local' value='موضعی'/>
<cd:constant name='location' value='مکان'/>
+ <cd:constant name='loffset' value='loffset'/>
<cd:constant name='logo' value='آرم'/>
<cd:constant name='logos' value='آرمها'/>
<cd:constant name='marcolor' value='رنگ‌حاش'/>
@@ -924,6 +926,7 @@
<cd:constant name='rightsubsentence' value='زیرجمله‌راست'/>
<cd:constant name='righttext' value='متن‌راست'/>
<cd:constant name='rightwidth' value='عرض‌راست'/>
+ <cd:constant name='roffset' value='roffset'/>
<cd:constant name='rotation' value='دوران'/>
<cd:constant name='rule' value='خط'/>
<cd:constant name='rulecolor' value='رنگ‌خط'/>
@@ -1018,6 +1021,7 @@
<cd:constant name='titleright' value='عنوان‌راست'/>
<cd:constant name='titlestyle' value='سبک‌عنوان'/>
<cd:constant name='to' value='به'/>
+ <cd:constant name='toffset' value='toffset'/>
<cd:constant name='tolerance' value='بردباری'/>
<cd:constant name='top' value='بالا'/>
<cd:constant name='topdistance' value='فاصله‌بالا'/>
diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml
index ec69be517..d0d647620 100644
--- a/tex/context/interface/keys-ro.xml
+++ b/tex/context/interface/keys-ro.xml
@@ -581,6 +581,7 @@
<cd:constant name='blank' value='blanc'/>
<cd:constant name='blockway' value='blockway'/>
<cd:constant name='bodyfont' value='fonttext'/>
+ <cd:constant name='boffset' value='boffset'/>
<cd:constant name='bookmark' value='semncarte'/>
<cd:constant name='bottom' value='jos'/>
<cd:constant name='bottomafter' value='bottomafter'/>
@@ -771,6 +772,7 @@
<cd:constant name='listtext' value='listtext'/>
<cd:constant name='local' value='local'/>
<cd:constant name='location' value='locatie'/>
+ <cd:constant name='loffset' value='loffset'/>
<cd:constant name='logo' value='logo'/>
<cd:constant name='logos' value='logos'/>
<cd:constant name='marcolor' value='culoaremarcaj'/>
@@ -924,6 +926,7 @@
<cd:constant name='rightsubsentence' value='subpropozitiedreapta'/>
<cd:constant name='righttext' value='textdreapta'/>
<cd:constant name='rightwidth' value='marginedreapta'/>
+ <cd:constant name='roffset' value='roffset'/>
<cd:constant name='rotation' value='rotatie'/>
<cd:constant name='rule' value='rigla'/>
<cd:constant name='rulecolor' value='culoarerigla'/>
@@ -1018,6 +1021,7 @@
<cd:constant name='titleright' value='titleright'/>
<cd:constant name='titlestyle' value='stiltitlu'/>
<cd:constant name='to' value='catre'/>
+ <cd:constant name='toffset' value='toffset'/>
<cd:constant name='tolerance' value='toleranta'/>
<cd:constant name='top' value='sus'/>
<cd:constant name='topdistance' value='distantasus'/>
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 1c8b0b763..ff3fe655a 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 12/20/11 22:24:50
+-- merge date : 12/22/11 14:43:04
do -- begin closure to overcome local limits and interference