diff options
author | Marius <mariausol@gmail.com> | 2012-07-17 13:16:14 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-07-17 13:16:14 +0300 |
commit | c30a841cef093918b475e0ea95ecf9fc9f30697d (patch) | |
tree | 861e4f6cf85f9ad0b0abe5b501a0bac21a6f63ab /tex/context/base/page-col.mkiv | |
parent | a13773bf241efe852de82ad42770e2abcc3ddf54 (diff) | |
download | context-c30a841cef093918b475e0ea95ecf9fc9f30697d.tar.gz |
beta 2012.07.17 00:23
Diffstat (limited to 'tex/context/base/page-col.mkiv')
-rw-r--r-- | tex/context/base/page-col.mkiv | 174 |
1 files changed, 96 insertions, 78 deletions
diff --git a/tex/context/base/page-col.mkiv b/tex/context/base/page-col.mkiv index 3143cadd2..54cf27bc5 100644 --- a/tex/context/base/page-col.mkiv +++ b/tex/context/base/page-col.mkiv @@ -19,65 +19,23 @@ \unprotect -%D The next two registers can be used to store pre column material as well -%D as footnotes or so. - -\newbox\precolumnbox \newdimen\precolumnboxheight -\newbox\postcolumnbox \newdimen\postcolumnboxheight - %D We reserve a counter for the number of columns as well as the current %D column. Both are not to be changed by users! \newcount\nofcolumns \nofcolumns\plusone \newcount\mofcolumns \mofcolumns\plusone -\setnewconstant\maxnofcolumns 50 -\setnewconstant\allocatednofcolumns 0 - -%D The next dimensions reports the final column height - -\newdimen\finalcolumnheights -\newcount\finalcolumnlines - -%D This register can be used as a temporary storage for page content. - -\newbox\restofpage - -%D A few more (some might go away): - -\newif\ifintermediatefootnotes % seems to be obsolete -\newif\ifcarryoverfootnotes %\carryoverfootnotestrue -\newif\iflastcolumnfootnotes %\lastcolumnfootnotestrue -\newif\ifbalancecolumns %\balancecolumnstrue -\newif\ifbalancetoheight %\balancetoheighttrue -\newif\ifforcecolumngrid \forcecolumngridtrue -\newif\ifstretchcolumns \stretchcolumnsfalse -\newif\ifinheritcolumns \inheritcolumnsfalse -\newif\ifheightencolumns \heightencolumnsfalse - -\newif\ifbalancingcolumns -\newif\ifcollectingcontent -\newif\ifcolumnoverflow - -\newdimen\intercolumnwidth -\newdimen\localcolumnwidth -\newdimen\savedpagetotal - \newconstant\columndirection % 0:lr 1:rl -\def\minbalancetoplines {1} -\def\minfreecolumnlines {2} - -\newif\ifrecentercolumnbox \recentercolumnboxtrue -\newif\ifrerecentercolumnbox \rerecentercolumnboxtrue +\setnewconstant\maxnofcolumns 50 +\setnewconstant\allocatednofcolumns 0 -%D During initialization the temporary boxes are allocated. -%D This enables us to use as much columns as we want, without -%D exhausting the pool of boxes too fast. We could have packed -%D them in one box, but we've got enough boxes. +%D During initialization the temporary boxes are allocated. This enables us to +%D use as much columns as we want, without exhausting the pool of boxes too +%D fast. We could have packed them in one box, but we've got enough boxes. %D -%D Two sets of boxes are declared, the txtboxes are used for -%D the text, the topboxes are for moved column floats. +%D Two sets of boxes are declared, the txtboxes are used for the text, the +%D topboxes are for moved column floats. \installcorenamespace{columntext} \installcorenamespace{columnfooter} @@ -92,15 +50,20 @@ \nofcolumns#1\relax \fi \ifnum\nofcolumns>\allocatednofcolumns - \dorecurse\nofcolumns - {\ifnum\recurselevel>\allocatednofcolumns\relax + \page_columns_allocate + \fi} + +\def\page_columns_allocate + {\dorecurse\nofcolumns + {\ifnum\recurselevel>\allocatednofcolumns\relax + \ifcsname\??columntext\recurselevel\endcsname \else \expandafter\newbox\csname\??columntext \recurselevel\endcsname % text \expandafter\newbox\csname\??columnfooter\recurselevel\endcsname % footer \expandafter\newbox\csname\??columntop \recurselevel\endcsname % top insert \expandafter\newbox\csname\??columnbottom\recurselevel\endcsname % bottom insert - \fi}% - \global\allocatednofcolumns\nofcolumns - \fi} + \fi + \fi}% + \global\allocatednofcolumns\nofcolumns} \def\firstcolumnbox {\columntextbox\plusone} \def\currentcolumnbox {\columntextbox\mofcolumns} @@ -115,15 +78,15 @@ \def\columntopbox #1{\csname\??columntop \number#1\endcsname} \def\columnbotbox #1{\csname\??columnbottom\number#1\endcsname} -\def\columnsettextbox {\global\setbox\columntextbox} -\def\columnsetfootbox {\global\setbox\columnfootbox} -\def\columnsettopbox {\global\setbox\columntopbox} -\def\columnsetbotbox {\global\setbox\columnbotbox} +\unexpanded\def\columnsettextbox {\global\setbox\columntextbox} +\unexpanded\def\columnsetfootbox {\global\setbox\columnfootbox} +\unexpanded\def\columnsettopbox {\global\setbox\columntopbox} +\unexpanded\def\columnsetbotbox {\global\setbox\columnbotbox} -\def\columngettextbox {\copy\columntextbox} -\def\columngetfootbox {\copy\columnfootbox} -\def\columngettopbox {\copy\columntopbox} -\def\columngetbotbox {\copy\columnbotbox} +\unexpanded\def\columngettextbox {\copy\columntextbox} +\unexpanded\def\columngetfootbox {\copy\columnfootbox} +\unexpanded\def\columngettopbox {\copy\columntopbox} +\unexpanded\def\columngetbotbox {\copy\columnbotbox} \unexpanded\def\columnerasetextboxes{\dorecurse\allocatednofcolumns{\columnsettextbox\recurselevel\emptybox}} \unexpanded\def\columnerasefootboxes{\dorecurse\allocatednofcolumns{\columnsetfootbox\recurselevel\emptybox}} @@ -135,25 +98,80 @@ %D with \type {\currentcolumnbox}. In case of the mid columns, \type %D {\firstcolumnbox} and \type {\lastcolumnbox} are handled outside these macro's. -%D If needed these can be sped up by using a dedicated loop macro. +% \unexpanded\def\dohandlecolumn#1% +% {\mofcolumns\recurselevel +% \let\currentcolumn\recurselevel +% #1\relax} +% +% \unexpanded\def\dohandleallcolumns#1% +% {\dorecurse\nofcolumns{\dohandlecolumn{#1}}} +% +% \unexpanded\def\dohandlerevcolumns#1% +% {\dostepwiserecurse\nofcolumns\plusone\minusone{\dohandlecolumn{#1}}} +% +% \unexpanded\def\dohandlemidcolumns#1% +% {\dohandleallcolumns +% {\ifnum\recurselevel>\plusone +% \ifnum\recurselevel<\nofcolumns +% \dohandlecolumn{#1}% +% \fi +% \fi}} +% +% As we don't nest we can use a fast variant: + +\unexpanded\def\dohandleallcolumnscs#1{\let\page_columns_action #1\page_columns_all_indeed} +\unexpanded\def\dohandleallcolumns #1{\def\page_columns_action{#1}\page_columns_all_indeed} + +\unexpanded\def\dohandlerevcolumnscs#1{\let\page_columns_action #1\page_columns_rev_indeed} +\unexpanded\def\dohandlerevcolumns #1{\def\page_columns_action{#1}\page_columns_rev_indeed} + +\unexpanded\def\dohandlemidcolumnscs#1{\let\page_columns_action #1\page_columns_mid_indeed} +\unexpanded\def\dohandlemidcolumns #1{\def\page_columns_action{#1}\page_columns_mid_indeed} + +\unexpanded\def\page_columns_all_indeed + {\mofcolumns\plusone + \edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \ifnum\mofcolumns<\nofcolumns + \expandafter\page_columns_all_next + \fi} + +\unexpanded\def\page_columns_all_next + {\advance\mofcolumns\plusone + \edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \ifnum\mofcolumns<\nofcolumns + \expandafter\page_columns_all_next + \fi} -\unexpanded\def\dohandlecolumn#1% - {\mofcolumns\recurselevel - \let\currentcolumn\recurselevel - #1\relax} +\unexpanded\def\page_columns_rev_indeed + {\mofcolumns\nofcolumns + \edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \ifnum\mofcolumns>\plusone + \expandafter\page_columns_rev_prev + \fi} -\unexpanded\def\dohandleallcolumns#1% - {\dorecurse\nofcolumns{\dohandlecolumn{#1}}} +\unexpanded\def\page_columns_rev_prev + {\advance\mofcolumns\minusone + \edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \ifnum\mofcolumns>\plusone + \expandafter\page_columns_rev_prev + \fi} -\unexpanded\def\dohandlerevcolumns#1% - {\dostepwiserecurse\nofcolumns\plusone\minusone{\dohandlecolumn{#1}}} +\unexpanded\def\page_columns_mid_indeed + {\mofcolumns\plustwo + \ifnum\mofcolumns<\nofcolumns + \expandafter\page_columns_mid_next + \fi} -\unexpanded\def\dohandlemidcolumns#1% - {\dohandleallcolumns - {\ifnum\recurselevel>\plusone - \ifnum\recurselevel<\nofcolumns - \dohandlecolumn{#1}% - \fi - \fi}} +\unexpanded\def\page_columns_mid_next + {\edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \advance\mofcolumns\plusone + \ifnum\mofcolumns<\nofcolumns + \expandafter\page_columns_mid_next + \fi} \protect \endinput |