From bfc07b53a2bd86788f68c1e5b653f6d6ca078320 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 12 Sep 2019 21:48:48 +1000 Subject: [PATCH] Correctly restore terminal state on suspend --- src/ncurses_ui.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 07672d08..c0f2a5c6 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -398,19 +398,22 @@ void NCursesUI::suspend() { bool mouse_enabled = m_mouse_enabled; enable_mouse(false); - tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios); + endwin(); auto current = set_signal_handler(SIGTSTP, SIG_DFL); sigset_t unblock_sigtstp, old_mask; sigemptyset(&unblock_sigtstp); sigaddset(&unblock_sigtstp, SIGTSTP); sigprocmask(SIG_UNBLOCK, &unblock_sigtstp, &old_mask); + tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios); raise(SIGTSTP); // suspend here + tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios); set_signal_handler(SIGTSTP, current); sigprocmask(SIG_SETMASK, &old_mask, nullptr); + doupdate(); check_resize(true); set_raw_mode(); enable_mouse(mouse_enabled);