From b3e4e125d003d280c06523efe541c8f880f4255a Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Wed, 30 Apr 2025 16:03:30 -0400 Subject: [PATCH] Fix doc, move logic to activate_url. --- doc/foot.ini.5.scd | 7 ++++--- url-mode.c | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 4a14884c..004565cd 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -1348,8 +1348,7 @@ e.g. *search-start=none*. *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 (and exit - URL mode). If the hint is completed with an uppercase character, - the match will also be pasted. Default: _Control+Shift+o_. + URL mode). *show-urls-persistent* Similar to *show-urls-launch*, but does not automatically exit URL @@ -1358,7 +1357,9 @@ e.g. *search-start=none*. *show-urls-copy* Enter URL mode, where all currently visible URLs are tagged with a jump label with a key sequence that will place the URL in the - clipboard. Default: _none_. + clipboard. If the hint is completed with an uppercase character, + the match will also be pasted. Default: _Control+Shift+o_. + Default: _none_. *regex-launch* Enter regex mode. This works exactly the same as URL mode; all diff --git a/url-mode.c b/url-mode.c index 19193b64..73240164 100644 --- a/url-mode.c +++ b/url-mode.c @@ -131,7 +131,7 @@ spawn_url_launcher(struct seat *seat, struct terminal *term, const char *url, static void activate_url(struct seat *seat, struct terminal *term, const struct url *url, - uint32_t serial) + uint32_t serial, bool paste_url_to_self) { char *url_string = NULL; @@ -159,6 +159,15 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url, switch (url->action) { case URL_ACTION_COPY: + if (paste_url_to_self) { + if (term->bracketed_paste) + term_to_slave(term, "\033[200~", 6); + + term_to_slave(term, url_string, strlen(url_string)); + + if (term->bracketed_paste) + term_to_slave(term, "\033[201~", 6); + } if (text_to_clipboard(seat, term, url_string, seat->kbd.serial)) { /* Now owned by our clipboard “manager” */ url_string = NULL; @@ -273,20 +282,11 @@ urls_input(struct seat *seat, struct terminal *term, } if (match) { - activate_url(seat, term, match, serial); + // If the last hint character was uppercase, copy and paste + activate_url(seat, term, match, serial, wc == toc32upper(wc)); switch (match->action) { case URL_ACTION_COPY: - // If the last hint character was uppercase, copy and paste - if (wc == toc32upper(wc)) { - if (term->bracketed_paste) - term_to_slave(term, "\033[200~", 6); - - term_to_slave(term, match->url, strlen(match->url)); - - if (term->bracketed_paste) - term_to_slave(term, "\033[201~", 6); - } urls_reset(term); break; case URL_ACTION_LAUNCH: