lao.el 6.2 KB

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