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 diff --git a/config.c b/config.c index fee47c03..f9ddf5e4 100644 --- a/config.c +++ b/config.c @@ -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 diff --git a/foot.ini b/foot.ini index dd17f510..abd3c412 100644 --- a/foot.ini +++ b/foot.ini @@ -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] diff --git a/input.c b/input.c index 29ac80ae..403ee965 100644 --- a/input.c +++ b/input.c @@ -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); diff --git a/terminal.h b/terminal.h index 76375d8e..042af6dc 100644 --- a/terminal.h +++ b/terminal.h @@ -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; diff --git a/url-mode.c b/url-mode.c index a283c27e..5b144e9f 100644 --- a/url-mode.c +++ b/url-mode.c @@ -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) { diff --git a/wayland.h b/wayland.h index 51b43e37..ff4f2d77 100644 --- a/wayland.h +++ b/wayland.h @@ -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, };