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