From: Timo Korvola Date: Mon, 19 Feb 2018 21:41:49 +0000 (+0200) Subject: Keep cursor within bounds in os_read_line. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=894aa5212b1011706a4f284d9baf5cb676dd3df3;p=liskon_frotz.git Keep cursor within bounds in os_read_line. Maximum scrpos is width - 1 even if len == width. Then the cursor will stay on the last character because there is no room to the right of it. #42: Handle terminal resizing --- diff --git a/src/curses/ux_input.c b/src/curses/ux_input.c index e4d3f4c..877e0f1 100644 --- a/src/curses/ux_input.c +++ b/src/curses/ux_input.c @@ -488,13 +488,16 @@ zchar os_read_line (int bufmax, zchar *buf, int timeout, int width, unix_set_global_timeout(timeout); for (;;) { int x2, max; + if (scrpos >= width) + scrpos = width - 1; move(y, x + scrpos); /* Maybe there's a cleaner way to do this, but refresh() is */ /* still needed here to print spaces. --DG */ refresh(); ch = unix_read_char(1); getyx(stdscr, y, x2); - max = MIN(h_screen_width - margin, bufmax); + width = h_screen_width - margin; + max = MIN(width, bufmax); /* The screen has shrunk and input no longer fits. Chop. */ if (len > max) { len = max;