config: add 'indicate-when-selecting'

This allows disabling the caret style mouse cursor when the Shift key
is held.
This commit is contained in:
Craig Barnes 2020-08-03 01:53:16 +01:00
parent 91da76656c
commit 7422719e5b
6 changed files with 13 additions and 2 deletions

View file

@ -25,7 +25,8 @@
* **pipe-selected** key binding. Works like **pipe-visible** and * **pipe-selected** key binding. Works like **pipe-visible** and
**pipe-scrollback**, but only pipes the currently selected text, if **pipe-scrollback**, but only pipes the currently selected text, if
any (https://codeberg.org/dnkl/foot/issues/51). any (https://codeberg.org/dnkl/foot/issues/51).
* **cursor.hide-when-typing** option to `footrc. * **cursor.hide-when-typing** option to `footrc`.
* **cursor.indicate-when-selecting** option to `footrc`.
### Deprecated ### Deprecated

View file

@ -520,6 +520,9 @@ parse_section_cursor(const char *key, const char *value, struct config *conf,
else if (strcmp(key, "hide-when-typing") == 0) else if (strcmp(key, "hide-when-typing") == 0)
conf->cursor.hide_when_typing = str_to_bool(value); conf->cursor.hide_when_typing = str_to_bool(value);
else if (strcmp(key, "indicate-when-selecting") == 0)
conf->cursor.indicate_when_selecting = str_to_bool(value);
else if (strcmp(key, "color") == 0) { else if (strcmp(key, "color") == 0) {
char *value_copy = strdup(value); char *value_copy = strdup(value);
const char *text = strtok(value_copy, " "); const char *text = strtok(value_copy, " ");
@ -1249,6 +1252,7 @@ config_load(struct config *conf, const char *conf_path, bool errors_are_fatal)
.style = CURSOR_BLOCK, .style = CURSOR_BLOCK,
.blink = false, .blink = false,
.hide_when_typing = false, .hide_when_typing = false,
.indicate_when_selecting = true,
.color = { .color = {
.text = 0, .text = 0,
.cursor = 0, .cursor = 0,

View file

@ -75,6 +75,7 @@ struct config {
enum cursor_style style; enum cursor_style style;
bool blink; bool blink;
bool hide_when_typing; bool hide_when_typing;
bool indicate_when_selecting;
struct { struct {
uint32_t text; uint32_t text;
uint32_t cursor; uint32_t cursor;

View file

@ -109,6 +109,10 @@ applications can change these at runtime.
*hide-when-typing* *hide-when-typing*
Boolean. When enabled, the mouse cursor is hidden while typing. Boolean. When enabled, the mouse cursor is hidden while typing.
*indicate-when-selecting*
Boolean. When enabled, the mouse cursor changes form to indicate
when the Shift key is held (for text selections).
*color* *color*
Two RRGGBB values specifying the foreground (text) and background Two RRGGBB values specifying the foreground (text) and background
(cursor) colors for the cursor. Default: inversed foreground and (cursor) colors for the cursor. Default: inversed foreground and

1
footrc
View file

@ -19,6 +19,7 @@
# color=111111 dcdccc # color=111111 dcdccc
# blink=no # blink=no
# hide-when-typing=no # hide-when-typing=no
# indicate-when-selecting=yes
[colors] [colors]
# alpha=1.0 # alpha=1.0

View file

@ -2213,7 +2213,7 @@ term_xcursor_update_for_seat(struct terminal *term, struct seat *seat)
const char *xcursor const char *xcursor
= seat->pointer.hidden ? XCURSOR_HIDDEN = seat->pointer.hidden ? XCURSOR_HIDDEN
: term->is_searching ? XCURSOR_LEFT_PTR : term->is_searching ? XCURSOR_LEFT_PTR
: selection_enabled(term, seat) ? XCURSOR_TEXT : (selection_enabled(term, seat) && term->conf->cursor.indicate_when_selecting) ? XCURSOR_TEXT
: XCURSOR_LEFT_PTR; : XCURSOR_LEFT_PTR;
render_xcursor_set(seat, term, xcursor); render_xcursor_set(seat, term, xcursor);