%D \module %D [ file=char-act, %D version=2006.12.05, %D title=\CONTEXT\ Character Support, %D subtitle=Active, %D author=Hans Hagen, %D date=\currentdate, %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 %C details. \writestatus{loading}{ConTeXt Character Support / Active} \unprotect %D \macros %D {processingverbatim} %D %D Typesetting a file in most cases results in more than one %D page. Because we don't want problems with files that are %D read in during the construction of the page, we set \type %D {\ifprocessingverbatim}, so the output routine can adapt %D its behavior. Originally we used \type {\scratchread}, but %D because we want to support nesting, we decided to use a %D separate input file. \newif\ifprocessingverbatim %D \macros %D {obeyedspace, obeyedtab, obeyedline, obeyedpage} %D %D We have followed Knuth in naming macros that make \SPACE, %D \NEWLINE\ and \NEWPAGE\ active and assigning them %D \type{\obeysomething}, but first we set some default values. \def\obeyedspace {\ifprocessingverbatim\hbox{ }\else\space\fi} \def\obeyedtab {\obeyedspace} \def\obeyedline {\par} \def\obeyedpage {\vfill\eject} %D \macros %D {controlspace,setcontrolspaces} %D %D First we define \type{\obeyspaces}. When we want visible %D spaces (control spaces) we only have to adapt the definition %D of \type{\obeyedspace} to: \def\controlspace{\hbox{\char32}} % rather tex \def\normalspace { } \def\normalspaces{\catcode\spaceasciicode\spacecatcode} \bgroup \catcode\spaceasciicode\activecatcode \gdef\obeyspaces{\catcode\spaceasciicode\activecatcode\def {\obeyedspace}} \gdef\setcontrolspaces{\catcode\spaceasciicode\activecatcode\def {\controlspace}} \egroup %D \macros %D {obeytabs, obeylines, obeypages,ignoretabs, ignorelines, ignorepages} %D %D Next we take care of \NEWLINE\ and \NEWPAGE\ and because we %D want to be able to typeset listings that contain \TAB, we %D have to handle those too. Because we have to redefine the %D \NEWPAGE\ character locally, we redefine the meaning of %D this (often already) active character. % \bgroup \permitcircumflexescape % \catcode\formfeedasciicode\activecatcode % \gdef^^L{\par} % \egroup \expandafter\def\activeformfeedtoken{\par} %D The following indirect definitions enable us to implement %D all kind of \type{\obeyed} handlers. % \bgroup \permitcircumflexescape % \catcode\tabasciicode \activecatcode % \catcode\endoflineasciicode\activecatcode % \catcode\formfeedasciicode \activecatcode % \gdef\obeytabs {\catcode\tabasciicode \activecatcode\def^^I{\obeyedtab }} % \gdef\obeylines {\catcode\endoflineasciicode\activecatcode\def^^M{\obeyedline}} % \gdef\obeypages {\catcode\formfeedasciicode \activecatcode\def^^L{\obeyedpage}} % \gdef\ignoretabs {\catcode\tabasciicode \activecatcode\def^^I{\obeyedspace}} % \gdef\ignorelines{\catcode\endoflineasciicode\activecatcode\def^^M{\obeyedspace}} % \gdef\ignorepages{\catcode\formfeedasciicode \ignorecatcode} % \gdef\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode} % \egroup \def\obeytabs {\catcode\tabasciicode \activecatcode\expandafter\def\activetabtoken {\obeyedtab }} \def\obeylines {\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedline}} \def\obeypages {\catcode\formfeedasciicode \activecatcode\expandafter\def\activeformfeedtoken {\obeyedpage}} \def\ignoretabs {\catcode\tabasciicode \activecatcode\expandafter\def\activetabtoken {\obeyedspace}} \def\ignorelines{\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedspace}} \def\ignorepages{\catcode\formfeedasciicode \ignorecatcode} \def\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode} %D \macros %D {naturaltextext} %D %D When one uses \ETEX, switching to normal \TEX\ is possible %D too. We also introduce a switch that can be used in the %D drivers and set in higher level shell macros. \def\naturaltextext#1\relax {\bgroup \def\ascii{#1}% \setcatcodetable\ctxcatcodes \prettynaturalfont{\scantextokens\expandafter{\ascii}\ifhmode\unskip\fi}% \egroup} \endinput \protect % obsolete (old hack for idris) % %D This is a hack, and only meant for special situations. We don't % %D support this in for instance verbatim. The active characters map % %D onto the \CONTEXT\ names and font handling etc. is up to the user. % % \registerctxluafile{char-act}{1.001} % % \def\enableactiveutf {\ctxlua{characters.active.enable()}} % \def\disableactiveutf{\ctxlua{characters.active.disable()}} % \def\testactiveutf #1{\ctxlua{characters.active.test("#1")}} %D Usage: %D %D \starttyping %D \enableactiveutf \testactiveutf{eacute} %D \stoptyping