xF: add a binding to open the last link
Better than nothing.
This commit is contained in:
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user