summaryrefslogtreecommitdiff
path: root/doc/context/presentations/context/2011/context-2011-sorting-registers.tex
blob: f05290906df276ceb4cc261f57e2c08b47b682f4 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
% tests/mkiv/scripts/korean-005.tex
% examplex elsewhere

% \enablemode[print]

\usemodule[present-overlap,abr-02]

\startdocument
  [title=Sorting,
   subtitle=registers,
   location=\ConTeXt\ Meeting 2011]

\startluacode

local function show(t,start,stop)
    if type(t) == "table" then
        start = start or 1
        stop = stop or #t
        for i=start,stop do
            if i > start then
                context.space()
            end
            if type(t[i]) == "number" then
                context(utf.char(t[i]))
            else
                context(t[i])
            end
        end
    elseif type(t) == "string" then
        context(t)
    elseif type(t) == "number" then
        context(utf.char(t))
    end
end

function context.ShowCharacterData(n)
    local d = characters.data[n]
    if d then
        local bTR, bTD, eTD, eTR = context.bTR, context.bTD, context.eTD, context.eTR
        context.bTABLE()
            bTR() bTD() context("unicode")  eTD() bTD() show(n)                      eTD() eTR()
            bTR() bTD() context("shcode")   eTD() bTD() show(characters.shchars [n]) eTD() eTR()
            bTR() bTD() context("lccode")   eTD() bTD() show(characters.lcchars [n]) eTD() eTR()
            bTR() bTD() context("uccode")   eTD() bTD() show(characters.ucchars [n]) eTD() eTR()
            bTR() bTD() context("fscode")   eTD() bTD() show(characters.fschars [n]) eTD() eTR() -- leadconsonant
            bTR() bTD() context("specials") eTD() bTD() show(
               characters.remap_hangul_syllabe(characters.specials[n]),2) eTD() eTR()
        context.eTABLE()
    end
end

\stopluacode

\unexpanded\def\ShowCharacterData#1{\cldcommand{ShowCharacterData("#1")}}

\Topic{The old way}

\StartSteps
\startitemize
\startitem in \MKII\ sorting is delegated to \TEXUTIL\ i.e.\ a multipass action \stopitem \FlushStep
\startitem encoding vectors are passed along \stopitem \FlushStep
\startitem sort vectors depend on the language \stopitem \FlushStep
\startitem there are the usual complications with direct characters and commands \stopitem \FlushStep
\stopitemize
\StopSteps

\Topic{Moving on}

\StartSteps
\startitemize
\startitem in \MKIV\ sorting happens during the run \stopitem \FlushStep
\startitem we only have to deal with \UNICODE\ (utf) \stopitem \FlushStep
\startitem sort vectors still depend on the language \stopitem \FlushStep
\startitem sorting can be controlled by methods \stopitem \FlushStep
\startitem there is no universal solution (conflicting user demands, mixed languages) \stopitem \FlushStep
\stopitemize
\StopSteps

\Topic{Character data}

\setupTABLE[background=color,backgroundcolor=lightgray,rulethickness=.75bp,framecolor=darkgray]

\StartSteps
\startcombination[5*1]
    {\definedfont[Normal*none]\ShowCharacterData{a}}            {regular\FlushStep}
    {\definedfont[Normal*none]\ShowCharacterData{ä}}            {accent\FlushStep}
    {\definedfont[Normal*none]\ShowCharacterData{æ}}            {ligature\FlushStep}
    {\definedfont[adobemyungjostd-medium]\ShowCharacterData{그}} {hangul\FlushStep}
    {\definedfont[adobemyungjostd-medium]\ShowCharacterData{학}} {hangul\FlushStep}
\stopcombination
\StopSteps

\Topic{Sorting methods}

\StartSteps
\starttabulate[|l|l|r|]
    \NC ch \NC raw character \NC       \FlushStep \NC \NR
    \NC uc \NC unicode       \NC       \FlushStep \NC \NR
    \NC mm \NC mapping       \NC minus \FlushStep \NC \NR
    \NC zm \NC               \NC zero  \FlushStep \NC \NR
    \NC pm \NC               \NC plus  \FlushStep \NC \NR
    \NC mc \NC lower case    \NC minus \FlushStep \NC \NR
    \NC zc \NC               \NC zero  \FlushStep \NC \NR
    \NC pc \NC               \NC plus  \FlushStep \NC \NR
\stoptabulate
\StopSteps

\Topic{Predefined methods}

\StartSteps
\starttabulate[|l|l|]
    \NC before \NC mm,mc,uc \NC \NR
    \NC after  \NC pm,mc,uc \NC \NR
    \NC first  \NC pc,mm,uc \NC \NR
    \NC last   \NC mc,mm,uc \NC \NR
\stoptabulate

\FlushStep

\starttyping
\enabletrackers[sorters.tests]
\enabletrackers[sorters.methods]
\stoptyping

\FlushStep
\StopSteps

\Topic{An example (1)}

\startbuffer
àâá\index{àâá}
aaa\index{aaa}
aab\index{aab}
Aaa\index{Aaa}
Aab\index{Aab}
\stopbuffer

\StartSteps
\typebuffer \FlushStep

\startlines \getbuffer \stoplines \FlushStep
\StopSteps

\Topic{An example (2)}

% \enabletrackers[sorters.tests]
% \enabletrackers[sorters.methods]

\setupregister[index][criterium=text,n=1,before=,after=]
\defineframed[indexframed][align=normal,width=.2\textwidth,strut=no]

\StartSteps
\startcombination[4*1]
    {\setupinteraction[state=stop]\indexframed{\placeregister[index][method={mm,mc,uc}]}} {mm,mc,uc\FlushStep}
    {\setupinteraction[state=stop]\indexframed{\placeregister[index][method={pm,mc,uc}]}} {pm,mc,uc\FlushStep}
    {\setupinteraction[state=stop]\indexframed{\placeregister[index][method={pc,mm,uc}]}} {pc,mm,uc\FlushStep}
    {\setupinteraction[state=stop]\indexframed{\placeregister[index][method={mc,mm,uc}]}} {mc,mm,uc\FlushStep}
\stopcombination
\StopSteps

\stopdocument