Merge branch 'bold-is-bright'

Closes #199
This commit is contained in:
Daniel Eklöf 2020-11-14 22:09:51 +01:00
commit 134e1d307c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 23 additions and 0 deletions

View file

@ -56,6 +56,9 @@
not possible to add a command to these actions when used in mouse
bindings, making them useless
(https://codeberg.org/dnkl/foot/issues/183).
* **bold-text-in-bright** option to `foot.ini`. When enabled, bold
text is rendered in a brighter color
(https://codeberg.org/dnkl/foot/issues/199).
### Changed

View file

@ -519,6 +519,9 @@ parse_section_main(const char *key, const char *value, struct config *conf,
conf->pad_y = y;
}
else if (strcmp(key, "bold-text-in-bright") == 0)
conf->bold_in_bright = str_to_bool(value);
else if (strcmp(key, "bell") == 0) {
if (strcmp(value, "set-urgency") == 0)
conf->bell_is_urgent = true;
@ -2017,6 +2020,7 @@ config_load(struct config *conf, const char *conf_path,
},
.pad_x = 2,
.pad_y = 2,
.bold_in_bright = false,
.bell_is_urgent = false,
.startup_mode = STARTUP_WINDOWED,
.fonts = {tll_init(), tll_init(), tll_init(), tll_init()},

View file

@ -79,6 +79,7 @@ struct config {
unsigned pad_x;
unsigned pad_y;
bool bold_in_bright;
bool bell_is_urgent;
enum { STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN } startup_mode;

View file

@ -101,6 +101,10 @@ in this order:
(including SMT). Note that this is not always the best value. In
some cases, the number of physical _cores_ is better.
*bold-text-in-bright*
Boolean. When enabled, bold text is rendered in a brighter color
(in addition to using a bold font). Default: _no_.
*bell*
Action to perform when receiving a *BEL* character. Can be set to
either *set-urgency* or *none*.

View file

@ -12,6 +12,7 @@
# term=foot
# login-shell=no
# workers=<number of logical CPUs>
# bold-text-in-bright=no
# bell=none
# word-delimiters=,│`|:"'()[]{}<>

View file

@ -239,6 +239,14 @@ color_dim(pixman_color_t *color)
color->blue /= 2;
}
static inline void
color_brighten(pixman_color_t *color)
{
color->red = color->red * 2 <= 0xffff ? color->red * 2 : 0xffff;
color->green = color->green * 2 <= 0xffff ? color->green * 2 : 0xffff;
color->blue = color->blue * 2 <= 0xffff ? color->blue * 2 : 0xffff;
}
static inline void
color_dim_for_search(pixman_color_t *color)
{
@ -407,6 +415,8 @@ render_cell(struct terminal *term, pixman_image_t *pix,
if (cell->attrs.dim)
color_dim(&fg);
if (term->conf->bold_in_bright && cell->attrs.bold)
color_brighten(&fg);
if (cell->attrs.blink && term->blink.state == BLINK_OFF)
color_dim(&fg);