config: add mouse.alternate-scroll-mode option

This option controls the initial state of the Alternate Scroll Mode,
and defaults to ‘enabled’.
This commit is contained in:
Daniel Eklöf 2020-09-15 19:09:00 +02:00
parent 04c1bab7b0
commit f2497320c6
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 31 additions and 0 deletions

View file

@ -73,6 +73,12 @@
(https://codeberg.org/dnkl/foot/issues/128).
* **scrollback-up-line** and **scrollback-down-line** key
bindings. They scroll up/down a single line in the scrollback.
* **mouse.alternate-scroll-mode** option to `foot.ini`. This option
controls the initial state of the _Alternate Scroll Mode_, and
defaults to `yes`. When enabled, mouse events are translated to
up/down key events in the alternate screen, letting you scroll in
e.g. `less` and other applications without enabling native mouse
support in them (https://codeberg.org/dnkl/foot/issues/135).
### Removed

View file

@ -764,6 +764,9 @@ parse_section_mouse(const char *key, const char *value, struct config *conf,
if (strcmp(key, "hide-when-typing") == 0)
conf->mouse.hide_when_typing = str_to_bool(value);
else if (strcmp(key, "alternate-scroll-mode") == 0)
conf->mouse.alternate_scroll_mode = str_to_bool(value);
else {
LOG_AND_NOTIFY_ERR("%s:%d: [mouse]: %s: invalid key", path, lineno, key);
return false;
@ -1907,6 +1910,7 @@ config_load(struct config *conf, const char *conf_path,
},
.mouse = {
.hide_when_typing = false,
.alternate_scroll_mode = true,
},
.csd = {
.preferred = CONF_CSD_PREFER_SERVER,

View file

@ -119,6 +119,7 @@ struct config {
struct {
bool hide_when_typing;
bool alternate_scroll_mode;
} mouse;
struct {

View file

@ -143,6 +143,24 @@ applications can change these at runtime.
*hide-when-typing*
Boolean. When enabled, the mouse cursor is hidden while typing.
*alternate-scroll-mode*
Boolean. This option controls the initial value for the _alternate
scroll mode_. When this mode is enabled, mouse scroll events are
translated to _up_/_down_ key events when displaying the alternate
screen.
This lets you scroll with the mouse in e.g. pagers (like _less_)
without enabling native mouse support in them.
Alternate scrolling is *not* used if the application enables
native mouse support.
This option can be modified by applications at run-time using the
escape sequences *CSI ? 1007 h* (enable) and *CSI ? 1007 l`
(disable).
Default: _yes_.
# SECTION: colors

View file

@ -23,6 +23,7 @@
[mouse]
# hide-when-typing=no
# alternate-scroll-mode=yes
[colors]
# alpha=1.0

View file

@ -964,6 +964,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.grid = &term->normal,
.composed_count = 0,
.composed = NULL,
.alt_scrolling = conf->mouse.alternate_scroll_mode,
.meta = {
.esc_prefix = true,
.eight_bit = true,