From 94b9b4ac08732fcfeb28b32a03ea5f70072fee1a Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 5 Jan 2012 19:27:42 +0100 Subject: beta 2011.12.15 09:22 --- tex/context/base/context-version.pdf | Bin 4069 -> 4075 bytes tex/context/base/context-version.png | Bin 105921 -> 105850 bytes tex/context/base/lang-lab.mkiv | 1 - tex/context/base/pack-mis.mkvi | 5 +- tex/context/base/pack-rul.mkiv | 66 ++++--- tex/context/base/spac-par.mkiv | 7 +- tex/context/base/status-files.pdf | Bin 23999 -> 24000 bytes tex/context/base/status-lua.pdf | Bin 169691 -> 169694 bytes tex/context/base/supp-box.mkiv | 344 ++++++++++++++++------------------- 9 files changed, 200 insertions(+), 223 deletions(-) diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 05262a92c..2cb34c4cd 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index 3540c2b30..a69c11acf 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv index 8af23b101..870ecd4f9 100644 --- a/tex/context/base/lang-lab.mkiv +++ b/tex/context/base/lang-lab.mkiv @@ -263,7 +263,6 @@ %D which expands to {\em something} or {\em iets}, depending on %D de current language. - \unexpanded\def\translate {\dosingleempty\translate_indeed} diff --git a/tex/context/base/pack-mis.mkvi b/tex/context/base/pack-mis.mkvi index 289b1232c..c24c13808 100644 --- a/tex/context/base/pack-mis.mkvi +++ b/tex/context/base/pack-mis.mkvi @@ -50,7 +50,7 @@ {\iffirstargument \setupcurrentplacement[#settings]% \fi - \dowithnextboxcontent{\forgetall}{\pack_placement_flush\egroup}\vbox} + \dowithnextboxcontentcs\forgetall\pack_placement_flush\vbox} \def\pack_placement_flush {\setlocalhsize @@ -78,7 +78,8 @@ \doif{\placementparameter\c!linecorrection }\v!on\stopbaselinecorrection \fi \endgroup - \placementparameter\c!after} + \placementparameter\c!after + \egroup} \protect \endinput diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index 186042083..4f6b14d71 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -1737,15 +1737,23 @@ \expandafter\nodoformatonelinerbox \fi} +% \def\dodoformatonelinerbox % we could even have a special one +% {\dowithnextboxcontentcs\ignorespaces\dododoformatonelinerbox\hbox} + \def\dodoformatonelinerbox - {\dowithnextboxcontent - {\ignorespaces} - {\hbox to \hsize - {\ifcase\raggedstatus\or\hss\or\hss\fi - \unhbox\nextbox \removeunwantedspaces - \ifcase\raggedstatus\or \or\hss\or\hss\fi}% - \egroup} - \hbox} + {\afterassignment\redoformatonelinerbox + \setbox\nextbox\hbox} + +\def\redoformatonelinerbox + {\aftergroup\dododoformatonelinerbox + \ignorespaces} + +\def\dododoformatonelinerbox + {\hbox to \hsize + {\ifcase\raggedstatus\or\hss\or\hss \fi + \unhbox\nextbox \removeunwantedspaces + \ifcase\raggedstatus\or \or\hss\or\hss\fi}% + \egroup} \def\nodoformatonelinerbox % grabs { {\let\next=} @@ -1763,9 +1771,9 @@ \bgroup \let\postprocessframebox\relax \framedforgetall -\iftrialtypesetting \else - \setframedforegroundcolor -\fi + \iftrialtypesetting \else + \setframedforegroundcolor + \fi \oninterlineskip \hsize\!!framedwidth \vsize\!!framedheight @@ -1784,9 +1792,9 @@ \bgroup \let\postprocessframebox\relax \framedforgetall -\iftrialtypesetting \else - \setframedforegroundcolor -\fi + \iftrialtypesetting \else + \setframedforegroundcolor + \fi \oninterlineskip \hsize\!!framedwidth \vsize\!!framedheight @@ -1805,9 +1813,9 @@ \bgroup \let\postprocessframebox\relax \framedforgetall -\iftrialtypesetting \else - \setframedforegroundcolor -\fi + \iftrialtypesetting \else + \setframedforegroundcolor + \fi \oninterlineskip \doframedsetups \raggedcommand @@ -1824,9 +1832,9 @@ \bgroup \let\postprocessframebox\relax \framedforgetall -\iftrialtypesetting \else - \setframedforegroundcolor -\fi + \iftrialtypesetting \else + \setframedforegroundcolor + \fi \oninterlineskip \hsize\!!framedwidth \doframedsetups @@ -1844,9 +1852,9 @@ \bgroup \let\postprocessframebox\relax \framedforgetall -\iftrialtypesetting \else - \setframedforegroundcolor -\fi + \iftrialtypesetting \else + \setframedforegroundcolor + \fi \vsize\!!framedheight \doframedsetups \vss @@ -1864,9 +1872,9 @@ \bgroup \let\postprocessframebox\relax \framedforgetall -\iftrialtypesetting \else - \setframedforegroundcolor -\fi + \iftrialtypesetting \else + \setframedforegroundcolor + \fi \doframedsetups \hss \localstrut @@ -1878,9 +1886,9 @@ \def\doformatboxNoSize {\hbox \bgroup -\iftrialtypesetting \else - \setframedforegroundcolor -\fi + \iftrialtypesetting \else + \setframedforegroundcolor + \fi \let\postprocessframebox\relax \doframedsetups \localstrut diff --git a/tex/context/base/spac-par.mkiv b/tex/context/base/spac-par.mkiv index 711a2525d..834840012 100644 --- a/tex/context/base/spac-par.mkiv +++ b/tex/context/base/spac-par.mkiv @@ -142,7 +142,12 @@ \def\flushatnextpar {\bgroup \global\let\flushpostponednodedata\doflushpostponednodedata - \dowithnextbox{\global\setbox\postponednodedata\hbox{\box\postponednodedata\box\nextbox}\egroup}\hbox} + \dowithnextboxcs\doflushatnextpar\hbox} + +\def\doflushatnextpar + {\global\setbox\postponednodedata\hbox + {\box\postponednodedata\box\nextbox}% + \egroup} \def\doflushpostponednodedata {\ifvoid\postponednodedata\else diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 3dbf8ccb5..901e46da8 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index d7322a908..d75df13e0 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv index 2c6093de9..ce4f0544f 100644 --- a/tex/context/base/supp-box.mkiv +++ b/tex/context/base/supp-box.mkiv @@ -691,32 +691,13 @@ \afterassignment\boxes_with_next_box_indeed \setbox\nextbox} -%D Now we can redefine \type {\dowithnextbox} as follows: -%D -%D \starttyping -%D \def\dowithnextbox{\dowithnextboxcontent\empty} -%D \stoptyping -%D -%D But since this macro is used often and since this implementation -%D is slower, we will not use that definition. +\unexpanded\def\dowithnextboxcontentcs#1#2% inside, after + {\let\boxes_with_next_box#2% + \let\boxes_with_next_box_indeed#1% + \afterassignment\boxes_with_next_box_content_indeed + \setbox\nextbox} -% maybe: -% -% depending on the size of the action, about 10% faster -% -% \newtoks\nextboxtoks -% -% \def\dowithnextbox {\afterassignment\redowithnextbox\nextboxtoks} -% \def\redowithnextbox {\afterassignment\boxes_with_next_box_indeed\setbox\nextbox} -% \def\boxes_with_next_box_indeed {\aftergroup\boxes_with_next_box} -% \def\boxes_with_next_box{\the\nextboxtoks} -% -% \long\def\dowithnextboxcontent#1% #2% inside, after -% {\def\boxes_with_next_box_indeed{#1\aftergroup\boxes_with_next_box}% -% \afterassignment\redowithnextboxcontent\nextboxtoks} -% -% \def\redowithnextboxcontent -% {\afterassignment\boxes_with_next_box_indeed\setbox\nextbox} +\def\boxes_with_next_box_content_indeed{\boxes_with_next_box_indeed\aftergroup\boxes_with_next_box}% %D \macros %D {llap, rlap, tlap, blap, clap} @@ -1204,110 +1185,70 @@ \ifdefined\fakecompoundhyphen\else \let\fakecompoundhyphen\relax \fi \ifdefined\veryraggedright \else \def\veryraggedright{\raggedright} \fi -%D The simple alternative is as follows: -%D -%D \starttyping -%D \unexpanded\def\limitatetext% -%D {\bgroup % evt \setstrut -%D \forgetall -%D \fakecompoundhyphen % dangerous ! ! ! ! ! ! ! ! ! -%D \dowithnextbox\dolimitatetext\normalhbox} -%D -%D \def\dolimitatetext#1#2% -%D {\doifelsenothing{#1} -%D {\unhbox\nextbox} -%D {\widowpenalty=0 -%D \clubpenalty=0 -%D \scratchdimen=#1\relax -%D \ifdim\wd\nextbox>\scratchdimen -%D \setbox\scratchbox=\normalhbox{ #2}% -%D \advance\scratchdimen by -\wd\scratchbox -%D \setbox\nextbox=\normalvbox -%D {\hsize=\scratchdimen -%D \hfuzz\maxdimen -%D \veryraggedright -%D \strut\unhcopy\nextbox}% -%D \ifdim\ht\nextbox>\strutht \else -%D \setbox\scratchbox\emptyhbox % overfull and not split -%D \fi -%D \setbox\nextbox=\normalvbox % if omitted: missing brace reported -%D {\splittopskip=\openstrutheight -%D \setbox\nextbox=\vsplit\nextbox to \strutht -%D \unvbox\nextbox -%D \setbox\nextbox=\lastbox -%D \global\setbox1=\normalhbox -%D {\unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox\unskip}}% -%D \unhbox1 -%D \else -%D \unhbox\nextbox -%D \fi}% -%D \egroup} -%D \stoptyping -%D -%D The next alternative accepts a negative width. A negative -%D value crops the beginning. The macro thereby becomes less -%D readable, which is why we kept the original here too. - \unexpanded\def\limitatetext {\bgroup % evt \setstrut \forgetall % otherwise indentation and so - %\def\limitatetext##1##2##3{##1}% \def ! \let\limitatetext\firstofthreearguments \fakecompoundhyphen % dangerous ! ! ! ! ! ! ! ! ! - \dowithnextboxcs\dolimitatetext\normalhbox} - -\def\dolimitatetext#1#2% - {\doifelsenothing{#1} - {\unhbox\nextbox} - {\nopenalties - \scratchdimen#1\relax - \ifdim\scratchdimen<\zeropoint\relax % we'll take the last line - \donefalse - \scratchdimen-\scratchdimen - \else - \donetrue - \fi - \ifdimw\wd\nextbox>\scratchdimen - \setbox\scratchbox\normalhbox{\ifdone\space#2\else#2\space\fi}% - \advance\scratchdimen -\wd\scratchbox - \setbox0\box\nextbox - \setbox\nextbox\normalvbox - {\hsize\scratchdimen - \hfuzz\maxdimen - \veryraggedright - \strut - \ifdone \else - \parfillskip\zeropoint - \rightskip\zeropoint - \hskip\zeropoint \!!plus 1\!!fill % \hsize - \fi - \unhcopy0}% - \ifdim\ht\nextbox>\strutht - \setbox\nextbox\normalvbox % if omitted: missing brace reported - {\splittopskip\openstrutheight - \ifdone - \setbox\nextbox\vsplit\nextbox to \strutht + \dowithnextboxcs\boxes_limitate_text\normalhbox} + +\def\boxes_limitate_text#1% #2 + {\doifelsenothing{#1}\boxes_limitate_text_nop\boxes_limitate_text_yes{#1}} % {#2} + +\def\boxes_limitate_text_nop#1#2% + {\unhbox\nextbox + \egroup} + +\def\boxes_limitate_text_yes#1#2% + {\nopenalties + \scratchdimen#1\relax + \ifdim\scratchdimen<\zeropoint\relax % we'll take the last line + \donefalse + \scratchdimen-\scratchdimen + \else + \donetrue + \fi + \ifdim\wd\nextbox>\scratchdimen + \setbox\scratchbox\normalhbox{\ifdone\space#2\else#2\space\fi}% + \advance\scratchdimen -\wd\scratchbox + \setbox0\box\nextbox + \setbox\nextbox\normalvbox + {\hsize\scratchdimen + \hfuzz\maxdimen + \veryraggedright + \strut + \ifdone \else + \parfillskip\zeropoint + \rightskip\zeropoint + \hskip\zeropoint \!!plus 1\!!fill % \hsize + \fi + \unhcopy0}% + \ifdim\ht\nextbox>\strutht + \setbox\nextbox\normalvbox % if omitted: missing brace reported + {\splittopskip\openstrutheight + \ifdone + \setbox\nextbox\vsplit\nextbox to \strutht + \else + \doloop + {\setbox0\vsplit\nextbox to \strutht + \ifdim\ht\nextbox>\strutht \else \exitloop \fi}% + \fi + \unvbox\nextbox + \setbox\nextbox\lastbox + \global\setbox1\normalhbox + {\ifdone + \unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox \else - \doloop - {\setbox0\vsplit\nextbox to \strutht - \ifdim\ht\nextbox>\strutht \else \exitloop \fi}% + \box\scratchbox\unhbox\nextbox \fi - \unvbox\nextbox - \setbox\nextbox\lastbox - \global\setbox1\normalhbox - {\ifdone - \unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox - \else - \box\scratchbox\unhbox\nextbox - \fi - \unskip}}% - \unhbox1 - \else - \unhbox0 - \fi - \else - \unhbox\nextbox - \fi}% + \unskip}}% + \unhbox1 + \else + \unhbox0 + \fi + \else + \unhbox\nextbox + \fi \egroup} %D We can also limit a text with more control: @@ -1323,12 +1264,13 @@ %D %D We build this feature on top of the previous macro. +% we could move the text argument to the end + \let\normallimitatetext\limitatetext \def\speciallimitatetext#1#2#3#4% text left right placeholder {%\dontleavehmode \bgroup - %\def\speciallimitatetext##1##2##3##4{##1}% \def ! \let\speciallimitatetext\firstoffourarguments \setbox0\normalhbox {\nohyphens @@ -1336,8 +1278,8 @@ \normallimitatetext{#1}{-#3}{}}% \setbox2\normalhbox {#1}% - \ifdim\wd2<\wd0 #1\else\unhbox0\fi - \egroup} + \ifdim\wd2<\wd0 #1\else\unhbox0\fi + \egroup} \unexpanded\def\limitatetext#1#2#3% \expanded added 2003/01/16 {\expanded{\beforesplitstring#2}\at,\to\leftlimit @@ -1928,32 +1870,33 @@ %D The next macro gobble boxes and is for instance used for %D overlays. First we show the general handler. -\newbox\processbox +\newbox\processbox % public : this is the one where \nextbox's end up in \unexpanded\def\processboxes#1% {\bgroup - \def\doprocessbox{#1}% #1 can be redefined halfway + \def\boxes_process_indeed{#1}% #1 can be redefined halfway \setbox\processbox\emptybox - \afterassignment\dogetprocessbox\let\next=} + \futurelet\nexttoken\boxes_process} -\unexpanded\def\endprocessboxes - {\ifhmode\unskip\fi - \box\processbox - \next - \egroup} - -\def\dogetprocessbox - {\ifx\next\bgroup - \expandafter\dodogetprocessbox +\def\boxes_process + {\ifx\nexttoken\bgroup + \expandafter\boxes_process_yes \else - \expandafter\endprocessboxes + \expandafter\boxes_process_nop \fi} -\def\dodogetprocessbox - {\dowithnextbox - {\ifhmode\unskip\fi\doprocessbox % takes \nextbox makes \processbox - \afterassignment\dogetprocessbox\let\next=} - \normalhbox\bgroup} +\def\boxes_process_yes + {\dowithnextboxcs\boxes_process_content\normalhbox} + +\def\boxes_process_content + {\removeunwantedspaces + \boxes_process_indeed % takes \nextbox makes \processbox + \futurelet\nexttoken\boxes_process} + +\unexpanded\def\boxes_process_nop + {\removeunwantedspaces + \box\processbox + \egroup} %D \macros %D {startoverlay} @@ -1974,38 +1917,26 @@ %D %D \leavevmode\getbuffer -\def\dooverlaybox - {\ifhmode\unskip\fi - \scratchdimen\dp - \ifdim\dp\nextbox>\dp\processbox - \nextbox - \else - \processbox - \fi +\def\boxes_overlay_process + {%\removeunwantedspaces % already done + \scratchdepth\dp\ifdim\dp\nextbox>\dp\processbox\nextbox\else\processbox\fi \ifdim\ht\nextbox>\ht\processbox - \setbox\processbox\normalvbox to \ht\nextbox - {\dp\processbox\zeropoint\vss\box\processbox\vss}% + \setbox\processbox\normalvbox to \ht\nextbox {\dp\processbox\zeropoint\vss\box\processbox\vss}% \else - \setbox\nextbox\normalvbox to \ht\processbox - {\dp\nextbox\zeropoint\vss\box\nextbox\vss}% + \setbox\nextbox \normalvbox to \ht\processbox{\dp\nextbox \zeropoint\vss\box\nextbox \vss}% \fi - \dp\nextbox\scratchdimen - \dp\processbox\scratchdimen - \scratchdimen\wd - \ifdim\wd\nextbox>\wd\processbox - \nextbox - \else - \processbox - \fi - \setbox\processbox\normalhbox to \scratchdimen - {\normalhbox to \scratchdimen{\hss\box\processbox\hss}% - \hskip-\scratchdimen - \normalhbox to \scratchdimen{\hss\box\nextbox\hss}}} + \dp\nextbox \scratchdepth + \dp\processbox\scratchdepth + \scratchwidth\wd\ifdim\wd\nextbox>\wd\processbox\nextbox\else\processbox\fi + \setbox\processbox\normalhbox to \scratchwidth + {\normalhbox to \scratchwidth{\hss\box\processbox\hss}% + \hskip-\scratchwidth + \normalhbox to \scratchwidth{\hss\box\nextbox \hss}}} \unexpanded\def\startoverlay {\bgroup \let\stopoverlay\egroup - \processboxes\dooverlaybox} + \processboxes\boxes_overlay_process} \let\stopoverlay\relax @@ -2049,16 +1980,26 @@ %D middle and right. These box types can be used to typeset %D paragraphs. -\unexpanded\def\lbox{\makelrcbox\normalvbox\raggedleft} -\unexpanded\def\cbox{\makelrcbox\normalvbox\raggedcenter} -\unexpanded\def\rbox{\makelrcbox\normalvbox\raggedright} +% \unexpanded\def\lbox{\makelrcbox\normalvbox\raggedleft} +% \unexpanded\def\cbox{\makelrcbox\normalvbox\raggedcenter} +% \unexpanded\def\rbox{\makelrcbox\normalvbox\raggedright} +% +% \unexpanded\def\ltop{\makelrcbox\normalvtop\raggedleft} +% \unexpanded\def\ctop{\makelrcbox\normalvtop\raggedcenter} +% \unexpanded\def\rtop{\makelrcbox\normalvtop\raggedright} +% +% \def\makelrcbox#1#2#3#% +% {#1#3\bgroup \forgetall \let\\=\endgraf #2\let\next=} + +\def\boxes_lrc_process#1{\bgroup\forgetall\let\\\endgraf#1\let\next} -\unexpanded\def\ltop{\makelrcbox\normalvtop\raggedleft} -\unexpanded\def\ctop{\makelrcbox\normalvtop\raggedcenter} -\unexpanded\def\rtop{\makelrcbox\normalvtop\raggedright} +\unexpanded\def\lbox#1#{\normalvbox#1\boxes_lrc_process\raggedleft } +\unexpanded\def\cbox#1#{\normalvbox#1\boxes_lrc_process\raggedcenter} +\unexpanded\def\rbox#1#{\normalvbox#1\boxes_lrc_process\raggedright } -\def\makelrcbox#1#2#3#% - {#1#3\bgroup \forgetall \let\\=\endgraf #2\let\next=} +\unexpanded\def\ltop#1#{\normalvtop#1\boxes_lrc_process\raggedleft } +\unexpanded\def\ctop#1#{\normalvtop#1\boxes_lrc_process\raggedcenter} +\unexpanded\def\rtop#1#{\normalvtop#1\boxes_lrc_process\raggedright } %D The alternatives \type {\tbox} and \type {\bbox} can be used %D to properly align boxes, like in: @@ -2080,21 +2021,44 @@ %D %D \getbuffer -\unexpanded\def\tbox{\tbbox\ht\dp} -\unexpanded\def\bbox{\tbbox\dp\ht} +% \unexpanded\def\tbox{\tbbox\ht\dp} +% \unexpanded\def\bbox{\tbbox\dp\ht} -\def\tbbox#1#2% - {\normalhbox\bgroup - \dowithnextbox - {\scratchdimen\dimexpr\ht\nextbox+\dp\nextbox-#1\strutbox\relax - #1\nextbox#1\strutbox - #2\nextbox\scratchdimen - \setbox\nextbox\normalhbox{\lower\dp\nextbox\box\nextbox}% - #1\nextbox#1\strutbox - #2\nextbox\scratchdimen - \box\nextbox - \egroup} - \normalhbox} +% \def\tbbox#1#2% +% {\normalhbox\bgroup +% \dowithnextbox +% {\scratchdimen\dimexpr\ht\nextbox+\dp\nextbox-#1\strutbox\relax +% #1\nextbox#1\strutbox +% #2\nextbox\scratchdimen +% \setbox\nextbox\normalhbox{\lower\dp\nextbox\box\nextbox}% +% #1\nextbox#1\strutbox +% #2\nextbox\scratchdimen +% \box\nextbox +% \egroup} +% \normalhbox} + +\unexpanded\def\tbox{\normalhbox\bgroup\dowithnextboxcs\boxes_tbox_finish\normalhbox} +\unexpanded\def\bbox{\normalhbox\bgroup\dowithnextboxcs\boxes_bbox_finish\normalhbox} + +\def\boxes_tbox_finish + {\scratchdepth\dimexpr\ht\nextbox+\dp\nextbox-\ht\strutbox\relax + \ht\nextbox\ht\strutbox + \dp\nextbox\scratchdepth + \setbox\nextbox\normalhbox{\lower\dp\nextbox\box\nextbox}% + \ht\nextbox\ht\strutbox + \dp\nextbox\scratchdepth + \box\nextbox + \egroup} + +\def\boxes_bbox_finish + {\scratchheight\dimexpr\ht\nextbox+\dp\nextbox-\dp\strutbox\relax + \dp\nextbox\dp\strutbox + \ht\nextbox\scratchheight + \setbox\nextbox\normalhbox{\lower\dp\nextbox\box\nextbox}% + \dp\nextbox\dp\strutbox + \ht\nextbox\scratchheight + \box\nextbox + \egroup} %D \macros %D {lhbox,mhbox,rhbox} -- cgit v1.2.3