From aeffe40efcfe65e932b9b5c07ec0b6422162aa7b Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Mon, 18 Oct 2021 11:23:17 +0200 Subject: Bind ^S to search, as in Emacs, with a trick We heavily depend on ncurses anyway, so no worries about portability. --- sdn.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sdn.cpp b/sdn.cpp index f73e88c..d8cd2e5 100644 --- a/sdn.cpp +++ b/sdn.cpp @@ -51,6 +51,11 @@ #include #include +// To implement cbreak() with disabled ^S that gets reënabled on endwin() +#define NCURSES_INTERNALS +#include +#undef CTRL // term.h -> termios.h -> sys/ttydefaults.h, too simplistic + // Unicode is complex enough already and we might make assumptions #ifndef __STDC_ISO_10646__ #error Unicode required for wchar_t @@ -439,7 +444,7 @@ static map g_normal_actions { {CTRL ('Y'), ACTION_SCROLL_UP}, {CTRL ('E'), ACTION_SCROLL_DOWN}, {'c', ACTION_CHDIR}, {ALT | KEY (UP), ACTION_PARENT}, {'&', ACTION_GO_START}, {'~', ACTION_GO_HOME}, - {'/', ACTION_SEARCH}, {'s', ACTION_SEARCH}, + {'/', ACTION_SEARCH}, {'s', ACTION_SEARCH}, {CTRL ('S'), ACTION_SEARCH}, {ALT | 'e', ACTION_RENAME_PREFILL}, {'e', ACTION_RENAME}, {KEY (F (6)), ACTION_RENAME_PREFILL}, {KEY (F (7)), ACTION_MKDIR}, {'t', ACTION_TOGGLE_FULL}, {ALT | 't', ACTION_TOGGLE_FULL}, @@ -1832,6 +1837,10 @@ int main (int argc, char *argv[]) { pop_levels (g.cwd); update (); + // This gets applied along with the following halfdelay() + cur_term->Nttyb.c_cc[VSTOP] = + cur_term->Nttyb.c_cc[VSTART] = _POSIX_VDISABLE; + // Invoking keypad() earlier would make ncurses flush its output buffer, // which would worsen start-up flickering if (halfdelay (1) == ERR || keypad (stdscr, TRUE) == ERR) { -- cgit v1.2.3-70-g09d2