aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--terminal.ui13
-rw-r--r--terminal.vala16
2 files changed, 21 insertions, 8 deletions
diff --git a/terminal.ui b/terminal.ui
index 4ba9555..4618d40 100644
--- a/terminal.ui
+++ b/terminal.ui
@@ -232,17 +232,26 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkImageMenuItem" id="copy_item">
+ <object class="GtkImageMenuItem" id="copy_item_text">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
- <signal name="activate" handler="vte_copy" swapped="no"/>
<accelerator key="c" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
</object>
</child>
<child>
+ <object class="GtkImageMenuItem" id="copy_item_html">
+ <property name="label">Copy as _HTML</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Copy the selection as HTML</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">False</property>
+ </object>
+ </child>
+ <child>
<object class="GtkImageMenuItem" id="paste_item">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
diff --git a/terminal.vala b/terminal.vala
index 5f4f4e0..c7a2c81 100644
--- a/terminal.vala
+++ b/terminal.vala
@@ -26,7 +26,8 @@ class Terminal : Gtk.Overlay {
[GtkChild] Gtk.Menu standard_context_menu;
[GtkChild] Gtk.Menu url_context_menu;
[GtkChild] Gtk.Menu hyperlink_context_menu;
- [GtkChild] Gtk.MenuItem copy_item;
+ [GtkChild] Gtk.MenuItem copy_item_text;
+ [GtkChild] Gtk.MenuItem copy_item_html;
[GtkChild] Gtk.Revealer search_revealer;
[GtkChild] Gtk.ScrolledWindow scrolled_window;
[GtkChild] Gtk.SearchEntry search_entry;
@@ -53,6 +54,9 @@ class Terminal : Gtk.Overlay {
clipboard = Gtk.Clipboard.get_default(window.get_display());
+ copy_item_text.activate.connect(() => vte_copy());
+ copy_item_html.activate.connect(() => vte_copy(true));
+
try {
var regex = new Vte.Regex.for_match(URL_REGEX, URL_REGEX.length, PCRE2_CASELESS | PCRE2_MULTILINE);
vte.match_add_regex(regex, 0);
@@ -300,10 +304,9 @@ class Terminal : Gtk.Overlay {
adjust_font_scale(vte.get_font_scale() / FONT_SCALE_FACTOR);
}
- [GtkCallback]
- void vte_copy() {
+ void vte_copy(bool html = false) {
if (vte.get_has_selection()) {
- vte.copy_clipboard_format(TEXT);
+ vte.copy_clipboard_format(html ? Vte.Format.HTML : Vte.Format.TEXT);
}
}
@@ -323,7 +326,8 @@ class Terminal : Gtk.Overlay {
} else if (hyperlink_match != null) {
hyperlink_context_menu.popup_at_pointer(event);
} else {
- copy_item.set_sensitive(vte.get_has_selection());
+ copy_item_text.set_sensitive(vte.get_has_selection());
+ copy_item_html.set_sensitive(vte.get_has_selection());
standard_context_menu.popup_at_pointer(event);
}
return true;
@@ -351,7 +355,7 @@ class Terminal : Gtk.Overlay {
[GtkCallback]
bool vte_key_press(Gdk.EventKey event) {
if (match_key(event, CONTROL_MASK | SHIFT_MASK, Gdk.Key.C)) {
- vte_copy();
+ vte_copy(false);
return true;
}