summaryrefslogtreecommitdiff
path: root/tex/context/base/xetx-ini.mkii
blob: 55155fa1af288352c1ec5385e05f1253ae7a6d83 (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
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
%D \module
%D   [       file=xetx-ini,
%D        version=2004.09.11,
%D          title=\CONTEXT\ System Macros,
%D       subtitle=\XETEX\ Initializations,
%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.

%D We moved some code around and now have reorganized the xetex
%D code in the \type {xetx} module namespace.

\unprotect

%D Some defaults.

\ifdefined\XeTeXuseglyphmetrics
    \XeTeXuseglyphmetrics\plusone
\fi

%D Character classes.

\newcount\nofXTXcharinjections

\def\defineXTXcharinjectionclass[#1]%
  {\global\advance\nofXTXcharinjections\plusone
   \setxvalue{@xtx@cc@#1}{\number\nofXTXcharinjections}}

\setxvalue{@xtx@cc@\s!default}{0}

\def\getXTXcharinjectionclass#1%
  {\csname @xtx@cc@\ifcsname @xtx@cc@#1\endcsname#1\else\s!default\fi\endcsname}

\let\currentXTXcharinjection\s!default

\def\startXTXcharinjecxtions[#1]%
  {\pushmacro\currentXTXcharinjection
   \def\currentXTXcharinjection{#1}}

\def\stopXTXcharinjections
  {\popmacro\currentXTXcharinjection}

\def\defineXTXcharinjection #1 #2 %
  {\doifnumberelse{#1}{\edef\XTXclassone{\number#1}}{\edef\XTXclassone{\getXTXcharinjectionclas{#1}}}%
   \doifnumberelse{#2}{\edef\XTXclasstwo{\number#2}}{\edef\XTXclasstwo{\getXTXcharinjectionclas{#2}}}%
   \expanded{\dodefineXTXcharinjection{\XTXclassone}{\XTXclasstwo}}}

\def\setXTXcharcodes #1 #2 #3 % encoding syntax
  {\catcode#1=11 \lccode #1=#2 \uccode #1=#3 }

\def\dosetXTXcharcodes#1#2#3% compact syntax
  {\catcode#1=11 \lccode #1=#2 \uccode #1=#3 }

\ifdefined\XeTeXinterchartoks

    \long\def\dodefineXTXcharinjection#1#2#3%
      {\XeTeXinterchartoks #1 #2 {\XTXcharinjection{#1}{#2}}%
       \setvalue{@xtx@ch@\currentXTXcharinjection @#1@#2@}{#3}}

    \def\setXTXcharacterclass #1 #2 %
      {\doifnumberelse{#2}
         {\XeTeXcharclass#1=#2\relax}
         {\XeTeXcharclass#1=\getXTXcharinjectionclass{#2}\relax}}

    \def\dosetXTXcharacterclass#1% #2 fast one
      {\XeTeXcharclass#1=\getXTXcharinjectionclass}

\else

    \long\def\dodefineXTXcharinjection#1#2#3%
      {\setvalue{@xtx@ch@\currentXTXcharinjection @#1@#2@}{#3}}

    \def\setXTXcharacterclass #1 #2 %
      {}

\fi

\chardef\XTXcharinjectionsmode=1

\letvalue{@xtx@ch@\s!empty}\empty

\def\XTXcharinjection#1#2%
  {\csname @xtx@ch@%
     \ifcase\XTXcharinjectionsmode
       \s!empty
     \or
       \ifcsname @xtx@ch@\currentXTXcharinjection @#1@#2@\endcsname \currentXTXcharinjection @#1@#2@\fi
     \or
       \ifcsname @xtx@ch@\currentXTXcharinjection @#1@#2@\endcsname \currentXTXcharinjection @#1@#2@\else
       \ifcsname @xtx@ch@\s!default               @#1@#2@\endcsname \s!default               @#1@#2@\else
         \s!empty
       \fi\fi
     \else
       \s!empty
     \fi
   \endcsname}

\def\enableXTXcharinjections[#1]%
  {\def\currentXTXcharinjection{#1}}

\protect \endinput

\starttext

\startXTXcharinjecxtions[default]
    \defineXTXcharinjection 10 40 {[default]}
\stopXTXcharinjections

\startXTXcharinjecxtions[whatever]
    \defineXTXcharinjection 20 40 {[whatever]}
\stopXTXcharinjections

\chardef\XTXcharinjectionsmode=0

\enableXTXcharinjections[default]  A\XTXcharinjection{10}{40}B\XTXcharinjection{20}{40}C
\enableXTXcharinjections[whatever] A\XTXcharinjection{10}{40}B\XTXcharinjection{20}{40}C

\chardef\XTXcharinjectionsmode=1

\enableXTXcharinjections[default]  A\XTXcharinjection{10}{40}B\XTXcharinjection{20}{40}C
\enableXTXcharinjections[whatever] A\XTXcharinjection{10}{40}B\XTXcharinjection{20}{40}C

\chardef\XTXcharinjectionsmode=2

\enableXTXcharinjections[default]  A\XTXcharinjection{10}{40}B\XTXcharinjection{20}{40}C
\enableXTXcharinjections[whatever] A\XTXcharinjection{10}{40}B\XTXcharinjection{20}{40}C

\stoptext