add url regex matching

This commit is contained in:
Daniel Micay 2012-05-22 05:10:54 -04:00
parent 48bbf2e1bd
commit 5dcbb38ed3
2 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,8 @@
#include <stdbool.h> #include <stdbool.h>
static const char *url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+]*";
static const char *font = "Consolas 9"; static const char *font = "Consolas 9";
static const long scrollback_lines = 1000; static const long scrollback_lines = 1000;

9
term.c
View File

@ -134,6 +134,15 @@ int main(int argc, char **argv) {
vte_terminal_set_mouse_autohide(VTE_TERMINAL(vte), mouse_autohide); vte_terminal_set_mouse_autohide(VTE_TERMINAL(vte), mouse_autohide);
vte_terminal_set_backspace_binding(VTE_TERMINAL(vte), VTE_ERASE_ASCII_BACKSPACE); vte_terminal_set_backspace_binding(VTE_TERMINAL(vte), VTE_ERASE_ASCII_BACKSPACE);
// url matching
int tmp = vte_terminal_match_add_gregex(VTE_TERMINAL(vte),
g_regex_new(url_regex,
G_REGEX_CASELESS,
G_REGEX_MATCH_NOTEMPTY,
NULL),
0);
vte_terminal_match_set_cursor_type(VTE_TERMINAL(vte), tmp, GDK_HAND2);
// set colors // set colors
GdkColor foreground, background; GdkColor foreground, background;
gdk_color_parse(foreground_color, &foreground); gdk_color_parse(foreground_color, &foreground);