Mercurial > hg > xemacs-beta
comparison lisp/leim/quail/thai.el @ 155:43dd3413c7c7 r20-3b4
Import from CVS: tag r20-3b4
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:39:39 +0200 |
parents | |
children | acd284d43ca1 |
comparison
equal
deleted
inserted
replaced
154:94141801dd7e | 155:43dd3413c7c7 |
---|---|
1 ;;; quail/thai.el --- Quail package for inputting Thai characters | |
2 | |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
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 | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 ;;; Code: | |
25 | |
26 (require 'quail) | |
27 (require 'language/thai-util) | |
28 | |
29 (eval-and-compile | |
30 | |
31 (defvar thai-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 "#" ",TF(B" ",Tr(B" ",Ts(B" ",Tt(B" "0,TQi1(B" ",T'(B" ; SPC .. ' | |
35 ",Tv(B" ",Tw(B" ",Tu(B" ",Ty(B" ",TA(B" ",T"(B" ",Tc(B" ",T=(B" ; ( .. / | |
36 ",T((B" ",TE(B" "/" "_" ",T@(B" ",T6(B" ",TX(B" ",TV(B" ; 0 .. 7 | |
37 ",T$(B" ",T5(B" ",T+(B" ",TG(B" ",T2(B" ",T*(B" ",TL(B" 0 ; 8 .. ? | |
38 ",Tq(B" ",TD(B" ",TZ(B" ",T)(B" ",T/(B" ",T.(B" ",Tb(B" ",T,(B" ; @ .. G | |
39 ",Tg(B" ",T3(B" ",Tk(B" ",TI(B" ",TH(B" ",Tn(B" ",Tl(B" ",TO(B" ; H .. O | |
40 ",T-(B" ",Tp(B" ",T1(B" ",T&(B" ",T8(B" ",Tj(B" ",TN(B" "\"" ; P .. W | |
41 ")" ",Tm(B" "(" ",T:(B" ",T_(B" ",TE(B" ",TY(B" ",Tx(B" ; X .. _ | |
42 ",T#(B" ",T?(B" ",TT(B" ",Ta(B" ",T!(B" ",TS(B" ",T4(B" ",T`(B" ; ` .. g | |
43 ",Ti(B" ",TC(B" ",Th(B" ",TR(B" ",TJ(B" ",T7(B" ",TW(B" ",T9(B" ; h .. o | |
44 ",TB(B" ",Tf(B" ",T>(B" ",TK(B" ",TP(B" ",TU(B" ",TM(B" ",Td(B" ; p .. w | |
45 ",T;(B" ",TQ(B" ",T<(B" ",T0(B" ",To(B" "," ",T%(B" 0] ; x .. DEL | |
46 "A table which maps ASCII key codes to corresponding Thai characters." | |
47 ) | |
48 | |
49 ) | |
50 | |
51 ;; Template of a cdr part of a Quail map when a consonant is entered. | |
52 (defvar thai-consonant-alist nil) | |
53 ;; Template of a cdr part of a Quail map when a vowel upper or a vowel | |
54 ;; lower is entered. | |
55 (defvar thai-vowel-upper-lower-alist nil) | |
56 | |
57 ;; Return a Quail map corresponding to KEY of length LEN. | |
58 ;; The car part of the map is a translation generated automatically. | |
59 ;; The cdr part of the map is a copy of ALIST. | |
60 (defun thai-generate-quail-map (key len alist) | |
61 (let ((str "") | |
62 (idx 0)) | |
63 (while (< idx len) | |
64 (setq str (concat str (aref thai-keyboard-mapping (aref key idx))) | |
65 idx (1+ idx))) | |
66 (cons (string-to-char (compose-string str)) (copy-alist alist)))) | |
67 | |
68 ;; Return a Quail map corresponding to KEY of length LEN when Thai | |
69 ;; tone mark is entered. | |
70 (defun thai-tone-input (key len) | |
71 (thai-generate-quail-map key len nil)) | |
72 | |
73 ;; Return a Quail map corresponding to KEY of length LEN when Thai | |
74 ;; vowel upper or vowel lower is entered. | |
75 (defun thai-vowel-upper-lower-input (key len) | |
76 (thai-generate-quail-map key len thai-vowel-upper-lower-alist)) | |
77 | |
78 ;; Return an alist which can be a cdr part of a Quail map | |
79 ;; corresponding to the current key when Thai consonant is entered. | |
80 (defun thai-consonant-input (key len) | |
81 (copy-alist thai-consonant-alist)) | |
82 | |
83 (quail-define-package "quail-thai" "Thai" "Thai" t | |
84 "Thai input method with TIS620 characters: | |
85 | |
86 The difference from the ordinal Thai keyboard: | |
87 ',T_(B' and ',To(B' are assigned to '\\' and '|' respectively, | |
88 ',T#(B' and ',T%(B' are assigned to '`' and '~' respectively, | |
89 Don't know where to assign characters ',Tz(B' and ',T{(B'." | |
90 nil t t nil t) | |
91 | |
92 ;; Define RULES in Quail map. In addition, create | |
93 ;; `thai-conconant-map' and `thai-vowel-upper-lower-alist' | |
94 ;; The general composing rules are as follows: | |
95 ;; | |
96 ;; T | |
97 ;; V T V T | |
98 ;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C | |
99 ;; v v | |
100 ;; | |
101 ;; where C: consonant, V: vowel upper, v: vowel lower, T: tone mark. | |
102 | |
103 (defmacro thai-quail-define-rules (&rest rules) | |
104 (let ((l rules) | |
105 consonant-alist | |
106 vowel-upper-lower-alist | |
107 rule trans ch c-set) | |
108 (while l | |
109 (setq rule (car l)) | |
110 (setq trans (nth 1 rule)) | |
111 (if (consp trans) | |
112 (setq trans (car trans))) | |
113 (setq c-set (char-category-set (string-to-char trans))) | |
114 (cond ((or (aref c-set ?2) | |
115 (aref c-set ?3)) | |
116 (setq consonant-alist | |
117 (cons (cons (string-to-char (car rule)) | |
118 'thai-vowel-upper-lower-input) | |
119 consonant-alist))) | |
120 ((aref c-set ?4) | |
121 (setq consonant-alist | |
122 (cons (cons (string-to-char (car rule)) | |
123 'thai-tone-input) | |
124 consonant-alist) | |
125 vowel-upper-lower-alist | |
126 (cons (cons (string-to-char (car rule)) | |
127 'thai-tone-input) | |
128 vowel-upper-lower-alist)))) | |
129 (setq l (cdr l))) | |
130 (list 'progn | |
131 (cons 'quail-define-rules rules) | |
132 `(setq thai-consonant-alist ',consonant-alist | |
133 thai-vowel-upper-lower-alist ',vowel-upper-lower-alist)))) | |
134 | |
135 (thai-quail-define-rules | |
136 ("1" (",TE(B" . thai-consonant-input)) | |
137 ("!" "#") | |
138 ("2" "/") | |
139 ("@" (",Tq(B" . thai-consonant-input)) | |
140 ("3" "_") | |
141 ("#" (",Tr(B" . thai-consonant-input)) | |
142 ("4" (",T@(B" . thai-consonant-input)) | |
143 ("$" (",Ts(B" . thai-consonant-input)) | |
144 ("5" (",T6(B" . thai-consonant-input)) | |
145 ("%" (",Tt(B" . thai-consonant-input)) | |
146 ("6" ",TX(B") | |
147 ("^" ",TY(B") | |
148 ("7" ",TV(B") | |
149 ("&" "0,TQi1(B") | |
150 ("8" (",T$(B" . thai-consonant-input)) | |
151 ("*" (",Tu(B" . thai-consonant-input)) | |
152 ("9" (",T5(B" . thai-consonant-input)) | |
153 ("\(" (",Tv(B" . thai-consonant-input)) | |
154 ("0" (",T((B" . thai-consonant-input)) | |
155 ("\)" (",Tw(B" . thai-consonant-input)) | |
156 ("-" (",T"(B" . thai-consonant-input)) | |
157 ("_" (",Tx(B" . thai-consonant-input)) | |
158 ("=" (",T*(B" . thai-consonant-input)) | |
159 ("+" (",Ty(B" . thai-consonant-input)) | |
160 ("\\" (",T_(B" . thai-consonant-input)) | |
161 ("|" (",To(B" . thai-consonant-input)) | |
162 ("`" (",T#(B" . thai-consonant-input)) | |
163 ("~" (",T%(B" . thai-consonant-input)) | |
164 ("q" ",Tf(B") | |
165 ("Q" ",Tp(B") | |
166 ("w" ",Td(B") | |
167 ("W" "\"") | |
168 ("e" ",TS(B") | |
169 ("E" (",T.(B" . thai-consonant-input)) | |
170 ("r" (",T>(B" . thai-consonant-input)) | |
171 ("R" (",T1(B" . thai-consonant-input)) | |
172 ("t" ",TP(B") | |
173 ("T" (",T8(B" . thai-consonant-input)) | |
174 ("y" ",TQ(B") | |
175 ("Y" ",Tm(B") | |
176 ("u" ",TU(B") | |
177 ("U" ",Tj(B") | |
178 ("i" (",TC(B" . thai-consonant-input)) | |
179 ("I" (",T3(B" . thai-consonant-input)) | |
180 ("o" (",T9(B" . thai-consonant-input)) | |
181 ("O" (",TO(B" . thai-consonant-input)) | |
182 ("p" (",TB(B" . thai-consonant-input)) | |
183 ("P" (",T-(B" . thai-consonant-input)) | |
184 ("\[" (",T:(B" . thai-consonant-input)) | |
185 ("{" (",T0(B" . thai-consonant-input)) | |
186 ("\]" (",TE(B" . thai-consonant-input)) | |
187 ("}" ",") | |
188 | |
189 ("a" (",T?(B" . thai-consonant-input)) | |
190 ("A" ",TD(B") | |
191 ("s" (",TK(B" . thai-consonant-input)) | |
192 ("S" (",T&(B" . thai-consonant-input)) | |
193 ("d" (",T!(B" . thai-consonant-input)) | |
194 ("D" (",T/(B" . thai-consonant-input)) | |
195 ("f" (",T4(B" . thai-consonant-input)) | |
196 ("F" ",Tb(B") | |
197 ("g" ",T`(B") | |
198 ("G" (",T,(B" . thai-consonant-input)) | |
199 ("h" ",Ti(B") | |
200 ("H" ",Tg(B") | |
201 ("j" ",Th(B") | |
202 ("J" ",Tk(B") | |
203 ("k" ",TR(B") | |
204 ("K" (",TI(B" . thai-consonant-input)) | |
205 ("l" (",TJ(B" . thai-consonant-input)) | |
206 ("L" (",TH(B" . thai-consonant-input)) | |
207 ("\;" (",TG(B" . thai-consonant-input)) | |
208 (":" (",T+(B" . thai-consonant-input)) | |
209 ("'" (",T'(B" . thai-consonant-input)) | |
210 ("\"" ".") | |
211 | |
212 ("z" (",T<(B" . thai-consonant-input)) | |
213 ("Z" "(") | |
214 ("x" (",T;(B" . thai-consonant-input)) | |
215 ("X" ")") | |
216 ("c" ",Ta(B") | |
217 ("C" (",T)(B" . thai-consonant-input)) | |
218 ("v" (",TM(B" . thai-consonant-input)) | |
219 ("V" (",TN(B" . thai-consonant-input)) | |
220 ("b" ",TT(B") | |
221 ("B" ",TZ(B") | |
222 ("n" ",TW(B") | |
223 ("N" ",Tl(B") | |
224 ("m" (",T7(B" . thai-consonant-input)) | |
225 ("M" ",Tn(B") | |
226 ("," (",TA(B" . thai-consonant-input)) | |
227 ("<" (",T2(B" . thai-consonant-input)) | |
228 ("." ",Tc(B") | |
229 (">" (",TL(B" . thai-consonant-input)) | |
230 ("/" (",T=(B" . thai-consonant-input)) | |
231 ("\"" ",TF(B") | |
232 ) | |
233 | |
234 ;;; quail/thai.el ends here |