1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-29 14:44:56 +03:00

terminal_ui: restore termios settings before suspending Kakoune.

TerminalUI::suspend() is responsible for undoing all Kakoune's modifications to
the terminal state, actually suspending the process, then re-applying all the
modifications after Kakoune wakes back up.

Previously, the "undo" and "reapply" steps for termios settings were both after
the suspend point, so on some platforms they were incorrect when the user
arrived back at the shell prompt.

Now, the termios "undo" step is back before the suspend point, and the undo and
reapply steps should be in exactly reversed order.

Fixes #3488.
This commit is contained in:
Tim Allen 2020-05-17 20:32:25 +10:00 committed by Maxime Coste
parent e760f2df6b
commit de065dad2d

View File

@ -398,6 +398,7 @@ void TerminalUI::suspend()
{ {
bool mouse_enabled = m_mouse_enabled; bool mouse_enabled = m_mouse_enabled;
enable_mouse(false); enable_mouse(false);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios);
restore_terminal(); restore_terminal();
auto current = set_signal_handler(SIGTSTP, SIG_DFL); auto current = set_signal_handler(SIGTSTP, SIG_DFL);
@ -408,7 +409,6 @@ void TerminalUI::suspend()
raise(SIGTSTP); // suspend here raise(SIGTSTP); // suspend here
tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios);
set_signal_handler(SIGTSTP, current); set_signal_handler(SIGTSTP, current);
sigprocmask(SIG_SETMASK, &old_mask, nullptr); sigprocmask(SIG_SETMASK, &old_mask, nullptr);