Ensure metadata is updated when theme changes, fixes #121

This commit is contained in:
Jeremy Soller 2024-02-08 12:37:02 -07:00
parent bf7668dbd7
commit 46cae2f2d3
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
2 changed files with 32 additions and 15 deletions

View file

@ -559,19 +559,7 @@ impl Terminal {
}
}
if changed {
self.metadata_set.clear();
let default_bg = convert_color(colors, Color::Named(NamedColor::Background));
let default_fg = convert_color(colors, Color::Named(NamedColor::Foreground));
let default_metadata = Metadata::new(default_bg, default_fg);
let (default_metadata_idx, _) = self.metadata_set.insert_full(default_metadata);
self.default_attrs = Attrs::new()
.family(Family::Monospace)
.weight(Weight(config.font_weight))
.stretch(config.typed_font_stretch())
.color(default_fg)
.metadata(default_metadata_idx);
self.update_colors(config);
update = true;
}
}
@ -583,6 +571,22 @@ impl Terminal {
}
}
pub fn update_colors(&mut self, config: &AppConfig) {
self.metadata_set.clear();
let default_bg = convert_color(&self.colors, Color::Named(NamedColor::Background));
let default_fg = convert_color(&self.colors, Color::Named(NamedColor::Foreground));
let default_metadata = Metadata::new(default_bg, default_fg);
let (default_metadata_idx, _) = self.metadata_set.insert_full(default_metadata);
self.default_attrs = Attrs::new()
.family(Family::Monospace)
.weight(Weight(config.font_weight))
.stretch(config.typed_font_stretch())
.color(default_fg)
.metadata(default_metadata_idx);
}
pub fn update_cell_size(&mut self) {
let default_attrs = self.default_attrs;
let (cell_width, cell_height) = {