move CLICKABLE_URL setting to config
This commit is contained in:
parent
859a0b2022
commit
dba6bc7357
4
config.h
4
config.h
|
@ -1,10 +1,6 @@
|
||||||
#define CLICKABLE_URL
|
|
||||||
|
|
||||||
static const char *url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+]*";
|
static const char *url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+]*";
|
||||||
|
|
||||||
#ifdef CLICKABLE_URL
|
|
||||||
#define URL_COMMAND(URL_MATCH) {"/usr/bin/firefox", URL_MATCH, NULL}
|
#define URL_COMMAND(URL_MATCH) {"/usr/bin/firefox", URL_MATCH, NULL}
|
||||||
#endif
|
|
||||||
|
|
||||||
// 0.0: opaque, 1.0: transparent
|
// 0.0: opaque, 1.0: transparent
|
||||||
//#define TRANSPARENCY 0.2
|
//#define TRANSPARENCY 0.2
|
||||||
|
|
17
termite.c
17
termite.c
|
@ -175,7 +175,6 @@ static gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, search_panel_
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CLICKABLE_URL
|
|
||||||
static void get_vte_padding(VteTerminal *vte, int *w, int *h) {
|
static void get_vte_padding(VteTerminal *vte, int *w, int *h) {
|
||||||
GtkBorder *border = NULL;
|
GtkBorder *border = NULL;
|
||||||
gtk_widget_style_get(GTK_WIDGET(vte), "inner-border", &border, NULL);
|
gtk_widget_style_get(GTK_WIDGET(vte), "inner-border", &border, NULL);
|
||||||
|
@ -208,7 +207,6 @@ static gboolean button_press_cb(VteTerminal *vte, GdkEventButton *event) {
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void beep_handler(GtkWindow *window) {
|
static void beep_handler(GtkWindow *window) {
|
||||||
gtk_window_set_urgency_hint(window, TRUE);
|
gtk_window_set_urgency_hint(window, TRUE);
|
||||||
|
@ -243,7 +241,9 @@ static gboolean position_overlay_cb(GtkBin *overlay, GtkWidget *widget, GdkRecta
|
||||||
|
|
||||||
#define IGNORE_ON_ERROR(ERROR) if (ERROR) g_clear_error(&ERROR); else
|
#define IGNORE_ON_ERROR(ERROR) if (ERROR) g_clear_error(&ERROR); else
|
||||||
|
|
||||||
static void load_config(GtkWindow *window, VteTerminal *vte, gboolean *dynamic_title, gboolean *urgent_on_bell) {
|
static void load_config(GtkWindow *window, VteTerminal *vte,
|
||||||
|
gboolean *dynamic_title, gboolean *urgent_on_bell,
|
||||||
|
gboolean *clickable_url) {
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GKeyFile *config = g_key_file_new();
|
GKeyFile *config = g_key_file_new();
|
||||||
if (!g_key_file_load_from_file(config, "termite.cfg", G_KEY_FILE_NONE, &error)) {
|
if (!g_key_file_load_from_file(config, "termite.cfg", G_KEY_FILE_NONE, &error)) {
|
||||||
|
@ -286,6 +286,9 @@ static void load_config(GtkWindow *window, VteTerminal *vte, gboolean *dynamic_t
|
||||||
*urgent_on_bell = g_key_file_get_boolean(config, "options", "urgent_on_bell", &error);
|
*urgent_on_bell = g_key_file_get_boolean(config, "options", "urgent_on_bell", &error);
|
||||||
g_clear_error(&error);
|
g_clear_error(&error);
|
||||||
|
|
||||||
|
*clickable_url = g_key_file_get_boolean(config, "options", "clickable_url", &error);
|
||||||
|
g_clear_error(&error);
|
||||||
|
|
||||||
gchar *font = g_key_file_get_string(config, "options", "font", &error);
|
gchar *font = g_key_file_get_string(config, "options", "font", &error);
|
||||||
IGNORE_ON_ERROR(error) {
|
IGNORE_ON_ERROR(error) {
|
||||||
vte_terminal_set_font_from_string(vte, font);
|
vte_terminal_set_font_from_string(vte, font);
|
||||||
|
@ -410,8 +413,8 @@ int main(int argc, char **argv) {
|
||||||
g_signal_connect(entry, "key-press-event", G_CALLBACK(entry_key_press_cb), &info);
|
g_signal_connect(entry, "key-press-event", G_CALLBACK(entry_key_press_cb), &info);
|
||||||
g_signal_connect(overlay, "get-child-position", G_CALLBACK(position_overlay_cb), NULL);
|
g_signal_connect(overlay, "get-child-position", G_CALLBACK(position_overlay_cb), NULL);
|
||||||
|
|
||||||
gboolean dynamic_title = FALSE, urgent_on_bell = FALSE;
|
gboolean dynamic_title = FALSE, urgent_on_bell = FALSE, clickable_url = FALSE;
|
||||||
load_config(GTK_WINDOW(window), VTE_TERMINAL(vte), &dynamic_title, &urgent_on_bell);
|
load_config(GTK_WINDOW(window), VTE_TERMINAL(vte), &dynamic_title, &urgent_on_bell, &clickable_url);
|
||||||
|
|
||||||
#ifdef TRANSPARENCY
|
#ifdef TRANSPARENCY
|
||||||
GdkScreen *screen = gtk_widget_get_screen(window);
|
GdkScreen *screen = gtk_widget_get_screen(window);
|
||||||
|
@ -437,7 +440,7 @@ int main(int argc, char **argv) {
|
||||||
vte_terminal_set_colors(VTE_TERMINAL(vte), &foreground, &background, palette, 16);
|
vte_terminal_set_colors(VTE_TERMINAL(vte), &foreground, &background, palette, 16);
|
||||||
vte_terminal_set_color_cursor(VTE_TERMINAL(vte), &cursor);
|
vte_terminal_set_color_cursor(VTE_TERMINAL(vte), &cursor);
|
||||||
|
|
||||||
#ifdef CLICKABLE_URL
|
if (clickable_url) {
|
||||||
int tmp = vte_terminal_match_add_gregex(VTE_TERMINAL(vte),
|
int tmp = vte_terminal_match_add_gregex(VTE_TERMINAL(vte),
|
||||||
g_regex_new(url_regex,
|
g_regex_new(url_regex,
|
||||||
G_REGEX_CASELESS,
|
G_REGEX_CASELESS,
|
||||||
|
@ -446,7 +449,7 @@ int main(int argc, char **argv) {
|
||||||
(GRegexMatchFlags)0);
|
(GRegexMatchFlags)0);
|
||||||
vte_terminal_match_set_cursor_type(VTE_TERMINAL(vte), tmp, GDK_HAND2);
|
vte_terminal_match_set_cursor_type(VTE_TERMINAL(vte), tmp, GDK_HAND2);
|
||||||
g_signal_connect(vte, "button-press-event", G_CALLBACK(button_press_cb), NULL);
|
g_signal_connect(vte, "button-press-event", G_CALLBACK(button_press_cb), NULL);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (urgent_on_bell) {
|
if (urgent_on_bell) {
|
||||||
g_signal_connect_swapped(vte, "beep", G_CALLBACK(beep_handler), window);
|
g_signal_connect_swapped(vte, "beep", G_CALLBACK(beep_handler), window);
|
||||||
|
|
|
@ -7,6 +7,7 @@ visible_bell = false
|
||||||
mouse_autohide = false
|
mouse_autohide = false
|
||||||
dynamic_title = true
|
dynamic_title = true
|
||||||
urgent_on_bell = true
|
urgent_on_bell = true
|
||||||
|
clickable_url = true
|
||||||
font = Monospace 9
|
font = Monospace 9
|
||||||
scrollback_lines = 1000
|
scrollback_lines = 1000
|
||||||
#icon_name = terminal
|
#icon_name = terminal
|
||||||
|
|
Loading…
Reference in New Issue