Merge from trunk.
[bpt/emacs.git] / leim / quail / lao.el
CommitLineData
4b725a70 1;;; lao.el --- Quail package for inputting Lao characters -*-coding: utf-8;-*-
24b31c88 2
03ba6797 3;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5df4f04c 4;; 2006, 2007, 2008, 2009, 2010, 2011
a3341d3c
KH
5;; National Institute of Advanced Industrial Science and Technology (AIST)
6;; Registration Number H14PRO021
24b31c88
KH
7
8;; Keywords: multilingual, input method, Lao
9
10;; This file is part of GNU Emacs.
11
3d544458 12;; GNU Emacs is free software: you can redistribute it and/or modify
24b31c88 13;; it under the terms of the GNU General Public License as published by
3d544458
GM
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) any later version.
24b31c88
KH
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
3d544458 23;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24b31c88 24
be567141
PJ
25;;; Commentary:
26
24b31c88
KH
27;;; Code:
28
29(require 'quail)
30(require 'lao-util)
31
653b6bad
KH
32(defun quail-lao-update-translation (control-flag)
33 (if (integerp control-flag)
34 ;; Non-composable character typed.
35 (setq quail-current-str
36 (buffer-substring (overlay-start quail-overlay)
37 (overlay-end quail-overlay))
38 unread-command-events
39 (string-to-list
40 (substring quail-current-key control-flag)))
41 (setq quail-current-str
42 (compose-string (quail-lookup-map-and-concat quail-current-key))))
43 control-flag)
44
a3341d3c 45(defvar lao-key-alist
653b6bad
KH
46 '(("!" . "1")
47 ("\"" . "=")
48 ("#" . "3")
49 ("$" . "4")
50 ("&" . "5")
4b725a70
PE
51 ("%" . "໌")
52 ("'" . "ງ")
653b6bad
KH
53 ("(" . "7")
54 (")" . "8")
55 ("*" . "6")
4b725a70
PE
56 ("+" . ["ໍ່"])
57 ("," . "ມ")
58 ("-" . "ຊ")
59 ("." . "ໃ")
60 ("/" . "ຝ")
61 ("0" . "ຂ")
62 ("1" . "ຢ")
63 ("2" . "ຟ")
64 ("3" . "ໂ")
65 ("4" . "ຖ")
66 ("5" . "ຸ")
67 ("6" . "ູ")
68 ("7" . "ຄ")
69 ("8" . "ຕ")
70 ("9" . "ຈ")
653b6bad 71 (":" . "%")
4b725a70
PE
72 (";" . "ວ")
73 ("<" . "ໝ")
74 ("=" . "ໍ")
653b6bad
KH
75 (">" . "$")
76 ("?" . ")")
77 ("@" . "2")
4b725a70
PE
78 ("A" . ["ັ້"])
79 ("B" . ["ຶ້"])
80 ("C" . "ຯ")
653b6bad 81 ("D" . ".")
4b725a70 82 ("E" . ["ຳ້"])
653b6bad
KH
83 ("F" . ",")
84 ("G" . ":")
4b725a70
PE
85 ("H" . "໊")
86 ("I" . "ຮ")
87 ("J" . "໋")
653b6bad
KH
88 ("K" . "!")
89 ("L" . "?")
4b725a70
PE
90 ("M" . "ໆ")
91 ("N" . ["ື້"])
92 ("O" . "ໜ")
93 ("P" . "ຽ")
94 ("Q" . ["ົ້"])
653b6bad
KH
95 ("R" . "_")
96 ("S" . ";")
97 ("T" . "+")
4b725a70 98 ("U" . ["ີ້"])
653b6bad
KH
99 ("V" . "x")
100 ("W" . "0")
101 ("X" . "(")
4b725a70 102 ("Y" . ["ິ້"])
653b6bad 103 ("Z" . "\"")
4b725a70
PE
104 ("[" . "ບ")
105 ("]" . "ລ")
106 ("^" . "ຼ")
653b6bad 107 ("_" . "9")
4b725a70
PE
108 ("`" . "ງ")
109 ("a" . "ັ")
110 ("b" . "ຶ")
111 ("c" . "ແ")
112 ("d" . "ກ")
113 ("e" . "ຳ")
114 ("f" . "ດ")
115 ("g" . "ເ")
116 ("h" . "້")
117 ("i" . "ຣ")
118 ("j" . "່")
119 ("k" . "າ")
120 ("l" . "ສ")
121 ("m" . "ທ")
122 ("n" . "ື")
123 ("o" . "ນ")
124 ("p" . "ຍ")
125 ("q" . "ົ")
126 ("r" . "ພ")
127 ("s" . "ຫ")
128 ("t" . "ະ")
129 ("u" . "ີ")
130 ("v" . "ອ")
131 ("w" . "ໄ")
132 ("x" . "ປ")
133 ("y" . "ິ")
134 ("z" . "ຜ")
653b6bad 135 ("{" . "-")
4b725a70 136 ("|" . ["ຫຼ"])
653b6bad 137 ("}" . "/")
4b725a70
PE
138 ("~" . "໌")
139 ("\\0" . "໐")
140 ("\\1" . "໑")
141 ("\\2" . "໒")
142 ("\\3" . "໓")
143 ("\\4" . "໔")
144 ("\\5" . "໕")
145 ("\\6" . "໖")
146 ("\\7" . "໗")
147 ("\\8" . "໘")
148 ("\\9" . "໙")
a3341d3c
KH
149 )
150 "Alist of key sequences vs the corresponding Lao string to input.
151This variable is for the input method \"lao\".
152If you change the value of this variable while quail/lao is already loaded,
153you need to re-load it to properly re-initialize related alists.")
154
155;; Temporary variable to initialize lao-consonant-key-alist, etc.
156(defconst lao-key-alist-vector
157 (let ((tail lao-key-alist)
4b725a70 158 consonant-key-alist semivowel-key-alist vowel-key-alist
a3341d3c
KH
159 voweltone-key-alist tone-key-alist other-key-alist
160 elt phonetic-type)
161 (while tail
162 (setq elt (car tail) tail (cdr tail))
163 (if (stringp (cdr elt))
164 (setq phonetic-type (get-char-code-property (aref (cdr elt) 0)
165 'phonetic-type))
166 (setq phonetic-type (get-char-code-property (aref (aref (cdr elt) 0) 0)
653b6bad 167 'phonetic-type))
a3341d3c
KH
168 (aset (cdr elt) 0 (compose-string (aref (cdr elt) 0))))
169 (cond ((eq phonetic-type 'consonant)
170 (setq consonant-key-alist (cons elt consonant-key-alist)))
171 ((memq phonetic-type '(vowel-upper vowel-lower))
172 (if (stringp (cdr elt))
173 (setq vowel-key-alist (cons elt vowel-key-alist))
174 (setq voweltone-key-alist (cons elt voweltone-key-alist))))
175 ((eq phonetic-type 'tone)
176 (setq tone-key-alist (cons elt tone-key-alist)))
177 ((eq phonetic-type 'semivowel-lower)
178 (setq semivowel-key-alist (cons elt semivowel-key-alist)))
179 (t
180 (setq other-key-alist (cons elt other-key-alist)))))
4b725a70 181 (vector consonant-key-alist semivowel-key-alist vowel-key-alist
a3341d3c
KH
182 voweltone-key-alist tone-key-alist other-key-alist)))
183
184(defconst lao-consonant-key-alist (aref lao-key-alist-vector 0))
185(defconst lao-semivowel-key-alist (aref lao-key-alist-vector 1))
186(defconst lao-vowel-key-alist (aref lao-key-alist-vector 2))
187(defconst lao-voweltone-key-alist (aref lao-key-alist-vector 3))
188(defconst lao-tone-key-alist (aref lao-key-alist-vector 4))
189(defconst lao-other-key-alist (aref lao-key-alist-vector 5))
190
191;; Done with it.
192(makunbound 'lao-key-alist-vector)
24b31c88
KH
193
194(quail-define-package
4b725a70 195 "lao" "Lao" "ລ" t
24b31c88 196 "Lao input method simulating Lao keyboard layout based on Thai TIS620"
653b6bad
KH
197 nil t t t t nil nil nil 'quail-lao-update-translation nil t)
198
199(quail-install-map
200 (quail-map-from-table
201 '((base-state (lao-consonant-key-alist . svt-state)
202 lao-vowel-key-alist
203 lao-voweltone-key-alist
204 lao-tone-key-alist
205 lao-other-key-alist)
206 (svt-state (lao-semivowel-key-alist . v-state)
3d587afd
KH
207 (lao-vowel-key-alist . t-state)
208 lao-voweltone-key-alist
209 lao-tone-key-alist)
653b6bad
KH
210 (v-state (lao-vowel-key-alist . t-state))
211 (t-state lao-tone-key-alist))))
24b31c88 212
be567141 213;;; lao.el ends here