bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getch() in nodelay mode returns KEY_RESIZE too late


From: Clemens Ladisch
Subject: getch() in nodelay mode returns KEY_RESIZE too late
Date: Mon, 08 Jun 2009 14:39:00 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

When the following program is run and its console window is resized, the
first following getch() call returns ERR instead of KEY_RESIZE.  That
KEY_RESIZE is returned only after the refresh() call, i.e., when a key
is pressed or when the window is resized a second time.


#include <stdio.h>
#include <poll.h>
#include <errno.h>
#include <ncurses.h>

int main()
{
        struct pollfd pfd;
        int c;

        initscr();
        cbreak();
        noecho();
        keypad(stdscr, TRUE);
        nodelay(stdscr, TRUE);
        pfd.fd = fileno(stdin);
        pfd.events = POLLIN;
        for (;;) {
                if (poll(&pfd, 1, -1) < 0) {
                        if (errno != EINTR)
                                break;
                }
                while ((c = getch()) != ERR) {
                        printw("key: %s\n", keyname(c));
                }
                refresh();
        }
        return 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]