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 (defconst tibetan-wylie-quote-alist '(("'" . ?
\e$(7"A
\e(B)))
71 ;; Special alist to avoid default stacking.
72 (defconst tibetan-wylie-non-stacking-alist
73 '(("-d" . "
\e$(7"2
\e(B")
74 ("-y" . "
\e$(7"B
\e(B")))
76 ;; Punctuations are not transcribed.
78 (defconst tibetan-wylie-punctuation-alist
83 ("//" . "
\e$(7!>
\e(B")
84 ("////" . ["
\e$(7!>
\e(B
\e$(7!>
\e(B"])
86 ("/\"" . "
\e$(8!@
\e(B") ; Not defined in Ext. Wylie.
94 ("*" . ["
\e$(7!4!5
\e(B"])
95 ("#" . ["
\e$(7!4!5!5
\e(B"])
100 ("3" . "
\e$(7!S
\e(B")
101 ("4" . "
\e$(7!T
\e(B")
102 ("5" . "
\e$(7!U
\e(B")
103 ("6" . "
\e$(7!V
\e(B")
104 ("7" . "
\e$(7!W
\e(B")
105 ("8" . "
\e$(7!X
\e(B")
106 ("9" . "
\e$(7!Y
\e(B")
107 ("-0" . "
\e$(7!c
\e(B")
108 ("-1" . "
\e$(7!Z
\e(B")
109 ("-2" . "
\e$(7![
\e(B")
110 ("-3" . "
\e$(7!\
\e(B")
111 ("-4" . "
\e$(7!]
\e(B")
112 ("-5" . "
\e$(7!^
\e(B")
113 ("-6" . "
\e$(7!_
\e(B")
114 ("-7" . "
\e$(7!`
\e(B")
115 ("-8" . "
\e$(7!a
\e(B")
116 ("-9" . "
\e$(7!b
\e(B")
117 ("|" . "
\e$(7!1!2!3!9!:!B!C!E!F!G!H!I!J!K!L!M!N!O!d!f!h!j!k!n!o
\e(B")))
119 (quail-define-package "tibetan-wylie" "Tibetan" "TIBw" t
120 "Tibetan character input by Extended Wylie key assignment.
122 +-------------------------------------+
123 |
\e$(7"!
\e$(8!;
\e(B k |
\e$(7""
\e$(8!;
\e(B kh |
\e$(7"#
\e$(8!;
\e(B g |
\e$(7"$
\e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7"F
\e$(8!;
\e(B SH |
\e$(7"G
\e$(8!;
\e(B s |
\e$(7"`
\e(B :
\e$(7#R#S#S#S
\e(B #
131 |
\e$(7"H
\e$(8!;
\e(B h |
\e$(7"I
\e$(8!;
\e(B A |
\e$(7"J
\e$(8!;
\e(B kSH| | |
\e$(7"_
\e(B M
\e$(7!l
\e(B
\e$(7!m
\e(B < >
132 +-------------------------------------+
\e$(8!D
\e(B %
133 (The consonant
\e$(7"I
\e$(8!;
\e(B must be typed explicitly.)
135 NOT SPECIFIED IN EXT. WYLIE:
136 +--------------------------------------------------------+
137 |
\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#R#S!I
\e(B = ^|
138 +--------------------------------------------------------+
139 |
\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 |
140 +-----------------------------------------------+
143 + : Consonant Stacking
144 \(Consonant stacking for ordinary Tibetan is done automatically)
145 - : No Consonant Stacking
146 \(To suppress automatic stacking for \"g-y\",
147 and to get da-drag in -r-d, -l-d .)
150 Tsheg is assigned to SPC. Space is assigned to period '.'.
152 nil nil nil nil nil nil nil nil
153 'quail-tibetan-update-translation)
155 ;; Here we build up a Quail map for a Tibtan sequence the whole of
156 ;; which can be one composition.
158 ;; A Tibetan syllable is typically structured as follows:
159 ;; [P] C [c+] V [M] [S [s]]
161 ;; where P:prefix, C:base consonant, c:subjoined consonant,
162 ;; V:vowel, M:vowel modifier, S:suffix, s:post suffix.
163 ;; In this pattern, the part indicated by "^^^" can be one composition.
166 (quail-map-from-table
167 '((base-state (tibetan-consonant-transcription-alist . sq-state)
168 (tibetan-precomposed-transcription-alist . s-state)
169 (tibetan-wylie-non-stacking-alist . sq-state)
170 tibetan-subjoined-transcription-alist
171 tibetan-vowel-transcription-alist
172 tibetan-modifier-transcription-alist
173 tibetan-wylie-punctuation-alist)
174 (sq-state (tibetan-wylie-quote-alist . s-state)
175 (tibetan-subjoined-transcription-alist . s-state))
176 (s-state (tibetan-subjoined-transcription-alist . s-state)
177 (tibetan-vowel-transcription-alist . m-state))
178 (m-state tibetan-modifier-transcription-alist))))
181 ;;; TibKey key alignment based input method
184 (defconst tibetan-tibkey-to-transcription-alist
186 ("`" . "`") ; sna ldan
187 ("~" . "~") ; sna ldan + nada
194 ("T" . "I") ; gi gu log
207 ("A" . "a") ; Vowel a (not used in original TibKey)
211 ("F" . "M") ; anusvara
212 ("g" . "u") ; zhabs kyu
214 ("H" . ",") ; viraama
216 ("J" . "e") ; 'greng bu
221 ("\"" . "+w") ; wa zur
225 ("C" . "+'") ; 'a chung
227 ("V" . "+y") ; ya btags
229 ("B" . "+r") ; ra btags
231 ("N" . "+l") ; la btags
239 ("hQ" ."+kSH") ; kSHa
260 ("hl" . "+tsh") ; tsha
274 ;; Special rule for `
\e$(7"B
\e(B' to avoid stacking.
278 (defconst tibetan-consonant-tibkey-alist nil)
279 (defconst tibetan-subjoined-tibkey-alist nil)
280 (defconst tibetan-vowel-tibkey-alist nil)
281 (defconst tibetan-modifier-tibkey-alist nil)
282 (defconst tibetan-non-stacking-tibkey-alist nil)
284 (let ((type-list '("consonant" "subjoined" "vowel" "modifier" "non-stacking"))
285 (tail tibetan-tibkey-to-transcription-alist)
288 (setq elt (car tail) tail (cdr tail))
289 (let ((types type-list)
290 type transcription trans-alist tibkey-alist)
292 (setq type (car types) types (cdr types))
294 (if (string= type "non-stacking")
295 'tibetan-wylie-non-stacking-alist
296 (intern (format "tibetan-%s-transcription-alist" type)))
298 (cdr (assoc (cdr elt) (symbol-value trans-alist))))
300 (setq tibkey-alist (intern (format "tibetan-%s-tibkey-alist" type)))
302 (cons (cons (car elt) transcription)
303 (symbol-value tibkey-alist)))))
305 (error "No Tibetan transcription for %s" (cdr elt))))))
307 (defconst tibetan-punctuation-tibkey-alist
308 '(("1" . "
\e$(7!Q
\e(B")
309 ("!" . ["
\e$(7#R#S#S#S
\e(B"]) ; nyi zla long
310 ("2" . "
\e$(7!R
\e(B")
311 ("@" . "
\e$(7#S
\e(B") ; nyi zla simple
312 ("3" . "
\e$(7!S
\e(B")
314 ("4" . "
\e$(7!T
\e(B")
316 ("5" . "
\e$(7!U
\e(B")
317 ("%" . "
\e$(8!D
\e(B")
318 ("6" . "
\e$(7!V
\e(B")
319 ("^" . "
\e$(7!1
\e(B")
320 ("7" . "
\e$(7!W
\e(B")
321 ("8" . "
\e$(7!X
\e(B")
322 ;;; ("*" ) ; avagraha, not supported yet
323 ("9" . "
\e$(7!Y
\e(B")
324 ("(" . "
\e$(7!l
\e(B")
325 ("0" . "
\e$(7!P
\e(B")
326 (")" . "
\e$(7!m
\e(B")
327 ;;; ("-" ) ; enphatic, not yet supported
329 ;;; ("=" ) ; special sign, not yet supported
330 ("+" . "
\e$(8!A
\e(B")
331 ("\\" . "
\e$(8!?
\e(B")
332 ("|" . "
\e$(7!8
\e(B")
333 ("I" . "
\e$(7"f
\e(B") ; avagraha
334 (":" . "
\e$(8"`
\e(B")
335 ;;; (">" ?
\e$(8!;
\e(B) ; to be assigned to SPC
337 ("?" . "
\e$(8!=
\e(B")
338 ("??" . "
\e$(7!>
\e(B")
339 ("????" . ["
\e$(7!>
\e(B
\e$(7!>
\e(B"])
340 (" " . "
\e$(8!;
\e(B")
343 ;; Convert TibKey string to Tibetan-Roman transcription string.
344 ;; If there's no proper conversion, return nil.
345 (defun quail-tibkey-to-transcription (tibkey)
346 (let ((len (length tibkey))
352 (while (and (not trans) (> last i))
353 (or (setq trans (cdr (assoc (substring tibkey i last)
354 tibetan-tibkey-to-transcription-alist)))
355 (setq last (1- last))))
357 (setq trans-list (cons trans trans-list)
359 (setq trans-list nil i len))))
360 (apply 'concat (nreverse trans-list))))
362 (defvar quail-tibkey-characters nil)
364 (defun quail-tibkey-update-translation (control-flag)
365 (if (integerp control-flag)
366 ;; Non-composable-character typed.
367 (setq quail-current-str
368 (buffer-substring (overlay-start quail-overlay)
369 (overlay-end quail-overlay))
370 unread-command-events
372 (substring quail-current-key control-flag)))
373 (let ((transcription (quail-tibkey-to-transcription quail-current-key)))
374 (if (> (length transcription) 0)
375 (let ((quail-current-key transcription))
377 (quail-tibetan-update-translation control-flag)))
378 (or quail-current-str
379 (setq quail-current-str quail-current-key)))))
382 (quail-define-package "tibetan-tibkey" "Tibetan" "TIBt" t
383 "Tibetan character input by TibKey key assignment.
385 \(This implementation is still incomplete.
386 Therefore, the following key assignment is a provisional one.)
390 +-------------------------------------------------------+
391 |`
\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|
392 +-------------------------------------------------------+
393 |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|
394 +-----------------------------------------------+
395 |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|
396 +---------------------------------------------+
397 |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|
398 +---------------------------------------+
399 The key 'h' is used for consonant stacking.
403 +----------------------------------------------------------+
404 |~
\e$(7"c
\e(B|!
\e$(7#R#S
\e(B|@
\e$(7#S
\e(B|# |$ |%
\e$(8!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|
405 +----------------------------------------------------------+
406 |Q
\e$(7"J
\e(B|W
\e$(7#T
\e(B|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|
407 +-----------------------------------------------+
408 |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|
409 +-------------------------------------------+
410 |Z |X |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"F
\e(B|< |> |?
\e$(8!=
\e(B |
411 +---------------------------------------+
413 DIFFERENCE FROM THE ORIGINAL TIBKEY:
415 1. Vowel 'a' should be typed explicitly by the key 'A'.
416 This is really inconvenient. But to make the coding
417 scheme clear, it is desirable to have an explicite
419 2. Tsheg is assigned to SPC key. You can input a space
421 4. To avoid the default stacking
\e$(7$B
\e(B and to obtain
\e$(7"#"B
\e(B,
422 type 'E' instead of 'v' (=
\e$(7"B
\e(B).
423 3. There are many characters that are not supported in the
424 current implementation (especially special signs). I hope
425 I'll complete in a future revision.
427 nil nil nil nil nil nil nil nil
428 'quail-tibkey-update-translation)
431 (quail-map-from-table
432 '((base-state (tibetan-consonant-tibkey-alist . s-state)
433 (tibetan-non-stacking-tibkey-alist . s-state)
434 tibetan-subjoined-tibkey-alist
435 tibetan-vowel-tibkey-alist
436 tibetan-modifier-tibkey-alist
437 tibetan-punctuation-tibkey-alist)
438 (s-state (tibetan-subjoined-tibkey-alist . s-state)
439 (tibetan-vowel-tibkey-alist . m-state))
440 (m-state tibetan-modifier-tibkey-alist))))