*** empty log message ***
[m17n/m17n-db.git] / FORMATS / IM.txt
1 /* Copyright (C) 2003, 2004, 2005
2      National Institute of Advanced Industrial Science and Technology (AIST)
3      Registration Number H15PRO112
4    See the end for copying conditions.  */
5
6 /***en
7
8 @page mdbIM Input Method
9
10 @section im-description DESCRIPTION
11
12 The m17n library provides a driver for input methods that are
13 dynamically loadable from the m17n database (see @ref m17nInputMethod
14 @latexonly (P.\pageref{group__m17nInputMethod}) @endlatexonly).
15
16 This section describes the data format that defines those input
17 methods.
18
19 @section im-format SYNTAX and SEMANTICS
20
21 The following data format defines an input method.  The driver loads a
22 definition from a file, a stream, etc.  The definition is converted
23 into the form of plist in the driver.
24
25 @verbatim
26 INPUT-METHOD ::=
27     IM-DECLARATION ? IM-DESCRIPTION ? TITLE ?
28      VARIABLE-LIST ? COMMAND-LIST ?  MODULE-LIST ?
29      MACRO-LIST ? MAP-LIST ? STATE-LIST ?
30
31 IM-DECLARATION ::= '(' 'input-method' LANGUAGE NAME EXTRA-ID ? VERSION ? ')'
32 LANGUAGE ::= SYMBOL
33 NAME ::= SYMBOL
34 EXTRA-ID ::= SYMBOL
35 VERSION ::= '(' 'version' VERSION-NUMBER ')'
36
37 IM-DESCRIPTION ::= '(' 'description' DESCRIPTION ')'
38 DESCRIPTION ::= MTEXT-OR-GETTEXT | 'nil'
39 MTEXT-OR-GETTEXT ::=  [ MTEXT | '(' '_' MTEXT ')']
40
41 TITLE ::= '(' 'title' TITLE-TEXT ')'
42 TITLE-TEXT ::= MTEXT
43
44 VARIABLE-LIST ::= '(' 'variable' VARIABLE-DECLARATION * ')'
45 VARIABLE-DECLARATION ::=  '(' VAR-NAME [ DESCRIPTION VALUE VALUE-CANDIDATE * ]')'
46 VAR-NAME ::= SYMBOL
47 VALUE ::= MTEXT | SYMBOL | INTEGER
48 VALUE-CANDIDATE ::= VALUE | '(' RANGE-FROM RANGE-TO ')'
49 RANGE-FROM ::= INTEGER
50 RANGE-TO ::= INTEGER
51
52 COMMAND-LIST ::= '(' 'command' COMMAND-DECLARATION * ')'
53 COMMAND-DECLARATION ::=  '(' CMD-NAME [ DESCRIPTION KEYSEQ * ] ')'
54 CMD-NAME ::= SYMBOL
55
56 @endverbatim
57
58 @c IM-DECLARATION specifies the language and name of this input
59 method.  
60
61 When @c LANGUAGE is @c t, the use of the input method is not limited
62 to one language.
63
64 When @c NAME is @c nil, the input method is not standalone, but
65 is expected to be used in other input methods.  In such cases,
66 @c EXTRA-ID is required to identify the input method.
67
68 @c VERSION specifies the required minimum version number of the m17n
69 library.  The format is "XX.YY.ZZ" where XX is a major version
70 number, YY is a minor version number, and ZZ is a patch level.
71
72 @c DESCRIPTION, if not nil, specifies the description text of an input
73 method, a variable or a command.  If @c MTEXT-OR-GETTEXT takes the
74 second form, the text is translated according to the current locale by
75 "gettext" (if the translation is provided).
76
77 @c TITLE-TEXT is a text displayed on the screen when this input method
78 is active.
79
80 There is one special input method file "global.mim" that declares
81 common variables and commands.  The input method driver always loads
82 this file and other input methods can inherit the variables and the
83 commands.
84
85 @c VARIABLE-DECLARATION declares a variable used in this input method.
86 If a variable must be initialized to the default value, or is to be
87 customized by a user, it must be declared here.  The declaration can
88 be used in two ways.  One is to introduce a new variable.  In that
89 case, @c VALUE must not be omitted.  Another is to inherit the variable
90 from what declared in "global.mim", and to give the different default
91 value and/or to make the variable customizable specially for the
92 current input method.  In the latter case, @c VALUE can be omitted.
93
94 @c COMMAND-DECLARATION declares a command used in this input method.
95 If a command must be bound to the default key sequence, or is to be
96 customized by a user, it must be declared here.  Like @c
97 VARIABLE-DECLARATION, the declaration can be used in two ways.  One is
98 to introduce a new command.  In that case, @c KEYSEQ must not be omitted.
99 Another is to inherit the command from what declared in "global.mim",
100 and to give the different key binding and/or to make the command
101 customizable specially for the current input method.  In the latter
102 case, @c KEYSEQ can be omitted.
103
104
105 @verbatim
106 MODULE-LIST ::= '(' 'module' MODULE * ')'
107
108 MODULE ::= '(' MODULE-NAME FUNCTION * ')'
109
110 MODULE-NAME ::= SYMBOL
111
112 FUNCTION ::= SYMBOL
113 @endverbatim
114
115 Each @c MODULE declares the name of an external module (i.e. dynamic
116 library) and function names exported by the module.  If a @c FUNCTION has
117 name "init", it is called with only the default arguments (see the
118 section about @c CALL) when an input context is created for the input
119 method.  If a @c FUNCTION has name "fini", it is called with only the
120 default arguments when an input context is destroyed.
121
122 @verbatim
123 MACRO-LIST ::=  MACRO-INCLUSION ? '(' 'macro' MACRO * ')' MACRO-INCLUSION ?
124
125 MACRO ::= '(' MACRO-NAME MACRO-ACTION * ')'
126
127 MACRO-NAME ::= SYMBOL
128
129 MACRO-ACTION ::= ACTION
130
131 TAGS ::= `(` LANGUAGE NAME EXTRA-ID ? `)`
132
133 MACRO-INCLUSION ::= '(' 'include' TAGS 'macro' MACRO-NAME ? ')'
134
135 @endverbatim
136
137 @c MACRO-INCLUSION includes macros from another input method specified
138 by @c TAGS.  When @c MACRO-NAME is not given, all macros from the
139 input method are included.
140
141 @verbatim MAP-LIST ::= MAP-INCLUSION ? '(' 'map' MAP * ')'
142 MAP-INCLUSION ?
143
144 MAP ::= '(' MAP-NAME RULE * ')'
145
146 MAP-NAME ::= SYMBOL
147
148 RULE ::= '(' KEYSEQ MAP-ACTION * ')'
149
150 KEYSEQ ::= MTEXT | '(' [ SYMBOL | INTEGER ] * ')'
151
152 MAP-INCLUSION ::= '(' 'include' TAGS 'map' MAP-NAME ? ')'
153
154 @endverbatim
155
156 When an input method is never standalone and always included in
157 another method, @c MAP-LIST can be omitted.
158
159 @c SYMBOL in the definitions of @c MAP-NAME must not be @c t nor @c
160 nil.
161
162 @c MTEXT in the definition of @c KEYSEQ consists of characters that
163 can be generated by a keyboard.  Therefore @c MTEXT usually contains
164 only ASCII characters.  However, if the input method is intended to be
165 used, for instance, with a West European keyboard, @c MTEXT may
166 contain Latin-1 characters.
167
168 @c SYMBOL in the definition of @c KEYSEQ must be the return value of
169 the minput_event_to_key () function.  Under the X window system, you
170 can quickly check the value using the @c xev command.  For example,
171 the return key, the backspace key, and the 0 key on the keypad are
172 represented as @c (Return) , @c (BackSpace) , and @c (KP_0)
173 respectively.  If the shift, control, meta, alt, super, and hyper
174 modifiers are used, they are represented by the S- , C- , M- , A- , s-
175 , and H- prefixes respectively in this order.  Thus, "return with
176 shift with meta with hyper" is @c (S-M-H-Return) .  Note that "a with
177 shift" .. "z with shift" are represented simply as A .. Z . Thus "a
178 with shift with meta with hyper" is @c (M-H-A) .
179
180 @c INTEGER in the definition of @c KEYSEQ must be a valid character
181 code.
182
183 @c MAP-INCLUSION includes maps from another input method specified by
184 @c TAGS. When @c MAP-NAME is not given, all maps from the input method
185 are included.
186
187
188 @verbatim
189 MAP-ACTION ::= ACTION
190
191 ACTION ::= INSERT | DELETE | SELECT | MOVE | MARK
192            | SHOW | HIDE | PUSHBACK | POP | UNDO 
193            | COMMIT | UNHANDLE | SHIFT | CALL
194            | SET | IF | COND | '(' MACRO-NAME ')'
195
196 PREDEFINED-SYMBOL ::=
197     '@0' | '@1' | '@2' | '@3' | '@4'
198     | '@5' | '@6' | '@7' | '@8' | '@9'
199     | '@<' | '@=' | '@>' | '@-' | '@+' | '@[' | '@]'
200     | '@@'
201     | '@-0' | '@-N' | '@+N'
202 @endverbatim
203
204 @verbatim
205 STATE-LIST ::= STATE-INCUSION ? '(' 'state' STATE * ')'  STATE-INCUSION ?
206
207 STATE ::= '(' STATE-NAME [ STATE-TITLE-TEXT ] BRANCH * ')'
208
209 STATE-NAME ::= SYMBOL
210
211 STATE-TITLE-TEXT ::= MTEXT
212
213 BRANCH ::= '(' MAP-NAME BRANCH-ACTION * ')'
214            | '(' 'nil' BRANCH-ACTION * ')'
215            | '(' 't' BRANCH-ACTION * ')'
216
217 STATE-INCLUSION ::= '(' 'include' TAGS 'state' STATE-NAME ? ')'
218
219 @endverbatim
220
221 When an input system is never standalone and always included in
222 another system, @c STATE-LIST can be omitted.
223
224 @c STATE-INCLUSION includes states from another input method specified
225 by @c TAGS. When @c STATE-NAME is not given, all states from the input
226 method are included.
227
228 The optional @c STATE-TITLE-TEXT specifies a title text displayed on
229 the screen when the input method is in this state.  If @c
230 STATE-TITLE-TEXT is omitted, @c TITLE-TEXT is used.
231
232 In the first form of @c BRANCH, @c MAP-NAME must be an item that
233 appears in @c MAP.  In this case, if a key sequence matching one of @c
234 KEYSEQs of @c MAP-NAME is typed, @c BRANCH-ACTIONs are executed.
235
236 In the second form of @c BRANCH, @c BRANCH-ACTIONs are executed if a
237 key sequence that doesn't match any of @c Branch's of the current
238 state is typed.
239
240 If there is no @c BRANCH beginning with @c nil and the typed key
241 sequence does not match any of the current @c BRANCHs, the input
242 method transits to the initial state.
243
244 In the third form of @c BRANCH, @c BRANCH-ACTIONs are executed when
245 shifted to the current state.  If the current state is the initial
246 state, @c BRANCH-ACTIONs are executed also when an input context of
247 the input method is created.
248
249 @verbatim
250 BRANCH-ACTION ::= ACTION
251 @endverbatim
252
253 An input method has the following two lists of symbols.
254
255 <ul>
256 <li> marker list
257
258 A marker is a symbol indicating a character position in the preediting
259 text.  The @c MARK action assigns a position to a marker.  The
260 position of a marker is referred by the @c MOVE and the @c DELETE actions.
261
262 <li> variable list
263
264 A variable is a symbol associated with an integer, a symbol, or an
265 M-text value.  The integer value of a variable can be set and referred
266 by the @c SET action.  It can be referred by the @c SET, the @c
267 INSERT, the @c SELECT, the @c UNDO, the @c IF, the @c COND actions.
268 The M-text value of a variable can be referred by the @c INSERT
269 action.  The symbol value of a variable can not be referred directly,
270 is used the library implicitly (e.g. candidates-charset).  All
271 variables are implicitly initialized to the integer value zero.
272
273 </ul>
274
275 Each @c PREDEFINED-SYMBOL has a special meaning when used as a marker.
276
277 <ul>
278 <li> @c @@0, @c @@1, @c @@2, @c @@3, @c @@4, @c @@5, @c @@6, @c @@7, @c @@8, @c @@9
279
280 The 0th, 1st, 2nd, ... 9th position respectively.
281
282 <li> @c @@<, @c @@=, @c @@>
283
284 The first, the current, and the last position.
285
286 <li> @c @@-, @c @@+
287
288 The previous and the next position.
289
290 <li> @c @@[, @c @@]
291
292 The previous and the next position where a candidate list changes.
293 </ul>
294
295 Some of the @c PREDEFINED-SYMBOL has a special meaning when used as a candidate
296 index in the @c SELECT action.
297
298 <ul>
299
300 <li> @c @@<, @c @@=, @c @@>
301
302 The first, the current, and the last candidate of the current candidate group.
303
304 <li> @c @@-
305
306 The previous candidate.  If the current candidate is the first one in
307 the current candidate group, then it means the last candidate in the
308 previous candidate group.
309
310 <li> @c @@+
311
312 The next candidate.  If the current candidate is the last one in the
313 current candidate group, then it means the first candidate in the next
314 candidate group.
315
316 <li> @c @@[, @c @@]
317
318 The candidate in the previous and the next candidate group having the same
319 candidate index as the current one.
320 </ul>
321
322 And, this also has a special meaning.
323
324 <ul>
325 <li> @c @@@
326
327 Number of handled keys at that moment.
328
329 </ul>
330
331 These are for supporting surround text handling.
332
333 <ul>
334 <li> @c @@-0
335
336 -1 if surrounding text is supported, -2 if not.
337
338 <li> @c @@-N
339
340 Here, @c N is a positive integer.  The value is the Nth previous
341 character in the preedit buffer.  If there are only M (M<N) previous
342 characters in it, the value is the (N-M)th previous character from the
343 inputting spot.  When this is used as the argument of @c delete
344 action, it specifies the number of characters to be deleted.
345
346 <li> @c @@+N
347
348 Here, @c N is a positive integer.  The value is the Nth following
349 character in the preedit buffer.  If there are only M (M<N) following
350 characters in it, the value is the (N-M)th following character from
351 the inputting spot.  When this is used as the argument of @c delete
352 action, it specifies the number of characters to be deleted.
353 </ul>
354
355 The arguments and the behavior of each action are listed below.
356
357 @verbatim
358 INSERT ::= '(' 'insert' MTEXT ')'
359            | MTEXT
360            | INTEGER
361            | SYMBOL
362            | '(' 'insert' SYMBOL ')'
363            | '(' 'insert' '(' CANDIDATES * ')' ')'
364            | '(' CANDIDATES * ')' 
365
366 CANDIDATES ::= MTEXT | '(' MTEXT * ')'
367 @endverbatim
368
369 The first and second forms insert @c MTEXT before the current position.
370
371 The third form inserts the character @c INTEGER before the current
372 position.
373
374 The fourth and fith form treats @c SYMBOL as a variable, and inserts
375 its value (if it is a valid character code) before the current
376 position.
377
378 In the sixth and seventh forms, each @c CANDIDATES represents a
379 candidate group, and each element of @c CANDIDATES represents a
380 candidate, i.e. if @c CANDIDATES is an M-text, the candidates are the
381 characters in the M-text; if @c CANDIDATES is a list of M-texts, the
382 candidates are the M-texts in the list.
383
384 These forms insert the first candidate before the current position.
385 The inserted string is associated with the list of candidates and
386 the information indicating the currently selected candidate.
387
388 The marker positions affected by the insertion are automatically relocated.
389
390 @verbatim
391 DELETE ::= '(' 'delete' SYMBOL ')'
392            | '(' 'delete' INTEGER ')'
393 @endverbatim
394
395 The first form treats @c SYMBOL as a marker, and deletes characters
396 between the current position and the marker position.
397
398 The second form treats @c INTEGER as a character position, and deletes
399 characters between the current position and the character position.
400
401 The marker positions affected by the deletion are automatically relocated.
402
403 @verbatim
404 SELECT ::= '(' 'select' PREDEFINED-SYMBOL ')'
405            | '(' 'select' INTEGER ')'
406            | '(' 'select' SYMBOL ')'
407 @endverbatim
408
409 This action first checks if the character just before the current position
410 belongs to a string that is associated with a candidate list.  If it is,
411 the action replaces that string with a candidate specified by the
412 argument.
413
414 The first form treats @c PREDEFINED-SYMBOL as a candidate index (as
415 described above) that specifies a new candidate in the candidate list.
416
417 The second form treats @c INTEGER as a candidate index that specifies a
418 new candidate in the candidate list.
419
420 In the third form, @c SYMBOL must have a integer value, and it is treated 
421 as a candidate index.
422
423 @verbatim SHOW ::= '(show)' @endverbatim
424
425 This actions instructs the input method driver to display a candidate
426 list associated with the string before the current position.
427
428 @verbatim
429 HIDE ::= '(hide)'
430 @endverbatim
431
432 This action instructs the input method driver to hide the currently
433 displayed candidate list.
434
435 @verbatim
436 MOVE ::= '(' 'move' SYMBOL ')'
437          | '(' 'move' INTEGER ')'
438 @endverbatim
439
440 The first form treats @c SYMBOL as a marker, and makes the marker
441 position be the new current position.
442
443 The second form treats @c INTEGER as a character position, and makes
444 that position be the new current position.
445
446 @verbatim
447 MARK ::= '(' 'mark' SYMBOL ')'
448 @endverbatim
449
450 This action treats @c SYMBOL as a marker, and sets its position to the
451 current position.  @c SYMBOL must not be a @c PREDEFINED-SYMBOL.
452
453 @verbatim
454 PUSHBACK :: = '(' 'pushback' INTEGER ')'
455               | '(' 'pushback' KEYSEQ ')'
456 @endverbatim
457
458 The first form pushes back the latest @c INTEGER number of key events
459 to the event queue if @c INTEGER is positive, and pushes back all key
460 events if @c INTEGER is zero.
461
462 The second form pushes back keys in @c KEYSEQ to the event queue.
463
464 @verbatim
465 POP ::= '(' 'pop' ')'
466 @endverbatim
467
468 This action pops the first key event that is not yet handled from the
469 event queue.
470
471 @verbatim
472 UNDO :: = '(' 'undo' [ INTEGER | SYMBOL ] ')'
473 @endverbatim
474
475 If there's no argument, this action cancels the last two key events
476 (i.e. the one that invoked this command, and the previous one).
477
478 If there's an integer argument NUM, it must be positive or negative
479 (not zero).  If positive, from the NUMth to the last events are
480 canceled.  If negative, the last (- NUM) events are canceled.
481
482 If there's a symbol argument, it must be resolved to an integer number
483 and the number is treated as the actual argument as above.
484
485 @verbatim
486 COMMIT :: = '(commit)'
487 @endverbatim
488
489 This action commits the current preedit.
490
491 @verbatim
492 UNHANDLE :: = '(unhandle)'
493 @endverbatim
494
495 This action commits the current preedit and returns the last key as
496 unhandled.
497
498 @verbatim
499 SHIFT :: = '(' 'shift' STATE-NAME ')'
500 @endverbatim
501
502 If @c STATE-NAME is @c t, this action shifts the current state to the
503 previous one, otherwise it shifts to @c STATE-NAME.  In the latter
504 case, @c STATE-NAME must appear in @c STATE-LIST.
505
506 @verbatim
507 CALL ::= '(' 'call' MODULE-NAME FUNCTION ARG * ')'
508
509 ARG ::= INTEGER | SYMBOL | MTEXT | PLIST
510 @endverbatim
511
512 This action calls the function @c FUNCTION of external module @c
513 MODULE-NAME.  @c MODULE-NAME and @c FUNCTION must appear in @c
514 MODULE-LIST.
515
516 The function is called with an argument of the type (#MPlist *).  The
517 key of the first element is #Mt and its value is a pointer to an
518 object of the type #MInputContext.  The key of the second element is
519 #Msymbol and its value is the current state name.  @c ARGs are used as
520 the value of the third and later elements.  Their keys are determined
521 automatically; if an @c ARG is an integer, the corresponding key is
522 #Minteger; if an @c ARG is a symbol, the corresponding key is
523 #Msymbol, etc.
524
525 The function must return NULL or a value of the type (#MPlist *) that
526 represents a list of actions to take.
527
528 @verbatim
529 SET ::= '(' CMD SYMBOL1 EXPRESSION ')'
530
531 CMD ::= 'set' | 'add' | 'sub' | 'mul' | 'div'
532
533 EXPRESSION ::= INTEGER | SYMBOL2 | '(' OPERATOR EXPRESSION * ')'
534
535 OPERATOR ::= '+' | '-' | '*' | '/' | '|' | '&' | '!'
536             | '=' | '<' | '>' | '<=' | '>='
537
538 @endverbatim
539
540 This action treats @c SYMBOL1 and @c SYMBOL2 as variables and sets the
541 value of @c SYMBOL1 as below.
542
543 If @c CMD is 'set', it sets the value of @c SYMBOL1 to the value of @c
544 EXPRESSION.
545
546 If @c CMD is 'add', it increments the value of @c SYMBOL1 by the value
547 of @c EXPRESSION.
548
549 If @c CMD is 'sub', it decrements the value of @c SYMBOL1 by the value
550 of @c EXPRESSION.
551
552 If @c CMD is 'mul', it multiplies the value of @c SYMBOL1 by the value
553 of @c EXPRESSION.
554
555 If @c CMD is 'div', it divides the value of @c SYMBOL1 by the value of
556 @c EXPRESSION.
557
558 @verbatim
559 IF ::= '(' CONDITION ACTION-LIST1 ACTION-LIST2 ? ')'
560
561 CONDITION ::= [ '=' | '<' | '>' | '<=' | '>=' ] EXPRESSION1 EXPRESSION2
562
563 ACTION-LIST1 ::= '(' ACTION * ')'
564
565 ACTION-LIST2 ::= '(' ACTION * ')'
566 @endverbatim
567
568 This action performs actions in @c ACTION-LIST1 if @c CONDITION is
569 true, and performs @c ACTION-LIST2 (if any) otherwise.
570
571 @verbatim
572 COND ::= '(' 'cond' [ '(' EXPRESSION ACTION * ') ] * ')'
573 @endverbatim
574
575 This action performs the first action @c ACTION whose corresponding
576 @c EXPRESSION has nonzero value.
577
578 @ifnot FOR-MAN
579
580 @section im-example1 EXAMPLE 1
581
582 This is a very simple example for inputting Latin characters with
583 diacritical marks (acute and cedilla).  For instance, when you type:
584 @verbatim
585     Comme'die-Franc,aise, chic,,
586 @endverbatim
587 you will get this:
588 @if FOR-HTML
589 @verbatim
590     Commédie-Française, chic,
591 @endverbatim
592 @endif
593 @if FOR-LATEX
594 @latexonly
595 \hskip5mm\texttt{\footnotesize Comm\'{e}die-Fran\c{c}aise, chic,}
596 @endlatexonly
597 @endif
598
599 The definition of the input method is very simple as below, and it is
600 quite straight forward to extend it to cover all Latin characters.
601
602 @if FOR-HTML
603 @verbatim
604 (title "latin-postfix")
605 (map
606  (trans
607   ("a'" ?á) ("e'" ?é) ("i'" ?í) ("o'" ?ó) ("u'" ?ú) ("c," ?ç)
608   ("A'" ?Á) ("E'" ?É) ("I'" ?Í) ("O'" ?Ó) ("U'" ?Ú) ("C," ?Ç)
609   ("a''" "a'") ("e''" "e'") ("i''" "i'") ("o''" "o'") ("u''" "u'")
610   ("c,," "c,")
611   ("A''" "A'") ("E''" "E'") ("I''" "I'") ("O''" "O'") ("U''" "U'")
612   ("C,," "C,")))
613 (state
614  (init
615   (trans)))
616 @endverbatim
617 @endif
618 @if FOR-LATEX
619 @latexonly
620 \texttt{\footnotesize
621 \hskip2mm(title "latin-postfix")\\
622 \hskip2mm(map\\
623 \hskip4mm (trans\\
624 \hskip6mm  ("a'" ?\'{a}) ("e'" ?\'{e}) ("i'" ?\'{i}) ("o'" ?\'{o})
625 ("u'" ?\'{u}) ("c," ?\c{c})\\
626 \hskip6mm  ("A'" ?\'{A}) ("E'" ?\'{E}) ("I'" ?\'{I}) ("O'" ?\'{O})
627 ("U'" ?\'{U}) ("C," ?\c{C})\\
628 \hskip6mm  ("a''" "a'") ("e''" "e'") ("i''" "i'") ("o''" "o'") ("u''" "u'")\\
629 \hskip6mm  ("c,," "c,")\\
630 \hskip6mm  ("A''" "A'") ("E''" "E'") ("I''" "I'") ("O''" "O'") ("U''" "U'")\\
631 \hskip6mm  ("C,," "C,")))\\
632 \hskip2mm(state\\
633 \hskip4mm (init\\
634 \hskip6mm  (trans)))}
635 @endlatexonly
636 @endif
637
638 @section im-example2 EXAMPLE 2
639
640 This example is for inputting Unicode characters by typing C-u
641 (Control-u) followed by four hexadecimal digits.  For instance, when
642 you type ("^u" means Control-u):
643 @verbatim
644     ^u2190^u2191^u2192^u2193
645 @endverbatim
646 you will get this (Unicode arrow symbols):
647 @if FOR-LATEX
648 @verbatim
649     $\leftarrow \uparrow \rightarrow \downarrow
650 @endverbatim
651 @endif
652 @if FOR-HTML
653 @verbatim
654     ←↑→↓
655 @endverbatim
656 @endif
657
658 The definition utilizes @c SET and @c IF commands as below:
659 @verbatim
660 (title "UNICODE")
661 (map
662  (starter
663   ((C-U) "U+"))
664  (hex
665   ("0" ?0) ("1" ?1) ... ("9" ?9) ("a" ?A) ("b" ?B) ... ("f" ?F)))
666 (state
667  (init
668   (starter (set code 0) (set count 0) (shift unicode)))
669  (unicode
670   (hex (set this @-)
671        (< this ?A
672           ((sub this 48))
673           ((sub this 55)))
674        (mul code 16) (add code this)
675        (add count 1)
676        (= count 4
677           ((delete @<) (insert code) (shift init))))))
678 @endverbatim
679
680 @section im-example3 EXAMPLE 3
681
682 This example is for inputting Chinese characters by typing PinYin key
683 sequence.
684 @if FOR-HTML
685 For instance, when you type:
686 @verbatim
687     nihaobei2jing2
688 @endverbatim
689 you will get:
690 @verbatim
691     你好北京
692 @endverbatim
693
694 The definition utilizes @c CANDIDATE and @c SELECT commands as below.
695 Note that this is just an example, and it ignores such important key
696 as Backspace.
697
698 @verbatim
699 (title "拼")
700
701 (map
702  ;; The initial character of Pinyin.
703  (starter
704   ("a") ("b") ... ("h") ("j") ... ("t") ("w") ("x") ("y") ("z"))
705
706  ;; Big table of Pinyin vs the corresponding Chinese characters.
707  (pinyin
708   ...
709   ("bei" ("被北备背悲辈杯倍贝碑" ...))
710   ("hao" ("好号毫豪浩耗皓嚎昊郝" ...))
711   ("jing" ("经京精境警竟静惊景敬" ...))
712   ("ni" ("你呢尼泥逆倪匿拟腻妮" ...))
713   ...)
714  ;; Typing 1, 2, ..., 0 selects the 0th, 1st, ..., 9th candidate.
715  (choose
716   ("1" (select 0)) ("2" (select 1)) ... ("9" (select 8)) ("0" (select 9))))
717
718 (state
719  (init
720   ;; When an initial character of Pinyin is typed, re-handle it in
721   ;; "main" state.  Anything else is just produced as is.
722   (starter (show) (pushback 1) (shift main)))
723
724  (main
725   ;; When a complete Pinyin sequence is typed, shift to "select" state
726   ;; to allow users to select one from the candidates.
727   (pinyin (shift select))
728
729   ;; When anything else is typed, produce the current candidate (if
730   ;; any), and re-handle the last input in "init" state.
731   (nil (hide) (shift init)))
732
733  (select
734   ;; When a number is typed, select the corresponding canidate,
735   ;; produce it, and shift to "init" state.
736   (choose (hide) (shift init))
737
738   ;; When anything else is typed, produce the current candidate,
739   ;; and re-handle the last input in "init" state.
740   (nil (hide) (shift init))))
741 @endverbatim
742
743 @elseif FOR-LATEX
744 @latexonly
745 \begin{center}
746 \fbox{This example is readable only in the documentation of HTML version.}
747 \end{center}
748 @endlatexonly
749 @endif
750
751 @endif
752
753 @section im-seealso SEE ALSO
754
755 @ref mim-list "Input Methods provided by the m17n database",
756 @ref mdbGeneral "mdbGeneral(5)"
757 */
758
759 /* 
760 Copyright (C) 2003, 2004, 2005
761   National Institute of Advanced Industrial Science and Technology (AIST)
762   Registration Number H15PRO112
763
764 This file is part of the m17n database; a sub-part of the m17n
765 library.
766
767 The m17n library is free software; you can redistribute it and/or
768 modify it under the terms of the GNU Lesser General Public License
769 as published by the Free Software Foundation; either version 2.1 of
770 the License, or (at your option) any later version.
771
772 The m17n library is distributed in the hope that it will be useful,
773 but WITHOUT ANY WARRANTY; without even the implied warranty of
774 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
775 Lesser General Public License for more details.
776
777 You should have received a copy of the GNU Lesser General Public
778 License along with the m17n library; if not, write to the Free
779 Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
780 Boston, MA 02110-1301, USA.
781 */
782
783 /* Local Variables: */
784 /* coding: utf-8 */
785 /* End: */