From b400903e25de321dffd310e30d76dad121ccceb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 10 Apr 2024 19:26:23 +0200 Subject: [PATCH] config: add new key-binding 'quit', unbound by default Closes #1475 --- CHANGELOG.md | 2 ++ config.c | 1 + doc/foot.ini.5.scd | 3 +++ foot.ini | 1 + input.c | 4 ++++ key-binding.h | 3 ++- 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d824c2a..96c7c8bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,8 +55,10 @@ * `cursor.unfocused-style=unchanged|hollow|none` to `foot.ini`. The default is `hollow` ([#1582][1582]). +* New key binding: `quit` ([#1475][1475]). [1582]: https://codeberg.org/dnkl/foot/issues/1582 +[1475]: https://codeberg.org/dnkl/foot/issues/1475 ### Changed diff --git a/config.c b/config.c index 6a8bb0a8..d63934b3 100644 --- a/config.c +++ b/config.c @@ -119,6 +119,7 @@ static const char *const binding_action_map[] = { [BIND_ACTION_PROMPT_PREV] = "prompt-prev", [BIND_ACTION_PROMPT_NEXT] = "prompt-next", [BIND_ACTION_UNICODE_INPUT] = "unicode-input", + [BIND_ACTION_QUIT] = "quit", /* Mouse-specific actions */ [BIND_ACTION_SCROLLBACK_UP_MOUSE] = "scrollback-up-mouse", diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 8cd0560f..a3ddb7c3 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -925,6 +925,9 @@ e.g. *search-start=none*. Default: _Control+Shift+u_. +*quit* + Quit foot. Default: _none_. + # SECTION: search-bindings This section lets you override the default key bindings used in diff --git a/foot.ini b/foot.ini index 9fd6c9db..a2c85e97 100644 --- a/foot.ini +++ b/foot.ini @@ -193,6 +193,7 @@ # clipboard-paste=Control+v Control+Shift+v Control+y XF86Paste # primary-paste=Shift+Insert # unicode-input=none +# quit=none # scrollback-up-page=Shift+Page_Up # scrollback-up-half-page=none # scrollback-up-line=none diff --git a/input.c b/input.c index 1a42e5ee..26f62629 100644 --- a/input.c +++ b/input.c @@ -444,6 +444,10 @@ execute_binding(struct seat *seat, struct terminal *term, unicode_mode_activate(seat); return true; + case BIND_ACTION_QUIT: + term_shutdown(term); + return true; + case BIND_ACTION_SELECT_BEGIN: selection_start( term, seat->mouse.col, seat->mouse.row, SELECTION_CHAR_WISE, false); diff --git a/key-binding.h b/key-binding.h index ba841efa..f42dbc48 100644 --- a/key-binding.h +++ b/key-binding.h @@ -40,6 +40,7 @@ enum bind_action_normal { BIND_ACTION_PROMPT_PREV, BIND_ACTION_PROMPT_NEXT, BIND_ACTION_UNICODE_INPUT, + BIND_ACTION_QUIT, /* Mouse specific actions - i.e. they require a mouse coordinate */ BIND_ACTION_SCROLLBACK_UP_MOUSE, @@ -53,7 +54,7 @@ enum bind_action_normal { BIND_ACTION_SELECT_QUOTE, BIND_ACTION_SELECT_ROW, - BIND_ACTION_KEY_COUNT = BIND_ACTION_UNICODE_INPUT + 1, + BIND_ACTION_KEY_COUNT = BIND_ACTION_QUIT + 1, BIND_ACTION_COUNT = BIND_ACTION_SELECT_ROW + 1, };