1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00

Fix reloading colors from config (#756)

This commit is contained in:
Tuomas Siipola 2017-08-29 18:54:12 +03:00 committed by Joe Wilm
parent 09c8c06631
commit 6495ab34d2
2 changed files with 15 additions and 2 deletions

View file

@ -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 {

View file

@ -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]