diff options
| author | Tuomas Siipola <siiptuo@kapsi.fi> | 2017-07-29 01:14:18 +0300 |
|---|---|---|
| committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-07-28 15:14:18 -0700 |
| commit | 9b13e344f0be068982845694442489e4932ccd5d (patch) | |
| tree | 098917a3f0ac3ccc515fd365d1dc4ced8222eb9c /src/term | |
| parent | e33168eff717683fbaf01b52dbf7b4d574a52157 (diff) | |
| download | r-alacritty-9b13e344f0be068982845694442489e4932ccd5d.tar.gz r-alacritty-9b13e344f0be068982845694442489e4932ccd5d.tar.bz2 r-alacritty-9b13e344f0be068982845694442489e4932ccd5d.zip | |
Support background and foreground color escape codes (#662)
Diffstat (limited to 'src/term')
| -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); |