*** empty log message ***
[m17n/m17n-db.git] / MIM / ko-romaja.mim
1 ;; ko-romaja.mim -- Input method for Korean Hangul with Romaja keys.
2 ;; Copyright (C) 2004, 2005
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., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23
24 (input-method ko romaja)
25
26 (description
27  "Hangul input method with romaja keys.
28 The roman-transliteration rules follows that of Hangule LE in IIIMF.
29
30 Common to CHOSEONG and JONGSEONG:
31   ㄱ(g) ㄲ(gg,kk,qq,c) ㄴ(n) ㄷ(d) ㄹ(l) ㄹ(r) ㅁ(m) ㅂ(b,v) ㅅ(s)
32   ㅆ(ss) ㅇ(ng) ㅇ(x) ㅈ(j) ㅊ(ch) ㅋ(k,q) ㅌ(t) ㅍ(p,f) ㅎ(h)
33
34 CHOSEONG:
35   ㄸ(dd,tt) ㅃ(bb,vv) ㅉ(jj)
36
37 JONGSEONG:
38   ㄳ(gs) ㄵ(nj) ㄶ(nh) ㄺ(lg) ㄻ(lm) ㄼ(lb) ㄽ(ls) ㄾ(lt) ㄿ(lp) ㅀ(lh) ㅄ(bs)
39
40 JUNGSEONG:
41   ㅏ(a) ㅐ(ai,ae) ㅑ (ya,ia) ㅒ(yai,yae,iae) ㅓ(eo) ㅔ(e,eoi) ㅕ(yeo,ieo)
42   ㅖ(ye,ie,yeoi) ㅗ(o) ㅘ(oa,wa,ua) ㅙ(oai,wae,uae,oae) ㅚ(oi,woe,uoe,oe)
43   ㅛ(yo,io) ㅜ(u,w,oo) ㅝ(ueo,wo,uo) ㅞ(ue,we) ㅟ(wi) ㅠ(yu,iu) ㅡ(eu)
44   ㅢ(eui,ui) ㅣ(i,y,ee)
45
46 Special:
47   Type uppercase letter to specify CHOSEONG explicitly.
48   Type \"I\" to toggle the composed-syllable mode and isolated-jamo mode.
49   Type \">>\" to fullwidth ASCII letter mode, \"<<\" to shift out the mode.
50   Type \"Z\" and a key to input fullwidth version of the key.
51 ")
52
53 (title "로마자")
54
55 (macro
56  (compose
57   ;; Convert Jamo sequence LVT to a precomposed character.
58   ;; See the Unicode Standard Version 3.0, Section 3.11.
59   (> L 0
60      ((set LIndex L) (sub LIndex 0x1100)
61       (set VIndex V) (sub VIndex 0x1161)
62       (set TIndex T) (sub TIndex 0x11A7)
63       ;; S = (LIndex * VCount + Vindex) * TCount + TIndex + SBase
64       (set S LIndex)
65       (mul S 21) ;; VCount
66       (add S VIndex)
67       (mul S 28) ;; TCount
68       (add S TIndex)
69       (add S 0xAC00) ;; SBase
70       (delete @<)
71       (insert S))))
72
73  ;; If L is not negative, convert Jame sequence LV to a precomposed
74  ;; character while assuming T is 0x11A7.  If L is 0 (i.e. missing),
75  ;; set L to 0x110B.
76  (compose-vowel
77   (< L 0
78      ()
79      ((= L 0 ((set L 0x110B)))
80       (set T1 T)
81       (set T 0x11A7)
82       (compose)
83       (set T T1)))))
84
85 (map
86  ;; This map is used only in init state, which means typing these
87  ;; uppercase letters in any other states causes shifting to init
88  ;; state, and they are re-handled in init state.
89  (uppercase
90   ("B" (pushback "b")) ("C" (pushback "c")) ("D" (pushback "d"))
91   ("F" (pushback "f")) ("G" (pushback "g")) ("H" (pushback "h"))
92   ("J" (pushback "j")) ("K" (pushback "k")) ("L" (pushback "l"))
93   ("M" (pushback "m")) ("N" (pushback "n")) ("P" (pushback "p"))
94   ("Q" (pushback "q")) ("R" (pushback "r")) ("S" (pushback "s"))
95   ("T" (pushback "t")) ("V" (pushback "v")) ("X" (pushback "x")))
96
97  ;; Keys common to CHOSEONG and JONGSEONG.  Set L1 to CHOSEONG, T to
98  ;; JONGSEONG, insert a Compatibility Jamo.  When this map is used in
99  ;; init state, L is still 0, thus compose macro does nothing.
100  ;; Otherwise, L is already set to a CHOSEONG, thus compose macro
101  ;; composes LVT into a syllable.
102  (X
103   ("g"  (set L1 0x1100) (set T 0x11A8) ?ㄱ (compose))
104   ("gg" (set L1 0x1101) (set T 0x11A9) ?ㄲ (compose))
105   ("kk" (set L1 0x1101) (set T 0x11A9) ?ㄲ (compose))
106   ("qq" (set L1 0x1101) (set T 0x11A9) ?ㄲ (compose))
107   ("c"  (set L1 0x1101) (set T 0x11A9) ?ㄲ (compose))
108   ("n"  (set L1 0x1102) (set T 0x11AB) ?ㄴ (compose))
109   ("d"  (set L1 0x1103) (set T 0x11AE) ?ㄷ (compose))
110   ("l"  (set L1 0x1105) (set T 0x11AF) ?ㄹ (compose))
111   ("r"  (set L1 0x1105) (set T 0x11AF) ?ㄹ (compose))
112   ("m"  (set L1 0x1106) (set T 0x11B7) ?ㅁ (compose))
113   ("b"  (set L1 0x1107) (set T 0x11B8) ?ㅂ (compose))
114   ("v"  (set L1 0x1107) (set T 0x11B8) ?ㅂ (compose))
115   ("s"  (set L1 0x1109) (set T 0x11BA) ?ㅅ (compose))
116   ("ss" (set L1 0x110A) (set T 0x11BB) ?ㅆ (compose))
117   ("ng" (set L1 0x110B) (set T 0x11BC) ?ㅇ (compose))
118   ("x"  (set L1 0x110B) (set T 0x11BC) ?ㅇ (compose))
119   ("j"  (set L1 0x110C) (set T 0x11BD) ?ㅈ (compose))
120   ("ch" (set L1 0x110E) (set T 0x11BE) ?ㅊ (compose))
121   ("k"  (set L1 0x110F) (set T 0x11BF) ?ㅋ (compose))
122   ("q"  (set L1 0x110F) (set T 0x11BF) ?ㅋ (compose))
123   ("t"  (set L1 0x1110) (set T 0x11C0) ?ㅌ (compose))
124   ("p"  (set L1 0x1111) (set T 0x11C1) ?ㅍ (compose))
125   ("f"  (set L1 0x1111) (set T 0x11C1) ?ㅍ (compose))
126   ("h"  (set L1 0x1112) (set T 0x11C2) ?ㅎ (compose)))
127
128  ;; Keys only for CHOSEONG.
129  ;; Set L to CHOSEONG, insert a Compatibility Jamo.
130  (L
131   ("dd" (set L 0x1104) ?ㄸ)
132   ("tt" (set L 0x1104) ?ㄸ)
133   ("bb" (set L 0x1108) ?ㅃ)
134   ("vv" (set L 0x1108) ?ㅃ)
135   ("jj" (set L 0x110D) ?ㅉ))
136
137  ;; Keys only for JONGSEONG.
138  ;; Set T to JONGSEONG, insert a Compatibility Jamo.
139  (T
140   ("gs" (set T 0x11AA) ?ㄳ (compose))
141   ("nj" (set T 0x11AC) ?ㄵ (compose))
142   ("nh" (set T 0x11AD) ?ㄶ (compose))
143   ("lg" (set T 0x11B0) ?ㄺ (compose))
144   ("lm" (set T 0x11B1) ?ㄻ (compose))
145   ("lb" (set T 0x11B2) ?ㄼ (compose))
146   ("ls" (set T 0x11B3) ?ㄽ (compose))
147   ("lt" (set T 0x11B4) ?ㄾ (compose))
148   ("lp" (set T 0x11B5) ?ㄿ (compose))
149   ("lh" (set T 0x11B6) ?ㅀ (compose))
150   ("bs" (set T 0x11B9) ?ㅄ (compose)))
151
152  ;; Keys only for JUNGSEONG.
153  ;; Set V to JUNGSEONG, insert a Compatibility Jamo.
154  (V
155   ("a"   (set V 0x1161) ?ㅏ (compose-vowel))
156   ("ai"  (set V 0x1162) ?ㅐ (compose-vowel))
157   ("ae"  (set V 0x1162) ?ㅐ (compose-vowel))
158   ("ya"  (set V 0x1163) ?ㅑ (compose-vowel))
159   ("ia"  (set V 0x1163) ?ㅑ (compose-vowel))
160   ("yai" (set V 0x1164) ?ㅒ (compose-vowel))
161   ("yae" (set V 0x1164) ?ㅒ (compose-vowel))
162   ("iae" (set V 0x1164) ?ㅒ (compose-vowel))
163   ("eo"  (set V 0x1165) ?ㅓ (compose-vowel))
164   ("e"   (set V 0x1166) ?ㅔ (compose-vowel))
165   ("eoi" (set V 0x1166) ?ㅔ (compose-vowel))
166   ("yeo" (set V 0x1167) ?ㅕ (compose-vowel))
167   ("ieo" (set V 0x1167) ?ㅕ (compose-vowel))
168   ("ye"  (set V 0x1168) ?ㅖ (compose-vowel))
169   ("ie"  (set V 0x1168) ?ㅖ (compose-vowel))
170   ("yeoi"(set V 0x1168) ?ㅖ (compose-vowel))
171   ("o"   (set V 0x1169) ?ㅗ (compose-vowel))
172   ("oa"  (set V 0x116A) ?ㅘ (compose-vowel))
173   ("wa"  (set V 0x116A) ?ㅘ (compose-vowel))
174   ("ua"  (set V 0x116A) ?ㅘ (compose-vowel))
175   ("oai" (set V 0x116B) ?ㅙ (compose-vowel))
176   ("wae" (set V 0x116B) ?ㅙ (compose-vowel))
177   ("uae" (set V 0x116B) ?ㅙ (compose-vowel))
178   ("oae" (set V 0x116B) ?ㅙ (compose-vowel))
179   ("oi"  (set V 0x116C) ?ㅚ (compose-vowel))
180   ("woe" (set V 0x116C) ?ㅚ (compose-vowel))
181   ("uoe" (set V 0x116C) ?ㅚ (compose-vowel))
182   ("oe"  (set V 0x116C) ?ㅚ (compose-vowel))
183   ("yo"  (set V 0x116D) ?ㅛ (compose-vowel))
184   ("io"  (set V 0x116D) ?ㅛ (compose-vowel))
185   ("u"   (set V 0x116E) ?ㅜ (compose-vowel))
186   ("w"   (set V 0x116E) ?ㅜ (compose-vowel))
187   ("oo"  (set V 0x116E) ?ㅜ (compose-vowel))
188   ("ueo" (set V 0x116F) ?ㅝ (compose-vowel))
189   ("wo"  (set V 0x116F) ?ㅝ (compose-vowel))
190   ("uo"  (set V 0x116F) ?ㅝ (compose-vowel))
191   ("ue"  (set V 0x1170) ?ㅞ (compose-vowel))
192   ("we"  (set V 0x1170) ?ㅞ (compose-vowel))
193   ("wi"  (set V 0x1171) ?ㅟ (compose-vowel))
194   ("yu"  (set V 0x1172) ?ㅠ (compose-vowel))
195   ("iu"  (set V 0x1172) ?ㅠ (compose-vowel))
196   ("eu"  (set V 0x1173) ?ㅡ (compose-vowel))
197   ("eui" (set V 0x1174) ?ㅢ (compose-vowel))
198   ("ui"  (set V 0x1174) ?ㅢ (compose-vowel))
199   ("i"   (set V 0x1175) ?ㅣ (compose-vowel))
200   ("y"   (set V 0x1175) ?ㅣ (compose-vowel))
201   ("ee"  (set V 0x1175) ?ㅣ (compose-vowel)))
202
203  ;; Keys starting V.
204  (V-head
205   ("a") ("y") ("e") ("o") ("w") ("u") ("i"))
206
207  ;; Input fullwidth punction characters by typing a punction twice.
208  (punctuation
209   ("," ?,)
210   (",," ?、)
211   ("." ?.)
212   (".." ?。)
213   ("?" ??)
214   ("??" ??)
215   ("!" ?!)
216   ("!!" ?!))
217
218  (backspace
219   ((BackSpace) (> @@ 1 ((undo)) ((unhandle)))))
220
221  ;; Toggle normal syllable mode and isolated jamo mode.
222  (toggle-mode
223   ("I" (= ISOLATED 0 ((set ISOLATED 1)) ((set ISOLATED 0)))))
224
225  (commit-preedit
226   (";")
227   ((S-\ ))))
228
229 (include (t nil cjk-util) map)
230
231 (state
232  (init
233   "로마자"
234   ;; This is to suppress compose action.
235   (t (set L 0))
236   ;; Uppercase keys are translated to the corresponding lowercase keys.
237   (uppercase)
238   (X (set L L1) (shift after-L))
239   (L (shift after-L))
240   (V (shift after-LV))
241   (T)
242   (backspace)
243   (punctuation)
244   (enter-fullwidth-mode (shift fullwidth-mode))
245   (enter-single-fullwidth-mode (shift single-fullwidth-mode))
246   (toggle-mode (shift isolated-jamo-mode)))
247
248  (after-L
249   (V (shift after-LV))
250   (commit-preedit (shift init))
251   (backspace))
252  (after-LV
253   (X (shift after-LVX))
254   (T (shift init))
255   (commit-preedit (shift init))
256   (backspace))
257  (after-LVX
258   (V-head (delete @<) (pushback 0) (shift fix-LV-redo-L))
259   (commit-preedit (shift init))
260   (backspace))
261
262  (fix-LV-redo-L
263   (t (set L 0))
264   (X (set L L1) (shift fix-LV-redo-V))
265   (L (shift fix-LV-redo-V))
266   (V (set L 0x110B) (set T 0x11A7) (compose) (shift init)))
267  (fix-LV-redo-V
268   (V (set T 0x11A7) (compose) (shift init)))
269
270  (isolated-jamo-mode
271   "자모"
272   ;; Suppress both compose and compose-vowel action.
273   (t (set L -1))
274   (X (commit))
275   (L (set L -1) (commit))
276   (T (commit))
277   (V (commit))
278   (commit-preedit (commit))
279   (enter-fullwidth-mode (shift fullwidth-mode))
280   (enter-single-fullwidth-mode (shift single-fullwidth-mode))
281   (toggle-mode (shift init))
282   (nil (unhandle))))
283
284 (include (t nil cjk-util) state)
285
286 ;; Local Variables:
287 ;; coding: utf-8
288 ;; mode: lisp
289 ;; End: