aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2025-04-20 05:16:18 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-04-26 08:46:39 +0000
commit624c383a1f45a4fbd5ebf687613c509e6c22d909 (patch)
tree8e756d919e0e0d7e937cc3552ebafad1c7c8b6d6
parentconfig: refactor: break out 'colors' to a color_theme struct (diff)
config: move cursor.color to colors.cursor
-rw-r--r--CHANGELOG.md8
-rw-r--r--config.c41
-rw-r--r--config.h12
-rw-r--r--doc/foot.ini.5.scd18
-rw-r--r--foot.ini3
-rw-r--r--osc.c10
-rw-r--r--terminal.c8
7 files changed, 69 insertions, 31 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c48c41c..7b8348ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -64,7 +64,15 @@
## Unreleased
### Added
### Changed
+
+* `cursor.color` moved to `colors.cursor`.
+
+
### Deprecated
+
+* `cursor.color` config option; use `colors.cursor` instead.
+
+
### Removed
### Fixed
### Security
diff --git a/config.c b/config.c
index 347cc1ec..4337d001 100644
--- a/config.c
+++ b/config.c
@@ -1445,6 +1445,20 @@ parse_section_colors(struct context *ctx)
return true;
}
+ else if (streq(key, "cursor")) {
+ if (!value_to_two_colors(
+ ctx,
+ &conf->colors.cursor.text,
+ &conf->colors.cursor.cursor,
+ false))
+ {
+ return false;
+ }
+
+ conf->colors.use_custom.cursor = true;
+ return true;
+ }
+
else if (streq(key, "urls")) {
if (!value_to_color(ctx, &conf->colors.url, false))
return false;
@@ -1537,17 +1551,24 @@ parse_section_cursor(struct context *ctx)
return value_to_uint32(ctx, 10, &conf->cursor.blink.rate_ms);
else if (streq(key, "color")) {
+ LOG_WARN("%s:%d: cursor.color: deprecated; use colors.cursor instead",
+ ctx->path, ctx->lineno);
+
+ user_notification_add(
+ &conf->notifications,
+ USER_NOTIFICATION_DEPRECATED,
+ xstrdup("cursor.color: use colors.cursor instead"));
+
if (!value_to_two_colors(
- ctx,
- &conf->cursor.color.text,
- &conf->cursor.color.cursor,
- false))
+ ctx,
+ &conf->colors.cursor.text,
+ &conf->colors.cursor.cursor,
+ false))
{
return false;
}
- conf->cursor.color.text |= 1u << 31;
- conf->cursor.color.cursor |= 1u << 31;
+ conf->colors.use_custom.cursor = true;
return true;
}
@@ -3356,6 +3377,10 @@ config_load(struct config *conf, const char *conf_path,
.alpha_mode = ALPHA_MODE_DEFAULT,
.selection_fg = 0x80000000, /* Use default bg */
.selection_bg = 0x80000000, /* Use default fg */
+ .cursor = {
+ .text = 0,
+ .cursor = 0,
+ },
.use_custom = {
.selection = false,
.jump_label = false,
@@ -3371,10 +3396,6 @@ config_load(struct config *conf, const char *conf_path,
.enabled = false,
.rate_ms = 500,
},
- .color = {
- .text = 0,
- .cursor = 0,
- },
.beam_thickness = {.pt = 1.5},
.underline_thickness = {.pt = 0., .px = -1},
},
diff --git a/config.h b/config.h
index 4a4e4ae9..89740db3 100644
--- a/config.h
+++ b/config.h
@@ -149,7 +149,12 @@ struct color_theme {
ALPHA_MODE_DEFAULT,
ALPHA_MODE_MATCHING,
ALPHA_MODE_ALL
- } alpha_mode;
+ } alpha_mode;
+
+ struct {
+ uint32_t text;
+ uint32_t cursor;
+ } cursor;
struct {
uint32_t fg;
@@ -174,6 +179,7 @@ struct color_theme {
} search_box;
struct {
+ bool cursor:1;
bool selection:1;
bool jump_label:1;
bool scrollback_indicator:1;
@@ -306,10 +312,6 @@ struct config {
bool enabled;
uint32_t rate_ms;
} blink;
- struct {
- uint32_t text;
- uint32_t cursor;
- } color;
struct pt_or_px beam_thickness;
struct pt_or_px underline_thickness;
} cursor;
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index cffbf9c5..13f768c2 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -898,15 +898,6 @@ applications can change these at runtime.
enabled. Expressed in milliseconds between each blink. Default:
_500_.
-*color*
- Two space separated RRGGBB values (i.e. plain old 6-digit hex
- values, without prefix) specifying the foreground (text) and
- background (cursor) colors for the cursor.
-
- Example: *ff0000 00ff00* (green cursor, red text)
-
- Default: the regular foreground and background colors, reversed.
-
*beam-thickness*
Thickness (width) of the beam styled cursor. The value is in
points, and its exact value thus depends on the monitor's DPI. To
@@ -967,6 +958,15 @@ The colors are in RRGGBB format (i.e. plain old 6-digit hex values,
without prefix). That is, they do *not* have an alpha component. You
can configure the background transparency with the _alpha_ option.
+*cursor*
+ Two space separated RRGGBB values (i.e. plain old 6-digit hex
+ values, without prefix) specifying the foreground (text) and
+ background (cursor) colors for the cursor.
+
+ Example: *ff0000 00ff00* (green cursor, red text)
+
+ Default: the regular foreground and background colors, reversed.
+
*foreground*
Default foreground color. This is the color used when no ANSI
color is being used. Default: _839496_.
diff --git a/foot.ini b/foot.ini
index 7d96ca0f..dc2ad6cd 100644
--- a/foot.ini
+++ b/foot.ini
@@ -85,7 +85,6 @@
[cursor]
# style=block
-# color=<inverse foreground/background>
# blink=no
# blink-rate=500
# beam-thickness=1.5
@@ -106,6 +105,8 @@
# flash=7f7f00
# flash-alpha=0.5
+# cursor=<inverse foreground/background>
+
## Normal/regular colors (color palette 0-7)
# regular0=242424 # black
# regular1=f62b5a # red
diff --git a/osc.c b/osc.c
index eaf6e33e..7e3e6376 100644
--- a/osc.c
+++ b/osc.c
@@ -1570,8 +1570,14 @@ osc_dispatch(struct terminal *term)
case 112:
LOG_DBG("resetting cursor color");
- term->colors.cursor_fg = term->conf->cursor.color.text;
- term->colors.cursor_bg = term->conf->cursor.color.cursor;
+ term->colors.cursor_fg = term->conf->colors.cursor.text;
+ term->colors.cursor_bg = term->conf->colors.cursor.cursor;
+
+ if (term->conf->colors.use_custom.cursor) {
+ term->colors.cursor_fg |= 1u << 31;
+ term->colors.cursor_bg |= 1u << 31;
+ }
+
term_damage_cursor(term);
break;
diff --git a/terminal.c b/terminal.c
index f2d03e77..16663647 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1298,8 +1298,8 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.fg = conf->colors.fg,
.bg = conf->colors.bg,
.alpha = conf->colors.alpha,
- .cursor_fg = conf->cursor.color.text,
- .cursor_bg = conf->cursor.color.cursor,
+ .cursor_fg = (conf->colors.use_custom.cursor ? 1u << 31 : 0) | conf->colors.cursor.text,
+ .cursor_bg = (conf->colors.use_custom.cursor ? 1u << 31 : 0) | conf->colors.cursor.cursor,
.selection_fg = conf->colors.selection_fg,
.selection_bg = conf->colors.selection_bg,
.use_custom_selection = conf->colors.use_custom.selection,
@@ -2153,8 +2153,8 @@ term_reset(struct terminal *term, bool hard)
term->colors.fg = term->conf->colors.fg;
term->colors.bg = term->conf->colors.bg;
term->colors.alpha = term->conf->colors.alpha;
- term->colors.cursor_fg = term->conf->cursor.color.text;
- term->colors.cursor_bg = term->conf->cursor.color.cursor;
+ term->colors.cursor_fg = (term->conf->colors.use_custom.cursor ? 1u << 31 : 0) | term->conf->colors.cursor.text;
+ term->colors.cursor_bg = (term->conf->colors.use_custom.cursor ? 1u << 31 : 0) | term->conf->colors.cursor.cursor;
term->colors.selection_fg = term->conf->colors.selection_fg;
term->colors.selection_bg = term->conf->colors.selection_bg;
term->colors.use_custom_selection = term->conf->colors.use_custom.selection;