1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
%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]
%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.
%D This feature is obsolete.
\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
|