AmendHub

Download:

jcs

/

subtext

/

amendments

/

80

console: Pass arrow keys through as VT100 arrow key sequences

Or at least the keycodes generated on the M0110A

jcs made amendment 80 over 2 years ago
--- console.c Mon Feb 14 15:16:20 2022 +++ console.c Mon Feb 21 15:28:46 2022 @@ -250,9 +250,32 @@ console_key_down(struct focusable *focusable, EventRec break; } } else { - console->session->ibuf[console->session->ibuflen++] = k; - if (k == '\r') - console->session->ibuf[console->session->ibuflen++] = '\n'; + switch (k) { + case 0x1C: /* left */ + console->session->ibuf[console->session->ibuflen++] = '\33'; + console->session->ibuf[console->session->ibuflen++] = '['; + console->session->ibuf[console->session->ibuflen++] = 'D'; + break; + case 0x1D: /* right */ + console->session->ibuf[console->session->ibuflen++] = '\33'; + console->session->ibuf[console->session->ibuflen++] = '['; + console->session->ibuf[console->session->ibuflen++] = 'C'; + break; + case 0x1E: /* up */ + console->session->ibuf[console->session->ibuflen++] = '\33'; + console->session->ibuf[console->session->ibuflen++] = '['; + console->session->ibuf[console->session->ibuflen++] = 'A'; + break; + case 0x1F: /* down */ + console->session->ibuf[console->session->ibuflen++] = '\33'; + console->session->ibuf[console->session->ibuflen++] = '['; + console->session->ibuf[console->session->ibuflen++] = 'B'; + break; + default: + console->session->ibuf[console->session->ibuflen++] = k; + if (k == '\r') + console->session->ibuf[console->session->ibuflen++] = '\n'; + } } } @@ -461,6 +484,8 @@ console_shift_chars(struct console *console, short sta Rect mover; RgnHandle rgn; short count; + + /* XXX: this currently only works on whole lines */ /* move all chars at start by offset, overwriting what's there */ count = (console->ncolumns * console->nlines) - start;