diff options
Diffstat (limited to '')
| -rw-r--r-- | handlekeys.c | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/handlekeys.c b/handlekeys.c index 322d41e..030c933 100644 --- a/handlekeys.c +++ b/handlekeys.c | |||
| @@ -18,8 +18,7 @@ struct key | |||
| 18 | char *name; | 18 | char *name; |
| 19 | }; | 19 | }; |
| 20 | 20 | ||
| 21 | // This table includes some variations I have found on some terminals, | 21 | // This table includes some variations I have found on some terminals. |
| 22 | // and the MC "Esc digit" versions. | ||
| 23 | // http://rtfm.etla.org/xterm/ctlseq.html has a useful guide. | 22 | // http://rtfm.etla.org/xterm/ctlseq.html has a useful guide. |
| 24 | // TODO - Don't think I got all the linux console variations. | 23 | // TODO - Don't think I got all the linux console variations. |
| 25 | // TODO - Add more shift variations, plus Ctrl & Alt variations when needed. | 24 | // TODO - Add more shift variations, plus Ctrl & Alt variations when needed. |
| @@ -44,10 +43,10 @@ static struct key keys[] = | |||
| 44 | {"\x07", "^G"}, // BEL | 43 | {"\x07", "^G"}, // BEL |
| 45 | {"\x08", "Del"}, // BS Delete key, usually. | 44 | {"\x08", "Del"}, // BS Delete key, usually. |
| 46 | {"\x09", "Tab"}, // HT | 45 | {"\x09", "Tab"}, // HT |
| 47 | {"\x0A", "Return"}, // LF Roxterm translates Ctrl-M to this. | 46 | {"\x0A", "Enter"}, // LF Roxterm translates Ctrl-M to this. |
| 48 | {"\x0B", "^K"}, // VT | 47 | {"\x0B", "^K"}, // VT |
| 49 | {"\x0C", "^L"}, // FF | 48 | {"\x0C", "^L"}, // FF |
| 50 | {"\x0D", "^M"}, // CR Other Return key, usually. | 49 | {"\x0D", "Return"}, // CR Other Enter/Return key, usually. |
| 51 | {"\x0E", "^N"}, // SO | 50 | {"\x0E", "^N"}, // SO |
| 52 | {"\x0F", "^O"}, // SI DISCARD | 51 | {"\x0F", "^O"}, // SI DISCARD |
| 53 | {"\x10", "^P"}, // DLE | 52 | {"\x10", "^P"}, // DLE |
| @@ -63,7 +62,7 @@ static struct key keys[] = | |||
| 63 | {"\x1A", "^Z"}, // SUB SIGTSTP | 62 | {"\x1A", "^Z"}, // SUB SIGTSTP |
| 64 | // Commented out coz it's the ANSI start byte in the below multibyte keys. | 63 | // Commented out coz it's the ANSI start byte in the below multibyte keys. |
| 65 | // Handled in the code with a timeout. | 64 | // Handled in the code with a timeout. |
| 66 | //{"\x1B", "^["}, // ESC Esc key. | 65 | //{"\x1B", "Esc"}, // ESC Esc key. |
| 67 | {"\x1C", "^\\"}, // FS SIGQUIT | 66 | {"\x1C", "^\\"}, // FS SIGQUIT |
| 68 | {"\x1D", "^]"}, // GS | 67 | {"\x1D", "^]"}, // GS |
| 69 | {"\x1E", "^^"}, // RS | 68 | {"\x1E", "^^"}, // RS |
| @@ -167,25 +166,6 @@ static struct key keys[] = | |||
| 167 | {"\x1BO1;2Q", "Shift F2"}, | 166 | {"\x1BO1;2Q", "Shift F2"}, |
| 168 | {"\x1BO1;2R", "Shift F3"}, | 167 | {"\x1BO1;2R", "Shift F3"}, |
| 169 | {"\x1BO1;2S", "Shift F4"}, | 168 | {"\x1BO1;2S", "Shift F4"}, |
| 170 | |||
| 171 | // MC "Esc digit" specials. | ||
| 172 | // NOTE - The MC Esc variations might not be such a good idea, other programs | ||
| 173 | // want the Esc key for other things. | ||
| 174 | // Notably seems that "Esc somekey" is used in place of "Alt somekey" | ||
| 175 | // AKA "Meta somekey" coz apparently some OSes swallow those. | ||
| 176 | // Conversely, some terminals send "Esc somekey" when you do | ||
| 177 | // "Alt somekey". | ||
| 178 | // MC Esc variants might be used on Macs for other things? | ||
| 179 | {"\x1B\x31", "F1"}, | ||
| 180 | {"\x1B\x32", "F2"}, | ||
| 181 | {"\x1B\x33", "F3"}, | ||
| 182 | {"\x1B\x34", "F4"}, | ||
| 183 | {"\x1B\x35", "F5"}, | ||
| 184 | {"\x1B\x36", "F6"}, | ||
| 185 | {"\x1B\x37", "F7"}, | ||
| 186 | {"\x1B\x38", "F8"}, | ||
| 187 | {"\x1B\x39", "F9"}, | ||
| 188 | {"\x1B\x30", "F10"} | ||
| 189 | }; | 169 | }; |
| 190 | 170 | ||
| 191 | static volatile sig_atomic_t sigWinch; | 171 | static volatile sig_atomic_t sigWinch; |
| @@ -196,9 +176,6 @@ static void handleSIGWINCH(int signalNumber) | |||
| 196 | sigWinch = 1; | 176 | sigWinch = 1; |
| 197 | } | 177 | } |
| 198 | 178 | ||
| 199 | // TODO - Unhandled complications - | ||
| 200 | // Less and more have the "ZZ" command, but nothing else seems to have | ||
| 201 | // multi ordinary character commands. | ||
| 202 | void handle_keys(long extra, | 179 | void handle_keys(long extra, |
| 203 | int (*handle_sequence)(long extra, char *sequence), | 180 | int (*handle_sequence)(long extra, char *sequence), |
| 204 | void (*handle_CSI)(long extra, char *command, int *params, int count)) | 181 | void (*handle_CSI)(long extra, char *command, int *params, int count)) |
| @@ -268,9 +245,7 @@ void handle_keys(long extra, | |||
| 268 | { | 245 | { |
| 269 | // After a short delay to check, this is a real Escape key, | 246 | // After a short delay to check, this is a real Escape key, |
| 270 | // not part of an escape sequence, so deal with it. | 247 | // not part of an escape sequence, so deal with it. |
| 271 | // TODO - So far the only uses of this have the escape at the start, | 248 | strcat(sequence, "Esc"); |
| 272 | // but maybe a strcat is needed instead later? | ||
| 273 | strcpy(sequence, "^["); | ||
| 274 | buffer[0] = buffIndex = 0; | 249 | buffer[0] = buffIndex = 0; |
| 275 | } | 250 | } |
| 276 | // TODO - Call some sort of timer tick callback. This wont be | 251 | // TODO - Call some sort of timer tick callback. This wont be |
