Paste URL/regex selection to prompt if key is uppercase.

Fixes #1975.

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.
This commit is contained in:
Ryan Roden-Corrent 2025-04-28 19:56:32 -04:00
parent d7b48d3924
commit 6e810fb677
No known key found for this signature in database
GPG key ID: 435D8B10692555C9

View file

@ -277,6 +277,12 @@ urls_input(struct seat *seat, struct terminal *term,
switch (match->action) { switch (match->action) {
case URL_ACTION_COPY: case URL_ACTION_COPY:
// If the last hint character was uppercase, copy and paste
if (wc >= 'A' && wc <= 'Z') {
term_to_slave(term, match->url, strlen(match->url));
}
urls_reset(term);
break;
case URL_ACTION_LAUNCH: case URL_ACTION_LAUNCH:
urls_reset(term); urls_reset(term);
break; break;