diff options
Diffstat (limited to 'src/term/mod.rs')
-rw-r--r-- | src/term/mod.rs | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs index 0a51aac3..942c1994 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -674,7 +674,10 @@ pub struct Term { semantic_escape_chars: String, /// Colors used for rendering - colors: color::List, + pub colors: color::List, + + /// Original colors from config + original_colors: color::List, cursor_style: CursorStyle, } @@ -774,6 +777,7 @@ impl Term { size_info: size, empty_cell: template, colors: color::List::from(config.colors()), + original_colors: color::List::from(config.colors()), semantic_escape_chars: config.selection().semantic_escape_chars.clone(), cursor_style: CursorStyle::Block, } @@ -781,7 +785,7 @@ impl Term { pub fn update_config(&mut self, config: &Config) { self.semantic_escape_chars = config.selection().semantic_escape_chars.clone(); - self.colors.fill_named(config.colors()); + self.original_colors.fill_named(config.colors()); self.visual_bell.update_config(config); } @@ -1123,6 +1127,11 @@ impl Term { let template = self.empty_cell; self.grid.clear(|c| c.reset(&template)); } + + #[inline] + pub fn background_color(&self) -> Rgb { + self.colors[NamedColor::Background] + } } impl ansi::TermInfo for Term { @@ -1606,15 +1615,19 @@ impl ansi::Handler for Term { } /// Set the indexed color value - /// - /// TODO needs access to `Config`, and `Config` should not overwrite values - /// when reloading #[inline] fn set_color(&mut self, index: usize, color: Rgb) { trace!("set_color[{}] = {:?}", index, color); self.colors[index] = color; } + /// Reset the indexed color to original value + #[inline] + fn reset_color(&mut self, index: usize) { + trace!("reset_color[{}]", index); + self.colors[index] = self.original_colors[index]; + } + #[inline] fn clear_screen(&mut self, mode: ansi::ClearMode) { trace!("clear_screen: {:?}", mode); |