Fix previous change.
[m17n/m17n-db.git] / MIM / vi-tcvn.mim
1 ;; vi-tcvn.mim -- Input method for Vietnames with TCVN6064 key sequence
2 ;; Copyright (C) 2008
3 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
4 ;;   Registration Number H15PRO112
5
6 ;; This file is part of the m17n database; a sub-part of the m17n
7 ;; library.
8
9 ;; The m17n library is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU Lesser General Public License
11 ;; as published by the Free Software Foundation; either version 2.1 of
12 ;; the License, or (at your option) any later version.
13
14 ;; The m17n library is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;; Lesser General Public License for more details.
18
19 ;; You should have received a copy of the GNU Lesser General Public
20 ;; License along with the m17n library; if not, write to the Free
21 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23
24 (input-method vi tcvn)
25
26 (description (_"Vietnames input method using the TCVN6064 sequence.
27 Typing Backslash ('\\') toggles the normal mode and English mode.
28 The following variables are customizable:
29   tone-mark-on-last: control tone mark position in equivocal cases
30   backspace-is-undo: control the action of Backspace key (delete or undo)"))
31
32 (title "Ắ(TCVN)")
33
34 (variable
35  (tone-mark-on-last
36   (_"Flag to control tone mark position in equivocal cases.
37 If this variable is 0 (the default), put tone mark on the first vowel
38 in such equivocal cases as \"oa\", \"oe\", \"uy\".
39 Otherwise, put tone mark on the last vowel.")
40   0 0 1)
41
42  (backspace-is-undo
43   (_"Flag to control the action of Backspace key (delete or undo).
44 If this variable is 0 (the default), Backspace key deletes the previous
45 character (e.g. \"q u a i s BS\" => \"quá\").
46 If the value is 1, Backspace key undoes the previous key
47 \(e.g. \"q u a i s BS\" => \"quai\").")
48   0 0 1))
49
50 (include (t nil vi-base) macro)
51 (include (t nil vi-base) map)
52
53 (map
54  (vowel-ext
55   ("2" ("âấầẩẫậ")) ("@" ("ÂẤẦẨẪẬ"))
56   ("1" ("ăắằẳẵặ")) ("!" ("ĂẮẰẲẴẶ"))
57   ("3" ("êếềểễệ")) ("#" ("ÊẾỀỂỄỆ"))
58   ("4" ("ôốồổỗộ")) ("$" ("ÔỐỒỔỖỘ"))
59   ("]" ("ơớờởỡợ")) ("}" ("ƠỚỜỞỠỢ"))
60   ("[" ("ưứừửữự")) ("{" ("ƯỨỪỬỮỰ")))
61
62  (consonant-ext
63   ("0" ?đ) (")" ?Đ))
64
65  (tone-mark
66   ("8" (set SELECT 1) ?1)
67   ("5" (set SELECT 2) ?2)
68   ("6" (set SELECT 3) ?3)
69   ("7" (set SELECT 4) ?4)
70   ("9" (set SELECT 5) ?5))
71
72  (misc
73   ("=" ?₫) ("==" ?=)
74   ((A-1) ?1) ((A-2) ?2) ((A-3) ?3) ((A-4) ?4) ((A-5) ?5)
75   ((A-6) ?6) ((A-7) ?7) ((A-8) ?8) ((A-9) ?9) ((A-0) ?0)
76   ((A--) ?-) ((A-=) ?=) ((A-\\) ?\\) ((A-\[) ?[) ((A-\]) ?])
77   ((A-!) ?!) ((A-@) ?@) ((A-\#) ?#) ((A-$) ?$) ((A-%) ?%)
78   ((A-^) ?^) ((A-&) ?&) ((A-*) ?*) ((A-\() ?\() ((A-\)) ?\))
79   ((A-_) ?_) ((A-+) ?+) ((A-\|) ?\|) ((A-{) ?{) ((A-}) ?}))
80
81  (temporary-escape
82   ("22" "2") ("@@" "@")
83   ("11" "1") ("!!" "!")
84   ("33" "3") ("##" "##")
85   ("44" "4") ("$$" "$")
86   ("]]" "]") ("}}" "}")
87   ("[[" "[") ("{{" "{")
88   ("00" "0") ("))" ")")))
89
90 (state
91  (init
92   ;; Initialize variables.  C is the initial consonant.  V-N is the
93   ;; (N-1)th vowel from the last.  C-AFTER-V is a number of consonants
94   ;; typed after vowel.  NST is 1 iff surrounding text is not supported.
95   (t (set C @-1) (set V-1 0) (set V-2 0) (set V-3 0) (set C-AFTER-V 0)
96      (set SELECT 0) (set NST (= @-0 -2)))
97
98   (consonant (set C @-1) (cond (NST (shift after-c))))
99   (consonant-ext (set C @-1) (cond (NST (shift after-c))))
100   ;; Mark M remembers the preedit position after the last vowel.
101   (vowel (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
102   (vowel-ext (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
103   (temporary-escape (shift temporary-escape))
104   (permanent-escape (shift escape-in-normal-mode))
105   (misc)
106   (smart-quotes))
107
108  ;; The state shifted to when an initial consonants is typed and
109  ;; surrounding text is not supported.
110  (after-c
111   (vowel (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
112   (vowel-ext (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v)))
113
114  ;; The state shifted to when a vowel is typed.
115  (after-v
116   (consonant (shift after-vc))
117   (consonant-ext (shift after-vc))
118   (vowel (mark M) (set V-3 V-2) (set V-2 V-1) (set V-1 @-1)
119          (move T) (select 0) (handle-mark) (move M))
120   (vowel-ext (mark M) (set V-3 V-2) (set V-2 V-1) (set V-1 @-1)
121              (move T) (select 0) (handle-mark) (move M))
122   (tone-mark (delete @-) (pushback 1) (shift after-t))
123   (backspace (delete @-)
124              (cond (V-3 (set V-1 V-2) (set V-2 V-3) (set V-3 0)
125                         (cond ((> TPLACE 2) (set SELECT 0))))
126                    (V-2 (set V-1 V-2) (set V-2 0)
127                         (cond ((> TPLACE 1) (set SELECT 0))))
128                    (1 (shift init)))))
129
130  ;; The state shifted to when a consonant is typed after a vowel.
131  (after-vc
132   (t (set C-AFTER-V 1))
133   (consonant (add C-AFTER-V 1))
134   (consonant-ext (add C-AFTER-V 1))
135   (tone-mark (delete @-) (pushback 1) (shift after-t))
136   (backspace (delete @-)
137              (sub C-AFTER-V 1)
138              (cond ((= C-AFTER-V 0) (shift after-v)))))
139
140  ;; The state shifted to when a tone-mark is typed.
141  (after-t
142   (t (set CURRENT-SELECT -1))
143   (tone-mark (cond ((= CURRENT-SELECT SELECT) (move T) (select 0) (move @>)
144                     (shift temporary-escape))
145                    (1 (delete @-) (handle-mark) (set CURRENT-SELECT SELECT))))
146   (nil (cond (C-AFTER-V (shift after-vc))
147              (1 (shift after-v)))))
148
149  (temporary-escape
150   "en"
151   (t (commit))
152   (alnum (commit)))
153
154  (escape-in-normal-mode
155   "EN"
156   (permanent-escape (insert "\\") (shift init))
157   ;; Any other key force shifting to permanent-escape.
158   (nil (shift permanent-escape)))
159
160  (permanent-escape
161   "EN"
162   (t (set ESCAPE 1))
163   (permanent-escape (shift escape-in-permanent-escape))
164   ;; Unhandle any characters.
165   (nil (unhandle)))
166
167  (escape-in-permanent-escape
168   "Ắ"
169   (permanent-escape (insert "\\") (commit) (shift permanent-escape))
170   ;; Any other key force shifting to init
171   ))
172
173 ;; Local Variables:
174 ;; coding: utf-8
175 ;; mode: lisp
176 ;; End: