mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-18 06:46:23 -04:00
config: add colors.alpha-non-whitespace option
This commit is contained in:
parent
0bf5a7e902
commit
50868caece
8 changed files with 39 additions and 1 deletions
|
|
@ -60,6 +60,8 @@
|
||||||
* Support for `wp_single_pixel_buffer_v1`; certain overlay surfaces
|
* Support for `wp_single_pixel_buffer_v1`; certain overlay surfaces
|
||||||
will now utilize the new single-pixel buffer protocol. This mainly
|
will now utilize the new single-pixel buffer protocol. This mainly
|
||||||
reduces the memory usage, but should also be slightly faster.
|
reduces the memory usage, but should also be slightly faster.
|
||||||
|
* `alpha-non-whitespace` option, allowing for adjustment of
|
||||||
|
transparency only for non whitespace characters.
|
||||||
|
|
||||||
[1707]: https://codeberg.org/dnkl/foot/issues/1707
|
[1707]: https://codeberg.org/dnkl/foot/issues/1707
|
||||||
|
|
||||||
|
|
|
||||||
23
config.c
23
config.c
|
|
@ -1340,6 +1340,20 @@ parse_section_colors(struct context *ctx)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (streq(key, "alpha-non-whitespace")) {
|
||||||
|
float alpha;
|
||||||
|
if (!value_to_float(ctx, &alpha))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (alpha < 0. || alpha > 1.) {
|
||||||
|
LOG_CONTEXTUAL_ERR("not in range 0.0-1.0");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf->colors.alpha_non_whitespace = alpha * 65535.;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
else if (streq(key, "flash-alpha")) {
|
else if (streq(key, "flash-alpha")) {
|
||||||
float alpha;
|
float alpha;
|
||||||
if (!value_to_float(ctx, &alpha))
|
if (!value_to_float(ctx, &alpha))
|
||||||
|
|
@ -2854,6 +2868,9 @@ parse_config_file(FILE *f, struct config *conf, const char *path, bool errors_ar
|
||||||
errno = 0;
|
errno = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set `alpha_non_whitespace` to atleast `alpha`. */
|
||||||
|
conf->colors.alpha_non_whitespace = max(conf->colors.alpha_non_whitespace, conf->colors.alpha);
|
||||||
|
|
||||||
if (errno != 0) {
|
if (errno != 0) {
|
||||||
LOG_AND_NOTIFY_ERRNO("failed to read from configuration");
|
LOG_AND_NOTIFY_ERRNO("failed to read from configuration");
|
||||||
if (errors_are_fatal)
|
if (errors_are_fatal)
|
||||||
|
|
@ -3092,6 +3109,12 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
.flash = 0x7f7f00,
|
.flash = 0x7f7f00,
|
||||||
.flash_alpha = 0x7fff,
|
.flash_alpha = 0x7fff,
|
||||||
.alpha = 0xffff,
|
.alpha = 0xffff,
|
||||||
|
/* HACK:
|
||||||
|
* when `alpha_non_whitespace` is not set its
|
||||||
|
* default value will be `alpha`. This is achived via
|
||||||
|
* restricting it to be at least the value of `alpha`
|
||||||
|
*/
|
||||||
|
.alpha_non_whitespace = 0x0000,
|
||||||
.selection_fg = 0x80000000, /* Use default bg */
|
.selection_fg = 0x80000000, /* Use default bg */
|
||||||
.selection_bg = 0x80000000, /* Use default fg */
|
.selection_bg = 0x80000000, /* Use default fg */
|
||||||
.use_custom = {
|
.use_custom = {
|
||||||
|
|
|
||||||
1
config.h
1
config.h
|
|
@ -220,6 +220,7 @@ struct config {
|
||||||
uint32_t flash_alpha;
|
uint32_t flash_alpha;
|
||||||
uint32_t table[256];
|
uint32_t table[256];
|
||||||
uint16_t alpha;
|
uint16_t alpha;
|
||||||
|
uint16_t alpha_non_whitespace;
|
||||||
uint32_t selection_fg;
|
uint32_t selection_fg;
|
||||||
uint32_t selection_bg;
|
uint32_t selection_bg;
|
||||||
uint32_t url;
|
uint32_t url;
|
||||||
|
|
|
||||||
|
|
@ -647,6 +647,12 @@ can configure the background transparency with the _alpha_ option.
|
||||||
Background translucency. A value in the range 0.0-1.0, where 0.0
|
Background translucency. A value in the range 0.0-1.0, where 0.0
|
||||||
means completely transparent, and 1.0 is opaque. Default: _1.0_.
|
means completely transparent, and 1.0 is opaque. Default: _1.0_.
|
||||||
|
|
||||||
|
*alpha-non-whitespace*
|
||||||
|
Background translucency for non whitespace characters.
|
||||||
|
A value in the range 0.0-1.0, where 0.0 means completely
|
||||||
|
transparent, and 1.0 is opaque. Default: The value of 0.0.
|
||||||
|
If this value is lower than _alpha_, _alpha_ will be used instead.
|
||||||
|
|
||||||
*selection-foreground*, *selection-background*
|
*selection-foreground*, *selection-background*
|
||||||
Foreground (text) and background color to use in selected
|
Foreground (text) and background color to use in selected
|
||||||
text. Note that *both* options must be set, or the default will be
|
text. Note that *both* options must be set, or the default will be
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -77,6 +77,7 @@
|
||||||
|
|
||||||
[colors]
|
[colors]
|
||||||
# alpha=1.0
|
# alpha=1.0
|
||||||
|
# alpha-non-whitespace=1.0
|
||||||
# background=242424
|
# background=242424
|
||||||
# foreground=ffffff
|
# foreground=ffffff
|
||||||
# flash=7f7f00
|
# flash=7f7f00
|
||||||
|
|
|
||||||
5
render.c
5
render.c
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
|
@ -572,8 +573,10 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_region32_t *damag
|
||||||
* NOTE: if changing this, also update render_margin()
|
* NOTE: if changing this, also update render_margin()
|
||||||
*/
|
*/
|
||||||
xassert(alpha == 0xffff);
|
xassert(alpha == 0xffff);
|
||||||
} else {
|
} else if (isspace(cell->wc) || cell->wc == 0) {
|
||||||
alpha = term->colors.alpha;
|
alpha = term->colors.alpha;
|
||||||
|
} else {
|
||||||
|
alpha = term->colors.alpha_non_whitespace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1221,6 +1221,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
.fg = conf->colors.fg,
|
.fg = conf->colors.fg,
|
||||||
.bg = conf->colors.bg,
|
.bg = conf->colors.bg,
|
||||||
.alpha = conf->colors.alpha,
|
.alpha = conf->colors.alpha,
|
||||||
|
.alpha_non_whitespace = conf->colors.alpha_non_whitespace,
|
||||||
.selection_fg = conf->colors.selection_fg,
|
.selection_fg = conf->colors.selection_fg,
|
||||||
.selection_bg = conf->colors.selection_bg,
|
.selection_bg = conf->colors.selection_bg,
|
||||||
.use_custom_selection = conf->colors.use_custom.selection,
|
.use_custom_selection = conf->colors.use_custom.selection,
|
||||||
|
|
|
||||||
|
|
@ -516,6 +516,7 @@ struct terminal {
|
||||||
uint32_t bg;
|
uint32_t bg;
|
||||||
uint32_t table[256];
|
uint32_t table[256];
|
||||||
uint16_t alpha;
|
uint16_t alpha;
|
||||||
|
uint16_t alpha_non_whitespace;
|
||||||
uint32_t selection_fg;
|
uint32_t selection_fg;
|
||||||
uint32_t selection_bg;
|
uint32_t selection_bg;
|
||||||
bool use_custom_selection;
|
bool use_custom_selection;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue