diff options
author | Tuomas Siipola <siiptuo@kapsi.fi> | 2017-08-29 18:54:12 +0300 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-08-29 08:54:12 -0700 |
commit | 6495ab34d2043440f138242cf58d39e687e6c02e (patch) | |
tree | 23599b2262c93085118b00e86191e729c0acbf02 /src | |
parent | 09c8c066310c20d858c66f06a6c283b4e88245d3 (diff) | |
download | alacritty-6495ab34d2043440f138242cf58d39e687e6c02e.tar.gz alacritty-6495ab34d2043440f138242cf58d39e687e6c02e.zip |
Fix reloading colors from config (#756)
Diffstat (limited to 'src')
-rw-r--r-- | src/term/color.rs | 4 | ||||
-rw-r--r-- | src/term/mod.rs | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/term/color.rs b/src/term/color.rs index 8f58d0ca..f1f53a98 100644 --- a/src/term/color.rs +++ b/src/term/color.rs @@ -4,6 +4,8 @@ use std::fmt; use {Rgb, ansi}; use config::Colors; +pub const COUNT: usize = 268; + /// List of indexed colors /// /// The first 16 entries are the standard ansi named colors. Items 16..232 are @@ -11,7 +13,7 @@ use config::Colors; /// the configured foreground color, item 257 is the configured background /// color, item 258 is the cursor foreground color, item 259 is the cursor /// background color. Following that are 8 positions for dim colors. -pub struct List([Rgb; 268]); +pub struct List([Rgb; COUNT]); impl<'a> From<&'a Colors> for List { fn from(colors: &Colors) -> List { diff --git a/src/term/mod.rs b/src/term/mod.rs index a068f553..a7892e6a 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -671,7 +671,10 @@ pub struct Term { semantic_escape_chars: String, /// Colors used for rendering - pub colors: color::List, + colors: color::List, + + /// Is color in `colors` modified or not + color_modified: [bool; color::COUNT], /// Original colors from config original_colors: color::List, @@ -773,6 +776,7 @@ impl Term { scroll_region: scroll_region, size_info: size, colors: color::List::from(config.colors()), + color_modified: [false; color::COUNT], original_colors: color::List::from(config.colors()), semantic_escape_chars: config.selection().semantic_escape_chars.clone(), cursor_style: CursorStyle::Block, @@ -782,6 +786,11 @@ impl Term { pub fn update_config(&mut self, config: &Config) { self.semantic_escape_chars = config.selection().semantic_escape_chars.clone(); self.original_colors.fill_named(config.colors()); + for i in 0..color::COUNT { + if !self.color_modified[i] { + self.colors[i] = self.original_colors[i]; + } + } self.visual_bell.update_config(config); } @@ -1615,6 +1624,7 @@ impl ansi::Handler for Term { fn set_color(&mut self, index: usize, color: Rgb) { trace!("set_color[{}] = {:?}", index, color); self.colors[index] = color; + self.color_modified[index] = true; } /// Reset the indexed color to original value @@ -1622,6 +1632,7 @@ impl ansi::Handler for Term { fn reset_color(&mut self, index: usize) { trace!("reset_color[{}]", index); self.colors[index] = self.original_colors[index]; + self.color_modified[index] = false; } #[inline] |