summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/tabl-pln.mkii
blob: 39bb50f23293fbe2226441791fef40e40c47594e (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
%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}

\unprotect

\newif    \if@@plnusetab
\newif    \if@@plncr
\newbox   \@@plntabs
\newbox   \@@plntabsyet
\newbox   \@@plntabsdone
\newdimen \@@plntabdimen

\def\cleartabs % visible
  {\global\setbox\@@plntabsyet\null
   \setbox\@@plntabs\null}

\def\settabs % visible
  {\setbox\@@plntabs\null
   \futurelet\next\@@plnsettabs}

\def\tabalign % visible
  {\@@plnusetabtrue\@@plnmaketabbox}

\let\+\tabalign % no outer here (can be overloaded)

\def\@@plnsettabs
  {\ifx\next\+%
     \def\nxt{\afterassignment\@@plnsettab\let\nxt}%
   \else
     \let\nxt\@@plnsetcols
   \fi
   \let\next\relax
   \nxt}

\def\@@plnsettab
  {\let\nxt\relax
   \@@plnusetabfalse\@@plnmaketabbox}

\def\@@plnsetcols#1\columns
  {\scratchcounter#1%
   \@@plntabdimen\hsize
   \loop
     \ifnum\scratchcounter>\zerocount \@nother
   \repeat}

\def\@nother
  {\scratchdimen\@@plntabdimen
   \divide\scratchdimen\scratchcounter
   \setbox\@@plntabs\hbox{\hbox to\scratchdimen{}\unhbox\@@plntabs}%
   \advance\@@plntabdimen-\scratchdimen
   \advance\scratchcounter\minusone}

\def\@@plnmaketabbox
  {\begingroup
   \global\setbox\@@plntabsyet\copy\@@plntabs
   \global\setbox\@@plntabsdone\null
   \def\cr
     {\@@plncrtrue\crcr\egroup\egroup
      \if@@plnusetab\unvbox\zerocount\lastbox\fi\endgroup
      \setbox\@@plntabs\hbox{\unhbox\@@plntabsyet\unhbox\@@plntabsdone}}%
   \setbox\zerocount\vbox\bgroup\@@plncrfalse
   \ialign\bgroup&\@@plnbegintabbox##\@@plnendtabbox\crcr}

\def\@@plnbegintabbox
  {\setbox\zerocount\hbox\bgroup}

\def\@@plnendtabbox
  {\if@@plncr
     \egroup % now \box\zerocount holds the column
   \else
     \hss\egroup
     \global\setbox\@@plntabsyet\hbox
       {\unhbox\@@plntabsyet\global\setbox\plusone\lastbox}% now \box\plusone holds its size
    \ifvoid\plusone
      \global\setbox\plusone\hbox to\wd\zerocount{}%
    \else
      \setbox\zerocount\hbox to\wd\plusone{\unhbox\zerocount}%
    \fi
    \global\setbox\@@plntabsdone\hbox{\box\plusone\unhbox\@@plntabsdone}%
  \fi
  \box\zerocount}

\protect \endinput