config: add scrollback-{up,down}-half key bindings

These new bindings scroll up/down half a page in the
scrollback (instead of the full page scrolled by
‘scrollback-{up,down}’).

Closes #128.
This commit is contained in:
Daniel Eklöf 2020-09-09 19:40:48 +02:00
parent a132e6cf84
commit 2e3bd5e23c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 28 additions and 2 deletions

View file

@ -64,6 +64,9 @@
`-W,--window-size-chars` command line option to `foot`. This option `-W,--window-size-chars` command line option to `foot`. This option
configures the initial window size in **characters**, and is an configures the initial window size in **characters**, and is an
alternative to **initial-window-size-pixels**. alternative to **initial-window-size-pixels**.
* **scrollback-up-half** and **scrollback-down-half** key
bindings. They scroll up/down half of a page in the scrollback
(https://codeberg.org/dnkl/foot/issues/128).
### Removed ### Removed

View file

@ -56,7 +56,9 @@ static const uint32_t default_bright[] = {
static const char *const binding_action_map[] = { static const char *const binding_action_map[] = {
[BIND_ACTION_NONE] = NULL, [BIND_ACTION_NONE] = NULL,
[BIND_ACTION_SCROLLBACK_UP] = "scrollback-up", [BIND_ACTION_SCROLLBACK_UP] = "scrollback-up",
[BIND_ACTION_SCROLLBACK_UP_HALF] = "scrollback-up-half",
[BIND_ACTION_SCROLLBACK_DOWN] = "scrollback-down", [BIND_ACTION_SCROLLBACK_DOWN] = "scrollback-down",
[BIND_ACTION_SCROLLBACK_DOWN_HALF] = "scrollback-down-half",
[BIND_ACTION_CLIPBOARD_COPY] = "clipboard-copy", [BIND_ACTION_CLIPBOARD_COPY] = "clipboard-copy",
[BIND_ACTION_CLIPBOARD_PASTE] = "clipboard-paste", [BIND_ACTION_CLIPBOARD_PASTE] = "clipboard-paste",
[BIND_ACTION_PRIMARY_PASTE] = "primary-paste", [BIND_ACTION_PRIMARY_PASTE] = "primary-paste",

View file

@ -239,10 +239,19 @@ default binding. This can be done by setting _action=none_;
e.g. *search-start=none*. e.g. *search-start=none*.
*scrollback-up* *scrollback-up*
Scrolls up/back in history. Default: _Shift+Page\_Up_. Scrolls up/back one page in history. Default: _Shift+Page\_Up_.
*scrollback-up-half*
Scrolls up/back half of a page in history. Default:
_Shift+Page\_Up_.
*scrollback-down* *scrollback-down*
Scroll down/forward in history. Default: _Shift+Page\_Down_. Scroll down/forward one page in history. Default:
_Shift+Page\_Down_.
*scrollback-down-half*
Scroll down/forward half of a page in history. Default:
_Shift+Page\_Down_.
*clipboard-copy* *clipboard-copy*
Copies the current selection into the _clipboard_. Default: _Control+Shift+C_. Copies the current selection into the _clipboard_. Default: _Control+Shift+C_.

View file

@ -58,7 +58,9 @@
[key-bindings] [key-bindings]
# scrollback-up=Shift+Page_Up # scrollback-up=Shift+Page_Up
# scrollback-up-half=none
# scrollback-down=Shift+Page_Down # scrollback-down=Shift+Page_Down
# scrollback-down-half=none
# clipboard-copy=Control+Shift+C # clipboard-copy=Control+Shift+C
# clipboard-paste=Control+Shift+V # clipboard-paste=Control+Shift+V
# search-start=Control+Shift+R # search-start=Control+Shift+R

View file

@ -91,10 +91,18 @@ execute_binding(struct seat *seat, struct terminal *term,
cmd_scrollback_up(term, term->rows); cmd_scrollback_up(term, term->rows);
return true; return true;
case BIND_ACTION_SCROLLBACK_UP_HALF:
cmd_scrollback_up(term, max(term->rows / 2, 1));
return true;
case BIND_ACTION_SCROLLBACK_DOWN: case BIND_ACTION_SCROLLBACK_DOWN:
cmd_scrollback_down(term, term->rows); cmd_scrollback_down(term, term->rows);
return true; return true;
case BIND_ACTION_SCROLLBACK_DOWN_HALF:
cmd_scrollback_down(term, max(term->rows / 2, 1));
return true;
case BIND_ACTION_CLIPBOARD_COPY: case BIND_ACTION_CLIPBOARD_COPY:
selection_to_clipboard(seat, term, serial); selection_to_clipboard(seat, term, serial);
return true; return true;

View file

@ -27,7 +27,9 @@ typedef tll(struct key_binding) key_binding_list_t;
enum bind_action_normal { enum bind_action_normal {
BIND_ACTION_NONE, BIND_ACTION_NONE,
BIND_ACTION_SCROLLBACK_UP, BIND_ACTION_SCROLLBACK_UP,
BIND_ACTION_SCROLLBACK_UP_HALF,
BIND_ACTION_SCROLLBACK_DOWN, BIND_ACTION_SCROLLBACK_DOWN,
BIND_ACTION_SCROLLBACK_DOWN_HALF,
BIND_ACTION_CLIPBOARD_COPY, BIND_ACTION_CLIPBOARD_COPY,
BIND_ACTION_CLIPBOARD_PASTE, BIND_ACTION_CLIPBOARD_PASTE,
BIND_ACTION_PRIMARY_PASTE, BIND_ACTION_PRIMARY_PASTE,