c9769b65acb2e977f19a12cb591b41e2b5081194
[m17n/m17n-docs.git] / data / dbformat.txt
1 /***en @page m17nDBFormat Data format of the m17n database
2
3 This section describes the data formats of the m17n database. */
4
5 /***en
6
7 @section m17nDBgeneral General format
8
9 @subsection description DESCRIPTION
10
11 The mdatabase_load () function returns the data specified by tags in
12 the form of plist if the first tag is not @c Mchartable nor @c
13 Mcharset.  The keys of the returned plist are limited to
14 <tt>Minteger</tt>, <tt>Msymbol</tt>, <tt>Mtext</tt>, and
15 <tt>Mplist</tt>.  The type of the value is unambiguously determined by
16 the corresponding key.  If the key is <tt>Minteger</tt>, the value is
17 an integer.  If the key is <tt>Msymbol</tt>, the value is a symbol.
18 And so on.
19
20 A number of expressions are possible to represent a plist.  For
21 instance, we can use the form <tt>(K1:V1, K2:V2, ..., Kn:Vn)</tt> to
22 represent a plist whose first property key and value are K1 and V1,
23 second key and value are K2 and V2, and so on.  However, we can use a
24 simpler expression here because the types of plists used in the m17n
25 database are fairly restricted.
26
27 Hereafter, we use an expression, which is similar to S-expression, to
28 represent a plist.  (Actually, the default database loader of the m17n
29 library is designed to read data files written in this expression.)
30
31 The expression consists of one or more <i>elements</i>.  Each element
32 represents a property, i.e. a single element of a plist.
33
34 Elements are separated by one or more <i>whitespaces</i>, i.e. a space
35 (code 32), a tab (code 9), or a newline (code 10).  Comments begin
36 with a semicolon (<tt>;</tt>) and extend to the end of the line.
37
38 The key and the value of each property are determined based on the
39 type of the element as explained below.
40
41 <ul>
42
43 <li> INTEGER
44
45 An element that matches the regular expression <tt>-?[0-9]+</tt> or
46 <tt>0[xX][0-9A-Fa-f]+</tt> represents a property whose key is
47 <tt>Minteger</tt>.  An element matching the former expression is
48 interpreted as an integer in decimal notation, and one matching the
49 latter is interpreted as an integer in hexadecimal notation.  The
50 value of the property is the result of interpretation.
51
52 For instance, the element <tt>0xA0</tt> represents a property whose value is
53 160 in decimal.
54
55 <li> SYMBOL
56
57 An element that matches the regular expression
58 <tt>[^-0-9(]([^\\()]|\\.)+</tt> represents a property whose key is
59 <tt> Msymbol</tt>.  In the element, <tt>\\t</tt>, <tt>\\n</tt>,
60 <tt>\\r</tt>, and <tt>\\e</tt> are replaced with tab (code 9), newline
61 (code 10), carriage return (code 13), and escape (code 27)
62 respectively.  Other characters following a backslash is interpreted
63 as it is.  The value of the property is the symbol having the
64 resulting string as its name.
65
66 For instance, the element <tt>abc\ def</tt> represents a property
67 whose value is the symbol having the name "abc def".
68
69 <li> M-TEXT
70
71 An element that matches the regular expression <tt>"([^"]|\\")*"</tt>
72 represents a property whose key is <tt>Mtext</tt>.  The backslash escape
73 explained above also applies here.  Moreover, each part in the
74 element matching the regular expression <tt>
75 \\[xX][0-9A-Fa-f][0-9A-Fa-f]</tt> is replaced with its hexadecimal
76 interpretation.
77
78 After having resolved the backslash escapes, the byte sequence between
79 the double quotes is interpreted as a UTF-8 sequence and decoded into
80 an M-text.  This M-text is the value of the property.
81
82 <li> PLIST
83
84 Zero or more elements surrounded by a pair of parentheses represent a
85 property whose key is <tt>Mplist</tt>.  Whitespaces before and after a
86 parenthesis can be omitted.  The value of the property is a plist,
87 which is the result of recursive interpretation of the elements
88 between the parentheses.
89
90 </ul>
91
92 @subsection example EXAMPLE
93
94 Here is an example of plist that is written in the expression
95 explained above.
96
97 @verbatim
98 abc 123 (pqr 0xff) "m\"text" (_\\_ ("string" xyz) -456)
99 @endverbatim
100
101 It represents the following plist:
102
103 @verbatim
104 (Msymbol:abc,
105  Minteger:123,
106  Mplist:(Msymbol:pqr,
107          Minteger:255),
108  Mtext:m"text,
109  Mplist:(Msymbol:_\_,
110          Mplist:(Mtext:string,
111                  Msymbol:xyz),
112          Minteger:-456))
113 @endverbatim
114 */
115 /***en
116
117 @section m17nDBflt Font Layout Table
118
119 @subsection description DESCRIPTION
120
121 Usually, the rendering engine converts character codes of into glyph
122 codes one by one by consulting information about encoding of each
123 selected font.  But, for rendering a text that requires complicated
124 layouting (e.g. Thai and Indic), such an one to one conversion is not
125 sufficient.  In addition, some glyphs must be shifted 2-dimensionally
126 on the screen.  For such a case, a font layout table (FLT in short)
127 must be used.
128
129 A FLT can contain the information equivarent to OpenType Layout Table
130 (CMAP, GSUB, and GPOS) in addition to the information about how to
131 extract a grapheme cluster and how to re-order characters.
132
133 The m17n library loads a FLT from the m17n database by the tags
134 \<font, layouter, FLT-NAME\>.  The plist format of the data is as
135 follows:
136
137 @verbatim
138 FONT-LAYOUT-TABLE ::=
139     '(' CATEGORY-TABLE GENERATOR
140         ( CATEGORY-TABLE ? GENERATOR ) * ')'
141
142 CATEGORY-TABLE ::=
143     '(' 'category' CATEGORY-SPEC + ')'
144
145 CATEGORY-SPEC ::=
146     '(' ( CODE | CODE-FROM CODE-TO ) CATEGORY-CODE ')'
147
148 CATEGORY-CODE ::=
149     [ '?A' | ... | '?Z' | '?a' | ... | '?z' ]
150
151 GENERATOR ::=
152     '(' 'generator' RULE RULE-DEF * ')'
153
154 RULE-DEF ::=
155     '(' RULE-NAME RULE ')'
156
157 RULE ::=
158     REGEXP-RULE | MATCH-RULE | MAP-RULE | PREDEFINED-RULE
159     | OTF-RULE
160
161 REGEXP-RULE ::=
162     '(' REGEXP RULE * ')' | RULE-NAME
163
164 MATCH-RULE ::=
165     '(' MATCH-IDX RULE * ')' | RULE-NAME
166
167 PREDEFINED-RULE ::= 
168     '=' | '*' | '<' | '>' | '|'
169
170 OTF-URLE ::=
171     'otf:SCRIPT-TAG[:LANGSYS-TAG]' 
172   where
173     SCRIPT-TAG is OTF's ScriptTag name (four letters) listed at:
174         <http://www.microsoft.om/typograph/otspec/scripttags.htm>
175     LANGSYS-TAG is OTF's Language System name (four letters) listed at:
176         <http://www.microsoft.om/typograph/otspec/languagetags.htm>
177   Example: 'otf:deva'
178
179 MAP-RULE ::=
180     '(' ( SEQ-TO-SEQ | RANGE-TO-CODE ) + ')' | RULE-NAME
181
182 SEQ-TO-SEQ ::=
183     '(' CODE + '-1' ( COMBINING ? CODE ) * ')'
184
185 RANGE-TO-CODE ::=
186     '(' '(' CODE-FROM CODE-TO ')' COMBINING ? CODE ')'
187
188 COMBINING ::=
189     'VHOVH'
190   where V ::= ( 't' | 'c' | 'b' | 'B' )
191         H ::= ( 'l' | 'c' | 'r' )
192         O ::= ( '.' | XOFF | YOFF XOFF ? )
193         XOFF ::= ('<' | '>') DIGITS
194         YOFF ::= ('+' | '-') DIGITS
195   Example: 'tc+bc', 'Bl-10<20Br'
196
197 Semantics of PREDEFINED-RULE:
198
199  '*': repeat the previous command (if successful)
200  '<': start grapheme cluster
201  '>': end grapheme cluster
202  '|': produce a special glyph that has category-code ' '
203  '=': use the first glyph of the current run as is
204 @endverbatim
205
206 @subsection seealso SEE ALSO
207
208 m17nDBgeneral(5)
209 */
210 /***en
211
212 @section m17nDBfontenc Font Encoding
213
214 The m17n library loads information about the encoding of each font
215 form the m17n database by the tags \<font, encoding\>.  The plist
216 format of the data is as follows:
217
218 @verbatim
219 FONT-ENCODING ::=
220     PER-FONT-INFO *
221
222 PER-FONT-INFO ::=
223     '(' FONT-SPEC ENCODING ')'
224
225 FONT-SPEC ::=
226     '(' 
227     [ FOUNDRY FAMILY [ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ] ] ] ] ] REGISTRY
228     ')'
229 @endverbatim
230
231 @c FOUNDRY to @c REGISTRY are symbols specifying the corresponding
232 XLFD font name fields.  Omitted symbols are regarded as @c nil, and
233 @c nil means a wild card.  For instance, this @c FONT-SPEC:
234
235 @verbatim
236     (nil alice0\ lao iso8859-1)
237 @endverbatim
238
239 should be applied to all fonts whose family is "alice0 lao", and
240 registry is "iso8859-1".
241
242 @c ENCODING is a symbol representing a charset.  A font matching @c
243 FONT-SPEC supports all characters of the charset, and a character code
244 is mapped to the corresponding glyph code of the font by this charset.
245 */
246 /***en
247
248 @section m17nDBfontset Fontset
249
250 The m17n library loads a fontset definition from the m17n database by
251 the tags \<fontset, FONTSET-NAME\>.  The plist format of the data is
252 as follows:
253
254 @verbatim
255 FONTSET ::=
256     PER-SCRIPT * PER-CHARSET * FALLBACK *
257
258 PER-SCRIPT ::=
259     '(' SCRIPT PER-LANGUAGE + ')'
260
261 PER-LANGUAGE ::=
262     '(' LANGUAGE FONT-SPEC-ELEMENT + ')'
263
264 PER-CHARSET ::=
265     '(' CHARSET FONT-SPEC-ELEMENT + ')'
266
267 FALLBACK ::=
268     FONT-SPEC-ELEMENT
269
270 FONT-SPEC-ELEMENT ::=
271     '(' FONT-SPEC [ FLT-NAME ] ')'
272
273 FONT-SPEC ::=
274     '(' 
275     [ FOUNDRY FAMILY [ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ] ] ] ] ] REGISTRY
276     ')'
277 @endverbatim    
278
279 @c SCRIPT is a symbol of script name (e.g. latin, han) or @c nil.  @c
280 LANGUAGE is a two-letter symbol of language name code defined by ISO
281 639 (e.g. ja, zh) or @c nil.  The meanings of @c FOUNDRY to @c
282 REGISTRY are the same as @e Font @e Encoding.  @c FLT-NAME is a name
283 of @ref flt.
284
285 For instance, this @c PER_SCRIPT:
286
287 @verbatim
288 (han
289   (ja
290     ((jisx0208.1983-0)))
291   (zh
292     ((gb2312.1980-0)))
293   (nil
294     ((big5-0))))
295 @endverbatim
296
297 instructs the rendering engine to use a font of registry
298 "jisx0208.1983-0" for a "han" character that has @c Mlanguage text
299 propert "ja" if the character is in the repertories of such fonts.
300 Otherwise, try a font of registry "gb2312.1980-0" or "big5-0".  If a
301 "han" character does not have @c Mlangauge text property, try all
302 three fonts.
303 */
304 /***en
305
306 @section m17nDBfontsize Font Resizing
307
308 In some case, a font contains incorrect information about its size
309 (typically in the case of a hacked TrueType font), which results in a
310 bad text layout when such a font is used in combination with the other
311 fonts.  To overcome this problem, the m17n library loads information
312 about font-size correction from the m17n database by the tags \<font,
313 resize\>.  The plist format of the data is as follows:
314
315 @verbatim
316 FONT-RESIZE ::=
317     PER-FONT-INFO *
318
319 PER-FONT-INFO ::=
320     '(' FONT-SPEC RESIZE-RATIO ')'
321
322 FONT-SPEC ::=
323     '(' 
324     [ FOUNDRY FAMILY [ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ] ] ] ] ] REGISTRY
325     ')'
326 @endverbatim
327
328 The meanings of @c FOUNDRY to @c REGISTRY are the same as @e Font @e
329 Encoding.  @c RESIZE-RATIO is an integer number specifying by
330 percentage how much the font-size must be adjusted.  For instance,
331 this @c PER-FONT-INFO:
332
333 @verbatim
334     ((devanagari-cdac) 150)
335 @endverbatim
336
337 means that, to use a font of registry "devanagari-cdac" with a
338 specific size, we have to open an 1.5 times bigger one.
339 */
340 /***en
341
342 @section m17nDBinput Input Metod
343
344 @verbatim
345 INPUT-METHOD ::=
346     '(' TITLE MAP-LIST MODULE-LIST ? STATE-LIST ')'
347
348 TITLE ::=
349     '(' title MTEXT ')'
350
351 MAP-LIST ::=
352     '(' 'map' MAP * ')'
353
354 MAP ::=
355     '(' MAP-NAME RULE * ')'
356
357 MAP-NAME ::=
358     symbol
359
360 RULE ::=
361     '(' KEYSEQ MAP-ACTION * ')'
362
363 KEYSEQ ::=
364     mtext | '(' [ symbol | integer ] * ')'
365
366 MAP-ACTION ::=
367     ACTION
368
369 ACTION ::=
370     mtext | CANDIDATES | '(' ACTION-NAME ACTION-ARG * ')'
371
372 CANDIDATES ::=
373     '(' CANDIDATE-GROUP * ')'
374
375   (in ASCTION,
376         MTEXT is a short form of "(insert MTEXT)"
377         CANDIDATES is a short form of "(candidates CANDIDATE-GROUP *)")
378
379 ACTION-NAME ::=
380     'insert' | 'candidates' | 'delete' | 'select' | 'select-group'
381         | 'move' | 'mark' | 'pushback' | 'undo' | 'shift' | 'call'
382
383 ACTION-ARG ::=
384         integer | symbol | mtext | CANDIDATE-GROUP
385
386 CANDIDATE-GROUP ::=
387         mtext | '('  mtext * ')'
388
389 PREDEFINED-SYMBOL ::=
390     '@0' | '@1' | '@2' | '@3' | '@4' | '@5' | '@6' | '@7' | '@8' | '@9'
391     | '@<' | '@=' | '@>' | '@-' | '@+'
392
393 MARKER ::=
394     PREDEFINED-SYMBOL | symbol
395
396 CANDIDATE-INDEX ::=
397     PREDEFINED-SYMBOL
398
399 CANDIDATE-GROUP-INDEX ::=
400     PREDEFINED-SYMBOL
401
402 ;; The first five actions ('insert' .. 'select-group') are for
403 ;; editing a text in the preediting buffer.  The buffer can keep
404 ;; multiple markers.  Each marker is represented by a symbol, and
405 ;; keeps a position between characters in the preediting buffer.
406
407 ;; PREDEFINED-SYMBOL has special meanings when used as MARKER:
408 ;;   '@0', '@1', ... '@9'
409 ;;      The 0th, 1th, ... 9th position.
410 ;;   '@<', '@=', '@>'
411 ;;      The first, current, and end position.
412 ;;   '@-', '@+'
413 ;;      The previous and next position.
414
415 ;; PREDEFINED-SYMBOL has special meanings when used as CANDIDATE-INDEX:
416 ;;   '@0', '@1', ... '@9'
417 ;;      The 0th, 1th, ... 9th candidate of the current candidate group.
418 ;;   '@<', '@=', '@>'
419 ;;      The first, current, and end candidate of the current candidate
420 ;;      group.
421 ;;   '@-'
422 ;;      The previous candidate.  If the current candidate is the
423 ;;      first of the current candidate group, the last candidate of
424 ;;      the previous candidate group.
425 ;;   '@+'
426 ;;      The next candidate.  If the current candidate is the last of
427 ;;      the current candidate group, the first candidate of the
428 ;;      previous candidate group.
429
430 ;; PREDEFINED-SYMBOL has special meanings when used as CANDIDATE-INDEX:
431 ;;   '@0', '@1', ... '@9'
432 ;;      The 0th, 1th, ... 9th candidate of the current candidate group.
433 ;;   '@<', '@=', '@>'
434 ;;      The first, current, and end candidate of the current candidate
435 ;;      group.
436 ;;   '@-'
437 ;;      The previous candidate.  If the current candidate is the
438 ;;      first of the current candidate group, the last candidate of
439 ;;      the previous candidate group.
440 ;;   '@+'
441 ;;      The next candidate.  If the current candidate is the last of
442 ;;      the current candidate group, the first candidate of the
443 ;;      previous candidate group.
444
445 ;; PREDEFINED-SYMBOL has special meanings when used as
446 ;; CANDIDATE-GROUP-INDEX:
447 ;;   '@0', '@1', ... '@9'
448 ;;      The 0th, 1th, ... 9th candidate group.
449 ;;   '@<', '@=', '@>'
450 ;;      The first, current, and end candidate group.
451 ;;   '@-', '@+'
452 ;;      The previous and the next candidate group.
453
454 ;; (insert MTEXT) inserts MTEXT before @=.
455
456 ;; (candidates CANDIDATE-GROUP *) set the current candidates list
457 ;; to the list of arguments, set the current candidate group to the
458 ;; first argument, insert the first candidate of the current group
459 ;; before @=, and mark the inserted text as the current candidate.
460 ;; Each element of CANDIDATE-GROUP represents a candidate, i.e. if
461 ;; CANDIDATE-GROUP is MTEXT, each character in MTEXT is a
462 ;; candidate, if CANDIDATE-GROUP is a list of MTEXT, each MTEXT is
463 ;; a candidate.
464
465 ;; (select CANDIDATE-INDEX) replaces the current candidate with
466 ;; what specified by CANDIDATE-INDEX.  If a candidate of the
467 ;; different candidate group is specified, set the current
468 ;; candidate group to that group.
469
470 ;; (select-group CANDIDATE-GROUP-INDEX) sets the current candidate
471 ;; group to a group indicated by CANDIDATE-GROUP-INDEX, and relaces
472 ;; the current candiate with the candiate of the same index in the
473 ;; new group.
474
475 ;; (delete MARKER) deletes characters between @= and the position
476 ;; specified by MARKER.
477
478 ;; (move MARKER) sets @= to the position of specified by MARKER.
479
480 ;; (mark MARKER) sets MARKER to the position of @=.  MARKER must
481 ;; not be PREDEFINED-SYMBOL.
482
483 ;; (pushback) pushbacks the latest key events to the event queue.
484
485 ;; (undo) cancels the last key events.
486
487 ;; (shift STATE-NAME) shifts the current state to the state
488 ;; specified by STATE-NAME.
489
490 ;; (call FUNCTION ARG *) calls the function FUNCTION of an external
491 ;; module.  FUNCTION must be defined in MODULE-LIST.
492
493 ;; The function is called with a property list (MPlist *) that has
494 ;; these properties in this order.
495 ;;   KEY                VALUE
496 ;;   ---                -----
497 ;;   mtext              The current preedit text.
498 ;;   symbol             The current state name (MSymbol).
499 ;; The remaining properties (if any) are ARGs.
500 ;;
501 ;; The function must return a property list (MPlist *) that
502 ;; represents a list of ACTIONs to take.
503
504 MODULE-LIST ::=
505     '(' 'module' MODULE * ')'
506
507 MODULE ::=
508     '(' MODULE-NAME FUNCTION * ')'
509
510 MODULE-NAME ::=
511     mtext
512
513 FUNCTION ::=
514     symbol
515
516 STATE-LIST ::=
517     '(' 'state' STATE * ')'
518
519 STATE ::=
520     '(' STATE-NAME BRANCH * ')'
521
522 STATE-NAME ::=
523     symbol
524
525 BRANCH ::=
526     '(' [ MAP-NAME | 'nil' ]  BRANCH-ACTION * ')'
527
528 ;; If MAP-NAME is specified, it must be a name of a map defined in
529 ;; MAP-LIST.  Otherwise, BRANCH is the default branch of STATE.
530
531 BRANCH-ACTION ::=
532     ACTION
533
534
535 ;; Example:
536
537 (title "sample")
538 (maps
539  (single
540   ("a" "A")
541   ("b" "B"))
542  (double
543   ("bb" (("BB" "Bb"))))
544  (select
545   ((Left) (select @-))
546   ((Right) (select @+))))
547
548 (states
549  (init
550   (single)
551   (double (shift selection)))
552  (selection
553   (select)))
554   
555 ;; When this input method is loaded, the following state transition
556 ;; machine is created.
557
558 ;; STATE-TRANSITION-MACHINE ::=
559 ;;      '(' STATE-NAME ROOT-MAP ')' *
560 ;; ROOT-MAP ::= TRANSITION-MAP
561 ;; TRANSITION-MAP ::=
562 ;;      '(' INDEX [ KEY | 'nil' ]
563 ;;          MAP-ACTIONS TRANSITION-MAPS BRANCH-ACTIONS ')'
564 ;; TRANSITION-MAPS ::=
565 ;;      '(' TRANSITION-MAP * ')'
566 ;; MAP-ACTIONS ::=
567 ;;      '(' MAP-ACTION * ')'
568 ;; BRANCH-ACTIONS ::=
569 ;;      '(' BRANCH-ACTION * ')'
570
571 (init
572  (#0 nil nil
573     ((#1 'a' ((insert "A")) nil nil)
574      (#2 'b' ((insert "B"))
575         ((#3 'b' ((candidates (("BB" "Bb")))) nil (shift selection)))
576         nil))
577     nil))
578 (selection
579  (#4 nil nil
580      ((#5 'Left' ((delete @<) (select @-)) nil nil)
581       (#6 'Right' ((delete @<) (select @+)) nil nil))
582     nil))
583
584 ;; The state transition machine keeps these things:
585 ;; STATE: the current state, initially 'init'.
586 ;; MAP: current transition map, initially #0.
587 ;; PREEDIT: the preediting buffer, initially empty.
588 ;; MARKERS: the positions assigned to each marker, @= is initially 0.
589 ;; PRODUCED: the produced text, initially empty.
590 ;; CANDIDATE-LIST: the current candidate group list, initially NULL.
591 ;; CANDIDATE-GROUP: the current candidate group, initially NULL.
592 ;; CANDIDATE: the the current candidate, initially NULL.
593 ;;
594 ;; When MAP is changed to the root map of the initial state, PREEDIT
595 ;; is concatenated to PRODUCED and reset to empty.  This way, the
596 ;; machine produces a text.
597 ;;
598 ;; The machine accepts one key KEY, handles it while updating internal
599 ;; information, and return 'nil' (if KEY is correctly handled) or KEY
600 ;; (if KEY can't be handled in the machine).
601
602 ;; Here we describes how the key sequence:
603 ;;      'a' 'b' 'b' 'Right' 'b' 'a'
604 ;; is handled by the machine and "aBbba" is produced.
605
606 ;; 'a' arrives.
607 ;;
608 ;; Lookup the transition maps of #0 for 'a' and find #1.  Change MAP
609 ;; to #1.  Perform its map actions.  Now PREEDIT contains "a".  As it
610 ;; has no sub transition maps, no branch actions, no state to shift,
611 ;; change MAP to #0, the root map of the current state.
612 ;;
613 ;; As we have changed MAP to the root map of the initial map,
614 ;; concatenate PREEDIT to PRODUCED, and reset PREEDIT to empty.
615 ;;
616 ;; Now we have consumed the key.  As MAP has sub transition maps, wait
617 ;; for the next key.
618
619 ;; 'b' arrives.
620 ;;
621 ;; Lookup #0 for 'b' and find #2.  Change MAP to #2.  Perform the map
622 ;; actions.  Now, PREEDIT contains "B".  As it has sub transition
623 ;; maps, and we have consumed the key, wait for the next key.
624
625 ;; 'b' arrives.
626 ;;
627
628 ;; Lookup #2 for 'b' and find #3.  Cancel the change in PREEDIT done
629 ;; by the map actions of #2, and change MAP to #3.  Perform the map
630 ;; actions.  Now, PREEDIT is "BB", CANDIDATE-LIST is (("BB" "Bb")),
631 ;; CANDIDATE is "BB".  As #3 has no sub transition maps and no branch
632 ;; actions, change STATE to 'selection' and change MAP to #4, the root
633 ;; map of 'selection'.  As it has sub transition maps, and we have
634 ;; consumed the key.  Wait for the next key.
635
636 ;; 'Right' arrives.
637 ;;
638 ;; Lookup #4 for 'Right' and find #5.  Change MAP to #5.  Perform the
639 ;; map actions.  Now PREEDIT is "Bb".  As #5 has no sub transition
640 ;; maps, no branch actions, no state to shift, change MAP to #4 (the
641 ;; initial map of the current state 'selection'.
642 ;;
643 ;; As #4 has sub transition maps, and we have consumed the key.  Wait
644 ;; for the next key.
645
646 ;; 'b' arrives.
647 ;;
648 ;; Lookup #4 for 'b' and fail.  As #4 has no branch maps, no shift to
649 ;; transit, change STATE to 'init', MAP to #0.
650 ;;
651 ;; As we have changed MAP to the root map of the initial map,
652 ;; concatenate PREEDIT to PRODUCED, and reset PREEDIT to empty.  Now
653 ;; PRODUCED has "aBb".
654 ;;
655 ;; As we have not yet consumed the key 'b', handle it in MAP (#0).
656 ;;
657 ;; Lookup #0 for 'b' and find #2.  Change MAP to #2.  Perform the map
658 ;; actions.  Now, PREEDIT contains "B".  As it has sub transition
659 ;; maps, and we have consumed the key, wait for the next key.
660
661 ;; 'a' arrives.  Lookup #2 for 'a' and fail.  As #2 has no branch
662 ;; actions, no state to shift, Change MAP to #0, the root map of the
663 ;; current state.
664 ;;
665 ;; As we have changed MAP to the root map of the initial map,
666 ;; concatenate PREEDIT to PRODUCED, and reset PREEDIT to empty.  Now
667 ;; PRODUCED has "aBbb".
668 ;;
669 ;; As we have not yet consumed the key 'a', handle it in MAP (#0).
670 ;;
671 ;; Lookup #0 for 'a' and find #1.  Change MAP to #1.  Perform its map
672 ;; actions.  Now PREEDIT contains "a".  As it has no sub transition
673 ;; maps, no branch actions, no state to shift, change MAP to #0, the
674 ;; root map of the current state.
675 ;;
676 ;; As we have changed MAP to the root map of the initial map,
677 ;; concatenate PREEDIT to PRODUCED, and reset PREEDIT to empty.  Now
678 ;; PRODUCED has "aBbba".
679
680 ;; Now we have consumed the key.  As MAP has sub transition maps, wait
681 ;; for the next key.
682 @endverbatim
683 */
684 ////