From 3d2dc856ab16e53beb8c0e0740b7233181b6f780 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 24 Jun 2020 17:21:58 +0200 Subject: [PATCH] Disable the SUSP character This makes binding \cz possible. We already ignore the SIGTSTP signal it sends, so until now it was useless. (also STOP and START for good measure, but since we disable flow control in fish anyway these already shouldn't have been sent) Fixes #7152 --- CHANGELOG.rst | 1 + src/reader.cpp | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 23a19dca0..710e40c64 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -78,6 +78,7 @@ Interactive improvements - When pressing Tab, fish displays ambiguous completions even when they have a common prefix, without the user having to press Tab again (#6924). +- Control-z is now available for binding (#7152). New or improved bindings diff --git a/src/reader.cpp b/src/reader.cpp index cfd82fd7a..c53e4a1a1 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -649,6 +649,20 @@ static void term_fix_modes(struct termios *modes) { modes->c_lflag &= ~IEXTEN; // turn off handling of discard and lnext characters modes->c_lflag &= ~IEXTEN; // turn off handling of discard and lnext characters modes->c_oflag |= OPOST; // turn on "implementation-defined post processing" - this often changes how line breaks work. + + // Disable flow control in the shell. We don't want to be stopped. + modes->c_iflag &= ~IXON; + modes->c_iflag &= ~IXOFF; + + modes->c_cc[VMIN] = 1; + modes->c_cc[VTIME] = 0; + + // We ignore these anyway, so there is no need to sacrifice a character. + modes->c_cc[VSUSP] = '\0'; + + // (these two are already disabled because of IXON/IXOFF) + modes->c_cc[VSTOP] = '\0'; + modes->c_cc[VSTART] = '\0'; } /// Tracks a currently pending exit. This may be manipulated from a signal handler. @@ -1127,12 +1141,6 @@ void reader_init() { std::memcpy(&shell_modes, &terminal_mode_on_startup, sizeof shell_modes); term_fix_modes(&shell_modes); - // Disable flow control in the shell. We don't want to be stopped. - shell_modes.c_iflag &= ~IXON; - shell_modes.c_iflag &= ~IXOFF; - - shell_modes.c_cc[VMIN] = 1; - shell_modes.c_cc[VTIME] = 0; // We do this not because we actually need the window size but for its side-effect of correctly // setting the COLUMNS and LINES env vars.