Yang Cheng | 6d1d600 | 2019-02-27 11:16:24 +0800 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | var EscapeSequences = require('xterm/lib/common/data/EscapeSequences'); |
| 4 | |
| 5 | var BACKSPACE = 8; |
| 6 | var PAGE_UP = 33; |
| 7 | var PAGE_DOWN = 34; |
| 8 | var END = 35; |
| 9 | var HOME = 36; |
| 10 | var INSERT = 45; |
| 11 | var DEL = 46; |
| 12 | var F1 = 112; |
| 13 | var F2 = 113; |
| 14 | var F3 = 114; |
| 15 | var F4 = 115; |
| 16 | var F5 = 116; |
| 17 | var F6 = 117; |
| 18 | var F7 = 118; |
| 19 | var F8 = 119; |
| 20 | var F9 = 120; |
| 21 | var F10 = 121; |
| 22 | var F11 = 122; |
| 23 | var F12 = 123; |
| 24 | |
| 25 | /* |
| 26 | VT100+ Character and Key Extensions |
| 27 | |
| 28 | Character or key | Character sequence |
| 29 | --------------------------------------- |
| 30 | HOME key | <ESC>h |
| 31 | END key | <ESC>k |
| 32 | INSERT key | <ESC>+ |
| 33 | DELETE key | <ESC>- |
| 34 | PAGE UP key | <ESC>? |
| 35 | PAGE DOWN key | <ESC>/ |
| 36 | F1 key | <ESC>1 |
| 37 | F2 key | <ESC>2 |
| 38 | F3 key | <ESC>3 |
| 39 | F4 key | <ESC>4 |
| 40 | F5 key | <ESC>5 |
| 41 | F6 key | <ESC>6 |
| 42 | F7 key | <ESC>7 |
| 43 | F8 key | <ESC>8 |
| 44 | F9 key | <ESC>9 |
| 45 | F10 key | <ESC>0 |
| 46 | F11 key | <ESC>! |
| 47 | F12 key | <ESC>@ |
| 48 | |
| 49 | */ |
| 50 | |
| 51 | function customVT100PlusKey(ev, term) { |
| 52 | var modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | |
| 53 | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0); |
| 54 | if (((modifiers) && (ev.keyCode != BACKSPACE)) || (ev.type != 'keydown')) { |
| 55 | return true; |
| 56 | } |
| 57 | switch (ev.keyCode) { |
| 58 | case BACKSPACE: |
| 59 | if (ev.altKey) { |
| 60 | return true; |
| 61 | } else if (!ev.shiftKey) { |
| 62 | term.handler(EscapeSequences.C0.BS); // Backspace |
| 63 | } else { |
| 64 | term.handler(EscapeSequences.C0.DEL); // Delete |
| 65 | } |
| 66 | break; |
| 67 | case PAGE_UP: |
| 68 | term.handler(EscapeSequences.C0.ESC + '?'); |
| 69 | break; |
| 70 | case PAGE_DOWN: |
| 71 | term.handler(EscapeSequences.C0.ESC + '/'); |
| 72 | break; |
| 73 | case END: |
| 74 | term.handler(EscapeSequences.C0.ESC + 'k'); |
| 75 | break; |
| 76 | case HOME: |
| 77 | term.handler(EscapeSequences.C0.ESC + 'h'); |
| 78 | break; |
| 79 | case INSERT: |
| 80 | term.handler(EscapeSequences.C0.ESC + '+'); |
| 81 | break; |
| 82 | case DEL: |
| 83 | term.handler(EscapeSequences.C0.ESC + '-'); |
| 84 | break; |
| 85 | case F1: |
| 86 | term.handler(EscapeSequences.C0.ESC + '1'); |
| 87 | break; |
| 88 | case F2: |
| 89 | term.handler(EscapeSequences.C0.ESC + '2'); |
| 90 | break; |
| 91 | case F3: |
| 92 | term.handler(EscapeSequences.C0.ESC + '3'); |
| 93 | break; |
| 94 | case F4: |
| 95 | term.handler(EscapeSequences.C0.ESC + '4'); |
| 96 | break; |
| 97 | case F5: |
| 98 | term.handler(EscapeSequences.C0.ESC + '5'); |
| 99 | break; |
| 100 | case F6: |
| 101 | term.handler(EscapeSequences.C0.ESC + '6'); |
| 102 | break; |
| 103 | case F7: |
| 104 | term.handler(EscapeSequences.C0.ESC + '7'); |
| 105 | break; |
| 106 | case F8: |
| 107 | term.handler(EscapeSequences.C0.ESC + '8'); |
| 108 | break; |
| 109 | case F9: |
| 110 | term.handler(EscapeSequences.C0.ESC + '9'); |
| 111 | break; |
| 112 | case F10: |
| 113 | term.handler(EscapeSequences.C0.ESC + '0'); |
| 114 | break; |
| 115 | case F11: |
| 116 | term.handler(EscapeSequences.C0.ESC + '!'); |
| 117 | break; |
| 118 | case F12: |
| 119 | term.handler(EscapeSequences.C0.ESC + '@'); |
| 120 | break; |
| 121 | default: |
| 122 | return true; |
| 123 | } |
| 124 | return false; |
| 125 | } |
| 126 | exports.customVT100PlusKey = customVT100PlusKey; |