1 ;;; tibetan.el --- Quail package for inputting Tibetan characters -*-coding: iso-2022-7bit;-*-
3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 ;; Free Software Foundation, Inc.
5 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
6 ;; 2006, 2007, 2008, 2009, 2010, 2011
7 ;; National Institute of Advanced Industrial Science and Technology (AIST)
8 ;; Registration Number H14PRO021
10 ;; Keywords: multilingual, input method, Tibetan
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; Author: Toru TOMABECHI, <Toru.Tomabechi@orient.unil.ch>
29 ;; Created: Feb. 17. 1997
32 ;; 1997.03.13 Support for inputting special signs and punctuations added.
33 ;; (Only Ext. Wylie input)
42 ;; Now quail-current-key is set to Tibetan-Roman transcription. We
43 ;; set quail-current-str to the corresponding Tibetan string (composed
44 ;; if necessary). Both Wylie and TibKey input methods use this
47 (defun quail-tibetan-update-translation (control-flag)
48 (if (numberp control-flag)
49 ;; Non-composable-character typed.
50 (setq quail-current-str
51 (buffer-substring (overlay-start quail-overlay)
52 (overlay-end quail-overlay))
55 (substring quail-current-key control-flag)))
56 ;; Special treatment of "-d..." and "-y...".
57 (if (string-match "^-[dy]" quail-current-key)
58 (setq quail-current-key (substring quail-current-key 1)))
59 (let ((str (tibetan-transcription-to-tibetan quail-current-key)))
60 ;; If quail-current-key is for punctuations, it can't be
61 ;; transcribed by tibetan-transcription-to-tibetan, thus STR
62 ;; contains ASCII string now. In that case, use the current
63 ;; characters set in quail-current-str.
64 (if (> (aref str 0) 255)
65 (setq quail-current-str (tibetan-compose-string str))
67 (setq quail-current-str quail-current-key)))))
70 ;;; Wylie transcription based input methods.
72 ;; Special alist for `
\e$(7"A
\e(B'. It must be treated as a subjoined
73 ;; consonant if it follows a consonant.
74 ;; * Removed by Tomabechi 2000/06/10 *
75 ;; 'a chung must be explicitly typed as a vowel ("fa")
76 ;;
\e$(7"A
\e(B is now treated as normal base consonants
77 ;; (defconst tibetan-wylie-quote-alist '(("'" . ?
\e$(7"A
\e(B)))
79 ;; Special alist to avoid default stacking.
80 (defconst tibetan-wylie-non-stacking-alist
81 '(("-d" . "
\e$(7"2
\e(B")
82 ("-y" . "
\e$(7"B
\e(B")))
84 ;; Punctuations are not transcribed.
86 (defconst tibetan-wylie-punctuation-alist
91 ("//" . "
\e$(7!>
\e(B")
92 ("////" . ["
\e$(7!>
\e(B
\e$(7!>
\e(B"])
94 ("/\"" . "
\e$(7!@
\e(B") ; Not defined in Ext. Wylie.
100 (">" . "
\e$(7!m
\e(B")
101 ("@" . "
\e$(7"f
\e(B")
102 ("*" . ["
\e$(7!4!5
\e(B"])
103 ("#" . ["
\e$(7!4!5!5
\e(B"])
104 ("^" . "
\e$(7!6
\e(B")
105 ("0" . "
\e$(7!P
\e(B")
106 ("1" . "
\e$(7!Q
\e(B")
107 ("2" . "
\e$(7!R
\e(B")
108 ("3" . "
\e$(7!S
\e(B")
109 ("4" . "
\e$(7!T
\e(B")
110 ("5" . "
\e$(7!U
\e(B")
111 ("6" . "
\e$(7!V
\e(B")
112 ("7" . "
\e$(7!W
\e(B")
113 ("8" . "
\e$(7!X
\e(B")
114 ("9" . "
\e$(7!Y
\e(B")
115 ("-0" . "
\e$(7!c
\e(B")
116 ("-1" . "
\e$(7!Z
\e(B")
117 ("-2" . "
\e$(7![
\e(B")
118 ("-3" . "
\e$(7!\
\e(B")
119 ("-4" . "
\e$(7!]
\e(B")
120 ("-5" . "
\e$(7!^
\e(B")
121 ("-6" . "
\e$(7!_
\e(B")
122 ("-7" . "
\e$(7!`
\e(B")
123 ("-8" . "
\e$(7!a
\e(B")
124 ("-9" . "
\e$(7!b
\e(B")
125 ("|" . "
\e$(7!0!1!2!3!7!9!:!B!C!E!F!G!H!I!J!K!L!M!N!O!d!f!h!j!k!n!o#O#P#Q#R#S#T#U#V#W#X#Y#Z#[#\#]#`
\e(B")))
127 (quail-define-package "tibetan-wylie" "Tibetan" "TIBw" t
128 "Tibetan character input by Extended Wylie key assignment.
130 +-------------------------------------+
131 |
\e$(7"!!;
\e(B k |
\e$(7""!;
\e(B kh |
\e$(7"#!;
\e(B g |
\e$(7"$!;
\e(B gh |
\e$(7"%!;
\e(B ng|
\e$(7"S
\e(B i
\e$(7!=
\e(B /
132 |
\e$(7"&!;
\e(B c |
\e$(7"'!;
\e(B ch |
\e$(7"(!;
\e(B j | |
\e$(7"*!;
\e(B ny|
\e$(7"U
\e(B u
\e$(7!>
\e(B //
133 |
\e$(7"+!;
\e(B T |
\e$(7",!;
\e(B TH |
\e$(7"-!;
\e(B D |
\e$(7".!;
\e(B DH |
\e$(7"/!;
\e(B N |
\e$(7"[
\e(B e
\e$(7!>
\e(B
\e$(7!>
\e(B ////
134 |
\e$(7"0!;
\e(B t |
\e$(7"1!;
\e(B th |
\e$(7"2!;
\e(B d |
\e$(7"3!;
\e(B dh |
\e$(7"4!;
\e(B n |
\e$(7"]
\e(B o
\e$(7!A
\e(B ;
135 |
\e$(7"5!;
\e(B p |
\e$(7"6!;
\e(B ph |
\e$(7"7!;
\e(B b |
\e$(7"8!;
\e(B bh |
\e$(7"9!;
\e(B m |
\e$(7"\
\e(B ai (ee, E)
\e$(7!?
\e(B $
136 |
\e$(7":!;
\e(B ts|
\e$(7";!;
\e(B tsh|
\e$(7"<!;
\e(B dz |
\e$(7"=!;
\e(B dzh|
\e$(7">!;
\e(B w |
\e$(7"^
\e(B au (oo, O)
\e$(7!@
\e(B &
137 |
\e$(7"?!;
\e(B zh|
\e$(7"@!;
\e(B z |
\e$(7"A!;
\e(B ' | |
\e$(7"B!;
\e(B y |
\e$(7"a
\e(B I
\e$(7!4!5
\e(B *
138 |
\e$(7"C!;
\e(B r |
\e$(7"D!;
\e(B l |
\e$(7"E!;
\e(B sh |
\e$(7"F!;
\e(B SH |
\e$(7"G!;
\e(B s |
\e$(7"`
\e(B :
\e$(7!4!5!5
\e(B #
139 |
\e$(7"H!;
\e(B h |
\e$(7"I!;
\e(B A |
\e$(7"J!;
\e(B kSH| | |
\e$(7"_
\e(B M
\e$(7!l
\e(B
\e$(7!m
\e(B < >
140 +-------------------------------------+
\e$(7!D
\e(B %
141 (The consonant
\e$(7"I!;
\e(B must be typed explicitly.)
143 NOT SPECIFIED IN EXT. WYLIE:
144 +--------------------------------------------------------+
145 |
\e$(7"c
\e(B = ~ |
\e$(7"d
\e(B = ` |
\e$(7"e
\e(B = , |
\e$(7"f
\e(B = @ |
\e$(7!g
\e(B = _o|
\e$(7!e
\e(B = _O|
\e$(7!6
\e(B = ^|
146 +--------------------------------------------------------+
147 |
\e$(7"i
\e(B = x |
\e$(7"j
\e(B = X |
\e$(7"g
\e(B = v |
\e$(7"h
\e(B = V |
\e$(7"k
\e(B = q |
\e$(7"l
\e(B = Q |
148 +-----------------------------------------------+
151 + : Consonant Stacking
152 \(Consonant stacking for ordinary Tibetan is done automatically)
153 - : No Consonant Stacking
154 \(To suppress automatic stacking for \"g-y\",
155 and to get da-drag in -r-d, -l-d .)
158 Tsheg is assigned to SPC. Space is assigned to period '.'.
160 nil nil nil nil nil nil nil nil
161 'quail-tibetan-update-translation)
163 ;; Here we build up a Quail map for a Tibtan sequence the whole of
164 ;; which can be one composition.
166 ;; A Tibetan syllable is typically structured as follows:
167 ;; [P] C [c+] V [M] [S [s]]
169 ;; where P:prefix, C:base consonant, c:subjoined consonant,
170 ;; V:vowel, M:vowel modifier, S:suffix, s:post suffix.
171 ;; In this pattern, the part indicated by "^^^" can be one composition.
173 ;;; modified by Tomabechi 1999/12/10
174 ;;; modified by Tomabechi 2000/06/08
175 ;;; Allows infinite addition of vowels/modifiers
176 ;;; as specified in Unicode v.3
178 (quail-map-from-table
179 '((base-state (tibetan-consonant-transcription-alist . svm-state)
180 (tibetan-precomposed-transcription-alist . svm-state)
181 (tibetan-wylie-non-stacking-alist . svm-state)
182 tibetan-subjoined-transcription-alist
183 tibetan-vowel-transcription-alist
184 tibetan-modifier-transcription-alist
185 tibetan-wylie-punctuation-alist)
186 (svm-state ;;(tibetan-wylie-quote-alist . vm-state)
187 (tibetan-vowel-transcription-alist . vm-state)
188 (tibetan-subjoined-transcription-alist . svm-state)
189 (tibetan-modifier-transcription-alist . m-state))
190 (vm-state (tibetan-vowel-transcription-alist . vm-state)
191 (tibetan-modifier-transcription-alist . m-state))
192 (m-state (tibetan-modifier-transcription-alist . m-state)))))
195 ;;; TibKey key alignment based input method
198 (defconst tibetan-tibkey-to-transcription-alist
200 ("`" . "`") ; sna ldan
201 ("~" . "~") ; sna ldan + nada
208 ("T" . "I") ; gi gu log
221 ("A" . "a") ; Vowel a (not used in original TibKey)
225 ("F" . "M") ; anusvara
226 ("g" . "u") ; zhabs kyu
228 ("H" . ",") ; viraama
230 ("J" . "e") ; 'greng bu
235 ("\"" . "+w") ; wa zur
239 ("C" . "+'") ; 'a chung
241 ("V" . "+y") ; ya btags
243 ("B" . "+r") ; ra btags
245 ("N" . "+l") ; la btags
253 ("hQ" ."+kSH") ; kSHa
274 ("hl" . "+tsh") ; tsha
288 ;; Special rule for `
\e$(7"B
\e(B' to avoid stacking.
292 (defconst tibetan-consonant-tibkey-alist nil)
293 (defconst tibetan-subjoined-tibkey-alist nil)
294 (defconst tibetan-vowel-tibkey-alist nil)
295 (defconst tibetan-modifier-tibkey-alist nil)
296 (defconst tibetan-non-stacking-tibkey-alist nil)
298 (let ((type-list '("consonant" "subjoined" "vowel" "modifier" "non-stacking"))
299 (tail tibetan-tibkey-to-transcription-alist)
302 (setq elt (car tail) tail (cdr tail))
303 (let ((types type-list)
304 type transcription trans-alist tibkey-alist)
306 (setq type (car types) types (cdr types))
308 (if (string= type "non-stacking")
309 'tibetan-wylie-non-stacking-alist
310 (intern (format "tibetan-%s-transcription-alist" type)))
312 (cdr (assoc (cdr elt) (symbol-value trans-alist))))
314 (setq tibkey-alist (intern (format "tibetan-%s-tibkey-alist" type)))
316 (cons (cons (car elt) transcription)
317 (symbol-value tibkey-alist)))))
319 (error "No Tibetan transcription for %s" (cdr elt))))))
321 (defconst tibetan-punctuation-tibkey-alist
322 '(("1" . "
\e$(7!Q
\e(B")
323 ("!" . "
\e$(7!4
\e(B") ; nyi zla long
324 ("2" . "
\e$(7!R
\e(B")
325 ("@" . "
\e$(7!5
\e(B") ; nyi zla simple
326 ("3" . "
\e$(7!S
\e(B")
328 ("4" . "
\e$(7!T
\e(B")
330 ("5" . "
\e$(7!U
\e(B")
331 ("%" . "
\e$(7!D
\e(B")
332 ("6" . "
\e$(7!V
\e(B")
333 ("^" . "
\e$(7!1
\e(B")
334 ("7" . "
\e$(7!W
\e(B")
335 ("8" . "
\e$(7!X
\e(B")
336 ;;; ("*" ) ; avagraha, not supported yet
337 ("9" . "
\e$(7!Y
\e(B")
338 ("(" . "
\e$(7!l
\e(B")
339 ("0" . "
\e$(7!P
\e(B")
340 (")" . "
\e$(7!m
\e(B")
341 ;;; ("-" ) ; enphatic, not yet supported
343 ;;; ("=" ) ; special sign, not yet supported
344 ("+" . "
\e$(7!A
\e(B")
345 ("\\" . "
\e$(7!?
\e(B")
346 ("|" . "
\e$(7!8
\e(B")
347 ("I" . "
\e$(7"f
\e(B") ; avagraha
348 (":" . "
\e$(7"`
\e(B")
349 ;;; (">" ?
\e$(7!;
\e(B) ; to be assigned to SPC
351 ("?" . "
\e$(7!=
\e(B")
352 ("??" . "
\e$(7!>
\e(B")
353 ("????" . ["
\e$(7!>
\e(B
\e$(7!>
\e(B"])
354 (" " . "
\e$(7!;
\e(B")
357 ;; Convert TibKey string to Tibetan-Roman transcription string.
358 ;; If there's no proper conversion, return nil.
359 (defun quail-tibkey-to-transcription (tibkey)
360 (let ((len (length tibkey))
366 (while (and (not trans) (> last i))
367 (or (setq trans (cdr (assoc (substring tibkey i last)
368 tibetan-tibkey-to-transcription-alist)))
369 (setq last (1- last))))
371 (setq trans-list (cons trans trans-list)
373 (setq trans-list nil i len))))
374 (apply 'concat (nreverse trans-list))))
376 (defvar quail-tibkey-characters nil)
378 (defun quail-tibkey-update-translation (control-flag)
379 (if (integerp control-flag)
380 ;; Non-composable-character typed.
381 (setq quail-current-str
382 (buffer-substring (overlay-start quail-overlay)
383 (overlay-end quail-overlay))
384 unread-command-events
386 (substring quail-current-key control-flag)))
387 (let ((transcription (quail-tibkey-to-transcription quail-current-key)))
388 (if (> (length transcription) 0)
389 (let ((quail-current-key transcription))
391 (quail-tibetan-update-translation control-flag)))
392 (or quail-current-str
393 (setq quail-current-str quail-current-key)))))
396 (quail-define-package "tibetan-tibkey" "Tibetan" "TIBt" t
397 "Tibetan character input by TibKey key assignment.
399 \(This implementation is still incomplete.
400 Therefore, the following key assignment is a provisional one.)
404 +-------------------------------------------------------+
405 |`
\e$(7"d
\e(B|1
\e$(7!Q
\e(B|2
\e$(7!R
\e(B|3
\e$(7!S
\e(B|4
\e$(7!T
\e(B|5
\e$(7!U
\e(B|6
\e$(7!V
\e(B|7
\e$(7!W
\e(B|8
\e$(7!X
\e(B|9
\e$(7!Y
\e(B|0
\e$(7!P
\e(B|- |= |\\
\e$(7!8
\e(B|
406 +-------------------------------------------------------+
407 |q
\e$(7"!
\e(B|w
\e$(7""
\e(B|e
\e$(7"#
\e(B|r
\e$(7"%
\e(B|t
\e$(7"&
\e(B|y
\e$(7"'
\e(B|u
\e$(7"(
\e(B|i
\e$(7"*
\e(B|o
\e$(7"0
\e(B|p
\e$(7"1
\e(B|[
\e$(7"2
\e(B|]
\e$(7"4
\e(B|
408 +-----------------------------------------------+
409 |a
\e$(7"5
\e(B| s
\e$(7"6
\e(B| d
\e$(7"7
\e(B|f
\e$(7"9
\e(B|g
\e$(7"U
\e(B|h |j
\e$(7"]
\e(B|k
\e$(7":
\e(B|l
\e$(7";
\e(B|;
\e$(7"<
\e(B|'
\e$(7">
\e(B|
410 +---------------------------------------------+
411 |z
\e$(7"?
\e(B|x
\e$(7"@
\e(B|c
\e$(7"A
\e(B|v
\e$(7"B
\e(B|b
\e$(7"C
\e(B|n
\e$(7"D
\e(B|m
\e$(7"E
\e(B|,
\e$(7"G
\e(B|.
\e$(7"H
\e(B|/
\e$(7"I
\e(B|
412 +---------------------------------------+
413 The key 'h' is used for consonant stacking.
417 +----------------------------------------------------------+
418 |~
\e$(7"c
\e(B|!
\e$(7!4
\e(B|@
\e$(7!5
\e(B|# |$ |%
\e$(7!D
\e(B |^
\e$(7!1
\e(B|& |* |(
\e$(7!l
\e(B|)
\e$(7!m
\e(B|_ |+
\e$(7!A
\e(B| |
\e$(7!8
\e(B|
419 +----------------------------------------------------------+
420 |Q
\e$(7"J
\e(B|W |E |R |T
\e$(7"a
\e(B|Y |U |I
\e$(7"f
\e(B|O
\e$(7"+
\e(B|P
\e$(7",
\e(B|{
\e$(7"-
\e(B|}
\e$(7"/
\e(B|
421 +-----------------------------------------------+
422 |A |S |D |F
\e$(7"_
\e(B|G
\e$(7"S
\e(B|H
\e$(7"e
\e(B|J
\e$(7"[
\e(B|K |L |:
\e$(7"`
\e(B|\"
\e$(7#>
\e(B|
423 +-------------------------------------------+
424 |Z |X |C
\e$(7"R
\e(B|V
\e$(7#B
\e(B|B
\e$(7#C
\e(B|N
\e$(7#D
\e(B|M
\e$(7"F
\e(B|< |> |?
\e$(7!=
\e(B |
425 +---------------------------------------+
427 DIFFERENCE FROM THE ORIGINAL TIBKEY:
429 1. Vowel 'a' should be typed explicitly by the key 'A'.
430 This is really inconvenient. But to make the coding
431 scheme clear, it is desirable to have an explicite
433 2. Tsheg is assigned to SPC key. You can input a space
435 4. To avoid the default stacking
\e$(7$B
\e(B and to obtain
\e$(7"#"B
\e(B,
436 type 'E' instead of 'v' (=
\e$(7"B
\e(B).
437 3. There are many characters that are not supported in the
438 current implementation (especially special signs). I hope
439 I'll complete in a future revision.
441 nil nil nil nil nil nil nil nil
442 'quail-tibkey-update-translation)
445 (quail-map-from-table
446 '((base-state (tibetan-consonant-tibkey-alist . s-state)
447 (tibetan-non-stacking-tibkey-alist . s-state)
448 tibetan-subjoined-tibkey-alist
449 tibetan-vowel-tibkey-alist
450 tibetan-modifier-tibkey-alist
451 tibetan-punctuation-tibkey-alist)
452 (s-state (tibetan-subjoined-tibkey-alist . s-state)
453 (tibetan-vowel-tibkey-alist . m-state))
454 (m-state tibetan-modifier-tibkey-alist))))
456 ;; arch-tag: 828fdb1a-733f-4c7b-b882-a19d2449ac99
457 ;;; tibetan.el ends here