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