1 ;; vi-viqr.mim -- Input method for Vietnames with VIQR key sequence
2 ;; Copyright (C) 2003, 2004, 2005
3 ;; National Institute of Advanced Industrial Science and Technology (AIST)
4 ;; Registration Number H15PRO112
6 ;; This file is part of the m17n database; a sub-part of the m17n
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.
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.
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.
24 (input-method vi viqr)
26 (description (_"Vietnames input method using the VIQR key 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)"))
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.")
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\").")
50 (include (t nil vi-base) macro)
51 (include (t nil vi-base) map)
55 ("a^" ("âấầẩẫậ")) ("A^" ("ÂẤẦẨẪẬ"))
56 ("a(" ("ăắằẳẵặ")) ("A(" ("ĂẮẰẲẴẶ"))
57 ("e^" ("êếềểễệ")) ("E^" ("ÊẾỀỂỄỆ"))
58 ("o^" ("ôốồổỗộ")) ("O^" ("ÔỐỒỔỖỘ"))
59 ("o+" ("ơớờởỡợ")) ("O+" ("ƠỚỜỞỠỢ"))
60 ("u+" ("ưứừửữự")) ("U+" ("ƯỨỪỬỮỰ")))
63 ("dd" ?đ) ("DD" ?Đ) ("Dd" ?Đ))
66 ("0" (set SELECT 0) ?0)
67 ("'" (set SELECT 1) ?')
68 ("`" (set SELECT 2) ?`)
69 ("?" (set SELECT 3) ??)
70 ("~" (set SELECT 4) ?~)
71 ("." (set SELECT 5) ?.))
74 ("a^^" "a^") ("A^^" "A^")
75 ("a((" "a(") ("A((" "A(")
76 ("e^^" "e^") ("E^^" "E^")
77 ("o^^" "o^") ("O^^" "O^")
78 ("o++" "o+") ("O++" "O+")
79 ("u++" "u+") ("U++" "U+")))
83 ;; Initialize variables. C is the initial consonant. V-N is the
84 ;; (N-1)th vowel from the last. C-AFTER-V is a number of consonants
85 ;; typed after vowel. NST is 1 iff surrounding text is not supported.
86 (t (set C @-1) (set V-1 0) (set V-2 0) (set V-3 0) (set C-AFTER-V 0)
87 (set SELECT 0) (set NST (= @-0 -2)))
89 (consonant (set C @-1) (cond (NST (shift after-c))))
90 (consonant-ext (set C @-1) (cond (NST (shift after-c))))
91 ;; Mark M remembers the preedit position after the last vowel.
92 (vowel (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
93 (vowel-ext (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
94 (temporary-escape (shift temporary-escape))
95 (permanent-escape (shift escape-in-normal-mode)))
97 ;; The state shifted to when an initial consonants is typed and
98 ;; surrounding text is not supported.
100 (vowel (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
101 (vowel-ext (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v)))
103 ;; The state shifted to when a vowel is typed.
105 (consonant (shift after-vc))
106 (consonant-ext (shift after-vc))
107 (vowel (mark M) (set V-3 V-2) (set V-2 V-1) (set V-1 @-1)
108 (move T) (select 0) (handle-mark) (move M))
109 (vowel-ext (mark M) (set V-3 V-2) (set V-2 V-1) (set V-1 @-1)
110 (move T) (select 0) (handle-mark) (move M))
111 (tone-mark (delete @-) (pushback 1) (shift after-t))
112 (backspace (delete @-)
113 (cond (V-3 (set V-1 V-2) (set V-2 V-3) (set V-3 0)
114 (cond ((> TPLACE 2) (set SELECT 0))))
115 (V-2 (set V-1 V-2) (set V-2 0)
116 (cond ((> TPLACE 1) (set SELECT 0))))
119 ;; The state shifted to when a consonant is typed after a vowel.
121 (t (set C-AFTER-V 1))
122 (consonant (add C-AFTER-V 1))
123 (consonant-ext (add C-AFTER-V 1))
124 (tone-mark (delete @-) (pushback 1) (shift after-t))
125 (backspace (delete @-)
127 (cond ((= C-AFTER-V 0) (shift after-v)))))
129 ;; The state shifted to when a tone-mark is typed.
131 (t (set CURRENT-SELECT -1))
132 (tone-mark (cond ((= CURRENT-SELECT SELECT) (move T) (select 0) (move @>)
133 (shift temporary-escape))
134 (1 (delete @-) (handle-mark) (set CURRENT-SELECT SELECT))))
135 (nil (cond (C-AFTER-V (shift after-vc))
136 (1 (shift after-v)))))
143 (escape-in-normal-mode
145 (permanent-escape (insert "\\") (shift init))
146 ;; Any other key force shifting to permanent-escape.
147 (nil (shift permanent-escape)))
152 (permanent-escape (shift escape-in-permanent-escape))
153 ;; Unhandle any characters.
156 (escape-in-permanent-escape
158 (permanent-escape (insert "\\") (commit) (shift permanent-escape))
159 ;; Any other key force shifting to init