diff options
| author | Ryan Roden-Corrent <git@rrc.codes> | 2025-04-28 23:56:32 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2025-05-01 11:53:11 +0000 |
| commit | 0ea572dc63083e0d415382da2df8050a70f8cd07 (patch) | |
| tree | 7d0bb4d02fa0d554bc72eef4c4af7fac66204d8c /url-mode.c | |
| parent | Merge branch 'releases/1.22' (diff) | |
Paste URL/regex selection to prompt if key is uppercase.
In copy-regex/show-urls-copy mode, if the last input character was
uppercase, copy the selection to the clipboard _and_ paste it. This is
useful for taking a file path from a command output:(log, git, test
failure, etc.) and using it in another command.
This is inspired by the behavior of copy mode in wezterm:
https://wezterm.org/quickselect.html
I could have made it check every character in the hint, but it seemed
fine to assume that if the last character was uppercase, the user
wanted this behavior.
Closes #1975.
Diffstat (limited to 'url-mode.c')
| -rw-r--r-- | url-mode.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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,7 +282,8 @@ 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: |
