1;;; lao.el --- Quail package for inputting Lao characters -*- lexical-binding: t; -*- 2 3;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 4;; 2006, 2007, 2008, 2009, 2010, 2011 5;; National Institute of Advanced Industrial Science and Technology (AIST) 6;; Registration Number H14PRO021 7 8;; Keywords: multilingual, input method, Lao 9 10;; This file is part of GNU Emacs. 11 12;; GNU Emacs is free software: you can redistribute it and/or modify 13;; it under the terms of the GNU General Public License as published by 14;; the Free Software Foundation, either version 3 of the License, or 15;; (at your option) any later version. 16 17;; GNU Emacs is distributed in the hope that it will be useful, 18;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20;; GNU General Public License for more details. 21 22;; You should have received a copy of the GNU General Public License 23;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. 24 25;;; Commentary: 26 27;;; Code: 28 29(require 'quail) 30(require 'lao-util) 31 32(defun quail-lao-update-translation (control-flag) 33 (if (integerp control-flag) 34 ;; Non-composable character typed. 35 (setq quail-current-str 36 (buffer-substring (overlay-start quail-overlay) 37 (overlay-end quail-overlay)) 38 unread-command-events 39 (append 40 (substring quail-current-key control-flag) 41 unread-command-events)) 42 (setq quail-current-str 43 (compose-string (quail-lookup-map-and-concat quail-current-key)))) 44 control-flag) 45 46(defvar lao-key-alist 47 '(("!" . "1") 48 ("\"" . "=") 49 ("#" . "3") 50 ("$" . "4") 51 ("&" . "5") 52 ("%" . "໌") 53 ("'" . "ງ") 54 ("(" . "7") 55 (")" . "8") 56 ("*" . "6") 57 ("+" . ["ໍ່"]) 58 ("," . "ມ") 59 ("-" . "ຊ") 60 ("." . "ໃ") 61 ("/" . "ຝ") 62 ("0" . "ຂ") 63 ("1" . "ຢ") 64 ("2" . "ຟ") 65 ("3" . "ໂ") 66 ("4" . "ຖ") 67 ("5" . "ຸ") 68 ("6" . "ູ") 69 ("7" . "ຄ") 70 ("8" . "ຕ") 71 ("9" . "ຈ") 72 (":" . "%") 73 (";" . "ວ") 74 ("<" . "ໝ") 75 ("=" . "ໍ") 76 (">" . "$") 77 ("?" . ")") 78 ("@" . "2") 79 ("A" . ["ັ້"]) 80 ("B" . ["ຶ້"]) 81 ("C" . "ຯ") 82 ("D" . ".") 83 ("E" . ["ຳ້"]) 84 ("F" . ",") 85 ("G" . ":") 86 ("H" . "໊") 87 ("I" . "ຮ") 88 ("J" . "໋") 89 ("K" . "!") 90 ("L" . "?") 91 ("M" . "ໆ") 92 ("N" . ["ື້"]) 93 ("O" . "ໜ") 94 ("P" . "ຽ") 95 ("Q" . ["ົ້"]) 96 ("R" . "_") 97 ("S" . ";") 98 ("T" . "+") 99 ("U" . ["ີ້"]) 100 ("V" . "x") 101 ("W" . "0") 102 ("X" . "(") 103 ("Y" . ["ິ້"]) 104 ("Z" . "\"") 105 ("[" . "ບ") 106 ("]" . "ລ") 107 ("^" . "ຼ") 108 ("_" . "9") 109 ("`" . "ງ") 110 ("a" . "ັ") 111 ("b" . "ຶ") 112 ("c" . "ແ") 113 ("d" . "ກ") 114 ("e" . "ຳ") 115 ("f" . "ດ") 116 ("g" . "ເ") 117 ("h" . "້") 118 ("i" . "ຣ") 119 ("j" . "່") 120 ("k" . "າ") 121 ("l" . "ສ") 122 ("m" . "ທ") 123 ("n" . "ື") 124 ("o" . "ນ") 125 ("p" . "ຍ") 126 ("q" . "ົ") 127 ("r" . "ພ") 128 ("s" . "ຫ") 129 ("t" . "ະ") 130 ("u" . "ີ") 131 ("v" . "ອ") 132 ("w" . "ໄ") 133 ("x" . "ປ") 134 ("y" . "ິ") 135 ("z" . "ຜ") 136 ("{" . "-") 137 ("|" . ["ຫຼ"]) 138 ("}" . "/") 139 ("~" . "໌") 140 ("\\0" . "໐") 141 ("\\1" . "໑") 142 ("\\2" . "໒") 143 ("\\3" . "໓") 144 ("\\4" . "໔") 145 ("\\5" . "໕") 146 ("\\6" . "໖") 147 ("\\7" . "໗") 148 ("\\8" . "໘") 149 ("\\9" . "໙") 150 ) 151 "Alist of key sequences vs the corresponding Lao string to input. 152This variable is for the input method \"lao\". 153If you change the value of this variable while quail/lao is already loaded, 154you need to re-load it to properly re-initialize related alists.") 155 156;; Temporary variable to initialize lao-consonant-key-alist, etc. 157(defconst lao-key-alist-vector 158 (let ((tail lao-key-alist) 159 consonant-key-alist semivowel-key-alist vowel-key-alist 160 voweltone-key-alist tone-key-alist other-key-alist 161 elt phonetic-type) 162 (while tail 163 (setq elt (car tail) tail (cdr tail)) 164 (if (stringp (cdr elt)) 165 (setq phonetic-type (get-char-code-property (aref (cdr elt) 0) 166 'phonetic-type)) 167 (setq phonetic-type (get-char-code-property (aref (aref (cdr elt) 0) 0) 168 'phonetic-type)) 169 (aset (cdr elt) 0 (compose-string (aref (cdr elt) 0)))) 170 (cond ((eq phonetic-type 'consonant) 171 (setq consonant-key-alist (cons elt consonant-key-alist))) 172 ((memq phonetic-type '(vowel-upper vowel-lower)) 173 (if (stringp (cdr elt)) 174 (setq vowel-key-alist (cons elt vowel-key-alist)) 175 (setq voweltone-key-alist (cons elt voweltone-key-alist)))) 176 ((eq phonetic-type 'tone) 177 (setq tone-key-alist (cons elt tone-key-alist))) 178 ((eq phonetic-type 'semivowel-lower) 179 (setq semivowel-key-alist (cons elt semivowel-key-alist))) 180 (t 181 (setq other-key-alist (cons elt other-key-alist))))) 182 (vector consonant-key-alist semivowel-key-alist vowel-key-alist 183 voweltone-key-alist tone-key-alist other-key-alist))) 184 185(defconst lao-consonant-key-alist (aref lao-key-alist-vector 0)) 186(defconst lao-semivowel-key-alist (aref lao-key-alist-vector 1)) 187(defconst lao-vowel-key-alist (aref lao-key-alist-vector 2)) 188(defconst lao-voweltone-key-alist (aref lao-key-alist-vector 3)) 189(defconst lao-tone-key-alist (aref lao-key-alist-vector 4)) 190(defconst lao-other-key-alist (aref lao-key-alist-vector 5)) 191 192;; Done with it. 193(makunbound 'lao-key-alist-vector) 194 195(quail-define-package 196 "lao" "Lao" "ລ" t 197 "Lao input method simulating Lao keyboard layout based on Thai TIS620" 198 nil t t t t nil nil nil #'quail-lao-update-translation nil t) 199 200(quail-install-map 201 (quail-map-from-table 202 '((base-state (lao-consonant-key-alist . svt-state) 203 lao-vowel-key-alist 204 lao-voweltone-key-alist 205 lao-tone-key-alist 206 lao-other-key-alist) 207 (svt-state (lao-semivowel-key-alist . v-state) 208 (lao-vowel-key-alist . t-state) 209 lao-voweltone-key-alist 210 lao-tone-key-alist) 211 (v-state (lao-vowel-key-alist . t-state)) 212 (t-state lao-tone-key-alist)))) 213 214;;; lao.el ends here 215