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
|
%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
\ifdefined\page_otr_fill_and_eject_page \else \let\page_otr_fill_and_eject_page\relax \fi % forward reference
%D \macros
%D {obeyedspace, obeyedtab, obeyedline, obeyedpage}
%D
%D We have followed Knuth in naming macros that make \SPACE, \NEWLINE\ and \NEWPAGE\
%D active and assigning them \type {\obeysomething}, but first we set some default
%D values.
%D
%D These are expandable:
\permanent\def\obeyedspace{\space}
\permanent\def\obeyedtab {\obeyedspace}
\permanent\def\obeyedline {\par}
\permanent\def\obeyedpage {\page_otr_fill_and_eject_page}
%D \macros
%D {controlspace,setcontrolspaces}
%D
%D First we define \type {\obeyspaces}. When we want visible spaces (control spaces)
%D we only have to adapt the definition of \type {\obeyedspace} to:
\immutable\chardef\asciispacechar\spaceasciicode % a real space character
\permanent\protected\def\naturalspace{\asciispacechar}
\permanent\protected\def\controlspace{\hbox{\asciispacechar}} % rather tex, we need the unicode value
\permanent\protected\def\normalspaces{\catcode\spaceasciicode\spacecatcode}
% \bgroup
% \catcode\spaceasciicode\activecatcode
% \protected\gdef\obeyspaces {\catcode\spaceasciicode\activecatcode\def {\obeyedspace }}
% \protected\gdef\setcontrolspaces{\catcode\spaceasciicode\activecatcode\def {\controlspace}}
% \egroup
%permanent\protected\def\obeyspaces {\catcode\spaceasciicode\activecatcode\letcharcode\spaceasciicode\obeyedspace }
%permanent\protected\def\setcontrolspaces{\catcode\spaceasciicode\activecatcode\letcharcode\spaceasciicode\controlspace}
%D \macros
%D {obeytabs, obeylines, obeypages,ignoretabs, ignorelines, ignorepages}
%D
%D Next we take care of \NEWLINE\ and \NEWPAGE\ and because we want to be able to
%D typeset listings that contain \TAB, we have to handle those too. Because we have
%D to redefine the \NEWPAGE\ character locally, we redefine the meaning of this
%D (often already) active character.
% \expandafter\def\activeformfeedtoken{\par}
\letcharcode\formfeedasciicode\par
%D The following indirect definitions enable us to implement all kind of \type
%D {\obeyed} handlers.
% \protected\def\obeytabs {\catcode\tabasciicode \activecatcode\expandafter\def\activetabtoken {\obeyedtab }}
% \protected\def\obeylines {\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedline}}
% \protected\def\obeypages {\catcode\formfeedasciicode \activecatcode\expandafter\def\activeformfeedtoken {\obeyedpage}}
% \protected\def\ignoretabs {\catcode\tabasciicode \activecatcode\expandafter\def\activetabtoken {\obeyedspace}}
% \protected\def\ignorelines{\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedspace}}
% \protected\def\ignorepages{\catcode\formfeedasciicode \ignorecatcode}
% \protected\def\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode}
% but ... as we don't want to freeze to \obeyedspace etc which can be set after
% \obeyspaces, we use an idirectness
\def\syst_obeyed_space{\obeyedspace}
\def\syst_obeyed_tab {\obeyedtab}
\def\syst_obeyed_line {\obeyedline}
\def\syst_obeyed_page {\obeyedpage}
\permanent\protected\def\obeyspaces {\catcode\spaceasciicode \activecatcode\enforced\letcharcode\spaceasciicode \syst_obeyed_space}
\permanent\protected\def\obeytabs {\catcode\tabasciicode \activecatcode\enforced\letcharcode\tabasciicode \syst_obeyed_tab }
\permanent\protected\def\obeylines {\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\syst_obeyed_line }
\permanent\protected\def\obeypages {\catcode\formfeedasciicode \activecatcode\enforced\letcharcode\formfeedasciicode \syst_obeyed_page }
\permanent\protected\def\ignoretabs {\catcode\tabasciicode \activecatcode\enforced\letcharcode\tabasciicode \syst_obeyed_space}
\permanent\protected\def\ignorelines{\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\syst_obeyed_space}
\permanent\protected\def\ignorepages{\catcode\formfeedasciicode \ignorecatcode}
\permanent\protected\def\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode}
\permanent\protected\def\setcontrolspaces{\catcode\spaceasciicode\activecatcode\enforced\letcharcode\spaceasciicode\controlspace}
\endinput \protect
|