mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
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.
This commit is contained in:
parent
183fd96aba
commit
0ea572dc63
3 changed files with 21 additions and 5 deletions
|
|
@ -85,8 +85,11 @@
|
||||||
- paper-color
|
- paper-color
|
||||||
- selenized
|
- selenized
|
||||||
- solarized
|
- solarized
|
||||||
|
* `regex-copy`/`show-urls-copy` will copy and paste the selected text if the hint
|
||||||
|
is completed with an uppercase character ([#1975][1975]).
|
||||||
|
|
||||||
[2025]: https://codeberg.org/dnkl/foot/issues/2025
|
[2025]: https://codeberg.org/dnkl/foot/issues/2025
|
||||||
|
[1975]: https://codeberg.org/dnkl/foot/issues/1975
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
|
|
@ -1358,7 +1358,8 @@ e.g. *search-start=none*.
|
||||||
*show-urls-copy*
|
*show-urls-copy*
|
||||||
Enter URL mode, where all currently visible URLs are tagged with a
|
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
|
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: _none_.
|
||||||
|
|
||||||
*regex-launch*
|
*regex-launch*
|
||||||
Enter regex mode. This works exactly the same as URL mode; all
|
Enter regex mode. This works exactly the same as URL mode; all
|
||||||
|
|
@ -1381,8 +1382,10 @@ e.g. *search-start=none*.
|
||||||
Default: _none_.
|
Default: _none_.
|
||||||
|
|
||||||
*regex-copy*
|
*regex-copy*
|
||||||
Same as *regex-copy*, but the match is placed in the clipboard,
|
Same as *regex-launch*, but the match is placed in the clipboard,
|
||||||
instead of "launched", upon activation. Default: _none_.
|
instead of "launched", upon activation. If the hint is completed
|
||||||
|
with an uppercase character, the match will also be pasted.
|
||||||
|
Default: _none_.
|
||||||
|
|
||||||
*prompt-prev*
|
*prompt-prev*
|
||||||
Jump to the previous, currently not visible, prompt (requires
|
Jump to the previous, currently not visible, prompt (requires
|
||||||
|
|
|
||||||
14
url-mode.c
14
url-mode.c
|
|
@ -131,7 +131,7 @@ spawn_url_launcher(struct seat *seat, struct terminal *term, const char *url,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
activate_url(struct seat *seat, struct terminal *term, const struct url *url,
|
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;
|
char *url_string = NULL;
|
||||||
|
|
||||||
|
|
@ -159,6 +159,15 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url,
|
||||||
|
|
||||||
switch (url->action) {
|
switch (url->action) {
|
||||||
case URL_ACTION_COPY:
|
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)) {
|
if (text_to_clipboard(seat, term, url_string, seat->kbd.serial)) {
|
||||||
/* Now owned by our clipboard “manager” */
|
/* Now owned by our clipboard “manager” */
|
||||||
url_string = NULL;
|
url_string = NULL;
|
||||||
|
|
@ -273,7 +282,8 @@ urls_input(struct seat *seat, struct terminal *term,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
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) {
|
switch (match->action) {
|
||||||
case URL_ACTION_COPY:
|
case URL_ACTION_COPY:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue