blob: 3638006c79a53c19692fcdc4e80c5c01da5200b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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
128
129
130
131
132
|
%D The following bunch of macros come from plain \TEX\ by
%D Don Knuth and deal with basic alignment. We just include
%D them here so that they can be used if needed. Normally,
%D \CONTEXT\ users will fall back on one of the three table
%D environments.
%D
%D The hidden names are somewhat adapted and we use other
%D local variables.
\writestatus{loading}{ConTeXt Table Macros / Plain Tabular}
%D This code might become a module.
\unprotect
\newconditional \c_tabl_plain_cr
\newconditional \c_tabl_plain_use_tab
\newbox \b_tabl_plain_tabs
\newbox \b_tabl_plain_tabs_yet
\newbox \b_tabl_plain_tabs_done
\newdimen \d_tabl_plain_tab
\let\m_tabl_plain_next\relax
\def\cleartabs % visible
{\global\setbox\b_tabl_plain_tabs_yet\emptyhbox
\setbox\b_tabl_plain_tabs\emptyhbox}
\def\settabs % visible
{\setbox\b_tabl_plain_tabs\emptyhbox
\futurelet\m_tabl_plain_next\tabl_plain_set_tabs}
\def\tabalign % visible
{\settrue\c_tabl_plain_use_tab
\tabl_plain_make_tab_box}
\ifdefined\+ \else
\let\+\tabalign % no outer here (can be overloaded)
\fi
\def\tabl_plain_set_tabs
{\ifx\m_tabl_plain_next\+%
\let\tabl_plain_nxt\tabl_plain_align
\else\ifx\m_tabl_plain_next\tabalign % added hh
\let\tabl_plain_nxt\tabl_plain_align
\else
\let\tabl_plain_nxt\tabl_plain_set_cols
\fi\fi
\let\m_tabl_plain_next\relax
\tabl_plain_nxt}
\def\tabl_plain_align
{\afterassignment\tabl_plain_set_tab
\let\tabl_plain_nxt}
\def\tabl_plain_set_tab
{\let\tabl_plain_nxt\relax
\setfalse\c_tabl_plain_use_tab
\tabl_plain_make_tab_box}
\def\tabl_plain_set_cols#1\columns
{\scratchcounter#1\relax
\d_tabl_plain_tab\hsize
\loop
\ifnum\scratchcounter>\zerocount
\tabl_plain_other
\repeat}
\def\tabl_plain_other
{\scratchdimen\d_tabl_plain_tab
\divide\scratchdimen\scratchcounter
\setbox\b_tabl_plain_tabs\hbox
{\hbox to\scratchdimen{}%
\unhbox\b_tabl_plain_tabs}%
\advance\d_tabl_plain_tab-\scratchdimen
\advance\scratchcounter\minusone}
\def\tabl_plain_make_tab_box
{\begingroup
\let\+\tabalign % added hh
\global\setbox\b_tabl_plain_tabs_yet\copy\b_tabl_plain_tabs
\global\setbox\b_tabl_plain_tabs_done\emptyhbox
\let\cr\tabl_plain_cr
\setbox\scratchbox\vbox\bgroup
\setfalse\c_tabl_plain_cr
\ialign\bgroup
\aligntab
\tabl_plain_begin_tab_box
\alignmark\alignmark
\tabl_plain_end_tab_box
\crcr}
\def\tabl_plain_cr
{\settrue\c_tabl_plain_cr
\crcr
\egroup
\egroup
\ifconditional\c_tabl_plain_use_tab
\unvbox\scratchbox
\lastbox % okay?
\fi
\endgroup
\setbox\b_tabl_plain_tabs\hbox
{\unhbox\b_tabl_plain_tabs_yet
\unhbox\b_tabl_plain_tabs_done}}
\def\tabl_plain_begin_tab_box
{\setbox\scratchbox\hbox\bgroup}
\def\tabl_plain_end_tab_box
{\ifconditional\c_tabl_plain_cr
\egroup % now \box\scratchbox holds the column
\else
\hss
\egroup
\global\setbox\b_tabl_plain_tabs_yet\hbox
{\unhbox\b_tabl_plain_tabs_yet
\global\setbox\globalscratchbox\lastbox}% now \box\globalscratchbox holds its size
\ifvoid\globalscratchbox
\global\setbox\globalscratchbox\hbox to \wd\scratchbox
{}%
\else
\setbox\scratchbox\hbox to \wd\globalscratchbox
{\unhbox\scratchbox}%
\fi
\global\setbox\b_tabl_plain_tabs_done\hbox
{\box\globalscratchbox
\unhbox\b_tabl_plain_tabs_done}%
\fi
\box\scratchbox}
\protect \endinput
|