comparison leim/quail/thai.el @ 88155:d7ddb3e565de

sync with trunk
author Henrik Enberg <henrik.enberg@telia.com>
date Mon, 16 Jan 2006 00:03:54 +0000
parents 23a1cea22d13
children
comparison
equal deleted inserted replaced
88154:8ce476d3ba36 88155:d7ddb3e565de
1 ;;; thai.el --- Quail package for inputting Thai characters 1 ;;; thai.el --- Quail package for inputting Thai characters
2 2
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 3 ;; Copyright (C) 1995, 1997, 1999, 2005
4 ;; Licensed to the Free Software Foundation. 4 ;; National Institute of Advanced Industrial Science and Technology (AIST)
5 ;; Registration Number H14PRO021
5 6
6 ;; Keywords: multilingual, input method, Thai 7 ;; Keywords: multilingual, input method, Thai
7 8
8 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
9 10
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details. 19 ;; GNU General Public License for more details.
19 20
20 ;; You should have received a copy of the GNU General Public License 21 ;; 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 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02111-1307, USA. 24 ;; Boston, MA 02110-1301, USA.
24 25
25 ;;; Commentary: 26 ;;; Commentary:
26 27
27 ;;; Code: 28 ;;; Code:
28 29
29 (require 'quail) 30 (require 'quail)
30 (require 'thai-util) 31 (require 'thai-util)
31 32
32 (defun quail-thai-update-translation (control-flag) 33 (defmacro thai-generate-quail-map (translation-table)
33 (if (integerp control-flag) 34 (let (map)
34 ;; Non-composable character typed. 35 (dotimes (i (length translation-table))
35 (setq quail-current-str 36 (let ((trans (aref translation-table i)))
36 (buffer-substring (overlay-start quail-overlay) 37 (when (not (eq trans 0))
37 (overlay-end quail-overlay)) 38 (if (> (length trans) 1)
38 unread-command-events 39 (setq trans (vector trans))
39 (string-to-list 40 (setq trans (aref trans 0)))
40 (substring quail-current-key control-flag))) 41 (setq map (cons (list (char-to-string i) trans) map)))))
41 (setq quail-current-str 42 `(quail-define-rules ,@map)))
42 (compose-string (quail-lookup-map-and-concat quail-current-key))))
43 control-flag)
44
45 (defun thai-generate-quail-map (translation-table)
46 (let ((i 0)
47 consonant vowel tone voweltone others)
48 ;; Categorize Thai characters into one of above.
49 (while (< i 128)
50 (let ((trans (aref translation-table i))
51 ptype)
52 (if (eq trans 0)
53 nil
54 (if (> (length trans) 1)
55 (setq ptype 'voweltone
56 trans (vector (compose-string trans)))
57 (setq ptype (get-char-code-property (aref trans 0) 'phonetic-type))
58 (cond ((memq ptype '(vowel-upper vowel-lower))
59 (setq ptype 'vowel))
60 ((not (memq ptype '(consonant tone)))
61 (setq ptype 'others))))
62 (set ptype (cons (cons (char-to-string i) trans)
63 (symbol-value ptype)))))
64 (setq i (1+ i)))
65
66 (quail-map-from-table
67 '((base-state (consonant . vt-state)
68 vowel tone voweltone others)
69 (vt-state (vowel . t-state)
70 voweltone tone)
71 (t-state tone)))))
72 43
73 ;; Thai Kesmanee keyboard support. 44 ;; Thai Kesmanee keyboard support.
74 45
75 (quail-define-package 46 (quail-define-package
76 "thai-kesmanee" "Thai" ",T!!(B>" t 47 "thai-kesmanee" "Thai" ",T!!(B>" t
78 49
79 The difference from the ordinal Thai keyboard: 50 The difference from the ordinal Thai keyboard:
80 ',T_(B' and ',To(B' are assigned to '\\' and '|' respectively, 51 ',T_(B' and ',To(B' are assigned to '\\' and '|' respectively,
81 ',T#(B' and ',T%(B' are assigned to '`' and '~' respectively, 52 ',T#(B' and ',T%(B' are assigned to '`' and '~' respectively,
82 Don't know where to assign characters ',Tz(B' and ',T{(B'." 53 Don't know where to assign characters ',Tz(B' and ',T{(B'."
83 nil t t t t nil nil nil 'quail-thai-update-translation nil t) 54 nil t t t t nil nil nil nil nil t)
84 55
85 (quail-install-map 56 (quail-install-map
86 (thai-generate-quail-map 57 (thai-generate-quail-map
87 [ 58 [
88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes 59 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes
89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes
90 0 "#" "." ",Tr(B" ",Ts(B" ",Tt(B" ",TQi(B" ",T'(B" ; SPC .. ' 61 ;; This data is quite old.
62 ;; 0 "#" "." ",Tr(B" ",Ts(B" ",Tt(B" ",TQi(B" ",T'(B" ; SPC .. '
63 ;; ",Tv(B" ",Tw(B" ",Tu(B" ",Ty(B" ",TA(B" ",T"(B" ",Tc(B" ",T=(B" ; ( .. /
64 ;; ",T((B" ",TE(B" "/" "_" ",T@(B" ",T6(B" ",TX(B" ",TV(B" ; 0 .. 7
65 ;; ",T$(B" ",T5(B" ",T+(B" ",TG(B" ",T2(B" ",T*(B" ",TL(B" ",TF(B" ; 8 .. ?
66 ;; ",Tq(B" ",TD(B" ",TZ(B" ",T)(B" ",T/(B" ",T.(B" ",Tb(B" ",T,(B" ; @ .. G
67 ;; ",Tg(B" ",T3(B" ",Tk(B" ",TI(B" ",TH(B" ",Tn(B" ",Tl(B" ",TO(B" ; H .. O
68 ;; ",T-(B" ",Tp(B" ",T1(B" ",T&(B" ",T8(B" ",Tj(B" ",TN(B" "\"" ; P .. W
69 ;; ")" ",Tm(B" "(" ",T:(B" ",T_(B" ",TE(B" ",TY(B" ",Tx(B" ; X .. _
70 ;; ",T#(B" ",T?(B" ",TT(B" ",Ta(B" ",T!(B" ",TS(B" ",T4(B" ",T`(B" ; ` .. g
71 ;; ",Ti(B" ",TC(B" ",Th(B" ",TR(B" ",TJ(B" ",T7(B" ",TW(B" ",T9(B" ; h .. o
72 ;; ",TB(B" ",Tf(B" ",T>(B" ",TK(B" ",TP(B" ",TU(B" ",TM(B" ",Td(B" ; p .. w
73 ;; ",T;(B" ",TQ(B" ",T<(B" ",T0(B" ",To(B" "," ",T%(B" 0 ; x .. DEL
74 ;; This is the correct data nowadays.
75 0 "+" "." ",Tr(B" ",Ts(B" ",Tt(B" ",T_(B" ",T'(B" ; SPC .. '
91 ",Tv(B" ",Tw(B" ",Tu(B" ",Ty(B" ",TA(B" ",T"(B" ",Tc(B" ",T=(B" ; ( .. / 76 ",Tv(B" ",Tw(B" ",Tu(B" ",Ty(B" ",TA(B" ",T"(B" ",Tc(B" ",T=(B" ; ( .. /
92 ",T((B" ",TE(B" "/" "_" ",T@(B" ",T6(B" ",TX(B" ",TV(B" ; 0 .. 7 77 ",T((B" ",Te(B" "/" "-" ",T@(B" ",T6(B" ",TX(B" ",TV(B" ; 0 .. 7
93 ",T$(B" ",T5(B" ",T+(B" ",TG(B" ",T2(B" ",T*(B" ",TL(B" ",TF(B" ; 8 .. ? 78 ",T$(B" ",T5(B" ",T+(B" ",TG(B" ",T2(B" ",T*(B" ",TL(B" ",TF(B" ; 8 .. ?
94 ",Tq(B" ",TD(B" ",TZ(B" ",T)(B" ",T/(B" ",T.(B" ",Tb(B" ",T,(B" ; @ .. G 79 ",Tq(B" ",TD(B" ",TZ(B" ",T)(B" ",T/(B" ",T.(B" ",Tb(B" ",T,(B" ; @ .. G
95 ",Tg(B" ",T3(B" ",Tk(B" ",TI(B" ",TH(B" ",Tn(B" ",Tl(B" ",TO(B" ; H .. O 80 ",Tg(B" ",T3(B" ",Tk(B" ",TI(B" ",TH(B" "?" ",Tl(B" ",TO(B" ; H .. O
96 ",T-(B" ",Tp(B" ",T1(B" ",T&(B" ",T8(B" ",Tj(B" ",TN(B" "\"" ; P .. W 81 ",T-(B" ",Tp(B" ",T1(B" ",T&(B" ",T8(B" ",Tj(B" ",TN(B" "\"" ; P .. W
97 ")" ",Tm(B" "(" ",T:(B" ",T_(B" ",TE(B" ",TY(B" ",Tx(B" ; X .. _ 82 "\)" ",Tm(B" "\(" ",T:(B" ",T#(B" ",TE(B" ",TY(B" ",Tx(B" ; X .. _
98 ",T#(B" ",T?(B" ",TT(B" ",Ta(B" ",T!(B" ",TS(B" ",T4(B" ",T`(B" ; ` .. g 83 "_" ",T?(B" ",TT(B" ",Ta(B" ",T!(B" ",TS(B" ",T4(B" ",T`(B" ; ` .. g
99 ",Ti(B" ",TC(B" ",Th(B" ",TR(B" ",TJ(B" ",T7(B" ",TW(B" ",T9(B" ; h .. o 84 ",Ti(B" ",TC(B" ",Th(B" ",TR(B" ",TJ(B" ",T7(B" ",TW(B" ",T9(B" ; h .. o
100 ",TB(B" ",Tf(B" ",T>(B" ",TK(B" ",TP(B" ",TU(B" ",TM(B" ",Td(B" ; p .. w 85 ",TB(B" ",Tf(B" ",T>(B" ",TK(B" ",TP(B" ",TU(B" ",TM(B" ",Td(B" ; p .. w
101 ",T;(B" ",TQ(B" ",T<(B" ",T0(B" ",To(B" "," ",T%(B" 0 ; x .. DEL 86 ",T;(B" ",TQ(B" ",T<(B" ",T0(B" ",T%(B" "," "%" 0 ; x .. DEL
102 ])) 87 ]))
103 88
104 89
105 90
106 ;; Thai Pattachote keyboard support. 91 ;; Thai Pattachote keyboard support.
107 92
108 (quail-define-package 93 (quail-define-package
109 "thai-pattachote" "Thai" ",T!;(B>" t 94 "thai-pattachote" "Thai" ",T!;(B>" t
110 "Thai Pattachote input method with TIS620 keyboard layout" 95 "Thai Pattachote input method with TIS620 keyboard layout"
111 nil t t t t nil nil nil 'quail-thai-update-translation nil t) 96 nil t t t t nil nil nil nil nil t)
112 97
113 (quail-install-map 98 (quail-install-map
114 (thai-generate-quail-map 99 (thai-generate-quail-map
115 [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes 100 [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes
116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes 101 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; control codes
126 ",TU(B" ",TA(B" ",TR(B" ",T9(B" ",T`(B" ",TJ(B" ",T$(B" ",TG(B" ; h .. o 111 ",TU(B" ",TA(B" ",TR(B" ",T9(B" ",T`(B" ",TJ(B" ",T$(B" ",TG(B" ; h .. o
127 ",Ta(B" ",Tg(B" ",TM(B" ",T7(B" ",TC(B" ",T4(B" ",TK(B" ",T5(B" ; p .. w 112 ",Ta(B" ",Tg(B" ",TM(B" ",T7(B" ",TC(B" ",T4(B" ",TK(B" ",T5(B" ; p .. w
128 ",T;(B" ",Th(B" ",T:(B" ",TO(B" ",Tm(B" ",TF(B" ",T%(B" 0 ; x .. DEL 113 ",T;(B" ",Th(B" ",T:(B" ",TO(B" ",Tm(B" ",TF(B" ",T%(B" 0 ; x .. DEL
129 ])) 114 ]))
130 115
116 ;;; arch-tag: fed6c468-0616-44b0-88bf-47347bf64825
131 ;;; thai.el ends here 117 ;;; thai.el ends here