config: add [colors].dim0-7

This allows you to configure custom colors to be used when colors are
being dimmed (`\E[2m`).

It is implemented by color matching (just like
bold-text-in-bright=palette-based); the color-to-be-dimmed is matched
against the current color palette.

If it matches one of the regular colors (colors 0-7), the
corresponding “dim” color will be used.

If it matches one of the bright colors (colors 8-15), the
corresponding “regular” color will be used (but *only* if the “dim”
color has been set).

Otherwise, the color is dimmed by reducing its luminance.

The default behavior, i.e. when dim0-7 hasn’t been configured, is to
dim by reducing luminance for *all* colors. I.e. we don’t do any color
matching at all. In particular, this means that dimming a bright color
will *not* result in the corresponding “regular” color.

Closes #776
This commit is contained in:
Daniel Eklöf 2021-11-03 14:25:38 +01:00
parent 0d2a429109
commit c01904a2c7
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 91 additions and 9 deletions

View file

@ -1290,6 +1290,14 @@ parse_section_colors(struct context *ctx)
else if (key_len == 7 && str_has_prefix(key, "bright") && last_digit < 8)
color = &conf->colors.table[8 + last_digit];
else if (key_len == 4 && str_has_prefix(key, "dim") && last_digit < 8) {
if (!value_to_color(ctx, &conf->colors.dim[last_digit], false))
return false;
conf->colors.use_custom.dim |= 1 << last_digit;
return true;
}
else if (strcmp(key, "foreground") == 0) color = &conf->colors.fg;
else if (strcmp(key, "background") == 0) color = &conf->colors.bg;
else if (strcmp(key, "selection-foreground") == 0) color = &conf->colors.selection_fg;