From d9729cc29eb717aae2c68ced24d4b04d4c2ea4cf Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 28 Oct 2012 09:26:54 +0100 Subject: Handle all available input before redrawing --- src/ncurses.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/ncurses.cc') diff --git a/src/ncurses.cc b/src/ncurses.cc index a7c2a3e5..1cbfbf1f 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -211,6 +211,16 @@ struct getch_iterator getch_iterator& operator++(int) { return *this; } }; +bool NCursesUI::is_key_available() +{ + timeout(0); + const int c = getch(); + if (c != ERR) + ungetch(c); + timeout(-1); + return c != ERR; +} + Key NCursesUI::get_key() { const unsigned c = getch(); -- cgit v1.2.3