From 72271ce52953e1e967e5f7a204630743a9c58a1c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 30 Mar 2020 19:49:35 +1100 Subject: [PATCH] Handle skipped characters with erase line (EL) instead of insert blank (ICH) insert blank seems to behave differently between terminals and would be less efficient because it still has to shift all following characters (that we will overwrite anyway). Fixes #3437 --- src/terminal_ui.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc index cfea7b9d..b98e2e55 100644 --- a/src/terminal_ui.cc +++ b/src/terminal_ui.cc @@ -271,25 +271,25 @@ void TerminalUI::Screen::output(bool force) printf("\033[%dH", line + 1); ColumnCount pending_move = 0; - for (auto& atom : lines[line++].atoms) + for (auto& [text, skip, face] : lines[line++].atoms) { + if (text.empty() and skip == 0) + continue; + if (pending_move != 0) { printf("\033[%dC", (int)pending_move); pending_move = 0; } - set_face(atom.face); - fputs(atom.text.c_str(), stdout); - if (atom.skip > 0) + set_face(face); + fputs(text.c_str(), stdout); + if (skip > 3 and face.attributes == Attribute{}) { - if (atom.skip > 4 and atom.face.attributes == Attribute{}) - { - printf("\033[%d@", (int)atom.skip); - pending_move = atom.skip; - } - else for (ColumnCount c = 0; c < atom.skip; ++c) - fputs(" ", stdout); + fputs("\033[K", stdout); + pending_move = skip; } + else if (skip > 0) + fputs(String{' ', skip}.c_str(), stdout); } } }