From aee9099a44c5af4c445bd2dfd62036ecb29b959a Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Sat, 28 Oct 2017 22:33:53 +0200 Subject: Detect error on character input Previously an error from the character input routine wgetch() was silently ignored. It should still be ignored, but must explicitly be detected in order to be ignored. The issue came up in connection with terminal window resize. For whatever reasons ncurses returns ERR (as well as KEY_RESIZE) when wgetch() asks for input after a resize. Signed-off-by: Lukas Fleischer --- src/keys.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/keys.c') diff --git a/src/keys.c b/src/keys.c index 68eca76..4e608c7 100644 --- a/src/keys.c +++ b/src/keys.c @@ -247,8 +247,12 @@ int keys_wgetch(WINDOW *win) int ch, i; char buf[UTF8_MAXLEN]; + ch = wgetch(win); + if (ch == ERR) + return ch; + /* Handle curses pseudo characters. */ - if ((ch = wgetch(win)) >= KEY_MIN) + if (ch >= KEY_MIN) return ch; /* Handle 1-byte UTF-8 characters. */ -- cgit v1.2.3-54-g00ecf