acf0f174e85b9421d0fa4a1c4f17e3763952cde8
[m17n/m17n-db.git] / ko-romaja.mim
1 ;; ko-romaja.mim -- Input method for Korean Hangul with Romaja keys.
2 ;; Copyright (C) 2004
3 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
4 ;;   Registration Number H15PRO112
5
6 ;; This file is part of the m17n database; a sub-part of the m17n
7 ;; library.
8
9 ;; The m17n library is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU Lesser General Public License
11 ;; as published by the Free Software Foundation; either version 2.1 of
12 ;; the License, or (at your option) any later version.
13
14 ;; The m17n library is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;; Lesser General Public License for more details.
18
19 ;; You should have received a copy of the GNU Lesser General Public
20 ;; License along with the m17n library; if not, write to the Free
21 ;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 ;; 02111-1307, USA.
23
24 ;;; <li> ko-romaja.mim
25 ;;;
26 ;;; Input method for Korean Hangul using Romaja keys.  The
27 ;;; roman-transliteration rules follows that of IIIMF shown in this
28 ;;; page: http://www3.sympatico.ca/d.moser/hangul.html
29
30 (title "로마자")
31
32 (macro
33  (compose
34   ;; Convert Jamo sequence LVT to a precomposed character.
35   ;; See the Unicode Standard Version 3.0, Section 3.11.
36   (> L 0
37      ((set LIndex L) (sub LIndex 0x1100)
38       (set VIndex V) (sub VIndex 0x1161)
39       (set TIndex T) (sub TIndex 0x11A7)
40       ;; S = (LIndex * VCount + Vindex) * TCount + TIndex + SBase
41       (set S LIndex)
42       (mul S 21) ;; VCount
43       (add S VIndex)
44       (mul S 28) ;; TCount
45       (add S TIndex)
46       (add S 0xAC00) ;; SBase
47       (delete @<)
48       (insert S))))
49
50  ;; If L is not negatice, convert Jame sequence LV to a precomposed
51  ;; character while assuming T is 0x11A7.  If L is 0 (i.e. missing),
52  ;; set L to 0x110B.
53  (compose-vowel
54   (< L 0
55      ()
56      ((= L 0 ((set L 0x110B)))
57       (set T1 T)
58       (set T 0x11A7)
59       (compose)
60       (set T T1)))))
61
62 (map
63  ;; Common keys for CHOSEONG and JONGSEONG.
64  ;; Set L1 to CHOSEONG, T to JONGSEONG, insert a Compatibility Jamo.
65  (X
66   ("g"  (set L1 0x1100) (set T 0x11A8) ?ㄱ (compose))
67   ("gg" (set L1 0x1101) (set T 0x11A9) ?ㄲ (compose))
68   ("G"  (set L1 0x1101) (set T 0x11A9) ?ㄲ (compose))
69   ("n"  (set L1 0x1102) (set T 0x11AB) ?ㄲ (compose))
70   ("d"  (set L1 0x1103) (set T 0x11AE) ?ㄷ (compose))
71   ("m"  (set L1 0x1106) (set T 0x11B7) ?ㅁ (compose))
72   ("b"  (set L1 0x1107) (set T 0x11B8) ?ㅂ (compose))
73   ("s"  (set L1 0x1109) (set T 0x11BA) ?ㅅ (compose))
74   ("ss" (set L1 0x110A) (set T 0x11BB) ?ㅆ (compose))
75   ("j"  (set L1 0x110C) (set T 0x11BD) ?ㅈ (compose))
76   ("z"  (set L1 0x110C) (set T 0x11BD) ?ㅈ (compose))
77   ("ch" (set L1 0x110E) (set T 0x11BE) ?ㅊ (compose))
78   ("k"  (set L1 0x110F) (set T 0x11BF) ?ㅋ (compose))
79   ("t"  (set L1 0x1110) (set T 0x11C0) ?ㅌ (compose))
80   ("p"  (set L1 0x1111) (set T 0x11C1) ?ㅍ (compose))
81   ("h"  (set L1 0x1112) (set T 0x11C2) ?ㅎ (compose)))
82
83  ;; Keys starting X.
84  (X-head
85   ("g") ("G") ("n") ("d") ("m") ("b") ("s") ("j") ("z") ("c")
86   ("k") ("t") ("p") ("h"))
87
88  ;; Keys only for CHOSEONG.
89  ;; Set L to CHOSEONG, insert a Compatibility Jamo.
90  (L
91   ("dd" (set L 0x1104) ?ㄸ)
92   ("D"  (set L 0x1104) ?ㄸ)
93   ("r"  (set L 0x1105) ?ㄹ)
94   ("bb" (set L 0x1108) ?ㅃ)
95   ("B"  (set L 0x1108) ?ㅃ)
96   ("S"  (set L 0x110A) ?ㅆ)
97   ("jj" (set L 0x110D) ?ㅉ)
98   ("J"  (set L 0x110D) ?ㅉ)
99   ("zz" (set L 0x110D) ?ㅉ)
100   ("Z"  (set L 0x110D) ?ㅉ)
101   ("q"  (set L 0x110F) ?ㅋ))
102
103  ;; Keys only for JONGSEONG.
104  ;; Set T to JONGSEONG, insert a Compatibility Jamo.
105  (T
106   ("gs" (set T 0x11AA) ?ㄳ (compose))
107   ("nj" (set T 0x11AC) ?ㄵ (compose))
108   ("nh" (set T 0x11AD) ?ㄶ (compose))
109   ("l"  (set T 0x11AF) ?ㄹ (compose))
110   ("lg" (set T 0x11B0) ?ㄺ (compose))
111   ("lm" (set T 0x11B1) ?ㄻ (compose))
112   ("lb" (set T 0x11B2) ?ㄼ (compose))
113   ("ls" (set T 0x11B3) ?ㄽ (compose))
114   ("lt" (set T 0x11B4) ?ㄾ (compose))
115   ("lp" (set T 0x11B5) ?ㄿ (compose))
116   ("lh" (set T 0x11B6) ?ㅀ (compose))
117   ("bs" (set T 0x11B9) ?ㅄ (compose))
118   ("ng" (set T 0x11BC) ?ㅇ (compose)))
119
120  ;; Keys only for JUNGSEONG.
121  ;; Set V to JUNGSEONG, insert a Compatibility Jamo.
122  (V
123   ("a"   (set V 0x1161) ?ㅏ (compose-vowel))
124   ("ai"  (set V 0x1162) ?ㅐ (compose-vowel))
125   ("ae"  (set V 0x1162) ?ㅐ (compose-vowel))
126   ("ya"  (set V 0x1163) ?ㅑ (compose-vowel))
127   ("yai" (set V 0x1164) ?ㅒ (compose-vowel))
128   ("yae" (set V 0x1164) ?ㅒ (compose-vowel))
129   ("eo"  (set V 0x1165) ?ㅓ (compose-vowel))
130   ("e"   (set V 0x1166) ?ㅔ (compose-vowel))
131   ("eoi" (set V 0x1166) ?ㅔ (compose-vowel))
132   ("yeo" (set V 0x1167) ?ㅕ (compose-vowel))
133   ("ye"  (set V 0x1168) ?ㅖ (compose-vowel))
134   ("yeoi"(set V 0x1168) ?ㅖ (compose-vowel))
135   ("o"   (set V 0x1169) ?ㅗ (compose-vowel))
136   ("oa"  (set V 0x116A) ?ㅘ (compose-vowel))
137   ("wa"  (set V 0x116A) ?ㅘ (compose-vowel))
138   ("oai" (set V 0x116B) ?ㅙ (compose-vowel))
139   ("wae" (set V 0x116B) ?ㅙ (compose-vowel))
140   ("oi"  (set V 0x116C) ?ㅚ (compose-vowel))
141   ("oe"  (set V 0x116C) ?ㅚ (compose-vowel))
142   ("yo"  (set V 0x116D) ?ㅛ (compose-vowel))
143   ("u"   (set V 0x116E) ?ㅜ (compose-vowel))
144   ("ueo" (set V 0x116F) ?ㅝ (compose-vowel))
145   ("wo"  (set V 0x116F) ?ㅝ (compose-vowel))
146   ("ue"  (set V 0x1170) ?ㅞ (compose-vowel))
147   ("we"  (set V 0x1170) ?ㅞ (compose-vowel))
148   ("ui"  (set V 0x1171) ?ㅟ (compose-vowel))
149   ("wi"  (set V 0x1171) ?ㅟ (compose-vowel))
150   ("yu"  (set V 0x1172) ?ㅠ (compose-vowel))
151   ("eu"  (set V 0x1173) ?ㅡ (compose-vowel))
152   ("eui" (set V 0x1174) ?ㅢ (compose-vowel))
153   ("ui"  (set V 0x1174) ?ㅢ (compose-vowel))
154   ("i"   (set V 0x1175) ?ㅣ (compose-vowel)))
155
156  ;; Keys starting V.
157  (V-head
158   ("a") ("y") ("e") ("o") ("w") ("u") ("i"))
159
160  (punctuation
161   ("," ?,)
162   (",," ?、)
163   ("." ?.)
164   (".." ?。)
165   ("?" ??)
166   ("??" ??)
167   ("!" ?!)
168   ("!!" ?!))
169
170  (backspace
171   ((BackSpace) (undo)))
172
173  (tilda
174   ("~"))
175
176  (space
177   ((S-\ ))))
178
179 (state
180  (init
181   (t (set L 0))
182   (X (set L L1) (shift after-L))
183   (L (shift after-L))
184   (V (shift after-LV))
185   (punctuation)
186   (backspace)
187   (space)
188   (tilda (shift single)))
189
190  (after-L
191   (V (shift after-LV))
192   (space (shift init))
193   (backspace))
194  (after-LV
195   (X (shift after-LVX))
196   (T (shift init))
197   (space (shift init))
198   (backspace))
199  (after-LVX
200   (V-head (delete @<) (pushback 0) (shift fix-LV-redo-L))
201   (space (shift init))
202   (backspace)
203   (nil    (delete @<) (pushback 0) (shift fix-LVT-redo-L)))
204
205  (fix-LVT-redo-L
206   (t (set L 0))
207   (X (set L L1) (shift fix-LVT-redo-V))
208   (L (shift fix-LVT-redo-V))
209   (V (shift fix-LVT-redo-T)))
210  (fix-LVT-redo-V
211   (V (shift fix-LVT-redo-T)))
212  (fix-LVT-redo-T
213   (X (shift init)))
214
215  (fix-LV-redo-L
216   (t (set L 0))
217   (X (set L L1) (shift fix-LV-redo-V))
218   (L (shift fix-LV-redo-V))
219   (V (shift init)))
220  (fix-LV-redo-V
221   (V (shift init)))
222
223  (single
224   (t (set L -1))
225   (X (shift init))
226   (L (shift init))
227   (T (shift init))
228   (V (shift init))))
229
230 ;; Local Variables:
231 ;; coding: utf-8
232 ;; mode: lisp
233 ;; End: