xF: add a binding to open the last link
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success

Better than nothing.
This commit is contained in:
2026-08-08 08:57:38 +02:00
parent 8ce60cdd2f
commit c413f6d4b2
+32
View File
@@ -274,6 +274,7 @@ enum action
ACTION_LOG,
ACTION_EDIT_INPUT,
ACTION_VIEW_TRANSCRIPT,
ACTION_OPEN,
ACTION_FORMAT,
ACTION_FORMAT_BOLD,
ACTION_FORMAT_ITALIC,
@@ -3498,6 +3499,34 @@ app_open (const char *object)
;
}
static bool
app_open_link (struct buffer_line_item *item)
{
if (!(item->style & BUFFER_LINE_ITEM_LINK_START))
return false;
struct str link = str_make ();
do str_append (&link, item->text);
while ((item = item->next) && item->style & BUFFER_LINE_ITEM_LINK);
app_open (link.str);
str_free (&link);
return true;
}
static bool
app_open_last_link (void)
{
if (!g.buffer_current)
return false;
struct buffer *b = g.buffer_current;
LIST_FOR_EACH_REVERSED (struct buffer_line, line, b->lines_tail)
LIST_FOR_EACH (struct buffer_line_item, item, line->items)
if (app_open_link (item))
return true;
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static char *
@@ -3834,6 +3863,8 @@ app_process_action (enum action action)
return app_launch_external_editor (false);
case ACTION_VIEW_TRANSCRIPT:
return app_launch_external_editor (true);
case ACTION_OPEN:
return app_open_last_link ();
case ACTION_FORMAT:
g.inserting_attribute = true;
return true;
@@ -3998,6 +4029,7 @@ g_default_bindings[] =
{ "M-h", ACTION_LOG },
{ "M-e", ACTION_EDIT_INPUT },
{ "M-E", ACTION_VIEW_TRANSCRIPT },
{ "C-o", ACTION_OPEN },
{ "M-m", ACTION_FORMAT },
{ "PageUp", ACTION_SCROLL_UP },
{ "PageDown", ACTION_SCROLL_DOWN },