config: add new mouse binding ‘launch-url’, bind to alt+BTN_LEFT

This adds a new mouse binding, launch-url (bound to Alt+BTN_LEFT by
default). When executed, the URL under the mouse pointer is
launched (with url.launcher, as usual).

This is done by calling urls_collect(), to get all currently visible
URLs (both auto-detected and OSC-8 ones), and then iterating them all
until we find one that spans the cell the mouse pointer is on.
This commit is contained in:
Daniel Eklöf 2022-06-17 18:45:28 +02:00
parent 8b882b3a13
commit 16d220d3f9
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 39 additions and 1 deletions

View file

@ -126,6 +126,7 @@ static const char *const binding_action_map[] = {
[BIND_ACTION_SELECT_WORD] = "select-word",
[BIND_ACTION_SELECT_WORD_WS] = "select-word-whitespace",
[BIND_ACTION_SELECT_ROW] = "select-row",
[BIND_ACTION_LAUNCH_URL] = "launch-url",
};
static const char *const search_binding_action_map[] = {
@ -2745,6 +2746,7 @@ add_default_mouse_bindings(struct config *conf)
{BIND_ACTION_SELECT_WORD, m_none, {.m = {BTN_LEFT, 2}}},
{BIND_ACTION_SELECT_WORD_WS, m_ctrl, {.m = {BTN_LEFT, 2}}},
{BIND_ACTION_SELECT_ROW, m_none, {.m = {BTN_LEFT, 3}}},
{BIND_ACTION_LAUNCH_URL, m_alt, {.m = {BTN_LEFT, 1}}},
};
conf->bindings.mouse.count = ALEN(bindings);