Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-tui/src/backend/termina.rs')
-rw-r--r--helix-tui/src/backend/termina.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/helix-tui/src/backend/termina.rs b/helix-tui/src/backend/termina.rs
index 784b93d5..30f67a3e 100644
--- a/helix-tui/src/backend/termina.rs
+++ b/helix-tui/src/backend/termina.rs
@@ -53,6 +53,8 @@ struct Capabilities {
synchronized_output: bool,
true_color: bool,
extended_underlines: bool,
+ /// OSC11 / OSC111 - change the terminal's background color.
+ dynamic_background_color: bool,
theme_mode: Option<theme::Mode>,
}
@@ -137,6 +139,9 @@ impl TerminaBackend {
let mut capabilities = Capabilities::default();
let start = Instant::now();
+ // HACK: emitting OSC11 / OSC111 seems to break SGR and cause flickering in tmux.
+ capabilities.dynamic_background_color = std::env::var_os("TMUX").is_none();
+
capabilities.kitty_keyboard = match config.kitty_keyboard_protocol {
KittyKeyboardProtocolConfig::Disabled => KittyKeyboardSupport::None,
KittyKeyboardProtocolConfig::Enabled => KittyKeyboardSupport::Full,
@@ -594,6 +599,9 @@ impl Backend for TerminaBackend {
}
fn set_background_color(&mut self, color: Option<Color>) -> io::Result<()> {
+ if !self.capabilities.dynamic_background_color {
+ return Ok(());
+ }
self.background_color = match color {
Some(Color::Rgb(r, g, b)) => Some(RgbColor::new(r, g, b)),
_ => None,
@@ -621,13 +629,19 @@ impl Drop for TerminaBackend {
let _ = self.disable_mouse_capture();
let _ = write!(
self.terminal,
- "{}{}{}{}{}",
+ "{}{}{}{}",
&self.reset_cursor_command,
decreset!(BracketedPaste),
decreset!(FocusTracking),
- Osc::ResetDynamicColor(osc::DynamicColorNumber::TextBackgroundColor),
decreset!(ClearAndEnableAlternateScreen),
);
+ if self.background_color.is_some() {
+ let _ = write!(
+ self.terminal,
+ "{}",
+ Osc::ResetDynamicColor(osc::DynamicColorNumber::TextBackgroundColor)
+ );
+ }
// NOTE: Drop for Platform terminal resets the mode and flushes the buffer when not
// panicking.
}