mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
url-mode: add a key binding that enables “persistent” URL mode
This is an alternative to ‘show-urls-launch’, where we stay in URL mode after activating an URL. Closes #964
This commit is contained in:
parent
0062f4e133
commit
501a9fbb5e
8 changed files with 37 additions and 11 deletions
|
|
@ -56,6 +56,10 @@
|
||||||
* `[csd].hide-when-maximized=yes|no` option
|
* `[csd].hide-when-maximized=yes|no` option
|
||||||
(https://codeberg.org/dnkl/foot/issues/1019).
|
(https://codeberg.org/dnkl/foot/issues/1019).
|
||||||
* Scrollback search mode now highlights all matches.
|
* 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
|
### Changed
|
||||||
|
|
|
||||||
3
config.c
3
config.c
|
|
@ -113,6 +113,7 @@ static const char *const binding_action_map[] = {
|
||||||
[BIND_ACTION_PIPE_SELECTED] = "pipe-selected",
|
[BIND_ACTION_PIPE_SELECTED] = "pipe-selected",
|
||||||
[BIND_ACTION_SHOW_URLS_COPY] = "show-urls-copy",
|
[BIND_ACTION_SHOW_URLS_COPY] = "show-urls-copy",
|
||||||
[BIND_ACTION_SHOW_URLS_LAUNCH] = "show-urls-launch",
|
[BIND_ACTION_SHOW_URLS_LAUNCH] = "show-urls-launch",
|
||||||
|
[BIND_ACTION_SHOW_URLS_PERSISTENT] = "show-urls-persistent",
|
||||||
[BIND_ACTION_TEXT_BINDING] = "text-binding",
|
[BIND_ACTION_TEXT_BINDING] = "text-binding",
|
||||||
|
|
||||||
/* Mouse-specific actions */
|
/* Mouse-specific actions */
|
||||||
|
|
@ -516,7 +517,7 @@ value_to_wchars(struct context *ctx, char32_t **res)
|
||||||
{
|
{
|
||||||
char32_t *s = ambstoc32(ctx->value);
|
char32_t *s = ambstoc32(ctx->value);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
LOG_CONTEXTUAL_ERR("not a valie string value");
|
LOG_CONTEXTUAL_ERR("not a valid string value");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -751,9 +751,14 @@ e.g. *search-start=none*.
|
||||||
Default: _not bound_
|
Default: _not bound_
|
||||||
|
|
||||||
*show-urls-launch*
|
*show-urls-launch*
|
||||||
|
|
||||||
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 open the URL. Default:
|
jump label with a key sequence that will open the URL (and exit
|
||||||
_Control+Shift+u_.
|
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*
|
*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
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -142,6 +142,7 @@
|
||||||
# pipe-selected=[xargs -r firefox] none
|
# pipe-selected=[xargs -r firefox] none
|
||||||
# show-urls-launch=Control+Shift+u
|
# show-urls-launch=Control+Shift+u
|
||||||
# show-urls-copy=none
|
# show-urls-copy=none
|
||||||
|
# show-urls-persistent=none
|
||||||
# noop=none
|
# noop=none
|
||||||
|
|
||||||
[search-bindings]
|
[search-bindings]
|
||||||
|
|
|
||||||
10
input.c
10
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_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));
|
xassert(!urls_mode_is_active(term));
|
||||||
|
|
||||||
enum url_action url_action = action == BIND_ACTION_SHOW_URLS_COPY
|
enum url_action url_action =
|
||||||
? URL_ACTION_COPY
|
action == BIND_ACTION_SHOW_URLS_COPY ? URL_ACTION_COPY :
|
||||||
: URL_ACTION_LAUNCH;
|
action == BIND_ACTION_SHOW_URLS_LAUNCH ? URL_ACTION_LAUNCH :
|
||||||
|
URL_ACTION_PERSISTENT;
|
||||||
|
|
||||||
urls_collect(term, url_action, &term->urls);
|
urls_collect(term, url_action, &term->urls);
|
||||||
urls_assign_key_combos(term->conf, &term->urls);
|
urls_assign_key_combos(term->conf, &term->urls);
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ enum overlay_style {
|
||||||
|
|
||||||
typedef tll(struct ptmx_buffer) ptmx_buffer_list_t;
|
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 {
|
struct url {
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
char *url;
|
char *url;
|
||||||
|
|
|
||||||
16
url-mode.c
16
url-mode.c
|
|
@ -84,7 +84,8 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case URL_ACTION_LAUNCH: {
|
case URL_ACTION_LAUNCH:
|
||||||
|
case URL_ACTION_PERSISTENT: {
|
||||||
size_t argc;
|
size_t argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|
||||||
|
|
@ -205,7 +206,18 @@ urls_input(struct seat *seat, struct terminal *term, uint32_t key,
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
activate_url(seat, term, 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) {
|
else if (is_valid) {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ enum bind_action_normal {
|
||||||
BIND_ACTION_PIPE_SELECTED,
|
BIND_ACTION_PIPE_SELECTED,
|
||||||
BIND_ACTION_SHOW_URLS_COPY,
|
BIND_ACTION_SHOW_URLS_COPY,
|
||||||
BIND_ACTION_SHOW_URLS_LAUNCH,
|
BIND_ACTION_SHOW_URLS_LAUNCH,
|
||||||
|
BIND_ACTION_SHOW_URLS_PERSISTENT,
|
||||||
BIND_ACTION_TEXT_BINDING,
|
BIND_ACTION_TEXT_BINDING,
|
||||||
|
|
||||||
/* Mouse specific actions - i.e. they require a mouse coordinate */
|
/* 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_WORD_WS,
|
||||||
BIND_ACTION_SELECT_ROW,
|
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,
|
BIND_ACTION_COUNT = BIND_ACTION_SELECT_ROW + 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue