page-lin.mkvi /size: 21 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=page-lin,
3
%D version=2007.11.29,
4
%D title=\CONTEXT\ Core Macros,
5
%D subtitle=Line Numbering,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
% generic or not ... maybe not bother too much and simplify to mkiv only
15
% get rid of \mk* (left over from experimental times)
16
%
17
% to be redone (was experiment) .. can be hooked into margin code
18
% reshuffle arguments
19
%
20
% this is early luatex code, 2007 or even before that, and it shows ... we
21
% have better tricks now
22 23
\writestatus
{
loading
}{
ConTeXt
Core
Macros
/
Line
Numbering
}
24 25
\unprotect
26 27
% todo: save settings
28
%
29
% low level interface
30
%
31
% we should use normal counters but then we need to sync settings
32 33
% some line
34
%
35
% \startlocallinenumbering
36
% some source code 1\par
37
% some source code 2\par
38
% some source code 3\par
39
% \stoplocallinenumbering
40
%
41
% some line
42 43
\registerctxluafile
{
page
-
lin
}{}
44 45
\definesystemattribute
[
linenumber
]
[
public
]
46
\definesystemattribute
[
linereference
][
public
]
47 48
\appendtoksonce
49
\c_attr_linenumber
\attributeunsetvalue
50
\to
\everyforgetall
51 52
\appendtoks
53
\c_attr_linenumber
\attributeunsetvalue
54
\to
\everyinsidefloat
55 56
\newcount
\linenumber
% not used
57
\newbox
\b_page_lines_scratch
58
\newcount
\c_page_lines_reference
59
\newconstant
\c_page_lines_nesting
60 61
\newconditional
\tracelinenumbering
% we keep this for old times sake
62 63
\installtextracker
64
{
lines
.
numbers
.
show
}
65
{
\settrue
\tracelinenumbering
}
66
{
\setfalse
\tracelinenumbering
}
67 68
% id nr shift width leftskip dir
69 70
\installcorenamespace
{
linenumberinginstance
}
71 72
% tag skipflag s getfield(n,"shift") getfield(n,"width") leftmarginwidth(getlist(n)) getfield(n,"dir"))
73 74
\let
\makelinenumber
\gobblefivearguments
% used at lua end
75 76
\newconditional
\page_postprocessors_needed_box
77 78
\unexpanded
\def
\page_postprocessors_linenumbers_page_indeed
#
tag
{
\page_lines_add_numbers_to_box
{
#
tag
}
\plusone
\plusone
\zerocount
}
79
\unexpanded
\def
\page_postprocessors_linenumbers_box_indeed
#
tag
{
\page_lines_add_numbers_to_box
{
#
tag
}
\plusone
\plusone
\zerocount
}
80
\unexpanded
\def
\page_postprocessors_linenumbers_deepbox_indeed
#
tag
{
\page_lines_add_numbers_to_box
{
#
tag
}
\plusone
\plusone
\plusone
}
81
\unexpanded
\def
\page_postprocessors_linenumbers_column_indeed
#
tag
{
\page_lines_add_numbers_to_box
{
#
tag
}
\currentcolumn
\nofcolumns
\zerocount
}
82 83
\let
\page_postprocessors_linenumbers_page
\gobbleoneargument
84
\let
\page_postprocessors_linenumbers_box
\gobbleoneargument
85
\let
\page_postprocessors_linenumbers_deepbox
\gobbleoneargument
86
\let
\page_postprocessors_linenumbers_column
\gobbleoneargument
87 88
\unexpanded
\def
\page_postprocessors_linenumbers_check
89
{
\glet
\page_postprocessors_linenumbers_check
\relax
90
\glet
\page_postprocessors_linenumbers_page
\page_postprocessors_linenumbers_page_indeed
91
\glet
\page_postprocessors_linenumbers_box
\page_postprocessors_linenumbers_box_indeed
92
\glet
\page_postprocessors_linenumbers_deepbox
\page_postprocessors_linenumbers_deepbox_indeed
93
\glet
\page_postprocessors_linenumbers_column
\page_postprocessors_linenumbers_column_indeed
}
94 95
\def
\page_lines_start_define
96
{
\setxvalue
{
\??linenumberinginstance
\currentlinenumbering
}
%
97
{
\clf_registerlinenumbering
98
continue
{
\ifnum
\c_page_lines_mode
=
\zerocount
\v!yes
\else
\v!no
\fi
}
%
99
start
\linenumberingparameter
\c!start
100
step
\linenumberingparameter
\c!step
101
method
{
\linenumberingparameter
\c!method
}
%
102
tag
{
\currentlinenumbering
}
%
103
}}
104 105
\def
\page_lines_start_update
106
{
\clf_setuplinenumbering
107
\csname
\??linenumberinginstance
\currentlinenumbering
\endcsname
108
{
%
109
continue
{
\ifnum
\c_page_lines_mode
=
\zerocount
\v!yes
\else
\v!no
\fi
}
%
110
}
%
111
\relax
}
112 113
\def
\page_lines_setup
114
{
\ifcsname
\??linenumberinginstance
\currentlinenumbering
\endcsname
115
\clf_setuplinenumbering
116
\lastnamedcs
117
{
%
118
continue
{
\ifnum
\c_page_lines_mode
=
\zerocount
\v!yes
\else
\v!no
\fi
}
%
119
start
\linenumberingparameter
\c!start
120
step
\linenumberingparameter
\c!step
121
method
{
\linenumberingparameter
\c!method
}
%
122
tag
{
\currentlinenumbering
}
%
123
}
%
124
\relax
125
\fi
}
126 127
% we could make this a bit more efficient by putting the end reference
128
% in the same table as the start one but why make things complex ...
129 130
\unexpanded
\def
\page_lines_some_reference
#
1
#
2
#
3
%
131
{
\dontleavehmode
\begingroup
132
\global\advance
\c_page_lines_reference
\plusone
133
\c_attr_linereference
\c_page_lines_reference
134
#
3
% todo: #3{#1} as there is no need to pass #1 as part of #3
135
% for the moment we use a simple system i.e. no prefixes etc .. todo: store as number
136
\c_strc_references_bind_state
\zerocount
% we don't want the prewordbreak and manage it here
137
\normalexpanded
{
\strc_references_set_named_reference
{
line
}{
#
2
}{
conversion
=
\linenumberingparameter
\c!conversion
}{
\the
\c_page_lines_reference
}}
% kind labels userdata text
138
\endgroup
}
139 140
% \def\page_lines_reference_start#1{\page_lines_some_reference{#1}{lr:b:#1}{}} % reimplemented later
141
% \def\page_lines_reference_stop #1{\page_lines_some_reference{#1}{lr:e:#1}{}} % reimplemented later
142 143
% \def\mklinestartreference#1[#2]{\in{#1}[lr:b:#2]} % not interfaced/ not used
144
% \def\mklinestopreference #1[#2]{\in{#1}[lr:e:#2]} % not interfaced/ not used
145 146
\newif
\ifnumberinglines
% will change
147
\newif
\iftypesettinglines
% will change
148 149
\installcorenamespace
{
linenumbering
}
150 151
\installcommandhandler
\??linenumbering
{
linenumbering
}
\??linenumbering
152 153
\setnewconstant
\c_page_lines_mode
\plusone
% 0=continue, 1=restart
154
\setnewconstant
\c_page_lines_location
\plusone
% 0=middle, 1=left, 2=right, 3=inner, 4=outer, 5=text, 6=begin, 7=end
155
\setnewconstant
\c_page_lines_alignment
\plusfive
% 0=middle, 1=left, 2=right, 5=auto
156 157
\newdimen
\d_page_lines_width
158
\newdimen
\d_page_lines_distance
159 160
\newevery
\beforeeverylinenumbering
\relax
161
\newevery
\aftereverylinenumbering
\relax
162
\newevery
\everylinenumber
\relax
163 164
\appendtoks
165
\page_lines_setup
166
\to
\everysetuplinenumbering
167 168
\appendtoks
169
\page_lines_start_define
170
\to
\everydefinelinenumbering
171 172
\setuplinenumbering
173
[
\c!conversion
=
\v!numbers
,
174
\c!start
=
1
,
175
\c!step
=
1
,
176
\c!method
=
\v!first
,
177
\c!continue
=
\v!no
,
178
\c!style
=
,
179
\c!color
=
,
180
\c!width
=
2
\emwidth
,
181
\c!left
=
,
182
\c!right
=
,
183
\c!command
=
,
184
\c!margin
=
2
.
5
\emwidth
,
185
\c!distance
=
\zeropoint
,
186
\c!location
=
\v!default
,
% depends on direction, columns etc
187
\c!align
=
\v!auto
]
188 189
\definelinenumbering
190
[]
191 192
% \startlinenumbering[<startvalue>|continue|settings|name]
193
% \startlinenumbering[name][<startvalue>|continue|settings]
194 195
\unexpanded
\def
\startlinenumbering
196
{
\begingroup
197
\page_postprocessors_linenumbers_check
198
\dodoubleempty
\page_lines_start
}
199 200
\newcount
\c_pages_lines_nesting
201 202
\def
\page_lines_start
% we stay downward compatible
203
{
\advance
\c_pages_lines_nesting
\plusone
204
\ifnum
\c_pages_lines_nesting
>
\plusone
205
\expandafter
\dodoubleempty
\expandafter
\gobbletwooptionals
206
\else
207
\expandafter
\page_lines_start_indeed
208
\fi
}
209 210
\def
\page_lines_start_indeed
211
{
\ifsecondargument
212
\expandafter
\page_lines_start_two
213
\else
\iffirstargument
214
\doubleexpandafter
\page_lines_start_one
215
\else
216
\doubleexpandafter
\page_lines_start_zero
217
\fi\fi
}
218 219
\def
\page_lines_start_zero
[#
1
][#
2
]
%
220
{
\edef
\m_argument
{
\linenumberingparameter
\c!continue
}
%
221
\ifx
\m_argument
\v!yes
222
\c_page_lines_mode
\zerocount
223
\else
224
\c_page_lines_mode
\plusone
225
\fi
226
\page_lines_start_followup
}
227 228
\def
\page_lines_start_one
[#
1
][#
2
]
% [continue|<number>|settings] % historic
229
{
\edef
\m_argument
{
#
1
}
%
230
\ifx
\m_argument
\v!continue
231
\c_page_lines_mode
\zerocount
232
\let
\currentlinenumbering
\empty
233
\else
234
\c_page_lines_mode
\plusone
235
\ifx
\m_argument
\v!empty
236
\let
\currentlinenumbering
\empty
237
\else
238
\doifelseassignment
{
#
1
}
239
{
\let
\currentlinenumbering
\empty
240
\setupcurrentlinenumbering
[#
1
]
}
241
{
\doifelsenumber
\m_argument
242
{
\let
\currentlinenumbering
\empty
243
\letlinenumberingparameter
\c!start
\m_argument
}
244
{
\let
\currentlinenumbering
\m_argument
}}
%
245
\fi
246
\edef
\p_continue
{
\linenumberingparameter
\c!continue
}
%
247
\ifx
\p_continue
\v!yes
248
\c_page_lines_mode
\zerocount
249
\fi
250
\fi
251
\page_lines_start_followup
}
252 253
\def
\page_lines_start_two
[#
1
][#
2
]
% [tag][continue|<number>|settings]
254
{
\edef
\currentlinenumbering
{
#
1
}
%
255
\edef
\m_argument
{
#
2
}
%
256
\ifx
\m_argument
\v!continue
257
\c_page_lines_mode
\zerocount
258
\else
259
\c_page_lines_mode
\plusone
260
\ifx
\m_argument
\v!empty
\else
261
\doifelseassignment
{
#
2
}
262
{
\setupcurrentlinenumbering
[#
2
]
}
263
{
\doifnumber
\m_argument
264
{
\letlinenumberingparameter
\c!start
\m_argument
}}
%
265
\fi
266
\edef
\p_continue
{
\linenumberingparameter
\c!continue
}
%
267
\ifx
\p_continue
\v!yes
268
\c_page_lines_mode
\zerocount
269
\fi
270
\fi
271
\page_lines_start_followup
}
272 273
\newconditional
\c_page_lines_auto_narrow
274
%\newconditional\c_page_lines_enabled
275 276
\appendtoks
277
\ifconditional
\page_postprocessors_needed_box
278
\page_postprocessors_linenumbers_page
\b_page_postprocessor
279
\fi
280
\to
\t_page_postprocessors_page
281 282
\appendtoks
283
\ifconditional
\page_postprocessors_needed_box
284
\page_postprocessors_linenumbers_column
\b_page_postprocessor
285
\fi
286
\to
\t_page_postprocessors_column
287 288
\def
\page_lines_start_followup
289
{
\numberinglinestrue
290
\edef
\p_location
{
\linenumberingparameter
\c!location
}
%
291
\setfalse
\c_page_lines_auto_narrow
292
\ifhmode
\else
293
\ifx
\p_location
\v!text
294
\ifdim
\leftskip
>
\zeropoint
\else
295
\advance\leftskip
\linenumberingparameter
\c!margin
296
\settrue
\c_page_lines_auto_narrow
297
\fi
298
\else\ifx
\p_location
\v!begin
299
\ifdim
\leftskip
>
\zeropoint
\else
300
\advance\leftskip
\linenumberingparameter
\c!margin
301
\settrue
\c_page_lines_auto_narrow
302
\fi
303
\else\ifx
\p_location
\v!end
304
\ifdim
\leftskip
>
\zeropoint
\else
305
\advance\rightskip
\linenumberingparameter
\c!margin
306
\settrue
\c_page_lines_auto_narrow
307
\fi
308
\fi\fi\fi
309
\fi
310
\the
\beforeeverylinenumbering
311
%\global\settrue\c_page_lines_enabled %
312
\global
\settrue
\page_postprocessors_needed_box
% see core-rul.mkiv
313
\ifcase
\c_page_lines_mode
\relax
314
\page_lines_start_update
% continue
315
\or
316
\page_lines_start_define
% only when assignment
317
\fi
318
\c_attr_linenumber
\csname
\??linenumberinginstance
\currentlinenumbering
\endcsname\relax
}
319 320
\unexpanded
\def
\stoplinenumbering
321
{
\ifconditional
\c_pages_lines_nesting
=
\plusone
322
\c_attr_linenumber
\attributeunsetvalue
323
\the
\aftereverylinenumbering
324
\ifconditional
\c_page_lines_auto_narrow
\par\fi
325
\fi
326
\endgroup
}
327 328
% number placement .. will change into (the new) margin code
329 330
\newconditional
\c_page_lines_fake_number
331
\newconstant
\b_page_lines_number
332
\newconstant
\c_page_lines_column
333
\newconstant
\c_page_lines_last_column
334
\newdimen
\d_page_lines_line_width
335
\settrue
\c_page_lines_dir_left_to_right
336 337
\installcorenamespace
{
linenumberinghandler
}
338 339
\def
\page_line_swap_align
% can become a helper
340
{
\ifx
\p_align
\v!inner
\let
\p_align
\v!outer
\else
341
\ifx
\p_align
\v!outer
\let
\p_align
\v!inner
\else
342
\ifx
\p_align
\v!flushleft
\let
\p_align
\v!flushright
\else
343
\ifx
\p_align
\v!flushright
\let
\p_align
\v!flushleft
\else
344
\ifx
\p_align
\v!left
\let
\p_align
\v!right
\else
345
\ifx
\p_align
\v!right
\let
\p_align
\v!left
\fi\fi\fi\fi\fi\fi
}
346 347
\let
\page_lines_make_number_indeed
\relax
348 349
% \def\page_lines_rlap{\ifconditional\c_page_lines_dir_left_to_right\expandafter\rlap\else\expandafter\llap\fi}
350
% \def\page_lines_llap{\ifconditional\c_page_lines_dir_left_to_right\expandafter\llap\else\expandafter\rlap\fi}
351 352
\def
\page_lines_add_numbers_to_box
#
box
#
column
#
max
#
nesting
%
353
{
\bgroup
354
\strc_tags_enable_indeed
355
\b_page_lines_number
#
box
\relax
356
\c_page_lines_column
#
column
\relax
357
\c_page_lines_last_column
#
max
\relax
358
\fullrestoreglobalbodyfont
359
\let
\makelinenumber
\page_lines_make_number
% used at lua end
360
\setbox
\b_page_lines_scratch
\vbox
361
{
\forgetall
362
\offinterlineskip
363
\clf_linenumbersstageone
364
\b_page_lines_number
365
#
nesting
%
366
\relax
}
%
367
\clf_linenumbersstagetwo
368
\b_page_lines_number
369
\b_page_lines_scratch
370
\relax
371
\egroup
}
372 373
\def
\page_lines_make_number
#
tag
#
mode
#
linenumber
#
width
#
dir
% with hang and parindent and skips we have to compensate for \hsize
374
{
\naturalhbox
to
\zeropoint
\bgroup
375
\ifcase
#
mode
\relax
376
% \settrue \c_page_lines_fake_number
377
\else
378
% \setfalse\c_page_lines_fake_number
379
\edef
\currentlinenumbering
{
#
tag
}
%
380
\def
\linenumber
{
#
linenumber
}
% unsafe
381
\d_page_lines_line_width
#
width
\scaledpoint
\relax
382
\d_page_lines_distance
\linenumberingparameter
\c!distance
\relax
383
\edef
\p_align
{
\linenumberingparameter
\c!align
}
%
384
\edef
\p_location
{
\linenumberingparameter
\c!location
}
%
385
\ifcase
#
dir
\relax
386
\settrue
\c_page_lines_dir_left_to_right
387
\else
388
\setfalse
\c_page_lines_dir_left_to_right
389
\fi
390
%
391
% maybe we also need an option to ignore columns, so that we renumber
392
% once but on the other hand this assumes aligned lines
393
%
394
\ifcase
\c_page_lines_last_column
\relax
395
\settrue
\c_page_lines_fake_number
% why
396
\or
397
% one column
398
\or
399
% two columns
400
\ifx
\p_location
\v!default
% or just margin
401
\ifcase
\c_page_lines_column
\relax
402
\settrue
\c_page_lines_fake_number
% why
403
\or
404
% one
405
\let
\p_location
\v!left
406
\else
407
% two
408
\let
\p_location
\v!right
409
% can become a helper
410
\page_line_swap_align
411
\fi
412
\fi
413
\else
414
% too fuzzy
415
\fi
416
\ifx
\p_location
\v!default
417
\ifconditional
\c_page_lines_dir_left_to_right
418
\let
\p_location
\v!left
419
\else
420
\let
\p_location
\v!right
421
\page_line_swap_align
% yes or no
422
\fi
423
\fi
424
%
425
\begincsname
\??linenumberinghandler
\p_location
\endcsname
426
\fi
427
\egroup
}
428 429
\def
\page_lines_number_inject
#
align
#
width
%
430
{
\edef
\p_width
{
\linenumberingparameter
\c!width
}
%
431
\ifx
\p_width
\v!margin
432
\d_page_lines_width
#
width
%
433
\else
434
\d_page_lines_width
\p_width
435
\fi
436
\relax
437
\ifdim
\d_page_lines_width
>
\zeropoint
438
% \ifconditional\c_page_lines_dir_left_to_right\else
439
% \let\simplealignedbox\simplereversealignedbox
440
% \fi
441
\ifconditional
\tracelinenumbering
442
\ruledhbox
{
\simplealignedbox
\d_page_lines_width
#
align
{
\page_lines_number_inject_indeed
}}
%
443
\else
444
\simplealignedbox
\d_page_lines_width
#
align
{
\page_lines_number_inject_indeed
}
%
445
\fi
446
\else
447
\ifconditional
\tracelinenumbering
448
\ruledhbox
449
\else
450
% \hbox
451
\fi
452
{
\page_lines_number_inject_indeed
}
%
453
\fi
}
454 455
\def
\page_lines_number_inject_indeed
456
{
\uselinenumberingstyleandcolor
\c!style\c!color
457
\linenumberingparameter
\c!command
458
{
\linenumberingparameter
\c!left
459
\convertnumber
{
\linenumberingparameter
\c!conversion
}
\linenumber
460
\linenumberingparameter
\c!right
}}
461 462
% \def\dodorlap{\hbox to \zeropoint{\box\nextbox\normalhss}\endgroup}
463
% \def\dodollap{\hbox to \zeropoint{\normalhss\box\nextbox}\endgroup}
464 465
\def
\page_line_handle_left
#
align
#
width
#
distance
%
466
{
\dostarttagged
\t!linenumber
\empty
467
\llap
468
{
\page_lines_number_inject
#
align
#
width
%
469
\dostarttagged
\t!ignore
\empty
470
\kern\dimexpr
471
#
distance
+
\d_page_lines_distance
472
\ifconditional
\c_page_lines_dir_left_to_right
\else
+
\d_page_lines_line_width
\fi
473
\relax
474
\the
\everylinenumber
475
\hss
476
\dostoptagged
}
%
477
\dostoptagged
}
478 479
\def
\page_line_handle_right
#
align
#
width
#
distance
%
480
{
\dostarttagged
\t!linenumber
\empty
481
\rlap
482
{
\dostarttagged
\t!ignore
\empty
483
\kern\dimexpr
484
#
distance
+
\d_page_lines_distance
485
\ifconditional
\c_page_lines_dir_left_to_right
+
\d_page_lines_line_width
\fi
486
\relax
487
\dostoptagged
488
\page_lines_number_inject
#
align
#
width
%
489
\dostarttagged
\t!ignore
\empty
490
\the
\everylinenumber
491
\hss
492
\dostoptagged
}
%
493
\dostoptagged
}
494 495
\setuvalue
{
\??linenumberinghandler\v!left
}
%
496
{
\page_line_handle_left
\p_align
\leftmarginwidth
\leftmargindistance
}
497 498
\setuvalue
{
\??linenumberinghandler\v!right
}
%
499
{
\page_line_handle_right
\p_align
\rightmarginwidth
\rightmargindistance
}
500 501
\setuvalue
{
\??linenumberinghandler\v!inner
}
%
502
{
\ifodd
\realpageno
503
\ifx
\p_align
\v!inner
504
\page_line_handle_left
\v!flushleft
\leftmarginwidth
\leftmargindistance
505
\else\ifx
\p_align
\v!outer
506
\page_line_handle_left
\v!flushright
\leftmarginwidth
\leftmargindistance
507
\else
508
\page_line_handle_left
\p_align
\leftmarginwidth
\leftmargindistance
509
\fi\fi
510
\else
511
\ifx
\p_align
\v!inner
512
\page_line_handle_right
\v!flushright
\rightmarginwidth
\rightmargindistance
513
\else\ifx
\p_align
\v!outer
514
\page_line_handle_right
\v!flushleft
\rightmarginwidth
\rightmargindistance
515
\else
516
\page_line_handle_right
\p_align
\rightmarginwidth
\rightmargindistance
517
\fi\fi
518
\fi
}
519 520
\setuvalue
{
\??linenumberinghandler\v!outer
}
%
521
{
\ifodd
\realpageno
522
\ifx
\p_align
\v!inner
523
\page_line_handle_right
\v!flushleft
\leftmarginwidth
\leftmargindistance
524
\else\ifx
\p_align
\v!outer
525
\page_line_handle_right
\v!flushright
\leftmarginwidth
\leftmargindistance
526
\else
527
\page_line_handle_right
\p_align
\leftmarginwidth
\leftmargindistance
528
\fi\fi
529
\else
530
\ifx
\p_align
\v!inner
531
\page_line_handle_left
\v!flushright
\rightmarginwidth
\rightmargindistance
532
\else\ifx
\p_align
\v!outer
533
\page_line_handle_left
\v!flushleft
\rightmarginwidth
\rightmargindistance
534
\else
535
\page_line_handle_left
\p_align
\rightmarginwidth
\rightmargindistance
536
\fi\fi
537
\fi
}
538 539
\def
\page_line_handle_begin
#
align
%
540
{
\rlap
541
{
\kern
\d_page_lines_distance
542
\page_lines_number_inject
#
align
\zeropoint
543
\the
\everylinenumber
}}
544 545
\def
\page_line_handle_end
#
align
%
546
{
\rlap
547
{
\kern
\d_page_lines_line_width
\relax
548
\llap
549
{
\page_lines_number_inject
#
align
\zeropoint
550
\kern
\d_page_lines_distance
551
\the
\everylinenumber
}}}
552 553
\setuvalue
{
\??linenumberinghandler\v!begin
}{
\page_line_handle_begin
\p_align
}
554
\setuvalue
{
\??linenumberinghandler\v!end
}{
\page_line_handle_end
\p_align
}
555
\setuvalue
{
\??linenumberinghandler\v!text
}{
\page_line_handle_begin
\p_align
}
556 557
\expandafter\let\csname
\??linenumberinghandler\v!inleft
\expandafter\endcsname\csname
\??linenumberinghandler\v!left
\endcsname
558
\expandafter\let\csname
\??linenumberinghandler\v!inmargin
\expandafter\endcsname\csname
\??linenumberinghandler\v!left
\endcsname
559
\expandafter\let\csname
\??linenumberinghandler\v!margin
\expandafter\endcsname\csname
\??linenumberinghandler\v!left
\endcsname
560
\expandafter\let\csname
\??linenumberinghandler\v!inright
\expandafter\endcsname\csname
\??linenumberinghandler\v!right
\endcsname
561 562
% referencing: \permithyphenation, also removes leading spaces (new per 29-11-2013)
563 564
\unexpanded
\def
\someline
[#
1
]
{
\page_lines_reference_start
{
#
1
}
\page_lines_reference_stop
{
#
1
}}
% was just a def
565
%unexpanded\def\startline[#1]{\page_lines_reference_start{#1}\ignorespaces}
566
\unexpanded
\def
\startline
[#
1
]
{
\page_lines_reference_start
{
#
1
}
\permithyphenation
\ignorespaces
}
%okay?
567
\unexpanded
\def
\stopline
[#
1
]
{
\removeunwantedspaces
\permithyphenation
\page_lines_reference_stop
{
#
1
}}
568 569
\def
\page_lines_reference_show_start
570
{
\ifconditional
\tracelinenumbering
571
\expandafter
\page_lines_reference_show_start_indeed
572
\else
573
\expandafter
\gobbleoneargument
574
\fi
}
575 576
\def
\page_lines_reference_show_stop
577
{
\ifconditional
\tracelinenumbering
578
\expandafter
\page_lines_reference_show_stop_indeed
579
\else
580
\expandafter
\gobbleoneargument
581
\fi
}
582 583
\def
\page_lines_reference_show_start_indeed
#
1
%
584
{
\setbox
\scratchbox
\hpack
{
\llap
585
{
\vrule
\s!width
\onepoint
\s!depth
\strutdp
\s!height
.
8
\strutht
\raise
.
8
5
\strutht
\hpack
{
\llap
{
\tt
\txx
#
1
}}}}
%
586
\smashbox
\scratchbox
587
\box
\scratchbox
}
588 589
\def
\page_lines_reference_show_stop_indeed
#
1
%
590
{
\setbox
\scratchbox
\hpack
{
\rlap
591
{
\raise
.
8
5
\strutht
\hpack
{
\rlap
{
\tt
\txx
#
1
}}
\vrule
\s!width
\onepoint
\s!depth
\strutdp
\s!height
.
8
\strutht
}}
%
592
\smashbox
\scratchbox
593
\box
\scratchbox
}
594 595
\def
\page_lines_reference_start
#
1
{
\page_lines_some_reference
{
#
1
}{
lr
:
b
:
#
1
}{
\page_lines_reference_show_start
{
#
1
}}}
596
\def
\page_lines_reference_stop
#
1
{
\page_lines_some_reference
{
#
1
}{
lr
:
e
:
#
1
}{
\page_lines_reference_show_stop
{
#
1
}}}
597 598
% eventually we will do this in lua
599 600
\def
\currentreferencelinenumber
{
\clf_filterreference
{
linenumber
}}
601 602
\let
\m_page_lines_from
\empty
603
\let
\m_page_lines_to
\empty
604 605
\unexpanded
\def
\doifelsesamelinereference
#
1
#
2
#
3
%
606
{
\doifelsereferencefound
{
lr
:
b
:
#
1
}
607
{
\edef
\m_page_lines_from
{
\currentreferencelinenumber
}
%
608
\doifelsereferencefound
{
lr
:
e
:
#
1
}
609
{
\edef
\m_page_lines_to
{
\currentreferencelinenumber
}
%
610
%[\m_page_lines_from,\m_page_lines_to]
611
\ifx
\m_page_lines_from
\m_page_lines_to
#
2
\else
#
3
\fi
}
612
{
#
2
}}
613
{
#
2
}}
614 615
\let
\doifsamelinereferenceelse\doifelsesamelinereference
616 617
\unexpanded
\def
\inline
#
1
[#
2
]
%
618
{
\doifelsenothing
{
#
1
}
619
{
\doifelsesamelinereference
{
#
2
}
620
{
\in
{
\leftlabeltext
\v!line
}{
\rightlabeltext
\v!line
}
[
lr
:
b
:
#
2
]
}
621
{
\in
{
\leftlabeltext
\v!lines
}{}
[
lr
:
b
:
#
2
]
--
\in
{}{
\rightlabeltext
\v!lines
}
[
lr
:
e
:
#
2
]
}}
622
{
\doifelsesamelinereference
{
#
2
}
623
{
\in
{
#
1
}
[
lr
:
b
:
#
2
]
}
624
{
\in
{
#
1
}
[
lr
:
b
:
#
2
]
--
\in
[
lr
:
e
:
#
2
]
}}}
625 626
\unexpanded
\def
\inlinerange
[#
1
]
%
627
{
\doifelsesamelinereference
{
#
1
}
628
{
\in
[
lr
:
b
:
#
1
]
}
629
{
\in
[
lr
:
b
:
#
1
]
\endash\in
[
lr
:
e
:
#
1
]
}}
630 631
\protect
\endinput
632