diff options
author | Kenichi Handa <handa@m17n.org> | 1999-12-15 00:32:16 +0000 |
---|---|---|
committer | Kenichi Handa <handa@m17n.org> | 1999-12-15 00:32:16 +0000 |
commit | 653b6bad9869ae61b054229921d2d4392f5b77cd (patch) | |
tree | b36aea6898d587bb6bf722683a5ae9426f684eb0 /leim/quail/thai.el | |
parent | c674f3518fa2a428fc07b6b48cdd767da15fb731 (diff) |
Rewritten for new composition.
Diffstat (limited to 'leim/quail/thai.el')
-rw-r--r-- | leim/quail/thai.el | 432 |
1 files changed, 79 insertions, 353 deletions
diff --git a/leim/quail/thai.el b/leim/quail/thai.el index 2824036243e..df215dff116 100644 --- a/leim/quail/thai.el +++ b/leim/quail/thai.el @@ -27,158 +27,47 @@ (require 'quail) (require 'thai-util) -(eval-and-compile +(defun quail-thai-update-translation (control-flag) + (if (integerp control-flag) + ;; Non-composable character typed. + (setq quail-current-str + (buffer-substring (overlay-start quail-overlay) + (overlay-end quail-overlay)) + unread-command-events + (string-to-list + (substring quail-current-key control-flag))) + (setq quail-current-str + (compose-string (quail-lookup-map-and-concat quail-current-key)))) + control-flag) + +(defun thai-generate-quail-map (translation-table) + (let ((i 0) + consonant vowel tone voweltone others) + ;; Categorize Thai characters into one of above. + (while (< i 128) + (let ((trans (aref translation-table i)) + ptype) + (if (eq trans 0) + nil + (if (> (length trans) 1) + (setq ptype 'voweltone + trans (vector trans)) + (setq ptype (get-char-code-property (aref trans 0) 'phonetic-type)) + (cond ((memq ptype '(vowel-upper vowel-lower)) + (setq ptype 'vowel)) + ((not (memq ptype '(consonant tone))) + (setq ptype 'others)))) + (set ptype (cons (cons (char-to-string i) trans) + (symbol-value ptype))))) + (setq i (1+ i))) + + (quail-map-from-table + '((base-state (consonant . vt-state) + vowel tone voweltone others) + (vt-state (vowel . t-state) + voweltone tone) + (t-state tone))))) -(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 -;; lower is entered. -(defvar thai-vowel-upper-lower-alist nil) - -;; Return a Quail map corresponding to KEY of length LEN. -;; The car part of the map is a translation generated automatically. -;; The cdr part of the map is a copy of ALIST. -(defun thai-generate-quail-map (key len alist) - (let ((str "") - (idx 0)) - (while (< idx len) - (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)))) - -;; Return a Quail map corresponding to KEY of length LEN when Thai -;; tone mark is entered. -(defun thai-tone-input (key len) - (thai-generate-quail-map key len nil)) - -;; 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 - (nth 3 (thai-keyboard-info thai-current-keyboard-type)))) - -;; Define RULES in Quail map. In addition, create -;; `thai-consonant-alist-KEYBOARD-TYPE' and -;; `thai-vowel-upper-lower-alist-KEYBOARD-TYPE'. - -;; The general composing rules are as follows: -;; -;; T -;; V T V T -;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C -;; v v -;; -;; where C: consonant, V: vowel upper, v: vowel lower, T: tone mark. - -(defmacro thai-quail-define-rules (keyboard-type &rest rules) - (let ((l rules) - consonant-alist - vowel-upper-lower-alist - rule trans ch c-set) - (while l - (setq rule (car l)) - (setq trans (nth 1 rule)) - (if (consp trans) - (setq trans (car trans))) - (setq c-set (char-category-set (string-to-char trans))) - (cond ((or (aref c-set ?2) - (aref c-set ?3)) - (setq consonant-alist - (cons (cons (string-to-char (car rule)) - 'thai-vowel-upper-lower-input) - consonant-alist))) - ((aref c-set ?4) - (setq consonant-alist - (cons (cons (string-to-char (car rule)) - 'thai-tone-input) - consonant-alist) - vowel-upper-lower-alist - (cons (cons (string-to-char (car rule)) - 'thai-tone-input) - vowel-upper-lower-alist)))) - (setq l (cdr l))) - `(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)))) - -;; 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 @@ -189,106 +78,27 @@ 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") - ("3" "_") - ("#" ",Tr(B") - ("4" (",T@(B" . thai-consonant-input)) - ("$" ",Ts(B") - ("5" (",T6(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") - ("9" (",T5(B" . thai-consonant-input)) - ("\(" ",Tv(B") - ("0" (",T((B" . thai-consonant-input)) - ("\)" ",Tw(B") - ("-" (",T"(B" . thai-consonant-input)) - ("_" ",Tx(B") - ("=" (",T*(B" . thai-consonant-input)) - ("+" ",Ty(B") - ("\\" ",T_(B") - ("|" ",To(B") - ("`" (",T#(B" . thai-consonant-input)) - ("~" (",T%(B" . thai-consonant-input)) - ("q" ",Tf(B") - ("Q" ",Tp(B") - ("w" ",Td(B") - ("W" "\"") - ("e" ",TS(B") - ("E" (",T.(B" . thai-consonant-input)) - ("r" (",T>(B" . thai-consonant-input)) - ("R" (",T1(B" . thai-consonant-input)) - ("t" ",TP(B") - ("T" (",T8(B" . thai-consonant-input)) - ("y" ",TQ(B") - ("Y" ",Tm(B") - ("u" ",TU(B") - ("U" ",Tj(B") - ("i" (",TC(B" . thai-consonant-input)) - ("I" (",T3(B" . thai-consonant-input)) - ("o" (",T9(B" . thai-consonant-input)) - ("O" ",TO(B") - ("p" (",TB(B" . thai-consonant-input)) - ("P" (",T-(B" . thai-consonant-input)) - ("\[" (",T:(B" . thai-consonant-input)) - ("{" (",T0(B" . thai-consonant-input)) - ("\]" (",TE(B" . thai-consonant-input)) - ("}" ",") + nil t t nil t nil nil nil 'quail-thai-update-translation nil t) + +(quail-install-map + (thai-generate-quail-map + [ + 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" ",TQi(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 + ])) - ("a" (",T?(B" . thai-consonant-input)) - ("A" ",TD(B") - ("s" (",TK(B" . thai-consonant-input)) - ("S" (",T&(B" . thai-consonant-input)) - ("d" (",T!(B" . thai-consonant-input)) - ("D" (",T/(B" . thai-consonant-input)) - ("f" (",T4(B" . thai-consonant-input)) - ("F" ",Tb(B") - ("g" ",T`(B") - ("G" (",T,(B" . thai-consonant-input)) - ("h" ",Ti(B") - ("H" ",Tg(B") - ("j" ",Th(B") - ("J" ",Tk(B") - ("k" ",TR(B") - ("K" (",TI(B" . thai-consonant-input)) - ("l" (",TJ(B" . thai-consonant-input)) - ("L" (",TH(B" . thai-consonant-input)) - ("\;" (",TG(B" . thai-consonant-input)) - (":" (",T+(B" . thai-consonant-input)) - ("'" (",T'(B" . thai-consonant-input)) - ("\"" ".") - - ("z" (",T<(B" . thai-consonant-input)) - ("Z" "(") - ("x" (",T;(B" . thai-consonant-input)) - ("X" ")") - ("c" ",Ta(B") - ("C" (",T)(B" . thai-consonant-input)) - ("v" (",TM(B" . thai-consonant-input)) - ("V" (",TN(B" . thai-consonant-input)) - ("b" ",TT(B") - ("B" ",TZ(B") - ("n" ",TW(B") - ("N" ",Tl(B") - ("m" (",T7(B" . thai-consonant-input)) - ("M" ",Tn(B") - ("," (",TA(B" . thai-consonant-input)) - ("<" (",T2(B" . thai-consonant-input)) - ("." ",Tc(B") - (">" (",TL(B" . thai-consonant-input)) - ("/" (",T=(B" . thai-consonant-input)) - ("?" ",TF(B") - ) ;; Thai Pattachote keyboard support. @@ -296,106 +106,22 @@ The difference from the ordinal Thai keyboard: (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 + nil t t nil t nil nil nil 'quail-thai-update-translation nil t) + +(quail-install-map + (thai-generate-quail-map + [ 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 + ])) |