Sync up with egg-980712.
[elisp/egg.git] / its / thai.el
1 ;;; its/thai.el --- Inputting Thai characters in Egg Input Method Architecture
2
3 ;; Copyright (C) 1997, 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-thai-composit consonant vowel tone))))
49
50   (defun its-thai-composit (consonant vowel tone)
51     (let (keyseq output)
52       (while consonant
53         (setq keyseq (car (car consonant))
54               output (cdr (car consonant))
55               consonant (cdr consonant))
56         (its-thai-add-vowel keyseq output vowel tone)
57         (its-thai-add-tone keyseq output tone))))
58
59   (defun its-thai-add-vowel (keyseq output vowel tone)
60     (let (next-keyseq next-output)
61       (while vowel
62         (setq next-keyseq (concat keyseq (car (car vowel)))
63               next-output (concat output (cdr (car vowel)))
64               vowel (cdr vowel))
65         (its-defrule next-keyseq (compose-string next-output))
66         (its-thai-add-tone next-keyseq next-output tone))))
67
68   (defun its-thai-add-tone (keyseq output tone)
69     (let (next-keyseq next-output)
70       (while tone
71         (setq next-keyseq (concat keyseq (car (car tone)))
72               next-output (concat output (cdr (car tone)))
73               tone (cdr tone))
74         (its-defrule next-keyseq (compose-string next-output))))))
75
76 ;; Thai Kesmanee keyboard support.
77
78 (define-its-state-machine its-thai-kesmanee-map
79   "kesmanee" "\e,T!!\e(B" Thai
80   "Map for Thai Kesmanee input method with TIS620 keyboard. (Thai)"
81
82   (define-its-thai-keymap
83     ("1"  "\e,TE\e(B" consonant)    ("!"  "#")
84     ("2"  "/")              ("@"  "\e,Tq\e(B")
85     ("3"  "_")              ("#"  "\e,Tr\e(B")
86     ("4"  "\e,T@\e(B" consonant)    ("$"  "\e,Ts\e(B")
87     ("5"  "\e,T6\e(B" consonant)    ("%"  "\e,Tt\e(B")
88     ("6"  "\e,TX\e(B" vowel)        ("^"  "\e,TY\e(B" vowel)
89     ("7"  "\e,TV\e(B" vowel)        ("&"  "\e0\e,TQi\e1\e(B" vowel)
90     ("8"  "\e,T$\e(B" consonant)    ("*"  "\e,Tu\e(B")
91     ("9"  "\e,T5\e(B" consonant)    ("("  "\e,Tv\e(B")
92     ("0"  "\e,T(\e(B" consonant)    (")"  "\e,Tw\e(B")
93     ("-"  "\e,T"\e(B" consonant)    ("_"  "\e,Tx\e(B")
94     ("="  "\e,T*\e(B" consonant)    ("+"  "\e,Ty\e(B")
95     ("\\" "\e,T_\e(B")              ("|"  "\e,To\e(B")
96     ("`"  "\e,T#\e(B" consonant)    ("~"  "\e,T%\e(B" consonant)
97
98     ("q"  "\e,Tf\e(B")              ("Q"  "\e,Tp\e(B")
99     ("w"  "\e,Td\e(B")              ("W"  "\"")
100     ("e"  "\e,TS\e(B")              ("E"  "\e,T.\e(B" consonant)
101     ("r"  "\e,T>\e(B" consonant)    ("R"  "\e,T1\e(B" consonant)
102     ("T"  "\e,T8\e(B" consonant)    ("t"  "\e,TP\e(B")
103     ("y"  "\e,TQ\e(B" vowel)        ("Y"  "\e,Tm\e(B" tone)
104     ("u"  "\e,TU\e(B" vowel)        ("U"  "\e,Tj\e(B" tone)
105     ("i"  "\e,TC\e(B" consonant)    ("I"  "\e,T3\e(B" consonant)
106     ("o"  "\e,T9\e(B" consonant)    ("O"  "\e,TO\e(B")
107     ("p"  "\e,TB\e(B" consonant)    ("P"  "\e,T-\e(B" consonant)
108     ("["  "\e,T:\e(B" consonant)    ("{"  "\e,T0\e(B" consonant)
109     ("]"  "\e,TE\e(B" consonant)    ("}"  ",")
110
111     ("a"  "\e,T?\e(B" consonant)    ("A"  "\e,TD\e(B")
112     ("s"  "\e,TK\e(B" consonant)    ("S"  "\e,T&\e(B" consonant)
113     ("d"  "\e,T!\e(B" consonant)    ("D"  "\e,T/\e(B" consonant)
114     ("f"  "\e,T4\e(B" consonant)    ("F"  "\e,Tb\e(B")
115     ("g"  "\e,T`\e(B")              ("G"  "\e,T,\e(B" consonant)
116     ("h"  "\e,Ti\e(B" tone)         ("H"  "\e,Tg\e(B" vowel)
117     ("j"  "\e,Th\e(B" tone)         ("J"  "\e,Tk\e(B" tone)
118     ("k"  "\e,TR\e(B")              ("K"  "\e,TI\e(B" consonant)
119     ("l"  "\e,TJ\e(B" consonant)    ("L"  "\e,TH\e(B" consonant)
120     (";"  "\e,TG\e(B" consonant)    (":"  "\e,T+\e(B" consonant)
121     ("'"  "\e,T'\e(B" consonant)    ("\"" "\e,TF\e(B")
122
123     ("z"  "\e,T<\e(B" consonant)    ("Z"  "(")
124     ("x"  "\e,T;\e(B" consonant)    ("X"  ")")
125     ("c"  "\e,Ta\e(B")              ("C"  "\e,T)\e(B" consonant)
126     ("v"  "\e,TM\e(B" consonant)    ("V"  "\e,TN\e(B" consonant)
127     ("b"  "\e,TT\e(B" vowel)        ("B"  "\e,TZ\e(B" vowel)
128     ("n"  "\e,TW\e(B" vowel)        ("N"  "\e,Tl\e(B" tone)
129     ("m"  "\e,T7\e(B" consonant)    ("M"  "\e,Tn\e(B" vowel)
130     (","  "\e,TA\e(B" consonant)    ("<"  "\e,T2\e(B" consonant)
131     ("."  "\e,Tc\e(B")              (">"  "\e,TL\e(B" consonant)
132     ("/"  "\e,T=\e(B" consonant)    ("?"  "?")))
133
134 (provide 'its/thai)
135
136 ;;; its/thai.el ends here