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