Use iTerm2 "synchronised update" sequences around redraws.

In terminals that support it, this sequence causes the terminal to not redraw
*its* output until the application has finished, reducing redraw flickering.

The sequence is defined in:

    https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec

...and is apparently also supported by kitty and libVTE.

Fixes #3482.
This commit is contained in:
Tim Allen 2020-05-15 20:47:10 +10:00 committed by Maxime Coste
parent 72271ce529
commit e760f2df6b

View File

@ -226,6 +226,9 @@ void TerminalUI::Screen::output(bool force)
if (lines.empty()) if (lines.empty())
return; return;
// iTerm2 "begin synchronised update" sequence
printf("\033P=1s\033\\");
struct Change { int keep; int add; int del; }; struct Change { int keep; int add; int del; };
Vector<Change> changes{Change{}}; Vector<Change> changes{Change{}};
auto new_hashes = lines | transform([](auto& line) { return hash_value(line.atoms); }) | gather<Vector>(); auto new_hashes = lines | transform([](auto& line) { return hash_value(line.atoms); }) | gather<Vector>();
@ -293,6 +296,9 @@ void TerminalUI::Screen::output(bool force)
} }
} }
} }
// iTerm2 "endsynchronised update" sequence
printf("\033P=2s\033\\");
} }
constexpr int TerminalUI::default_shift_function_key; constexpr int TerminalUI::default_shift_function_key;