aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormutantturkey <mutantturkey@gmail.com>2012-08-29 10:10:50 -0400
committermutantturkey <mutantturkey@gmail.com>2012-08-29 10:10:50 -0400
commit2eb70ceccc5f8639bbf4cc50af7e5dac9d42a894 (patch)
tree22fd5fba83367ea004f28d42358a4ca8692f9784
parent09e8d2d214deaa6e0af3c4dfefb8c10b8df6e16e (diff)
added a URL opener, by default using the xdg-open program. This is a setting in defaults.h
-rw-r--r--defaults.h10
-rw-r--r--svte.c25
2 files changed, 34 insertions, 1 deletions
diff --git a/defaults.h b/defaults.h
index a2ede96..3e36bf8 100644
--- a/defaults.h
+++ b/defaults.h
@@ -17,13 +17,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef DEFAULT_BROWSER_COMMAND
+#define DEFAULT_BROWSER_COMMAND "xdg-open"
+#endif
#ifndef DEFAULT_CONFIG_FILE
#define DEFAULT_CONFIG_FILE g_build_path("/", g_get_home_dir(), ".svterc", NULL);
#endif
+
#ifndef DEFAULT_FONT
#define DEFAULT_FONT "monospace 10"
#endif
+
#ifndef DEFAULT_URL_REGEX
#define DEFAULT_URL_REGEX "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+]*"
#endif
@@ -32,17 +37,22 @@
#ifndef DEFAULT_FULLSCREEN
#define DEFAULT_FULLSCREEN TRUE
#endif
+
#ifndef DEFAULT_ALLOW_BOLD
#define DEFAULT_ALLOW_BOLD TRUE
#endif
+
#ifndef DEFAULT_NUM_SCROLLBACK_LINES
#define DEFAULT_NUM_SCROLLBACK_LINES -1
#endif
+
#ifndef DEFAULT_TRANSPARENT_BG
#define DEFAULT_TRANSPARENT_BG FALSE
#endif
+
#ifndef DEFAULT_PALETTE_SIZE
#define DEFAULT_PALETTE_SIZE 16
#endif
+
#define DEFAULT_FOREGROUND_COLOR "#c0c0c0"
#define DEFAULT_BACKGROUND_COLOR "#000"
diff --git a/svte.c b/svte.c
index 76013fc..10bb28a 100644
--- a/svte.c
+++ b/svte.c
@@ -74,6 +74,8 @@ static void configure_window();
static void tab_focus(GtkNotebook *notebook, GtkNotebookPage *page,
guint page_num, gpointer user_data);
static void set_window_title(term *t);
+static void launch_url(char *url);
+
static inline term* get_current_term();
static inline term* get_nth_term(guint page);
@@ -109,6 +111,12 @@ static inline term* get_current_term(){
return t;
}
+
+static void launch_url(char *url) {
+ g_spawn_command_line_async(g_strconcat(DEFAULT_BROWSER_COMMAND, " ", url, NULL), NULL);
+}
+
+
/* key event handler */
gboolean event_key(GtkWidget *widget, GdkEventKey *event) {
guint(g) = event->keyval;
@@ -161,6 +169,21 @@ gboolean event_key(GtkWidget *widget, GdkEventKey *event) {
/* button event handler */
gboolean event_button(GtkWidget *widget, GdkEventButton *button_event, struct term *t) {
+
+ glong col = 0;
+ glong row = 0;
+ int ret = 0;
+ gchar *match;
+
+ if(button_event->button == 1) {
+ match = vte_terminal_match_check(VTE_TERMINAL(t->vte),
+ button_event->x / vte_terminal_get_char_width (VTE_TERMINAL (t->vte)),
+ button_event->y / vte_terminal_get_char_height (VTE_TERMINAL (t->vte)),
+ &ret);
+ launch_url(match);
+ return TRUE;
+
+ }
return FALSE;
}
@@ -394,7 +417,7 @@ static void configure_window() {
tab_new();
gtk_widget_show_all(svte.win);
-
+
/* add the callback signals */
g_signal_connect(G_OBJECT(svte.win), "destroy", G_CALLBACK(quit), NULL);
g_signal_connect(svte.win, "key-press-event", G_CALLBACK(event_key), NULL);