1 ;;; tibetan.el --- Quail package for inputting Tibetan characters -*-coding: utf-8-emacs;-*-
3 ;; Copyright (C) 1997, 2001-2013 Free Software Foundation, Inc.
4 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5 ;; 2006, 2007, 2008, 2009, 2010, 2011
6 ;; National Institute of Advanced Industrial Science and Technology (AIST)
7 ;; Registration Number H14PRO021
9 ;; Keywords: multilingual, input method, Tibetan
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; Author: Toru TOMABECHI, <Toru.Tomabechi@orient.unil.ch>
28 ;; Created: Feb. 17. 1997
31 ;; 1997.03.13 Support for inputting special signs and punctuation added.
32 ;; (Only Ext. Wylie input)
41 ;; Now quail-current-key is set to Tibetan-Roman transcription. We
42 ;; set quail-current-str to the corresponding Tibetan string (composed
43 ;; if necessary). Both Wylie and TibKey input methods use this
46 (defun quail-tibetan-update-translation (control-flag)
47 (if (numberp control-flag
)
48 ;; Non-composable-character typed.
49 (setq quail-current-str
50 (buffer-substring (overlay-start quail-overlay
)
51 (overlay-end quail-overlay
))
54 (substring quail-current-key control-flag
)))
55 ;; Special treatment of "-d..." and "-y...".
56 (if (string-match "^-[dy]" quail-current-key
)
57 (setq quail-current-key
(substring quail-current-key
1)))
58 (let ((str (tibetan-transcription-to-tibetan quail-current-key
)))
59 ;; If quail-current-key is for punctuation, it can't be
60 ;; transcribed by tibetan-transcription-to-tibetan, thus STR
61 ;; contains ASCII string now. In that case, use the current
62 ;; characters set in quail-current-str.
63 (if (> (aref str
0) 255)
64 (setq quail-current-str
(tibetan-compose-string str
))
66 (setq quail-current-str quail-current-key
)))))
69 ;;; Wylie transcription based input methods.
71 ;; Special alist for `འ'. It must be treated as a subjoined
72 ;; consonant if it follows a consonant.
73 ;; * Removed by Tomabechi 2000/06/10 *
74 ;; 'a chung must be explicitly typed as a vowel ("fa")
75 ;; འ is now treated as normal base consonants
76 ;; (defconst tibetan-wylie-quote-alist '(("'" . ?འ)))
78 ;; Special alist to avoid default stacking.
79 (defconst tibetan-wylie-non-stacking-alist
83 ;; Punctuation characters are not transcribed.
85 (defconst tibetan-wylie-punctuation-alist
93 ("/\"" .
"༐") ; Not defined in Ext. Wylie.
124 ("|" .
"ༀ༁༂༃༇༉༊༒༓༕༖༗༘༙༚༛༜༝༞༟༴༶༸༺༻༾༿྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿏")))
126 (quail-define-package "tibetan-wylie" "Tibetan" "TIBw" t
127 "Tibetan character input by Extended Wylie key assignment.
129 +-------------------------------------+
130 |ཀ་ k |ཁ་ kh |ག་ g |གྷ་ gh |ང་ ng| ི i ། /
131 |ཅ་ c |ཆ་ ch |ཇ་ j | |ཉ་ ny| ུ u ༎ //
132 |ཊ་ T |ཋ་ TH |ཌ་ D |ཌྷ་ DH |ཎ་ N | ེ e ༎ ༎ ////
133 |ཏ་ t |ཐ་ th |ད་ d |དྷ་ dh |ན་ n | ོ o ༑ ;
134 |པ་ p |ཕ་ ph |བ་ b |བྷ་ bh |མ་ m | ཻ ai (ee, E) ༏ $
135 |ཙ་ ts|ཚ་ tsh|ཛ་ dz |ཛྷ་ dzh|ཝ་ w | ཽ au (oo, O) ༐ &
136 |ཞ་ zh|ཟ་ z |འ་ ' | |ཡ་ y | ྀ I ༄༅ *
137 |ར་ r |ལ་ l |ཤ་ sh |ཥ་ SH |ས་ s | ཿ : ༄༅༅ #
138 |ཧ་ h |ཨ་ A |ཀྵ་ kSH| | | ཾ M ༼ ༽ < >
139 +-------------------------------------+ ༔ %
140 (The consonant ཨ་ must be typed explicitly.)
142 NOT SPECIFIED IN EXT. WYLIE:
143 +--------------------------------------------------------+
144 |ྂ = ~ |ྃ = ` |྄ = , |྅ = @ |༷ = _o|༵ = _O|༆ = ^|
145 +--------------------------------------------------------+
146 |ྈ = x |ྉ = X |྆ = v |྇ = V |ྊ = q |ྋ = Q |
147 +-----------------------------------------------+
150 + : Consonant Stacking
151 \(Consonant stacking for ordinary Tibetan is done automatically)
152 - : No Consonant Stacking
153 \(To suppress automatic stacking for \"g-y\",
154 and to get da-drag in -r-d, -l-d .)
157 Tsheg is assigned to SPC. Space is assigned to period '.'.
159 nil nil nil nil nil nil nil nil
160 'quail-tibetan-update-translation
)
162 ;; Here we build up a Quail map for a Tibetan sequence the whole of
163 ;; which can be one composition.
165 ;; A Tibetan syllable is typically structured as follows:
166 ;; [P] C [c+] V [M] [S [s]]
168 ;; where P:prefix, C:base consonant, c:subjoined consonant,
169 ;; V:vowel, M:vowel modifier, S:suffix, s:post suffix.
170 ;; In this pattern, the part indicated by "^^^" can be one composition.
172 ;;; modified by Tomabechi 1999/12/10
173 ;;; modified by Tomabechi 2000/06/08
174 ;;; Allows infinite addition of vowels/modifiers
175 ;;; as specified in Unicode v.3
177 (quail-map-from-table
178 '((base-state (tibetan-consonant-transcription-alist . svm-state
)
179 (tibetan-precomposed-transcription-alist . svm-state
)
180 (tibetan-wylie-non-stacking-alist . svm-state
)
181 tibetan-subjoined-transcription-alist
182 tibetan-vowel-transcription-alist
183 tibetan-modifier-transcription-alist
184 tibetan-wylie-punctuation-alist
)
185 (svm-state ;;(tibetan-wylie-quote-alist . vm-state)
186 (tibetan-vowel-transcription-alist . vm-state
)
187 (tibetan-subjoined-transcription-alist . svm-state
)
188 (tibetan-modifier-transcription-alist . m-state
))
189 (vm-state (tibetan-vowel-transcription-alist . vm-state
)
190 (tibetan-modifier-transcription-alist . m-state
))
191 (m-state (tibetan-modifier-transcription-alist . m-state
)))))
194 ;;; TibKey key alignment based input method
197 (defconst tibetan-tibkey-to-transcription-alist
199 ("`" .
"`") ; sna ldan
200 ("~" .
"~") ; sna ldan + nada
207 ("T" .
"I") ; gi gu log
220 ("A" .
"a") ; Vowel a (not used in original TibKey)
224 ("F" .
"M") ; anusvara
225 ("g" .
"u") ; zhabs kyu
229 ("J" .
"e") ; 'greng bu
234 ("\"" .
"+w") ; wa zur
238 ("C" .
"+'") ; 'a chung
240 ("V" .
"+y") ; ya btags
242 ("B" .
"+r") ; ra btags
244 ("N" .
"+l") ; la btags
252 ("hQ" .
"+kSH") ; kSHa
273 ("hl" .
"+tsh") ; tsha
287 ;; Special rule for `ཡ' to avoid stacking.
291 (defconst tibetan-consonant-tibkey-alist nil
)
292 (defconst tibetan-subjoined-tibkey-alist nil
)
293 (defconst tibetan-vowel-tibkey-alist nil
)
294 (defconst tibetan-modifier-tibkey-alist nil
)
295 (defconst tibetan-non-stacking-tibkey-alist nil
)
297 (let ((type-list '("consonant" "subjoined" "vowel" "modifier" "non-stacking"))
298 (tail tibetan-tibkey-to-transcription-alist
)
301 (setq elt
(car tail
) tail
(cdr tail
))
302 (let ((types type-list
)
303 type transcription trans-alist tibkey-alist
)
305 (setq type
(car types
) types
(cdr types
))
307 (if (string= type
"non-stacking")
308 'tibetan-wylie-non-stacking-alist
309 (intern (format "tibetan-%s-transcription-alist" type
)))
311 (cdr (assoc (cdr elt
) (symbol-value trans-alist
))))
313 (setq tibkey-alist
(intern (format "tibetan-%s-tibkey-alist" type
)))
315 (cons (cons (car elt
) transcription
)
316 (symbol-value tibkey-alist
)))))
318 (error "No Tibetan transcription for %s" (cdr elt
))))))
320 (defconst tibetan-punctuation-tibkey-alist
322 ("!" .
"༄") ; nyi zla long
324 ("@" .
"༅") ; nyi zla simple
335 ;;; ("*" ) ; avagraha, not supported yet
340 ;;; ("-" ) ; emphatic, not yet supported
342 ;;; ("=" ) ; special sign, not yet supported
346 ("I" .
"྅") ; avagraha
348 ;;; (">" ?་) ; to be assigned to SPC
356 ;; Convert TibKey string to Tibetan-Roman transcription string.
357 ;; If there's no proper conversion, return nil.
358 (defun quail-tibkey-to-transcription (tibkey)
359 (let ((len (length tibkey
))
365 (while (and (not trans
) (> last i
))
366 (or (setq trans
(cdr (assoc (substring tibkey i last
)
367 tibetan-tibkey-to-transcription-alist
)))
368 (setq last
(1- last
))))
370 (setq trans-list
(cons trans trans-list
)
372 (setq trans-list nil i len
))))
373 (apply 'concat
(nreverse trans-list
))))
375 (defvar quail-tibkey-characters nil
)
377 (defun quail-tibkey-update-translation (control-flag)
378 (if (integerp control-flag
)
379 ;; Non-composable-character typed.
380 (setq quail-current-str
381 (buffer-substring (overlay-start quail-overlay
)
382 (overlay-end quail-overlay
))
383 unread-command-events
385 (substring quail-current-key control-flag
)))
386 (let ((transcription (quail-tibkey-to-transcription quail-current-key
)))
387 (if (> (length transcription
) 0)
388 (let ((quail-current-key transcription
))
390 (quail-tibetan-update-translation control-flag
)))
391 (or quail-current-str
392 (setq quail-current-str quail-current-key
)))))
395 (quail-define-package "tibetan-tibkey" "Tibetan" "TIBt" t
396 "Tibetan character input by TibKey key assignment.
398 \(This implementation is still incomplete.
399 Therefore, the following key assignment is a provisional one.)
403 +-------------------------------------------------------+
404 |`ྃ|1༡|2༢|3༣|4༤|5༥|6༦|7༧|8༨|9༩|0༠|- |= |\\༈|
405 +-------------------------------------------------------+
406 |qཀ|wཁ|eག|rང|tཅ|yཆ|uཇ|iཉ|oཏ|pཐ|[ད|]ན|
407 +-----------------------------------------------+
408 |aཔ| sཕ| dབ|fམ|gུ|h |jོ|kཙ|lཚ|;ཛ|'ཝ|
409 +---------------------------------------------+
410 |zཞ|xཟ|cའ|vཡ|bར|nལ|mཤ|,ས|.ཧ|/ཨ|
411 +---------------------------------------+
412 The key 'h' is used for consonant stacking.
416 +----------------------------------------------------------+
417 |~ྂ|!༄|@༅|# |$ |%༔ |^༁|& |* |(༼|)༽|_ |+༑| |༈|
418 +----------------------------------------------------------+
419 |Qཀྵ|W |E |R |Tྀ|Y |U |I྅|Oཊ|Pཋ|{ཌ|}ཎ|
420 +-----------------------------------------------+
421 |A |S |D |Fཾ|Gི|H྄|Jེ|K |L |:ཿ|\"ྭ|
422 +-------------------------------------------+
423 |Z |X |Cཱ|Vྱ|Bྲ|Nླ|Mཥ|< |> |?། |
424 +---------------------------------------+
426 DIFFERENCE FROM THE ORIGINAL TIBKEY:
428 1. Vowel 'a' should be typed explicitly by the key 'A'.
429 This is really inconvenient. But to make the coding
430 scheme clear, it is desirable to have an explicit
432 2. Tsheg is assigned to SPC key. You can input a space
434 4. To avoid the default stacking and to obtain གཡ,
435 type 'E' instead of 'v' (=ཡ).
436 3. There are many characters that are not supported in the
437 current implementation (especially special signs). I hope
438 I'll complete in a future revision.
440 nil nil nil nil nil nil nil nil
441 'quail-tibkey-update-translation
)
444 (quail-map-from-table
445 '((base-state (tibetan-consonant-tibkey-alist . s-state
)
446 (tibetan-non-stacking-tibkey-alist . s-state
)
447 tibetan-subjoined-tibkey-alist
448 tibetan-vowel-tibkey-alist
449 tibetan-modifier-tibkey-alist
450 tibetan-punctuation-tibkey-alist
)
451 (s-state (tibetan-subjoined-tibkey-alist . s-state
)
452 (tibetan-vowel-tibkey-alist . m-state
))
453 (m-state tibetan-modifier-tibkey-alist
))))
455 ;;; tibetan.el ends here