aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-11-14 21:09:51 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-11-14 21:09:51 +0000
commit134e1d307c97dfd9308f2efb603b55edb6a6e1b0 (patch)
treec34cab8fae6aff8d35220e63c14e0f6179ee651c
parentinstall: simplify sentence (diff)
parentchangelog: bold-text-in-bright (diff)
Merge branch 'bold-is-bright'
Closes #199
-rw-r--r--CHANGELOG.md3
-rw-r--r--config.c4
-rw-r--r--config.h1
-rw-r--r--doc/foot.ini.5.scd4
-rw-r--r--foot.ini1
-rw-r--r--render.c10
6 files changed, 23 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7cadd8fa..e45b2e58 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/config.c b/config.c
index b7909f9e..3e47179b 100644
--- a/config.c
+++ b/config.c
@@ -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()},
diff --git a/config.h b/config.h
index 48961790..a173015f 100644
--- a/config.h
+++ b/config.h
@@ -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;
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index fea26fcf..cfa5b667 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -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*.
diff --git a/foot.ini b/foot.ini
index b22ed049..7ab950c5 100644
--- a/foot.ini
+++ b/foot.ini
@@ -12,6 +12,7 @@
# term=foot
# login-shell=no
# workers=<number of logical CPUs>
+# bold-text-in-bright=no
# bell=none
# word-delimiters=,│`|:"'()[]{}<>
diff --git a/render.c b/render.c
index 96822a33..cec569da 100644
--- a/render.c
+++ b/render.c
@@ -240,6 +240,14 @@ color_dim(pixman_color_t *color)
}
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)
{
color->red /= 2;
@@ -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);