Mercurial > emacs
annotate leim/quail/thai.el @ 26748:8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
(diff-minor-mode, diff-minor-mode-prefix, diff-minor-mode-map):
New code to support the minor mode version.
(diff-recenter): New function.
(diff-next-hunk, diff-next-file): Use it.
(diff-remembered-files-alist): New var.
(diff-merge-strings): New function.
(diff-find-file-name): Make it smarter and use the user's input more.
(diff-mode): Cosmetic changes.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 07 Dec 1999 07:04:03 +0000 |
parents | dd39cae4cf0f |
children | cd1cb9bf30e1 |
rev | line source |
---|---|
18673 | 1 ;;; quail/thai.el --- Quail package for inputting Thai characters |
2 | |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
4 ;; Licensed to the Free Software Foundation. | |
5 | |
6 ;; Keywords: multilingual, input method, Thai | |
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 the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Code: | |
26 | |
27 (require 'quail) | |
28 (require 'thai-util) | |
29 | |
30 (eval-and-compile | |
31 | |
32 (defvar thai-keyboard-mapping-alist | |
33 '((kesmanee | |
34 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes | |
35 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes | |
36 0 "#" ",TF(B" ",Tr(B" ",Ts(B" ",Tt(B" "0,TQi1(B" ",T'(B" ; SPC .. ' | |
37 ",Tv(B" ",Tw(B" ",Tu(B" ",Ty(B" ",TA(B" ",T"(B" ",Tc(B" ",T=(B" ; ( .. / | |
38 ",T((B" ",TE(B" "/" "_" ",T@(B" ",T6(B" ",TX(B" ",TV(B" ; 0 .. 7 | |
39 ",T$(B" ",T5(B" ",T+(B" ",TG(B" ",T2(B" ",T*(B" ",TL(B" ",TF(B" ; 8 .. ? | |
40 ",Tq(B" ",TD(B" ",TZ(B" ",T)(B" ",T/(B" ",T.(B" ",Tb(B" ",T,(B" ; @ .. G | |
41 ",Tg(B" ",T3(B" ",Tk(B" ",TI(B" ",TH(B" ",Tn(B" ",Tl(B" ",TO(B" ; H .. O | |
42 ",T-(B" ",Tp(B" ",T1(B" ",T&(B" ",T8(B" ",Tj(B" ",TN(B" "\"" ; P .. W | |
43 ")" ",Tm(B" "(" ",T:(B" ",T_(B" ",TE(B" ",TY(B" ",Tx(B" ; X .. _ | |
44 ",T#(B" ",T?(B" ",TT(B" ",Ta(B" ",T!(B" ",TS(B" ",T4(B" ",T`(B" ; ` .. g | |
45 ",Ti(B" ",TC(B" ",Th(B" ",TR(B" ",TJ(B" ",T7(B" ",TW(B" ",T9(B" ; h .. o | |
46 ",TB(B" ",Tf(B" ",T>(B" ",TK(B" ",TP(B" ",TU(B" ",TM(B" ",Td(B" ; p .. w | |
47 ",T;(B" ",TQ(B" ",T<(B" ",T0(B" ",To(B" "." ",T%(B" 0] ; x .. DEL | |
48 nil nil) | |
49 | |
50 (pattachote | |
51 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes | |
52 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes | |
53 0 "+" ",T1(B" "/" "," "?" "_" ",T"(B" ; SPC .. ' | |
54 "(" ")" "." "%" ",TP(B" ",Tq(B" ",T((B" ",T>(B" ; ( .. / | |
55 ",Tp(B" "=" ",Tr(B" ",Ts(B" ",Tt(B" ",Tu(B" ",TY(B" ",Tw(B" ; 0 .. 7 | |
56 ",Tx(B" ",Ty(B" ",T&(B" ",Td(B" ",T?(B" ",Tv(B" ",T2(B" ",TL(B" ; 8 .. ? | |
19458
196438eb86d1
(thai-keyboard-mapping-alist): Some entry corrected.
Kenichi Handa <handa@m17n.org>
parents:
19409
diff
changeset
|
57 "\"" ",Tk(B" ",TQ(B" ",T0(B" ",TS(B" ",Tf(B" ",T3(B" ",Tl(B" ; @ .. G |
18673 | 58 ",TW(B" ",T+(B" ",T<(B" ",T*(B" ",Tb(B" ",TN(B" ",TH(B" ",T6(B" ; H .. O |
19465
10d0ae6abbea
(thai-keyboard-mapping-alist): Some entry corrected.
Kenichi Handa <handa@m17n.org>
parents:
19458
diff
changeset
|
59 ",T2(B" ",Tj(B" ",T-(B" ",T8(B" ",TI(B" ",T=(B" ",T@(B" ",TD(B" ; P .. W |
18673 | 60 ",T.(B" ",TV(B" ",T.(B" ",Tc(B" ",TZ(B" ",T2(B" ",TX(B" "-" ; X .. _ |
19458
196438eb86d1
(thai-keyboard-mapping-alist): Some entry corrected.
Kenichi Handa <handa@m17n.org>
parents:
19409
diff
changeset
|
61 ",T#(B" ",Ti(B" ",TT(B" ",TE(B" ",T'(B" ",TB(B" ",T!(B" ",TQ(B" ; ` .. g |
18673 | 62 ",TU(B" ",TA(B" ",TR(B" ",T9(B" ",T`(B" ",TJ(B" ",T$(B" ",TG(B" ; h .. o |
19465
10d0ae6abbea
(thai-keyboard-mapping-alist): Some entry corrected.
Kenichi Handa <handa@m17n.org>
parents:
19458
diff
changeset
|
63 ",Ta(B" ",Tg(B" ",TM(B" ",T7(B" ",TC(B" ",T4(B" ",TK(B" ",T5(B" ; p .. w |
18673 | 64 ",T;(B" ",Th(B" ",T:(B" ",TO(B" ",Tm(B" ",TF(B" ",T%(B" 0] ; x .. DEL |
65 nil nil) | |
66 ) | |
67 "Alist of Thai keyboard types vs. corresponding mapping tables. | |
68 Each element is a list of: | |
69 KEYBOARD-TYPE, ASCII-THAI-TABLE, CONSONANT-MAP-TEMPLATE, | |
70 and VOWEL-UPPER-LOWER-TEMPLATE. | |
71 | |
72 KEYBOARD-TYPE is a symbol, one of kesmanee or pattachote. | |
73 | |
74 ASCII-THAI-TABLE is a vector indexed by an ASCII key code | |
75 and the value is the one-char string of Thai character | |
76 assigned at the location of ASCII key on the specific Thai keyboard. | |
77 The value is 0 if no Thai character is assigned at the location. | |
78 | |
79 CONSONANT-MAP-TEMPLATE is a template of a cdr part of a Quail map when | |
80 a consonant is entered. | |
81 | |
82 VOWEL-UPPER-LOWER-TEMPLATE is a template of a cdr part of a Quail map | |
83 when a vowel upper or a vowel lower is entered.") | |
84 | |
85 (defmacro thai-keyboard-info (keyboard-type) | |
86 `(assq ,keyboard-type thai-keyboard-mapping-alist)) | |
87 | |
88 ) | |
89 | |
90 (defvar thai-current-keyboard-type nil | |
91 "Thai Keyboard type which Quail is assuming currently. | |
92 This variable is used in Quail internally only.") | |
93 | |
94 ;; Template of a cdr part of a Quail map when a consonant is entered. | |
95 (defvar thai-consonant-alist nil) | |
96 ;; Template of a cdr part of a Quail map when a vowel upper or a vowel | |
97 ;; lower is entered. | |
98 (defvar thai-vowel-upper-lower-alist nil) | |
99 | |
100 ;; Return a Quail map corresponding to KEY of length LEN. | |
101 ;; The car part of the map is a translation generated automatically. | |
102 ;; The cdr part of the map is a copy of ALIST. | |
103 (defun thai-generate-quail-map (key len alist) | |
104 (let ((str "") | |
105 (idx 0)) | |
106 (while (< idx len) | |
107 (setq str (concat str (aref (nth 1 (thai-keyboard-info | |
108 thai-current-keyboard-type)) | |
109 (aref key idx))) | |
110 idx (1+ idx))) | |
111 (cons (string-to-char (compose-string str)) (copy-alist alist)))) | |
112 | |
113 ;; Return a Quail map corresponding to KEY of length LEN when Thai | |
114 ;; tone mark is entered. | |
115 (defun thai-tone-input (key len) | |
116 (thai-generate-quail-map key len nil)) | |
117 | |
118 ;; Return a Quail map corresponding to KEY of length LEN when Thai | |
119 ;; vowel upper or vowel lower is entered. | |
120 (defun thai-vowel-upper-lower-input (key len) | |
121 (thai-generate-quail-map | |
122 key len | |
123 (nth 3 (thai-keyboard-info thai-current-keyboard-type)))) | |
124 | |
125 ;; Define RULES in Quail map. In addition, create | |
126 ;; `thai-consonant-alist-KEYBOARD-TYPE' and | |
127 ;; `thai-vowel-upper-lower-alist-KEYBOARD-TYPE'. | |
128 | |
129 ;; The general composing rules are as follows: | |
130 ;; | |
131 ;; T | |
132 ;; V T V T | |
133 ;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C | |
134 ;; v v | |
135 ;; | |
136 ;; where C: consonant, V: vowel upper, v: vowel lower, T: tone mark. | |
137 | |
138 (defmacro thai-quail-define-rules (keyboard-type &rest rules) | |
139 (let ((l rules) | |
140 consonant-alist | |
141 vowel-upper-lower-alist | |
142 rule trans ch c-set) | |
143 (while l | |
144 (setq rule (car l)) | |
145 (setq trans (nth 1 rule)) | |
146 (if (consp trans) | |
147 (setq trans (car trans))) | |
148 (setq c-set (char-category-set (string-to-char trans))) | |
149 (cond ((or (aref c-set ?2) | |
150 (aref c-set ?3)) | |
151 (setq consonant-alist | |
152 (cons (cons (string-to-char (car rule)) | |
153 'thai-vowel-upper-lower-input) | |
154 consonant-alist))) | |
155 ((aref c-set ?4) | |
156 (setq consonant-alist | |
157 (cons (cons (string-to-char (car rule)) | |
158 'thai-tone-input) | |
159 consonant-alist) | |
160 vowel-upper-lower-alist | |
161 (cons (cons (string-to-char (car rule)) | |
162 'thai-tone-input) | |
163 vowel-upper-lower-alist)))) | |
164 (setq l (cdr l))) | |
165 `(progn | |
166 (quail-define-rules ,@rules) | |
167 (setcar (nthcdr 2 (thai-keyboard-info ,keyboard-type)) | |
168 ',consonant-alist) | |
169 (setcar (nthcdr 3 (thai-keyboard-info ,keyboard-type)) | |
170 ',vowel-upper-lower-alist)))) | |
171 | |
172 ;; Return an alist which can be a cdr part of a Quail map | |
173 ;; corresponding to the current key when Thai consonant is entered. | |
174 (defun thai-consonant-input (key len) | |
175 (let ((quail-package-name (quail-name))) | |
176 (setq thai-current-keyboard-type | |
177 (cond ((string= quail-package-name "thai-pattachote") 'pattachote) | |
19409
c816908e9589
(thai-consonant-input): Typo fixed.
Kenichi Handa <handa@m17n.org>
parents:
18673
diff
changeset
|
178 ((string= quail-package-name "thai-kesmanee") 'kesmanee) |
c816908e9589
(thai-consonant-input): Typo fixed.
Kenichi Handa <handa@m17n.org>
parents:
18673
diff
changeset
|
179 (t (error "Invalid Quail package %s" quail-package-name)))) |
18673 | 180 (copy-alist (nth 2 (thai-keyboard-info thai-current-keyboard-type))))) |
181 | |
182 ;; Thai Kesmanee keyboard support. | |
183 | |
184 (quail-define-package | |
185 "thai-kesmanee" "Thai" ",T!!(B>" t | |
186 "Thai Kesmanee input method with TIS620 keyboard layout | |
187 | |
188 The difference from the ordinal Thai keyboard: | |
189 ',T_(B' and ',To(B' are assigned to '\\' and '|' respectively, | |
190 ',T#(B' and ',T%(B' are assigned to '`' and '~' respectively, | |
191 Don't know where to assign characters ',Tz(B' and ',T{(B'." | |
19722
dd39cae4cf0f
For each package, pass t for the SIMPLE
Kenichi Handa <handa@m17n.org>
parents:
19465
diff
changeset
|
192 nil t t nil t nil nil nil nil nil t) |
18673 | 193 |
194 (thai-quail-define-rules 'kesmanee | |
195 ("1" (",TE(B" . thai-consonant-input)) | |
196 ("!" "#") | |
197 ("2" "/") | |
198 ("@" ",Tq(B") | |
199 ("3" "_") | |
200 ("#" ",Tr(B") | |
201 ("4" (",T@(B" . thai-consonant-input)) | |
202 ("$" ",Ts(B") | |
203 ("5" (",T6(B" . thai-consonant-input)) | |
204 ("%" ",Tt(B") | |
205 ("6" ",TX(B") | |
206 ("^" ",TY(B") | |
207 ("7" ",TV(B") | |
208 ("&" "0,TQi1(B") | |
209 ("8" (",T$(B" . thai-consonant-input)) | |
210 ("*" ",Tu(B") | |
211 ("9" (",T5(B" . thai-consonant-input)) | |
212 ("\(" ",Tv(B") | |
213 ("0" (",T((B" . thai-consonant-input)) | |
214 ("\)" ",Tw(B") | |
215 ("-" (",T"(B" . thai-consonant-input)) | |
216 ("_" ",Tx(B") | |
217 ("=" (",T*(B" . thai-consonant-input)) | |
218 ("+" ",Ty(B") | |
219 ("\\" ",T_(B") | |
220 ("|" ",To(B") | |
221 ("`" (",T#(B" . thai-consonant-input)) | |
222 ("~" (",T%(B" . thai-consonant-input)) | |
223 ("q" ",Tf(B") | |
224 ("Q" ",Tp(B") | |
225 ("w" ",Td(B") | |
226 ("W" "\"") | |
227 ("e" ",TS(B") | |
228 ("E" (",T.(B" . thai-consonant-input)) | |
229 ("r" (",T>(B" . thai-consonant-input)) | |
230 ("R" (",T1(B" . thai-consonant-input)) | |
231 ("t" ",TP(B") | |
232 ("T" (",T8(B" . thai-consonant-input)) | |
233 ("y" ",TQ(B") | |
234 ("Y" ",Tm(B") | |
235 ("u" ",TU(B") | |
236 ("U" ",Tj(B") | |
237 ("i" (",TC(B" . thai-consonant-input)) | |
238 ("I" (",T3(B" . thai-consonant-input)) | |
239 ("o" (",T9(B" . thai-consonant-input)) | |
240 ("O" ",TO(B") | |
241 ("p" (",TB(B" . thai-consonant-input)) | |
242 ("P" (",T-(B" . thai-consonant-input)) | |
243 ("\[" (",T:(B" . thai-consonant-input)) | |
244 ("{" (",T0(B" . thai-consonant-input)) | |
245 ("\]" (",TE(B" . thai-consonant-input)) | |
246 ("}" ",") | |
247 | |
248 ("a" (",T?(B" . thai-consonant-input)) | |
249 ("A" ",TD(B") | |
250 ("s" (",TK(B" . thai-consonant-input)) | |
251 ("S" (",T&(B" . thai-consonant-input)) | |
252 ("d" (",T!(B" . thai-consonant-input)) | |
253 ("D" (",T/(B" . thai-consonant-input)) | |
254 ("f" (",T4(B" . thai-consonant-input)) | |
255 ("F" ",Tb(B") | |
256 ("g" ",T`(B") | |
257 ("G" (",T,(B" . thai-consonant-input)) | |
258 ("h" ",Ti(B") | |
259 ("H" ",Tg(B") | |
260 ("j" ",Th(B") | |
261 ("J" ",Tk(B") | |
262 ("k" ",TR(B") | |
263 ("K" (",TI(B" . thai-consonant-input)) | |
264 ("l" (",TJ(B" . thai-consonant-input)) | |
265 ("L" (",TH(B" . thai-consonant-input)) | |
266 ("\;" (",TG(B" . thai-consonant-input)) | |
267 (":" (",T+(B" . thai-consonant-input)) | |
268 ("'" (",T'(B" . thai-consonant-input)) | |
269 ("\"" ".") | |
270 | |
271 ("z" (",T<(B" . thai-consonant-input)) | |
272 ("Z" "(") | |
273 ("x" (",T;(B" . thai-consonant-input)) | |
274 ("X" ")") | |
275 ("c" ",Ta(B") | |
276 ("C" (",T)(B" . thai-consonant-input)) | |
277 ("v" (",TM(B" . thai-consonant-input)) | |
278 ("V" (",TN(B" . thai-consonant-input)) | |
279 ("b" ",TT(B") | |
280 ("B" ",TZ(B") | |
281 ("n" ",TW(B") | |
282 ("N" ",Tl(B") | |
283 ("m" (",T7(B" . thai-consonant-input)) | |
284 ("M" ",Tn(B") | |
285 ("," (",TA(B" . thai-consonant-input)) | |
286 ("<" (",T2(B" . thai-consonant-input)) | |
287 ("." ",Tc(B") | |
288 (">" (",TL(B" . thai-consonant-input)) | |
289 ("/" (",T=(B" . thai-consonant-input)) | |
290 ("?" ",TF(B") | |
291 ) | |
292 | |
293 | |
294 ;; Thai Pattachote keyboard support. | |
295 | |
296 (quail-define-package | |
297 "thai-pattachote" "Thai" ",T!;(B>" t | |
298 "Thai Pattachote input method with TIS620 keyboard layout" | |
19722
dd39cae4cf0f
For each package, pass t for the SIMPLE
Kenichi Handa <handa@m17n.org>
parents:
19465
diff
changeset
|
299 nil t t nil t nil nil nil nil nil t) |
18673 | 300 |
301 (thai-quail-define-rules 'pattachote | |
302 ("1" "=") | |
303 ("!" "+") | |
304 ("2" ",Tr(B") | |
305 ("@" "\"") | |
306 ("3" ",Ts(B") | |
307 ("#" "/") | |
308 ("4" ",Tt(B") | |
309 ("$" ",") | |
310 ("5" ",Tu(B") | |
311 ("%" "?") | |
312 ("6" ",TY(B") | |
313 ("^" ",TX(B") | |
314 ("7" ",Tw(B") | |
315 ("&" "_") | |
316 ("8" ",Tx(B") | |
317 ("*" ".") | |
318 ("9" ",Ty(B") | |
319 ("(" "(") | |
320 ("0" ",Tp(B") | |
321 (")" ")") | |
322 ("-" ",Tq(B") | |
323 ("_" "-") | |
324 ("=" ",Tv(B") | |
325 ("+" "%") | |
326 ("\\" ",TZ(B") | |
327 ("|" ",Tm(B") | |
328 ("`" (",T#(B" . thai-consonant-input)) | |
329 ("~" (",T%(B" . thai-consonant-input)) | |
330 | |
331 ("q" ",Tg(B") | |
332 ("Q" ",Tj(B") | |
333 ("w" (",T5(B" . thai-consonant-input)) | |
334 ("W" ",TD(B") | |
335 ("e" (",TB(B" . thai-consonant-input)) | |
336 ("E" ",Tf(B") | |
337 ("r" (",TM(B" . thai-consonant-input)) | |
338 ("R" (",T-(B" . thai-consonant-input)) | |
339 ("t" (",TC(B" . thai-consonant-input)) | |
340 ("T" (",TI(B" . thai-consonant-input)) | |
341 ("y" ",Th(B") | |
342 ("Y" ",TV(B") | |
343 ("u" (",T4(B" . thai-consonant-input)) | |
344 ("U" (",T=(B" . thai-consonant-input)) | |
345 ("i" (",TA(B" . thai-consonant-input)) | |
346 ("I" (",T+(B" . thai-consonant-input)) | |
347 ("o" (",TG(B" . thai-consonant-input)) | |
348 ("O" (",T6(B" . thai-consonant-input)) | |
349 ("p" ",Ta(B") | |
350 ("P" (",T2(B" . thai-consonant-input)) | |
351 ("\[" ",Tc(B") | |
352 ("{" ",TO(B") | |
353 ("\]" (",T2(B" . thai-consonant-input)) | |
354 ("}" ",TF(B") | |
355 | |
356 ("a" ",Ti(B") | |
357 ("A" ",Tk(B") | |
358 ("s" (",T7(B" . thai-consonant-input)) | |
359 ("S" (",T8(B" . thai-consonant-input)) | |
360 ("d" (",T'(B" . thai-consonant-input)) | |
361 ("D" ",TS(B") | |
362 ("f" (",T!(B" . thai-consonant-input)) | |
363 ("F" (",T3(B" . thai-consonant-input)) | |
364 ("g" ",TQ(B") | |
365 ("G" ",Tl(B") | |
366 ("h" ",TU(B") | |
367 ("H" ",TW(B") | |
368 ("j" ",TR(B") | |
369 ("J" (",T<(B" . thai-consonant-input)) | |
370 ("k" (",T9(B" . thai-consonant-input)) | |
371 ("K" (",T*(B" . thai-consonant-input)) | |
372 ("l" ",T`(B") | |
373 ("L" ",Tb(B") | |
374 (";" ",Td(B") | |
375 (":" (",T&(B" . thai-consonant-input)) | |
376 ("'" (",T"(B" . thai-consonant-input)) | |
377 ("\"" (",T1(B" . thai-consonant-input)) | |
378 | |
379 ("z" (",T:(B" . thai-consonant-input)) | |
380 ("Z" (",T.(B" . thai-consonant-input)) | |
381 ("x" (",T;(B" . thai-consonant-input)) | |
382 ("X" (",T.(B" . thai-consonant-input)) | |
383 ("c" (",TE(B" . thai-consonant-input)) | |
384 ("C" (",T0(B" . thai-consonant-input)) | |
385 ("v" (",TK(B" . thai-consonant-input)) | |
386 ("V" (",T@(B" . thai-consonant-input)) | |
387 ("b" ",TT(B") | |
388 ("B" ",TQ(B") | |
389 ("n" (",T$(B" . thai-consonant-input)) | |
390 ("N" (",TH(B" . thai-consonant-input)) | |
391 ("m" (",TJ(B" . thai-consonant-input)) | |
392 ("M" (",TN(B" . thai-consonant-input)) | |
393 ("," ",TP(B") | |
394 ("<" (",T?(B" . thai-consonant-input)) | |
395 ("." (",T((B" . thai-consonant-input)) | |
396 (">" (",T2(B" . thai-consonant-input)) | |
397 ("/" (",T>(B" . thai-consonant-input)) | |
398 ("?" (",TL(B" . thai-consonant-input)) | |
399 ) | |
400 | |
401 ;;; quail/thai.el ends here |