| 2359 | // Converts a key string sequence of the form a<C-w>bd<Left> into Vim's |
| 2360 | // keymap representation. |
| 2361 | function parseKeyString(str) { |
| 2362 | var idx = 0; |
| 2363 | var keys = []; |
| 2364 | while (idx < str.length) { |
| 2365 | if (str.charAt(idx) != '<') { |
| 2366 | keys.push(str.charAt(idx)); |
| 2367 | idx++; |
| 2368 | continue; |
| 2369 | } |
| 2370 | // Vim key notation here means desktop Vim key-notation. |
| 2371 | // See :help key-notation in desktop Vim. |
| 2372 | var vimKeyNotationStart = ++idx; |
| 2373 | while (str.charAt(idx++) != '>') {} |
| 2374 | var vimKeyNotation = str.substring(vimKeyNotationStart, idx - 1); |
| 2375 | var mod=''; |
| 2376 | var match = (/^C-(.+)$/).exec(vimKeyNotation); |
| 2377 | if (match) { |
| 2378 | mod='Ctrl-'; |
| 2379 | vimKeyNotation=match[1]; |
| 2380 | } |
| 2381 | var key; |
| 2382 | switch (vimKeyNotation) { |
| 2383 | case 'BS': |
| 2384 | key = 'Backspace'; |
| 2385 | break; |
| 2386 | case 'CR': |
| 2387 | key = 'Enter'; |
| 2388 | break; |
| 2389 | case 'Del': |
| 2390 | key = 'Delete'; |
| 2391 | break; |
| 2392 | default: |
| 2393 | key = vimKeyNotation; |
| 2394 | break; |
| 2395 | } |
| 2396 | keys.push(mod + key); |
| 2397 | } |
| 2398 | return keys; |
| 2399 | } |
| 2400 | |
| 2401 | var exCommands = { |
| 2402 | map: function(cm, params) { |