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
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;