summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2017-10-28 22:33:53 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2017-10-29 08:42:03 +0100
commitaee9099a44c5af4c445bd2dfd62036ecb29b959a (patch)
treefe1ded17aaf66c70b19c5111853ebd4a253df11e /src
parent012a0e6670533911d70f47533e064969c7fc3b65 (diff)
downloadcalcurse-aee9099a44c5af4c445bd2dfd62036ecb29b959a.tar.gz
calcurse-aee9099a44c5af4c445bd2dfd62036ecb29b959a.zip
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 <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/keys.c6
1 files changed, 5 insertions, 1 deletions
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. */