summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/unic-run.tex
blob: 49b8b6d968ddb711591039cb2503d7467fa22603 (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
%D \module
%D   [       file=unic-run,
%D        version=2005.06.22,
%D          title=\CONTEXT\ \UNICODE\ Support,
%D       subtitle=Goodies,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\unprotect

%D \macros
%D   {showunicodevector}
%D
%D Original version by Nikolai Weibull. Adapted a bit (no local count
%D definitions, stepwiserecurse instead of -1 calculations, a bit less
%D code and such). BTW, this is kind of tricky and somehow we don't
%D have align interference.

\gdef\doshowunicodevectorrow#1#2%
  {\NC
   \ttx\uchexnumber{#2}%
   \VL
   \dostepwiserecurse{0}{15}{1}{\unicodechar{\numexpr#1*256+#2+\recurselevel*16\relax}\VL}%
   \AR}

\gdef\showunicodevector#1%
  {\starttable[|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|]
     \NC\NC\dostepwiserecurse{0}{15}{1}{\ttx\uchexnumber\recurselevel\NC}\AR
     \DC\DL[16]\DR
     \dostepwiserecurse{0}{15}{1}
       {\expanded{\doshowunicodevectorrow{#1}{\recurselevel}}%
        \DC\DL[16]\DR}
     \NC \use{17}{\hfill \ttx unicode table hex:\uchexnumbers{#1} dec:\threedigits{#1}\kern-.25em}\NC \AR
   \stoptable}

%D \starttyping
%D \chardef\utfunicodetracer=0
%D \chardef\utfunicodetracer=7
%D
%D \showunicodevector{000}
%D \showunicodevector{001}
%D \showunicodevector{002}
%D \showunicodevector{003}
%D \showunicodevector{004}
%D \showunicodevector{005}
%D \showunicodevector{030}
%D \showunicodevector{031}
%D \showunicodevector{032}
%D \showunicodevector{033}
%D \showunicodevector{034}
%D \stoptyping

%D \macros
%D   {showunicodetable}
%D
%D A more verbose variant:

\gdef\doshowunicodetablerow#1#2%
  {\bTR
   \bTD\uchexnumber{#2}\eTD
   \dostepwiserecurse{0}{15}{1}
     {\bTD
      \edef\entrypoint{\the\numexpr#1*256+#2+##1*16\relax}%
      \chardef\utfunicodetracer0{\dontleavehmode   \strut\unicodechar\entrypoint\endgraf}%
      \tt
      \chardef\utfunicodetracer7{\dontleavehmode\txx\strut\unicodechar\entrypoint\endgraf}%
      \chardef\utfunicodetracer3{\dontleavehmode\txx\strut\unicodechar\entrypoint\endgraf}%
      \chardef\utfunicodetracer8{\dontleavehmode\txx\strut\unicodechar\entrypoint\endgraf}%
      \eTD}%
   \bTD\uchexnumber{#2}\eTD
   \eTR}

\gdef\showunicodetable#1%
  {\vbox\bgroup
   \setupTABLE[\c!background=\v!screen,\c!backgroundscreen=.90,\c!frame=\v!off,\c!frameoffset=0pt,\c!width=8em,\c!height=6em]%
   \setupTABLE[c]     [\v!each] [\c!align={middle,lohi}]%
   \setupTABLE[c]     [\v!first][\c!background=\v!screen,\c!backgroundscreen=.85,\c!style=\tt\tfa]%
   \setupTABLE[c]     [\v!last] [\c!background=\v!screen,\c!backgroundscreen=.85,\c!style=\tt\tfa]%
   \setupTABLE[r]     [\v!first][\c!background=\v!screen,\c!backgroundscreen=.85,\c!style=\tt\tfa]%
   \setupTABLE[r]     [\v!last] [\c!background=\v!screen,\c!backgroundscreen=.85,\c!style=\tt\tfa]%
   \setupTABLE[r]     [\v!odd]  [\c!background=\v!screen,\c!backgroundscreen=.80]%
   \setupTABLE[c]     [\v!odd]  [\c!background=\v!screen,\c!backgroundscreen=.80]%
   \setupTABLE[\v!odd][\v!odd]  [\c!background=\v!screen,\c!backgroundscreen=.90]%
   \bTABLE
     \bTR
       \bTD dec: \numbers{#1}\endgraf hex: \uchexnumbers{#1}\eTD
       \dostepwiserecurse{0}{15}{1}{\bTD\uchexnumber{##1}\eTD}%
       \bTD dec: \numbers{#1}\endgraf hex: \uchexnumbers{#1}\eTD
     \eTR
     \dostepwiserecurse{0}{15}{1}{\doshowunicodetablerow{#1}{##1}}%
     \bTR
       \bTD dec: \numbers{#1}\endgraf hex: \uchexnumbers{#1}\eTD
       \dostepwiserecurse{0}{15}{1}{\bTD\uchexnumber{##1}\eTD}%
       \bTD dec: \numbers{#1}\endgraf hex: \uchexnumbers{#1}\eTD
     \eTR
   \eTABLE
   \egroup}

\protect \endinput

% alternative
%
% \gdef\doshowunicodevectorrowa#1#2#3#4%
%   {\NC
%    \ttx\uchexnumber{#2}%
%    \VL
%    \dostepwiserecurse{#3}{#4}{1}{\unicodechar{\numexpr#1*256+#2+\recurselevel*16\relax}\VL}%
%    \AR}
%
% \gdef\doshowunicodevectorrowb#1#2#3#4%
%   {\NC
%    \relax
%    \VL
%    \dostepwiserecurse{#3}{#4}{1}{\unicodechar{\numexpr#1*256+#2+\recurselevel*16\relax}\VL}%
%    \AR}
%
% \gdef\showunicodevector#1%
%   {\starttable[|c|c|c|c|c|c|c|c|c|]
%      \NC\NC\dostepwiserecurse{0}{7}{1}{\ttx\uchexnumber\recurselevel/\uchexnumber{\the\numexpr2*\recurselevel\relax}\NC}\AR\DC\DL[8]\DR
%      \dostepwiserecurse{0}{15}{1}
%        {\expanded{\doshowunicodevectorrowa{#1}{\recurselevel}{0} {7}}\DC\DL[8]\DR%
%         \expanded{\doshowunicodevectorrowb{#1}{\recurselevel}{8}{15}}\DC\DL[8]\DR}%
%      \NC \use{9}{\hfill \ttx unicode table hex:\uchexnumbers{#1} dec:\threedigits{#1}\kern-.25em}\NC \AR
%    \stoptable}