add binding to open urls
This commit is contained in:
parent
b2f90f4e48
commit
381316b6f7
|
@ -36,6 +36,7 @@ COMMAND MODE
|
||||||
* ``?``: reverse search
|
* ``?``: reverse search
|
||||||
* ``u``: forward url search
|
* ``u``: forward url search
|
||||||
* ``U``: reverse url search
|
* ``U``: reverse url search
|
||||||
|
* ``Return``: open the current selection as a url
|
||||||
* ``n``: next search match
|
* ``n``: next search match
|
||||||
* ``N``: previous search match
|
* ``N``: previous search match
|
||||||
|
|
||||||
|
|
11
termite.c
11
termite.c
|
@ -6,6 +6,7 @@
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <vte/vte.h>
|
#include <vte/vte.h>
|
||||||
|
#include <vte/vteaccess.h>
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
# define __attribute__(x)
|
# define __attribute__(x)
|
||||||
|
@ -192,6 +193,13 @@ static void move_to_row_start(VteTerminal *vte, select_info *select, long row) {
|
||||||
update_selection(vte, select);
|
update_selection(vte, select);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void open_selection(VteTerminal *vte) {
|
||||||
|
AtkText *text = ATK_TEXT(vte_terminal_accessible_new(vte));
|
||||||
|
char *selection = atk_text_get_selection(text, 0, NULL, NULL);
|
||||||
|
launch_browser(selection);
|
||||||
|
g_free(selection);
|
||||||
|
}
|
||||||
|
|
||||||
/* {{{ CALLBACKS */
|
/* {{{ CALLBACKS */
|
||||||
void window_title_cb(VteTerminal *vte, gboolean *dynamic_title) {
|
void window_title_cb(VteTerminal *vte, gboolean *dynamic_title) {
|
||||||
const char * const title = *dynamic_title ? vte_terminal_get_window_title(vte) : NULL;
|
const char * const title = *dynamic_title ? vte_terminal_get_window_title(vte) : NULL;
|
||||||
|
@ -271,6 +279,9 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info)
|
||||||
case GDK_KEY_U:
|
case GDK_KEY_U:
|
||||||
search(vte, url_regex, true);
|
search(vte, url_regex, true);
|
||||||
break;
|
break;
|
||||||
|
case GDK_KEY_Return:
|
||||||
|
open_selection(vte);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue