diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e69af3..ae73f58f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ * **pipe-selected** key binding. Works like **pipe-visible** and **pipe-scrollback**, but only pipes the currently selected text, if any (https://codeberg.org/dnkl/foot/issues/51). -* **cursor.hide-when-typing** option to `footrc. +* **mouse.hide-when-typing** option to `footrc`. * **scrollback.multiplier** option to `footrc` (https://codeberg.org/dnkl/foot/issues/54). diff --git a/config.c b/config.c index 68424cca..59476f43 100644 --- a/config.c +++ b/config.c @@ -528,9 +528,6 @@ parse_section_cursor(const char *key, const char *value, struct config *conf, else if (strcmp(key, "blink") == 0) conf->cursor.blink = str_to_bool(value); - else if (strcmp(key, "hide-when-typing") == 0) - conf->cursor.hide_when_typing = str_to_bool(value); - else if (strcmp(key, "color") == 0) { char *value_copy = strdup(value); const char *text = strtok(value_copy, " "); @@ -559,6 +556,21 @@ parse_section_cursor(const char *key, const char *value, struct config *conf, return true; } +static bool +parse_section_mouse(const char *key, const char *value, struct config *conf, + const char *path, unsigned lineno) +{ + if (strcmp(key, "hide-when-typing") == 0) + conf->mouse.hide_when_typing = str_to_bool(value); + + else { + LOG_AND_NOTIFY_ERR("%s:%d: [mouse]: %s: invalid key", path, lineno, key); + return false; + } + + return true; +} + static bool parse_section_csd(const char *key, const char *value, struct config *conf, const char *path, unsigned lineno) @@ -1029,6 +1041,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path, bool errors_ar SECTION_SCROLLBACK, SECTION_COLORS, SECTION_CURSOR, + SECTION_MOUSE, SECTION_CSD, SECTION_KEY_BINDINGS, SECTION_SEARCH_BINDINGS, @@ -1050,6 +1063,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path, bool errors_ar [SECTION_SCROLLBACK] = {&parse_section_scrollback, "scrollback"}, [SECTION_COLORS] = {&parse_section_colors, "colors"}, [SECTION_CURSOR] = {&parse_section_cursor, "cursor"}, + [SECTION_MOUSE] = {&parse_section_mouse, "mouse"}, [SECTION_CSD] = {&parse_section_csd, "csd"}, [SECTION_KEY_BINDINGS] = {&parse_section_key_bindings, "key-bindings"}, [SECTION_SEARCH_BINDINGS] = {&parse_section_search_bindings, "search-bindings"}, @@ -1260,12 +1274,14 @@ config_load(struct config *conf, const char *conf_path, bool errors_are_fatal) .cursor = { .style = CURSOR_BLOCK, .blink = false, - .hide_when_typing = false, .color = { .text = 0, .cursor = 0, }, }, + .mouse = { + .hide_when_typing = false, + }, .csd = { .preferred = CONF_CSD_PREFER_SERVER, .title_height = 26, diff --git a/config.h b/config.h index a0484e9f..0c105cda 100644 --- a/config.h +++ b/config.h @@ -75,13 +75,16 @@ struct config { struct { enum cursor_style style; bool blink; - bool hide_when_typing; struct { uint32_t text; uint32_t cursor; } color; } cursor; + struct { + bool hide_when_typing; + } mouse; + struct { /* Bindings for "normal" mode */ tll(struct config_key_binding_normal) key; diff --git a/doc/footrc.5.scd b/doc/footrc.5.scd index 2832552c..8e45e6a2 100644 --- a/doc/footrc.5.scd +++ b/doc/footrc.5.scd @@ -110,9 +110,6 @@ applications can change these at runtime. Boolean. Enables blinking cursor. Note that this can be overridden by applications. Default: _no_. -*hide-when-typing* - Boolean. When enabled, the mouse cursor is hidden while typing. - *color* Two RRGGBB values specifying the foreground (text) and background (cursor) colors for the cursor. Default: inversed foreground and @@ -120,6 +117,13 @@ applications can change these at runtime. cursor. The other cursor styles are always rendered with the foreground color. + +# SECTION: mouse + +*hide-when-typing* + Boolean. When enabled, the mouse cursor is hidden while typing. + + # SECTION: colors This section controls the 16 ANSI colors and the default foreground @@ -152,6 +156,7 @@ _alpha_ option. 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_. + # SECTION: csd This section controls the look of the _CSDs_ (Client Side @@ -193,6 +198,7 @@ component. Close button's AARRGGBB color. Default: use the default _regular1_ color (red). + # SECTION: key-bindings This section lets you override the default key bindings. @@ -276,6 +282,7 @@ e.g. *search-start=none*. Default: _not bound_ + # SECTION: search-bindings This section lets you override the default key bindings used in diff --git a/footrc b/footrc index 6e288a24..81fddde1 100644 --- a/footrc +++ b/footrc @@ -19,6 +19,8 @@ # style=block # color=111111 dcdccc # blink=no + +[mouse] # hide-when-typing=no [colors] diff --git a/input.c b/input.c index 97563930..77922c1a 100644 --- a/input.c +++ b/input.c @@ -700,7 +700,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, bool should_repeat = xkb_keymap_key_repeats(seat->kbd.xkb_keymap, key); xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->kbd.xkb_state, key); - if (state == XKB_KEY_DOWN && term->conf->cursor.hide_when_typing && + if (state == XKB_KEY_DOWN && term->conf->mouse.hide_when_typing && /* TODO: better way to detect modifers */ sym != XKB_KEY_Shift_L && sym != XKB_KEY_Shift_R && sym != XKB_KEY_Control_L && sym != XKB_KEY_Control_R &&