summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/pack-rul.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/pack-rul.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/pack-rul.mkiv273
1 files changed, 187 insertions, 86 deletions
diff --git a/Master/texmf-dist/tex/context/base/pack-rul.mkiv b/Master/texmf-dist/tex/context/base/pack-rul.mkiv
index 26fdaadeaf5..afacc2901b1 100644
--- a/Master/texmf-dist/tex/context/base/pack-rul.mkiv
+++ b/Master/texmf-dist/tex/context/base/pack-rul.mkiv
@@ -13,6 +13,8 @@
\writestatus{loading}{ConTeXt Packaging Macros / Ruled Content}
+%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.
@@ -51,7 +53,7 @@
\def\dosetuplinewidth[#1]%
{\assigndimension{#1}\linewidth{.2\points}{.4\points}{.6\points}}
-\def\setuplinewidth
+\unexpanded\def\setuplinewidth
{\dosingleargument\dosetuplinewidth}
%D \macros
@@ -71,7 +73,7 @@
%D
%D \showsetup{setupscreens}
-\def\setupscreens
+\unexpanded\def\setupscreens
{\dodoubleargument\getparameters[\??rs]}
%D We will communicate through module specific variables, current
@@ -293,7 +295,7 @@
\appendtoks \oninterlineskip \to \everyoverlay
-\def\defineoverlay
+\unexpanded\def\defineoverlay
{\dodoubleargument\dodefineoverlay}
\def\dodefineoverlay[#1][#2]%
@@ -415,7 +417,7 @@
\setlayoutcomponentattribute\v!background\component
\fi
\let\foregroundbox\normalforegroundbox
- \hbox to \backgroundwidth \layoutcomponentboxattribute % width in case 'foreground' is used as overlay
+ \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}}}
@@ -610,6 +612,8 @@
\def\inheritlocalframed[#1]#2[#3]{\letvalue{#1\s!parent}#3}
\def\copylocalframed [#1]#2[#3]{\setvalue{#1\s!parent}{#3}}
+\let\setuplocalframed\getparameters % obsolete
+
\presetlocalframed[\??ol]
\newcount\framednesting
@@ -620,7 +624,7 @@
\expandafter\let\csname\??ol:\the\framednesting\s!parent\endcsname\??ol
\dodoubleempty\startlocalframed[\??ol:\the\framednesting]}
-\def\setupframed
+\unexpanded\def\setupframed
{\dodoubleempty\dosetupframed}
\def\dosetupframed
@@ -766,24 +770,38 @@
%D Because it is used so often the he next macro is (and
%D looks) rather optimized.
+% \def\s!root{root} % maybe configurable
+
\let\postprocessframebox\relax
\let\@@framed\s!unknown
-\def\framedparameter #1{\csname\doframedparameter\@@framed#1\endcsname}
+% \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\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\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\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\s!root{root} % maybe configurable
-
-\def\doframedparentparameter#1#2{\ifx#1\relax\doframedrootparameter#2\else\doframedparameter#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\frameddimension#1{\the\dimexpr\framedparameter{#1}\relax}
+
\def\dosetframedattributes#1#2% style color
{\edef\fontattributehash {\framedparameterhash#1}%
\edef\colorattributehash{\framedparameterhash#2}%
@@ -866,7 +884,7 @@
% todo: protect local \framednames
-\def\startlocalframed[#1][#2]%
+\unexpanded\def\startlocalframed[#1][#2]%
{\bgroup
\inframedtrue
\edef\@@framed{#1}%
@@ -884,7 +902,7 @@
\framedparameter\c!extras
% to get the right spacing
\edef\fontattributehash{\framedparameterhash\c!foregroundstyle}%
- \ifx\fontattributehash\empty\else\dosetfontattribute \fontattributehash\c!foregroundstyle\fi
+ \ifx\fontattributehash\empty\else\dosetfontattribute\fontattributehash\c!foregroundstyle\fi
% beware, both the frame and background offset can be overruled
%
\edef\doframedsetups{\framedparameter\c!setups}%
@@ -1088,6 +1106,7 @@
\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}
@@ -1134,7 +1153,7 @@
%D ...,bottom=\kern0pt,...
%D \stoptyping
-\def\stoplocalframed
+\unexpanded\def\stoplocalframed
{\dontshowcomposition
\@@stopframedorientation % hm, wrong place ! should rotate the result (after reshape)
\handleframedlocator\c!before\@@locallocation
@@ -1441,14 +1460,16 @@
\def\doinlinemframed[#1]#2%
{\begingroup
\mframedstyle\mathstyle\relax
- \inframed[#1]{$\triggermathstyle\mframedstyle#2$}%
+ \inframed[#1]{\Ustartmath\triggermathstyle\mframedstyle#2\Ustopmath}%
\endgroup}
+\def\funnymathstrut{\Ustartmath\triggermathstyle\mframedstyle\vphantom{(}\Ustopmath}
+
\def\dodisplaymframed[#1]#2%
{\begingroup
\mframedstyle\mathstyle\relax
- \def\normalstrut{$\triggermathstyle\mframedstyle\vphantom{(}$}%
- \framed[#1]{$\triggermathstyle\mframedstyle#2$}%
+ \let\normalstrut\funnymathstrut
+ \framed[#1]{\Ustartmath\triggermathstyle\mframedstyle#2\Ustopmath}%
\endgroup}
\def\mframed {\dosingleempty\dodisplaymframed}
@@ -1862,9 +1883,9 @@
%D framecolorkaderkleur=DemoBlue,
%D rulethickness=2pt]
%D \def\status%
-%D {backgroundoffset=\framedparameter\c!backgroundoffset\\
-%D frameoffset=\framedparameter\c!frameoffset\\
-%D depth=\framedparameter\c!depth}
+%D {backgroundoffset=\the\dimexpr\framedparameter\c!backgroundoffset\relax\\
+%D frameoffset=\the\dimexpr\framedparameter\c!frameoffset\relax\\
+%D depth=\the\dimexpr\framedparameter\c!depth\relax}
%D \dontleavehmode \ruledhbox{\framed[backgroundoffset=0pt,frameoffset=0pt]{\status}}
%D \vss
%D \dontleavehmode \ruledhbox{\framed[backgroundoffset=5pt,frameoffset=0pt]{\status}}
@@ -2048,7 +2069,7 @@
%D
%D \showsetup{setupblackrules}
-\def\setupblackrules
+\unexpanded\def\setupblackrules
{\dodoubleargument\getparameters[\??bj]}
%D \macros
@@ -2185,7 +2206,7 @@
%D
%D \showsetup{setupmarginrules}
-\def\setupmarginrules
+\unexpanded\def\setupmarginrules
{\dodoubleargument\getparameters[\??ka]}
%D \macros
@@ -2267,13 +2288,13 @@
%D \showsetup{vl}
%D \showsetup{hl}
-\def\complexvl[#1]%
+\def\dovlwdhtdp#1#2#3%
{\bgroup
- \!!dimena#1\strutht
- \!!dimenb#1\strutdp
+ \!!dimena#2\strutht
+ \!!dimenb#3\strutdp
\setbox\scratchbox\hbox
{\vrule
- \!!width \linewidth
+ \!!width #1\linewidth
\!!height\!!dimena
\!!depth \!!dimenb}%
\dp\scratchbox\strutdp
@@ -2281,6 +2302,9 @@
\box\scratchbox
\egroup}
+\def\complexvl[#1]%
+ {\dovlwdhtdp{1}{#1}{#1}}
+
\def\complexhl[#1]%
{\hbox
{\vrule
@@ -2412,7 +2436,7 @@
\def\dosetupthinrules[#1]%
{\getparameters[\??dl][#1]}
-\def\setupthinrules
+\unexpanded\def\setupthinrules
{\dosingleargument\dosetupthinrules}
\def\dothinrules[#1]%
@@ -2633,11 +2657,11 @@
\c!orientation=,
\c!indenting=,
#2]%
- \setvalue{\e!start#1}{\dostartframedtext[#1]}%
- \setvalue{\e!stop #1}{\dostopframedtext }%
- \setvalue {#1}{\doframedtext [#1]}}
+ \setuvalue{\e!start#1}{\dostartframedtext[#1]}%
+ \setuvalue{\e!stop #1}{\dostopframedtext }%
+ \setuvalue {#1}{\doframedtext [#1]}}
-\def\defineframedtext
+\unexpanded\def\defineframedtext
{\dodoubleempty\dodefineframedtext}
%D We define the general (and original) case by just saying:
@@ -2648,7 +2672,7 @@
%D because we have to handle an optional identifier (and
%D because these commands evolved out of a single case).
-\def\framedtextparameter#1#2%
+\def\framedtextparameter#1#2% todo: currentframedtext
{\csname\??kd#1#2\endcsname}
\def\dosetupframedtexts[#1][#2]%
@@ -2659,7 +2683,7 @@
\getparameters[\??kd\v!framedtext][#1]%
\fi}
-\def\setupframedtexts
+\unexpanded\def\setupframedtexts
{\dodoubleempty\dosetupframedtexts}
\def\dostartframedtext
@@ -2806,12 +2830,12 @@
%D
%D \showsetup{defineframed}
-\def\defineframed
+\unexpanded\def\defineframed
{\dodoubleempty\dodefineframed}
\def\dodefineframed[#1][#2]%
{\iffirstargument
- \setvalue{#1}{\dodoubleempty\doframed[#2]}%
+ \setuvalue{#1}{\dodoubleempty\doframed[#2]}%
\fi}
\def\doframed[#1][#2]%
@@ -2865,7 +2889,7 @@
%D The implementation looks a bit complicated due to the
%D optional arguments.
-\def\setuptextrules
+\unexpanded\def\setuptextrules
{\dodoubleargument\getparameters[\??tl]}
\def\complextextrule[#1]% if needed we can make it installable
@@ -2888,15 +2912,13 @@
\setbox\scratchbox\hbox to \hsize
{\dimen4\dimexpr .5ex+.5\linewidth\relax
\dimen6\dimexpr-.5ex+.5\linewidth\relax
- \doifnothing{#1}\firstargumentfalse
- \iffirstargument
- \doifelse\@@tllocation\v!inmargin
- {\llap{\doattributes\??tl\c!style\c!color{#1}\hskip\leftmargindistance}}
- {\color[\@@tlrulecolor]
- {\vrule\!!height\dimen4\!!depth\dimen6\!!width\@@tlwidth}%
- \hbox spread 2\dimexpr\@@tldistance\relax
- {\hss\doattributes\??tl\c!style\c!color{\strut#1}\hss}}%
- \fi
+ \doifsomething{#1}
+ {\doifelse\@@tllocation\v!inmargin
+ {\llap{\doattributes\??tl\c!style\c!color{#1}\hskip\leftmargindistance}}
+ {\color[\@@tlrulecolor]
+ {\vrule\!!height\dimen4\!!depth\dimen6\!!width\@@tlwidth}%
+ \hbox spread 2\dimexpr\@@tldistance\relax
+ {\hss\doattributes\??tl\c!style\c!color{\strut#1}\hss}}}%
\color[\@@tlrulecolor]
{\leaders\hrule\!!height\dimen4\!!depth\dimen6\hfill}}%
\ht\scratchbox\strutht
@@ -2961,14 +2983,14 @@
%D The grouped commands also supports bodyfont switching:
-\def\starttextrule#1%
+\unexpanded\def\starttextrule#1%
{\bgroup
\def\dounknowntextrule{\domiddletextrule}
\dotoptextrule{#1}
\bgroup
\doifsomething\@@tlbodyfont{\switchtobodyfont[\@@tlbodyfont]}}
-\def\stoptextrule
+\unexpanded\def\stoptextrule
{\par
\egroup
\dobottomtextrule\empty
@@ -2997,7 +3019,7 @@
%D \showsetup{fillinrules}
%D \showsetup{setupfillinrules}
-\def\setupfillinrules
+\unexpanded\def\setupfillinrules
{\dodoubleargument\getparameters[\??il]}
\definecomplexorsimpleempty\fillinrules
@@ -3080,7 +3102,7 @@
%D \showsetup{fillinline}
%D \showsetup{setupfillinlines}
-\def\setupfillinlines
+\unexpanded\def\setupfillinlines
{\dodoubleargument\getparameters[\??iv]}
\definecomplexorsimpleempty\fillinline
@@ -3160,7 +3182,7 @@
\let\stopbackground \relax
\let\background \relax}}
-\def\setupbackground
+\unexpanded\def\setupbackground
{\dosingleargument\dosetupbackground}
%D Actually typesetting the background is implemented rather
@@ -3312,50 +3334,128 @@
%D
%D \typebuffer
-\def\defineframedcontent
+% \unexpanded\def\defineframedcontent
+% {\dodoubleempty\dodefineframedcontent}
+%
+% \def\dodefineframedcontent[#1][#2]%
+% {\presetlocalframed[\??fc#1]%
+% \getparameters[\??fc#1]
+% [\c!leftoffset=\zeropoint,
+% \c!rightoffset=\getvalue{\??fc#1\c!leftoffset},
+% \c!topoffset=\zeropoint,
+% \c!bottomoffset=\getvalue{\??fc#1\c!topoffset},
+% \c!strut=\v!no,
+% \c!offset=\v!overlay,
+% \c!linecorrection=\v!no,
+% \c!left=,
+% \c!right=,
+% #2]}
+%
+% \unexpanded\def\setupframedcontent
+% {\dodoubleempty\dosetupframedcontent}
+%
+% \def\dosetupframedcontent[#1][#2]%
+% {\def\docommand##1{\getparameters[\??fc##1][#2]}%
+% \processcommacommand[#1]\docommand}
+%
+% \unexpanded\def\startframedcontent[#1]%
+% {\bgroup
+% \doifelse{#1}\v!off
+% {\let\stopframedcontent\egroup}
+% {\ifcsname\??fc#1\c!frame\endcsname
+% \dostartframedcontent{#1}%
+% \fi}}
+%
+% \def\dostartframedcontent#1%
+% {\unexpanded\def\stopframedcontent{\dostopframedcontent{#1}}%
+% \setbox\framebox\hbox\bgroup
+% \setlocalhsize
+% \hsize\localhsize
+% \advance\hsize\dimexpr-\getvalue{\??fc#1\c!leftoffset}-\getvalue{\??fc#1\c!rightoffset} \relax
+% \advance\vsize\dimexpr-\getvalue{\??fc#1\c!topoffset} -\getvalue{\??fc#1\c!bottomoffset}\relax
+% \hskip\getvalue{\??fc#1\c!leftoffset}%
+% \vbox\bgroup
+% \vskip\getvalue{\??fc#1\c!topoffset}%
+% \vbox\bgroup
+% \forgetall
+% \blank[\v!disable]}
+%
+% \def\dostopframedcontent#1%
+% {\removelastskip
+% \egroup
+% \vskip\getvalue{\??fc#1\c!bottomoffset}%
+% \egroup
+% \hskip\getvalue{\??fc#1\c!rightoffset}%
+% \egroup
+% \doifvalue{\??fc#1\c!width}\v!fit
+% {\letvalue{\??fc#1\c!width}\v!fixed}% no shapebox
+% \ifinsidefloat
+% \donefalse
+% \else
+% \doifelsevalue{\??fc#1\c!linecorrection}\v!yes\donetrue\donefalse
+% \fi
+% % plaats ?
+% \ifdone\startlinecorrection\fi
+% \getvalue{\??fc#1\c!left}% new
+% \localframed[\??fc#1]{\box\framebox}%
+% \getvalue{\??fc#1\c!right}% new
+% \ifdone\stoplinecorrection\fi
+% \egroup}
+
+\def\framedcontentparameter #1{\csname\doframedcontentparameter{\??fc\@@framedcontent}#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}
+
+\presetlocalframed[\??fc]
+
+\getparameters
+ [\??fc]
+ [\c!leftoffset=\zeropoint,
+ \c!rightoffset=\framedcontentparameter\c!leftoffset,
+ \c!topoffset=\zeropoint,
+ \c!bottomoffset=\framedcontentparameter\c!topoffset,
+ \c!strut=\v!no,
+ %\c!linecorrection=\v!no,
+ %\c!left=,
+ %\c!right=,
+ %\c!width=\v!fit,
+ \c!offset=\v!overlay]
+
+\def\letframedcontentparameter#1%
+ {\letvalue{\??fc\@@framedcontent#1}}
+
+\unexpanded\def\defineframedcontent
{\dodoubleempty\dodefineframedcontent}
\def\dodefineframedcontent[#1][#2]%
- {\presetlocalframed[\??fc#1]%
- \getparameters[\??fc#1]
- [\c!leftoffset=\zeropoint,
- \c!rightoffset=\getvalue{\??fc#1\c!leftoffset},
- \c!topoffset=\zeropoint,
- \c!bottomoffset=\getvalue{\??fc#1\c!topoffset},
- \c!strut=\v!no,
- \c!offset=\v!overlay,
- \c!linecorrection=\v!no,
- \c!left=,
- \c!right=,
- #2]}
+ {\getparameters[\??fc#1][\s!parent=\??fc,#2]}
-\let\setuplocalframed\getparameters
-
-\def\setupframedcontent
+\unexpanded\def\setupframedcontent
{\dodoubleempty\dosetupframedcontent}
\def\dosetupframedcontent[#1][#2]%
{\def\docommand##1{\getparameters[\??fc##1][#2]}%
\processcommacommand[#1]\docommand}
-\def\startframedcontent[#1]%
+\unexpanded\def\startframedcontent
+ {\dosingleempty\dostartframedcontent}
+
+\def\dostartframedcontent[#1]%
{\bgroup
- \doifelse{#1}\v!off
- {\let\stopframedcontent\egroup}
- {\ifcsname\??fc#1\c!frame\endcsname
- \dostartframedcontent{#1}%
- \fi}}
-
-\def\dostartframedcontent#1%
- {\def\stopframedcontent{\dostopframedcontent{#1}}%
+ \edef\@@framedcontent{#1}%
+ \let\stopframedcontent\egroup
+ \doifnot{#1}\v!off{\dodostartframedcontent{#1}}}
+
+\def\dodostartframedcontent#1%
+ {\unexpanded\def\stopframedcontent{\dostopframedcontent{#1}}%
\setbox\framebox\hbox\bgroup
\setlocalhsize
\hsize\localhsize
- \advance\hsize\dimexpr-\getvalue{\??fc#1\c!leftoffset}-\getvalue{\??fc#1\c!rightoffset} \relax
- \advance\vsize\dimexpr-\getvalue{\??fc#1\c!topoffset} -\getvalue{\??fc#1\c!bottomoffset}\relax
- \hskip\getvalue{\??fc#1\c!leftoffset}%
+ \advance\hsize\dimexpr-\framedcontentparameter\c!leftoffset-\framedcontentparameter\c!rightoffset \relax
+ \advance\vsize\dimexpr-\framedcontentparameter\c!topoffset -\framedcontentparameter\c!bottomoffset\relax
+ \hskip\framedcontentparameter\c!leftoffset
\vbox\bgroup
- \vskip\getvalue{\??fc#1\c!topoffset}%
+ \vskip\framedcontentparameter\c!topoffset
\vbox\bgroup
\forgetall
\blank[\v!disable]}
@@ -3363,22 +3463,22 @@
\def\dostopframedcontent#1%
{\removelastskip
\egroup
- \vskip\getvalue{\??fc#1\c!bottomoffset}%
+ \vskip\framedcontentparameter\c!bottomoffset
\egroup
- \hskip\getvalue{\??fc#1\c!rightoffset}%
+ \hskip\framedcontentparameter\c!rightoffset
\egroup
- \doifvalue{\??fc#1\c!width}\v!fit
- {\letvalue{\??fc#1\c!width}\v!fixed}% no shapebox
+ \doif{\framedcontentparameter\c!width}\v!fit
+ {\letframedcontentparameter\c!width\v!fixed}% no shapebox
\ifinsidefloat
\donefalse
\else
- \doifelsevalue{\??fc#1\c!linecorrection}\v!yes\donetrue\donefalse
+ \doifelse{\framedcontentparameter\c!linecorrection}\v!yes\donetrue\donefalse
\fi
% plaats ?
\ifdone\startlinecorrection\fi
- \getvalue{\??fc#1\c!left}% new
+ \framedcontentparameter\c!left % new
\localframed[\??fc#1]{\box\framebox}%
- \getvalue{\??fc#1\c!right}% new
+ \framedcontentparameter\c!right % new
\ifdone\stoplinecorrection\fi
\egroup}
@@ -3566,6 +3666,7 @@
\!!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