From 6df29b2fd1757f6548a98a879f6babfde71cc6e7 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Fri, 19 Oct 2018 17:49:11 -0500 Subject: [PATCH] Revert "Disable ONLCR mapping of NL output to CR-NL" This reverts commit 3f820f0edf637bc5769602dd7fff1fb22b2329cc. While the premise described by @nbuwe is sound in #4505, we are now apparently relying on this behavior is some places (although inadvertently as there doesn't seem to be a deliberate acknowledgement of that anywhere). Turning off ONLCR causes things like indented multiline commands to not appear correct at the tty (subsequent lines appear both at column 0 and again indented). --- src/reader.cpp | 1 - src/screen.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/reader.cpp b/src/reader.cpp index 9c309d601..028cefced 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -924,7 +924,6 @@ void reader_init() { shell_modes.c_iflag &= ~INLCR; // disable mapping NL (\cJ) to CR (\cM) shell_modes.c_iflag &= ~IXON; // disable flow control shell_modes.c_iflag &= ~IXOFF; // disable flow control - shell_modes.c_iflag &= ~ONLCR; // disable mapping of NL to CR-NL on output (#4505) shell_modes.c_lflag &= ~ICANON; // turn off canonical mode shell_modes.c_lflag &= ~ECHO; // turn off echo mode diff --git a/src/screen.cpp b/src/screen.cpp index 7e0458a57..817468ac2 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -488,6 +488,13 @@ static void s_move(screen_t *s, data_buffer_t *b, int new_x, int new_y) { y_steps = new_y - s->actual.cursor.y; + if (y_steps > 0 && (strcmp(cursor_down, "\n") == 0)) { + // This is very strange - it seems some (all?) consoles use a simple newline as the cursor + // down escape. This will of course move the cursor to the beginning of the line as well as + // moving it down one step. The cursor_up does not have this behaviour... + s->actual.cursor.x = 0; + } + if (y_steps < 0) { str = cursor_up; } else {