diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
commit | 15995e10bfc68edf79970c4ea4fbb6678566c46e (patch) | |
tree | 2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/core-sys.mkiv | |
parent | c9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff) |
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-sys.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/core-sys.mkiv | 369 |
1 files changed, 121 insertions, 248 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-sys.mkiv b/Master/texmf-dist/tex/context/base/core-sys.mkiv index f61cabec3d2..88e0ebf23f1 100644 --- a/Master/texmf-dist/tex/context/base/core-sys.mkiv +++ b/Master/texmf-dist/tex/context/base/core-sys.mkiv @@ -5,7 +5,7 @@ %D subtitle=System, %D author=Hans Hagen, %D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for @@ -21,7 +21,7 @@ %D Version checking: -\def\newcontextversion#1% +\unexpanded\def\newcontextversion#1% {\doifelse{#1}\contextversion {\let\newcontextversion\gobbleoneargument} {\writeline @@ -35,30 +35,26 @@ %D End of lines to the output. \TEX\ will map this onto the platform specific %D line ending. I hate this mess. -\edef\operatingsystem {\ctxwrite {os.platform}} +\edef\operatingsystem {\cldcontext{os.platform}} +\def \jobfilename {\cldcontext{environment.jobfilename or ""}} +\def \jobfilesuffix {\cldcontext{environment.jobfilesuffix or ""}} +\def \inputfilebarename{\cldcontext{environment.inputfilebarename or ""}} +\def \inputfilesuffix {\cldcontext{environment.inputfilesuffix or ""}} +\def \inputfilename {\cldcontext{environment.inputfilename or ""}} +\def \outputfilename {\cldcontext{environment.outputfilename or ""}} -\def \jobfilename {\ctxsprint{environment.jobfilename or ""}} -\def \jobfilesuffix {\ctxsprint{environment.jobfilesuffix or ""}} -\def \inputfilebarename{\ctxsprint{environment.inputfilebarename or ""}} -\def \inputfilesuffix {\ctxsprint{environment.inputfilesuffix or ""}} -\def \inputfilename {\ctxsprint{environment.inputfilename or ""}} -\def \outputfilename {\ctxsprint{environment.outputfilename or ""}} +\installcorenamespace{system} -\newtoks \everysetupsystem - -\unexpanded\def\setupsystem - {\dosingleargument\dosetupsystem} - -\def\dosetupsystem[#1]% - {\getparameters[\??sv][#1]% - \the\everysetupsystem} +\installdirectcommandhandler \??system {system} \appendtoks - \edef\outputresolution{\@@svresolution}% + \edef\outputresolution{\directsystemparameter\c!resolution}% + \edef\outputfilename {\directsystemparameter\c!file }% + \edef\inputfilename {\directsystemparameter\c!inputfile }% \to \everysetupsystem \appendtoks - \ifcase\@@svn + \ifcase\directsystemparameter\c!n\relax % % 0 : unknown \or \setsystemmode\v!first % 1 : first run @@ -71,21 +67,16 @@ \fi \to \everysetupsystem -\appendtoks - \edef\outputfilename{\@@svfile}% - \edef\inputfilename {\@@svinputfile}% -\to \everysetupsystem - -\let\@@jobsuffix\s!unknown +\let\m_system_job_suffix\s!unknown \appendtoks - \resetsystemmode{suffix-\@@jobsuffix}% - \edef\@@jobsuffix{\jobsuffix}% - \setsystemmode{suffix-\@@jobsuffix}% + \resetsystemmode{suffix-\m_system_job_suffix}% + \edef\m_system_job_suffix{\jobsuffix}% + \setsystemmode{suffix-\m_system_job_suffix}% \to \everysetupsystem \appendtoks - \ctxlua {commands.updatefilenames("\inputfilename","\outputfilename")}% + \ctxcommand{updatefilenames("\inputfilename","\outputfilename")}% \to \everysetupsystem % Some mechanisms (see x-res-01) use either \jobfilename or @@ -95,13 +86,11 @@ \def\jobfullname{\jobfilename.\jobfilesuffix} -\def\setjobfullname#1% #1 = default if not given +\unexpanded\def\setjobfullname#1% #1 = default if not given {\doifelsenothing\jobfilename {\let\jobfullname\empty} {\doif\jobfilesuffix\c!tex{\edef\jobfullname{\jobfilename.#1}}}} -\def\systemparameter#1{\executeifdefined{\??sv#1}\empty} - %D There are a couple of system states avaiable: %D %D \starttabulate [|T|T|] @@ -130,7 +119,7 @@ \unexpanded\def\setuprandomize[#1]% {\doifsomething{#1} - {\bgroup + {\begingroup % tex's time is in minutes \scratchcounter\normaltime \processaction @@ -143,7 +132,7 @@ \s!unknown=>\scratchcounter#1]% \expanded{\setrandomseed{\the\scratchcounter}}% % \writestatus\m!system{randomseed: \the\scratchcounter}% - \egroup}} + \endgroup}} \setupsystem [\c!directory=, @@ -158,25 +147,9 @@ %D Remark: windows programs normally handle \type {cr|lf|crlf} but unix %D is more picky, so we default to the \type {cr}. I never understood why %D \type {crlf} was not used in all systems, since it makes most sense. +%D But anyway, in \MKIV\ we avoid most of the complications anyway as we +%D deal with much at the \LUA\ end. -\def\dostartglobaldefs#1#2% - {\edef\!!stringa{\the\globaldefs}% - \ifnum\globaldefs#10 - \globaldefs-\globaldefs - \fi - \advance\globaldefs #21 - \setevalue{@gd@\the\globaldefs}{\!!stringa}} - -\def\dostopglobaldefs - {\doifdefinedelse{@gd@\the\globaldefs} - {\globaldefs\getvalue{@gd@\the\globaldefs}\relax} - {\globaldefs\zerocount}} - -\unexpanded\def\startlocal {\dostartglobaldefs>-} -\unexpanded\def\stoplocal {\dostopglobaldefs} -\unexpanded\def\startglobal {\dostartglobaldefs<+} -\unexpanded\def\stopglobal {\dostopglobaldefs} - \def\complexstart[#1]{\bgroup\getvalue{\e!start#1}} \def\complexstop [#1]{\getvalue{\e!stop #1}\egroup} @@ -186,133 +159,87 @@ \definecomplexorsimple\start \definecomplexorsimple\stop -% \def\dododefinestartstop[#1][#2]% todo: use indirect commands -% {\getparameters -% [\??be#1] -% [\c!before=, -% \c!after=, -% \c!inbetween=, -% \c!commands=, -% \c!style=, -% #2]% -% \setuvalue{#1}% -% {\groupedcommand -% {\getvalue{\??be#1\c!commands}% -% \dostarttagged\t!construct{#1}% -% \dostartattributes{\??be#1}\c!style\c!color} -% {\dostopattributes -% \dostoptagged -% \getvalue{\??be#1\c!inbetween}}}% -% \setuvalue{\e!start#1}% -% {\getvalue{\??be#1\c!before}% -% \bgroup -% \getvalue{\??be#1\c!commands}% -% \dostarttagged\t!construct{#1}% -% \dostartattributes{\??be#1}\c!style\c!color\empty}% -% \setuvalue{\e!stop#1}% -% {\dostopattributes -% \dostoptagged -% \egroup -% \getvalue{\??be#1\c!after}}} -% -% \def\dodefinestartstop[#1][#2]% -% {\def\docommand##1{\dododefinestartstop[##1][#2]}% -% \processcommalist[#1]\docommand} -% -% \unexpanded\def\definestartstop -% {\dodoubleargument\dodefinestartstop} -% -% \def\dosetupstartstop[#1][#2]% -% {\def\docommand##1{\getparameters[\??be##1][#2]}% -% \processcommalist[#1]\docommand} -% -% \unexpanded\def\setupstartstop -% {\dodoubleargument\dosetupstartstop} - - % \c!before \c!after \c!inbetween \c!commands \c!style \c!color -\installcommandhandler{\??be}{startstop}{\??be} +\installcorenamespace{startstop} + +\installcommandhandler \??startstop {startstop} \??startstop \appendtoks - \normalexpanded{\dodefinestartstop{\currentstartstop}}% + \setuevalue{\e!start\currentstartstop}{\syst_startstop_start {\currentstartstop}}% + \setuevalue{\e!stop \currentstartstop}{\syst_startstop_stop {\currentstartstop}}% + \setuevalue {\currentstartstop}{\syst_startstop_indeed{\currentstartstop}}% \to \everydefinestartstop -\unexpanded\def\dodefinestartstop#1% - {\setuvalue{#1}% - {\groupedcommand - {\def\currentstartstop{#1}% - \startstopparameter\c!commands - \dostarttagged\t!construct\currentstartstop - \dosetstartstopattributes\c!style\c!color} - {\def\currentstartstop{#1}% - \dostoptagged - \startstopparameter\c!inbetween}}% - \setuvalue{\e!start#1}% - {\namedstartstopparameter{#1}\c!before - \bgroup - \def\currentstartstop{#1}% - \startstopparameter\c!commands +\unexpanded\def\syst_startstop_start#1% + {\namedstartstopparameter{#1}\c!before + \bgroup + \def\currentstartstop{#1}% + \startstopparameter\c!commands + \dostarttagged\t!construct\currentstartstop + \usestartstopstyleandcolor\c!style\c!color} + +\unexpanded\def\syst_startstop_stop#1% + {\dostoptagged + \egroup + \namedstartstopparameter{#1}\c!after} + +\unexpanded\def\syst_startstop_indeed#1% + {\groupedcommand + {\def\currentstartstop{#1}% + \startstopparameter\c!commands % will become setups \dostarttagged\t!construct\currentstartstop - \dosetstartstopattributes\c!style\c!color}% - \setuvalue{\e!stop#1}% - {\dostoptagged - \egroup - \namedstartstopparameter{#1}\c!after}} - -% \docommand kan niet worden gebruikt omdat deze macro -% soms lokaal wordt gebruikt - -% te zijner tijd: -% -% \definevariable {pc} % ProtectedCommand -% -% \def\executeprotected#1% -% {\csname\??pc\string#1\endcsname} -% -% \unexpanded\def\defineprotected#1#2% -% {\expandafter\def\csname\??pc\string#2\endcsname} -% -% \unexpanded\def\defineunprotected#1% -% {\def#1} -% -% \def\doprotected% -% {\ifx\next\define -% \let\next=\defineprotected -% \else -% \let\next=\executeprotected -% \fi -% \next} -% -% \def\unexpanded% -% {\futurelet\next\doprotected} -% -% \unexpanded\define\ziezo{ziezo} -% -% \unexpanded\ziezo + \usestartstopstyleandcolor\c!style\c!color} + {\def\currentstartstop{#1}% + \dostoptagged + \startstopparameter\c!inbetween}} + +\installcorenamespace{highlight} + +\installcommandhandler \??highlight {highlight} \??highlight % we could do with less + +\appendtoks + \setuevalue\currenthighlight{\typo_highlights_indeed{\currenthighlight}}% +\to \everydefinehighlight + +\ifdefined\dotaghighlight \else \let\dotaghighlight\relax \fi + +\unexpanded\def\typo_highlights_indeed#1% inline style/color switch + {\dontleavehmode\groupedcommand % otherwise wrong par number in tags + {\def\currenthighlight{#1}% + \dostarttagged\t!highlight\currenthighlight + \usehighlightstyleandcolor\c!style\c!color + \dotaghighlight} + {\dostoptagged}} -\def\complexdefine[#1]#2#3% - {\ifx#2\undefined - \else +\unexpanded\def\define + {\doifnextoptionalelse\syst_basics_define_yes\syst_basics_define_nop} + +\unexpanded\def\syst_basics_define_yes[#1]#2#3% + {\ifdefined#2% \showmessage\m!system4{\string#2}% \fi - \ifcase0#1\def#2{#3}% - \or\def#2##1{#3}% - \or\def#2##1##2{#3}% - \or\def#2##1##2##3{#3}% - \or\def#2##1##2##3##4{#3}% - \or\def#2##1##2##3##4##5{#3}% - \or\def#2##1##2##3##4##5##6{#3}% - \or\def#2##1##2##3##4##5##6##7{#3}% - \or\def#2##1##2##3##4##5##6##7##8{#3}% - \or\def#2##1##2##3##4##5##6##7##8##9{#3}% - \else\def#2{#3}% - \fi} - -\definecomplexorsimpleempty\define + \ifcase0#1\relax + \def#2{#3}\or + \def#2##1{#3}\or + \def#2##1##2{#3}\or + \def#2##1##2##3{#3}\or + \def#2##1##2##3##4{#3}\or + \def#2##1##2##3##4##5{#3}\or + \def#2##1##2##3##4##5##6{#3}\or + \def#2##1##2##3##4##5##6##7{#3}\or + \def#2##1##2##3##4##5##6##7##8{#3}\or + \def#2##1##2##3##4##5##6##7##8##9{#3}\else + \def#2{#3}\fi} + +\unexpanded\def\syst_basics_define_nop#1#2% + {\ifdefined#1% + \showmessage\m!system4{\string#1}% + \fi + \def#1{#2}} % \startluacode -% local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes +% local contextsprint, ctxcatcodes = context.sprint, tex.ctxcatcodes % local format, match, gmatch, rep = string.format, string.match, string.gmatch, string.rep % local empty = { % "single", @@ -341,38 +268,38 @@ % else % n = 0 % end -% texsprint(ctxcatcodes,format("\\unexpanded\\def\\%s",cmd)) +% contextsprint(ctxcatcodes,format("\\unexpanded\\def\\%s",cmd)) % if #a > 0 then -% texsprint(ctxcatcodes,format("{\\do%sempty\\do%s}",empty[#a],cmd)) -% texsprint(ctxcatcodes,format("\\def\\do%s",cmd)) +% contextsprint(ctxcatcodes,format("{\\do%sempty\\do%s}",empty[#a],cmd)) +% contextsprint(ctxcatcodes,format("\\def\\do%s",cmd)) % for i=1,#a do -% texsprint(ctxcatcodes,"[#",i,"]") +% contextsprint(ctxcatcodes,"[#",i,"]") % end -% texsprint(ctxcatcodes,"{") +% contextsprint(ctxcatcodes,"{") % for i=#a,1,-1 do -% texsprint(ctxcatcodes,format("\\if%sargument",check[i])) -% texsprint(ctxcatcodes,format("\\def\\next{\\dodo%s",cmd)) +% contextsprint(ctxcatcodes,format("\\if%sargument",check[i])) +% contextsprint(ctxcatcodes,format("\\def\\next{\\dodo%s",cmd)) % for j=1,#a-i do -% texsprint(ctxcatcodes,format("[%s]",a[j])) +% contextsprint(ctxcatcodes,format("[%s]",a[j])) % end % for j=1,i do -% texsprint(ctxcatcodes,format("[#%s]",j)) +% contextsprint(ctxcatcodes,format("[#%s]",j)) % end -% texsprint(ctxcatcodes,"}") +% contextsprint(ctxcatcodes,"}") % if i == 1 then -% texsprint(ctxcatcodes,rep("\\fi",#a)) +% contextsprint(ctxcatcodes,rep("\\fi",#a)) % else -% texsprint(ctxcatcodes,"\\else") +% contextsprint(ctxcatcodes,"\\else") % end % end -% texsprint(ctxcatcodes,"\\next}") -% texsprint(ctxcatcodes,format("\\def\\dodo%s",cmd)) +% contextsprint(ctxcatcodes,"\\next}") +% contextsprint(ctxcatcodes,format("\\def\\dodo%s",cmd)) % for i=1,#a do -% texsprint(ctxcatcodes,"[#",i,"]") +% contextsprint(ctxcatcodes,"[#",i,"]") % end % end % for i=1,n do -% texsprint(ctxcatcodes,"#",#a+i) +% contextsprint(ctxcatcodes,"#",#a+i) % end % end % \stopluacode @@ -387,73 +314,19 @@ % \whateverb[A][B]{C}{D} % \stoptext +%D This is a checked variant of \type {\getvalue}. + \unexpanded\def\macroname#1% brrr - {\executeifdefined{#1}\empty} - -\def\usecommands#1% - {\bgroup - \def\docommand##1{\setbox0\hbox{\getvalue{\string##1}##1}}% - \processcommalist[#1]\docommand - \egroup} - -\newif\ifforcefileexpansion % handy for document level overload - -%D The next implementation is about 4 times as faster than a -%D processaction alternative on an string of average length. -%D Since this feature is used in XML processing, it made sense -%D to support this faster alternative. It's installable as well. -%D -%D We keep this around for \MKII\ \XML\ but it's not used in \MKIV\ -%D code as expansion is controlled in another way there. - -\def\installexpander#1#2#3% changed, no longer \convert..\to... - {\setvalue{\s!do\c!expansion#1l}{#2}% - \setvalue{\s!do\c!expansion#1g}{#3}}% - -% \convertexpanded is obsolete - -\long\def\doconvertexpanded#1#2#3% #4 % [l|g] \cs {kind} {data} - {\csname % that we assign all exp a value - \s!do\c!expansion - \ifforcefileexpansion - \v!yes - \else\ifcsname\s!do\c!expansion#3#1\endcsname - #3% - \else - \s!default - \fi\fi - #1% - \endcsname#2}% #3 - -\long\def\defconvertexpanded {\doconvertexpanded l} -\long\def\gdefconvertexpanded{\doconvertexpanded g} - -\installexpander\v!command \defconvertedcommand \gdefconvertedcommand -\installexpander\s!default \defconvertedargument \gdefconvertedargument -\installexpander\empty \defconvertedargument \gdefconvertedargument -\installexpander\v!no \defconvertedargument \gdefconvertedargument -\installexpander\v!yes \defconvertedmeaning \gdefconvertedmeaning -\installexpander\v!yes \defconvertedmeaning \gdefconvertedmeaning -\installexpander\v!strict \defreducedargument \gdefreducedargument -\installexpander {utf} \defreducedtoutf \gdefreducedtoutf - -\def\dodefconvertedmeaning#1#2#3% watch the double expansion ! - {\bgroup - \xdef\@@globalexpanded{#3}% - \xdef\@@globalexpanded{\@@globalexpanded}% - \egroup - #1#2\@@globalexpanded} + {\csname\ifcsname#1\endcsname#1\else\s!empty\fi\endcsname} -\def\defconvertedmeaning {\dodefconvertedmeaning\defconvertedcommand} -\def\gdefconvertedmeaning{\dodefconvertedmeaning\gdefconvertedcommand} +% %D A weird one that I probably needed once, so it might as well become +% %D obsolete. +% +% \unexpanded\def\usecommands#1% +% {\begingroup +% \def\docommand##1{\setbox\scratchbox\hbox{\csname\string##1\endcsname##1}}% +% \processcommalist[#1]\docommand +% \endgroup} -\def\dodefreducedargument#1#2#3% - {\begingroup - \reducetocoding[raw]% - \edef\ascii{#3}% - \expandafter\endgroup\expandafter#1\expandafter#2\expandafter{\ascii}} -\def\defreducedargument {\dodefreducedargument\edef} -\def\gdefreducedargument{\dodefreducedargument\xdef} - \protect \endinput |