diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
commit | 57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch) | |
tree | 1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/tex/context/base/buff-ver.mkiv | |
parent | 6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff) |
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/buff-ver.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/buff-ver.mkiv | 290 |
1 files changed, 178 insertions, 112 deletions
diff --git a/Master/texmf-dist/tex/context/base/buff-ver.mkiv b/Master/texmf-dist/tex/context/base/buff-ver.mkiv index 28e3e60d501..dacbdb7ac99 100644 --- a/Master/texmf-dist/tex/context/base/buff-ver.mkiv +++ b/Master/texmf-dist/tex/context/base/buff-ver.mkiv @@ -17,9 +17,9 @@ \unprotect -\ifx\startlinenumbering\undefined \let\startlinenumbering\relax \fi -\ifx\stoplinenumbering \undefined \let\stoplinenumbering\relax \fi -\ifx\setuplinenumbering\undefined \def\setuplinenumbering[#1]{} \fi +\ifdefined\startlinenumbering\else \let\startlinenumbering \relax \fi +\ifdefined\stoplinenumbering \else \let\stoplinenumbering \relax \fi +\ifdefined\setuplinenumbering\else \unexpanded\def\setuplinenumbering[#1]{} \fi % D \macros % D {iflinepar} @@ -66,16 +66,17 @@ \uppercasestring#2\to\asciib \setevalue{\??ty\??ty\asciia}{\asciib}} -\def\setupprettiesintype#1% +\unexpanded\def\setupprettiesintype#1% {\uppercasestring#1\to\ascii \edef\prettyidentifier{\executeifdefined{\??ty\??ty\ascii}{TEX}}% \begingroup % we can move this to lua - \lowercasestring \f!prettyprefix\prettyidentifier\to\filename - \doonlyonce\filename{\ctxloadluafile\filename\empty}% + % \lowercasestring \f!prettyprefix\prettyidentifier\to\filename + % \doonlyonce\filename{\ctxloadluafile\filename\empty}% + \ctxlua{buffers.loadvisualizer("\ascii")}% \endgroup} -\def\setupprettytype +\unexpanded\def\setupprettytype {\processingverbatimtrue % will move \ctxlua{buffers.visualizers.reset()}} @@ -84,7 +85,7 @@ \spaceskip\wd\scratchbox \xspaceskip\spaceskip} -\let\obeycharacters\relax +\let\obeycharacters\relax % tab mess can go \setvalue{\??tp:\c!lines:\v!yes }{\obeybreakpoints} \setvalue{\??tp:\c!lines:\v!hyphenated}{\obeyhyphens} @@ -93,59 +94,65 @@ %setvalue{\??tp:\c!empty:\v!all }{\obeyallemptylines} \setvalue{\??tp:\c!option:\v!none }{\let\obeycharacters\relax} -\setvalue{\??tp:\c!option:\v!color }{\setupprettiesintype{TEX}% - \let\obeycharacters\setupprettytype - \let\obeytabs\ignoretabs} +\setvalue{\??tp:\c!option:\empty }{\let\obeycharacters\relax} +\setvalue{\??tp:\c!option:\v!color }{\setupprettiesintype{\typingparameter\c!option}% + \let\obeycharacters\setupprettytype} \setvalue{\??tp:\c!option:\v!normal }{\let\obeycharacters\setupgroupedtype} -\setvalue{\??tp:\c!option:\v!commands }{\def\obeycharacters{\setupcommandsintype}% - \let\obeytabs\ignoretabs} -\setvalue{\??tp:\c!option:\v!slanted }{\let\obeycharacters\setupslantedtype - \let\obeytabs\ignoretabs} +\setvalue{\??tp:\c!option:\v!slanted }{\let\obeycharacters\setupslantedtype} \setvalue{\??tp:\c!option:\s!unknown }{\setupprettiesintype{\typingparameter\c!option}% - \let\obeycharacters\setupprettytype - \let\obeytabs\ignoretabs} + \let\obeycharacters\setupprettytype} +%setvalue{\??tp:\c!option:\v!commands }{\def\obeycharacters{\setupcommandsintype}} \def\dosetverbatimfont {\redoconvertfont\dosetfontattribute{\currenttypingclass\currenttyping}\c!style \normalnoligatures\font} -\def\setupcommonverbatim +\unexpanded\def\setupcommonverbatim {\let\prettyidentifier\s!default % -% \doifelse{\typingparameter\c!text}\v!yes -% \naturaltextexttrue -% \naturaltextextfalse \def\prettyidentifierfont{\typingparameter\c!icommand}% \def\prettyvariablefont {\typingparameter\c!vcommand}% \def\prettynaturalfont {\typingparameter\c!ccommand}% % - \doif{\typingparameter\c!space}\v!on - {\def\obeyspaces{\setcontrolspaces}}% - \doif{\typingparameter\c!page }\v!no - {\def\obeypages {\ignorepages}}% - % \ignorehyphens % default \getvalue{\??tp:\c!lines:\typingparameter\c!lines}% \getvalue{\??tp:\c!empty:\typingparameter\c!empty}% \getvalue{\??tp:\c!option:\ifcsname\??tp:\c!option:\typingparameter\c!option\endcsname\typingparameter\c!option\else\s!unknown\fi}% - \doifnumberelse{\typingparameter\c!tab} - {\def\obeytabs{\setfixedtabskips{\typingparameter\c!tab}}}% - \donothing \setupverbatimcolor} \newtoks \everyinitializeverbatim -\def\doinitializeverbatim +\def\ignorebeginofpretty [#1]{} +\def\ignoreendofpretty {} + +\def\doverbatimbop{\bgroup\beginofpretty} +\def\doverbatimeop{\endofpretty\egroup} +\def\doverbatimsop{\endofpretty\egroup\bgroup\beginofpretty} + +\let\noverbatimbop\ignorebeginofpretty +\let\noverbatimeop\ignoreendofpretty +\let\noverbatimsop\ignorebeginofpretty + +\def\doinitializeverbatim % todo: combine all in one call is faster {\ctxlua{buffers.visualizers.reset()}% - \def\obs{\obeyedspace}% + \doifelse{\typingparameter\c!space}\v!on + {\let\obs\fastcontrolspace}% + {\let\obs\specialobeyedspace}% + \edef\askedverbatimtab{\typingparameter\c!tab}% + \doifelse\askedverbatimtab\v!no + {\ctxlua{buffers.settablength(1)}} + {\doifnumberelse{\askedverbatimtab} + {\ctxlua{buffers.settablength(\askedverbatimtab)}} + {\ctxlua{buffers.settablength()}}}% \ctxlua{buffers.doifelsevisualizer("\prettyidentifier")} {\ctxlua{buffers.setvisualizer("\prettyidentifier")}% - \def\bop{\bgroup\beginofpretty}% - \def\eop{\endofpretty\egroup}% - \def\sop{\endofpretty\egroup\bgroup\beginofpretty}}% - {\let\bop\donothing - \let\eop\donothing - \let\sop\donothing}% + \let\bop\doverbatimbop + \let\eop\doverbatimeop + \let\sop\doverbatimsop}% + {\ctxlua{buffers.setvisualizer("\v!typing")}% or resetdefaultvisualizer + \let\bop\noverbatimbop + \let\eop\noverbatimeop + \let\sop\noverbatimsop}% \relax\the\everyinitializeverbatim\relax} \appendtoks @@ -163,14 +170,54 @@ % \typeTEX{\example---oeps}. this---ligates---again. % \type {\example---oeps}. this---ligates---again. -\def\setupcommandsintype % can also be \string\ - {\ctxlua{ - buffers.visualizers.enableescape = true - buffers.visualizers.escapetoken = \!!bs\typingparameter\c!escape\!!es - }% - \setevalue{\typingparameter\c!escape}{\typingparameter\c!escape}} +%D \startbuffer +%D \setuptyping[TEX][escape=yes] +%D +%D \startTEX +%D /BTEX\em sometex/ETEX +%D /BTEX\em sometex/ETEX \after +%D \before /BTEX\em sometex/ETEX +%D \before /BTEX\em sometex/ETEX \after +%D \before /BTEX\em sometex/ETEX \inbetween /BTEX\em sometex/ETEX \after +%D \before \after +%D \stopTEX +%D \stopbuffer +%D +%D \typebuffer \start \getbuffer \stop +%D +%D \startbuffer +%D \setuptyping[TEX][escape={[[,]]}] +%D +%D \startTEX +%D [[\em sometex]] +%D [[\em sometex]] \after +%D \before [[\em sometex]] +%D \before [[\em sometex]] \after +%D \before [[\em sometex]] \inbetween [[\em sometex]] \after +%D \before \after +%D \stopTEX +%D \stopbuffer +%D +%D \typebuffer \start \getbuffer \stop +%D +%D \startbuffer +%D \setuptyping[TEX][escape=//] +%D +%D \startTEX +%D //\em sometex +%D \before //\em sometex +%D \stopTEX +%D +%D \typebuffer \start \getbuffer \stop + +\unexpanded\def\setupcommandsintype + {\ctxlua{buffers.set_escape("\currenttyping",\!!bs\typingparameter\c!escape\!!es)}} + +\appendtoks + \setupcommandsintype +\to \everyinitializeverbatim -\def\setupslantedtype +\unexpanded\def\setupslantedtype {\slantedtypepermittedtrue} \ifx\setupprettytype \undefined \let\setupprettytype \relax \fi @@ -272,15 +319,6 @@ \catcode`\>=\@@other \futurelet\next\dodotype} -% \def\dodotype -% {\ifx\next\bgroup -% \@EA\dodotypeA -% \else\if\next<% -% \doifelse{\typingparameter\c!option}\v!none{\@EAEAEA\dodotypeB}{\@EAEAEA\dodotypeC}% -% \else -% \@EAEAEA\dodotypeD -% \fi\fi} - \def\dodotype {\ifx\next\bgroup \@EA\dodotypeA @@ -362,19 +400,15 @@ \setupcommonverbatim %\dosetverbatimfont %\setverbatimspaceskip - %\let\obeytabs \ignoretabs % probably not needed - %\let\obeylines\ignorelines % probably not needed - %\let\obeypages\ignorepages % probably not needed %\setupcopyverbatim % not needed - \setcatcodetable\vrbcatcodes - } + \setcatcodetable\vrbcatcodes} %D \macros %D {setuptype} %D %D Some characteristics of \type{\type} can be set up by: -\def\setuptype +\unexpanded\def\setuptype {\dodoubleempty\dosetuptype} \def\dosetuptype[#1][#2]% @@ -407,7 +441,7 @@ \veryraggedright} \def\ignorehyphens - {% \language\minusone % extra bonus, the \null should do the job too + {\language\minusone % extra bonus, the \null should do the job too \let\obeyedspace \specialobeyedspace \let\controlspace\specialcontrolspace \spaceskip.5em\relax} @@ -465,6 +499,19 @@ \unexpanded\def\mat{\groupedcommand{\setgroupedtype\$}{\$}} \unexpanded\def\dis{\groupedcommand{\setgroupedtype\$\$}{\$\$}} +\let\normaltexttex\tex +\let\normaltextarg\arg +\let\normaltextmat\mat +\let\normaltextdis\dis + +\def\astype + {\groupedcommand\dorawtype\relax} + +\def\dorawtype + {\let\currenttypingclass\??ty + \normalverbatimcolor % \verbatimcolor + \dosetverbatimfont} + %D \macros %D {starttyping} %D @@ -491,9 +538,9 @@ {\setxvalue{\currenttypingclass\currenttyping#1}{#2}} \setvalue{\??tp:\c!blank:\v!standard}{\ctxparskip} -\setvalue{\??tp:\c!blank:\v!small }{\blankokleinmaat} -\setvalue{\??tp:\c!blank:\v!medium }{\blankomiddelmaat} -\setvalue{\??tp:\c!blank:\v!big }{\blankogrootmaat} +\setvalue{\??tp:\c!blank:\v!small }{\smallskipamount} +\setvalue{\??tp:\c!blank:\v!medium }{\medskipamount} +\setvalue{\??tp:\c!blank:\v!big }{\bigskipamount} \setvalue{\??tp:\c!blank:\v!halfline}{.5\baselineskip} \setvalue{\??tp:\c!blank:\v!line }{\baselineskip} \setvalue{\??tp:\c!blank:\v!none }{\zeropoint} @@ -519,9 +566,11 @@ \else \doadaptleftskip{\typingparameter\c!margin}% \fi + % no symbolic blanks ! \edef\!!stringa{\executeifdefined{\??bo\typingparameter\c!blank}{\typingparameter\c!blank}}% \scratchskip\executeifdefined{\??tp:\c!blank:\!!stringa}\!!stringa\relax \ifgridsnapping + % this will be adapted \ifdim\scratchskip=.5\baselineskip\relax \edef\verbatimbaselineskip{\the\scratchskip}% new \else @@ -530,6 +579,7 @@ \else \edef\verbatimbaselineskip{\the\scratchskip}% \fi +\doifsomething{\typingparameter\c!align}{\setupalign[\typingparameter\c!align]}% \setupcommonverbatim} %D The basic display verbatim commands are defined in an @@ -582,22 +632,21 @@ \def\dotypefileverbatim {\doinitializeverbatim - \ctxlua{buffers.typefile("\readfilename")}} + \beginofverbatimlines + \ctxlua{buffers.typefile("\readfilename","\typingparameter\c!strip","\typingparameter\c!range")}% + \endofverbatimlines} \def\dotypefilelinesverbatim#1#2% - {#1% - \doinitializeverbatim - \ctxlua{buffers.typefile("\readfilename")}% - #2} + {#1\dotypefileverbatim#2} \unexpanded\def\dotypeblockverbatim#1#2% - {\dowithbuffer{_typing_}{#1}{#2} - {} - {\doinitializeverbatim - \beginofverbatimlines - \ctxlua{buffers.type("_typing_")}% - \endofverbatimlines - \csname#2\endcsname}} + {\dowithbuffer{_typing_}{#1}{#2} + {} + {\doinitializeverbatim + \beginofverbatimlines + \ctxlua{buffers.type("_typing_","\typingparameter\c!strip","\typingparameter\c!range")}% + \endofverbatimlines + \csname#2\endcsname}} \def\dododostarttyping[#1]% {\typingparameter\c!before @@ -612,8 +661,7 @@ {\stopverbatimcolor \stoppacked % includes \egroup \typingparameter\c!after - \egroup - \dochecknextindentation{\??tp#1}% + \normalexpanded{\egroup\checknextindentation[\typingparameter\c!indentnext]}% \dorechecknextindentation} %D Line numbering for files is combined with filtering, while @@ -630,7 +678,7 @@ %D ... %D \stopcode %D -%D \startcode[continue] +%D \startcode[start=continue] %D ... %D ... %D \stopcode @@ -640,6 +688,27 @@ %D \stopcode %D \stoptyping +%D Ranges: +%D +%D \starttyping +%D % label:start:one +%D +%D \def\MyMacro +%D {just an example} +%D +%D % label:stop:one +%D +%D \starttext +%D +%D % \typefile[file][range={3,6}]{whatever.tex} +%D +%D % \typefile[file][range={3,+2}]{whatever.tex} +%D +%D \typefile[file][range={label:start:one,label:stop:one}]{whatever.tex} +%D +%D \stoptext +%D \stoptyping + %D \macros %D {setuptyping} %D @@ -655,7 +724,7 @@ \getparameters[\??tp][#1]% \fi} -\def\setuptyping +\unexpanded\def\setuptyping {\dodoubleempty\dosetuptyping} %D \macros @@ -664,11 +733,11 @@ %D Specific inline verbatim commands can be defined with the %D following command. -\def\definetype +\unexpanded\def\definetype {\dodoubleempty\dodefinetype} \def\dodefinetype[#1][#2]% - {\unexpanded\setvalue{#1}{\dotype{#1}}% + {\setuvalue{#1}{\dotype{#1}}% \getparameters[\??ty#1][#2]} %D \macros @@ -688,7 +757,9 @@ %D %D The definitions default to the standard typing values. -\def\presettyping[#1][#2]% +% TODO: parent etc ! + +\def\presettyping[#1][#2]% brrr also use parent here {\copyparameters[\??tp#1][\??tp][\c!color,\c!style]% \getparameters [\??tp#1][#2]} @@ -697,7 +768,7 @@ \setvalue{\e!stop #1}{\dostoptyping {#1}}% \presettyping[#1][#2]} -\def\definetyping +\unexpanded\def\definetyping {\dodoubleempty\dodefinetyping} %D We can use some core color commands. These are faster than @@ -705,7 +776,7 @@ %D line basis. %D %D \starttyping -%D \def\setupverbatimcolor% +%D \unexpanded\def\setupverbatimcolor% %D {\edef\prettypalet{\prettyidentifier\typingparameter\c!palet}% %D \def\beginofpretty[##1]{\startcolormode{\prettypalet:##1}}% %D \def\endofpretty {\stopcolormode}} @@ -720,10 +791,7 @@ \def\normalstopverbatimcolor {\stopcolor} \def\normalverbatimcolor {\getvalue{\typingparameter\c!color}}% command ! -\def\ignorebeginofpretty [#1]{} -\def\ignoreendofpretty {} - -\def\setupnormalprettyverbatim +\unexpanded\def\setupnormalprettyverbatim {\edef\prettypalet{\prettyidentifier\prettypalet}% \let\beginofpretty \normalbeginofpretty \let\endofpretty \normalendofpretty @@ -731,7 +799,7 @@ \let\stopverbatimcolor \normalstopverbatimcolor \let\verbatimcolor \normalverbatimcolor} -\def\setupignoreprettyverbatim +\unexpanded\def\setupignoreprettyverbatim {\let\prettypalet \empty \let\beginofpretty \ignorebeginofpretty \let\endofpretty \ignoreendofpretty @@ -739,7 +807,7 @@ \let\stopverbatimcolor \normalstopverbatimcolor \let\verbatimcolor \normalverbatimcolor} -\def\setupverbatimcolor +\unexpanded\def\setupverbatimcolor {\edef\prettypalet{\typingparameter\c!palet}% \ifx\prettypalet\empty \setupignoreprettyverbatim @@ -799,33 +867,28 @@ \fi\fi} \def\dosetuptypelinenumbering#1% fuzzy - {\ifcsname\currenttypingclass\currenttyping\c!start\endcsname \else - \setuptyping[\currenttyping][\c!start=1,\c!stop=,\c!step=1,\c!nlines=]% - \fi - \setuptyping[\currenttyping][#1]% + {%\ifcsname\currenttypingclass\currenttyping\c!start\endcsname \else + % \setuptyping[\currenttyping][\c!start=1,\c!stop=,\c!step=1,\c!continue=\v!no,\c!nlines=]% + %\fi + \doifassignmentelse{#1}{\setuptyping[\currenttyping][#1]}\donothing \doifelse{\typingparameter\c!numbering}\v!file {% kind of special: filters lines ! - \setuplinenumbering[\c!method=\v!file]% + \setuplinenumbering[\currenttyping][\c!method=\v!file]% \donetrue} {\doifelse{\typingparameter\c!numbering}\v!line - {% \setuplinenumbering defaults start/step to 1/1, so we need - \doifinsetelse\v!continue{#1,\typingparameter\c!start} - {\scratchcounter0\typingparameter\c!n - \setxtypingparameter\c!start{\ifnum\scratchcounter=0 1\else\number\scratchcounter\fi}}% - {\doifnothing{\typingparameter\c!start}{\settypingparameter\c!start{1}}}% - \doifnothing{\typingparameter\c!step}{\settypingparameter\c!step{1}}% - \setuplinenumbering - [\c!method=\v!type, - \c!start=\typingparameter\c!start, - \c!stop=\typingparameter\c!stop, - \c!step=\typingparameter\c!step]% + {\doifinset\v!continue{#1}{\setuptyping[\currenttyping][\c!continue=\v!yes]}% fails: \settypingparameter\c!continue{\v!yes} \donetrue} {\donefalse}}% \ifdone - \ifx\startlinenumbering\undefined \let\startlinenumbering\relax \fi - \ifx\stoplinenumbering \undefined \let\stoplinenumbering \relax \fi - \def\beginofverbatimlines{\startlinenumbering}% - \def\endofverbatimlines {\stoplinenumbering\setxtypingparameter\c!n{\number\linenumber}}% + \edef\beginofverbatimlines{\noexpand\startlinenumbering + [\currenttyping]% + [\c!continue=\typingparameter\c!continue, + \c!method=\v!type, + \c!start=\typingparameter\c!start, + \c!stop=\typingparameter\c!stop, % ? + \c!step=\typingparameter\c!step]% + }% + \def\endofverbatimlines{\stoplinenumbering}% \fi} \def\reporttypingerror#1% temp hack @@ -880,7 +943,8 @@ {\doiflocfileelse{#1} {\firstoftwoarguments} {\doifinputfileelse{#1} - {\def\readfilename{\pathplusfile\filepath{#1}}\firstoftwoarguments} % messy, looks wrong too +% {\def\readfilename{\pathplusfile\filepath{#1}}\firstoftwoarguments} % messy, looks wrong too + {\def\readfilename{#1}\firstoftwoarguments} % messy, looks wrong too {\secondoftwoarguments}}} \def\dodotypefile[#1][#2]#3% @@ -930,14 +994,16 @@ \c!evenmargin=\!!zeropoint, \c!oddmargin=\!!zeropoint, \c!blank=\v!line, - \c!escape=/, % beware \string\ , should also be accepted + \c!escape=, % yes | no | START,STOP BTEX,ETEX \c!numbering=\v!no, \c!lines=, + \c!range=, \c!empty=, \c!start=1, \c!stop=, \c!step=1, \c!continue=, + \c!strip=\v!no, % auto or number \c!nlines=] \definetyping[\v!typing] |