%D \module %D [ file=regi-ini, %D version=2000.12.27, % 1998.12.03, %D title=\CONTEXT\ Regime Macros, %D subtitle=Initialization, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. \unprotect %D Plugs into the common interface. \def\mkloadregime#1% {\makeshortfilename[\truefilename{\f!regimeprefix#1}]% \startreadingfile \readsysfile\shortfilename {\showmessage\m!regimes2{#1}} {\showmessage\m!regimes3{#1}}% \stopreadingfile} \def\mkenableregime#1% {\the\executeifdefined{\@reg@#1}\emptytoks} \def\mkwalkregime#1% {\the\executeifdefined{\@reg@\currentregime}\emptytoks} \def\mkautosetregime#1#2% {\ifnum#2>127 \expanded{\defineactivetoken #2 \@EA\noexpand\csname#1\endcsname}% \fi} %D Remark: regimes accumulate, so there is no explicit reset in %D mkii mode. %D \macros %D {startregime} %D %D Sometimes it makes sense to activate the characters in the %D upper half of the character table. Such a bundle of %D characters can be packages in a regime. Later we will see %D encodings (that links characters slots to glyphs) and %D mappings (that take care of hyphenation and case changes). %D %D When character~231 is of category code letter, it %D directly maps to glyph~231 (unless of course some virtual %D font is used). By making character~231 active, we can map %D it onto for instance the glyph in slot 233. This mapping %D can in itself be indirect, in the sense that it is for %D instance handled by an accent command. %D %D Regimes are implemented roughly the same as mappings, but %D enabled under different circumstances. In the future, the %D low level implementation may change. \def\startregime[#1]% {\pushmacro\currentregime \edef\currentregime{#1}% \checkregimetoks} \def\checkregimetoks {\doifundefined{\@reg@\currentregime} {\@EA\newtoks\csname\@reg@\currentregime\endcsname}} \def\stopregime {\popmacro\currentregime} \def\setregimetoks {\checkregimetoks \@EA\let\@EA\regimetoks\csname\@reg@\currentregime\endcsname} %D \macros %D {defineactivedecimal, defineactivedecimals, defineactivetoken} %D %D The following commands are rather ugly ones. It makes a %D character active and assigns it a value. When expanded, %D the decimal number of the character is passed as first %D argument. %D %D \starttyping %D \def\decimalcharacter#1{\message{#1 is now active}} %D %D \defineactivedecimal 122 {\decimalcharacter} %D %D \defineactivedecimals 128 to 255 as {\decimalcharacter} %D \stoptyping %D %D This command is typically used in coding definitions, %D like the \UNICODE\ one. \def\dodefineactivedecimal#1#2% \unexpanded ? pdfdoc encoding {\catcode#1\active \scratchcounter\uccode\activehackcode \uccode\activehackcode#1\relax \uppercase{\unexpanded\edef~{\noexpand#2{\number#1}}}% \uccode\activehackcode\scratchcounter} \long\def\defineactivedecimal#1 #2 % {\setregimetoks \regimetoks\expandafter{\the\regimetoks\dodefineactivedecimal{#1}{#2}}} \long\def\defineactivedecimals#1 to #2 as #3 % {\setregimetoks \dostepwiserecurse{#1}{#2}\plusone {\regimetoks\@EA\@EA\@EA{\@EA\the\@EA\regimetoks\@EA\dodefineactivedecimal\@EA{\recurselevel}{#3}}}} \def\doexpandactivedecimal#1% {\ifnum#1>\scratchcounter \expandafter\gobbletwoarguments \else \noexpand\dodefineactivedecimal{#1}{\the\scratchtoks}% \expandafter\expandafter\expandafter\doexpandactivedecimal\expandafter \fi\expandafter{\the\numexpr#1+\plusone\relax}} \long\def\defineactivedecimals#1 to #2 as #3 % {\setregimetoks \scratchcounter#2\relax \scratchtoks{#3}% \expanded{\regimetoks{\the\regimetoks\doexpandactivedecimal{#1}}}% \ignorespaces} \long\def\defineactivetoken #1 #2% no {} after #2, else no kern {\setregimetoks \regimetoks\expandafter{\the\regimetoks\defineactivecharacter#1 {#2}}} \long\def\defineactiveinspector #1 #2% watch the missing {} {\setregimetoks \regimetoks\expandafter{\the\regimetoks\defineactivecharacter#1 {#2}}} % D This is kind of obsolete (replaced by previous code). % % \def\definetoken #1 % #1 = rawtoken or number % {\doifnumberelse{\string#1} % {\expanded{\dodefinetoken{\rawcharacter{#1}}}} % {\expanded{\dodefinetoken{\string#1}}}} % % \def\dodefinetoken#1#2% % {\defineactivecharacter#1 {\dohandletoken{#1}} % % \setvalue{\@reg@:t:\currentregime#1}{#2}} % % \def\dohandletoken#1% % {\csname\ifcsname \@reg@:t:\currentregime#1\endcsname % regi-def sets the defaults % \@reg@:t:\currentregime\else\defaultregime\fi#1\endcsname} %D Preloading: \useregime[def,uni,utf] % we load the rest runtime \protect \endinput