annotate leim/quail/hangul.el @ 97573:95b685a816d7

*** empty log message ***
author Michael Albinus <michael.albinus@gmx.de>
date Wed, 20 Aug 2008 20:08:50 +0000
parents 434f2e8f84e9
children 8cc7dbd8078f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
1 ;;; hangul.el --- Korean Hangul input method
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
3 ;; Author: Jihyun Cho <jihyun.jo@gmail.com>
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 ;; Keywords: multilingual, input method, Korean, Hangul
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6 ;; This file is part of GNU Emacs.
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7
94710
4f1fd208c354 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79727
diff changeset
8 ;; GNU Emacs is free software: you can redistribute it and/or modify
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
94710
4f1fd208c354 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79727
diff changeset
10 ;; the Free Software Foundation, either version 3 of the License, or
4f1fd208c354 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79727
diff changeset
11 ;; (at your option) any later version.
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13 ;; GNU Emacs is distributed in the hope that it will be useful,
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
94710
4f1fd208c354 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79727
diff changeset
19 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20
38453
519983161a46 Some fixes to follow lisp coding conventions and typo fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 37396
diff changeset
21 ;;; Commentary:
519983161a46 Some fixes to follow lisp coding conventions and typo fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 37396
diff changeset
22
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
23 ;; This file is to implement the following hangul automata:
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
24 ;; - Hangul 2-Bulsik input method
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
25 ;; - Hangul 3-Bulsik final input method
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
26 ;; - Hangul 3-Bulsik 390 input method
44421
84b09c068bb9 added comment
Jaeyoun Chung <jay@kldp.org>
parents: 42596
diff changeset
27
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 ;;; Code:
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 (require 'quail)
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
31 (require 'cl)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
32 (require 'hanja-util)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
33
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
34 ;; Hangul double Jamo table.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
35 ;; The format is an alist of JAMO-TYPE vs. DOUBLE-JAMO-TABLE.
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
36 ;;
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
37 ;; JAMO-TYPE is a symbol `cho' for Choseong, `jung' for Jungseong, and
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
38 ;; `jong' for Jongseong.
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
39 ;;
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
40 ;; DOUBLE-JAMO-TABLE is an alist of Jamo index vs. the vector of Jamo
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
41 ;; indies that can be combined with the car part.
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
42 ;;
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
43 ;; Jamo index is a relative index in `hangul Compatibility Jamo' area
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
44 ;; of the Unicode (i.e. 1 for U+3131).
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
45
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
46 (defconst hangul-djamo-table
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
47 '((cho . ((1 . [1]) ; Choseong
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
48 (7 . [7])
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
49 (18 . [18])
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
50 (21 . [21])
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
51 (24 . [24])))
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
52 (jung . ((39 . [31 32 51]) ; Jungseong
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
53 (44 . [35 36 51])
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
54 (49 . [51])))
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
55 (jong . ((1 . [1 21]) ; Jongseong
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
56 (4 . [24 30])
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
57 (9 . [1 17 18 21 28 29 30])
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
58 (18 . [18 21])
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
59 (21 . [21])))))
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
61 ;; Hangul 2-Bulsik keymap.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
62 ;; It converts an ASCII code A-Z, a-z, to the corresponding hangul
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
63 ;; Jamo index.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
64
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
65 (defconst hangul2-keymap
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
66 [17 48 26 23 7 9 30 39 33 35 31 51 49 44 32 36 18 1 4 21 37 29 24 28 43 27])
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
68 ;; Hangul 3-Bulsik final keymap. 3-Bulsik use full keyboard layout.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
69 ;; Therefore, we must map all printable ASCII codes (`!' to `~')
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
70 ;; to Hangul 3-Bulsik codes.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
71 ;; Other parts are the same as `hangul2-keymap'.
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
72 (defconst hangul3-keymap
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
73 [2 183 24 15 14 8220 120 39 126 8221 43 44 41 46 74 119 30 22 18 78 83
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
74 68 73 85 79 52 110 44 62 46 33 10 7 63 27 12 5 11 69 48 55 49 50 51
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
75 34 45 56 57 29 16 6 13 54 3 28 20 53 26 40 58 60 61 59 42 23 79 71
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
76 86 72 66 84 96 109 115 93 116 122 113 118 121 21 67 4 70 99 74 9 1
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
77 101 17 37 92 47 8251])
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
79 ;; Hangul 3-Bulsik 390 keymap.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
80 ;; The role is the same as `hangul3-keymap'.
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
81 (defconst hangul390-keymap
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
82 [24 34 35 36 37 38 120 40 41 42 43 44 45 46 73 119 30 22 18 77 82 67 72
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
83 84 78 58 110 50 61 51 63 64 7 33 11 10 27 2 47 39 56 52 53 54 49 48
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
84 57 62 29 68 6 59 55 16 28 20 60 26 91 92 93 94 95 96 23 78 70 85 71
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
85 65 83 90 109 115 87 116 122 113 118 121 21 66 4 69 99 73 9 1 101 17
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
86 123 124 125 126])
18673
751941736224 Initial revision
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
88 (defvar hangul-im-keymap
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
89 (let ((map (make-sparse-keymap)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
90 (define-key map "\d" 'hangul-delete-backward-char)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
91 (define-key map [f9] 'hangul-to-hanja-conversion)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
92 map)
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
93 "Keymap for Hangul method. It is used by all Hangul input method.")
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
94
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
95 ;; Current input character buffer. Store separated hangul character.
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
96 ;; The first and second are Choseong position.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
97 ;; The third and forth are Jungseong position.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
98 ;; The fifth and sixth are Jongseong position.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
99 ;; The second, forth and sixth are double Jamo position.
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
100 (defvar hangul-queue
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
101 (make-vector 6 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
102
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
103 (defsubst notzerop (number)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
104 (not (zerop number)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
105
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
106 (defsubst alphabetp (char)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
107 (or (and (>= char ?A) (<= char ?Z))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
108 (and (>= char ?a) (<= char ?z))))
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44421
diff changeset
109
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
110 (defun hangul-character (cho jung jong)
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
111 "Convert CHO, JUNG, JONG to the precomposed `Hangul Syllables' character.
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
112 CHO, JUNG, JONG are relative indices in `Hangul Compatibility Jamo' of unicode.
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
113 Return a zero-length string if the conversion fails."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
114 (or
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
115 (decode-char
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
116 'ucs
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
117 (if (and (/= cho 0) (/= jung 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
118 (+ #xac00
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
119 (* 588
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
120 (- cho
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
121 (cond ((< cho 3) 1)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
122 ((< cho 5) 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
123 ((< cho 10) 4)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
124 ((< cho 20) 11)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
125 (t 12))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
126 (* 28 (- jung 31))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
127 (- jong
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
128 (cond ((< jong 8) 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
129 ((< jong 19) 1)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
130 ((< jong 25) 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
131 (t 3))))
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
132 (+ #x3130
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
133 (cond ((/= cho 0) cho)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
134 ((/= jung 0) jung)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
135 ((/= jong 0) jong)))))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
136 ""))
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44421
diff changeset
137
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
138 (defun hangul-insert-character (&rest queues)
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
139 "Insert characters generated from QUEUEs.
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
140 Each QUEUE has the same form as `hangul-queue'.
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
141 Setup `quail-overlay' to the last character."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
142 (if (and mark-active transient-mark-mode)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
143 (progn
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
144 (delete-region (region-beginning) (region-end))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
145 (deactivate-mark)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
146 (quail-delete-region)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
147 (let ((first (car queues)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
148 (insert
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
149 (hangul-character
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
150 (+ (aref first 0) (hangul-djamo 'cho (aref first 0) (aref first 1)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
151 (+ (aref first 2) (hangul-djamo 'jung (aref first 2) (aref first 3)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
152 (+ (aref first 4) (hangul-djamo 'jong (aref first 4) (aref first 5))))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
153 (move-overlay quail-overlay (overlay-start quail-overlay) (point))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
154 (dolist (queue (cdr queues))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
155 (insert
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
156 (hangul-character
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
157 (+ (aref queue 0) (hangul-djamo 'cho (aref queue 0) (aref queue 1)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
158 (+ (aref queue 2) (hangul-djamo 'jung (aref queue 2) (aref queue 3)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
159 (+ (aref queue 4) (hangul-djamo 'jong (aref queue 4) (aref queue 5)))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
160 (move-overlay quail-overlay (1+ (overlay-start quail-overlay)) (point))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
161
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
162 (defun hangul-djamo (jamo char1 char2)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
163 "Return the dobule Jamo index calculated from the arguments.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
164 JAMO is a type of Hangul Jamo; `cho', `jung', or `jong'.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
165 CHAR1 and CAHR2 are Hangul Jamo indices.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
166 Return nil if CHAR1 and CHAR2 can not combined."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
167 (let* ((jamo (cdr (assoc jamo hangul-djamo-table)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
168 (char1 (cdr (assoc char1 jamo))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
169 (if char1
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
170 (let ((i (length char1)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
171 (or (catch 'found
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
172 (while (> i 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
173 (if (= char2 (aref char1 (1- i)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
174 (throw 'found i))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
175 (setf i (1- i))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
176 0))
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
177 0)))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
178
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
179 (defsubst hangul2-input-method-jaum (char)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
180 "Store Hangul Jamo indice CHAR in `hangul-queue'.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
181 It is a Hangul 2-Bulsik Jaum.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
182 This function processes a Hangul 2-Bulsik Jaum.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
183 The Hangul 2-Bulsik is composed of a Jaum and a Moum.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
184 The Jaum can be located in a Choseong position and a Jongseong position.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
185 Unless the function inserts CHAR to `hangul-queue',
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
186 commit current `hangul-queue' and then set a new `hangul-queue',
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
187 and insert CHAR to new `hangul-queue'."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
188 (if (cond ((zerop (aref hangul-queue 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
189 (aset hangul-queue 0 char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
190 ((and (zerop (aref hangul-queue 1))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
191 (zerop (aref hangul-queue 2))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
192 (notzerop (hangul-djamo 'cho (aref hangul-queue 0) char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
193 (aset hangul-queue 1 char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
194 ((and (zerop (aref hangul-queue 4))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
195 (notzerop (aref hangul-queue 2))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
196 (/= char 8)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
197 (/= char 19)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
198 (/= char 25)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
199 (numberp
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
200 (hangul-character
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
201 (+ (aref hangul-queue 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
202 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
203 'cho
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
204 (aref hangul-queue 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
205 (aref hangul-queue 1)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
206 (+ (aref hangul-queue 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
207 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
208 'jung
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
209 (aref hangul-queue 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
210 (aref hangul-queue 3)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
211 char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
212 (aset hangul-queue 4 char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
213 ((and (zerop (aref hangul-queue 5))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
214 (notzerop (hangul-djamo 'jong (aref hangul-queue 4) char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
215 (numberp
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
216 (hangul-character
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
217 (+ (aref hangul-queue 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
218 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
219 'cho
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
220 (aref hangul-queue 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
221 (aref hangul-queue 1)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
222 (+ (aref hangul-queue 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
223 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
224 'jung
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
225 (aref hangul-queue 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
226 (aref hangul-queue 3)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
227 (+ (aref hangul-queue 4)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
228 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
229 'jong
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
230 (aref hangul-queue 4)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
231 char)))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
232 (aset hangul-queue 5 char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
233 (hangul-insert-character hangul-queue)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
234 (hangul-insert-character hangul-queue
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
235 (setq hangul-queue (vector char 0 0 0 0 0)))))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
236
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
237 (defsubst hangul2-input-method-moum (char)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
238 "Store Hangul Jamo indice CHAR in `hangul-queue'.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
239 It is a Hangul 2-Bulsik Moum.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
240 This function process a Hangul 2-Bulsik Moum.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
241 The Moum can be located in a Jungseong position.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
242 Other parts are the same as a `hangul2-input-method-jaum'."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
243 (if (cond ((zerop (aref hangul-queue 2))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
244 (aset hangul-queue 2 char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
245 ((and (zerop (aref hangul-queue 3))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
246 (zerop (aref hangul-queue 4))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
247 (notzerop (hangul-djamo 'jung (aref hangul-queue 2) char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
248 (aset hangul-queue 3 char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
249 (hangul-insert-character hangul-queue)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
250 (let ((next-char (vector 0 0 char 0 0 0)))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
251 (cond ((notzerop (aref hangul-queue 5))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
252 (aset next-char 0 (aref hangul-queue 5))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
253 (aset hangul-queue 5 0))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
254 ((notzerop (aref hangul-queue 4))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
255 (aset next-char 0 (aref hangul-queue 4))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
256 (aset hangul-queue 4 0)))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
257 (hangul-insert-character hangul-queue
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
258 (setq hangul-queue next-char)))))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
259
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
260 (defsubst hangul3-input-method-cho (char)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
261 "Store Hangul Jamo indice CHAR in `hangul-queue'.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
262 It is a Hangul 3-Bulsik Choseong.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
263 This function process a Hangul 3-Bulsik Choseong.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
264 The Hangul 3-Bulsik is composed of a Choseong, a Jungseong and a Jongseong.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
265 The Choseong can be located in a Choseong position.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
266 Other parts are the same as a `hangul2-input-method-jaum'."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
267 (if (cond ((and (zerop (aref hangul-queue 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
268 (zerop (aref hangul-queue 4)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
269 (aset hangul-queue 0 char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
270 ((and (zerop (aref hangul-queue 1))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
271 (zerop (aref hangul-queue 2))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
272 (notzerop (hangul-djamo 'cho (aref hangul-queue 0) char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
273 (aset hangul-queue 1 char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
274 (hangul-insert-character hangul-queue)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
275 (hangul-insert-character hangul-queue
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
276 (setq hangul-queue (vector char 0 0 0 0 0)))))
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44421
diff changeset
277
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
278 (defsubst hangul3-input-method-jung (char)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
279 "Store Hangul Jamo indice CHAR in `hangul-queue'.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
280 It is a Hangul 3-Bulsik Jungseong.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
281 This function process a Hangul 3-Bulsik Jungseong.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
282 The Jungseong can be located in a Jungseong position.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
283 Other parts are the same as a `hangul3-input-method-cho'."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
284 (if (cond ((and (zerop (aref hangul-queue 2))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
285 (zerop (aref hangul-queue 4)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
286 (aset hangul-queue 2 char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
287 ((and (zerop (aref hangul-queue 3))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
288 (notzerop (hangul-djamo 'jung (aref hangul-queue 2) char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
289 (aset hangul-queue 3 char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
290 (hangul-insert-character hangul-queue)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
291 (hangul-insert-character hangul-queue
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
292 (setq hangul-queue (vector 0 0 char 0 0 0)))))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
293
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
294 (defsubst hangul3-input-method-jong (char)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
295 "Store Hangul Jamo indice CHAR in `hangul-queue'.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
296 It is a Hangul 3-Bulsik Jongseong.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
297 This function process a Hangul 3-Bulsik Jongseong.
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
298 The Jongseong can be located in a Jongseong position.
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
299 Other parts are the same as a `hangul3-input-method-cho'."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
300 (if (cond ((and (zerop (aref hangul-queue 4))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
301 (notzerop (aref hangul-queue 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
302 (notzerop (aref hangul-queue 2))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
303 (numberp
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
304 (hangul-character
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
305 (+ (aref hangul-queue 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
306 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
307 'cho
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
308 (aref hangul-queue 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
309 (aref hangul-queue 1)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
310 (+ (aref hangul-queue 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
311 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
312 'jung
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
313 (aref hangul-queue 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
314 (aref hangul-queue 3)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
315 char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
316 (aset hangul-queue 4 char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
317 ((and (zerop (aref hangul-queue 5))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
318 (notzerop (hangul-djamo 'jong (aref hangul-queue 4) char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
319 (numberp
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
320 (hangul-character
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
321 (+ (aref hangul-queue 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
322 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
323 'cho
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
324 (aref hangul-queue 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
325 (aref hangul-queue 1)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
326 (+ (aref hangul-queue 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
327 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
328 'jung
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
329 (aref hangul-queue 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
330 (aref hangul-queue 3)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
331 (+ (aref hangul-queue 4)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
332 (hangul-djamo
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
333 'jong
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
334 (aref hangul-queue 4)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
335 char)))))
97416
434f2e8f84e9 (hangul3-input-method-jong): Fix array indexing bug.
Kenichi Handa <handa@m17n.org>
parents: 95637
diff changeset
336 (aset hangul-queue 5 char)))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
337 (hangul-insert-character hangul-queue)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
338 (if (zerop (apply '+ (append hangul-queue nil)))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
339 (hangul-insert-character (setq hangul-queue (vector 0 0 0 0 char 0)))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
340 (hangul-insert-character hangul-queue
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
341 (setq hangul-queue (vector 0 0 0 0 char 0))))))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
342
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
343 (defun hangul-delete-backward-char ()
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
344 "Delete the previous hangul character by Jaso units."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
345 (interactive)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
346 (let ((i 5))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
347 (while (and (> i 0) (zerop (aref hangul-queue i)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
348 (setq i (1- i)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
349 (aset hangul-queue i 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
350 (if (notzerop (apply '+ (append hangul-queue nil)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
351 (hangul-insert-character hangul-queue)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
352 (delete-backward-char 1)))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
353
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
354 (defun hangul-to-hanja-conversion ()
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
355 "Convert the previous hangul character to the corresponding hanja character."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
356 (interactive)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
357 (let ((echo-keystrokes 0)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
358 delete-func
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
359 hanja-character)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
360 (setq hanja-character (hangul-to-hanja-char (preceding-char)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
361 (when hanja-character
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
362 (delete-backward-char 1)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
363 (insert hanja-character)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
364 (setq hangul-queue (make-vector 6 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
365 (move-overlay quail-overlay (point) (point)))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
366
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
367 ;; Support function for `hangul2-input-method'. Actually, this
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
368 ;; function handles the Hangul 2-Bulsik. KEY is an entered key code
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
369 ;; used for looking up `hangul2-keymap'."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
370 (defun hangul2-input-method-internal (key)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
371 (let ((char (+ (aref hangul2-keymap (1- (% key 32)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
372 (cond ((or (= key ?O) (= key ?P)) 2)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
373 ((or (= key ?E) (= key ?Q) (= key ?R)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
374 (= key ?T) (= key ?W)) 1)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
375 (t 0)))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
376 (if (< char 31)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
377 (hangul2-input-method-jaum char)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
378 (hangul2-input-method-moum char))))
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44421
diff changeset
379
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
380 (defun hangul2-input-method (key)
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
381 "2-Bulsik input method."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
382 (if (or buffer-read-only (not (alphabetp key)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
383 (list key)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
384 (quail-setup-overlays nil)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
385 (let ((input-method-function nil)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
386 (echo-keystrokes 0)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
387 (help-char nil))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
388 (setq hangul-queue (make-vector 6 0))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
389 (hangul2-input-method-internal key)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
390 (unwind-protect
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
391 (catch 'exit-input-loop
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
392 (while t
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
393 (let* ((seq (read-key-sequence nil))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
394 (cmd (lookup-key hangul-im-keymap seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
395 key)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
396 (cond ((and (stringp seq)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
397 (= 1 (length seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
398 (setq key (aref seq 0))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
399 (alphabetp key))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
400 (hangul2-input-method-internal key))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
401 ((commandp cmd)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
402 (call-interactively cmd))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
403 (t
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
404 (setq unread-command-events (listify-key-sequence seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
405 (throw 'exit-input-loop nil))))))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
406 (quail-delete-overlays)))))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
407
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
408 ;; Support function for `hangul3-input-method'. Actually, this
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
409 ;; function handles the Hangul 3-Bulsik final. KEY is an entered key
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
410 ;; code used for looking up `hangul3-keymap'."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
411 (defun hangul3-input-method-internal (key)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
412 (let ((char (aref hangul3-keymap (- key 33))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
413 (cond ((and (> char 92) (< char 123))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
414 (hangul3-input-method-cho (- char 92)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
415 ((and (> char 65) (< char 87))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
416 (hangul3-input-method-jung (- char 35)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
417 ((< char 31)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
418 (hangul3-input-method-jong char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
419 (t
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
420 (setq hangul-queue (make-vector 6 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
421 (insert (decode-char 'ucs char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
422 (move-overlay quail-overlay (point) (point))))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
423
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
424 (defun hangul3-input-method (key)
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
425 "3-Bulsik final input method."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
426 (if (or buffer-read-only (< key 33) (>= key 127))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
427 (list key)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
428 (quail-setup-overlays nil)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
429 (let ((input-method-function nil)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
430 (echo-keystrokes 0)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
431 (help-char nil))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
432 (setq hangul-queue (make-vector 6 0))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
433 (hangul3-input-method-internal key)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
434 (unwind-protect
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
435 (catch 'exit-input-loop
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
436 (while t
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
437 (let* ((seq (read-key-sequence nil))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
438 (cmd (lookup-key hangul-im-keymap seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
439 key)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
440 (cond ((and (stringp seq)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
441 (= 1 (length seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
442 (setq key (aref seq 0))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
443 (and (>= key 33) (< key 127)))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
444 (hangul3-input-method-internal key))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
445 ((commandp cmd)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
446 (call-interactively cmd))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
447 (t
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
448 (setq unread-command-events (listify-key-sequence seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
449 (throw 'exit-input-loop nil))))))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
450 (quail-delete-overlays)))))
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44421
diff changeset
451
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
452 ;; Support function for `hangul390-input-method'. Actually, this
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
453 ;; function handles the Hangul 3-Bulsik 390. KEY is an entered key
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
454 ;; code used for looking up `hangul390-keymap'."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
455 (defun hangul390-input-method-internal (key)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
456 (let ((char (aref hangul390-keymap (- key 33))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
457 (cond ((or (and (> char 86) (< char 91))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
458 (and (> char 96) (< char 123)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
459 (hangul3-input-method-cho (- char (if (< char 97) 86 92))))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
460 ((and (> char 64) (< char 86))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
461 (hangul3-input-method-jung (- char 34)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
462 ((< char 31)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
463 (hangul3-input-method-jong char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
464 (t
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
465 (setq hangul-queue (make-vector 6 0))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
466 (insert (decode-char 'ucs char))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
467 (move-overlay quail-overlay (point) (point))))))
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44421
diff changeset
468
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
469 (defun hangul390-input-method (key)
95582
4d17533ba12f Docstrings and comments improved.
Kenichi Handa <handa@m17n.org>
parents: 95514
diff changeset
470 "3-Bulsik 390 input method."
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
471 (if (or buffer-read-only (< key 33) (>= key 127))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
472 (list key)
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
473 (quail-setup-overlays nil)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
474 (let ((input-method-function nil)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
475 (echo-keystrokes 0)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
476 (help-char nil))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
477 (setq hangul-queue (make-vector 6 0))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
478 (hangul390-input-method-internal key)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
479 (unwind-protect
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
480 (catch 'exit-input-loop
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
481 (while t
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
482 (let* ((seq (read-key-sequence nil))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
483 (cmd (lookup-key hangul-im-keymap seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
484 key)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
485 (cond ((and (stringp seq)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
486 (= 1 (length seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
487 (setq key (aref seq 0))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
488 (and (>= key 33) (< key 127)))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
489 (hangul390-input-method-internal key))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
490 ((commandp cmd)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
491 (call-interactively cmd))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
492 (t
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
493 (setq unread-command-events (listify-key-sequence seq))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
494 (throw 'exit-input-loop nil))))))
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
495 (quail-delete-overlays)))))
38453
519983161a46 Some fixes to follow lisp coding conventions and typo fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 37396
diff changeset
496
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
497 ;; Text shown by describe-input-method. Set to a proper text by
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
498 ;; hangul-input-method-activate.
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
499 (defvar hangul-input-method-help-text nil)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
500 (make-variable-buffer-local 'hangul-input-method-help-text)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
501
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
502 (defun hangul-input-method-activate (input-method func help-text &rest args)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
503 "Activate Hangul input method INPUT-METHOD.
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
504 FUNC is a function to handle input key.
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
505 HELP-TEXT is a text set in `hangul-input-method-help-text'."
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
506 (setq inactivate-current-input-method-function 'hangul-input-method-inactivate
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
507 describe-current-input-method-function 'hangul-input-method-help
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
508 hangul-input-method-help-text help-text)
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
509 (quail-delete-overlays)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
510 (if (eq (selected-window) (minibuffer-window))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
511 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
512 (set (make-local-variable 'input-method-function) func))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
513
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
514 (defun hangul-input-method-inactivate ()
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
515 "Inactivate the current Hangul input method."
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
516 (interactive)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
517 (unwind-protect
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
518 (progn
95637
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
519 (quail-hide-guidance)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
520 (quail-delete-overlays)
572e23ede3f0 Docstrings improved.
Kenichi Handa <handa@m17n.org>
parents: 95582
diff changeset
521 (setq describe-current-input-method-function nil))
95500
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
522 (kill-local-variable 'input-method-function)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
523
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
524 (defun hangul-input-method-help ()
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
525 "Describe the current Hangul input method."
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
526 (interactive)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
527 (with-output-to-temp-buffer "*Help*"
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
528 (princ hangul-input-method-help-text)))
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
529
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
530 (provide 'hangul)
ad9123bca9ed Completely re-written.
Kenichi Handa <handa@m17n.org>
parents: 94710
diff changeset
531
95514
ad40a2d6712f Add arch tagline
Miles Bader <miles@gnu.org>
parents: 95500
diff changeset
532 ;; arch-tag: 26bc93fc-64ee-4fb1-b26d-22220d132dbe
38453
519983161a46 Some fixes to follow lisp coding conventions and typo fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 37396
diff changeset
533 ;;; hangul.el ends here