*** empty log message ***
[m17n/m17n-db.git] / MIM / zh-util.mim
1 ;; zh-util.mim -- Provide utilities for Chinese input methods.
2 ;; Copyright (C) 2005, 2008
3 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
4 ;;   Registration Number H15PRO112
5
6 ;; This file is part of the m17n library.
7
8 ;; The m17n library is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU Lesser General Public License
10 ;; as published by the Free Software Foundation; either version 2.1 of
11 ;; the License, or (at your option) any later version.
12
13 ;; The m17n library is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;; Lesser General Public License for more details.
17
18 ;; You should have received a copy of the GNU Lesser General Public
19 ;; License along with the m17n library; if not, write to the Free
20 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
22
23 (input-method t nil zh-util)
24
25 (description "Provide utilities for Chinese input methods.
26 This is acutually not a standalone input method, but is expected
27 to be included in the other Chinese input method (e.g. zh-py).
28 ")
29
30 (map
31  ;; Typing 1, 2, ..., 0 selects the 0th, 1st, ..., 9th candidate.
32  (choose
33   ("1" (select 0))
34   ("2" (select 1))
35   ("3" (select 2))
36   ("4" (select 3))
37   ("5" (select 4))
38   ("6" (select 5))
39   ("7" (select 6))
40   ("8" (select 7))
41   ("9" (select 8))
42   ("0" (select 9)))
43
44  (change-candidate
45   ((Left) (select @-))
46   ((C-b) (select @-))
47   ((Right) (select @+))
48   ((C-f) (select @+))
49   ((Up) (select @\[))
50   ((C-p) (select @\[))
51   ((Down) (select @\]))
52   ((C-n) (select @\])))
53
54  (focus-move
55   ;; When an input spot is moved, commit the current predit by shifting
56   ;; to init.
57   ((input-focus-move)))
58
59  (focus-change
60   ;; When an input focus is out or in, keep the current preedit.
61   ((input-focus-out) (set KK @@) (sub KK 1) (undo KK))
62   ((input-focus-in) (set KK @@) (sub KK 1) (undo KK)))
63
64  (backspace
65   ((BackSpace)))
66
67  (commit-preedit
68   ((S-\ ))
69   ((\ ))))
70
71 (state
72  (check-undo
73   ;; When Backspace is typed, cancel the last input.
74   (backspace (undo))
75   (focus-move (shift init))
76   (focus-change)
77   ;; When anything else is typed, produce the current candidate (if
78   ;; any), and re-handle the last input in "init" state.
79   (nil (hide) (shift init)))
80
81  (select
82   (t (set K @@) (sub K 1))
83   ;; When a number is typed, select the corresponding canidate,
84   ;; produce it, and shift to "init" state.
85   (focus-move (shift init))
86   (focus-change)
87   (choose (hide) (shift init))
88   (change-candidate)
89   (backspace (undo K))
90   ;; When key to force committing, commit the current preedit.
91   (commit-preedit (shift init))
92   ;; When anything else is typed, produce the current candidate,
93   ;; and re-handle the last input in "init" state.
94   (nil (hide) (shift init))))