From 2582d57465d7b9c289e451afeab7d38825b4bf1d Mon Sep 17 00:00:00 2001 From: Kaian Date: Mon, 8 Apr 2019 21:24:12 +0200 Subject: [PATCH] ncurses: read first input before screen display --- src/ncurses/manager.c | 5 ++++- src/ncurses/window.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ncurses/manager.c b/src/ncurses/manager.c index 5ee033f..2fa41f8 100644 --- a/src/ncurses/manager.c +++ b/src/ncurses/manager.c @@ -552,8 +552,11 @@ ncurses_init(GMainLoop *loop, GError **error) // Create the first displayed window ncurses_create_window(WINDOW_CALL_LIST); + // Hack: First readed key before screen display causes ESC key to be read + ncurses_read_input(STDERR_FILENO, G_IO_IN, loop); + // Source for reading events from stdin - GSource *source = g_unix_fd_source_new(fileno(stdin), G_IO_IN | G_IO_ERR | G_IO_HUP); + GSource *source = g_unix_fd_source_new(STDIN_FILENO, G_IO_IN | G_IO_ERR | G_IO_HUP); g_source_set_callback(source, (GSourceFunc) ncurses_read_input, loop, NULL); g_source_attach(source, NULL); diff --git a/src/ncurses/window.h b/src/ncurses/window.h index e58351a..8e0b157 100644 --- a/src/ncurses/window.h +++ b/src/ncurses/window.h @@ -32,7 +32,7 @@ #define __SNGREP_WINDOW_H #include -#include +#include #include #include