diff lisp/leim/quail/thai.el @ 197:acd284d43ca1 r20-3b25

Import from CVS: tag r20-3b25
author cvs
date Mon, 13 Aug 2007 10:00:02 +0200
parents 43dd3413c7c7
children
line wrap: on
line diff
--- a/lisp/leim/quail/thai.el	Mon Aug 13 09:59:07 2007 +0200
+++ b/lisp/leim/quail/thai.el	Mon Aug 13 10:00:02 2007 +0200
@@ -1,7 +1,7 @@
 ;;; quail/thai.el --- Quail package for inputting Thai characters
 
-;; Copyright (C) 1995 Free Software Foundation, Inc.
 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
+;; Licensed to the Free Software Foundation.
 
 ;; Keywords: multilingual, input method, Thai
 
@@ -18,36 +18,79 @@
 ;; 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, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; 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.
 
 ;;; Code:
 
 (require 'quail)
-(require 'language/thai-util)
+(require 'thai-util)
 
 (eval-and-compile
 
-(defvar thai-keyboard-mapping
-  [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	; control codes
-   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	; control codes
-   0 "#" ",TF(B" ",Tr(B" ",Ts(B" ",Tt(B" "0,TQi1(B" ",T'(B"	; SPC .. '
-   ",Tv(B" ",Tw(B" ",Tu(B" ",Ty(B" ",TA(B" ",T"(B" ",Tc(B" ",T=(B"	; ( .. /
-   ",T((B" ",TE(B" "/" "_" ",T@(B" ",T6(B" ",TX(B" ",TV(B"	; 0 .. 7
-   ",T$(B" ",T5(B" ",T+(B" ",TG(B" ",T2(B" ",T*(B" ",TL(B" 0	; 8 .. ?
-   ",Tq(B" ",TD(B" ",TZ(B" ",T)(B" ",T/(B" ",T.(B" ",Tb(B" ",T,(B"	; @ .. G
-   ",Tg(B" ",T3(B" ",Tk(B" ",TI(B" ",TH(B" ",Tn(B" ",Tl(B" ",TO(B"	; H .. O
-   ",T-(B" ",Tp(B" ",T1(B" ",T&(B" ",T8(B" ",Tj(B" ",TN(B" "\""	; P .. W
-   ")" ",Tm(B" "(" ",T:(B" ",T_(B" ",TE(B" ",TY(B" ",Tx(B"	; X .. _
-   ",T#(B" ",T?(B" ",TT(B" ",Ta(B" ",T!(B" ",TS(B" ",T4(B" ",T`(B"	; ` .. g
-   ",Ti(B" ",TC(B" ",Th(B" ",TR(B" ",TJ(B" ",T7(B" ",TW(B" ",T9(B"	; h .. o
-   ",TB(B" ",Tf(B" ",T>(B" ",TK(B" ",TP(B" ",TU(B" ",TM(B" ",Td(B"	; p .. w
-   ",T;(B" ",TQ(B" ",T<(B" ",T0(B" ",To(B" "," ",T%(B" 0]	; x .. DEL
-  "A table which maps ASCII key codes to corresponding Thai characters."
-  )
+(defvar thai-keyboard-mapping-alist
+  '((kesmanee
+     [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	; control codes
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	; control codes
+      0 "#" ",TF(B" ",Tr(B" ",Ts(B" ",Tt(B" "0,TQi1(B" ",T'(B"	; SPC .. '
+      ",Tv(B" ",Tw(B" ",Tu(B" ",Ty(B" ",TA(B" ",T"(B" ",Tc(B" ",T=(B"	; ( .. /
+      ",T((B" ",TE(B" "/" "_" ",T@(B" ",T6(B" ",TX(B" ",TV(B"	; 0 .. 7
+      ",T$(B" ",T5(B" ",T+(B" ",TG(B" ",T2(B" ",T*(B" ",TL(B" ",TF(B"	; 8 .. ?
+      ",Tq(B" ",TD(B" ",TZ(B" ",T)(B" ",T/(B" ",T.(B" ",Tb(B" ",T,(B"	; @ .. G
+      ",Tg(B" ",T3(B" ",Tk(B" ",TI(B" ",TH(B" ",Tn(B" ",Tl(B" ",TO(B"	; H .. O
+      ",T-(B" ",Tp(B" ",T1(B" ",T&(B" ",T8(B" ",Tj(B" ",TN(B" "\""	; P .. W
+      ")" ",Tm(B" "(" ",T:(B" ",T_(B" ",TE(B" ",TY(B" ",Tx(B"	; X .. _
+      ",T#(B" ",T?(B" ",TT(B" ",Ta(B" ",T!(B" ",TS(B" ",T4(B" ",T`(B"	; ` .. g
+      ",Ti(B" ",TC(B" ",Th(B" ",TR(B" ",TJ(B" ",T7(B" ",TW(B" ",T9(B"	; h .. o
+      ",TB(B" ",Tf(B" ",T>(B" ",TK(B" ",TP(B" ",TU(B" ",TM(B" ",Td(B"	; p .. w
+      ",T;(B" ",TQ(B" ",T<(B" ",T0(B" ",To(B" "." ",T%(B" 0]	; x .. DEL
+     nil nil)
+
+    (pattachote
+     [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	; control codes
+      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	; control codes
+      0 "+" ",T1(B" "/" "," "?" "_" ",T"(B"	; SPC .. '
+      "(" ")" "." "%" ",TP(B" ",Tq(B" ",T((B" ",T>(B"	; ( .. /
+      ",Tp(B" "=" ",Tr(B" ",Ts(B" ",Tt(B" ",Tu(B" ",TY(B" ",Tw(B"	; 0 .. 7
+      ",Tx(B" ",Ty(B" ",T&(B" ",Td(B" ",T?(B" ",Tv(B" ",T2(B" ",TL(B"	; 8 .. ?
+      "\"" ",Tk(B" ",TQ(B" ",T0(B" ",TS(B" ",Tf(B" ",T3(B" ",Tl(B"	; @ .. G
+      ",TW(B" ",T+(B" ",T<(B" ",T*(B" ",Tb(B" ",TN(B" ",TH(B" ",T6(B"	; H .. O
+      ",T2(B" ",Tj(B" ",T-(B" ",T8(B" ",TI(B" ",T=(B" ",T@(B" ",TD(B"	; P .. W
+      ",T.(B" ",TV(B" ",T.(B" ",Tc(B" ",TZ(B" ",T2(B" ",TX(B" "-"	; X .. _
+      ",T#(B" ",Ti(B" ",TT(B" ",TE(B" ",T'(B" ",TB(B" ",T!(B" ",TQ(B"	; ` .. g
+      ",TU(B" ",TA(B" ",TR(B" ",T9(B" ",T`(B" ",TJ(B" ",T$(B" ",TG(B"	; h .. o
+      ",Ta(B" ",Tg(B" ",TM(B" ",T7(B" ",TC(B" ",T4(B" ",TK(B" ",T5(B"	; p .. w
+      ",T;(B" ",Th(B" ",T:(B" ",TO(B" ",Tm(B" ",TF(B" ",T%(B" 0]	; x .. DEL
+     nil nil)
+    )
+  "Alist of Thai keyboard types vs. corresponding mapping tables.
+Each element is a list of:
+  KEYBOARD-TYPE, ASCII-THAI-TABLE, CONSONANT-MAP-TEMPLATE,
+  and VOWEL-UPPER-LOWER-TEMPLATE.
+
+KEYBOARD-TYPE is a symbol, one of kesmanee or pattachote.
+
+ASCII-THAI-TABLE is a vector indexed by an ASCII key code
+and the value is the one-char string of Thai character
+assigned at the location of ASCII key on the specific Thai keyboard.
+The value is 0 if no Thai character is assigned at the location.
+
+CONSONANT-MAP-TEMPLATE is a template of a cdr part of a Quail map when
+a consonant is entered.
+
+VOWEL-UPPER-LOWER-TEMPLATE is a template of a cdr part of a Quail map
+when a vowel upper or a vowel lower is entered.")
+
+(defmacro thai-keyboard-info (keyboard-type)
+  `(assq ,keyboard-type thai-keyboard-mapping-alist))
 
 )
 
+(defvar thai-current-keyboard-type nil
+  "Thai Keyboard type which Quail is assuming currently.
+This variable is used in Quail internally only.")
+
 ;; Template of a cdr part of a Quail map when a consonant is entered.
 (defvar thai-consonant-alist nil)
 ;; Template of a cdr part of a Quail map when a vowel upper or a vowel
@@ -61,7 +104,9 @@
   (let ((str "")
 	(idx 0))
     (while (< idx len)
-      (setq str (concat str (aref thai-keyboard-mapping (aref key idx)))
+      (setq str (concat str (aref (nth 1 (thai-keyboard-info
+					  thai-current-keyboard-type))
+				  (aref key idx)))
 	    idx (1+ idx)))
     (cons (string-to-char (compose-string str)) (copy-alist alist))))
 
@@ -73,24 +118,14 @@
 ;; Return a Quail map corresponding to KEY of length LEN when Thai
 ;; vowel upper or vowel lower is entered.
 (defun thai-vowel-upper-lower-input (key len)
-  (thai-generate-quail-map key len thai-vowel-upper-lower-alist))
-
-;; Return an alist which can be a cdr part of a Quail map
-;; corresponding to the current key when Thai consonant is entered.
-(defun thai-consonant-input (key len)
-  (copy-alist thai-consonant-alist))
-
-(quail-define-package "quail-thai" "Thai" "Thai" t
-		      "Thai input method with TIS620 characters:
-
-The difference from the ordinal Thai keyboard:
-    ',T_(B' and ',To(B' are assigned to '\\' and '|' respectively,
-    ',T#(B' and ',T%(B' are assigned to '`' and '~' respectively,
-    Don't know where to assign characters ',Tz(B' and ',T{(B'."
-		      nil t t nil t)
+  (thai-generate-quail-map
+   key len
+   (nth 3 (thai-keyboard-info thai-current-keyboard-type))))
 
 ;; Define RULES in Quail map.  In addition, create
-;; `thai-conconant-map' and `thai-vowel-upper-lower-alist'
+;; `thai-consonant-alist-KEYBOARD-TYPE' and
+;; `thai-vowel-upper-lower-alist-KEYBOARD-TYPE'.
+
 ;; The general composing rules are as follows:
 ;;
 ;;                          T
@@ -100,7 +135,7 @@
 ;;
 ;; where C: consonant, V: vowel upper, v: vowel lower, T: tone mark.
 
-(defmacro thai-quail-define-rules (&rest rules)
+(defmacro thai-quail-define-rules (keyboard-type &rest rules)
   (let ((l rules)
 	consonant-alist
 	vowel-upper-lower-alist
@@ -127,38 +162,62 @@
 			       'thai-tone-input)
 			 vowel-upper-lower-alist))))
       (setq l (cdr l)))
-    (list 'progn
-	  (cons 'quail-define-rules rules)
-	  `(setq thai-consonant-alist ',consonant-alist
-		 thai-vowel-upper-lower-alist ',vowel-upper-lower-alist))))
+    `(progn
+	  (quail-define-rules ,@rules)
+	  (setcar (nthcdr 2 (thai-keyboard-info ,keyboard-type))
+		  ',consonant-alist)
+	  (setcar (nthcdr 3 (thai-keyboard-info ,keyboard-type))
+		  ',vowel-upper-lower-alist))))
 
-(thai-quail-define-rules
+;; Return an alist which can be a cdr part of a Quail map
+;; corresponding to the current key when Thai consonant is entered.
+(defun thai-consonant-input (key len)
+  (let ((quail-package-name (quail-name)))
+    (setq thai-current-keyboard-type
+	  (cond ((string= quail-package-name "thai-pattachote") 'pattachote)
+		((string= quail-package-name "thai-kesmanee") 'kesmanee)
+		(t (error "Invalid Quail package %s" quail-package-name))))
+    (copy-alist (nth 2 (thai-keyboard-info thai-current-keyboard-type)))))
+
+;; Thai Kesmanee keyboard support.
+
+(quail-define-package
+ "thai-kesmanee" "Thai" ",T!!(B>" t
+ "Thai Kesmanee input method with TIS620 keyboard layout
+
+The difference from the ordinal Thai keyboard:
+    ',T_(B' and ',To(B' are assigned to '\\' and '|' respectively,
+    ',T#(B' and ',T%(B' are assigned to '`' and '~' respectively,
+    Don't know where to assign characters ',Tz(B' and ',T{(B'."
+ nil t t nil t nil nil nil nil nil t)
+
+(thai-quail-define-rules 'kesmanee
  ("1" (",TE(B" . thai-consonant-input))
  ("!" "#")
  ("2" "/")
- ("@" (",Tq(B" . thai-consonant-input))
+ ("@" ",Tq(B")
  ("3" "_")
- ("#" (",Tr(B" . thai-consonant-input))
+ ("#" ",Tr(B")
  ("4" (",T@(B" . thai-consonant-input))
- ("$" (",Ts(B" . thai-consonant-input))
+ ("$" ",Ts(B")
  ("5" (",T6(B" . thai-consonant-input))
- ("%" (",Tt(B" . thai-consonant-input))
+ ("%" ",Tt(B")
  ("6" ",TX(B")
  ("^" ",TY(B")
  ("7" ",TV(B")
  ("&" "0,TQi1(B")
  ("8" (",T$(B" . thai-consonant-input))
- ("*" (",Tu(B" . thai-consonant-input))
+ ("*" ",Tu(B")
  ("9" (",T5(B" . thai-consonant-input))
- ("\(" (",Tv(B" . thai-consonant-input))
+ ("\(" ",Tv(B")
  ("0" (",T((B" . thai-consonant-input))
- ("\)" (",Tw(B" . thai-consonant-input))
+ ("\)" ",Tw(B")
  ("-" (",T"(B" . thai-consonant-input))
- ("_" (",Tx(B" . thai-consonant-input))
+ ("_" ",Tx(B")
  ("=" (",T*(B" . thai-consonant-input))
- ("+" (",Ty(B" . thai-consonant-input))
- ("\\" (",T_(B" . thai-consonant-input))
- ("|" (",To(B" . thai-consonant-input))
+ ("+" ",Ty(B")
+ ("\\" ",T_(B")
+ ("|" ",To(B")
  ("`" (",T#(B" . thai-consonant-input))
  ("~" (",T%(B" . thai-consonant-input))
  ("q" ",Tf(B")
@@ -178,7 +237,7 @@
  ("i" (",TC(B" . thai-consonant-input))
  ("I" (",T3(B" . thai-consonant-input))
  ("o" (",T9(B" . thai-consonant-input))
- ("O" (",TO(B" . thai-consonant-input))
+ ("O" ",TO(B")
  ("p" (",TB(B" . thai-consonant-input))
  ("P" (",T-(B" . thai-consonant-input))
  ("\[" (",T:(B" . thai-consonant-input))
@@ -228,7 +287,115 @@
  ("." ",Tc(B")
  (">" (",TL(B" . thai-consonant-input))
  ("/" (",T=(B" . thai-consonant-input))
- ("\"" ",TF(B")
+ ("?" ",TF(B")
+ )
+
+
+;; Thai Pattachote keyboard support.
+
+(quail-define-package
+ "thai-pattachote" "Thai" ",T!;(B>" t
+ "Thai Pattachote input method with TIS620 keyboard layout"
+ nil t t nil t nil nil nil nil nil t)
+
+(thai-quail-define-rules 'pattachote
+ ("1" "=")
+ ("!" "+")
+ ("2" ",Tr(B")
+ ("@" "\"")
+ ("3" ",Ts(B")
+ ("#" "/")
+ ("4" ",Tt(B")
+ ("$" ",")
+ ("5" ",Tu(B")
+ ("%" "?")
+ ("6" ",TY(B")
+ ("^" ",TX(B")
+ ("7" ",Tw(B")
+ ("&" "_")
+ ("8" ",Tx(B")
+ ("*" ".")
+ ("9" ",Ty(B")
+ ("(" "(")
+ ("0" ",Tp(B")
+ (")" ")")
+ ("-" ",Tq(B")
+ ("_" "-")
+ ("=" ",Tv(B")
+ ("+" "%")
+ ("\\" ",TZ(B")
+ ("|" ",Tm(B")
+ ("`" (",T#(B" . thai-consonant-input))
+ ("~" (",T%(B" . thai-consonant-input))
+
+ ("q" ",Tg(B")
+ ("Q" ",Tj(B")
+ ("w" (",T5(B" . thai-consonant-input))
+ ("W" ",TD(B")
+ ("e" (",TB(B" . thai-consonant-input))
+ ("E" ",Tf(B")
+ ("r" (",TM(B" . thai-consonant-input))
+ ("R" (",T-(B" . thai-consonant-input))
+ ("t" (",TC(B" . thai-consonant-input))
+ ("T" (",TI(B" . thai-consonant-input))
+ ("y" ",Th(B")
+ ("Y" ",TV(B")
+ ("u" (",T4(B" . thai-consonant-input))
+ ("U" (",T=(B" . thai-consonant-input))
+ ("i" (",TA(B" . thai-consonant-input))
+ ("I" (",T+(B" . thai-consonant-input))
+ ("o" (",TG(B" . thai-consonant-input))
+ ("O" (",T6(B" . thai-consonant-input))
+ ("p" ",Ta(B")
+ ("P" (",T2(B" . thai-consonant-input))
+ ("\[" ",Tc(B")
+ ("{" ",TO(B")
+ ("\]" (",T2(B" . thai-consonant-input))
+ ("}" ",TF(B")
+
+ ("a" ",Ti(B")
+ ("A" ",Tk(B")
+ ("s" (",T7(B" . thai-consonant-input))
+ ("S" (",T8(B" . thai-consonant-input))
+ ("d" (",T'(B" . thai-consonant-input))
+ ("D" ",TS(B")
+ ("f" (",T!(B" . thai-consonant-input))
+ ("F" (",T3(B" . thai-consonant-input))
+ ("g" ",TQ(B")
+ ("G" ",Tl(B")
+ ("h" ",TU(B")
+ ("H" ",TW(B")
+ ("j" ",TR(B")
+ ("J" (",T<(B" . thai-consonant-input))
+ ("k" (",T9(B" . thai-consonant-input))
+ ("K" (",T*(B" . thai-consonant-input))
+ ("l" ",T`(B")
+ ("L" ",Tb(B")
+ (";" ",Td(B")
+ (":" (",T&(B" . thai-consonant-input))
+ ("'" (",T"(B" . thai-consonant-input))
+ ("\"" (",T1(B" . thai-consonant-input))
+
+ ("z" (",T:(B" . thai-consonant-input))
+ ("Z" (",T.(B" . thai-consonant-input))
+ ("x" (",T;(B" . thai-consonant-input))
+ ("X" (",T.(B" . thai-consonant-input))
+ ("c" (",TE(B" . thai-consonant-input))
+ ("C" (",T0(B" . thai-consonant-input))
+ ("v" (",TK(B" . thai-consonant-input))
+ ("V" (",T@(B" . thai-consonant-input))
+ ("b" ",TT(B")
+ ("B" ",TQ(B")
+ ("n" (",T$(B" . thai-consonant-input))
+ ("N" (",TH(B" . thai-consonant-input))
+ ("m" (",TJ(B" . thai-consonant-input))
+ ("M" (",TN(B" . thai-consonant-input))
+ ("," ",TP(B")
+ ("<" (",T?(B" . thai-consonant-input))
+ ("." (",T((B" . thai-consonant-input))
+ (">" (",T2(B" . thai-consonant-input))
+ ("/" (",T>(B" . thai-consonant-input))
+ ("?" (",TL(B" . thai-consonant-input))
  )
 
 ;;; quail/thai.el ends here