1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\writestatus{loading}{ConTeXt Buffer Macros Verbatim}
17
18\registerctxluafile{buffver}{autosuffix}
19
20\unprotect
21
22\startcontextdefinitioncode
23
24\definesystemattribute[verbatimline][public]
25
26\appendtoks
27 \c_attr_verbatimline\attributeunsetvalue
28\to \everyforgetall
29
30
31
32\installcorenamespace{typinglines}
33\installcorenamespace{typingspace}
34
35\newtoks\everyinitializeverbatim
36
37\appendtoks
38 \expand\everyresettypesetting
39 \resetfontfeature
40 \resetcharacterspacing
41 \resetbreakpoints
42 \nohyphencollapsing
43\to \everyinitializeverbatim
44
45\permanent\protected\def\setverbatimspaceskip
46 {\spaceskip\scaledfontcharwd\fontx\relax
47 \xspaceskip\spaceskip}
48
49\defcsname\??typinglines\v!no \endcsname{\buff_verbatim_ignore_hyphens}
50\defcsname\??typinglines\v!normal \endcsname{\buff_verbatim_ignore_hyphens}
51\defcsname\??typinglines\v!yes \endcsname{\buff_verbatim_obey_breakpoints}
52\defcsname\??typinglines\v!hyphenated\endcsname{\buff_verbatim_obey_hyphens}
53
54\defcsname\??typingspace\v!on \endcsname{\enforced\let\obeyedspace\specialcontrolspace}
55\defcsname\??typingspace\v!stretch \endcsname{\enforced\let\obeyedspace\specialstretchedspace}
56\letcsname\??typingspace\v!normal \endcsname\donothing
57\defcsname\??typingspace\v!fixed \endcsname{\enforced\let\obeyedspace\specialfixedspace}
58\defcsname\??typingspace\v!character \endcsname{\enforced\chardef\obeyedspace\spaceasciicode}
59
60\protected\def\buff_verbatim_obey_hyphens
61 {}
62
63\protected\def\buff_verbatim_obey_breakpoints
64 {\nohyphens
65 \veryraggedright}
66
67\protected\def\buff_verbatim_ignore_hyphens
68 {\nohyphens}
69
70\def\buff_verbatim_initialize_type_one
71 {\enforced\let\obeylines\ignorelines
72 \edef\p_buff_option{\typeparameter\c!option}
73 \ifx\p_buff_option\v!none
74 \usetypestyleandcolor\c!style\c!color
75 \orelse\ifempty\p_buff_option
76 \usetypestyleandcolor\c!style\c!color
77 \else
78 \usetypestyleparameter\c!style
79 \fi
80 \setcatcodetable\vrbcatcodes}
81
82\def\buff_verbatim_initialize_type_two
83 {\spaceskip.5\emwidth\relax
84 \enforced\let\obeyedspace\specialobeyedspace
85 \enforced\let\controlspace\specialcontrolspace
86 \begincsname\??typinglines\typeparameter\c!lines\endcsname
87 \begincsname\??typingspace\typeparameter\c!space\endcsname
88 \relax\expand\everyinitializeverbatim\relax
89 \usesetupsparameter\typeparameter\relax}
90
91\permanent\protected\def\doinitializeverbatim
92 {\buff_verbatim_initialize_type_one
93 \buff_verbatim_initialize_type_two}
94
95\let\buff_verbatim_set_line_margin\relax
96
97\def\buff_verbatim_set_line_margin_indeed
98 {\hskip\doifelseoddpage{\typingparameter\c!oddmargin}{\typingparameter\c!evenmargin}\relax}
99
100\def\buff_verbatim_initialize_typing_one
101 {\usebodyfontparameter\typingparameter
102 \ifzerodim\typingparameter\c!oddmargin\else
103 \let\buff_verbatim_set_line_margin\buff_verbatim_set_line_margin_indeed
104 \fi
105 \ifzerodim\typingparameter\c!evenmargin\else
106 \let\buff_verbatim_set_line_margin\buff_verbatim_set_line_margin_indeed
107 \fi
108 \ifrelax\buff_verbatim_set_line_margin
109 \doadaptleftskip{\typingparameter\c!margin}
110 \fi
111 \edef\p_buff_option{\typingparameter\c!option}
112 \ifx\p_buff_option\v!none
113 \usetypingstyleandcolor\c!style\c!color
114 \orelse\ifempty\p_buff_option
115 \usetypingstyleandcolor\c!style\c!color
116 \else
117 \usetypingstyleparameter\c!style
118 \fi
119 \usealignparameter\typingparameter}
120
121\def\buff_verbatim_initialize_typing_two
122 {\spaceskip.5\emwidth\relax
123 \enforced\let\obeyedspace\specialobeyedspace
124 \enforced\let\controlspace\specialcontrolspace
125 \begincsname\??typinglines\typingparameter\c!lines\endcsname
126 \begincsname\??typingspace\typingparameter\c!space\endcsname
127 \relax\expand\everyinitializeverbatim\relax
128 \usesetupsparameter\typingparameter\relax}
129
130
131
132
133
134
135\installcorenamespace{type}
136
137\installcommandhandler \??type {type} \??type
138
139\appendtoks
140 \frozen\instance\protected\edefcsname\currenttype\endcsname{\buff_verbatim_type{\currenttype}}
141\to \everydefinetype
142
143\appendtoks
144 \buff_verbatim_initialize_visualizer{\typeparameter\c!option}
145\to \everysetuptype
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163\installcorenamespace{typing}
164
165\installcommandhandler \??typing {typing} \??typing
166
167\appendtoks
168 \frozen\protected\instance\edefcsname\e!start\currenttyping\endcsname{\buff_verbatim_typing_start{\currenttyping}{\currenttyping}}
169 \frozen\protected\instance\edefcsname\e!stop \currenttyping\endcsname{\buff_verbatim_typing_stop}
170 \ifempty\currenttypingparent
171 \normalexpanded{\definelinenumbering[\currenttyping]}
172 \else
173 \normalexpanded{\definelinenumbering[\currenttyping][\currenttypingparent]}
174 \fi
175\to \everydefinetyping
176
177\appendtoks
178 \buff_verbatim_initialize_visualizer{\typingparameter\c!option}
179\to \everysetuptyping
180
181\def\buff_verbatim_initialize_visualizer#1
182 {\ifproductionrun\clf_loadvisualizer{#1}\fi}
183
184\permanent\protected\def\doifelsevisualizer#1
185 {\clf_doifelsevisualizer{#1}}
186
187\aliased\let\doifvisualizerelse\doifelsevisualizer
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248\def\buff_verbatim_left_of_type
249 {\typeparameter\c!left
250 \typeparameter\c!command\bgroup}
251
252\def\buff_verbatim_right_of_type
253 {\egroup
254 \typeparameter\c!right}
255
256\permanent\protected\def\type{\buff_verbatim_type\empty}
257\permanent\protected\def\typ {\buff_verbatim_typ \empty}
258
259\protected\def\buff_verbatim_type#1
260 {\dontleavehmode
261 \bgroup
262 \cdef\currenttype{#1}
263 \buff_verbatim_type_indeed}
264
265\def\buff_verbatim_typ#1
266 {\dontleavehmode
267 \bgroup
268 \cdef\currenttype{#1}
269 \lettypeparameter\c!lines\v!hyphenated
270 \enforced\let\specialobeyedspace\specialstretchedspace
271 \buff_verbatim_type_indeed}
272
273\tolerant\def\buff_verbatim_type_indeed[#S#1]
274 {\ifarguments\or\setupcurrenttype[#1]\fi
275 \buff_verbatim_left_of_type
276 \futureexpand\bgroup\buff_verbatim_type_a\buff_verbatim_type_one}
277
278\def\buff_verbatim_type_one
279 {\catcode\lessthanasciicode\othercatcode
280 \catcode\morethanasciicode\othercatcode
281 \futureexpandis<\buff_verbatim_type_b\buff_verbatim_type_c}
282
283\def\buff_verbatim_type_three
284 {\if\next<
285 \expandafter\buff_verbatim_type_b
286 \else
287 \expandafter\buff_verbatim_type_c
288 \fi}
289
290\def\buff_verbatim_type_a
291 {\buff_verbatim_initialize_type_one
292 \setcatcodetable\tpacatcodes
293 \buff_verbatim_type_normal}
294
295\def\buff_verbatim_type_b#1
296 {\buff_verbatim_initialize_type_one
297 \setcatcodetable\tpbcatcodes
298 \buff_verbatim_type_nested}
299
300\def\buff_verbatim_type_c#1
301 {\buff_verbatim_initialize_type_one
302 \setcatcodetable\vrbcatcodes
303 \def\next##1#1{\buff_verbatim_type_normal{##1}}
304 \next}
305
306\def\buff_verbatim_type_normal#1
307 {\buff_verbatim_initialize_type_two
308 \dostarttaggedchained\t!verbatim\currenttype\??type
309 \clf_type
310 data {\protecteddetokenize{#1}}
311 tab {\typeparameter\c!tab}
312 method {\p_buff_option}
313 compact {\typeparameter\c!compact}
314 escape {\typeparameter\c!escape}
315
316 \relax
317 \dostoptagged
318 \buff_verbatim_right_of_type
319 \egroup}
320
321\def\buff_verbatim_type_nested#1
322 {\buff_verbatim_initialize_type_two
323 \dostarttaggedchained\t!verbatim\currenttype\??type
324 \clf_type
325 data {\detokenize{#1}}
326
327 tab {\typeparameter\c!tab}
328 method {\p_buff_option}
329 escape {\typeparameter\c!escape}
330
331 method {nested}
332 \relax
333 \dostoptagged
334 \buff_verbatim_right_of_type
335 \egroup
336 \gobbleoneargument}
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359\permanent\protected\def\specialfixedspace {\kern\interwordspace\relax}
360\permanent\protected\def\specialobeyedspace {\hskip\interwordspace\relax}
361\permanent\protected\def\specialstretchedspace {\hskip.5\interwordspace\s!plus.125\interwordspace\relax}
362\permanent\protected\def\specialcontrolspace {\normalcontrolspace\allowbreak}
363
364\permanent\protected\def\explicitfixedspace {\asciispacechar}
365\permanent\protected\def\explicitobeyedspace {\asciispacechar\allowbreak}
366\permanent\protected\def\explicitstretchedspace{\asciispacechar\hskip\zeropoint\s!plus.125\interwordspace\relax}
367\permanent\protected\def\explicitcontrolspace {\optionalcontrolspace\allowbreak}
368
369\appendtoks
370 \enforced\protected\def\obeyedspace{\hskip\zeroskip\relax\asciispacechar\hskip\zeroskip\relax}
371\to \everyenableelements
372
373\permanent\protected\def\obeyhyphens
374 {\enforced\let\obeyedspace \specialobeyedspace
375 \enforced\let\controlspace\specialcontrolspace
376 \spaceskip.25\emwidth\relax}
377
378\permanent\protected\def\obeybreakpoints
379 {\ignorehyphens
380 \veryraggedright}
381
382\permanent\protected\def\ignorehyphens
383 {\nohyphens
384 \enforced\let\obeyedspace \specialobeyedspace
385 \enforced\let\controlspace\specialcontrolspace
386 \spaceskip.5\emwidth\relax}
387
388
389
390
391
392
393
394
395
396
397\immutable\def\lesscharacter {<}
398\immutable\def\morecharacter {>}
399
400\immutable\let\texescape \textbackslash
401\immutable\let\leftargument \textbraceleft
402\immutable\let\rightargument \textbraceright
403\immutable\let\inlinemathmarker \textdollar
404\immutable\def\displaymathmarker{\textdollar\textdollar}
405
406\def\buff_verbatim_special_type#1#2#
407 {\dontleavehmode\bgroup
408 \buff_verbatim_initialize_type_one
409 \catcode\leftbraceasciicode \begingroupcatcode
410 \catcode\rightbraceasciicode\endgroupcatcode
411 #1
412 \bgroup
413 \aftergroup#2
414 \aftergroup\egroup
415 \let\nexttoken}
416
417\mutable\protected\def\tex{\buff_verbatim_special_type\texescape \relax}
418\mutable\protected\def\arg{\buff_verbatim_special_type\leftargument \rightargument}
419\mutable\protected\def\mat{\buff_verbatim_special_type\inlinemathmarker \inlinemathmarker}
420\mutable\protected\def\dis{\buff_verbatim_special_type\displaymathmarker\displaymathmarker}
421
422\aliased\let\normaltexttex\tex
423\aliased\let\normaltextarg\arg
424\aliased\let\normaltextmat\mat
425\aliased\let\normaltextdis\dis
426
427\permanent\protected\def\astype
428 {\dontleavehmode
429 \bgroup\usetypestyleandcolor\c!style\c!color\let\nexttoken}
430
431\permanent\protected\def\asciistr#1
432 {\dontleavehmode\begingroup
433 \dostarttagged\t!verbatim\empty
434 \usetypestyleandcolor\c!style\c!color\detokenize{#1}
435 \dostoptagged
436 \endgroup}
437
438
439
440
441\mutable\let\beginofverbatimlines\relax
442\mutable\let\endofverbatimlines \relax
443
444\protected\def\buff_verbatim_typing_start#1#2
445 {\begingroup
446 \cdef\currenttyping {#1}
447 \edef\currenttypingwrapper{#2}
448 \obeylines
449 \futureexpandis[\buff_verbatim_typing_start_yes\buff_verbatim_typing_start_nop}
450
451\def\buff_verbatim_typing_start_yes[#S#1]
452 {\ifhastok={#1}
453 \setupcurrenttyping[#1]
454 \orelse\ifcstok{#1}\v!continue
455 \lettypingparameter\c!continue\v!yes
456 \fi
457 \typingparameter\c!before\relax
458 \startpacked[\v!blank]
459 \buff_verbatim_setup_line_numbering
460 \buff_verbatim_initialize_typing_one
461 \buff_verbatim_setup_keep_together
462 \normalexpanded{\buff_verbatim_type_block{\e!start\currenttypingwrapper}{\e!stop\currenttypingwrapper}}}
463
464\def\buff_verbatim_typing_start_nop
465 {\typingparameter\c!before\relax
466 \startpacked[\v!blank]
467 \buff_verbatim_setup_line_numbering
468 \buff_verbatim_initialize_typing_one
469 \buff_verbatim_setup_keep_together
470 \normalexpanded{\buff_verbatim_type_block{\e!start\currenttypingwrapper}{\e!stop \currenttypingwrapper}}}
471
472\protected\def\buff_verbatim_setup_keep_together
473 {\ifcstok{\typingparameter\c!keeptogether}\v!yes
474 \c_buff_optimize_linebreaks\conditionaltrue
475 \else
476 \c_buff_optimize_linebreaks\conditionalfalse
477 \fi}
478
479\protected\def\buff_verbatim_type_block#1#2
480 {\normalexpanded{\buff_pickup
481 {typing}
482 {#1}
483 {#2}
484 {}
485 {\buff_verbatim_type_block_verbatim_indeed{#1}{#2}}
486 \ifcstok{\typingparameter\c!strip}\v!no\zerocount\else\plusone\fi}}
487
488\protected\def\buff_verbatim_type_block_verbatim_indeed#1#2
489 {\buff_verbatim_initialize_typing_two
490 \dostarttaggedchained\t!verbatimblock\currenttyping\??typing
491 \beginofverbatimlines
492 \dostarttagged\t!verbatimlines\empty
493 \clf_typebuffer
494 name {typing}
495 strip {\typingparameter\c!strip}
496 range {\typingparameter\c!range}
497 tab {\typingparameter\c!tab}
498 par {\typingparameter\c!paragraph}
499 method {\p_buff_option}
500 escape {\typingparameter\c!escape}
501 nature {display}
502 \relax
503 \dostoptagged
504 \endofverbatimlines
505 \dostoptagged
506 \begincsname#2\endcsname}
507
508\protected\def\buff_verbatim_typing_stop
509 {\stoppacked
510 \typingparameter\c!after\relax
511 \useindentnextparameter\typingparameter
512 \endgroup
513 \dorechecknextindentation}
514
515\permanent\protected\def\startnamedtyping[#1]
516 {\buff_verbatim_typing_start{#1}\e!namedtyping}
517
518\permanent\let\stopnamedtyping\buff_verbatim_typing_stop
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573\mutable\lettonothing\currenttypingfile
574
575\appendtoks
576 \frozen\protected\instance\edefcsname\e!type\currenttyping\v!file\endcsname{\typefile[\currenttyping]}
577\to \everydefinetyping
578
579\permanent\tolerant\protected\def\typefile[#S#1]#*[#S#2]#:#3
580 {\begingroup
581 \ifparameter#2\or
582 \setuptyping[#1][#2]
583 \buff_verbatim_type_file_checked{#1}{#3}
584 \orelse\ifparameter#1\or
585 \ifhastok={#1}
586 \setuptyping[\v!file][#1]
587 \buff_verbatim_type_file_checked\v!file{#3}
588 \else
589 \buff_verbatim_type_file_checked{#1}{#3}
590 \fi
591 \else
592 \buff_verbatim_type_file_checked\v!file{#3}
593 \fi
594 \useindentnextparameter\typingparameter
595 \endgroup
596 \dorechecknextindentation}
597
598\def\buff_verbatim_type_file_checked#1#2
599 {\doifelsetypingfile{#2}
600 {\buff_verbatim_type_file_indeed{#1}\currenttypingfile}
601 {\showmessage\m!verbatims1{#2}}}
602
603\permanent\protected\def\doifelsetypingfile#1
604 {\edef\currenttypingfile{\locfilename{#1}}
605 \ifempty\currenttypingfile
606 \edef\currenttypingfile{\locfilename{#1.tex}}
607 \fi
608 \ifempty\currenttypingfile
609 \expandafter\secondoftwoarguments
610 \else
611 \expandafter\firstoftwoarguments
612 \fi}
613
614\aliased\let\doiftypingfileelse\doifelsetypingfile
615
616\def\buff_verbatim_type_file_indeed#1#2
617 {\cdef\currenttyping{#1}
618 \typingparameter\c!before\relax
619 \startpacked[\v!blank]
620 \buff_verbatim_setup_line_numbering
621 \buff_verbatim_initialize_typing_one
622 \buff_verbatim_initialize_typing_two
623 \dostarttaggedchained\t!verbatimblock\currenttyping\??typing
624 \beginofverbatimlines
625 \dostarttagged\t!verbatimlines\empty
626 \clf_typefile
627 name {#2}
628 strip {\typingparameter\c!strip}
629 range {\typingparameter\c!range}
630 regime {\currentregime}
631 tab {\typingparameter\c!tab}
632 method {\p_buff_option}
633 nature {display}
634 \relax
635 \dostoptagged
636 \endofverbatimlines
637 \dostoptagged
638 \stoppacked
639 \typingparameter\c!after\relax}
640
641
642
643\newconditional\verbatimnumberinglines
644
645\permanent\protected\def\beginofverbatimlinenumbering
646 {\startlinenumbering
647 [\currenttyping]
648 [\c!continue=\typingparameter\c!continue,
649 \c!method=\v!type,
650 \c!start=\typingparameter\c!start,
651 \c!stop=\typingparameter\c!stop,
652 \c!step=\typingparameter\c!step]}
653
654\permanent\protected\def\endofverbatimlinenumbering
655 {\stoplinenumbering}
656
657\def\buff_verbatim_setup_line_numbering
658 {\ifdefined\startlinenumbering
659 \edef\p_numbering{\typingparameter\c!numbering}
660 \ifx\p_numbering\v!file
661 \setuplinenumbering[\currenttyping][\c!method=\v!file]
662 \verbatimnumberinglines\conditionaltrue
663 \orelse\ifx\p_numbering\v!line
664 \verbatimnumberinglines\conditionaltrue
665 \else
666 \verbatimnumberinglines\conditionalfalse
667 \fi
668 \ifconditional\verbatimnumberinglines
669 \enforced\let\beginofverbatimlines\beginofverbatimlinenumbering
670 \enforced\let\endofverbatimlines \endofverbatimlinenumbering
671 \fi
672 \fi}
673
674
675
676
677
678
679
680
681
682
683
684
685\permanent\protected\def\filename#1{{\tttf\hyphenatedfilename{#1}}}
686
687
688
689
690
691
692\permanent\protected\def\verbatim#1{\detokenize{#1}}
693
694
695
696
697
698
699
700
701\setuptyping
702 [\c!before=\blank,
703 \c!after=\blank,
704
705
706
707 \c!space=\v!off,
708 \c!lines=\v!no,
709 \c!page=\v!no,
710 \c!tab=\v!yes,
711 \c!option=\v!none,
712 \c!text=\v!no,
713 \c!style=\tt,
714 \c!indentnext=\v!yes,
715 \c!margin=\zeropoint,
716 \c!evenmargin=\zeropoint,
717 \c!oddmargin=\zeropoint,
718 \c!blank=\v!line,
719
720 \c!numbering=\v!no,
721
722 \c!start=1,
723
724 \c!step=1,
725
726 \c!strip=\v!no]
727
728\definetyping[\v!typing]
729
730
731
732\setuplinenumbering[\v!typing][\c!location=\v!left,\c!width=\zeropoint]
733
734\setuptyping [\v!file] [\s!parent=\??typing \v!typing]
735\setuplinenumbering[\v!file] [\s!parent=\??linenumbering\v!typing]
736
737\setuptyping [\v!buffer][\s!parent=\??typing \v!file]
738\setuplinenumbering[\v!buffer][\s!parent=\??linenumbering\v!file]
739
740
741
742\setuptype
743 [\c!space=\v!off,
744 \c!lines=\v!no,
745
746 \c!style=\tt,
747
748 \c!page=\v!no,
749 \c!tab=\v!yes,
750 \c!compact=\v!all]
751
752
753
754
755
756\permanent\protected\def\typebuffer
757 {\begingroup
758 \let\currenttyping\v!buffer
759 \buff_verbatim_type_buffer}
760
761\permanent\protected\def\typedefinedbuffer[#1]
762 {\buff_verbatim_type_defined_buffer[\v!buffer][\thedefinedbuffer{#1}]}
763
764
765
766
767
768
769\appendtoks
770 \frozen\instance\protected\edefcsname\e!type\currentbuffer\endcsname
771 {\buff_verbatim_type_defined_buffer[\currentbuffer][\currentdefinedbuffer]}
772\to \everydefinebuffer
773
774\appendtoks
775 \frozen\instance\protected\edefcsname\e!type\currenttyping\v!buffer\endcsname
776 {\buff_verbatim_type_buffer_class{\currenttyping}}
777\to \everydefinetyping
778
779\tolerant\protected\def\buff_verbatim_type_buffer[#S#1]#*[#S#2]
780 {\ifarguments
781 \buff_verbatim_type_buffer_indeed\currenttyping\empty
782 \or
783 \ifhastok={#1}
784 \setupcurrenttyping[#1]
785 \buff_verbatim_type_buffer_indeed\currenttyping\empty
786 \else
787 \processcommalist[#1]{\buff_verbatim_type_buffer_indeed\currenttyping}
788 \fi
789 \or
790 \setupcurrenttyping[#2]
791 \processcommalist[#1]{\buff_verbatim_type_buffer_indeed\currenttyping}
792 \fi
793 \useindentnextparameter\typingparameter
794 \endgroup
795 \dorechecknextindentation}
796
797\protected\def\buff_verbatim_type_buffer_class#1
798 {\begingroup
799 \cdef\currenttyping{#1}
800 \buff_verbatim_type_buffer}
801
802\tolerant\protected\def\buff_verbatim_type_defined_buffer[#1]#*[#2]#*[#S#3]
803 {\begingroup
804 \cdef\currenttyping{\namedbufferparameter{#1}\c!category}
805 \ifempty\currenttyping
806 \let\currenttyping\v!buffer
807 \fi
808 \ifhastok={#3}
809 \setupcurrenttyping[#3]
810 \orelse\ifempty{#3}\else
811 \cdef\currenttyping{#3}
812 \fi
813 \buff_verbatim_type_buffer_indeed{\currenttyping}{#2}
814 \useindentnextparameter\typingparameter
815 \endgroup
816 \dorechecknextindentation}
817
818\protected\def\buff_verbatim_type_buffer_indeed#1#2
819 {\cdef\currenttyping{#1}
820 \typingparameter\c!before\relax
821 \startpacked[\v!blank]
822 \buff_verbatim_setup_line_numbering
823 \buff_verbatim_initialize_typing_one
824 \buff_verbatim_initialize_typing_two
825 \dostarttaggedchained\t!verbatimblock{#1}\??typing
826 \beginofverbatimlines
827 \dostarttagged\t!verbatimlines\empty
828 \clf_typebuffer
829 name {#2}
830 strip {\typingparameter\c!strip}
831 range {\typingparameter\c!range}
832 regime {\currentregime}
833 tab {\typingparameter\c!tab}
834 par {\typingparameter\c!paragraph}
835 method {\p_buff_option}
836 escape {\typingparameter\c!escape}
837 nature {display}
838 \relax
839 \dostoptagged
840 \endofverbatimlines
841 \dostoptagged
842 \stoppacked
843 \typingparameter\c!after\relax}
844
845\permanent\tolerant\protected\def\typeinlinebuffer[#S#1]#,[#S#2]
846 {\dontleavehmode
847 \begingroup
848 \enforced\let\setupcurrenttyping\setupcurrenttype
849 \lettonothing\currenttype
850 \ifparameters
851 \buff_verbatim_type_buffer_indeed_inline\currenttyping\empty
852 \or
853 \ifhastok={#1}
854 \setupcurrenttyping[#1]
855 \buff_verbatim_type_buffer_indeed_inline\currenttyping\empty
856 \else
857 \processcommalist[#1]{\buff_verbatim_type_buffer_indeed_inline\currenttyping}
858 \fi
859 \or
860 \setupcurrenttyping[#2]
861 \processcommalist[#1]{\buff_verbatim_type_buffer_indeed_inline\currenttyping}
862 \fi
863 \endgroup}
864
865\protected\def\buff_verbatim_type_buffer_indeed_inline#1#2
866 {\cdef\currenttype{#1}
867 \buff_verbatim_initialize_type_one
868 \dostarttaggedchained\t!verbatim\currenttype\??type
869 \clf_typebuffer
870 name {#2}
871 strip {\v!yes}
872 regime {\currentregime}
873 method {\p_buff_option}
874 nature {inline}
875 \relax
876 \dostoptagged}
877
878
879
880
881
882
883
884
885\permanent\tolerant\protected\def\processbuffer[#S#1]#*[#S#2]
886 {\writestatus{nota bene}{\string\processbuffer\space is obsolete}
887 \begingroup
888 \ifarguments
889 \buff_verbatim_process_indeed\v!buffer\empty
890 \or
891 \ifhastok={#1}
892 \setuptyping[\v!buffer][#1]
893 \buff_verbatim_process_indeed\v!buffer\empty
894 \else
895 \processcommalist[#1]{\buff_verbatim_process_indeed\v!buffer}
896 \fi
897 \or
898 \setuptyping[\v!buffer][#2]
899 \processcommalist[#1]{\buff_verbatim_process_indeed\v!buffer}
900 \fi
901 \endgroup}
902
903\def\buff_verbatim_process_indeed#1#2
904 {\cdef\currenttyping{#1}
905 \clf_processbuffer
906 name {#2}
907 strip {\typingparameter\c!strip}
908 tab {\typingparameter\c!tab}
909
910
911 nature {direct}
912 \relax}
913
914
915
916
917
918\newinteger\nofverbatimlines
919
920\protected\def\buff_verbatim_begin_of_line
921 {\ifconditional\verbatimnumberinglines
922 \global\advanceby\nofverbatimlines\plusone
923 \c_attr_verbatimline\nofverbatimlines
924 \fi
925 \noindent
926 \buff_verbatim_set_line_margin
927 \expand\everyline
928 \strut
929 \dostarttagged\t!verbatimline\empty}
930
931\protected\def\buff_verbatim_end_of_line
932 {\dostoptagged
933 \obeyedline
934 \par
935 \ifconditional\verbatimnumberinglines
936 \c_attr_verbatimline\attributeunsetvalue
937 \fi}
938
939\protected\def\buff_verbatim_empty_line
940 {\dostoptagged
941 \ifconditional\verbatimnumberinglines
942 \par\strut\par
943 \else
944 \blank[\typingparameter\c!blank]
945 \fi
946 \dostarttagged\t!verbatimlines\empty}
947
948
949
950\newinteger \c_buff_verbatim_noflines
951\newinteger \c_buff_verbatim_current
952\newconditional\c_buff_optimize_linebreaks
953
954\permanent\protected\def\doverbatimspace {\obeyedspace}
955
956\permanent\protected\def\doinlineverbatimstart {}
957\permanent\protected\def\doinlineverbatimstop {}
958\permanent\protected\def\doinlineverbatimbeginline {}
959\permanent\protected\def\doinlineverbatimnewline {\obeyedspace}
960\permanent\protected\def\doinlineverbatimemptyline {\obeyedspace}
961
962\permanent\protected\def\dodisplayverbatimstart {\advanceby\c_buff_verbatim_current\plusone
963 \buff_verbatim_begin_of_line}
964\permanent\protected\def\dodisplayverbatimstop {\buff_verbatim_end_of_line}
965\permanent\protected\def\dodisplayverbatimbeginline{\advanceby\c_buff_verbatim_current\plusone
966 \buff_verbatim_begin_of_line}
967\permanent\protected\def\dodisplayverbatimnewline {\buff_verbatim_end_of_line
968 \par
969 \ifconditional\c_buff_optimize_linebreaks
970 \buff_verbatim_inject_breaks
971 \fi}
972\permanent\protected\def\dodisplayverbatimemptyline{\buff_verbatim_empty_line}
973
974\protected\def\buff_verbatim_inject_breaks
975 {\ifnum\c_buff_verbatim_current=\plusone
976 \nobreak
977 \orelse\ifnum\c_buff_verbatim_noflines=\plusthree
978 \nobreak
979 \orelse\ifnum\c_buff_verbatim_current=\numexpr\c_buff_verbatim_noflines\plusone\relax
980 \nobreak
981 \fi}
982
983\permanent\protected\def\dodisplayverbatiminitialize#1
984 {\forgetparindent
985 \c_buff_verbatim_noflines#1\relax
986 \c_buff_verbatim_current\zerocount}
987
988\loadmarkfile{buffimpdefault}
989\loadmarkfile{buffimpnested}
990\loadmarkfile{buffimpescaped}
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010\appendtoks
1011
1012 \enforced\def\type#1{\detokenize{#1}}
1013 \enforced\def\tex #1{\letterbackslash#1}
1014\to \everysimplifycommands
1015
1016\stopcontextdefinitioncode
1017
1018
1019
1020\permanent\protected\def\literalmode{\setcatcodetable\txtcatcodes}
1021
1022\protect \endinput
1023 |