char-act.mkxl /size: 4764 b    last modification: 2021-10-28 13:50
1%D \module
2%D   [       file=char-act,
3%D        version=2006.12.05,
4%D          title=\CONTEXT\ Character Support,
5%D       subtitle=Active,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Character Support / Active}
15
16\unprotect
17
18\ifdefined\page_otr_fill_and_eject_page \else \let\page_otr_fill_and_eject_page\relax \fi % forward reference
19
20%D \macros
21%D   {obeyedspace, obeyedtab, obeyedline, obeyedpage}
22%D
23%D We have followed Knuth in naming macros that make \SPACE, \NEWLINE\ and \NEWPAGE\
24%D active and assigning them \type {\obeysomething}, but first we set some default
25%D values.
26%D
27%D These are expandable:
28
29\permanent\def\obeyedspace{\space}
30\permanent\def\obeyedtab  {\obeyedspace}
31\permanent\def\obeyedline {\par}
32\permanent\def\obeyedpage {\page_otr_fill_and_eject_page}
33
34%D \macros
35%D   {controlspace,setcontrolspaces}
36%D
37%D First we define \type {\obeyspaces}. When we want visible spaces (control spaces)
38%D we only have to adapt the definition of \type {\obeyedspace} to:
39
40\immutable\chardef\asciispacechar\spaceasciicode % a real space character
41
42\permanent\protected\def\naturalspace{\asciispacechar}
43\permanent\protected\def\controlspace{\hbox{\asciispacechar}} % rather tex, we need the unicode value
44\permanent\protected\def\normalspaces{\catcode\spaceasciicode\spacecatcode}
45
46% \bgroup
47%     \catcode\spaceasciicode\activecatcode
48%     \protected\gdef\obeyspaces      {\catcode\spaceasciicode\activecatcode\def {\obeyedspace }}
49%     \protected\gdef\setcontrolspaces{\catcode\spaceasciicode\activecatcode\def {\controlspace}}
50% \egroup
51
52%permanent\protected\def\obeyspaces      {\catcode\spaceasciicode\activecatcode\letcharcode\spaceasciicode\obeyedspace }
53%permanent\protected\def\setcontrolspaces{\catcode\spaceasciicode\activecatcode\letcharcode\spaceasciicode\controlspace}
54
55%D \macros
56%D   {obeytabs, obeylines, obeypages,ignoretabs, ignorelines, ignorepages}
57%D
58%D Next we take care of \NEWLINE\ and \NEWPAGE\ and because we want to be able to
59%D typeset listings that contain \TAB, we have to handle those too. Because we have
60%D to redefine the \NEWPAGE\ character locally, we redefine the meaning of this
61%D (often already) active character.
62
63% \expandafter\def\activeformfeedtoken{\par}
64
65\letcharcode\formfeedasciicode\par
66
67%D The following indirect definitions enable us to implement all kind of \type
68%D {\obeyed} handlers.
69
70% \protected\def\obeytabs   {\catcode\tabasciicode      \activecatcode\expandafter\def\activetabtoken      {\obeyedtab }}
71% \protected\def\obeylines  {\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedline}}
72% \protected\def\obeypages  {\catcode\formfeedasciicode \activecatcode\expandafter\def\activeformfeedtoken {\obeyedpage}}
73
74% \protected\def\ignoretabs {\catcode\tabasciicode      \activecatcode\expandafter\def\activetabtoken      {\obeyedspace}}
75% \protected\def\ignorelines{\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedspace}}
76% \protected\def\ignorepages{\catcode\formfeedasciicode \ignorecatcode}
77% \protected\def\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode}
78
79% but ... as we don't want to freeze to \obeyedspace etc which can be set after
80% \obeyspaces, we use an idirectness
81
82\def\syst_obeyed_space{\obeyedspace}
83\def\syst_obeyed_tab  {\obeyedtab}
84\def\syst_obeyed_line {\obeyedline}
85\def\syst_obeyed_page {\obeyedpage}
86
87\permanent\protected\def\obeyspaces {\catcode\spaceasciicode    \activecatcode\enforced\letcharcode\spaceasciicode    \syst_obeyed_space}
88\permanent\protected\def\obeytabs   {\catcode\tabasciicode      \activecatcode\enforced\letcharcode\tabasciicode      \syst_obeyed_tab  }
89\permanent\protected\def\obeylines  {\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\syst_obeyed_line }
90\permanent\protected\def\obeypages  {\catcode\formfeedasciicode \activecatcode\enforced\letcharcode\formfeedasciicode \syst_obeyed_page }
91
92\permanent\protected\def\ignoretabs {\catcode\tabasciicode      \activecatcode\enforced\letcharcode\tabasciicode      \syst_obeyed_space}
93\permanent\protected\def\ignorelines{\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\syst_obeyed_space}
94\permanent\protected\def\ignorepages{\catcode\formfeedasciicode \ignorecatcode}
95\permanent\protected\def\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode}
96
97\permanent\protected\def\setcontrolspaces{\catcode\spaceasciicode\activecatcode\enforced\letcharcode\spaceasciicode\controlspace}
98
99\endinput \protect
100