--- /dev/null
+;;; its/thai.el --- Inputting Thai characters in Egg Input Method Architecture
+
+;; Copyright (C) 1998 Mule Project,
+;; Powered by Electrotechnical Laboratory, JAPAN.
+;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
+
+;; Author: KATAYAMA Yoshio <kate@pfu.co.jp>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+
+;;; Code:
+
+(eval-when-compile
+ (require 'its)
+ (require 'cl)
+
+ (defmacro define-its-thai-keymap (&rest rule)
+ (let (input output type list)
+ (while rule
+ (setq input (car (car rule))
+ output (nth 1 (car rule))
+ type (nth 2 (car rule))
+ rule (cdr rule)
+ list (cons `(its-defrule ,input ,output) list))
+ (if type
+ (setq list (cons `(setq ,type (cons (cons ,input ,output) ,type))
+ list))))
+ `(let (consonant vowel tone)
+ ,@list
+ (its-define-thai-composit consonant vowel tone))))
+
+ (defun its-define-thai-composit (consonant vowel tone)
+ (let (pair state)
+ (while consonant
+ (setq pair (car consonant)
+ consonant (cdr consonant))
+ (setq state (its-goto-state (car pair)))
+ (its-make-next-state state -1 (aref (cdr pair) 0) (cdr pair))
+ (its-define-thai-add-vowel state (car pair) (cdr pair) vowel tone)
+ (its-define-thai-add-tone state (car pair) (cdr pair) tone)
+ (its-defrule-otherwise state (cdr pair)))))
+
+ (defun its-define-thai-add-vowel (state keyseq output vowel tone)
+ (let (next-state next-key next-keyseq next-output composed-output)
+ (while vowel
+ (setq next-key (car (car vowel))
+ next-keyseq (concat keyseq next-key)
+ next-output (concat output (cdr (car vowel)))
+ composed-output (compose-string next-output)
+ vowel (cdr vowel))
+ (setq next-state (its-make-next-state state
+ (aref next-key 0)
+ next-keyseq
+ composed-output))
+ (its-make-next-state next-state -1 next-keyseq composed-output)
+ (its-define-thai-add-tone next-state next-keyseq next-output tone)
+ (its-defrule-otherwise next-state composed-output))))
+
+ (defun its-define-thai-add-tone (state keyseq output tone)
+ (let (next-state next-key next-keyseq next-output composed-output)
+ (while tone
+ (setq next-key (car (car tone))
+ next-keyseq (concat keyseq next-key)
+ next-output (concat output (cdr (car tone)))
+ composed-output (compose-string next-output)
+ tone (cdr tone))
+ (setq next-state (its-make-next-state state
+ (aref next-key 0)
+ next-keyseq
+ composed-output))))))
+
+;; Thai Kesmanee keyboard support.
+
+(define-its-state-machine its-thai-kesmanee-map
+ "kesmanee" "\e,T!!\e(B" 'Thai
+ "Map for Thai Kesmanee input method with TIS620 keyboard. (Thai)"
+
+ (define-its-thai-keymap
+ ("1" "\e,TE\e(B" consonant) ("!" "#")
+ ("2" "/") ("@" "\e,Tq\e(B")
+ ("3" "_") ("#" "\e,Tr\e(B")
+ ("4" "\e,T@\e(B" consonant) ("$" "\e,Ts\e(B")
+ ("5" "\e,T6\e(B" consonant) ("%" "\e,Tt\e(B")
+ ("6" "\e,TX\e(B" vowel) ("^" "\e,TY\e(B" vowel)
+ ("7" "\e,TV\e(B" vowel) ("&" "\e0\e,TQi\e1\e(B" vowel)
+ ("8" "\e,T$\e(B" consonant) ("*" "\e,Tu\e(B")
+ ("9" "\e,T5\e(B" consonant) ("(" "\e,Tv\e(B")
+ ("0" "\e,T(\e(B" consonant) (")" "\e,Tw\e(B")
+ ("-" "\e,T"\e(B" consonant) ("_" "\e,Tx\e(B")
+ ("=" "\e,T*\e(B" consonant) ("+" "\e,Ty\e(B")
+ ("\\" "\e,T_\e(B") ("|" "\e,To\e(B")
+ ("`" "\e,T#\e(B" consonant) ("~" "\e,T%\e(B" consonant)
+
+ ("q" "\e,Tf\e(B") ("Q" "\e,Tp\e(B")
+ ("w" "\e,Td\e(B") ("W" "\"")
+ ("e" "\e,TS\e(B") ("E" "\e,T.\e(B" consonant)
+ ("r" "\e,T>\e(B" consonant) ("R" "\e,T1\e(B" consonant)
+ ("T" "\e,T8\e(B" consonant) ("t" "\e,TP\e(B")
+ ("y" "\e,TQ\e(B" vowel) ("Y" "\e,Tm\e(B" tone)
+ ("u" "\e,TU\e(B" vowel) ("U" "\e,Tj\e(B" tone)
+ ("i" "\e,TC\e(B" consonant) ("I" "\e,T3\e(B" consonant)
+ ("o" "\e,T9\e(B" consonant) ("O" "\e,TO\e(B")
+ ("p" "\e,TB\e(B" consonant) ("P" "\e,T-\e(B" consonant)
+ ("[" "\e,T:\e(B" consonant) ("{" "\e,T0\e(B" consonant)
+ ("]" "\e,TE\e(B" consonant) ("}" ",")
+
+ ("a" "\e,T?\e(B" consonant) ("A" "\e,TD\e(B")
+ ("s" "\e,TK\e(B" consonant) ("S" "\e,T&\e(B" consonant)
+ ("d" "\e,T!\e(B" consonant) ("D" "\e,T/\e(B" consonant)
+ ("f" "\e,T4\e(B" consonant) ("F" "\e,Tb\e(B")
+ ("g" "\e,T`\e(B") ("G" "\e,T,\e(B" consonant)
+ ("h" "\e,Ti\e(B" tone) ("H" "\e,Tg\e(B" vowel)
+ ("j" "\e,Th\e(B" tone) ("J" "\e,Tk\e(B" tone)
+ ("k" "\e,TR\e(B") ("K" "\e,TI\e(B" consonant)
+ ("l" "\e,TJ\e(B" consonant) ("L" "\e,TH\e(B" consonant)
+ (";" "\e,TG\e(B" consonant) (":" "\e,T+\e(B" consonant)
+ ("'" "\e,T'\e(B" consonant) ("\"" "\e,TF\e(B")
+
+ ("z" "\e,T<\e(B" consonant) ("Z" "(")
+ ("x" "\e,T;\e(B" consonant) ("X" ")")
+ ("c" "\e,Ta\e(B") ("C" "\e,T)\e(B" consonant)
+ ("v" "\e,TM\e(B" consonant) ("V" "\e,TN\e(B" consonant)
+ ("b" "\e,TT\e(B" vowel) ("B" "\e,TZ\e(B" vowel)
+ ("n" "\e,TW\e(B" vowel) ("N" "\e,Tl\e(B" tone)
+ ("m" "\e,T7\e(B" consonant) ("M" "\e,Tn\e(B" vowel)
+ ("," "\e,TA\e(B" consonant) ("<" "\e,T2\e(B" consonant)
+ ("." "\e,Tc\e(B") (">" "\e,TL\e(B" consonant)
+ ("/" "\e,T=\e(B" consonant) ("?" "?")))
+
+(provide 'its/thai)
+
+;;; its/thai.el ends here