1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Page Macros Column Helpers}
15
16
17
18
19
20\unprotect
21
22
23
24
25
26\newcount\mofcolumns \mofcolumns\plusone
27
28\newconstant\columndirection
29
30\setnewconstant\maxnofcolumns 50
31\setnewconstant\allocatednofcolumns 0
32
33\newdimen\columnwidth
34\newdimen\columndistance
35
36
37
38
39
40
41
42
43\installcorenamespace{columntext}
44\installcorenamespace{columnfooter}
45\installcorenamespace{columntop}
46\installcorenamespace{columnbottom}
47
48\unexpanded\def\initializecolumns#1
49 {\ifnum#1>\maxnofcolumns
50 \showmessage\m!columns1\maxnofcolumns
51 \nofcolumns\maxnofcolumns
52 \else
53 \nofcolumns#1\relax
54 \fi
55 \ifnum\nofcolumns>\allocatednofcolumns
56 \page_columns_allocate
57 \fi}
58
59\def\page_columns_allocate
60 {\dorecurse\nofcolumns
61 {\ifnum\recurselevel>\allocatednofcolumns\relax
62 \ifcsname\??columntext\recurselevel\endcsname \else
63 \expandafter\newbox\csname\??columntext \recurselevel\endcsname
64 \expandafter\newbox\csname\??columnfooter\recurselevel\endcsname
65 \expandafter\newbox\csname\??columntop \recurselevel\endcsname
66 \expandafter\newbox\csname\??columnbottom\recurselevel\endcsname
67 \fi
68 \fi}
69 \global\allocatednofcolumns\nofcolumns}
70
71\def\currentcolumn {1}
72
73\def\firstcolumnbox {\columntextbox\plusone}
74\def\currentcolumnbox {\columntextbox\mofcolumns}
75\def\lastcolumnbox {\columntextbox\nofcolumns}
76
77\def\firsttopcolumnbox {\columntopbox \plusone}
78\def\currenttopcolumnbox {\columntopbox \mofcolumns}
79\def\lasttopcolumnbox {\columntopbox \nofcolumns}
80
81\def\columntextbox #1{\csname\??columntext \number#1\endcsname}
82\def\columnfootbox #1{\csname\??columnfooter\number#1\endcsname}
83\def\columntopbox #1{\csname\??columntop \number#1\endcsname}
84\def\columnbotbox #1{\csname\??columnbottom\number#1\endcsname}
85
86\unexpanded\def\columnsettextbox {\global\setbox\columntextbox}
87\unexpanded\def\columnsetfootbox {\global\setbox\columnfootbox}
88\unexpanded\def\columnsettopbox {\global\setbox\columntopbox}
89\unexpanded\def\columnsetbotbox {\global\setbox\columnbotbox}
90
91\unexpanded\def\columngettextbox {\copy\columntextbox}
92\unexpanded\def\columngetfootbox {\copy\columnfootbox}
93\unexpanded\def\columngettopbox {\copy\columntopbox}
94\unexpanded\def\columngetbotbox {\copy\columnbotbox}
95
96\unexpanded\def\columnerasetextboxes{\dorecurse\allocatednofcolumns{\columnsettextbox\recurselevel\emptybox}}
97\unexpanded\def\columnerasefootboxes{\dorecurse\allocatednofcolumns{\columnsetfootbox\recurselevel\emptybox}}
98\unexpanded\def\columnerasetopboxes {\dorecurse\allocatednofcolumns{\columnsettopbox \recurselevel\emptybox}}
99\unexpanded\def\columnerasebotboxes {\dorecurse\allocatednofcolumns{\columnsetbotbox \recurselevel\emptybox}}
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127\unexpanded\def\dohandleallcolumnscs#1{\let\page_columns_action #1\page_columns_all_indeed}
128\unexpanded\def\dohandleallcolumns #1{\def\page_columns_action{#1}\page_columns_all_indeed}
129
130\unexpanded\def\dohandlerevcolumnscs#1{\let\page_columns_action #1\page_columns_rev_indeed}
131\unexpanded\def\dohandlerevcolumns #1{\def\page_columns_action{#1}\page_columns_rev_indeed}
132
133\unexpanded\def\dohandlemidcolumnscs#1{\let\page_columns_action #1\page_columns_mid_indeed}
134\unexpanded\def\dohandlemidcolumns #1{\def\page_columns_action{#1}\page_columns_mid_indeed}
135
136\unexpanded\def\page_columns_all_indeed
137 {\mofcolumns\plusone
138 \edef\currentcolumn{\the\mofcolumns}
139 \page_columns_action\relax
140 \ifnum\mofcolumns<\nofcolumns
141 \expandafter\page_columns_all_next
142 \fi}
143
144\unexpanded\def\page_columns_all_next
145 {\advance\mofcolumns\plusone
146 \edef\currentcolumn{\the\mofcolumns}
147 \page_columns_action\relax
148 \ifnum\mofcolumns<\nofcolumns
149 \expandafter\page_columns_all_next
150 \fi}
151
152\unexpanded\def\page_columns_rev_indeed
153 {\mofcolumns\nofcolumns
154 \edef\currentcolumn{\the\mofcolumns}
155 \page_columns_action\relax
156 \ifnum\mofcolumns>\plusone
157 \expandafter\page_columns_rev_prev
158 \fi}
159
160\unexpanded\def\page_columns_rev_prev
161 {\advance\mofcolumns\minusone
162 \edef\currentcolumn{\the\mofcolumns}
163 \page_columns_action\relax
164 \ifnum\mofcolumns>\plusone
165 \expandafter\page_columns_rev_prev
166 \fi}
167
168\unexpanded\def\page_columns_mid_indeed
169 {\mofcolumns\plustwo
170 \ifnum\mofcolumns<\nofcolumns
171 \expandafter\page_columns_mid_next
172 \fi}
173
174\unexpanded\def\page_columns_mid_next
175 {\edef\currentcolumn{\the\mofcolumns}
176 \page_columns_action\relax
177 \advance\mofcolumns\plusone
178 \ifnum\mofcolumns<\nofcolumns
179 \expandafter\page_columns_mid_next
180 \fi}
181
182\protect \endinput
183 |