AmendHub

Download:

jcs

/

subtext

/

amendments

/

553

console: Don't panic when cursor is out of bounds, just clamp it

This is how our terminal size probing works, after all.

jcs made amendment 553 about 1 year ago
--- console.c Fri Nov 17 11:24:43 2023 +++ console.c Sun Nov 19 10:03:13 2023 @@ -161,8 +161,12 @@ console_idle(struct focusable *focusable, EventRecord /* uncursor */ cursor = (console->cursor_line * console->ncolumns) + console->cursor_column; - if (cursor >= sizeof(console->attrs) - 1) - panic("console_idle: cursor out of bounds!"); + if (cursor >= sizeof(console->attrs) - 1) { + console->cursor_line = console->nlines - 1; + console->cursor_column = console->ncolumns - 1; + cursor = (console->cursor_line * console->ncolumns) + + console->cursor_column; + } console->attrs[cursor] &= ~ATTR_CURSOR; console->attrs[cursor] |= ATTR_DIRTY;