From e760f2df6b5d0958c458898c566152ed53fc90f5 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Fri, 15 May 2020 20:47:10 +1000 Subject: [PATCH] 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. --- src/terminal_ui.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc index b98e2e55..6b2a5966 100644 --- a/src/terminal_ui.cc +++ b/src/terminal_ui.cc @@ -226,6 +226,9 @@ void TerminalUI::Screen::output(bool force) if (lines.empty()) return; + // iTerm2 "begin synchronised update" sequence + printf("\033P=1s\033\\"); + struct Change { int keep; int add; int del; }; Vector changes{Change{}}; auto new_hashes = lines | transform([](auto& line) { return hash_value(line.atoms); }) | gather(); @@ -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;