1 ;;; quail/tibetan.el -- Quail package for inputting Tibetan characters
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
6 ;; Keywords: multilingual, input method, Tibetan
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 ;; Author: Toru TOMABECHI, <Toru.Tomabechi@orient.unil.ch>
26 ;; Created: Feb. 17. 1997
29 ;; 1997.03.13 Support for inputting special signs and punctuations added.
30 ;; (Only Ext. Wylie input)
37 ;; Now quail-current-key is set to Tibetan-Roman transcription. We
38 ;; set quail-current-str to the corresponding Tibetan string (composed
39 ;; if necessary). Both Wylie and TibKey input methods use this
42 (defun quail-tibetan-update-translation (control-flag)
43 (if (numberp control-flag
)
44 ;; Non-composable-character typed.
45 (setq quail-current-str
46 (buffer-substring (overlay-start quail-overlay
)
47 (overlay-end quail-overlay
))
50 (substring quail-current-key control-flag
)))
51 ;; Special treatment of "-d..." and "-y...".
52 (if (string-match "^-[dy]" quail-current-key
)
53 (setq quail-current-key
(substring quail-current-key
1)))
54 (let ((str (tibetan-transcription-to-tibetan quail-current-key
)))
55 ;; If quail-current-key is for punctuations, it can't be
56 ;; transcribed by tibetan-transcription-to-tibetan, thus STR
57 ;; contains ASCII string now. In that case, use the current
58 ;; characters set in quail-current-str.
59 (if (> (aref str
0) 255)
60 (setq quail-current-str
(tibetan-compose-string str
))
62 (setq quail-current-str quail-current-key
)))))
65 ;;; Wylie transcription based input methods.
67 ;; Special alist for `\e$(7"A\e(B'. It must be treated as a subjoined
68 ;; consonant if it follows a consonant.
69 ;; * Removed by Tomabechi 2000/06/10 *
70 ;; 'a chung must be explicitly typed as a vowel ("fa")
71 ;; \e$(7"A\e(B is now treated as normal base consonants
72 ;; (defconst tibetan-wylie-quote-alist '(("'" . ?\e$(7"A\e(B)))
74 ;; Special alist to avoid default stacking.
75 (defconst tibetan-wylie-non-stacking-alist
76 '(("-d" .
"\e$(7"2\e(B")
77 ("-y
" . "\e$
(7"B\e(B")))
79 ;; Punctuations are not transcribed.
81 (defconst tibetan-wylie-punctuation-alist
86 ("//" .
"\e$(7!>\e(B")
87 ("////" .
["\e$(7!>\e(B \e$(7!>\e(B"])
89 ("/\"" .
"\e$(7!@\e(B") ; Not defined in Ext. Wylie.
97 ("*" . ["\e$
(7!4!5\e(B"])
98 ("#" . ["\e$
(7!4!5!5\e(B"])
100 ("0" . "\e$
(7!P
\e(B")
101 ("1" . "\e$
(7!Q
\e(B")
102 ("2" . "\e$
(7!R
\e(B")
103 ("3" . "\e$
(7!S
\e(B")
104 ("4" . "\e$
(7!T
\e(B")
105 ("5" . "\e$
(7!U
\e(B")
106 ("6" . "\e$
(7!V
\e(B")
107 ("7" . "\e$
(7!W
\e(B")
108 ("8" . "\e$
(7!X
\e(B")
109 ("9" . "\e$
(7!Y
\e(B")
110 ("-
0" . "\e$
(7!c
\e(B")
111 ("-
1" . "\e$
(7!Z
\e(B")
112 ("-
2" . "\e$
(7![\e(B")
113 ("-
3" . "\e$
(7!\
\e(B")
114 ("-
4" . "\e$
(7!]\e(B")
115 ("-
5" . "\e$
(7!^
\e(B")
116 ("-
6" . "\e$
(7!_
\e(B")
117 ("-
7" . "\e$
(7!`\e(B")
118 ("-
8" . "\e$
(7!a
\e(B")
119 ("-
9" . "\e$
(7!b
\e(B")
120 ("|
" . "\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")))
122 (quail-define-package "tibetan-wylie
" "Tibetan
" "TIBw
" t
123 "Tibetan character input by Extended Wylie key assignment.
125 +-------------------------------------
+
126 |
\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 /
127 |
\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 //
128 |
\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 ////
129 |
\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 ;
130 |
\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 $
131 |
\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 &
132 |
\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 *
133 |
\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 #
134 |
\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 < >
135 +-------------------------------------
+ \e$
(7!D
\e(B %
136 (The consonant
\e$
(7"I!;\e(B must be typed explicitly.)
138 NOT SPECIFIED IN EXT. WYLIE:
139 +--------------------------------------------------------+
140 |\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 = ^|
141 +--------------------------------------------------------+
142 |\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 |
143 +-----------------------------------------------+
146 + : Consonant Stacking
147 \(Consonant stacking for ordinary Tibetan is done automatically)
148 - : No Consonant Stacking
149 \(To suppress automatic stacking for \"g-y\",
150 and to get da-drag in -r-d, -l-d .)
153 Tsheg is assigned to SPC. Space is assigned to period '.'.
155 nil nil nil nil nil nil nil nil
156 'quail-tibetan-update-translation
)
158 ;; Here we build up a Quail map for a Tibtan sequence the whole of
159 ;; which can be one composition.
161 ;; A Tibetan syllable is typically structured as follows:
162 ;; [P] C [c+] V [M] [S [s]]
164 ;; where P:prefix, C:base consonant, c:subjoined consonant,
165 ;; V:vowel, M:vowel modifier, S:suffix, s:post suffix.
166 ;; In this pattern, the part indicated by "^^^" can be one composition.
168 ;;; modified by Tomabechi 1999/12/10
169 ;;; modified by Tomabechi 2000/06/08
170 ;;; Allows infinite addition of vowels/modifiers
171 ;;; as specified in Unicode v.3
173 (quail-map-from-table
174 '((base-state (tibetan-consonant-transcription-alist . svm-state
)
175 (tibetan-precomposed-transcription-alist . svm-state
)
176 (tibetan-wylie-non-stacking-alist . svm-state
)
177 tibetan-subjoined-transcription-alist
178 tibetan-vowel-transcription-alist
179 tibetan-modifier-transcription-alist
180 tibetan-wylie-punctuation-alist
)
181 (svm-state ;;(tibetan-wylie-quote-alist . vm-state)
182 (tibetan-vowel-transcription-alist . vm-state
)
183 (tibetan-subjoined-transcription-alist . svm-state
)
184 (tibetan-modifier-transcription-alist . m-state
))
185 (vm-state (tibetan-vowel-transcription-alist . vm-state
)
186 (tibetan-modifier-transcription-alist . m-state
))
187 (m-state (tibetan-modifier-transcription-alist . m-state
)))))
190 ;;; TibKey key alignment based input method
193 (defconst tibetan-tibkey-to-transcription-alist
195 ("`" .
"`") ; sna ldan
196 ("~" .
"~") ; sna ldan + nada
203 ("T" .
"I") ; gi gu log
216 ("A" .
"a") ; Vowel a (not used in original TibKey)
220 ("F" .
"M") ; anusvara
221 ("g" .
"u") ; zhabs kyu
223 ("H" .
",") ; viraama
225 ("J" .
"e") ; 'greng bu
230 ("\"" .
"+w") ; wa zur
234 ("C" .
"+'") ; 'a chung
236 ("V" .
"+y") ; ya btags
238 ("B" .
"+r") ; ra btags
240 ("N" .
"+l") ; la btags
248 ("hQ" .
"+kSH") ; kSHa
269 ("hl" .
"+tsh") ; tsha
283 ;; Special rule for `\e$(7"B\e(B' to avoid stacking.
287 (defconst tibetan-consonant-tibkey-alist nil
)
288 (defconst tibetan-subjoined-tibkey-alist nil
)
289 (defconst tibetan-vowel-tibkey-alist nil
)
290 (defconst tibetan-modifier-tibkey-alist nil
)
291 (defconst tibetan-non-stacking-tibkey-alist nil
)
293 (let ((type-list '("consonant" "subjoined" "vowel" "modifier" "non-stacking"))
294 (tail tibetan-tibkey-to-transcription-alist
)
297 (setq elt
(car tail
) tail
(cdr tail
))
298 (let ((types type-list
)
299 type transcription trans-alist tibkey-alist
)
301 (setq type
(car types
) types
(cdr types
))
303 (if (string= type
"non-stacking")
304 'tibetan-wylie-non-stacking-alist
305 (intern (format "tibetan-%s-transcription-alist" type
)))
307 (cdr (assoc (cdr elt
) (symbol-value trans-alist
))))
309 (setq tibkey-alist
(intern (format "tibetan-%s-tibkey-alist" type
)))
311 (cons (cons (car elt
) transcription
)
312 (symbol-value tibkey-alist
)))))
314 (error "No Tibetan transcription for %s" (cdr elt
))))))
316 (defconst tibetan-punctuation-tibkey-alist
317 '(("1" .
"\e$(7!Q\e(B")
318 ("!" .
"\e$(7!4\e(B") ; nyi zla long
319 ("2" .
"\e$(7!R\e(B")
320 ("@" .
"\e$(7!5\e(B") ; nyi zla simple
321 ("3" .
"\e$(7!S\e(B")
323 ("4" .
"\e$(7!T\e(B")
325 ("5" .
"\e$(7!U\e(B")
326 ("%" .
"\e$(7!D\e(B")
327 ("6" .
"\e$(7!V\e(B")
328 ("^" .
"\e$(7!1\e(B")
329 ("7" .
"\e$(7!W\e(B")
330 ("8" .
"\e$(7!X\e(B")
331 ;;; ("*" ) ; avagraha, not supported yet
332 ("9" .
"\e$(7!Y\e(B")
333 ("(" .
"\e$(7!l\e(B")
334 ("0" .
"\e$(7!P\e(B")
335 (")" .
"\e$(7!m\e(B")
336 ;;; ("-" ) ; enphatic, not yet supported
338 ;;; ("=" ) ; special sign, not yet supported
339 ("+" .
"\e$(7!A\e(B")
340 ("\\" .
"\e$(7!?\e(B")
341 ("|" .
"\e$(7!8\e(B")
342 ("I" .
"\e$(7"f
\e(B") ; avagraha
343 (":" . "\e$
(7"`\e(B")
344 ;;; (">" ?\e$(7!;\e(B) ; to be assigned to SPC
346 ("?" .
"\e$(7!=\e(B")
347 ("??" .
"\e$(7!>\e(B")
348 ("????" .
["\e$(7!>\e(B \e$(7!>\e(B"])
349 (" " .
"\e$(7!;\e(B")
352 ;; Convert TibKey string to Tibetan-Roman transcription string.
353 ;; If there's no proper conversion, return nil.
354 (defun quail-tibkey-to-transcription (tibkey)
355 (let ((len (length tibkey
))
361 (while (and (not trans
) (> last i
))
362 (or (setq trans
(cdr (assoc (substring tibkey i last
)
363 tibetan-tibkey-to-transcription-alist
)))
364 (setq last
(1- last
))))
366 (setq trans-list
(cons trans trans-list
)
368 (setq trans-list nil i len
))))
369 (apply 'concat
(nreverse trans-list
))))
371 (defvar quail-tibkey-characters nil
)
373 (defun quail-tibkey-update-translation (control-flag)
374 (if (integerp control-flag
)
375 ;; Non-composable-character typed.
376 (setq quail-current-str
377 (buffer-substring (overlay-start quail-overlay
)
378 (overlay-end quail-overlay
))
379 unread-command-events
381 (substring quail-current-key control-flag
)))
382 (let ((transcription (quail-tibkey-to-transcription quail-current-key
)))
383 (if (> (length transcription
) 0)
384 (let ((quail-current-key transcription
))
386 (quail-tibetan-update-translation control-flag
)))
387 (or quail-current-str
388 (setq quail-current-str quail-current-key
)))))
391 (quail-define-package "tibetan-tibkey" "Tibetan" "TIBt" t
392 "Tibetan character input by TibKey key assignment.
394 \(This implementation is still incomplete.
395 Therefore, the following key assignment is a provisional one.)
399 +-------------------------------------------------------+
400 |`\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|
401 +-------------------------------------------------------
+
402 |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|
403 +-----------------------------------------------+
404 |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|
405 +---------------------------------------------+
406 |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|
407 +---------------------------------------+
408 The key 'h' is used for consonant stacking.
412 +----------------------------------------------------------+
413 |~\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|
414 +----------------------------------------------------------
+
415 |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|
416 +-----------------------------------------------+
417 |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|
418 +-------------------------------------------
+
419 |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 |
420 +---------------------------------------
+
422 DIFFERENCE FROM THE ORIGINAL TIBKEY
:
424 1. Vowel
'a
' should be typed explicitly by the key
'A
'.
425 This is really inconvenient. But to make the coding
426 scheme clear
, it is desirable to have an explicite
428 2. Tsheg is assigned to SPC key. You can input a space
430 4. To avoid the default stacking
\e$
(7$B
\e(B and to obtain
\e$
(7"#"B
\e(B,
431 type
'E
' instead of
'v
' (=\e$
(7"B\e(B).
432 3. There are many characters that are not supported in the
433 current implementation (especially special signs). I hope
434 I'll complete in a future revision.
436 nil nil nil nil nil nil nil nil
437 'quail-tibkey-update-translation
)
440 (quail-map-from-table
441 '((base-state (tibetan-consonant-tibkey-alist . s-state
)
442 (tibetan-non-stacking-tibkey-alist . s-state
)
443 tibetan-subjoined-tibkey-alist
444 tibetan-vowel-tibkey-alist
445 tibetan-modifier-tibkey-alist
446 tibetan-punctuation-tibkey-alist
)
447 (s-state (tibetan-subjoined-tibkey-alist . s-state
)
448 (tibetan-vowel-tibkey-alist . m-state
))
449 (m-state tibetan-modifier-tibkey-alist
))))