155
|
1 ;;; quail/lao.el --- Quail package for inputting Lao characters
|
|
2
|
|
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
|
|
5
|
|
6 ;; Keywords: multilingual, input method, Lao
|
|
7
|
|
8 ;; This file is part of GNU Emacs.
|
|
9
|
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
11 ;; it under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 ;; GNU General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
23
|
|
24 ;;; Code:
|
|
25
|
|
26 (require 'quail)
|
|
27 (require 'language/lao-util)
|
|
28
|
|
29 (eval-and-compile
|
|
30
|
|
31 (defconst lao-keyboard-mapping
|
|
32 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes
|
|
33 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes
|
|
34 0 "1" "=" "3" "4" "(1l(B" "5" "(1'(B" ; SPC .. '
|
|
35 "7" "8" "6" "(1mh(B" "(1A(B" "9" "(1c(B" "(1=(B" ; ( .. /
|
|
36 "(1"(B" "(1B(B" "(1?(B" "(1b(B" "(16(B" "(1X(B" "(1Y(B" "(1$(B" ; 0 .. 7
|
|
37 "(15(B" "(1((B" "%" "(1G(B" "(1}(B" "(1m(B" ">" "\)" ; 8 .. ?
|
|
38 "2" "(1Qi(B" "(1Vi(B" "(1O(B" "." "(1Si(B" "," ":" ; @ .. G
|
|
39 "(1j(B" "(1N(B" "(1k(B" "!" "?" "(1f(B" "(1Wi(B" "(1|(B" ; H .. O
|
|
40 "(1](B" "(1[i(B" "_" ";" "+" "(1Ui(B" "x" "0" ; P .. W
|
|
41 "\(" "(1Ti(B" "\"" "(1:(B" 0 "(1E(B" "(1\(B" "(1*(B" ; X .. _
|
|
42 "(1'(B" "(1Q(B" "(1V(B" "(1a(B" "(1!(B" "(1S(B" "(14(B" "(1`(B" ; ` .. g
|
|
43 "(1i(B" "(1C(B" "(1h(B" "(1R(B" "(1J(B" "(17(B" "(1W(B" "(19(B" ; h .. o
|
|
44 "(1-(B" "(1[(B" "(1>(B" "(1K(B" "(1P(B" "(1U(B" "(1M(B" "(1d(B" ; p .. w
|
|
45 "(1;(B" "(1T(B" "(1<(B" "-" "(1K\(B" "/" "~" 0] ; x .. DEL
|
|
46 "A table which maps ASCII key codes to corresponding Lao characters."
|
|
47 )
|
|
48
|
|
49 )
|
|
50
|
|
51 ;; Template of a cdr part of a Quail map when a consonant is entered.
|
|
52 (defvar lao-consonant-alist nil)
|
|
53 ;; Template of a cdr part of a Quail map when a vowel upper is entered.
|
|
54 (defvar lao-vowel-upper-alist nil)
|
|
55 ;; Template of a cdr part of a Quail map when a vowel lower is entered.
|
|
56 (defvar lao-vowel-lower-alist nil)
|
|
57 ;; Template of a cdr part of a Quail map when a semivowel lower is entered.
|
|
58 (defvar lao-semivowel-lower-alist nil)
|
|
59
|
|
60 ;; Return a Quail map corresponding to KEY of length LEN.
|
|
61 ;; The car part of the map is a translation generated automatically.
|
|
62 ;; The cdr part of the map is a copy of ALIST.
|
|
63 (defun lao-generate-quail-map (key len alist)
|
|
64 (let ((str "")
|
|
65 (idx 0))
|
|
66 (while (< idx len)
|
|
67 (setq str (concat str (aref lao-keyboard-mapping (aref key idx)))
|
|
68 idx (1+ idx)))
|
|
69 (cons (string-to-char (compose-string str)) (copy-alist alist))))
|
|
70
|
|
71 ;; Return a Quail map corresponding to KEY of length LEN when Lao
|
|
72 ;; tone mark is entered.
|
|
73 (defun lao-tone-input (key len)
|
|
74 (lao-generate-quail-map key len nil))
|
|
75
|
|
76 ;; Return a Quail map corresponding to KEY of length LEN when Lao
|
|
77 ;; vowel upper is entered.
|
|
78 (defun lao-vowel-upper-input (key len)
|
|
79 (lao-generate-quail-map key len lao-vowel-upper-alist))
|
|
80
|
|
81 ;; Return a Quail map corresponding to KEY of length LEN when Lao
|
|
82 ;; vowel lower is entered.
|
|
83 (defun lao-vowel-lower-input (key len)
|
|
84 (lao-generate-quail-map key len lao-vowel-lower-alist))
|
|
85
|
|
86 ;; Return a Quail map corresponding to KEY of length LEN when Lao
|
|
87 ;; semivowel lower is entered.
|
|
88 (defun lao-semivowel-lower-input (key len)
|
|
89 (lao-generate-quail-map key len lao-semivowel-lower-alist))
|
|
90
|
|
91 ;; Return an alist which can be a cdr part of a Quail map
|
|
92 ;; corresponding to the current key when Lao consonant is entered.
|
|
93 (defun lao-consonant-input (key len)
|
|
94 (copy-alist lao-consonant-alist))
|
|
95
|
|
96 (quail-define-package "quail-lao" "Lao" "Lao" t
|
|
97 "Lao input method with TIS620 characters:"
|
|
98 nil t t t t)
|
|
99
|
|
100 (defmacro lao-quail-define-rules (&rest rules)
|
|
101 (let ((l rules)
|
|
102 consonant-alist
|
|
103 vowel-upper-alist
|
|
104 vowel-lower-alist
|
|
105 semivowel-lower-alist
|
|
106 rule trans ch c-set)
|
|
107 (while l
|
|
108 (setq rule (car l))
|
|
109 (setq trans (nth 1 rule))
|
|
110 (if (consp trans)
|
|
111 (setq trans (car trans)))
|
|
112 (setq c-set (char-category-set (string-to-char trans)))
|
|
113 (cond ((aref c-set ?2) ; vowel upper
|
|
114 (setq consonant-alist
|
|
115 (cons (cons (string-to-char (car rule))
|
|
116 'lao-vowel-upper-input)
|
|
117 consonant-alist)))
|
|
118 ((aref c-set ?3) ; vowel lower
|
|
119 (setq consonant-alist
|
|
120 (cons (cons (string-to-char (car rule))
|
|
121 'lao-vowel-lower-input)
|
|
122 consonant-alist)
|
|
123 semivowel-lower-alist
|
|
124 (cons (cons (string-to-char (car rule))
|
|
125 'lao-vowel-lower-input)
|
|
126 semivowel-lower-alist)))
|
|
127 ((aref c-set ?4) ; tone
|
|
128 (setq consonant-alist
|
|
129 (cons (cons (string-to-char (car rule))
|
|
130 'lao-tone-input)
|
|
131 consonant-alist)
|
|
132 vowel-upper-alist
|
|
133 (cons (cons (string-to-char (car rule))
|
|
134 'lao-tone-input)
|
|
135 vowel-upper-alist)
|
|
136 vowel-lower-alist
|
|
137 (cons (cons (string-to-char (car rule))
|
|
138 'lao-tone-input)
|
|
139 vowel-lower-alist)))
|
|
140 ((aref c-set ?9) ; semivowel lower
|
|
141 (setq consonant-alist
|
|
142 (cons (cons (string-to-char (car rule))
|
|
143 'lao-semivowel-lower-input)
|
|
144 consonant-alist)
|
|
145 vowel-upper-alist
|
|
146 (cons (cons (string-to-char (car rule))
|
|
147 'lao-semivowel-lower-input)
|
|
148 vowel-upper-alist))))
|
|
149 (setq l (cdr l)))
|
|
150 (list 'progn
|
|
151 (cons 'quail-define-rules rules)
|
|
152 `(setq lao-consonant-alist ',consonant-alist
|
|
153 lao-vowel-upper-alist ',vowel-upper-alist
|
|
154 lao-vowel-lower-alist ',vowel-lower-alist
|
|
155 lao-semivowel-lower-alist ',semivowel-lower-alist))))
|
|
156
|
|
157 (lao-quail-define-rules
|
|
158 ("!" "1")
|
|
159 ("\"" "=")
|
|
160 ("#" "3")
|
|
161 ("$" "4")
|
|
162 ("&" "5")
|
|
163 ("%" "(1l(B")
|
|
164 ("'" ("(1'(B" . lao-consonant-input))
|
|
165 ("(" "7")
|
|
166 (")" "8")
|
|
167 ("*" "6")
|
|
168 ("+" "0(1mh1(B")
|
|
169 ("," ("(1A(B" . lao-consonant-input))
|
|
170 ("-" "9")
|
|
171 ("." "(1c(B")
|
|
172 ("/" ("(1=(B" . lao-consonant-input))
|
|
173 ("0" ("(1"(B" . lao-consonant-input))
|
|
174 ("1" ("(1B(B" . lao-consonant-input))
|
|
175 ("2" ("(1?(B" . lao-consonant-input))
|
|
176 ("3" "(1b(B")
|
|
177 ("4" ("(16(B" . lao-consonant-input))
|
|
178 ("5" "(1X(B")
|
|
179 ("6" "(1Y(B")
|
|
180 ("7" ("(1$(B" . lao-consonant-input))
|
|
181 ("8" ("(15(B" . lao-consonant-input))
|
|
182 ("9" ("(1((B" . lao-consonant-input))
|
|
183 (":" "%")
|
|
184 (";" ("(1G(B" . lao-consonant-input))
|
|
185 ("<" ("(1}(B" . lao-consonant-input))
|
|
186 ("=" "(1m(B")
|
|
187 (">" ">")
|
|
188 ("?" ")")
|
|
189 ("@" "2")
|
|
190 ("A" "0(1Qi1(B")
|
|
191 ("B" "0(1Vi1(B")
|
|
192 ("C" "(1O(B")
|
|
193 ("D" ".")
|
|
194 ("E" "0(1Si1(B")
|
|
195 ("F" ",")
|
|
196 ("G" ":")
|
|
197 ("H" "(1j(B")
|
|
198 ("I" ("(1N(B" . lao-consonant-input))
|
|
199 ("J" "(1k(B")
|
|
200 ("K" "!")
|
|
201 ("L" "?")
|
|
202 ("M" "(1f(B")
|
|
203 ("N" "0(1Wi1(B")
|
|
204 ("O" ("(1|(B" . lao-consonant-input))
|
|
205 ("P" "(1](B")
|
|
206 ("Q" "0(1[i1(B")
|
|
207 ("R" "_")
|
|
208 ("S" ";")
|
|
209 ("T" "+")
|
|
210 ("U" "0(1Ui1(B")
|
|
211 ("V" "x")
|
|
212 ("W" "0")
|
|
213 ("X" "(")
|
|
214 ("Y" "0(1Ti1(B")
|
|
215 ("Z" "\"")
|
|
216 ("[" ("(1:(B" . lao-consonant-input))
|
|
217 ("]" ("(1E(B" . lao-consonant-input))
|
|
218 ("^" "(1\(B")
|
|
219 ("_" ("(1*(B" . lao-consonant-input))
|
|
220 ("`" ("(1'(B" . lao-consonant-input))
|
|
221 ("a" "(1Q(B")
|
|
222 ("b" "(1V(B")
|
|
223 ("c" "(1a(B")
|
|
224 ("d" ("(1!(B" . lao-consonant-input))
|
|
225 ("e" "(1S(B")
|
|
226 ("f" ("(14(B" . lao-consonant-input))
|
|
227 ("g" "(1`(B")
|
|
228 ("h" "(1i(B")
|
|
229 ("i" ("(1C(B" . lao-consonant-input))
|
|
230 ("j" "(1h(B")
|
|
231 ("k" "(1R(B")
|
|
232 ("l" ("(1J(B" . lao-consonant-input))
|
|
233 ("m" ("(17(B" . lao-consonant-input))
|
|
234 ("n" "(1W(B")
|
|
235 ("o" ("(19(B" . lao-consonant-input))
|
|
236 ("p" ("(1-(B" . lao-consonant-input))
|
|
237 ("q" "(1[(B")
|
|
238 ("r" ("(1>(B" . lao-consonant-input))
|
|
239 ("s" ("(1K(B" . lao-consonant-input))
|
|
240 ("t" "(1P(B")
|
|
241 ("u" "(1U(B")
|
|
242 ("v" ("(1M(B" . lao-consonant-input))
|
|
243 ("w" "(1d(B")
|
|
244 ("x" ("(1;(B" . lao-consonant-input))
|
|
245 ("y" "(1T(B")
|
|
246 ("z" ("(1<(B" . lao-consonant-input))
|
|
247 ("{" "-")
|
|
248 ("|" ("0(1K\1(B" . lao-consonant-input))
|
|
249 ("}" "/")
|
|
250 ("~" "(1l(B")
|
|
251 ("\\0" "(1p(B")
|
|
252 ("\\1" "(1q(B")
|
|
253 ("\\2" "(1r(B")
|
|
254 ("\\3" "(1s(B")
|
|
255 ("\\4" "(1t(B")
|
|
256 ("\\5" "(1u(B")
|
|
257 ("\\6" "(1v(B")
|
|
258 ("\\7" "(1w(B")
|
|
259 ("\\8" "(1x(B")
|
|
260 ("\\9" "(1y(B")
|
|
261 )
|
|
262
|
|
263
|
|
264 ;;; quail/lao.el ends here
|