summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/char-act.mkiv
blob: 7d7268c8ba6ad6724785952890c6ea47b73b72ce (plain)
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
%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,
%D \NEWLINE\ and \NEWPAGE\ active and assigning them
%D \type{\obeysomething}, but first we set some default values.

% These are expandable!

\def\obeyedspace {\space}
\def\obeyedtab   {\obeyedspace}
\def\obeyedline  {\par}
\def\obeyedpage  {\page_otr_fill_and_eject_page}

%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:

\chardef\asciispacechar\spaceasciicode % a real space character

\unexpanded\def\naturalspace{\asciispacechar}
\unexpanded\def\controlspace{\hbox{\asciispacechar}}               % rather tex, we need the unicode value
\unexpanded\def\normalspaces{\catcode\spaceasciicode\spacecatcode}

\bgroup
    \catcode\spaceasciicode\activecatcode
    \unexpanded\gdef\obeyspaces{\catcode\spaceasciicode\activecatcode\def {\obeyedspace}}
    \unexpanded\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.

\expandafter\def\activeformfeedtoken{\par}

%D The following indirect definitions enable us to implement
%D all kind of \type{\obeyed} handlers.

\unexpanded\def\obeytabs   {\catcode\tabasciicode      \activecatcode\expandafter\def\activetabtoken      {\obeyedtab }}
\unexpanded\def\obeylines  {\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedline}}
\unexpanded\def\obeypages  {\catcode\formfeedasciicode \activecatcode\expandafter\def\activeformfeedtoken {\obeyedpage}}

\unexpanded\def\ignoretabs {\catcode\tabasciicode      \activecatcode\expandafter\def\activetabtoken      {\obeyedspace}}
\unexpanded\def\ignorelines{\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedspace}}
\unexpanded\def\ignorepages{\catcode\formfeedasciicode \ignorecatcode}
\unexpanded\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.

\unexpanded\def\naturaltextext#1\relax % this command will become obsolete
  {\begingroup
   \def\ascii{#1}%
   \setcatcodetable\ctxcatcodes
   \prettynaturalfont{\scantextokens\expandafter{\ascii}\ifhmode\unskip\fi}%
   \endgroup}

\endinput \protect