mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-02 07:15:31 -04:00
config: make selection foreground/background colors configurable
The default is still to inverse the regular foreground/background colors. If the user sets *both* of the new options, selection-foreground and selection-background, those colors will *always* be used for selected cells, instead of inverting the regular foreground/background colors.
This commit is contained in:
parent
156cce6ef6
commit
5e36ebdef8
6 changed files with 33 additions and 8 deletions
|
|
@ -28,6 +28,8 @@
|
||||||
* **mouse.hide-when-typing** option to `footrc`.
|
* **mouse.hide-when-typing** option to `footrc`.
|
||||||
* **scrollback.multiplier** option to `footrc`
|
* **scrollback.multiplier** option to `footrc`
|
||||||
(https://codeberg.org/dnkl/foot/issues/54).
|
(https://codeberg.org/dnkl/foot/issues/54).
|
||||||
|
* **colors.selection-foreground** and **colors.selection-background**
|
||||||
|
options to `footrc`.
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
||||||
9
config.c
9
config.c
|
|
@ -474,6 +474,8 @@ parse_section_colors(const char *key, const char *value, struct config *conf,
|
||||||
else if (strcmp(key, "bright5") == 0) color = &conf->colors.bright[5];
|
else if (strcmp(key, "bright5") == 0) color = &conf->colors.bright[5];
|
||||||
else if (strcmp(key, "bright6") == 0) color = &conf->colors.bright[6];
|
else if (strcmp(key, "bright6") == 0) color = &conf->colors.bright[6];
|
||||||
else if (strcmp(key, "bright7") == 0) color = &conf->colors.bright[7];
|
else if (strcmp(key, "bright7") == 0) color = &conf->colors.bright[7];
|
||||||
|
else if (strcmp(key, "selection-foreground") == 0) color = &conf->colors.selection_fg;
|
||||||
|
else if (strcmp(key, "selection-background") == 0) color = &conf->colors.selection_bg;
|
||||||
else if (strcmp(key, "alpha") == 0) {
|
else if (strcmp(key, "alpha") == 0) {
|
||||||
double alpha;
|
double alpha;
|
||||||
if (!str_to_double(value, &alpha) || alpha < 0. || alpha > 1.) {
|
if (!str_to_double(value, &alpha) || alpha < 0. || alpha > 1.) {
|
||||||
|
|
@ -1257,6 +1259,9 @@ config_load(struct config *conf, const char *conf_path, bool errors_are_fatal)
|
||||||
default_bright[7],
|
default_bright[7],
|
||||||
},
|
},
|
||||||
.alpha = 0xffff,
|
.alpha = 0xffff,
|
||||||
|
.selection_fg = 0x80000000, /* Use default bg */
|
||||||
|
.selection_bg = 0x80000000, /* Use default fg */
|
||||||
|
.selection_uses_custom_colors = false,
|
||||||
},
|
},
|
||||||
|
|
||||||
.cursor = {
|
.cursor = {
|
||||||
|
|
@ -1373,6 +1378,10 @@ config_load(struct config *conf, const char *conf_path, bool errors_are_fatal)
|
||||||
ret = parse_config_file(f, conf, conf_path, errors_are_fatal);
|
ret = parse_config_file(f, conf, conf_path, errors_are_fatal);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
conf->colors.selection_uses_custom_colors =
|
||||||
|
conf->colors.selection_fg >> 24 == 0 &&
|
||||||
|
conf->colors.selection_bg >> 24 == 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (ret && tll_length(conf->fonts) == 0)
|
if (ret && tll_length(conf->fonts) == 0)
|
||||||
tll_push_back(conf->fonts, config_font_parse("monospace"));
|
tll_push_back(conf->fonts, config_font_parse("monospace"));
|
||||||
|
|
|
||||||
3
config.h
3
config.h
|
|
@ -70,6 +70,9 @@ struct config {
|
||||||
uint32_t regular[8];
|
uint32_t regular[8];
|
||||||
uint32_t bright[8];
|
uint32_t bright[8];
|
||||||
uint16_t alpha;
|
uint16_t alpha;
|
||||||
|
uint32_t selection_fg;
|
||||||
|
uint32_t selection_bg;
|
||||||
|
bool selection_uses_custom_colors;
|
||||||
} colors;
|
} colors;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,11 @@ _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_.
|
||||||
|
|
||||||
|
*selection-foreground*, *selection-background*
|
||||||
|
Foreground (text) and background color to use in selected
|
||||||
|
text. Note that *both* options must be set, or the default will be
|
||||||
|
used. Default: _inverse foreground/background_.
|
||||||
|
|
||||||
|
|
||||||
# SECTION: csd
|
# SECTION: csd
|
||||||
|
|
||||||
|
|
|
||||||
2
footrc
2
footrc
|
|
@ -43,6 +43,8 @@
|
||||||
# bright5=fcace3 # bright magenta
|
# bright5=fcace3 # bright magenta
|
||||||
# bright6=b3ffff # bright cyan
|
# bright6=b3ffff # bright cyan
|
||||||
# bright7=ffffff # bright white
|
# bright7=ffffff # bright white
|
||||||
|
# selection-foreground=<inverse foreground/background>
|
||||||
|
# selection-background=<inverse foreground/background>
|
||||||
|
|
||||||
[csd]
|
[csd]
|
||||||
# preferred=server
|
# preferred=server
|
||||||
|
|
|
||||||
20
render.c
20
render.c
|
|
@ -384,15 +384,19 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
||||||
uint32_t _fg = 0;
|
uint32_t _fg = 0;
|
||||||
uint32_t _bg = 0;
|
uint32_t _bg = 0;
|
||||||
|
|
||||||
/* Use cell specific color, if set, otherwise the default colors (possible reversed) */
|
if (is_selected && term->conf->colors.selection_uses_custom_colors) {
|
||||||
_fg = cell->attrs.have_fg ? cell->attrs.fg : term->colors.fg;
|
_fg = term->conf->colors.selection_fg;
|
||||||
_bg = cell->attrs.have_bg ? cell->attrs.bg : term->colors.bg;
|
_bg = term->conf->colors.selection_bg;
|
||||||
|
} else {
|
||||||
|
/* Use cell specific color, if set, otherwise the default colors (possible reversed) */
|
||||||
|
_fg = cell->attrs.have_fg ? cell->attrs.fg : term->colors.fg;
|
||||||
|
_bg = cell->attrs.have_bg ? cell->attrs.bg : term->colors.bg;
|
||||||
|
|
||||||
/* If *one* is set, we reverse */
|
if (term->reverse ^ cell->attrs.reverse ^ is_selected) {
|
||||||
if (term->reverse ^ cell->attrs.reverse ^ is_selected) {
|
uint32_t swap = _fg;
|
||||||
uint32_t swap = _fg;
|
_fg = _bg;
|
||||||
_fg = _bg;
|
_bg = swap;
|
||||||
_bg = swap;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell->attrs.blink && term->blink.state == BLINK_OFF)
|
if (cell->attrs.blink && term->blink.state == BLINK_OFF)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue