3b41d18970fa361d5c7c4ae23a6ffb3a8744b794
[elisp/egg.git] / its / thai.el
1 ;;; its/thai.el --- Inputting Thai characters in Egg Input Method Architecture
2
3 ;; Copyright (C) 1998 Mule Project,
4 ;; Powered by Electrotechnical Laboratory, JAPAN.
5 ;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
6
7 ;; Author: KATAYAMA Yoshio <kate@pfu.co.jp>
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28
29 ;;; Code:
30
31 (eval-when-compile
32   (require 'its)
33   (require 'cl)
34
35   (defmacro define-its-thai-keymap (&rest rule)
36     (let (input output type list)
37       (while rule
38         (setq input  (car (car rule))
39               output (nth 1 (car rule))
40               type   (nth 2 (car rule))
41               rule   (cdr rule)
42               list   (cons `(its-defrule ,input ,output) list))
43         (if type
44             (setq list (cons `(setq ,type (cons (cons ,input ,output) ,type))
45                              list))))
46       `(let (consonant vowel tone)
47          ,@list
48          (its-define-thai-composit consonant vowel tone))))
49
50   (defun its-define-thai-composit (consonant vowel tone)
51     (let (pair state)
52       (while consonant
53         (setq pair (car consonant)
54               consonant (cdr consonant))
55         (setq state (its-goto-state (car pair)))
56         (its-make-next-state state -1 (aref (cdr pair) 0) (cdr pair))
57         (its-define-thai-add-vowel state (car pair) (cdr pair) vowel tone)
58         (its-define-thai-add-tone state (car pair) (cdr pair) tone)
59         (its-defrule-otherwise state (cdr pair)))))
60
61   (defun its-define-thai-add-vowel (state keyseq output vowel tone)
62     (let (next-state next-key next-keyseq next-output composed-output)
63       (while vowel
64         (setq next-key (car (car vowel))
65               next-keyseq (concat keyseq next-key)
66               next-output (concat output (cdr (car vowel)))
67               composed-output (compose-string next-output)
68               vowel (cdr vowel))
69         (setq next-state (its-make-next-state state
70                                               (aref next-key 0)
71                                               next-keyseq
72                                               composed-output))
73         (its-make-next-state next-state -1 next-keyseq composed-output)
74         (its-define-thai-add-tone next-state next-keyseq next-output tone)
75         (its-defrule-otherwise next-state composed-output))))
76
77   (defun its-define-thai-add-tone (state keyseq output tone)
78     (let (next-state next-key next-keyseq next-output composed-output)
79       (while tone
80         (setq next-key (car (car tone))
81               next-keyseq (concat keyseq next-key)
82               next-output (concat output (cdr (car tone)))
83               composed-output (compose-string next-output)
84               tone (cdr tone))
85         (setq next-state (its-make-next-state state
86                                               (aref next-key 0)
87                                               next-keyseq
88                                               composed-output))))))
89
90 ;; Thai Kesmanee keyboard support.
91
92 (define-its-state-machine its-thai-kesmanee-map
93   "kesmanee" "\e,T!!\e(B" 'Thai
94   "Map for Thai Kesmanee input method with TIS620 keyboard. (Thai)"
95
96   (define-its-thai-keymap
97     ("1"  "\e,TE\e(B" consonant)    ("!"  "#")
98     ("2"  "/")              ("@"  "\e,Tq\e(B")
99     ("3"  "_")              ("#"  "\e,Tr\e(B")
100     ("4"  "\e,T@\e(B" consonant)    ("$"  "\e,Ts\e(B")
101     ("5"  "\e,T6\e(B" consonant)    ("%"  "\e,Tt\e(B")
102     ("6"  "\e,TX\e(B" vowel)        ("^"  "\e,TY\e(B" vowel)
103     ("7"  "\e,TV\e(B" vowel)        ("&"  "\e0\e,TQi\e1\e(B" vowel)
104     ("8"  "\e,T$\e(B" consonant)    ("*"  "\e,Tu\e(B")
105     ("9"  "\e,T5\e(B" consonant)    ("("  "\e,Tv\e(B")
106     ("0"  "\e,T(\e(B" consonant)    (")"  "\e,Tw\e(B")
107     ("-"  "\e,T"\e(B" consonant)    ("_"  "\e,Tx\e(B")
108     ("="  "\e,T*\e(B" consonant)    ("+"  "\e,Ty\e(B")
109     ("\\" "\e,T_\e(B")              ("|"  "\e,To\e(B")
110     ("`"  "\e,T#\e(B" consonant)    ("~"  "\e,T%\e(B" consonant)
111
112     ("q"  "\e,Tf\e(B")              ("Q"  "\e,Tp\e(B")
113     ("w"  "\e,Td\e(B")              ("W"  "\"")
114     ("e"  "\e,TS\e(B")              ("E"  "\e,T.\e(B" consonant)
115     ("r"  "\e,T>\e(B" consonant)    ("R"  "\e,T1\e(B" consonant)
116     ("T"  "\e,T8\e(B" consonant)    ("t"  "\e,TP\e(B")
117     ("y"  "\e,TQ\e(B" vowel)        ("Y"  "\e,Tm\e(B" tone)
118     ("u"  "\e,TU\e(B" vowel)        ("U"  "\e,Tj\e(B" tone)
119     ("i"  "\e,TC\e(B" consonant)    ("I"  "\e,T3\e(B" consonant)
120     ("o"  "\e,T9\e(B" consonant)    ("O"  "\e,TO\e(B")
121     ("p"  "\e,TB\e(B" consonant)    ("P"  "\e,T-\e(B" consonant)
122     ("["  "\e,T:\e(B" consonant)    ("{"  "\e,T0\e(B" consonant)
123     ("]"  "\e,TE\e(B" consonant)    ("}"  ",")
124
125     ("a"  "\e,T?\e(B" consonant)    ("A"  "\e,TD\e(B")
126     ("s"  "\e,TK\e(B" consonant)    ("S"  "\e,T&\e(B" consonant)
127     ("d"  "\e,T!\e(B" consonant)    ("D"  "\e,T/\e(B" consonant)
128     ("f"  "\e,T4\e(B" consonant)    ("F"  "\e,Tb\e(B")
129     ("g"  "\e,T`\e(B")              ("G"  "\e,T,\e(B" consonant)
130     ("h"  "\e,Ti\e(B" tone)         ("H"  "\e,Tg\e(B" vowel)
131     ("j"  "\e,Th\e(B" tone)         ("J"  "\e,Tk\e(B" tone)
132     ("k"  "\e,TR\e(B")              ("K"  "\e,TI\e(B" consonant)
133     ("l"  "\e,TJ\e(B" consonant)    ("L"  "\e,TH\e(B" consonant)
134     (";"  "\e,TG\e(B" consonant)    (":"  "\e,T+\e(B" consonant)
135     ("'"  "\e,T'\e(B" consonant)    ("\"" "\e,TF\e(B")
136
137     ("z"  "\e,T<\e(B" consonant)    ("Z"  "(")
138     ("x"  "\e,T;\e(B" consonant)    ("X"  ")")
139     ("c"  "\e,Ta\e(B")              ("C"  "\e,T)\e(B" consonant)
140     ("v"  "\e,TM\e(B" consonant)    ("V"  "\e,TN\e(B" consonant)
141     ("b"  "\e,TT\e(B" vowel)        ("B"  "\e,TZ\e(B" vowel)
142     ("n"  "\e,TW\e(B" vowel)        ("N"  "\e,Tl\e(B" tone)
143     ("m"  "\e,T7\e(B" consonant)    ("M"  "\e,Tn\e(B" vowel)
144     (","  "\e,TA\e(B" consonant)    ("<"  "\e,T2\e(B" consonant)
145     ("."  "\e,Tc\e(B")              (">"  "\e,TL\e(B" consonant)
146     ("/"  "\e,T=\e(B" consonant)    ("?"  "?")))
147
148 (provide 'its/thai)
149
150 ;;; its/thai.el ends here