From 6db2337c56992a4c8cb028d122c89f31d9b54673 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Sat, 28 Nov 2015 20:28:01 +0100 Subject: [PATCH] Add word chars back in if VTE is 0.40+ --- doc/terminator_config.5 | 4 ++++ terminatorlib/config.py | 1 + terminatorlib/preferences.glade | 41 +++++++++++++++++++++++++++++++++ terminatorlib/prefseditor.py | 11 +++++++++ terminatorlib/terminal.py | 3 +++ 5 files changed, 60 insertions(+) diff --git a/doc/terminator_config.5 b/doc/terminator_config.5 index c6f736ff..f6cd0089 100644 --- a/doc/terminator_config.5 +++ b/doc/terminator_config.5 @@ -442,6 +442,10 @@ Default value: \fBclose\fR .B palette Terminals have a 16-colour palette that applications inside the terminal can use. This is that palette, in the form of a colon-separated list of colour names. Colour names should be in hex format e.g. "#FF00FF". .TP +.B word_chars +These characters are included when selecting text by double clicking. +Default value: \fB',./?%&#:_'\fR +.TP .B mouse_autohide \fR(boolean) Controls whether the mouse cursor should be hidden while typing. Default value: \fBTrue\fR diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 501f7f1b..063f311d 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -227,6 +227,7 @@ DEFAULTS = { 'palette' : '#2e3436:#cc0000:#4e9a06:#c4a000:\ #3465a4:#75507b:#06989a:#d3d7cf:#555753:#ef2929:#8ae234:#fce94f:\ #729fcf:#ad7fa8:#34e2e2:#eeeeec', + 'word_chars' : ',./?%&#:_', 'mouse_autohide' : True, 'update_records' : True, 'login_shell' : False, diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index d7c63e45..a9ad6853 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1619,6 +1619,47 @@ 5 + + + True + False + 12 + + + True + False + 0 + Select-by-_word characters: + True + center + word_chars_entry + + + False + False + 0 + + + + + True + True + • + + + + True + True + 1 + + + + + False + True + 6 + + False diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 46b02fed..37fa3d58 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -424,6 +424,12 @@ class PrefsEditor: # Rewrap on resize widget = guiget('rewrap_on_resize_checkbutton') widget.set_active(self.config['rewrap_on_resize']) + # Word chars + widget = guiget('word_chars_entry') + widget.set_text(self.config['word_chars']) + # Word char support was missing from vte 0.38, hide from the UI + if not hasattr(self.term.vte, 'set_word_char_exceptions'): + guiget('word_chars_hbox').hide() # Cursor shape widget = guiget('cursor_shape_combobox') if self.config['cursor_shape'] == 'underline': @@ -929,6 +935,11 @@ class PrefsEditor: self.config['cursor_shape'] = value self.config.save() + def on_word_chars_entry_changed(self, widget): + """Word characters changed""" + self.config['word_chars'] = widget.get_text() + self.config.save() + def on_font_selector_font_set(self, widget): """Font changed""" self.config['font'] = widget.get_font_name() diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 68a1bf71..4f28872c 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -628,6 +628,9 @@ class Terminal(Gtk.VBox): if self.custom_encoding != True: self.vte.set_encoding(self.config['encoding']) + # Word char support was missing from vte 0.38, silently skip this setting + if hasattr(self.vte, 'set_word_char_exceptions'): + self.vte.set_word_char_exceptions(self.config['word_chars']) self.vte.set_mouse_autohide(self.config['mouse_autohide']) backspace = self.config['backspace_binding']