diff --git a/src/main.rs b/src/main.rs index 3bf9e7f..4a9453f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3066,7 +3066,7 @@ impl Application for App { && let Some(terminal) = tab_model.data::>(entity) { let terminal = terminal.lock().unwrap(); - let rgb = terminal.colors()[index].unwrap_or_default(); + let rgb = terminal.effective_color(index); let text = f(rgb); terminal.input_no_scroll(text.into_bytes()); } diff --git a/src/terminal.rs b/src/terminal.rs index 73f8581..6cb0ce3 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -386,6 +386,19 @@ impl Terminal { &self.colors } + pub fn effective_color(&self, index: usize) -> Rgb { + if index == NamedColor::Background as usize { + self.colors[index].unwrap_or_else(|| { + // Allow using an unset background + let [r, g, b, _] = + cosmic_text::Color(WINDOW_BG_COLOR.load(Ordering::SeqCst)).as_rgba(); + Rgb { r, g, b } + }) + } else { + self.colors[index].unwrap_or_default() + } + } + pub fn default_attrs(&self) -> &Attrs<'static> { &self.default_attrs }