1 ;;; tibetan.el --- Quail package for inputting Tibetan characters -*-coding: utf-8-emacs;-*-
3 ;; Copyright (C) 1997, 2001-2018 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 <https://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 unread-command-events
))
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 punctuation, 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 `འ'. 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 ;; འ is now treated as normal base consonants
77 ;; (defconst tibetan-wylie-quote-alist '(("'" . ?འ)))
79 ;; Special alist to avoid default stacking.
80 (defconst tibetan-wylie-non-stacking-alist
84 ;; Punctuation characters are not transcribed.
86 (defconst tibetan-wylie-punctuation-alist
94 ("/\"" .
"༐") ; Not defined in Ext. Wylie.
125 ("|" .
"ༀ༁༂༃༇༉༊༒༓༕༖༗༘༙༚༛༜༝༞༟༴༶༸༺༻༾༿྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿏")))
127 (quail-define-package "tibetan-wylie" "Tibetan" "TIBw" t
128 "Tibetan character input by Extended Wylie key assignment.
130 +-------------------------------------+
131 |ཀ་ k |ཁ་ kh |ག་ g |གྷ་ gh |ང་ ng| ི i ། /
132 |ཅ་ c |ཆ་ ch |ཇ་ j | |ཉ་ ny| ུ u ༎ //
133 |ཊ་ T |ཋ་ TH |ཌ་ D |ཌྷ་ DH |ཎ་ N | ེ e ༎ ༎ ////
134 |ཏ་ t |ཐ་ th |ད་ d |དྷ་ dh |ན་ n | ོ o ༑ ;
135 |པ་ p |ཕ་ ph |བ་ b |བྷ་ bh |མ་ m | ཻ ai (ee, E) ༏ $
136 |ཙ་ ts|ཚ་ tsh|ཛ་ dz |ཛྷ་ dzh|ཝ་ w | ཽ au (oo, O) ༐ &
137 |ཞ་ zh|ཟ་ z |འ་ \\=' | |ཡ་ y | ྀ I ༄༅ *
138 |ར་ r |ལ་ l |ཤ་ sh |ཥ་ SH |ས་ s | ཿ : ༄༅༅ #
139 |ཧ་ h |ཨ་ A |ཀྵ་ kSH| | | ཾ M ༼ ༽ < >
140 +-------------------------------------+ ༔ %
141 (The consonant ཨ་ must be typed explicitly.)
143 NOT SPECIFIED IN EXT. WYLIE:
144 +--------------------------------------------------------+
145 |ྂ = ~ |ྃ = \\=` |྄ = , |྅ = @ |༷ = _o|༵ = _O|༆ = ^|
146 +--------------------------------------------------------+
147 |ྈ = x |ྉ = X |྆ = v |྇ = V |ྊ = q |ྋ = 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 Tibetan 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
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 `ཡ' 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
323 ("!" .
"༄") ; nyi zla long
325 ("@" .
"༅") ; nyi zla simple
336 ;;; ("*" ) ; avagraha, not supported yet
341 ;;; ("-" ) ; emphatic, not yet supported
343 ;;; ("=" ) ; special sign, not yet supported
347 ("I" .
"྅") ; avagraha
349 ;;; (">" ?་) ; to be assigned to SPC
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 unread-command-events
))
388 (let ((transcription (quail-tibkey-to-transcription quail-current-key
)))
389 (if (> (length transcription
) 0)
390 (let ((quail-current-key transcription
))
392 (quail-tibetan-update-translation control-flag
)))
393 (or quail-current-str
394 (setq quail-current-str quail-current-key
)))))
397 (quail-define-package "tibetan-tibkey" "Tibetan" "TIBt" t
398 "Tibetan character input by TibKey key assignment.
400 \(This implementation is still incomplete.
401 Therefore, the following key assignment is a provisional one.)
405 +-------------------------------------------------------+
406 |`ྃ|1༡|2༢|3༣|4༤|5༥|6༦|7༧|8༨|9༩|0༠|- |= |\\༈|
407 +-------------------------------------------------------+
408 |qཀ|wཁ|eག|rང|tཅ|yཆ|uཇ|iཉ|oཏ|pཐ|[ད|]ན|
409 +-----------------------------------------------+
410 |aཔ| sཕ| dབ|fམ|gུ|h |jོ|kཙ|lཚ|;ཛ|\\='ཝ|
411 +---------------------------------------------+
412 |zཞ|xཟ|cའ|vཡ|bར|nལ|mཤ|,ས|.ཧ|/ཨ|
413 +---------------------------------------+
414 The key `h' is used for consonant stacking.
418 +----------------------------------------------------------+
419 |~ྂ|!༄|@༅|# |$ |%༔ |^༁|& |* |(༼|)༽|_ |+༑| |༈|
420 +----------------------------------------------------------+
421 |Qཀྵ|W |E |R |Tྀ|Y |U |I྅|Oཊ|Pཋ|{ཌ|}ཎ|
422 +-----------------------------------------------+
423 |A |S |D |Fཾ|Gི|H྄|Jེ|K |L |:ཿ|\"ྭ|
424 +-------------------------------------------+
425 |Z |X |Cཱ|Vྱ|Bྲ|Nླ|Mཥ|< |> |?། |
426 +---------------------------------------+
428 DIFFERENCE FROM THE ORIGINAL TIBKEY:
430 1. Vowel `a' should be typed explicitly by the key `A'.
431 This is really inconvenient. But to make the coding
432 scheme clear, it is desirable to have an explicit
434 2. Tsheg is assigned to SPC key. You can input a space
436 4. To avoid the default stacking and to obtain གཡ,
437 type `E' instead of `v' (=ཡ).
438 3. There are many characters that are not supported in the
439 current implementation (especially special signs).
440 I hope I'll complete in a future revision.
442 nil nil nil nil nil nil nil nil
443 'quail-tibkey-update-translation
)
446 (quail-map-from-table
447 '((base-state (tibetan-consonant-tibkey-alist . s-state
)
448 (tibetan-non-stacking-tibkey-alist . s-state
)
449 tibetan-subjoined-tibkey-alist
450 tibetan-vowel-tibkey-alist
451 tibetan-modifier-tibkey-alist
452 tibetan-punctuation-tibkey-alist
)
453 (s-state (tibetan-subjoined-tibkey-alist . s-state
)
454 (tibetan-vowel-tibkey-alist . m-state
))
455 (m-state tibetan-modifier-tibkey-alist
))))
457 ;;; tibetan.el ends here