Skip to content

Instantly share code, notes, and snippets.

@cj1324
Last active November 1, 2017 05:45
Show Gist options
  • Save cj1324/7af3d4b80d7221fd0778 to your computer and use it in GitHub Desktop.
Save cj1324/7af3d4b80d7221fd0778 to your computer and use it in GitHub Desktop.
tilda-mouse-quick-copy-paste
diff -Naur tilda-tilda-1.3.3/src/tilda_terminal.c tilda-tilda-1.3.3-patch/src/tilda_terminal.c
--- tilda-tilda-1.3.3/src/tilda_terminal.c|-2016-04-18 20:09:55.000000000 +0800
+++ tilda-tilda-1.3.3-patch/src/tilda_terminal.c|---2017-02-03 17:49:23.293474235 +0800
@@ -48,6 +48,7 @@
#endif
static void window_title_changed_cb (GtkWidget *widget, gpointer data);
static int button_press_cb (GtkWidget *widget, GdkEventButton *event, gpointer data);
+static void selection_changed_cb (GtkWidget *widget, gpointer data);
static gboolean key_press_cb (GtkWidget *widget, GdkEvent *event, tilda_term *terminal);
static void iconify_window_cb (GtkWidget *widget, gpointer data);
static void deiconify_window_cb (GtkWidget *widget, gpointer data);
@@ -183,6 +184,8 @@
G_CALLBACK(move_window_cb), tw->window);
g_signal_connect (G_OBJECT (tw->notebook), "switch-page",
G_CALLBACK (tilda_terminal_switch_page_cb), tw);
+ g_signal_connect (G_OBJECT(term->vte_term), "selection-changed",
+ G_CALLBACK(selection_changed_cb), term);
=
/* Match URL's, etc */
term->http_regexp=g_regex_new(HTTP_REGEXP, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, &error);
@@ -282,6 +285,16 @@
g_print ("Status = `%s'.\n", vte_terminal_get_status_line (VTE_TERMINAL(widget)));
}
#endif
+static void selection_changed_cb (GtkWidget *widget, gpointer data)
+{
+ DEBUG_FUNCTION ("status_line_changed_cb");
+ DEBUG_ASSERT (widget != NULL);
+ DEBUG_ASSERT (data != NULL);
+ tilda_term *tt = TILDA_TERM(data);
+ if (vte_terminal_get_has_selection(VTE_TERMINAL(tt->vte_term))){
+ vte_terminal_copy_clipboard (VTE_TERMINAL (tt->vte_term));
+ }
+}
=
static void iconify_window_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
{
@@ -1021,9 +1034,10 @@
tilda_window_prev_tab (tt->tw);
break;
case 3: /* Right Click */
- popup_menu (tt->tw, tt);
+ vte_terminal_paste_clipboard (VTE_TERMINAL (tt->vte_term));
break;
case 2: /* Middle Click */
+ popup_menu (tt->tw, tt);
break;
case 1: /* Left Click */
terminal = VTE_TERMINAL(tt->vte_term);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment