diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2022-03-22 18:07:06 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2022-04-17 09:24:27 +0000 |
| commit | 501a9fbb5e1ec09c26cf61c464cf5b4ae6dba28a (patch) | |
| tree | b14ea152b7d8a93d3533c31c1024cdb059fe2b80 | |
| parent | changelog: scrollback search mode highlights all matches (diff) | |
url-mode: add a key binding that enables “persistent” URL mode
This is an alternative to ‘show-urls-launch’, where we stay in URL
mode after activating an URL.
Closes #964
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | config.c | 3 | ||||
| -rw-r--r-- | doc/foot.ini.5.scd | 9 | ||||
| -rw-r--r-- | foot.ini | 1 | ||||
| -rw-r--r-- | input.c | 10 | ||||
| -rw-r--r-- | terminal.h | 2 | ||||
| -rw-r--r-- | url-mode.c | 16 | ||||
| -rw-r--r-- | wayland.h | 3 |
8 files changed, 37 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5b8562..0f180e38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,10 @@ * `[csd].hide-when-maximized=yes|no` option (https://codeberg.org/dnkl/foot/issues/1019). * Scrollback search mode now highlights all matches. +* `[key-binding].show-urls-persistent` action. This key binding action + is similar to `show-urls-launch`, but does not automatically exit + URL mode after activating an URL + (https://codeberg.org/dnkl/foot/issues/964). ### Changed @@ -113,6 +113,7 @@ static const char *const binding_action_map[] = { [BIND_ACTION_PIPE_SELECTED] = "pipe-selected", [BIND_ACTION_SHOW_URLS_COPY] = "show-urls-copy", [BIND_ACTION_SHOW_URLS_LAUNCH] = "show-urls-launch", + [BIND_ACTION_SHOW_URLS_PERSISTENT] = "show-urls-persistent", [BIND_ACTION_TEXT_BINDING] = "text-binding", /* Mouse-specific actions */ @@ -516,7 +517,7 @@ value_to_wchars(struct context *ctx, char32_t **res) { char32_t *s = ambstoc32(ctx->value); if (s == NULL) { - LOG_CONTEXTUAL_ERR("not a valie string value"); + LOG_CONTEXTUAL_ERR("not a valid string value"); return false; } diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 37eb0068..e7dcf3f3 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -751,9 +751,14 @@ e.g. *search-start=none*. Default: _not bound_ *show-urls-launch* + Enter URL mode, where all currently visible URLs are tagged with a - jump label with a key sequence that will open the URL. Default: - _Control+Shift+u_. + jump label with a key sequence that will open the URL (and exit + URL mode). Default: _Control+Shift+u_. + +*show-urls-persistent* + Similar to *show-urls-launch*, but does not automatically exit URL + mode after activating an URL. Default: _none_. *show-urls-copy* Enter URL mode, where all currently visible URLs are tagged with a @@ -142,6 +142,7 @@ # pipe-selected=[xargs -r firefox] none # show-urls-launch=Control+Shift+u # show-urls-copy=none +# show-urls-persistent=none # noop=none [search-bindings] @@ -314,12 +314,14 @@ execute_binding(struct seat *seat, struct terminal *term, } case BIND_ACTION_SHOW_URLS_COPY: - case BIND_ACTION_SHOW_URLS_LAUNCH: { + case BIND_ACTION_SHOW_URLS_LAUNCH: + case BIND_ACTION_SHOW_URLS_PERSISTENT: { xassert(!urls_mode_is_active(term)); - enum url_action url_action = action == BIND_ACTION_SHOW_URLS_COPY - ? URL_ACTION_COPY - : URL_ACTION_LAUNCH; + enum url_action url_action = + action == BIND_ACTION_SHOW_URLS_COPY ? URL_ACTION_COPY : + action == BIND_ACTION_SHOW_URLS_LAUNCH ? URL_ACTION_LAUNCH : + URL_ACTION_PERSISTENT; urls_collect(term, url_action, &term->urls); urls_assign_key_combos(term->conf, &term->urls); @@ -291,7 +291,7 @@ enum overlay_style { typedef tll(struct ptmx_buffer) ptmx_buffer_list_t; -enum url_action { URL_ACTION_COPY, URL_ACTION_LAUNCH }; +enum url_action { URL_ACTION_COPY, URL_ACTION_LAUNCH, URL_ACTION_PERSISTENT }; struct url { uint64_t id; char *url; @@ -84,7 +84,8 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url) } break; - case URL_ACTION_LAUNCH: { + case URL_ACTION_LAUNCH: + case URL_ACTION_PERSISTENT: { size_t argc; char **argv; @@ -205,7 +206,18 @@ urls_input(struct seat *seat, struct terminal *term, uint32_t key, if (match) { activate_url(seat, term, match); - urls_reset(term); + + switch (match->action) { + case URL_ACTION_COPY: + case URL_ACTION_LAUNCH: + urls_reset(term); + break; + + case URL_ACTION_PERSISTENT: + term->url_keys[0] = U'\0'; + render_refresh_urls(term); + break; + } } else if (is_valid) { @@ -56,6 +56,7 @@ enum bind_action_normal { BIND_ACTION_PIPE_SELECTED, BIND_ACTION_SHOW_URLS_COPY, BIND_ACTION_SHOW_URLS_LAUNCH, + BIND_ACTION_SHOW_URLS_PERSISTENT, BIND_ACTION_TEXT_BINDING, /* Mouse specific actions - i.e. they require a mouse coordinate */ @@ -67,7 +68,7 @@ enum bind_action_normal { BIND_ACTION_SELECT_WORD_WS, BIND_ACTION_SELECT_ROW, - BIND_ACTION_KEY_COUNT = BIND_ACTION_SHOW_URLS_LAUNCH + 1, + BIND_ACTION_KEY_COUNT = BIND_ACTION_TEXT_BINDING + 1, BIND_ACTION_COUNT = BIND_ACTION_SELECT_ROW + 1, }; |
