23 #include <QStringList>
28 KateViKeyParser::KateViKeyParser()
40 if ( m_instance == NULL ) {
47 void KateViKeyParser::initKeyTables()
49 m_qt2katevi->insert( Qt::Key_Escape,
QString(
"esc" ) );
50 m_qt2katevi->insert( Qt::Key_Tab,
QString(
"tab" ) );
51 m_qt2katevi->insert( Qt::Key_Backtab,
QString(
"backtab" ) );
52 m_qt2katevi->insert( Qt::Key_Backspace,
QString(
"backspace" ) );
53 m_qt2katevi->insert( Qt::Key_Return,
QString(
"return" ) );
54 m_qt2katevi->insert( Qt::Key_Enter,
QString(
"enter" ) );
55 m_qt2katevi->insert( Qt::Key_Insert,
QString(
"insert" ) );
56 m_qt2katevi->insert( Qt::Key_Delete,
QString(
"delete" ) );
57 m_qt2katevi->insert( Qt::Key_Pause,
QString(
"pause" ) );
58 m_qt2katevi->insert( Qt::Key_Print,
QString(
"print" ) );
59 m_qt2katevi->insert( Qt::Key_SysReq,
QString(
"sysreq" ) );
60 m_qt2katevi->insert( Qt::Key_Clear,
QString(
"clear" ) );
61 m_qt2katevi->insert( Qt::Key_Home,
QString(
"home" ) );
62 m_qt2katevi->insert( Qt::Key_End,
QString(
"end" ) );
63 m_qt2katevi->insert( Qt::Key_Left,
QString(
"left" ) );
64 m_qt2katevi->insert( Qt::Key_Up,
QString(
"up" ) );
65 m_qt2katevi->insert( Qt::Key_Right,
QString(
"right" ) );
66 m_qt2katevi->insert( Qt::Key_Down,
QString(
"down" ) );
67 m_qt2katevi->insert( Qt::Key_PageUp,
QString(
"pageup" ) );
68 m_qt2katevi->insert( Qt::Key_PageDown,
QString(
"pagedown" ) );
69 m_qt2katevi->insert( Qt::Key_Shift,
QString(
"shift" ) );
70 m_qt2katevi->insert( Qt::Key_Control,
QString(
"control" ) );
71 m_qt2katevi->insert( Qt::Key_Meta,
QString(
"meta" ) );
72 m_qt2katevi->insert( Qt::Key_Alt,
QString(
"alt" ) );
73 m_qt2katevi->insert( Qt::Key_AltGr,
QString(
"altgr" ) );
74 m_qt2katevi->insert( Qt::Key_CapsLock,
QString(
"capslock" ) );
75 m_qt2katevi->insert( Qt::Key_NumLock,
QString(
"numlock" ) );
76 m_qt2katevi->insert( Qt::Key_ScrollLock,
QString(
"scrolllock" ) );
77 m_qt2katevi->insert( Qt::Key_F1,
QString(
"f1" ) );
78 m_qt2katevi->insert( Qt::Key_F2,
QString(
"f2" ) );
79 m_qt2katevi->insert( Qt::Key_F3,
QString(
"f3" ) );
80 m_qt2katevi->insert( Qt::Key_F4,
QString(
"f4" ) );
81 m_qt2katevi->insert( Qt::Key_F5,
QString(
"f5" ) );
82 m_qt2katevi->insert( Qt::Key_F6,
QString(
"f6" ) );
83 m_qt2katevi->insert( Qt::Key_F7,
QString(
"f7" ) );
84 m_qt2katevi->insert( Qt::Key_F8,
QString(
"f8" ) );
85 m_qt2katevi->insert( Qt::Key_F9,
QString(
"f9" ) );
86 m_qt2katevi->insert( Qt::Key_F10,
QString(
"f10" ) );
87 m_qt2katevi->insert( Qt::Key_F11,
QString(
"f11" ) );
88 m_qt2katevi->insert( Qt::Key_F12,
QString(
"f12" ) );
89 m_qt2katevi->insert( Qt::Key_F13,
QString(
"f13" ) );
90 m_qt2katevi->insert( Qt::Key_F14,
QString(
"f14" ) );
91 m_qt2katevi->insert( Qt::Key_F15,
QString(
"f15" ) );
92 m_qt2katevi->insert( Qt::Key_F16,
QString(
"f16" ) );
93 m_qt2katevi->insert( Qt::Key_F17,
QString(
"f17" ) );
94 m_qt2katevi->insert( Qt::Key_F18,
QString(
"f18" ) );
95 m_qt2katevi->insert( Qt::Key_F19,
QString(
"f19" ) );
96 m_qt2katevi->insert( Qt::Key_F20,
QString(
"f20" ) );
97 m_qt2katevi->insert( Qt::Key_F21,
QString(
"f21" ) );
98 m_qt2katevi->insert( Qt::Key_F22,
QString(
"f22" ) );
99 m_qt2katevi->insert( Qt::Key_F23,
QString(
"f23" ) );
100 m_qt2katevi->insert( Qt::Key_F24,
QString(
"f24" ) );
101 m_qt2katevi->insert( Qt::Key_F25,
QString(
"f25" ) );
102 m_qt2katevi->insert( Qt::Key_F26,
QString(
"f26" ) );
103 m_qt2katevi->insert( Qt::Key_F27,
QString(
"f27" ) );
104 m_qt2katevi->insert( Qt::Key_F28,
QString(
"f28" ) );
105 m_qt2katevi->insert( Qt::Key_F29,
QString(
"f29" ) );
106 m_qt2katevi->insert( Qt::Key_F30,
QString(
"f30" ) );
107 m_qt2katevi->insert( Qt::Key_F31,
QString(
"f31" ) );
108 m_qt2katevi->insert( Qt::Key_F32,
QString(
"f32" ) );
109 m_qt2katevi->insert( Qt::Key_F33,
QString(
"f33" ) );
110 m_qt2katevi->insert( Qt::Key_F34,
QString(
"f34" ) );
111 m_qt2katevi->insert( Qt::Key_F35,
QString(
"f35" ) );
112 m_qt2katevi->insert( Qt::Key_Super_L,
QString(
"super_l" ) );
113 m_qt2katevi->insert( Qt::Key_Super_R,
QString(
"super_r" ) );
114 m_qt2katevi->insert( Qt::Key_Menu,
QString(
"menu" ) );
115 m_qt2katevi->insert( Qt::Key_Hyper_L,
QString(
"hyper_l" ) );
116 m_qt2katevi->insert( Qt::Key_Hyper_R,
QString(
"hyper_r" ) );
117 m_qt2katevi->insert( Qt::Key_Help,
QString(
"help" ) );
118 m_qt2katevi->insert( Qt::Key_Direction_L,
QString(
"direction_l" ) );
119 m_qt2katevi->insert( Qt::Key_Direction_R,
QString(
"direction_r" ) );
120 m_qt2katevi->insert( Qt::Key_Multi_key,
QString(
"multi_key" ) );
121 m_qt2katevi->insert( Qt::Key_Codeinput,
QString(
"codeinput" ) );
122 m_qt2katevi->insert( Qt::Key_SingleCandidate,
QString(
"singlecandidate" ) );
123 m_qt2katevi->insert( Qt::Key_MultipleCandidate,
QString(
"multiplecandidate" ) );
124 m_qt2katevi->insert( Qt::Key_PreviousCandidate,
QString(
"previouscandidate" ) );
125 m_qt2katevi->insert( Qt::Key_Mode_switch,
QString(
"mode_switch" ) );
126 m_qt2katevi->insert( Qt::Key_Kanji,
QString(
"kanji" ) );
127 m_qt2katevi->insert( Qt::Key_Muhenkan,
QString(
"muhenkan" ) );
128 m_qt2katevi->insert( Qt::Key_Henkan,
QString(
"henkan" ) );
129 m_qt2katevi->insert( Qt::Key_Romaji,
QString(
"romaji" ) );
130 m_qt2katevi->insert( Qt::Key_Hiragana,
QString(
"hiragana" ) );
131 m_qt2katevi->insert( Qt::Key_Katakana,
QString(
"katakana" ) );
132 m_qt2katevi->insert( Qt::Key_Hiragana_Katakana,
QString(
"hiragana_katakana" ) );
133 m_qt2katevi->insert( Qt::Key_Zenkaku,
QString(
"zenkaku" ) );
134 m_qt2katevi->insert( Qt::Key_Hankaku,
QString(
"hankaku" ) );
135 m_qt2katevi->insert( Qt::Key_Zenkaku_Hankaku,
QString(
"zenkaku_hankaku" ) );
136 m_qt2katevi->insert( Qt::Key_Touroku,
QString(
"touroku" ) );
137 m_qt2katevi->insert( Qt::Key_Massyo,
QString(
"massyo" ) );
138 m_qt2katevi->insert( Qt::Key_Kana_Lock,
QString(
"kana_lock" ) );
139 m_qt2katevi->insert( Qt::Key_Kana_Shift,
QString(
"kana_shift" ) );
140 m_qt2katevi->insert( Qt::Key_Eisu_Shift,
QString(
"eisu_shift" ) );
141 m_qt2katevi->insert( Qt::Key_Eisu_toggle,
QString(
"eisu_toggle" ) );
142 m_qt2katevi->insert( Qt::Key_Hangul,
QString(
"hangul" ) );
143 m_qt2katevi->insert( Qt::Key_Hangul_Start,
QString(
"hangul_start" ) );
144 m_qt2katevi->insert( Qt::Key_Hangul_End,
QString(
"hangul_end" ) );
145 m_qt2katevi->insert( Qt::Key_Hangul_Hanja,
QString(
"hangul_hanja" ) );
146 m_qt2katevi->insert( Qt::Key_Hangul_Jamo,
QString(
"hangul_jamo" ) );
147 m_qt2katevi->insert( Qt::Key_Hangul_Romaja,
QString(
"hangul_romaja" ) );
148 m_qt2katevi->insert( Qt::Key_Hangul_Jeonja,
QString(
"hangul_jeonja" ) );
149 m_qt2katevi->insert( Qt::Key_Hangul_Banja,
QString(
"hangul_banja" ) );
150 m_qt2katevi->insert( Qt::Key_Hangul_PreHanja,
QString(
"hangul_prehanja" ) );
151 m_qt2katevi->insert( Qt::Key_Hangul_PostHanja,
QString(
"hangul_posthanja" ) );
152 m_qt2katevi->insert( Qt::Key_Hangul_Special,
QString(
"hangul_special" ) );
153 m_qt2katevi->insert( Qt::Key_Dead_Grave,
QString(
"dead_grave" ) );
154 m_qt2katevi->insert( Qt::Key_Dead_Acute,
QString(
"dead_acute" ) );
155 m_qt2katevi->insert( Qt::Key_Dead_Circumflex,
QString(
"dead_circumflex" ) );
156 m_qt2katevi->insert( Qt::Key_Dead_Tilde,
QString(
"dead_tilde" ) );
157 m_qt2katevi->insert( Qt::Key_Dead_Macron,
QString(
"dead_macron" ) );
158 m_qt2katevi->insert( Qt::Key_Dead_Breve,
QString(
"dead_breve" ) );
159 m_qt2katevi->insert( Qt::Key_Dead_Abovedot,
QString(
"dead_abovedot" ) );
160 m_qt2katevi->insert( Qt::Key_Dead_Diaeresis,
QString(
"dead_diaeresis" ) );
161 m_qt2katevi->insert( Qt::Key_Dead_Abovering,
QString(
"dead_abovering" ) );
162 m_qt2katevi->insert( Qt::Key_Dead_Doubleacute,
QString(
"dead_doubleacute" ) );
163 m_qt2katevi->insert( Qt::Key_Dead_Caron,
QString(
"dead_caron" ) );
164 m_qt2katevi->insert( Qt::Key_Dead_Cedilla,
QString(
"dead_cedilla" ) );
165 m_qt2katevi->insert( Qt::Key_Dead_Ogonek,
QString(
"dead_ogonek" ) );
166 m_qt2katevi->insert( Qt::Key_Dead_Iota,
QString(
"dead_iota" ) );
167 m_qt2katevi->insert( Qt::Key_Dead_Voiced_Sound,
QString(
"dead_voiced_sound" ) );
168 m_qt2katevi->insert( Qt::Key_Dead_Semivoiced_Sound,
QString(
"dead_semivoiced_sound" ) );
169 m_qt2katevi->insert( Qt::Key_Dead_Belowdot,
QString(
"dead_belowdot" ) );
170 m_qt2katevi->insert( Qt::Key_Dead_Hook,
QString(
"dead_hook" ) );
171 m_qt2katevi->insert( Qt::Key_Dead_Horn,
QString(
"dead_horn" ) );
172 m_qt2katevi->insert( Qt::Key_Back,
QString(
"back" ) );
173 m_qt2katevi->insert( Qt::Key_Forward,
QString(
"forward" ) );
174 m_qt2katevi->insert( Qt::Key_Stop,
QString(
"stop" ) );
175 m_qt2katevi->insert( Qt::Key_Refresh,
QString(
"refresh" ) );
176 m_qt2katevi->insert( Qt::Key_VolumeDown,
QString(
"volumedown" ) );
177 m_qt2katevi->insert( Qt::Key_VolumeMute,
QString(
"volumemute" ) );
178 m_qt2katevi->insert( Qt::Key_VolumeUp,
QString(
"volumeup" ) );
179 m_qt2katevi->insert( Qt::Key_BassBoost,
QString(
"bassboost" ) );
180 m_qt2katevi->insert( Qt::Key_BassUp,
QString(
"bassup" ) );
181 m_qt2katevi->insert( Qt::Key_BassDown,
QString(
"bassdown" ) );
182 m_qt2katevi->insert( Qt::Key_TrebleUp,
QString(
"trebleup" ) );
183 m_qt2katevi->insert( Qt::Key_TrebleDown,
QString(
"trebledown" ) );
184 m_qt2katevi->insert( Qt::Key_MediaPlay,
QString(
"mediaplay" ) );
185 m_qt2katevi->insert( Qt::Key_MediaStop,
QString(
"mediastop" ) );
186 m_qt2katevi->insert( Qt::Key_MediaPrevious,
QString(
"mediaprevious" ) );
187 m_qt2katevi->insert( Qt::Key_MediaNext,
QString(
"medianext" ) );
188 m_qt2katevi->insert( Qt::Key_MediaRecord,
QString(
"mediarecord" ) );
189 m_qt2katevi->insert( Qt::Key_HomePage,
QString(
"homepage" ) );
190 m_qt2katevi->insert( Qt::Key_Favorites,
QString(
"favorites" ) );
191 m_qt2katevi->insert( Qt::Key_Search,
QString(
"search" ) );
192 m_qt2katevi->insert( Qt::Key_Standby,
QString(
"standby" ) );
193 m_qt2katevi->insert( Qt::Key_OpenUrl,
QString(
"openurl" ) );
194 m_qt2katevi->insert( Qt::Key_LaunchMail,
QString(
"launchmail" ) );
195 m_qt2katevi->insert( Qt::Key_LaunchMedia,
QString(
"launchmedia" ) );
196 m_qt2katevi->insert( Qt::Key_Launch0,
QString(
"launch0" ) );
197 m_qt2katevi->insert( Qt::Key_Launch1,
QString(
"launch1" ) );
198 m_qt2katevi->insert( Qt::Key_Launch2,
QString(
"launch2" ) );
199 m_qt2katevi->insert( Qt::Key_Launch3,
QString(
"launch3" ) );
200 m_qt2katevi->insert( Qt::Key_Launch4,
QString(
"launch4" ) );
201 m_qt2katevi->insert( Qt::Key_Launch5,
QString(
"launch5" ) );
202 m_qt2katevi->insert( Qt::Key_Launch6,
QString(
"launch6" ) );
203 m_qt2katevi->insert( Qt::Key_Launch7,
QString(
"launch7" ) );
204 m_qt2katevi->insert( Qt::Key_Launch8,
QString(
"launch8" ) );
205 m_qt2katevi->insert( Qt::Key_Launch9,
QString(
"launch9" ) );
206 m_qt2katevi->insert( Qt::Key_LaunchA,
QString(
"launcha" ) );
207 m_qt2katevi->insert( Qt::Key_LaunchB,
QString(
"launchb" ) );
208 m_qt2katevi->insert( Qt::Key_LaunchC,
QString(
"launchc" ) );
209 m_qt2katevi->insert( Qt::Key_LaunchD,
QString(
"launchd" ) );
210 m_qt2katevi->insert( Qt::Key_LaunchE,
QString(
"launche" ) );
211 m_qt2katevi->insert( Qt::Key_LaunchF,
QString(
"launchf" ) );
212 m_qt2katevi->insert( Qt::Key_MediaLast,
QString(
"medialast" ) );
213 m_qt2katevi->insert( Qt::Key_unknown,
QString(
"unknown" ) );
214 m_qt2katevi->insert( Qt::Key_Call,
QString(
"call" ) );
215 m_qt2katevi->insert( Qt::Key_Context1,
QString(
"context1" ) );
216 m_qt2katevi->insert( Qt::Key_Context2,
QString(
"context2" ) );
217 m_qt2katevi->insert( Qt::Key_Context3,
QString(
"context3" ) );
218 m_qt2katevi->insert( Qt::Key_Context4,
QString(
"context4" ) );
219 m_qt2katevi->insert( Qt::Key_Flip,
QString(
"flip" ) );
220 m_qt2katevi->insert( Qt::Key_Hangup,
QString(
"hangup" ) );
221 m_qt2katevi->insert( Qt::Key_No,
QString(
"no" ) );
222 m_qt2katevi->insert( Qt::Key_Select,
QString(
"select" ) );
223 m_qt2katevi->insert( Qt::Key_Yes,
QString(
"yes" ) );
224 m_qt2katevi->insert( Qt::Key_Execute,
QString(
"execute" ) );
225 m_qt2katevi->insert( Qt::Key_Printer,
QString(
"printer" ) );
226 m_qt2katevi->insert( Qt::Key_Play,
QString(
"play" ) );
227 m_qt2katevi->insert( Qt::Key_Sleep,
QString(
"sleep" ) );
228 m_qt2katevi->insert( Qt::Key_Zoom,
QString(
"zoom" ) );
229 m_qt2katevi->insert( Qt::Key_Cancel,
QString(
"cancel" ) );
232 i != m_qt2katevi->constEnd(); ++i) {
233 m_katevi2qt->insert( i.value(), i.key() );
236 m_nameToKeyCode->insert(
QString(
"invalid" ), -1 );
237 m_nameToKeyCode->insert(
QString(
"esc" ), 1 );
238 m_nameToKeyCode->insert(
QString(
"tab" ), 2 );
239 m_nameToKeyCode->insert(
QString(
"backtab" ), 3 );
240 m_nameToKeyCode->insert(
QString(
"backspace" ), 4 );
241 m_nameToKeyCode->insert(
QString(
"return" ), 5 );
242 m_nameToKeyCode->insert(
QString(
"enter" ), 6 );
243 m_nameToKeyCode->insert(
QString(
"insert" ), 7 );
244 m_nameToKeyCode->insert(
QString(
"delete" ), 8 );
245 m_nameToKeyCode->insert(
QString(
"pause" ), 9 );
246 m_nameToKeyCode->insert(
QString(
"print" ), 10 );
247 m_nameToKeyCode->insert(
QString(
"sysreq" ), 11 );
248 m_nameToKeyCode->insert(
QString(
"clear" ), 12 );
249 m_nameToKeyCode->insert(
QString(
"home" ), 13 );
250 m_nameToKeyCode->insert(
QString(
"end" ), 14 );
251 m_nameToKeyCode->insert(
QString(
"left" ), 15 );
252 m_nameToKeyCode->insert(
QString(
"up" ), 16 );
253 m_nameToKeyCode->insert(
QString(
"right" ), 17 );
254 m_nameToKeyCode->insert(
QString(
"down" ), 18 );
255 m_nameToKeyCode->insert(
QString(
"pageup" ), 19 );
256 m_nameToKeyCode->insert(
QString(
"pagedown" ), 20 );
257 m_nameToKeyCode->insert(
QString(
"shift" ), 21 );
258 m_nameToKeyCode->insert(
QString(
"control" ), 22 );
259 m_nameToKeyCode->insert(
QString(
"meta" ), 23 );
260 m_nameToKeyCode->insert(
QString(
"alt" ), 24 );
261 m_nameToKeyCode->insert(
QString(
"altgr" ), 25 );
262 m_nameToKeyCode->insert(
QString(
"capslock" ), 26 );
263 m_nameToKeyCode->insert(
QString(
"numlock" ), 27 );
264 m_nameToKeyCode->insert(
QString(
"scrolllock" ), 28 );
265 m_nameToKeyCode->insert(
QString(
"f1" ), 29 );
266 m_nameToKeyCode->insert(
QString(
"f2" ), 30 );
267 m_nameToKeyCode->insert(
QString(
"f3" ), 31 );
268 m_nameToKeyCode->insert(
QString(
"f4" ), 32 );
269 m_nameToKeyCode->insert(
QString(
"f5" ), 33 );
270 m_nameToKeyCode->insert(
QString(
"f6" ), 34 );
271 m_nameToKeyCode->insert(
QString(
"f7" ), 35 );
272 m_nameToKeyCode->insert(
QString(
"f8" ), 36 );
273 m_nameToKeyCode->insert(
QString(
"f9" ), 37 );
274 m_nameToKeyCode->insert(
QString(
"f10" ), 38 );
275 m_nameToKeyCode->insert(
QString(
"f11" ), 39 );
276 m_nameToKeyCode->insert(
QString(
"f12" ), 40 );
277 m_nameToKeyCode->insert(
QString(
"f13" ), 41 );
278 m_nameToKeyCode->insert(
QString(
"f14" ), 42 );
279 m_nameToKeyCode->insert(
QString(
"f15" ), 43 );
280 m_nameToKeyCode->insert(
QString(
"f16" ), 44 );
281 m_nameToKeyCode->insert(
QString(
"f17" ), 45 );
282 m_nameToKeyCode->insert(
QString(
"f18" ), 46 );
283 m_nameToKeyCode->insert(
QString(
"f19" ), 47 );
284 m_nameToKeyCode->insert(
QString(
"f20" ), 48 );
285 m_nameToKeyCode->insert(
QString(
"f21" ), 49 );
286 m_nameToKeyCode->insert(
QString(
"f22" ), 50 );
287 m_nameToKeyCode->insert(
QString(
"f23" ), 51 );
288 m_nameToKeyCode->insert(
QString(
"f24" ), 52 );
289 m_nameToKeyCode->insert(
QString(
"f25" ), 53 );
290 m_nameToKeyCode->insert(
QString(
"f26" ), 54 );
291 m_nameToKeyCode->insert(
QString(
"f27" ), 55 );
292 m_nameToKeyCode->insert(
QString(
"f28" ), 56 );
293 m_nameToKeyCode->insert(
QString(
"f29" ), 57 );
294 m_nameToKeyCode->insert(
QString(
"f30" ), 58 );
295 m_nameToKeyCode->insert(
QString(
"f31" ), 59 );
296 m_nameToKeyCode->insert(
QString(
"f32" ), 60 );
297 m_nameToKeyCode->insert(
QString(
"f33" ), 61 );
298 m_nameToKeyCode->insert(
QString(
"f34" ), 62 );
299 m_nameToKeyCode->insert(
QString(
"f35" ), 63 );
300 m_nameToKeyCode->insert(
QString(
"super_l" ), 64 );
301 m_nameToKeyCode->insert(
QString(
"super_r" ), 65 );
302 m_nameToKeyCode->insert(
QString(
"menu" ), 66 );
303 m_nameToKeyCode->insert(
QString(
"hyper_l" ), 67 );
304 m_nameToKeyCode->insert(
QString(
"hyper_r" ), 68 );
305 m_nameToKeyCode->insert(
QString(
"help" ), 69 );
306 m_nameToKeyCode->insert(
QString(
"direction_l" ), 70 );
307 m_nameToKeyCode->insert(
QString(
"direction_r" ), 71 );
308 m_nameToKeyCode->insert(
QString(
"multi_key" ), 172 );
309 m_nameToKeyCode->insert(
QString(
"codeinput" ), 173 );
310 m_nameToKeyCode->insert(
QString(
"singlecandidate" ), 174 );
311 m_nameToKeyCode->insert(
QString(
"multiplecandidate" ), 175 );
312 m_nameToKeyCode->insert(
QString(
"previouscandidate" ), 176 );
313 m_nameToKeyCode->insert(
QString(
"mode_switch" ), 177 );
314 m_nameToKeyCode->insert(
QString(
"kanji" ), 178 );
315 m_nameToKeyCode->insert(
QString(
"muhenkan" ), 179 );
316 m_nameToKeyCode->insert(
QString(
"henkan" ), 180 );
317 m_nameToKeyCode->insert(
QString(
"romaji" ), 181 );
318 m_nameToKeyCode->insert(
QString(
"hiragana" ), 182 );
319 m_nameToKeyCode->insert(
QString(
"katakana" ), 183 );
320 m_nameToKeyCode->insert(
QString(
"hiragana_katakana" ), 184 );
321 m_nameToKeyCode->insert(
QString(
"zenkaku" ), 185 );
322 m_nameToKeyCode->insert(
QString(
"hankaku" ), 186 );
323 m_nameToKeyCode->insert(
QString(
"zenkaku_hankaku" ), 187 );
324 m_nameToKeyCode->insert(
QString(
"touroku" ), 188 );
325 m_nameToKeyCode->insert(
QString(
"massyo" ), 189 );
326 m_nameToKeyCode->insert(
QString(
"kana_lock" ), 190 );
327 m_nameToKeyCode->insert(
QString(
"kana_shift" ), 191 );
328 m_nameToKeyCode->insert(
QString(
"eisu_shift" ), 192 );
329 m_nameToKeyCode->insert(
QString(
"eisu_toggle" ), 193 );
330 m_nameToKeyCode->insert(
QString(
"hangul" ), 194 );
331 m_nameToKeyCode->insert(
QString(
"hangul_start" ), 195 );
332 m_nameToKeyCode->insert(
QString(
"hangul_end" ), 196 );
333 m_nameToKeyCode->insert(
QString(
"hangul_hanja" ), 197 );
334 m_nameToKeyCode->insert(
QString(
"hangul_jamo" ), 198 );
335 m_nameToKeyCode->insert(
QString(
"hangul_romaja" ), 199 );
336 m_nameToKeyCode->insert(
QString(
"hangul_jeonja" ), 200 );
337 m_nameToKeyCode->insert(
QString(
"hangul_banja" ), 201 );
338 m_nameToKeyCode->insert(
QString(
"hangul_prehanja" ), 202 );
339 m_nameToKeyCode->insert(
QString(
"hangul_posthanja" ), 203 );
340 m_nameToKeyCode->insert(
QString(
"hangul_special" ), 204 );
341 m_nameToKeyCode->insert(
QString(
"dead_grave" ), 205 );
342 m_nameToKeyCode->insert(
QString(
"dead_acute" ), 206 );
343 m_nameToKeyCode->insert(
QString(
"dead_circumflex" ), 207 );
344 m_nameToKeyCode->insert(
QString(
"dead_tilde" ), 208 );
345 m_nameToKeyCode->insert(
QString(
"dead_macron" ), 209 );
346 m_nameToKeyCode->insert(
QString(
"dead_breve" ), 210 );
347 m_nameToKeyCode->insert(
QString(
"dead_abovedot" ), 211 );
348 m_nameToKeyCode->insert(
QString(
"dead_diaeresis" ), 212 );
349 m_nameToKeyCode->insert(
QString(
"dead_abovering" ), 213 );
350 m_nameToKeyCode->insert(
QString(
"dead_doubleacute" ), 214 );
351 m_nameToKeyCode->insert(
QString(
"dead_caron" ), 215 );
352 m_nameToKeyCode->insert(
QString(
"dead_cedilla" ), 216 );
353 m_nameToKeyCode->insert(
QString(
"dead_ogonek" ), 217 );
354 m_nameToKeyCode->insert(
QString(
"dead_iota" ), 218 );
355 m_nameToKeyCode->insert(
QString(
"dead_voiced_sound" ), 219 );
356 m_nameToKeyCode->insert(
QString(
"dead_semivoiced_sound" ), 220 );
357 m_nameToKeyCode->insert(
QString(
"dead_belowdot" ), 221 );
358 m_nameToKeyCode->insert(
QString(
"dead_hook" ), 222 );
359 m_nameToKeyCode->insert(
QString(
"dead_horn" ), 223 );
360 m_nameToKeyCode->insert(
QString(
"back" ), 224 );
361 m_nameToKeyCode->insert(
QString(
"forward" ), 225 );
362 m_nameToKeyCode->insert(
QString(
"stop" ), 226 );
363 m_nameToKeyCode->insert(
QString(
"refresh" ), 227 );
364 m_nameToKeyCode->insert(
QString(
"volumedown" ), 228 );
365 m_nameToKeyCode->insert(
QString(
"volumemute" ), 229 );
366 m_nameToKeyCode->insert(
QString(
"volumeup" ), 230 );
367 m_nameToKeyCode->insert(
QString(
"bassboost" ), 231 );
368 m_nameToKeyCode->insert(
QString(
"bassup" ), 232 );
369 m_nameToKeyCode->insert(
QString(
"bassdown" ), 233 );
370 m_nameToKeyCode->insert(
QString(
"trebleup" ), 234 );
371 m_nameToKeyCode->insert(
QString(
"trebledown" ), 235 );
372 m_nameToKeyCode->insert(
QString(
"mediaplay" ), 236 );
373 m_nameToKeyCode->insert(
QString(
"mediastop" ), 237 );
374 m_nameToKeyCode->insert(
QString(
"mediaprevious" ), 238 );
375 m_nameToKeyCode->insert(
QString(
"medianext" ), 239 );
376 m_nameToKeyCode->insert(
QString(
"mediarecord" ), 240 );
377 m_nameToKeyCode->insert(
QString(
"homepage" ), 241 );
378 m_nameToKeyCode->insert(
QString(
"favorites" ), 242 );
379 m_nameToKeyCode->insert(
QString(
"search" ), 243 );
380 m_nameToKeyCode->insert(
QString(
"standby" ), 244 );
381 m_nameToKeyCode->insert(
QString(
"openurl" ), 245 );
382 m_nameToKeyCode->insert(
QString(
"launchmail" ), 246 );
383 m_nameToKeyCode->insert(
QString(
"launchmedia" ), 247 );
384 m_nameToKeyCode->insert(
QString(
"launch0" ), 248 );
385 m_nameToKeyCode->insert(
QString(
"launch1" ), 249 );
386 m_nameToKeyCode->insert(
QString(
"launch2" ), 250 );
387 m_nameToKeyCode->insert(
QString(
"launch3" ), 251 );
388 m_nameToKeyCode->insert(
QString(
"launch4" ), 252 );
389 m_nameToKeyCode->insert(
QString(
"launch5" ), 253 );
390 m_nameToKeyCode->insert(
QString(
"launch6" ), 254 );
391 m_nameToKeyCode->insert(
QString(
"launch7" ), 255 );
392 m_nameToKeyCode->insert(
QString(
"launch8" ), 256 );
393 m_nameToKeyCode->insert(
QString(
"launch9" ), 257 );
394 m_nameToKeyCode->insert(
QString(
"launcha" ), 258 );
395 m_nameToKeyCode->insert(
QString(
"launchb" ), 259 );
396 m_nameToKeyCode->insert(
QString(
"launchc" ), 260 );
397 m_nameToKeyCode->insert(
QString(
"launchd" ), 261 );
398 m_nameToKeyCode->insert(
QString(
"launche" ), 262 );
399 m_nameToKeyCode->insert(
QString(
"launchf" ), 263 );
400 m_nameToKeyCode->insert(
QString(
"medialast" ), 264 );
401 m_nameToKeyCode->insert(
QString(
"unknown" ), 265 );
402 m_nameToKeyCode->insert(
QString(
"call" ), 266 );
403 m_nameToKeyCode->insert(
QString(
"context1" ), 267 );
404 m_nameToKeyCode->insert(
QString(
"context2" ), 268 );
405 m_nameToKeyCode->insert(
QString(
"context3" ), 269 );
406 m_nameToKeyCode->insert(
QString(
"context4" ), 270 );
407 m_nameToKeyCode->insert(
QString(
"flip" ), 271 );
408 m_nameToKeyCode->insert(
QString(
"hangup" ), 272 );
409 m_nameToKeyCode->insert(
QString(
"no" ), 273 );
410 m_nameToKeyCode->insert(
QString(
"select" ), 274 );
411 m_nameToKeyCode->insert(
QString(
"yes" ), 275 );
412 m_nameToKeyCode->insert(
QString(
"execute" ), 276 );
413 m_nameToKeyCode->insert(
QString(
"printer" ), 277 );
414 m_nameToKeyCode->insert(
QString(
"play" ), 278 );
415 m_nameToKeyCode->insert(
QString(
"sleep" ), 279 );
416 m_nameToKeyCode->insert(
QString(
"zoom" ), 280 );
417 m_nameToKeyCode->insert(
QString(
"cancel" ), 281 );
419 m_nameToKeyCode->insert(
QString(
"a" ), 282 );
420 m_nameToKeyCode->insert(
QString(
"b" ), 283 );
421 m_nameToKeyCode->insert(
QString(
"c" ), 284 );
422 m_nameToKeyCode->insert(
QString(
"d" ), 285 );
423 m_nameToKeyCode->insert(
QString(
"e" ), 286 );
424 m_nameToKeyCode->insert(
QString(
"f" ), 287 );
425 m_nameToKeyCode->insert(
QString(
"g" ), 288 );
426 m_nameToKeyCode->insert(
QString(
"h" ), 289 );
427 m_nameToKeyCode->insert(
QString(
"i" ), 290 );
428 m_nameToKeyCode->insert(
QString(
"j" ), 291 );
429 m_nameToKeyCode->insert(
QString(
"k" ), 292 );
430 m_nameToKeyCode->insert(
QString(
"l" ), 293 );
431 m_nameToKeyCode->insert(
QString(
"m" ), 294 );
432 m_nameToKeyCode->insert(
QString(
"n" ), 295 );
433 m_nameToKeyCode->insert(
QString(
"o" ), 296 );
434 m_nameToKeyCode->insert(
QString(
"p" ), 297 );
435 m_nameToKeyCode->insert(
QString(
"q" ), 298 );
436 m_nameToKeyCode->insert(
QString(
"r" ), 299 );
437 m_nameToKeyCode->insert(
QString(
"s" ), 300 );
438 m_nameToKeyCode->insert(
QString(
"t" ), 301 );
439 m_nameToKeyCode->insert(
QString(
"u" ), 302 );
440 m_nameToKeyCode->insert(
QString(
"v" ), 303 );
441 m_nameToKeyCode->insert(
QString(
"w" ), 304 );
442 m_nameToKeyCode->insert(
QString(
"x" ), 305 );
443 m_nameToKeyCode->insert(
QString(
"y" ), 306 );
444 m_nameToKeyCode->insert(
QString(
"z" ), 307 );
445 m_nameToKeyCode->insert(
QString(
"`" ), 308 );
446 m_nameToKeyCode->insert(
QString(
"!" ), 309 );
447 m_nameToKeyCode->insert(
QString(
"\"" ), 310 );
448 m_nameToKeyCode->insert(
QString(
"$" ), 311 );
449 m_nameToKeyCode->insert(
QString(
"%" ), 312 );
450 m_nameToKeyCode->insert(
QString(
"^" ), 313 );
451 m_nameToKeyCode->insert(
QString(
"&" ), 314 );
452 m_nameToKeyCode->insert(
QString(
"*" ), 315 );
453 m_nameToKeyCode->insert(
QString(
"(" ), 316 );
454 m_nameToKeyCode->insert(
QString(
")" ), 317 );
455 m_nameToKeyCode->insert(
QString(
"-" ), 318 );
456 m_nameToKeyCode->insert(
QString(
"_" ), 319 );
457 m_nameToKeyCode->insert(
QString(
"=" ), 320 );
458 m_nameToKeyCode->insert(
QString(
"+" ), 321 );
459 m_nameToKeyCode->insert(
QString(
"[" ), 322 );
460 m_nameToKeyCode->insert(
QString(
"]" ), 323 );
461 m_nameToKeyCode->insert(
QString(
"{" ), 324 );
462 m_nameToKeyCode->insert(
QString(
"}" ), 325 );
463 m_nameToKeyCode->insert(
QString(
":" ), 326 );
464 m_nameToKeyCode->insert(
QString(
";" ), 327 );
465 m_nameToKeyCode->insert(
QString(
"@" ), 328 );
466 m_nameToKeyCode->insert(
QString(
"'" ), 329 );
467 m_nameToKeyCode->insert(
QString(
"#" ), 330 );
468 m_nameToKeyCode->insert(
QString(
"~" ), 331 );
469 m_nameToKeyCode->insert(
QString(
"\\" ), 332 );
470 m_nameToKeyCode->insert(
QString(
"|" ), 333 );
471 m_nameToKeyCode->insert(
QString(
"," ), 334 );
472 m_nameToKeyCode->insert(
QString(
"." ), 335 );
474 m_nameToKeyCode->insert(
QString(
"/" ), 337 );
475 m_nameToKeyCode->insert(
QString(
"?" ), 338 );
476 m_nameToKeyCode->insert(
QString(
" " ), 339 );
478 m_nameToKeyCode->insert(
QString(
"0"), 340);
479 m_nameToKeyCode->insert(
QString(
"1"), 341);
480 m_nameToKeyCode->insert(
QString(
"2"), 342);
481 m_nameToKeyCode->insert(
QString(
"3"), 343);
482 m_nameToKeyCode->insert(
QString(
"4"), 344);
483 m_nameToKeyCode->insert(
QString(
"5"), 345);
484 m_nameToKeyCode->insert(
QString(
"6"), 346);
485 m_nameToKeyCode->insert(
QString(
"7"), 347);
486 m_nameToKeyCode->insert(
QString(
"8"), 348);
487 m_nameToKeyCode->insert(
QString(
"9"), 349);
491 i != m_nameToKeyCode->constEnd(); ++i) {
492 m_keyCodeToName->insert( i.value(), i.key() );
498 return ( m_qt2katevi->contains( key ) ? m_qt2katevi->value( key ) :
"invalid" );
503 return ( m_katevi2qt->contains( keypress ) ? m_katevi2qt->value( keypress ) : -1 );
510 unsigned int keyCodeTemp = 0;
512 bool insideTag =
false;
514 for (
int i = 0; i < keys.length(); i++ ) {
519 temp.setNum( 0xE000+keyCodeTemp, 16);
520 QChar code(0xE000+keyCodeTemp );
521 encodedSequence.append( code );
528 if ( keys.mid( i ).indexOf(
'-' ) != -1 && keys.mid( i ).indexOf(
'-' ) < keys.mid( i ).indexOf(
'>' ) ) {
533 const QString untilClosing = keys.mid( i, keys.mid( i ).indexOf(
'>' ) ).toLower();
537 while ((nextHypen = untilClosing.indexOf(QChar(
'-'), currentPos)) != -1)
539 tokens << untilClosing.mid(currentPos, nextHypen - currentPos + 1);
540 currentPos = nextHypen + 1;
542 tokens << untilClosing.mid(currentPos);
544 foreach (
const QString& str, tokens ) {
545 if ( str ==
"s-" && ( keyCodeTemp & 0x01 ) != 0x1 )
547 else if ( str ==
"c-" && ( keyCodeTemp & 0x02 ) != 0x2 )
549 else if ( str ==
"a-" && ( keyCodeTemp & 0x04 ) != 0x4 )
551 else if ( str ==
"m-" && ( keyCodeTemp & 0x08 ) != 0x8 )
554 if ( m_nameToKeyCode->contains( str ) || ( str.length() == 1 && str.at( 0 ).isLetterOrNumber() ) ) {
555 if ( m_nameToKeyCode->contains( str ) ) {
556 keyCodeTemp += m_nameToKeyCode->value( str ) * 0x10;
558 keyCodeTemp += str.at( 0 ).unicode() * 0x10;
561 int endOfBlock = keys.indexOf(
'>' );
562 if ( endOfBlock -= -1 ) {
563 endOfBlock = keys.length()-1;
565 encodedSequence.clear();
566 encodedSequence.append( m_nameToKeyCode->value(
"invalid" ) );
573 QString str = keys.mid( i, keys.indexOf(
'>', i )-i ).toLower();
574 if ( keys.indexOf(
'>', i ) != -1 && ( m_nameToKeyCode->contains( str ) || ( str.length() == 1 && str.at( 0 ).isLetterOrNumber() ) ) ) {
575 if ( m_nameToKeyCode->contains( str ) ) {
576 keyCodeTemp += m_nameToKeyCode->value( str ) * 0x10;
578 keyCodeTemp += str.at( 0 ).unicode() * 0x10;
581 int endOfBlock = keys.indexOf(
'>' );
582 if ( endOfBlock -= -1 ) {
583 endOfBlock = keys.length()-1;
585 encodedSequence.clear();
586 keyCodeTemp = m_nameToKeyCode->value(
"invalid" ) * 0x10;
590 i += keys.mid( i, keys.mid( i ).indexOf(
'>' ) ).length()-1;
598 if (rest.indexOf(
'>', 1) != -1 && rest.mid(1, rest.indexOf(
'>', 1) - 1) ==
"space")
600 encodedSequence.append(
" ");
601 i += rest.indexOf(
'>', 1);
604 else if ( rest.indexOf(
'>', 1 ) == -1 || ( rest.indexOf(
'<', 1 ) < rest.indexOf(
'>', 1 ) && rest.indexOf(
'<', 1 ) != -1 ) ) {
605 encodedSequence.append( c );
611 encodedSequence.append( c );
616 return encodedSequence;
623 for (
int i = 0; i < keys.length(); i++ ) {
624 QChar c = keys.at( i );
625 int keycode = c.unicode();
627 if ( ( keycode & 0xE000 ) != 0xE000 ) {
632 if ( ( keycode & 0x1 ) == 0x1 ) {
633 ret.append( QLatin1String(
"s-") );
636 if ( ( keycode & 0x2 ) == 0x2 ) {
637 ret.append( QLatin1String(
"c-") );
640 if ( ( keycode & 0x4 ) == 0x4 ) {
641 ret.append( QLatin1String(
"a-") );
644 if ( ( keycode & 0x8 ) == 0x8 ) {
645 ret.append( QLatin1String(
"m-") );
649 if ( ( keycode & 0xE000 ) == 0xE000 ) {
650 ret.append( m_keyCodeToName->value( ( keycode-0xE000 )/0x10 ) );
652 ret.append( QChar( keycode ) );
663 const int keyCode = keyEvent.key();
664 const QString &text = keyEvent.text();
665 const Qt::KeyboardModifiers mods = keyEvent.modifiers();
670 if ( mods & Qt::GroupSwitchModifier ) {
671 return ( !text.isEmpty() ) ? text.at(0) : QChar();
674 if ( text.isEmpty() || ( text.length() == 1 && text.at(0) < 0x20 ) || keyCode == Qt::Key_Delete
675 || ( mods != Qt::NoModifier && mods != Qt::ShiftModifier && mods != Qt::KeypadModifier) ) {
678 keyPress.append(
'<' );
679 keyPress.append( ( mods & Qt::ShiftModifier ) ?
"s-" :
"" );
680 keyPress.append( ( mods & Qt::ControlModifier ) ?
"c-" :
"" );
681 keyPress.append( ( mods & Qt::AltModifier ) ?
"a-" :
"" );
682 keyPress.append( ( mods & Qt::MetaModifier ) ?
"m-" :
"" );
683 keyPress.append( keyCode <= 0xFF ? QChar( keyCode ) :
qt2vi( keyCode ) );
684 keyPress.append(
'>' );
QString qt2vi(int key) const
const QChar KeyEventToQChar(const QKeyEvent &keyEvent)
const QString decodeKeySequence(const QString &keys) const
const QString encodeKeySequence(const QString &keys) const
for encoding keypresses w/ modifiers into an internal QChar representation and back again to a descri...
static KateViKeyParser * self()
int vi2qt(const QString &keypress) const