summaryrefslogtreecommitdiff
path: root/tex/context/base/cont-new.mkiv
blob: c58ec05bd1ab86abda2ae80ef721c1336b6ceeac (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
%D \module
%D   [       file=cont-new,
%D        version=1995.10.10,
%D          title=\CONTEXT\ Miscellaneous Macros,
%D       subtitle=New Macros,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\newcontextversion{2014.10.07 11:14}

%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.

\unprotect

% \writestatus\m!system{beware: some patches loaded from cont-new.mkiv}

% \attribute152\zerocount : marks ... lots of sweeps so best early in list

%D Maybe:

% \appendtoks
%     \inheritmaintextcolor
% \to \everybeforenoteinsert

% \appendtoks
%     \inheritmaintextcolor
% \to \everymargindatacontent

% This is experimental; if this changes we need to adapt the mb-mp
% style too. It's not in the core yet.

% \def\ActionY{\blank\analyzenofparlines{\inleftmargin{\analyzednofparlines}}}
% \def\ActionN{\analyzenofparlines{\inleftmargin{\analyzednofparlines}}}
%
% \saveparnumber\ifnum\nofparlines<2 \ActionY\else\ActionN\fi 1.1 nop \crlf
%                                                             1.2 nop \par
% \saveparnumber\ifnum\nofparlines<2 \ActionY\else\ActionN\fi 2.1 nop \par
% \saveparnumber\ifnum\nofparlines<2 \ActionY\else\ActionN\fi 3.1 yes \crlf
%                                                             3.2 nop \crlf
%                                                             3.3 nop \par
% \saveparnumber\ifnum\nofparlines<2 \ActionY\else\ActionN\fi 4.1 nop \crlf
%                                                             4.2 nop \par
% \saveparnumber\ifnum\nofparlines<2 \ActionY\else\ActionN\fi 5.1 nop \par
% \saveparnumber\ifnum\nofparlines<2 \ActionY\else\ActionN\fi 6.1 yes \par
%
% \saveparnumber\doifelselessparlines {2}\ActionY\ActionN     1.1 nop \crlf
%                                                             1.2 nop \par
% \saveparnumber\doifelselessparlines {2}\ActionY\ActionN     2.1 nop \par
% \saveparnumber\doifelselessparlines {2}\ActionY\ActionN     3.1 yes \crlf
%                                                             3.2 nop \crlf
%                                                             3.3 nop \par
% \saveparnumber\doifelselessparlines {2}\ActionY\ActionN     4.1 nop \crlf
%                                                             4.2 nop \par
% \saveparnumber\doifelselessparlines {2}\ActionY\ActionN     5.1 nop \par
% \saveparnumber\doifelselessparlines {2}\ActionY\ActionN     6.1 yes \par

\newcount   \c_typo_par_current
\newcount   \c_typo_par_saved
\newconstant\c_typo_par_state
\newconstant\c_typo_par_lines
\newconstant\c_typo_par_criterium

\appendtoks
    \advance\c_typo_par_current\plusone % local
\to \everypar

\unexpanded\def\saveparnumber
  {\c_typo_par_saved\tagparcounter} % local

\def\savedparnumber  {\number\c_typo_par_saved}
\def\currentparnumber{\number\c_typo_par_current}

\unexpanded\def\nofparlines
  {\numexpr
     \ifhmode
       \maxdimen
     \else\ifnum\c_typo_par_current=\c_typo_par_current
        % we have not yet started a new one
       \prevgraf
     \else\ifnum\c_typo_par_current>\c_typo_par_current
        % we are somewhere in the future
       \maxdimen
     \else
       \zerocount
     \fi\fi\fi
   \relax}

\unexpanded\def\setnofparlinesstate
  {\c_typo_par_state\numexpr
     \ifhmode
       \zerocount
     \else\ifnum\c_typo_par_current=\c_typo_par_current
        % we have not yet started a new one
       \plusone
     \else\ifnum\c_typo_par_current>\c_typo_par_current
        % we are somewhere in the future
       \plustwo
     \else
       \plusthree
     \fi\fi\fi
   \relax}

\unexpanded\def\shownofparlines
  {\dontleavehmode\hbox\bgroup
   \infofont
   [%
   \number\c_typo_par_current:\number\c_typo_par_current:\space
   \ifcase\c_typo_par_state
     unknown%
   \or
     \ifnum\c_typo_par_lines<\c_typo_par_criterium
       \darkred
       \number\c_typo_par_lines<\number\c_typo_par_criterium
     \else
       \darkgreen
       \number\c_typo_par_lines>=\number\c_typo_par_criterium
     \fi
   \or
     ahead%
   \else
     behind%
   \fi
   ]%
   \egroup}

\unexpanded\def\doifelselessparlines#1%
  {\c_typo_par_criterium#1\relax
   \c_typo_par_lines\prevgraf
   \setnofparlinesstate
   \ifnum\nofparlines<#1\relax
     \expandafter\firstoftwoarguments
   \else
     \expandafter\secondoftwoarguments
   \fi}

\unexpanded\def\doiflessparlines#1%
  {\c_typo_par_criterium#1\relax
   \c_typo_par_lines\prevgraf
   \setnofparlinesstate
   \ifnum\nofparlines<#1\relax
     \expandafter\firstofoneargument
   \else
     \expandafter\gobbleoneargument
   \fi}

%D Maybe:

\unexpanded\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox}
\unexpanded\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop}

%D Needs some work:

\unexpanded\def\startgridcorrection
  {\dosingleempty\spac_grid_correction_start}

\def\spac_grid_correction_start[#1]%
  {\ifgridsnapping
     \snaptogrid[#1]\vbox\bgroup
   \else
     \startbaselinecorrection
   \fi}

\unexpanded\def\stopgridcorrection
  {\ifgridsnapping
     \egroup
   \else
     \stopbaselinecorrection
   \fi}

\unexpanded\def\checkgridsnapping
  {\lineskip\ifgridsnapping\zeropoint\else\normallineskip\fi}

%D Probably obsolete:

\unexpanded\def\startcolumnmakeup % don't change
  {\bgroup
   \getrawnoflines\textheight % raw as we cna have topskip
   \setbox\scratchbox\vbox to \dimexpr\noflines\lineheight-\lineheight+\topskip\relax
     \bgroup
     \forgetall}

\unexpanded\def\stopcolumnmakeup
  {\egroup
   \dp\scratchbox\zeropoint
   \wd\scratchbox\textwidth
   \box\scratchbox
   \egroup
   \page_otr_command_synchronize_hsize}

%D Till we fixed all styles:

\let\\=\crlf

\protect \endinput