diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/pack-rul.mkiv | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/pack-rul.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/pack-rul.mkiv | 631 |
1 files changed, 337 insertions, 294 deletions
diff --git a/Master/texmf-dist/tex/context/base/pack-rul.mkiv b/Master/texmf-dist/tex/context/base/pack-rul.mkiv index afacc2901b1..c137aea01a2 100644 --- a/Master/texmf-dist/tex/context/base/pack-rul.mkiv +++ b/Master/texmf-dist/tex/context/base/pack-rul.mkiv @@ -328,6 +328,16 @@ \box\scratchbox \egroup} +%D \macros +%D {overlayfakebox} + +\def\overlayfakebox + {\hbox + {\setbox\scratchbox\emptyhbox + \wd\scratchbox\overlaywidth + \ht\scratchbox\overlayheight + \box\scratchbox}} + %D The empty case is: \let\executeoverlay\gobblesevenarguments @@ -469,7 +479,7 @@ \fi\fi} \def\dostrokedlinedbox - {\setbox\scratchbox\null + {\setbox\scratchbox\emptyhbox \wd\scratchbox\frameddimenwd \ht\scratchbox\frameddimenht \dp\scratchbox\frameddimendp @@ -571,8 +581,6 @@ %D start with defining some booleans. These give an impression %D of what we are going to take into account. -% todo: chardefs - \newif\ifboxhasoffset \newif\ifboxhaswidth \newif\ifboxhasheight @@ -612,8 +620,6 @@ \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 @@ -622,28 +628,38 @@ {\bgroup \advance\framednesting\plusone \expandafter\let\csname\??ol:\the\framednesting\s!parent\endcsname\??ol - \dodoubleempty\startlocalframed[\??ol:\the\framednesting]} + \dodoubleempty\dolocalframed[\??ol:\the\framednesting]} \unexpanded\def\setupframed {\dodoubleempty\dosetupframed} -\def\dosetupframed +% \def\dosetupframed +% {\ifsecondargument +% \@EA\dodoublesetupframed +% \else +% \@EA\dosinglesetupframed +% \fi} + +% we can consider setting the parent of the regular framed to +% something else in the otr so that we isolate it there + +\def\dosetupframed[#1][#2]% {\ifsecondargument - \@EA\dodoublesetupframed + \getparameters[\??ol#1][#2]% \else - \@EA\dosinglesetupframed + \getparameters[\??ol][#1]% \fi} -\def\dosinglesetupframed[#1][#2]% - {\getparameters[\??ol][#1]} +% \def\dosinglesetupframed[#1][#2]% +% {\getparameters[\??ol][#1]} -\def\dodoublesetupframed[#1][#2]% - {\bgroup - \let\dodoubleempty\empty - \def\doframed[##1]{\gdef\globalredefinedframed{\dodoubleempty\doframed[##1,#2]}}% - \getvalue{#1}% - \egroup - \letvalue{#1}\globalredefinedframed} +% \def\dodoublesetupframed[#1][#2]% +% {\bgroup +% \let\dodoubleempty\empty +% \def\doframed[##1]{\gdef\globalredefinedframed{\dodoubleempty\doframed[##1,#2]}}% +% \getvalue{#1}% +% \egroup +% \letvalue{#1}\globalredefinedframed} %D \startbuffer %D \setupframed [framecolor=yellow] \framed{A} @@ -655,7 +671,6 @@ %D %D \startbuffer %D \presetlocalframed[myframed] -%D \setuplocalframed[myframed][width=4cm,height=2cm] %D \localframed[myframed][framecolor=green]{oeps} %D \stopbuffer %D @@ -675,14 +690,10 @@ \newif\ifinframed -\def\localframed - {\bgroup - \dodoubleempty\startlocalframed} - %D The next one is faster on multiple backgrounds per page. No %D dimensions can be set, only frames and backgrounds. -\def\fastlocalframed[#1]#2[#3]#4% 3-4 +\unexpanded\def\fastlocalframed[#1]#2[#3]#4% 3-4 {\bgroup \inframedtrue \edef\@@framed{#1}% @@ -884,14 +895,40 @@ % todo: protect local \framednames -\unexpanded\def\startlocalframed[#1][#2]% +\unexpanded\def\localframed + {\bgroup + \dodoubleempty\dolocalframed} + +\unexpanded\def\dolocalframed[#1][#2]% assumes a \dodoubleempty (slows down), also should have leading \bgroup {\bgroup \inframedtrue \edef\@@framed{#1}% \ifsecondargument % faster \getparameters[\@@framed][#2]% here ! \fi - \!!framedframeoffset\framedparameter\c!frameoffset + \dodolocalframed} + +\unexpanded\def\directlocalframed[#1]% no optional + {\bgroup + \bgroup + \inframedtrue + \edef\@@framed{#1}% + \dodolocalframed} + +\unexpanded\def\localframedwithsettings[#1][#2]% no checking (so no spaces between) + {\bgroup + \bgroup + \inframedtrue + \edef\@@framed{#1}% + \getparameters[\@@framed][#2]% here ! + \dodolocalframed} + +\def\c!fr!analyze{fr:analyze} % private option + +% 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 @@ -922,6 +959,7 @@ \edef\@@localorientation{\framedparameter\c!orientation}% % \edef\@@localautowidth {\framedparameter\c!autowidth}% + \edef\@@localfranalyze {\framedparameter\c!fr!analyze}% experimental option % \ifx\@@localframing\v!overlay % no frame, no offset, no framewidth \boxhasframefalse @@ -973,7 +1011,14 @@ \fi\fi \!!framedheight\zeropoint \!!framedwidth \zeropoint - \ifx\localwidth\v!fit + \ifx\localwidth\empty % fallback to fit + \ifboxhasformat + \boxhaswidthtrue + \!!framedwidth\hsize + \else + \boxhaswidthfalse + \fi + \else\ifx\localwidth\v!fit \ifboxhasformat \boxhaswidthtrue \!!framedwidth\hsize @@ -997,15 +1042,17 @@ \else \boxhaswidthtrue \!!framedwidth\localwidth - \fi\fi\fi\fi - \ifx\localheight\v!fit + \fi\fi\fi\fi\fi + \ifx\localheight\empty % fallback to fit + \boxhasheightfalse + \else\ifx\localheight\v!fit \boxhasheightfalse % no longer: \boxhasstrutfalse \else\ifx\localheight\v!broad \boxhasheightfalse \else \boxhasheighttrue \!!framedheight\localheight - \fi\fi + \fi\fi\fi \ifboxhasheight % obey user set height, also downward compatible \else @@ -1113,7 +1160,7 @@ \def\dowithframebox {% moved : \let\postprocessframebox\relax - \stoplocalframed} + \finishlocalframed} \def\dodowithframebox {\aftergroup\dowithframebox} @@ -1128,6 +1175,23 @@ %D future extensions. %D \macros +%D {\doassigncheckedframeoffset} +%D +%D Offset helper (see menus): + +\def\doassigncheckedframeoffset#1#2% + {\edef\checkedframeoffset{#2}% + #1% + \ifx\checkedframeoffset\empty \zeropoint\else + \ifx\checkedframeoffset\v!overlay\zeropoint\else + \ifx\checkedframeoffset\v!none \zeropoint\else + \ifx\checkedframeoffset\v!frame \zeropoint\else + \ifx\checkedframeoffset\v!default\zeropoint\else + #2% + \fi\fi\fi\fi\fi + \relax} + +%D \macros %D {ifreshapeframebox} %D %D The last few lines tell what to do after the content of the @@ -1153,31 +1217,59 @@ %D ...,bottom=\kern0pt,... %D \stoptyping -\unexpanded\def\stoplocalframed +% experiment ... \@@localfranalyze -> 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 + {\ifreshapeframebox + \doreshapeframedbox + \else\ifx\@@localfranalyze\v!yes + \doanalyzeframedbox + \else + \resetshapeframebox + \fi\fi + \boxhaswidthfalse} + +\def\finishlocalframedb + {\ifx\@@localfranalyze\v!yes + \doanalyzeframedbox + \else + \resetshapeframebox + \fi + \boxhaswidthfalse} + +\def\finishlocalframedc + {\ifx\@@localfranalyze\v!yes + \doanalyzeframedbox + \else + \resetshapeframebox + \fi} + +\unexpanded\def\finishlocalframed {\dontshowcomposition \@@stopframedorientation % hm, wrong place ! should rotate the result (after reshape) \handleframedlocator\c!before\@@locallocation \ifboxhasformat \ifx\@@localautowidth\v!force - \ifreshapeframebox\doreshapeframedbox\fi - \boxhaswidthfalse - \else - \ifx\localwidth\v!fit - \ifx\@@localautowidth\v!yes - \ifreshapeframebox\doreshapeframedbox\fi - \fi - \boxhaswidthfalse - \else\ifx\localwidth\v!fixed - \boxhaswidthfalse + \finishlocalframeda + \else\ifx\localwidth\v!fit + \ifx\@@localautowidth\v!yes + \finishlocalframeda \else - \resetshapeframebox - \fi\fi + \finishlocalframedb + \fi + \else\ifx\localwidth\v!fixed + \finishlocalframedb + \else + \finishlocalframedc + \fi\fi\fi + \ifconditional\boxcontentneedsprocessing + \mkdoprocessboxcontents\framebox \fi - \ifconditional\boxcontentneedsprocessing - \mkdoprocessboxcontents\framebox - \fi - \else - \resetshapeframebox + \else + \finishlocalframedc \fi \ifboxhaswidth \wd\framebox\!!framedwidth @@ -1212,7 +1304,7 @@ \egroup} \def\dosetfakedframebox - {\setbox\scratchbox\null + {\setbox\scratchbox\emptyhbox \wd\scratchbox\wd\framebox \ht\scratchbox\ht\framebox \dp\scratchbox\dp\framebox @@ -1622,13 +1714,13 @@ %D Beware, since we entered a group and either or not grab the next %D bgroup token, we need to finish the group in the oneliner mode. -\ifx\raggedoneliner\undefined \chardef\raggedoneliner\zerocount \fi +\ifdefined\raggedonelinerstate \else \newconditional\raggedonelinerstate \fi \def\doformatonelinerbox % beware: assumes explicit preceding bgroup - {\ifcase\raggedoneliner - \expandafter\nodoformatonelinerbox - \else + {\ifconditional\raggedonelinerstate \expandafter\dodoformatonelinerbox + \else + \expandafter\nodoformatonelinerbox \fi} \def\dodoformatonelinerbox @@ -1827,21 +1919,20 @@ %D doing so, we need to reshape the box: \newcount\framednoflines -\newdimen\framedlastlength +\newdimen\framedfirstheight +\newdimen\framedlastdepth \def\resetshapeframebox - {\framednoflines \zerocount - \framedlastlength\zeropoint} + {\framednoflines \zerocount + \framedfirstheight\zeropoint + \framedlastdepth \zeropoint} \let\framedboxwidth \!!zeropoint \let\framedboxheight\!!zeropoint \let\framedboxdepth \!!zeropoint -\def\doreshapeframedbox{\ifvbox\framebox\ctxlua{commands.doreshapeframedbox(\number\framebox)}\fi} - -%D The two variables \type {\framednoflines} and \type -%D {\framedlastlength} can be used in a second pass to -%D optimized framed material. +\def\doreshapeframedbox{\ifvbox\framebox\ctxcommand{doreshapeframedbox(\number\framebox)}\fi} +\def\doanalyzeframedbox{\ifvbox\framebox\ctxcommand{doanalyzeframedbox(\number\framebox)}\fi} % torture test / strange case (much depth) / method 2 needed % @@ -2011,10 +2102,10 @@ %D sort of newline signal. In horizontal boxes it expands to a %D space. -\def\vboxednewline +\unexpanded\def\vboxednewline {\endgraf\ignorespaces} -\def\hboxednewline +\unexpanded\def\hboxednewline {\unskip\normalspace\ignorespaces} %D We can set each rule on or off. The default setting is @@ -2082,10 +2173,12 @@ %D %D \showsetup{blackrule} -\def\complexblackrule[#1]% +\definecomplexorsimple\blackrule + +\unexpanded\def\complexblackrule[#1]% {\hbox\bgroup\getparameters[\??bj][#1]\domakeblackrule\egroup} -\def\simpleblackrule +\unexpanded\def\simpleblackrule {\hbox\bgroup\domakeblackrule\egroup} \def\domakeblackrule @@ -2099,8 +2192,6 @@ \!!depth \@@bjdepth \stopcolor} -\definecomplexorsimple\blackrule - %D \macros %D {blackrules} %D @@ -2290,20 +2381,18 @@ \def\dovlwdhtdp#1#2#3% {\bgroup - \!!dimena#2\strutht - \!!dimenb#3\strutdp \setbox\scratchbox\hbox {\vrule \!!width #1\linewidth - \!!height\!!dimena - \!!depth \!!dimenb}% + \!!height#2\strutht + \!!depth #3\strutdp}% \dp\scratchbox\strutdp \ht\scratchbox\strutht \box\scratchbox \egroup} \def\complexvl[#1]% - {\dovlwdhtdp{1}{#1}{#1}} + {\dovlwdhtdp\plusone{#1}{#1}} \def\complexhl[#1]% {\hbox @@ -2361,25 +2450,27 @@ %D %D which looks like: \thinrules[n=2] +\newconstant\ruletype + \def\thinrule {\strut \bgroup - \chardef\ruletype\plusone + \ruletype\plusone \processaction [\@@dlalternative] - [ \v!a=>\chardef\ruletype0,% no line - %\v!b=>\chardef\ruletype1,% height/depth - \v!c=>\chardef\ruletype2,% topheight/botdepth - % 11=>\chardef\ruletype1,% fallback for backgrounds - 0=>\chardef\ruletype0,% compatible with backgrounds - % 1=>\chardef\ruletype1,% compatible with backgrounds - 2=>\chardef\ruletype2]% compatible with backgrounds + [ \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 - \chardef\ruletype\zerocount + \ruletype\zerocount \else - \doifnot\@@dlframe\v!on{\chardef\ruletype\zerocount}% + \doifnot\@@dlframe\v!on{\ruletype\zerocount}% \fi \ifnum\ruletype=\plusone \doif\@@dlheight\v!max{\let\@@dlheight\!!plusone}% @@ -2622,108 +2713,78 @@ %D %D The next definition shows the defaults. -\def\dodefineframedtext[#1][#2]% - {\presetlocalframed[\??kd#1]% - \getparameters[\??kd#1] - [\c!width=0.75\hsize, - \c!height=\v!fit, - \c!align=\v!yes, - \c!top=, - \c!bottom=\vfill, - \c!offset=1em, - \c!bodyfont=, - \c!style=, - \c!color=, - \c!left=, - \c!right=\hfill, - \c!before=\blank, - \c!after=\blank, - \c!inner=, - \c!frame=\v!on, - \c!topframe=, - \c!bottomframe=, - \c!leftframe=, - \c!rightframe=, - \c!radius=.5\bodyfontsize, - \c!corner=\v!rectangular, - \c!foregroundcolor=, - \c!foregroundstyle=, - \c!background=, - \c!backgroundcolor=, - \c!backgroundscreen=\@@rsscreen, - \c!linecorrection=\v!on, - \c!depthcorrection=\v!on, - \c!margin=\v!standard, - \c!orientation=, - \c!indenting=, - #2]% - \setuvalue{\e!start#1}{\dostartframedtext[#1]}% - \setuvalue{\e!stop #1}{\dostopframedtext }% - \setuvalue {#1}{\doframedtext [#1]}} - -\unexpanded\def\defineframedtext - {\dodoubleempty\dodefineframedtext} - -%D We define the general (and original) case by just saying: - -\defineframedtext[\v!framedtext] - -%D We need several steps before the actual job is done, -%D because we have to handle an optional identifier (and -%D because these commands evolved out of a single case). +\installcommandhandler \??kd {framedtext} \??kd -\def\framedtextparameter#1#2% todo: currentframedtext - {\csname\??kd#1#2\endcsname} - -\def\dosetupframedtexts[#1][#2]% - {\ifsecondargument - \def\docommand##1{\getparameters[\??kd##1][#2]}% - \processcommacommand[#1]\docommand % new, #1 may be macro - \else - \getparameters[\??kd\v!framedtext][#1]% - \fi} +\let\setupframedtexts\setupframedtext -\unexpanded\def\setupframedtexts - {\dodoubleempty\dosetupframedtexts} +\presetlocalframed[\??kd] -\def\dostartframedtext - {\bgroup\dotripleempty\dodostartframedtext} +\setupframedtext + [\c!width=0.75\hsize, + \c!height=\v!fit, + \c!align=\v!yes, + %\c!top=, + \c!bottom=\vfill, + \c!offset=1em, + %\c!bodyfont=, + %\c!style=, + %\c!color=, + %\c!left=, + \c!right=\hfill, + \c!before=\blank, + \c!after=\blank, + %\c!inner=, + \c!frame=\v!on, + %\c!topframe=, + %\c!bottomframe=, + %\c!leftframe=, + %\c!rightframe=, + \c!radius=.5\bodyfontsize, + \c!corner=\v!rectangular, + %\c!orientation=, + %\c!indenting=, + %\c!foregroundcolor=, + %\c!foregroundstyle=, + %\c!background=, + %\c!backgroundcolor=, + \c!backgroundscreen=\@@rsscreen, + \c!linecorrection=\v!on, + \c!depthcorrection=\v!on, + \c!margin=\v!standard] -\def\dodostartframedtext[#1][#2][#3]% - {\doifassignmentelse{#2} - {\dododostartframedtext[#1][][#2]} - {\dododostartframedtext[#1][#2][#3]}} +\appendtoks + \setuevalue{\e!start\currentframedtext}{\dostartframedtext{\currentframedtext}}% + \setuevalue{\e!stop \currentframedtext}{\dostopframedtext }% + \setuevalue {\currentframedtext}{\doframedtext {\currentframedtext}}% +\to \everydefineframedtext -\setfalse\framedtextlocationnone +\unexpanded\def\dostartframedtext#1% + {\bgroup + \edef\currentframedtext{#1}% + \dodoubleempty\dodostartframedtext} -\def\checkframedtext % messy dependency - {\ifinsidefloat - \localhsize\hsize - \else\ifdim\sidefloatvsize>\zeropoint % will be proper handle - % \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} +\def\dodostartframedtext[#1][#2]% + {\doifassignmentelse{#1} + {\dododostartframedtext[][#1]} + {\dododostartframedtext[#1][#2]}} -\def\dododostartframedtext[#1][#2][#3]% #3 only passed to framed, not to framedtext - {\doifsomething{#2}{\setvalue{\??kd#1\c!location}{#2}}% does not listen to #3 +\def\dododostartframedtext[#1][#2]% #2 only passed to framed, not to framedtext + {\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{#1}\c!location] - [ \v!left=>\letvalue{\??kd#1\c!left }\relax - \letvalue{\??kd#1\c!right}\hfill, - \v!right=>\letvalue{\??kd#1\c!left }\hfill - \letvalue{\??kd#1\c!right}\relax, - \v!middle=>\letvalue{\??kd#1\c!left }\hfill - \letvalue{\??kd#1\c!right}\hfill, - \v!none=>\letvalue{\??kd#1\c!left }\relax % new - \letvalue{\??kd#1\c!right}\relax % new + [\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]% - \letvalue{\??kd#1\c!location}\empty + \resetframedtextparameter\c!location % removed 06/2001 % \forgetparindent % added 06/2001 [see demo-bbv] @@ -2733,43 +2794,28 @@ \startboxedcontent \hsize\localhsize % \insidefloattrue % ? better - \normalexpanded{\noexpand\switchtobodyfont[\framedtextparameter{#1}\c!bodyfont]}% - \startcolor[\framedtextparameter{#1}\c!color]% - \localframed[\??kd#1][\c!strut=\v!no,#3]% todo: use delayedstrut + \normalexpanded{\noexpand\switchtobodyfont[\framedtextparameter\c!bodyfont]}% + \startcolor[\framedtextparameter\c!color]% + \localframed[\??kd\currentframedtext][\c!strut=\v!no]% todo: use delayedstrut \bgroup \let\\=\endgraf - \framedtextparameter{#1}\c!inner % oud spul - \doifvalue{\??kd#1\c!depthcorrection}\v!on % new, inside box - {\bgroup - \verticalstrut - % we need \nowhitespace in case of setups setting whitespace - % nb, not safe, text vs \vbox as next - \vskip-\struttotal - \nowhitespace % na vskip ! new 20/05/2004, fails with next content being box (\scale{..}) - }% + \framedtextparameter\c!inner % oud spul + \doif{\framedtextparameter\c!depthcorrection}\v!on\doftstartdepthcorrection \doinhibitblank % \blank[\v!disable]% plaatst signal -\setupindenting[\framedtextparameter{#1}\c!indenting]% - \doconvertfont{\framedtextparameter{#1}\c!style}\empty - \def\dostopframedtext{\dodostopframedtext{#1}{#2}}} + \setupindenting[\framedtextparameter\c!indenting]% + %\doconvertfont{\framedtextparameter\c!style}\empty} %%%%% todo: attr setter + \dosetframedtextattributes\c!style\c!color} %D The \type {none} option is handy for nested usage, as %D in the presentation styles, where we don't want %D interference. -\def\dodostopframedtext#1#2% % no \baselinecorrection, see faq docs +\defineplacement[\??kd][\s!parent=\??kd\currentframedtext] + +\unexpanded\def\dostopframedtext % no \baselinecorrection, see faq docs {\endgraf \removelastskip - \doifvalue{\??kd#1\c!depthcorrection}\v!on % local and global - {\forgetall - \vskip-\struttotal - \verticalstrut - \egroup - \forgetall % brrr too often - \vskip-\lineheight - % will be an option, not default - % \setbaselinecorrections - % \donegbotbaselinecorrection - \verticalstrut} + \doif{\framedtextparameter\c!depthcorrection}\v!on\doftstopdepthcorrection \stopboxedcontent \stopcolor \ifconditional\framedtextlocationnone @@ -2780,10 +2826,47 @@ \box\framebox \else \egroup - \doplacement[\??kd#1][\c!depthcorrection=\v!off]{\box\framebox}% + \placement[\??kd][\c!depthcorrection=\v!off]{\box\framebox}% \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\sidefloatvsize>\zeropoint % will be proper handle + % \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} + +\def\doftstartdepthcorrection + {\bgroup + \verticalstrut + % we need \nowhitespace in case of setups setting whitespace + % nb, not safe, text vs \vbox as next + \vskip-\struttotal + \nowhitespace} % na vskip ! new 20/05/2004, fails with next content being box (\scale{..}) + +\def\doftstopdepthcorrection + {\forgetall + \vskip-\struttotal + \verticalstrut + \egroup + \forgetall % brrr too often + \vskip-\lineheight + % will be an option, not default + % \setbaselinecorrections + % \donegbotbaselinecorrection + \verticalstrut} + %D Placement can be ignored: %D %D \starttyping @@ -2802,17 +2885,19 @@ %D The simple brace (or group) delimited case is typeset %D slightly different and is not aligned. -\def\doframedtext - {\bgroup\dodoubleempty\dodoframedtext} +\unexpanded\def\doframedtext#1% + {\bgroup + \edef\currentframedtext{#1}% + \dosingleempty\dodoframedtext} -\def\dodoframedtext[#1][#2]% beware! - {\normalexpanded{\noexpand\switchtobodyfont[\getvalue{\??kd#1\c!bodyfont}]}% - \localframed[\??kd#1][\c!strut=\v!no,#2]% +\def\dodoframedtext[#1]% beware! + {\normalexpanded{\noexpand\switchtobodyfont[\\framedtextparameter\c!bodyfont]}% + \localframed[\??kd\currentframedtext][\c!strut=\v!no,#1]% \bgroup \blank[\v!disable]% \let\\=\endgraf - \getvalue{\??kd#1\c!inner}% % kleur naar outer level - \dostartattributes{\??kd#1}\c!style\c!color\empty + \framedtextparameter\c!inner + \dosetframedtextattributes\c!style\c!color \bgroup \aftergroup\docloseframedtext \let\next=} @@ -2823,23 +2908,46 @@ \egroup \egroup} +\defineframedtext[\v!framedtext] + %D \macros %D {defineframed} %D %D One can also define simple framed texts, using: %D %D \showsetup{defineframed} +%D +%D As suggested by Wolfgang we can now use the new \MKIV\ inheritance +%D model instead of passing a combination of arguments. This also +%D also simplified the \type {\setupframed} command. There are +%D certainly more places where such improvements can be made. -\unexpanded\def\defineframed +\def\defineframed {\dodoubleempty\dodefineframed} \def\dodefineframed[#1][#2]% - {\iffirstargument - \setuvalue{#1}{\dodoubleempty\doframed[#2]}% - \fi} + {\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\doframed[#1][#2]% - {\framed[#1,#2]} +\def\doframed[#1]% + {\bgroup + \expandafter\let\expandafter\tempframedcount\csname\??ol:#1\endcsname + \advance\tempframedcount\plusone + \expandafter\def\csname\??ol#1:\the\tempframedcount\s!parent\endcsname{\??ol#1}% \copylocalframed + \dodoubleempty\dolocalframed[\??ol#1:\the\tempframedcount]} + +%D We can do: +%D +%D \starttyping +%D \defineframed[\v!framed] +%D \stoptyping +%D +%D but the existing one is ok as well (less csname messy too). %D \macros %D {textrule, starttextrule, setuptextrules} @@ -3196,7 +3304,7 @@ % 0=no-split, 1=no-split+indent, 2=split, 3=split+indent -\chardef\backgroundsplitmode\plusthree +\setnewconstant\backgroundsplitmode\plusthree %D The \type{\vbox to \lineheight{}\vskip\zeropoint} %D construction gives the first real line a decent height by @@ -3225,7 +3333,7 @@ \dimen2\leftskip % new ** \forgetall \ifinsidefloat - \chardef\backgroundsplitmode\zerocount + \backgroundsplitmode\zerocount \fi \ifcase\backgroundsplitmode \localframed[\??ag][\c!offset=\v!overlay]{\box0}% @@ -3239,11 +3347,11 @@ \loop \ifdim\pagetotal=\zeropoint % empty page \scratchdimen\textheight - \chardef\backgroundsplit\plusone % split to max height + \backgroundsplitmode\plusone % split to max height \else \setbox\scratchbox\vbox{\@@agbefore}% \scratchdimen\dimexpr\pagegoal-\ht\scratchbox-\pagetotal\relax - \chardef\backgroundsplit\plustwo % split to partial height + \backgroundsplitmode\plustwo % split to partial height \fi \advance\scratchdimen\dimexpr-\@@agtopoffset-\@@agbottomoffset\relax \ifdim\scratchdimen>2\lineheight\relax % reasonable, will be configurable @@ -3251,9 +3359,9 @@ \setbox2\vsplit0 to \scratchdimen \else \setbox2\box0 - \chardef\backgroundsplit\zerocount % no split + \backgroundsplitmode\zerocount % no split \fi - \setbox2\vbox \ifcase\backgroundsplit\or to \textheight \fi % max split + \setbox2\vbox \ifcase\backgroundsplitmode\or to \textheight \fi % max split {\vskip\@@agtopoffset \unvcopy2 \prevdepth\dp2 @@ -3261,7 +3369,7 @@ \vskip\@@agbottomoffset \vfill} \@@agbefore - \ifcase\backgroundsplit\or\or % partial split + \ifcase\backgroundsplitmode\or\or % partial split \ifdim\pagegoal<\maxdimen \pagegoal=1.2\pagegoal % be a bit more tolerant \fi @@ -3271,7 +3379,7 @@ \ifnum\backgroundsplitmode=\plusthree \hskip\dimen2 \fi % \localframed[\??ag][\c!offset=\v!overlay]{\box2}% new ** \stoplinecorrection - \ifcase\backgroundsplit % no split + \ifcase\backgroundsplitmode % no split \@@agafter \else % some split \vfill\eject % geen \page ! @@ -3334,74 +3442,6 @@ %D %D \typebuffer -% \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} @@ -3521,6 +3561,9 @@ \setuplinewidth [\v!medium] +% We could omit the empty setings but that is some 10% slower due to +% extra testing in the chain. + \setupframed [\c!width=\v!fit, \c!height=\v!broad, @@ -3554,12 +3597,12 @@ \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=] + \c!setups=, + \c!strut=\v!yes] \setupscreens [%\c!factor=1.0, % obsolete |