From 77432ee1c54585c9cb2003d484b6b3ec24d77190 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 31 Jan 2020 00:26:52 -0500 Subject: [PATCH] set ~ICRNL with termios.c_iflag #303 --- src/lib/input.c | 3 +++ src/lib/notcurses.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/input.c b/src/lib/input.c index 640817fe6..a59c0627c 100644 --- a/src/lib/input.c +++ b/src/lib/input.c @@ -319,6 +319,9 @@ handle_ncinput(notcurses* nc, ncinput* ni){ } char32_t r = handle_input(nc, ni); // ctrl (*without* alt) + letter maps to [1..26], and is independent of shift + // FIXME need to distinguish between: + // - Enter and ^J + // - Tab and ^I bool ctrl = r > 0 && r <= 26; if(ctrl){ r += 'A' - 1; diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 92b36a0cc..c3476c960 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -840,8 +840,10 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){ // see termios(3). disabling ECHO and ICANON means input will not be echoed // to the screen, input is made available without enter-based buffering, and // line editing is disabled. since we have not gone into raw mode, ctrl+c - // etc. still have their typical effects. + // etc. still have their typical effects. ICRNL maps return to 13 (Ctrl+M) + // instead of 10 (Ctrl+J). modtermios.c_lflag &= (~ECHO & ~ICANON); + modtermios.c_iflag &= (~ICRNL); if(tcsetattr(ret->ttyfd, TCSANOW, &modtermios)){ fprintf(stderr, "Error disabling echo / canonical on %d (%s)\n", ret->ttyfd, strerror(errno));