diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/buff-ver.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/buff-ver.mkiv | 155 |
1 files changed, 115 insertions, 40 deletions
diff --git a/Master/texmf-dist/tex/context/base/buff-ver.mkiv b/Master/texmf-dist/tex/context/base/buff-ver.mkiv index 430834a30d8..17dfd9d6933 100644 --- a/Master/texmf-dist/tex/context/base/buff-ver.mkiv +++ b/Master/texmf-dist/tex/context/base/buff-ver.mkiv @@ -19,6 +19,8 @@ \unprotect +\startcontextdefinitioncode + \definesystemattribute[verbatimline][public] \appendtoksonce @@ -45,8 +47,10 @@ \unexpanded\def\specialcontrolspace{\hskip\zeropoint\fastcontrolspace\hskip\zeropoint} -\setvalue{\??typinglines\v!yes }{\obeybreakpoints} -\setvalue{\??typinglines\v!hyphenated}{\obeyhyphens} +\setvalue{\??typinglines\v!no }{\buff_verbatim_ignore_hyphens} +\setvalue{\??typinglines\v!normal }{\buff_verbatim_ignore_hyphens} +\setvalue{\??typinglines\v!yes }{\buff_verbatim_obey_breakpoints} +\setvalue{\??typinglines\v!hyphenated}{\buff_verbatim_obey_hyphens} \setvalue{\??typingspace\v!on }{\let\obeyedspace\specialcontrolspace} \setvalue{\??typingspace\v!stretch }{\let\obeyedspace\specialstretchedspace} @@ -61,15 +65,36 @@ \setvalue{\??typingblank\v!line }{\baselineskip} \setvalue{\??typingblank\v!none }{\zeropoint} +\unexpanded\def\buff_verbatim_obey_hyphens + {} + +\unexpanded\def\buff_verbatim_obey_breakpoints + {\language\minusone % tricky as this affects the pagebuilder + \veryraggedright} + +\unexpanded\def\buff_verbatim_ignore_hyphens + {\language\minusone} % tricky as this affects the pagebuilder + +\def\buff_verbatim_initialize_breaks % order matters + {\spaceskip.5\emwidth\relax + \let\obeyedspace\specialobeyedspace + \let\controlspace\specialcontrolspace + \edef\p_buff_lines{\typeparameter\c!lines}% + \ifcsname\??typinglines\p_buff_lines\endcsname % sets \obeyedspace, \controlspace, + \csname\??typinglines\p_buff_lines\endcsname + \fi + \edef\p_buff_space{\typeparameter\c!space}% + \ifcsname\??typingspace\p_buff_space\endcsname % sets \obeyedspace + \csname\??typingspace\p_buff_space\endcsname + \fi} + \def\buff_verbatim_initialize_type_one {\let\obeylines\ignorelines - \ignorehyphens % default \usetypestyleandcolor\c!style\c!color \setcatcodetable\vrbcatcodes} \def\buff_verbatim_initialize_type_two - {\let\obeyedspace\specialobeyedspace - \csname\??typingspace\typeparameter\c!space\endcsname + {\buff_verbatim_initialize_breaks \relax\the\everyinitializeverbatim\relax} \unexpanded\def\doinitializeverbatim % for use elsewhere .. temp hack (see lxml-ini) @@ -98,13 +123,10 @@ {\switchtobodyfont[\typingparameter\c!bodyfont]% can be low level call \buff_verbatim_check_margins \usetypingstyleandcolor\c!style\c!color - \doifsomething{\typingparameter\c!align}{\setupalign[\typingparameter\c!align]}% - \ignorehyphens} % default + \doifsomething{\typingparameter\c!align}{\setupalign[\typingparameter\c!align]}} \def\buff_verbatim_initialize_typing_two - {\let\obeyedspace\specialobeyedspace - \csname\??typingspace\typingparameter\c!space\endcsname - \csname\??typinglines\typingparameter\c!lines\endcsname + {\buff_verbatim_initialize_breaks \relax\the\everyinitializeverbatim\relax} %D \macros @@ -149,7 +171,11 @@ \appendtoks \setuevalue{\e!start\currenttyping}{\buff_verbatim_typing_start{\currenttyping}}% \setuevalue{\e!stop \currenttyping}{\buff_verbatim_typing_stop {\currenttyping}}% - \normalexpanded{\definelinenumbering[\currenttyping]}% + \ifx\currenttypingparent\empty + \normalexpanded{\definelinenumbering[\currenttyping]}% + \else + \normalexpanded{\definelinenumbering[\currenttyping][\currenttypingparent]}% + \fi \to \everydefinetyping \appendtoks @@ -241,7 +267,7 @@ {\dontleavehmode \bgroup \edef\currenttype{#1}% - \doifnextoptionalelse\buff_verbatim_type_yes\buff_verbatim_type_nop} + \doifnextoptionalcselse\buff_verbatim_type_yes\buff_verbatim_type_nop} \def\buff_verbatim_type_yes[#1]% {\setupcurrenttype[#1]% @@ -255,9 +281,9 @@ {\dontleavehmode \bgroup \edef\currenttype{#1}% - \lettypeparameter\v!lines\v!hyphenated + \lettypeparameter\c!lines\v!hyphenated \let\specialobeyedspace\specialstretchedspace - \doifnextoptionalelse\buff_verbatim_type_yes\buff_verbatim_type_nop} + \doifnextoptionalcselse\buff_verbatim_type_yes\buff_verbatim_type_nop} \def\buff_verbatim_type_one {\ifx\next\bgroup @@ -298,10 +324,11 @@ {\buff_verbatim_initialize_type_two \dostarttagged\t!verbatim\currenttype \ctxcommand{typestring{ - data = \!!bs\detokenize{#1}\!!es, - tab = "\typeparameter\c!tab", - method = "\typeparameter\c!option", - nature = "inline", + data = \!!bs\detokenize{#1}\!!es, + tab = "\typeparameter\c!tab", + method = "\typeparameter\c!option", + nature = "inline", + compact = "\typeparameter\c!compact", % none | all | last (all needed in tabulate etc for manuals) }}% \dostoptagged \buff_verbatim_right_of_type @@ -334,7 +361,7 @@ \unexpanded\def\specialfixedspace {\kern\interwordspace\relax} \unexpanded\def\specialobeyedspace {\hskip\interwordspace\relax} % better than spaceskip -\unexpanded\def\specialstretchedspace{\hskip.5\interwordspace\s!plus.125\interwordstretch\relax} % more but not less +\unexpanded\def\specialstretchedspace{\hskip.5\interwordspace\s!plus.125\interwordspace\relax} % \interwordstretch can be zero \unexpanded\def\specialcontrolspace {\hskip\zeropoint\hbox{\normalcontrolspace}\hskip\zeropoint\relax} \unexpanded\def\obeyhyphens @@ -350,7 +377,7 @@ {\language\minusone % extra bonus, the \null should do the job too \let\obeyedspace \specialobeyedspace \let\controlspace\specialcontrolspace - \spaceskip.5em\relax} + \spaceskip.5\emwidth\relax} %D \macros %D {tex,arg,mat,dis,astype} @@ -378,7 +405,9 @@ \catcode\leftbraceasciicode \begingroupcatcode \catcode\rightbraceasciicode\endgroupcatcode #1% + \bgroup % else wrong font for #2 \aftergroup#2% + \aftergroup\egroup \let\nexttoken} \unexpanded\def\tex{\buff_verbatim_special_type\texescape \relax} @@ -414,21 +443,31 @@ \expandafter\buff_verbatim_typing_start_nop \fi} +\unexpanded\def\buff_verbatim_setup_keep_together + {\edef\p_keeptogether{\typingparameter\c!keeptogether}% + \ifx\p_keeptogether\v!yes + \settrue \c_buff_optimize_linebreaks + \else + \setfalse\c_buff_optimize_linebreaks + \fi} + \def\buff_verbatim_typing_start_nop {\typingparameter\c!before \startpacked[\v!blank] \buff_verbatim_setup_line_numbering \buff_verbatim_initialize_typing_one + \buff_verbatim_setup_keep_together \normalexpanded{\buff_verbatim_type_block{\e!start\currenttyping}{\e!stop\currenttyping}}} \def\buff_verbatim_typing_start_yes[#1]% {\typingparameter\c!before \startpacked[\v!blank] \doifassignmentelse{#1} - {\setuptyping[\currenttyping][#1]} - {\doifinset\v!continue{#1}{\setuptyping[\currenttyping][\c!continue=\v!yes]}}% + {\setupcurrenttyping[#1]} + {\doifinset\v!continue{#1}{\lettypingparameter\c!continue\v!yes}}% \buff_verbatim_setup_line_numbering \buff_verbatim_initialize_typing_one + \buff_verbatim_setup_keep_together \normalexpanded{\buff_verbatim_type_block{\e!start\currenttyping}{\e!stop\currenttyping}}} \unexpanded\def\buff_verbatim_type_block#1#2% @@ -637,9 +676,11 @@ \setuptyping [\c!before=\blank, \c!after=\blank, + %\c!keeptogether=yes, % this will become default (when tested enough) %\c!bodyfont=, %\c!color=, \c!space=\v!off, + \c!lines=\v!no, \c!page=\v!no, \c!tab=\v!yes, % what is this: \s!ascii ? \c!option=\v!none, @@ -652,7 +693,6 @@ \c!blank=\v!line, %\c!escape=, % yes | no | {START,STOP} | default when yes: {BTEX,ETEX} \c!numbering=\v!no, - %\c!lines=, %\c!range=, \c!start=1, %\c!stop=, @@ -662,18 +702,23 @@ \definetyping[\v!typing] -\setuptyping[\v!file] [\s!parent=\??typing\v!typing] % we don't want \start..\stop overload -\setuptyping[\v!buffer][\s!parent=\??typing\v!file] % we don't want \start..\stop overload +\setuptyping [\v!file] [\s!parent=\??typing \v!typing] % we don't want \start..\stop overload +\setuplinenumbering[\v!file] [\s!parent=\??linenumbering\v!typing] + +\setuptyping [\v!buffer][\s!parent=\??typing \v!file] % we don't want \start..\stop overload +\setuplinenumbering[\v!buffer][\s!parent=\??linenumbering\v!file] %D The setups for inline verbatim default to: \setuptype [\c!space=\v!off, + \c!lines=\v!no, %\c!color=, \c!style=\tt, %\c!option=\v!normal, \c!page=\v!no, - \c!tab=\v!yes] + \c!tab=\v!yes, + \c!compact=\v!all] %D Buffers @@ -685,6 +730,9 @@ \unexpanded\def\buff_verbatim_type_defined_buffer {\dotripleempty\buff_verbatim_type_defined_buffer_indeed} +\unexpanded\def\typedefinedbuffer[#1]% + {\buff_verbatim_type_defined_buffer[\v!buffer][\thedefinedbuffer{#1}]}% + \appendtoks \setuevalue{\e!type\currentbuffer}{\buff_verbatim_type_defined_buffer[\v!buffer][\currentdefinedbuffer]}% \to \everydefinebuffer @@ -719,8 +767,9 @@ \buff_verbatim_setup_line_numbering \buff_verbatim_initialize_typing_one \buff_verbatim_initialize_typing_two - \beginofverbatimlines \dostarttagged\t!verbatimblock{#1}% + \beginofverbatimlines + \dostarttagged\t!verbatimlines\empty \ctxcommand{typebuffer { name = "#2", strip = "\typingparameter\c!strip", @@ -733,6 +782,7 @@ }}% \dostoptagged \endofverbatimlines + \dostoptagged \stoppacked \typingparameter\c!after} @@ -807,19 +857,42 @@ % hooks: -\def\doinlineverbatimstart {} -\def\doinlineverbatimstop {} -\def\doinlineverbatimbeginline {} -\def\doinlineverbatimnewline {\obeyedspace} -\def\doinlineverbatimemptyline {\obeyedspace} - -\def\dodisplayverbatimstart {\buff_verbatim_begin_of_line} -\def\dodisplayverbatimstop {\buff_verbatim_end_of_line} -\def\dodisplayverbatimbeginline {\buff_verbatim_begin_of_line} -\def\dodisplayverbatimnewline {\buff_verbatim_end_of_line\par} -\def\dodisplayverbatimemptyline {\buff_verbatim_empty_line} - -\def\doverbatimspace {\obeyedspace} +\newcount \c_buff_verbatim_noflines +\newcount \c_buff_verbatim_current +\newconditional\c_buff_optimize_linebreaks + +\def\doverbatimspace {\obeyedspace} + +\unexpanded\def\doinlineverbatimstart {} +\unexpanded\def\doinlineverbatimstop {} +\unexpanded\def\doinlineverbatimbeginline {} +\unexpanded\def\doinlineverbatimnewline {\obeyedspace} +\unexpanded\def\doinlineverbatimemptyline {\obeyedspace} + +\unexpanded\def\dodisplayverbatimstart {\advance\c_buff_verbatim_current\plusone + \buff_verbatim_begin_of_line} +\unexpanded\def\dodisplayverbatimstop {\buff_verbatim_end_of_line} +\unexpanded\def\dodisplayverbatimbeginline{\advance\c_buff_verbatim_current\plusone + \buff_verbatim_begin_of_line} +\unexpanded\def\dodisplayverbatimnewline {\buff_verbatim_end_of_line + \par + \ifconditional\c_buff_optimize_linebreaks + \buff_verbatim_inject_breaks + \fi} +\unexpanded\def\dodisplayverbatimemptyline{\buff_verbatim_empty_line} + +\unexpanded\def\buff_verbatim_inject_breaks + {\ifnum\c_buff_verbatim_current=\plusone + \nobreak + \else\ifnum\c_buff_verbatim_noflines=\plusthree + \nobreak + \else\ifnum\c_buff_verbatim_current=\numexpr\c_buff_verbatim_noflines-\plusone\relax + \nobreak + \fi\fi\fi} + +\unexpanded\def\dodisplayverbatiminitialize#1% + {\c_buff_verbatim_noflines#1\relax + \c_buff_verbatim_current\zerocount} \loadmarkfile{buff-imp-default} % preloaded as otherwise spurious spaces inline due to loading \loadmarkfile{buff-imp-nested} % preloaded as otherwise spurious spaces inline due to loading @@ -846,4 +919,6 @@ \def\tex #1{\letterbackslash#1}% \to \everysimplifycommands +\stopcontextdefinitioncode + \protect \endinput |