Support DIM

* Add a color deriver and derive dim colors for all themes.
 * Derive actual bright colors for the OneHalfDark theme while at it.
 * Use dim colors when the DIM flag is set.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
Mohammad AlSaleh 2024-01-12 01:41:37 +03:00 • committed by Jeremy Soller
parent 679e7ee4f5
commit f34116f3f7
4 changed files with 158 additions and 72 deletions

View file

@ -85,6 +85,13 @@ fn as_bright(mut color: Color) -> Color {
color
}
fn as_dim(mut color: Color) -> Color {
if let Color::Named(named) = color {
color = Color::Named(named.to_dim());
}
color
}
fn convert_color(colors: &Colors, color: Color) -> cosmic_text::Color {
let rgb = match color {
Color::Named(named_color) => match colors[named_color] {
@ -581,12 +588,13 @@ impl Terminal {
let mut attrs = self.default_attrs;
let cell_fg =
if self.use_bright_bold && indexed.cell.flags.contains(Flags::BOLD) {
as_bright(indexed.cell.fg)
} else {
indexed.cell.fg
};
let cell_fg = if indexed.cell.flags.contains(Flags::DIM) {
as_dim(indexed.cell.fg)
} else if self.use_bright_bold && indexed.cell.flags.contains(Flags::BOLD) {
as_bright(indexed.cell.fg)
} else {
indexed.cell.fg
};
let (mut fg, mut bg) = if indexed.cell.flags.contains(Flags::INVERSE) {
(