On 2014/01/13 12:41, Philip Guenther wrote:
> On Mon, 13 Jan 2014, Gregor Best wrote:
> > The patch below seems to fix that for me. resizeterm() does a
> > putchar(KEY_RESIZE), part of which then gets interpreted as a command
> > parameter in rundisplay().
>
> I think you meant "ungetch(KEY_RESIZE)", but that pointed me at the
> getnstr() manpage, which notes that it returns KEY_RESIZE if there was a
> pending resize event. Changing readline() to loop on getnstr() while it
> returns that, resetting the cursor position each time, seems to fix the
> problem in my testing.
Thanks, both diffs fix things for me, but this one is clearer and more
precise - OK.
>
> Philip Guenther
>
>
> Index: display.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/top/display.c,v
> retrieving revision 1.46
> diff -u -p -r1.46 display.c
> --- display.c 28 Nov 2013 18:24:55 -0000 1.46
> +++ display.c 13 Jan 2014 20:37:38 -0000
> @@ -641,9 +641,12 @@ readline(char *buffer, int size)
> /* allow room for null terminator */
> size -= 1;
>
> - if (smart_terminal)
> - getnstr(buffer, size);
> - else
> + if (smart_terminal) {
> + int y, x;
> + getyx(stdscr, y, x);
> + while (getnstr(buffer, size) == KEY_RESIZE)
> + move(y, x);
> + } else
> return readlinedumb(buffer, size);
>
> cnt = strlen(buffer);
>