From bde31245331faa732bfedd7a1ae77764ea27ecd5 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 22 Mar 2020 23:50:27 +0900 Subject: [PATCH] [qwaq] Fix some more formatLine cases I think this is all of them. Scrolling around in a file, including having the end of file visible in the window, seems to work well. --- ruamoko/qwaq/qwaq-curses.c | 2 +- ruamoko/qwaq/qwaq-editbuffer-bi.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ruamoko/qwaq/qwaq-curses.c b/ruamoko/qwaq/qwaq-curses.c index 3306af584..02368edc8 100644 --- a/ruamoko/qwaq/qwaq-curses.c +++ b/ruamoko/qwaq/qwaq-curses.c @@ -152,7 +152,7 @@ get_window (qwaq_resources_t *res, const char *name, int handle) window_t *window = window_get (res, handle); if (!window || !window->win) { - PR_RunError (res->pr, "invalid window passed to %s", name + 3); + PR_RunError (res->pr, "invalid window passed to %s", name + 5); } return window; } diff --git a/ruamoko/qwaq/qwaq-editbuffer-bi.c b/ruamoko/qwaq/qwaq-editbuffer-bi.c index 70bb64fa5..2f3f560e9 100644 --- a/ruamoko/qwaq/qwaq-editbuffer-bi.c +++ b/ruamoko/qwaq/qwaq-editbuffer-bi.c @@ -469,10 +469,12 @@ formatLine (txtbuffer_t *buffer, unsigned linePtr, unsigned xpos, ptr++; } col = ptr >= sels && ptr < sele ? cols : coln; - while (xpos < pos && length-- > 0) { + while (xpos < pos && length > 0) { *dst++ = col | ' '; + length--; + xpos++; } - while (length > 0) { + while (length > 0 && ptr < buffer->textSize) { col = ptr >= sels && ptr < sele ? cols : coln; c = getChar (buffer, ptr++); if (c == '\n') { @@ -489,7 +491,7 @@ formatLine (txtbuffer_t *buffer, unsigned linePtr, unsigned xpos, length--; } } - while (c != '\n') { + while (c != '\n' && ptr < buffer->textSize) { c = getChar (buffer, ptr++); } col = ptr >= sels && ptr < sele ? cols : coln;