From 1e89dc3064f9bcafa0c21a636d7260b310668634 Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 22 Sep 2015 19:32:10 +0500 Subject: [PATCH 1/2] Added config for 'putty paste style' and handle mouse click --- terminatorlib/config.py | 1 + terminatorlib/terminal.py | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 5e2a8845..3e024af9 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -242,6 +242,7 @@ DEFAULTS = { 'force_no_bell' : False, 'cycle_term_tab' : True, 'copy_on_selection' : False, + 'putty_paste_style' : False, 'alternate_screen_scroll': True, 'split_to_group' : False, 'autoclean_groups' : True, diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index ed035fcd..77657ef3 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -77,6 +77,10 @@ class Terminal(gtk.VBox): TARGET_TYPE_VTE = 8 + LEFT_CLICK = 1 + MIDDLE_CLICK = 2 + RIGHT_CLICK = 3 + terminator = None vte = None terminalbox = None @@ -896,17 +900,25 @@ class Terminal(gtk.VBox): # Suppress double-click behavior return True - if event.button == 1: + if self.config['putty_paste_style']: + btn_to_paste = self.RIGHT_CLICK + btn_to_context_menu = self.MIDDLE_CLICK + else: + btn_to_paste = self.MIDDLE_CLICK + btn_to_context_menu = self.RIGHT_CLICK + + + if event.button == self.LEFT_CLICK: # Ctrl+leftclick on a URL should open it if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK: url = self.check_for_url(event) if url: self.open_url(url, prepare=True) - elif event.button == 2: + elif event.button == btn_to_paste: # middleclick should paste the clipboard self.paste_clipboard(True) return(True) - elif event.button == 3: + elif event.button == btn_to_context_menu: # rightclick should display a context menu if Ctrl is not pressed if event.state & gtk.gdk.CONTROL_MASK == 0: self.popup_menu(widget, event) From a8c260fcf3905b1c9409c0efc2c42cb08a7e516e Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 22 Sep 2015 19:44:35 +0500 Subject: [PATCH 2/2] Added UI config for Putty-paste-style, and text to documentations --- doc/manual/_build/html/_sources/preferences.txt | 5 +++++ doc/manual/source/preferences.rst | 5 +++++ doc/terminator_config.5 | 4 ++++ terminatorlib/preferences.glade | 16 ++++++++++++++++ terminatorlib/prefseditor.py | 8 ++++++++ 5 files changed, 38 insertions(+) diff --git a/doc/manual/_build/html/_sources/preferences.txt b/doc/manual/_build/html/_sources/preferences.txt index 720c3c72..c75e993a 100644 --- a/doc/manual/_build/html/_sources/preferences.txt +++ b/doc/manual/_build/html/_sources/preferences.txt @@ -256,6 +256,11 @@ a separate window launched from the menu bar. This puts the selection into the copy/paste buffer, as well as being available on middle-click. +**Putty paste style** (default: off) + + Make right mouse button in Putty-style: right button - paste from + clipboard, middle - open popup (for ex-Putty users). + **Select-by-word characters** (default: ``-A-Za-z0-9,./?%&#:_``) Using double-click to select text will use this pattern to define diff --git a/doc/manual/source/preferences.rst b/doc/manual/source/preferences.rst index 720c3c72..c75e993a 100644 --- a/doc/manual/source/preferences.rst +++ b/doc/manual/source/preferences.rst @@ -256,6 +256,11 @@ a separate window launched from the menu bar. This puts the selection into the copy/paste buffer, as well as being available on middle-click. +**Putty paste style** (default: off) + + Make right mouse button in Putty-style: right button - paste from + clipboard, middle - open popup (for ex-Putty users). + **Select-by-word characters** (default: ``-A-Za-z0-9,./?%&#:_``) Using double-click to select text will use this pattern to define diff --git a/doc/terminator_config.5 b/doc/terminator_config.5 index 0fa344f9..66a81cd2 100644 --- a/doc/terminator_config.5 +++ b/doc/terminator_config.5 @@ -489,6 +489,10 @@ Default value: \fBUTF-8\fR .B copy_on_selection \fR(boolean) If set to True, text selections will be automatically copied to the clipboard, in addition to being made the Primary selection. Default value: \fBFalse\fR +.TP +.B putty_paste_style \fR(boolean) +If set to True, right mouse click - paste Primary selection, middle mouse click - popup menu. +Default value: \fBFalse\fR .SH layouts diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index ed484a1c..7e28f213 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1590,6 +1590,22 @@ 5 + + + Putty paste style + True + True + False + False + True + + + + False + False + 6 + + False diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 21bf79fb..c67033e2 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -425,6 +425,9 @@ class PrefsEditor: # Copy on selection widget = guiget('copy_on_selection') widget.set_active(self.config['copy_on_selection']) + # Putty paste style + widget = guiget('putty_paste_style') + widget.set_active(self.config['putty_paste_style']) # Word chars widget = guiget('word_chars_entry') widget.set_text(self.config['word_chars']) @@ -722,6 +725,11 @@ class PrefsEditor: self.config['copy_on_selection'] = widget.get_active() self.config.save() + def on_putty_paste_style_toggled(self, widget): + """Putty paste style setting changed""" + self.config['putty_paste_style'] = widget.get_active() + self.config.save() + def on_cursor_blink_toggled(self, widget): """Cursor blink setting changed""" self.config['cursor_blink'] = widget.get_active()