diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-ver.tex')
-rw-r--r-- | Master/texmf-dist/tex/context/base/core-ver.tex | 940 |
1 files changed, 278 insertions, 662 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-ver.tex b/Master/texmf-dist/tex/context/base/core-ver.tex index 5713e0cb36d..8623dffef51 100644 --- a/Master/texmf-dist/tex/context/base/core-ver.tex +++ b/Master/texmf-dist/tex/context/base/core-ver.tex @@ -55,6 +55,10 @@ \unprotect +\ifx\startlinenumbering\undefined \let\startlinenumbering\relax \fi +\ifx\stoplinenumbering \undefined \let\stoplinenumbering\relax \fi +\ifx\setuplinenumbering\undefined \def\setuplinenumbering[#1]{} \fi + % \type{ <crlf> char} geeft bagger %D We are going to embed the general verbatim support macros in @@ -63,6 +67,18 @@ %D are hooked into the support macros via the \type{\obey} %D macros. +\newif\ifslantedtypeactivated +\newif\ifslantedtypepermitted + +\def\switchslantedtype + {\ifslantedtypepermitted + \ifslantedtypeactivated + \slantedtypeactivatedfalse\tttf + \else + \slantedtypeactivatedtrue\ttsl + \fi + \fi} + \newprettytrue % movet to here from cont-sys.tex \def\prettyidentifier {TEX} @@ -72,71 +88,19 @@ {\dodoubleargument\doinstallprettytype} \def\doinstallprettytype[#1][#2]% map #1 onto #2 - {\uppercasestring#1\to\asciiA - \uppercasestring#2\to\asciiB - \setevalue{\??ty\??ty\asciiA}{\asciiB}} + {\uppercasestring#1\to\asciia + \uppercasestring#2\to\asciib + \setevalue{\??ty\??ty\asciia}{\asciib}} \def\setupprettiesintype#1% {\uppercasestring#1\to\ascii - \edef\prettyidentifier - {\ifundefined{\??ty\??ty\ascii}TEX% - \else\getvalue{\??ty\??ty\ascii}\fi}% - \doifundefined{setuppretty\prettyidentifier type}% - {\bgroup - \setbox0\hbox % get rid of spaces when in-line \newpretty loading - {\restorecatcodes % also needed when loading during \newpretty - \startreadingfile % restore < and > if needed - \lowercasestring verb-\prettyidentifier.tex\to\filename - \readsysfile\filename\donothing\donothing - \stopreadingfile}% - \egroup}% - \doifdefinedelse{setuppretty\prettyidentifier type}% - {\let\uncatcodecharacters\uncatcodeallcharacters % ugly, should be switch - \def\setupprettytype{\getvalue{setuppretty\prettyidentifier type}}} - {\let\setupprettytype\relax}} - -\installprettytype [RAW] [RAW] - -\installprettytype [TEX] [TEX] - -\installprettytype [PERL] [PL] -\installprettytype [PL] [PL] -\installprettytype [PM] [PL] - -\installprettytype [METAPOST] [MP] -\installprettytype [METAFONT] [MP] -\installprettytype [MP] [MP] -\installprettytype [MF] [MP] - -\installprettytype [JAVASCRIPT] [JS] -\installprettytype [JAVA] [JV] -\installprettytype [JS] [JS] -\installprettytype [JV] [JV] + \edef\prettyidentifier{\executeifdefined{\??ty\??ty\ascii}{TEX}}% + \mksetupprettiesintype} -\installprettytype [SQL] [SQL] - -\installprettytype [PASCAL] [PAS] -\installprettytype [PAS] [PAS] -\installprettytype [MODULA] [PAS] -\installprettytype [MOD] [PAS] - -\installprettytype [EIFFEL] [EIF] -\installprettytype [EIF] [EIF] -\installprettytype [E] [EIF] - -\installprettytype [XML] [XML] - -\installnewpretty M {\setupprettiesintype {MP}\setupprettytype} -\installnewpretty P {\setupprettiesintype {PL}\setupprettytype} -\installnewpretty T {\setupprettiesintype{TEX}\setupprettytype} -\installnewpretty J {\setupprettiesintype {JV}\setupprettytype} -\installnewpretty S {\setupprettiesintype{SQL}\setupprettytype} -\installnewpretty W {\setupprettiesintype{PAS}\setupprettytype} % Wirth -\installnewpretty I {\setupprettiesintype{EIF}\setupprettytype} % E taken -\installnewpretty X {\setupprettiesintype{XML}\setupprettytype} +\def\setupprettytype{\mksetupprettytype} \def\setupcommonverbatim - {\eightbitcharactersfalse % obey regime / encoding + {\recatcodeuppercharactersfalse % obey regime / encoding % \def\prettyidentifier{TEX}% % @@ -190,6 +154,22 @@ \def\verbatimfont{\redoconvertfont\dosetfontattribute{\currenttypingclass\currenttyping}\c!style\normalnoligatures\font}% \setupverbatimcolor} +% BEWARE: the noligatures will globally change the verbatim font's behaviour + +% test case: +% +% \definetype[typeTEX][option=tex] +% +% \typeTEX|\example---oeps|. this---ligates---again. +% \typeTEX{\example---oeps}. this---ligates---again. +% \type {\example---oeps}. this---ligates---again. + +\def\setupcommandsintype{\mksetupcommandsintype} +\def\setupslantedtype {\slantedtypepermittedtrue\mksetupslantedtype} + +\ifx\setupprettytype \undefined \let\setupprettytype \relax \fi +\ifx\setupslantedtype \undefined \let\setupslantedtype \relax \fi +\ifx\setupgroupedtype \undefined \let\setupgroupedtype \relax \fi \ifx\normalnoligatures\undefined \let\normalnoligatures\gobbleoneargument \fi %D The verbatim commands have a rather long and turbulent @@ -232,9 +212,9 @@ %D \macros %D {type} %D -%D We define \type{\type} as a protected command. First we -%D set the catcodes of \type{<} and \type{>} and then we start -%D looking ahead. +%D We define \type{\type} as a protected command. This command +%D has several invocations: grouped, wirt boundary characters, +%D and with font switches. % \starttyping % normal: \par \type{xx<<..xx..<<xx <<xx>> >>..>>xx} \par \type<<....>> \par \type<<..<<xx>>..>> \par @@ -246,261 +226,14 @@ % none: \par \type{xx<<..xx..<<xx <<xx>> >>..>>xx} \par \type<<....>> \par \type<<..<<xx>>..>> \par % \stoptyping -\unexpanded\def\type - {\dotype\empty} - -\def\dotype#1% - {\bgroup - \strut % new, enables leading space in \type { abc } at par start - \let\currenttypingclass\??ty - \edef\currenttyping{#1}% - \catcode`\<=\@@other - \catcode`\>=\@@other - \futurelet\next\dodotype} - -%D Next we distinguish between the three alternatives and call -%D for the appropriate macros. - -\def\dodotypeA - {\initializetype - \initializetypegrouping - \verbatimcolor - \afterassignment\protectfirsttype\let\next=} - -\def\dodotypeB - {\initializetype - \setupnotypegrouping - \verbatimcolor - \let\next=} - -\def\dodotypeC<#1% - {\initializetype - \verbatimcolor - \if#1<% - \@EA\setupalternativetypegrouping - \else - \@EA#1% - \fi} - -\def\dodotypeD#1% - {\initializetype - \verbatimcolor - \catcode`#1=\@@endgroup} - -\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} - -% Verbatim does not work when passed as an argument, so here is a -% workaround. Beware, spaces are introduced after a \type {\csname}. - -\chardef\recodeverbatimmode\zerocount % 0=nothing 1=rescan 2=autorescan - -% \appendtoks \chardef\recodeverbatimmode\plustwo \to \everytabulate -% \appendtoks \chardef\recodeverbatimmode\plustwo \to \everytable - -\def\dodotypeA - {\initializetype - \initializetypegrouping - \verbatimcolor - \ifcase\recodeverbatimmode - \@EA\dodotypeAA - \or - \@EA\dodotypeAB - \or - \ifnum\catcode`\{=\@@active - \@EAEAEA\dodotypeAB - \else - \@EAEAEA\dodotypeAA - \fi - \else - \@EA\dodotypeAA - \fi} - -\def\dodotypeAA - {\afterassignment\protectfirsttype\let\next=} - -\def\dodotypeAB - {\bgroup - \catcode`\}=\@@endgroup - \catcode`\{=\@@begingroup - \afterassignment\redotypeAB\global\globalscratchtoks} - -\def\redotypeAB - {\egroup - \expandafter\convertargument\the\globalscratchtoks\to\ascii - \ifx\scantokens\undefined\ascii\else\everyeof{\hskip-\spaceskip}\scantokens\expandafter{\ascii}\fi - \egroup} - -\bgroup -\catcode`\[=\@@begingroup -\catcode`\]=\@@endgroup -\catcode`\{=\@@active -\catcode`\}=\@@active -\gdef\initializetypegrouping - [\ifnum\catcode`\{=\@@active - \let\normalactivebgroup{% - \let\normalactiveegroup}% - \else - \catcode`\{=\@@active - \catcode`\}=\@@active - \let\normalactivebgroup\leftargument - \let\normalactiveegroup\rightargument - \fi - \def\activeleftargument - [\bgroup - \catcode`\}=\@@active - \let}\activerightargument - \normalactivebgroup]% - \def\activerightargument - [\normalactiveegroup - \egroup]% - \let{=\activeleftargument - % not \let}=\egroup, otherwise things go wrong in alignments (???) - \catcode`\}=\@@endgroup] -\egroup - -\bgroup -\catcode`\<=\@@active -\catcode`\>=\@@active -\gdef\setupalternativetypegrouping - {\catcode`\<=\@@active - \catcode`\>=\@@active - \def\doless - {\ifx<\next - \def\next - {\bgroup\switchslantedtype - \let\next=}% - \else - \let\next\lesscharacter - \fi - \next}% - \def\domore - {\ifx>\next - \def\next - {\egroup - \let\next=}% - \else - \let\next\morecharacter - \fi - \next}% - \def<{\futurelet\next\doless}% - \def>{\futurelet\next\domore}} -\egroup - -\def\setupnotypegrouping - {\catcode`\<=\@@begingroup - \catcode`\>=\@@endgroup} - %D When writing the manual to \CONTEXT\ and documenting this %D source we needed to typeset \type{<<} and \type{>>}. Because %D we wanted to do this in the natural way, we've adapted the -%D original definition a bit. We still show the original -%D because we think it's shows a bit better what we are -%D doing. -%D -%D \starttyping -%D \bgroup -%D \catcode`\<=\@@active -%D \catcode`\>=\@@active -%D \gdef\setupgroupedtype% -%D {\catcode`\<=\@@active -%D \catcode`\>=\@@active -%D \def<% -%D {\def\do% -%D {\ifx\next<% -%D \def\next{\bgroup\switchslantedtype\let\next=}% -%D \else -%D \let\next\lesscharacter -%D \fi -%D \next}% -%D \futurelet\next\do}% -%D \def>% -%D {\def\do% -%D {\ifx\next>% -%D \def\next{\egroup\let\next=}% -%D \else -%D \let\next\morecharacter -%D \fi -%D \next}% -%D \futurelet\next\do}} -%D \egroup -%D \stoptyping -%D -%D The final implementation looks a bit further and treats the -%D lone \type{<<} and \type{>>} a bit different. The \type -%D {\null} prevents ligatures, which unfortunately turn up -%D in Lucida fonts. - -\def\doenterdoublelesstype - {\ifx\next\egroup - \lesscharacter\null\lesscharacter - \else - \bgroup\switchslantedtype - \let\doenterdoublemoretype\egroup - \fi} - -\def\doenterdoublemoretype - {\def\doenterdoubletype - {\ifx\next\egroup - \morecharacter\null\morecharacter - \fi}} - -\bgroup -\catcode`\<=\@@active -\catcode`\>=\@@active -\gdef\setupgroupedtype - {\catcode`\<=\@@active - \catcode`\>=\@@active - \def\doless - {\ifx<\next - \def\next - {\def\enterdoubletype{\futurelet\next\doenterdoublelesstype}% - \afterassignment\enterdoubletype - \let\next=}% - \else - \let\next\lesscharacter - \fi - \next}% - \def\domore - {\ifx>\next - \def\next - {\def\enterdoubletype{\futurelet\next\doenterdoublemoretype}% - \afterassignment\enterdoubletype - \let\next=}% - \else - \let\next\morecharacter - \fi - \next}% - \def<{\futurelet\next\doless}% - \def>{\futurelet\next\domore}} -\egroup - -\newif\ifslantedtypeactivated -\newif\ifslantedtypepermitted - -\def\switchslantedtype - {\ifslantedtypepermitted - \ifslantedtypeactivated - \slantedtypeactivatedfalse\tttf - \else - \slantedtypeactivatedtrue\ttsl - \fi - \fi} - -\def\setupcommandsintype% can also be \string\ - {\setupgroupedtype - \edef\\{\typingparameter\c!escape}% - \letvalue{\\}=\\% for instance \/=/ - \@EA\catcode\@EA`\\=\@@escape - \def\BTEX##1\ETEX##2% ##2 gobbles active space - {\naturaltextext##1\unskip\relax}} +%D original definition a bit. This implementation went through +%D several live cycles. The final implementation looks a bit +%D further and treats the lone \type{<<} and \type{>>} a bit +%D different. The \type {\null} prevents ligatures, which +%D unfortunately turn up in Lucida fonts. %D The following lines show what happens when we set %D \type {option=commands}. @@ -520,58 +253,9 @@ %D %D \typebuffer -\def\setupslantedtype - {\setupgroupedtype - \slantedtypepermittedtrue} - -\let\protectedfirsttype\string % \relax for special cases - -% \bgroup -% \catcode`\<=\active -% \catcode`\>=\active -% \gdef\doprotectfirsttype -% {\ifx\next<% -% \let\next\relax -% \else\ifx\next\bgroup -% \let\next\relax -% \else\ifx\next\egroup % takes care of \type{} -% \let\next\relax -% \else\ifx\next\activeleftargument -% \let\next\relax -% \else -% \let\next\protectedfirsttype -% \fi\fi\fi\fi -% \next} -% \egroup -% -% \def\protectfirsttype -% {\futurelet\next\doprotectfirsttype} -% -% The next one is safe for: -% -% \def\xx#1{\type{#1}} \xx{\ifx} - -\bgroup -\catcode`\<=\active -\catcode`\>=\active -\gdef\doprotectfirsttype - {\normalifx\next<% - \endrobusttest \let\next\relax - \normalelse\normalifx\next\bgroup - \endrobusttest \let\next\relax - \normalelse\normalifx\next\egroup % takes care of \type{} - \endrobusttest \let\next\relax - \normalelse\normalifx\next\activeleftargument - \endrobusttest \let\next\relax - \normalelse - \endrobusttest \let\next\protectedfirsttype - \normalfi\normalfi\normalfi\normalfi - \next} -\egroup - -\def\protectfirsttype - {\beginrobusttest - \futurelet\next\doprotectfirsttype} +\unexpanded\def\type{\mktype\empty} + +\let\mktype\gobbleoneargument %D The neccessary initializations are done by calling %D \type{\initializetype} which in return calls for the support @@ -597,17 +281,6 @@ \getparameters[\??ty][#1]% \fi} -%D The setups for inline verbatim default to: - -\setuptype - [ \c!space=\v!off, - \c!color=, - \c!style=\tt\tf, % \tttf gives problems with {\tx \type...} - \c!page=\v!no, - \c!tab=\v!yes, - \c!palet=colorpretty, - \c!option=\v!normal] - %D \macros %D {typ,obeyhyphens,obeybreakpoints} %D @@ -618,43 +291,20 @@ %D works all right, but a decent hyphenation support of %D \type{\tt} text will be implemented soon. -% \def\obeyhyphens -% {\def\obeyedspace{\hskip\spaceskip}% -% \edef\savedfont{\the\font}% -% \ttsl\hyphenchar\font45 -% \tttf\hyphenchar\font45 -% \savedfont -% \spaceskip.5em\!!plus.25em\!!minus.25em\relax} -% -% \def\obeybreakpoints -% {\def\obeyedspace{\hskip\spaceskip}% -% \spaceskip.5em -% \veryraggedright} - \def\obeyhyphens - {\def\obeyedspace {\hskip\spaceskip}% + {\def\obeyedspace {\hskip\interwordspace}% better than spaceskip \def\controlspace{\hskip\zeropoint\hbox{\char32}\hskip\zeropoint}% - \spaceskip.25em\!!plus.5em\!!minus.25em\relax} + \spaceskip.25em\relax} % hm a bit of stretch ! \def\obeybreakpoints {\ignorehyphens \veryraggedright} \def\ignorehyphens - {\def\obeyedspace {\null\hskip\spaceskip\null}% + {\def\obeyedspace {\null\hskip\interwordspace\null}% better than spaceskip \def\controlspace{\null\hskip\zeropoint\hbox{\char32}\hskip\zeropoint\null}% \spaceskip.5em\relax} -%\unexpanded\def\typ -% {\bgroup -% \obeyhyphens -% \futurelet\next\dotype} - -%\unexpanded\def\typ -% {\bgroup -% \obeyhyphens -% \futurelet\next\dodotype} - \unexpanded\def\typ {\bgroup \let\@@tylines\v!hyphenated @@ -693,36 +343,6 @@ %D \unexpanded\def\mat{\dospecialtype\$\$} %D \unexpanded\def\dis{\dospecialtype{\$\$}{\$\$}} %D \stoptyping -%D -% %D For sometime we used the better but less readable is -% %D alternative -% %D -% %D \starttyping -% %D \def\doprocessgroup#1#2#3% -% %D {\bgroup -% %D #1% -% %D \def\doprocessgroup% -% %D {\def\doprocessgroup{#3\egroup}% -% %D \bgroup -% %D \aftergroup\doprocessgroup -% %D #2}% -% %D \afterassignment\doprocessgroup -% %D \let\next=} -% %D -% %D \def\setgroupedtype% -% %D {\initializetype -% %D \catcode`\{=\@@begingroup -% %D \catcode`\}=\@@endgroup} -% %D -% %D \unexpanded\def\tex{\doprocessgroup\setgroupedtype\texescape\relax} -% %D \unexpanded\def\arg{\doprocessgroup\setgroupedtype\leftargument\rightargument} -% %D \unexpanded\def\mat{\doprocessgroup\setgroupedtype\$\$} -% %D \unexpanded\def\dis{\doprocessgroup\setgroupedtype{\$\$}{\$\$}} -% %D \stoptyping -% %D -%D -%D But since \type{\groupedcommand} became available, we use -%D however \def\setgroupedtype {\let\currenttypingclass\??ty @@ -804,18 +424,6 @@ %D indirect way. As we will see, they are a specific case of a %D more general mechanism. -% formal version -% -% \def\dostarttyping#1% -% {\let\currenttypingclass\??tp -% \edef\currenttyping{#1}% -% \typingparameter\c!before -% \startpacked % includes \bgroup -% \dosetuptypelinenumbering{}% -% \initializetyping -% \startverbatimcolor -% \expandafter\processdisplayverbatim\expandafter{\s!stop#1}} - % we need this hack because otherwise verbatim skips % the first line (everything after the initial command) @@ -842,9 +450,9 @@ \dosetuptypelinenumbering{#1}% \initializetyping \startverbatimcolor - \expanded{\processdisplayverbatim{\s!stop\currenttyping}}} + \expanded{\mktypeblockverbatim{\s!start\currenttyping}{\s!stop\currenttyping}}} -\def\dostoptyping#1% +\def\dostoptyping#1% hm, currenttyping {\stopverbatimcolor \stoppacked % includes \egroup \typingparameter\c!after @@ -884,20 +492,6 @@ %D argument is given, the values apply to both the standard %D command \type{\starttyping} and \type{\typefile}. -%\indirect\def\setuptyping\dodoubleempty[#1][#2]% -% {\iffirstargument -% \getparameters[\??tp#1][#2]% -% \else -% \getparameters[\??tp][#1]% -% \fi} -% -%\doubleemptied\def\setuptyping[#1][#2]% -% {\iffirstargument -% \getparameters[\??tp#1][#2]% -% \else -% \getparameters[\??tp][#1]% -% \fi} - \def\dosetuptyping[#1][#2]% {\ifsecondargument \getparameters[\??tp#1][#2]% @@ -908,36 +502,6 @@ \def\setuptyping {\dodoubleempty\dosetuptyping} -%D The setups for display verbatim and file verbatim are -%D shared. One can adapt the extra defined typing environments, -%D but they also default to the values below. Watch the -%D alternative escape character. - -\setuptyping - [ \c!before=\blank, - \c!after=\blank, - \c!bodyfont=, - \c!color=, - \c!space=\v!off, - \c!page=\v!no, - \c!tab=\s!ascii, - \c!option=\v!none, - \c!palet=colorpretty, - \c!text=\v!no, - \c!style=\tttf, - \c!icommand=\ttsl, - \c!vcommand=, - \c!ccommand=\tttf, - \c!indentnext=\v!yes, - \c!margin=\!!zeropoint, - \c!evenmargin=\!!zeropoint, - \c!oddmargin=\!!zeropoint, - \c!blank=\v!line, - \c!escape=/, % beware \string\ , should also be accepted - \c!numbering=\v!no, - \c!lines=, - \c!empty=] - %D \macros %D {definetype} %D @@ -948,10 +512,7 @@ {\dodoubleempty\dodefinetype} \def\dodefinetype[#1][#2]% - {\unexpanded\setvalue{#1}{\dotype{#1}}% -% \copyparameters % maybe no longer needed, implicit inheritance now -% [\??ty#1][\??ty] -% [\c!space,\c!palet,\c!color,\c!style,\c!page,\c!tab,\c!option]% + {\unexpanded\setvalue{#1}{\mktype{#1}}% \getparameters[\??ty#1][#2]} %D \macros @@ -972,12 +533,8 @@ %D The definitions default to the standard typing values. \def\presettyping[#1][#2]% - {\copyparameters - [\??tp#1][\??tp] - [\c!color,\c!style]% - \getparameters - [\??tp#1] - [#2]} + {\copyparameters[\??tp#1][\??tp][\c!color,\c!style]% + \getparameters [\??tp#1][#2]} \def\dodefinetyping[#1][#2]% {\setvalue{\e!start#1}{\dostarttyping{#1}}% @@ -987,76 +544,6 @@ \def\definetyping {\dodoubleempty\dodefinetyping} -\definetyping[\v!typing] - -\definetyping[RAW] [\c!option=RAW] -\definetyping[MP] [\c!option=MP] -\definetyping[PL] [\c!option=PL] -\definetyping[PM] [\c!option=PL] -\definetyping[JS] [\c!option=JS] -\definetyping[JV] [\c!option=JV] -\definetyping[SQL] [\c!option=SQL] -\definetyping[TEX] [\c!option=TEX] -\definetyping[PAS] [\c!option=PAS] -\definetyping[PASCAL][\c!option=PAS] -\definetyping[MOD] [\c!option=PAS] -\definetyping[MODULA][\c!option=PAS] -\definetyping[DELPHI][\c!option=PAS] -\definetyping[EIFFEL][\c!option=EIF] -\definetyping[XML] [\c!option=XML] - -%D We use the \CONTEXT\ color system for switching to and from -%D color mode. We can always redefine these colors afterwards. - -\definecolor [colorprettyone] [r=.9, g=.0, b=.0] % red -\definecolor [colorprettytwo] [r=.0, g=.8, b=.0] % green -\definecolor [colorprettythree] [r=.0, g=.0, b=.9] % blue -\definecolor [colorprettyfour] [r=.8, g=.8, b=.6] % yellow - -\definecolor [grayprettyone] [s=.30] -\definecolor [grayprettytwo] [s=.45] -\definecolor [grayprettythree] [s=.60] -\definecolor [grayprettyfour] [s=.75] - -\definepalet - [colorpretty] - [ prettyone=colorprettyone, - prettytwo=colorprettytwo, - prettythree=colorprettythree, - prettyfour=colorprettyfour] - -\definepalet - [graypretty] - [ prettyone=grayprettyone, - prettytwo=grayprettytwo, - prettythree=grayprettythree, - prettyfour=grayprettyfour] - -% ---> naar verb-* ? of predefine als undefined? - -\definepalet [TEXcolorpretty] [colorpretty] -\definepalet [TEXgraypretty] [graypretty] -\definepalet [PLcolorpretty] [colorpretty] -\definepalet [PLgraypretty] [graypretty] -\definepalet [PMcolorpretty] [colorpretty] -\definepalet [PMgraypretty] [graypretty] -\definepalet [MPcolorpretty] [colorpretty] -\definepalet [MPgraypretty] [graypretty] -\definepalet [JVcolorpretty] [colorpretty] -\definepalet [JVgraypretty] [graypretty] -\definepalet [JScolorpretty] [colorpretty] -\definepalet [JSgraypretty] [graypretty] -\definepalet [SQLcolorpretty] [colorpretty] -\definepalet [SQLgraypretty] [graypretty] -\definepalet [PAScolorpretty] [colorpretty] -\definepalet [PASgraypretty] [graypretty] -\definepalet [EIFcolorpretty] [colorpretty] -\definepalet [EIFgraypretty] [graypretty] -\definepalet [XMLcolorpretty] [colorpretty] -\definepalet [XMLgraypretty] [graypretty] - -% Some real in-depth knowlegde of palets: `palet:color' it is! - %D We can use some core color commands. These are faster than %D the standard color switching ones and work ok on a line by %D line basis. @@ -1214,8 +701,6 @@ % \typefile[start=4,step=3]{zapf} % \typefile{zapf} -\presettyping[\v!file][] - \def\typefile {\dodoubleempty\dotypefile} @@ -1230,31 +715,6 @@ \dodotypefile[\v!file][]{#3}% \fi\fi} -% \def\dosetuptypelinenumbering#1% fuzzy -% {\doifundefined{\currenttypingclass\currenttyping\c!start} -% {\setuptyping[\currenttyping][\c!start=1,\c!stop=,\c!step=1,\c!nlines=,#1]}% -% \doifelse{\typingparameter\c!numbering}\v!file -% {\setuplinenumbering[\c!method=\v!file]% -% \donetrue} -% {\doifelse{\typingparameter\c!numbering}\v!line -% {% \setuplinenumbering defaults start/step to 1/1, so we need -% \doifnothing{\typingparameter\c!start }{\settypingparameter\c!start {1}}% -% \doifnothing{\typingparameter\c!step }{\settypingparameter\c!step {1}}% -% \doifnothing{\typingparameter\c!continue}{\settypingparameter\c!continue{}}% -% \setuplinenumbering -% [\c!method=\v!type, -% \c!continue=\typingparameter\c!continue, -% \c!start=\typingparameter\c!start, -% \c!step=\typingparameter\c!step]% -% \donetrue} -% {\donefalse}}% -% \ifdone -% \ifx\startlinenumbering\undefined \let\startlinenumbering\relax \fi -% \ifx\stoplinenumbering \undefined \let\stoplinenumbering \relax \fi -% \def\beginofverbatimlines{\startlinenumbering}% -% \def\endofverbatimlines {\stoplinenumbering }% -% \fi} - \def\dosetuptypelinenumbering#1% fuzzy {\doifundefined{\currenttypingclass\currenttyping\c!start} {\setuptyping[\currenttyping][\c!start=1,\c!stop=,\c!step=1,\c!nlines=]}% @@ -1284,78 +744,63 @@ \def\endofverbatimlines {\stoplinenumbering\setxtypingparameter\c!n{\number\linenumber}}% \fi} -% \setuptyping % not needed -% [\v!file] -% [\c!start=1, -% \c!stop=, -% \c!step=1, -% \c!continue=, -% \c!nlines=] - -\setuptyping - [\c!start=1, - \c!stop=, - \c!step=1, - \c!continue=, - \c!nlines=] +\def\reporttypingerror#1% temp hack + {\blank + \dontleavehmode\hbox\bgroup + \expanded{\convertargument#1}\to\ascii + \tttf[\makemessage\m!verbatims1\ascii]% + \showmessage\m!verbatims1\ascii + \egroup + \blank} -\def\dodotypefile[#1][#2]#3% +\def\dosometyping#1#2#3#4#5% {\bgroup \let\currenttypingclass\??tp \edef\currenttyping{#1}% \typingparameter\c!before - \doiflocfileelse{#3} - \donetrue % sets \readfilename - {\doifinputfileelse{#3} - {\donetrue - \def\readfilename{\pathplusfile\filepath{#3}}} - \donefalse}% - \ifdone - \startpacked % includes \bgroup - \dosetuptypelinenumbering{#2}% - \doifinset{\typingparameter\c!option}{\v!commands,\v!slanted,\v!normal} - {\setuptyping[#1][\c!option=\v!none]}% - \doif{\typingparameter\c!option}\v!color - {\expandafter\aftersplitstring#3\at.\to\prettyidentifier - \settypingparameter\c!option{\prettyidentifier}}% - \initializetyping - \startverbatimcolor - \doifundefinedelse{\currenttypingclass#3\v!global\c!start} - {\scratchcounter\zerocount} - {\scratchcounter\getvalue{\currenttypingclass#3\v!global\c!start}}% - \advance\scratchcounter\plusone - \setxvalue{\currenttypingclass#3\v!global\c!start}{\the\scratchcounter}% - \doifelsenothing{\typingparameter\c!start} - {\processfileverbatim\readfilename} - {\doif{\typingparameter\c!start}\v!continue - {\setevalue{\currenttypingclass#1\c!start}% - {\getvalue{\currenttypingclass#3\v!global\c!start}}}% - \doifelsenothing{\typingparameter\c!stop} - {\doifelsenothing{\typingparameter\c!nlines} - {\processfileverbatim\readfilename} - {\scratchcounter\typingparameter\c!start - \advance\scratchcounter\typingparameter\c!nlines - \advance\scratchcounter\minusone - \setxvalue{\currenttypingclass#3\v!global\c!start}% - {\the\scratchcounter}% - \processfilelinesverbatim\readfilename - {\typingparameter\c!start} - {\getvalue{\currenttypingclass#3\v!global\c!start}}}}% - {\processfilelinesverbatim\readfilename - {\typingparameter\c!start} - {\typingparameter\c!stop }}}% - \stopverbatimcolor - \stoppacked % includes \egroup - \else - \ifmmode\hbox\fi\bgroup - \expanded{\convertargument#3}\to\ascii - \tttf[\makemessage\m!verbatims1\ascii]% - \showmessage\m!verbatims1\ascii - \egroup - \fi + \startpacked % includes \bgroup + \dosetuptypelinenumbering{#2}% + \doifinset{\typingparameter\c!option}{\v!commands,\v!slanted,\v!normal} + {\setuptyping[#1][\c!option=\v!none]}% + \doif{\typingparameter\c!option}\v!color + {\expandafter\aftersplitstring#3\at.\to\prettyidentifier + \settypingparameter\c!option{\prettyidentifier}}% + \initializetyping + \startverbatimcolor + \doifundefinedelse{\currenttypingclass#3\v!global\c!start} + {\scratchcounter\zerocount} + {\scratchcounter\getvalue{\currenttypingclass#3\v!global\c!start}}% + \advance\scratchcounter\plusone + \setxvalue{\currenttypingclass#3\v!global\c!start}{\the\scratchcounter}% + \doifelsenothing{\typingparameter\c!start} + {#4} + {\doif{\typingparameter\c!start}\v!continue + {\setevalue{\currenttypingclass#1\c!start}% + {\getvalue{\currenttypingclass#3\v!global\c!start}}}% + \doifelsenothing{\typingparameter\c!stop} + {\doifelsenothing{\typingparameter\c!nlines} + {#4} + {\setxvalue{\currenttypingclass#3\v!global\c!start}% + {\the\numexpr\typingparameter\c!start+\typingparameter\c!nlines+\minusone\relax}% + #5{\typingparameter\c!start}{\getvalue{\currenttypingclass#3\v!global\c!start}}}}% + {#5{\typingparameter\c!start}{\typingparameter\c!stop}}}% + \stopverbatimcolor + \stoppacked \typingparameter\c!after \egroup} +\def\doifelsetypingfile#1% sets \readfilename + {\doiflocfileelse{#1} + {\firstoftwoarguments} + {\doifinputfileelse{#1} + {\def\readfilename{\pathplusfile\filepath{#1}}\firstoftwoarguments} + {\secondoftwoarguments}}} + +\def\dodotypefile[#1][#2]#3% + {\doifelsetypingfile{#3} + {\dosometyping{#1}{#2}{#3}\mktypefileverbatim\mktypefilelinesverbatim} + {\reporttypingerror{#3}}} + %D \macros %D {filename} %D @@ -1378,4 +823,175 @@ \def\verbatim#1{\convertargument#1\to\ascii\ascii} +%D Plugins + +\loadmarkfile{core-ver} + +%D The setups for display verbatim and file verbatim are +%D shared. One can adapt the extra defined typing environments, +%D but they also default to the values below. Watch the +%D alternative escape character. + +\setuptyping + [ \c!before=\blank, + \c!after=\blank, + \c!bodyfont=, + \c!color=, + \c!space=\v!off, + \c!page=\v!no, + \c!tab=\s!ascii, + \c!option=\v!none, + \c!palet=colorpretty, + \c!text=\v!no, + \c!style=\tttf, + \c!icommand=\ttsl, + \c!vcommand=, + \c!ccommand=\tttf, + \c!indentnext=\v!yes, + \c!margin=\!!zeropoint, + \c!evenmargin=\!!zeropoint, + \c!oddmargin=\!!zeropoint, + \c!blank=\v!line, + \c!escape=/, % beware \string\ , should also be accepted + \c!numbering=\v!no, + \c!lines=, + \c!empty=, + \c!start=1, + \c!stop=, + \c!step=1, + \c!continue=, + \c!nlines=] + +\definetyping[\v!typing] + +\presettyping[\v!file][] + +% \setuptyping % not needed +% [\v!file] +% [\c!start=1, +% \c!stop=, +% \c!step=1, +% \c!continue=, +% \c!nlines=] + +%D The setups for inline verbatim default to: + +\setuptype + [ \c!space=\v!off, + \c!color=, + \c!style=\tt\tf, % \tttf gives problems with {\tx \type...} + \c!page=\v!no, + \c!tab=\v!yes, + \c!palet=colorpretty, + \c!option=\v!normal] + +\definetyping[RAW] [\c!option=RAW] +\definetyping[MP] [\c!option=MP] +\definetyping[PL] [\c!option=PL] +\definetyping[PM] [\c!option=PL] +\definetyping[JS] [\c!option=JS] +\definetyping[JV] [\c!option=JV] +\definetyping[SQL] [\c!option=SQL] +\definetyping[TEX] [\c!option=TEX] +\definetyping[PAS] [\c!option=PAS] +\definetyping[PASCAL][\c!option=PAS] +\definetyping[MOD] [\c!option=PAS] +\definetyping[MODULA][\c!option=PAS] +\definetyping[DELPHI][\c!option=PAS] +\definetyping[EIFFEL][\c!option=EIF] +\definetyping[XML] [\c!option=XML] +\definetyping[LUA] [\c!option=LUA] + +\installprettytype [RAW] [RAW] + +\installprettytype [TEX] [TEX] + +\installprettytype [PERL] [PL] +\installprettytype [PL] [PL] +\installprettytype [PM] [PL] + +\installprettytype [METAPOST] [MP] +\installprettytype [METAFONT] [MP] +\installprettytype [MP] [MP] +\installprettytype [MF] [MP] + +\installprettytype [JAVASCRIPT] [JS] +\installprettytype [JAVA] [JV] +\installprettytype [JS] [JS] +\installprettytype [JV] [JV] + +\installprettytype [SQL] [SQL] + +\installprettytype [PASCAL] [PAS] +\installprettytype [PAS] [PAS] +\installprettytype [MODULA] [PAS] +\installprettytype [MOD] [PAS] + +\installprettytype [EIFFEL] [EIF] +\installprettytype [EIF] [EIF] +\installprettytype [E] [EIF] + +\installprettytype [XML] [XML] + +\installprettytype [LUA] [LUA] + +\installnewpretty M {\setupprettiesintype {MP}\setupprettytype} +\installnewpretty P {\setupprettiesintype {PL}\setupprettytype} +\installnewpretty T {\setupprettiesintype{TEX}\setupprettytype} +\installnewpretty J {\setupprettiesintype {JV}\setupprettytype} +\installnewpretty S {\setupprettiesintype{SQL}\setupprettytype} +\installnewpretty W {\setupprettiesintype{PAS}\setupprettytype} % Wirth +\installnewpretty I {\setupprettiesintype{EIF}\setupprettytype} % E taken +\installnewpretty X {\setupprettiesintype{XML}\setupprettytype} + +%D We use the \CONTEXT\ color system for switching to and from +%D color mode. We can always redefine these colors afterwards. + +\definecolor [colorprettyone] [r=.9, g=.0, b=.0] % red +\definecolor [colorprettytwo] [r=.0, g=.8, b=.0] % green +\definecolor [colorprettythree] [r=.0, g=.0, b=.9] % blue +\definecolor [colorprettyfour] [r=.8, g=.8, b=.6] % yellow + +\definecolor [grayprettyone] [s=.30] +\definecolor [grayprettytwo] [s=.45] +\definecolor [grayprettythree] [s=.60] +\definecolor [grayprettyfour] [s=.75] + +\definepalet + [colorpretty] + [ prettyone=colorprettyone, + prettytwo=colorprettytwo, + prettythree=colorprettythree, + prettyfour=colorprettyfour] + +\definepalet + [graypretty] + [ prettyone=grayprettyone, + prettytwo=grayprettytwo, + prettythree=grayprettythree, + prettyfour=grayprettyfour] + +\definepalet [TEXcolorpretty] [colorpretty] +\definepalet [TEXgraypretty] [graypretty] +\definepalet [PLcolorpretty] [colorpretty] +\definepalet [PLgraypretty] [graypretty] +\definepalet [PMcolorpretty] [colorpretty] +\definepalet [PMgraypretty] [graypretty] +\definepalet [MPcolorpretty] [colorpretty] +\definepalet [MPgraypretty] [graypretty] +\definepalet [JVcolorpretty] [colorpretty] +\definepalet [JVgraypretty] [graypretty] +\definepalet [JScolorpretty] [colorpretty] +\definepalet [JSgraypretty] [graypretty] +\definepalet [SQLcolorpretty] [colorpretty] +\definepalet [SQLgraypretty] [graypretty] +\definepalet [PAScolorpretty] [colorpretty] +\definepalet [PASgraypretty] [graypretty] +\definepalet [EIFcolorpretty] [colorpretty] +\definepalet [EIFgraypretty] [graypretty] +\definepalet [XMLcolorpretty] [colorpretty] +\definepalet [XMLgraypretty] [graypretty] +\definepalet [LUAcolorpretty] [colorpretty] +\definepalet [LUAgraypretty] [graypretty] + \protect \endinput |