Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/configsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ static cfg_opt_t config_opts[] = {
CFG_BOOL("match_email_addresses", TRUE, CFGF_NONE),
CFG_BOOL("match_numbers", TRUE, CFGF_NONE),

/* Whether to automatically copy selected text to clipboard */
CFG_BOOL("copy_on_selection", FALSE, CFGF_NONE),

/* if set to TRUE, tilda will fall back to open
* URIs with the 'web_browser' option. */
CFG_BOOL("use_custom_web_browser", FALSE, CFGF_NONE),
Expand Down
22 changes: 19 additions & 3 deletions src/tilda.ui
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label-xalign">0</property>
<child>
<!-- n-columns=2 n-rows=1 -->
<!-- n-columns=2 n-rows=2 -->
<object class="GtkGrid" id="grid_select_by_word">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand All @@ -976,7 +976,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Word Characters:</property>
<property name="label" translatable="yes">Select by Word Characters:</property>
<property name="xalign">1</property>
</object>
<packing>
Expand All @@ -995,14 +995,30 @@
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_copy_on_selection">
<property name="label" translatable="yes">Copy on Selection</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Automatically copy selected text to clipboard</property>
<property name="halign">start</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Select by Word&lt;/b&gt;</property>
<property name="label" translatable="yes">&lt;b&gt;Selection&lt;/b&gt;</property>
<property name="use-markup">True</property>
</object>
</child>
Expand Down
19 changes: 19 additions & 0 deletions src/tilda_terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static void maximize_window_cb (GtkWidget *widget, gpointer data);
static void restore_window_cb (GtkWidget *widget, gpointer data);
static void refresh_window_cb (GtkWidget *widget, gpointer data);
static void move_window_cb (GtkWidget *widget, guint x, guint y, gpointer data);
static void selection_changed_cb (VteTerminal *terminal, gpointer data);

static gchar *get_default_command (void);
gchar *get_working_directory (tilda_term *terminal);
Expand Down Expand Up @@ -218,6 +219,8 @@ struct tilda_term_ *tilda_term_init (struct tilda_window_ *tw, gint index)
G_CALLBACK(refresh_window_cb), tw->window);
g_signal_connect (G_OBJECT(term->vte_term), "move-window",
G_CALLBACK(move_window_cb), tw->window);
g_signal_connect (G_OBJECT(term->vte_term), "selection-changed",
G_CALLBACK(selection_changed_cb), term);

TildaMatchRegistry * registry = tilda_match_registry_new ();
term->registry = registry;
Expand Down Expand Up @@ -906,6 +909,22 @@ static void handle_left_button_click (GtkWidget * window,
}
}

static void selection_changed_cb (VteTerminal *terminal, gpointer data)
{
DEBUG_FUNCTION ("selection_changed_cb");
DEBUG_ASSERT (terminal != NULL);

/* Only proceed if copy_on_selection is enabled */
if (!config_getbool("copy_on_selection")) {
return;
}

/* Only copy if there is an actual selection (not when selection is cleared) */
if (vte_terminal_get_has_selection(terminal)) {
vte_terminal_copy_clipboard_format(terminal, VTE_FORMAT_TEXT);
}
}

gchar * tilda_terminal_get_full_title (tilda_term *tt)
{
DEBUG_FUNCTION ("tilda_terminal_get_title");
Expand Down
8 changes: 8 additions & 0 deletions src/wizard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,12 @@ static void check_scroll_on_keystroke_toggled_cb (GtkWidget *w, tilda_window *tw
}
}

static void check_copy_on_selection_toggled_cb (GtkWidget *w, tilda_window *tw)
{
const gboolean status = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
config_setbool ("copy_on_selection", status);
}

static void combo_backspace_binding_changed_cb (GtkWidget *w, tilda_window *tw)
{
const gint status = gtk_combo_box_get_active (GTK_COMBO_BOX(w));
Expand Down Expand Up @@ -1986,6 +1992,7 @@ static void initialize_scrollback_settings(void) {

CHECK_BUTTON ("check_scroll_on_output", "scroll_on_output");
CHECK_BUTTON ("check_scroll_on_keystroke", "scroll_on_key");
CHECK_BUTTON ("check_copy_on_selection", "copy_on_selection");
}

static void initialize_set_as_desktop_checkbox (void) {
Expand Down Expand Up @@ -2109,6 +2116,7 @@ static void connect_wizard_signals (TildaWizard *wizard)
CONNECT_SIGNAL ("check_infinite_scrollback", "toggled", check_infinite_scrollback_toggled_cb, tw);
CONNECT_SIGNAL ("check_scroll_on_output","toggled",check_scroll_on_output_toggled_cb, tw);
CONNECT_SIGNAL ("check_scroll_on_keystroke","toggled",check_scroll_on_keystroke_toggled_cb, tw);
CONNECT_SIGNAL ("check_copy_on_selection","toggled",check_copy_on_selection_toggled_cb, tw);

/* Compatibility Tab */
CONNECT_SIGNAL ("combo_backspace_binding","changed",combo_backspace_binding_changed_cb, tw);
Expand Down