From 18783cb9ce4f44352d8911f0df45523414312903 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Wed, 2 Dec 2015 14:36:18 +0100 Subject: [PATCH 1/6] Remove the now unused posix regex code, and set the regex boundary vars to the correct '\b' value --- terminatorlib/config.py | 1 - terminatorlib/terminal.py | 28 +++++----------------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 0c74173c..59d84ed8 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -104,7 +104,6 @@ DEFAULTS = { 'always_on_top' : False, 'hide_on_lose_focus' : False, 'sticky' : False, - 'try_posix_regexp' : platform.system() != 'Linux', 'use_custom_url_handler': False, 'custom_url_handler' : '', 'disable_real_transparency' : False, diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index e4ae8d4b..e9f6b41d 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -142,7 +142,7 @@ class Terminal(Gtk.VBox): self.vte.show() self.default_encoding = self.vte.get_encoding() - self.update_url_matches(self.config['try_posix_regexp']) + self.update_url_matches() self.terminalbox = self.create_terminalbox() @@ -257,7 +257,7 @@ class Terminal(Gtk.VBox): return(terminalbox) - def update_url_matches(self, posix = True): + def update_url_matches(self): """Update the regexps used to match URLs""" userchars = "-A-Za-z0-9" passchars = "-A-Za-z0-9,?;.:/!%$^*&~\"#'" @@ -267,22 +267,8 @@ class Terminal(Gtk.VBox): user = "[" + userchars + "]+(:[" + passchars + "]+)?" urlpath = "/[" + pathchars + "]*[^]'.}>) \t\r\n,\\\"]" - if posix: - dbg ('Terminal::update_url_matches: Trying POSIX URL regexps') - lboundry = "[[:<:]]" - rboundry = "[[:>:]]" - else: # GNU - dbg ('Terminal::update_url_matches: Trying GNU URL regexps') - lboundry = "\\<" - rboundry = "\\>" - - # VERIFY/FIXME FOR GTK3: What's this with the POSIX and GNU mode l/r boundry[sic] values? - # Neither of the two works for me since the Vte 0.38 update. - # Should we get rid of them and the try_posix_regexp option totally? - # They don't seem to be necessary, and there really shouldn't be any difference - # between Linux and non-Linux systems, GLib should hide this (does it?). - lboundry = '' - rboundry = '' + lboundry = "\\b" + rboundry = "\\b" re = (lboundry + schemes + "//(" + user + "@)?[" + hostchars +".]+(:[0-9]+)?(" + @@ -291,11 +277,7 @@ class Terminal(Gtk.VBox): self.matches['full_uri'] = self.vte.match_add_gregex(reg, 0) if self.matches['full_uri'] == -1: - if posix: - err ('Terminal::update_url_matches: POSIX failed, trying GNU') - self.update_url_matches(posix = False) - else: - err ('Terminal::update_url_matches: Failed adding URL matches') + err ('Terminal::update_url_matches: Failed adding URL matches') else: re = (lboundry + '(callto:|h323:|sip:)' + "[" + userchars + "+][" + From 5fc34fe3c0f9adc39c139d259681d4380ba17435 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Wed, 2 Dec 2015 19:39:58 +0100 Subject: [PATCH 2/6] Fix drag and drop of a link from Firefox / Chrome --- terminatorlib/terminal.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index e9f6b41d..6f19744f 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -68,6 +68,7 @@ class Terminal(Gtk.VBox): } TARGET_TYPE_VTE = 8 + TARGET_TYPE_MOZ = 9 MOUSEBUTTON_LEFT = 1 MOUSEBUTTON_MIDDLE = 2 @@ -354,7 +355,7 @@ class Terminal(Gtk.VBox): srcvtetargets = [("vte", Gtk.TargetFlags.SAME_APP, self.TARGET_TYPE_VTE)] dsttargets = [("vte", Gtk.TargetFlags.SAME_APP, self.TARGET_TYPE_VTE), - ('text/x-moz-url', 0, 0), + ('text/x-moz-url', 0, self.TARGET_TYPE_MOZ), ('_NETSCAPE_URL', 0, 0)] ''' The following should work, but on my system it corrupts the returned @@ -1069,7 +1070,7 @@ class Terminal(Gtk.VBox): return(False) def on_drag_data_received(self, widget, drag_context, x, y, selection_data, - _info, _time, data): + info, _time, data): """Something has been dragged into the terminal. Handle it as either a URL or another terminal.""" dbg('drag data received of type: %s' % (selection_data.get_data_type())) @@ -1077,6 +1078,12 @@ class Terminal(Gtk.VBox): Gtk.targets_include_uri(drag_context.list_targets()): # copy text with no modification yet to destination txt = selection_data.get_data() + + # https://bugs.launchpad.net/terminator/+bug/1518705 + if info == self.TARGET_TYPE_MOZ: + txt = txt.decode('utf-16').encode('utf-8') + txt = txt.split('\n')[0] + txt_lines = txt.split( "\r\n" ) if txt_lines[-1] == '': for line in txt_lines[:-1]: From 74ca52582debc407c77b2584c858332741c7d128 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Wed, 2 Dec 2015 19:48:42 +0100 Subject: [PATCH 3/6] Fix the editing of the window title --- terminatorlib/terminal.py | 1 - 1 file changed, 1 deletion(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 6f19744f..85350869 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -1848,7 +1848,6 @@ class Terminal(Gtk.VBox): ( Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT )) dialog.set_default_response(Gtk.ResponseType.ACCEPT) - dialog.set_has_separator(False) dialog.set_resizable(False) dialog.set_border_width(8) From 9c21b835c2f07be15b1b2a76850aa1b0ff5ce7ee Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Wed, 2 Dec 2015 20:07:21 +0100 Subject: [PATCH 4/6] Fix closing window using short-cut --- terminatorlib/window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index dddd503f..f6f38e59 100755 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -208,9 +208,9 @@ class Window(Container, Gtk.Window): self.set_fullscreen(not self.isfullscreen) elif mapping == 'close_window': if not self.on_delete_event(window, - Gdk.Event(Gdk.DELETE)): + Gdk.Event.new(Gdk.EventType.DELETE)): self.on_destroy_event(window, - Gdk.Event(Gdk.DESTROY)) + Gdk.Event.new(Gdk.EventType.DESTROY)) else: return(False) return(True) From fc6e3e7e654a616adbbb263aefa7fa1e2e9163c3 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Wed, 2 Dec 2015 20:57:59 +0100 Subject: [PATCH 5/6] Fix profile re-use when opening new window --- terminatorlib/terminal.py | 2 +- terminatorlib/terminator.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 85350869..fc3fd0a4 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -1815,7 +1815,7 @@ class Terminal(Gtk.VBox): self.emit('ungroup-tab') def key_new_window(self): - self.terminator.new_window(self.get_cwd()) + self.terminator.new_window(self.get_cwd(), self.get_profile()) def key_new_tab(self): self.get_toplevel().tab_new(self) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index ac8f3a48..97f6f3f9 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -201,13 +201,15 @@ class Terminator(Borg): return terminal return None - def new_window(self, cwd=None): + def new_window(self, cwd=None, profile=None): """Create a window with a Terminal in it""" maker = Factory() window = maker.make('Window') terminal = maker.make('Terminal') if cwd: terminal.set_cwd(cwd) + if profile and self.config['always_split_with_profile']: + terminal.force_set_profile(None, profile) window.add(terminal) window.show(True) terminal.spawn_child() From 4ac75317e7e6c71e318422b65fac843f4158dd19 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Wed, 2 Dec 2015 21:12:59 +0100 Subject: [PATCH 6/6] Fix scrollbar position on current terminals when changed in prefs --- terminatorlib/terminal.py | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index fc3fd0a4..e17c8d1a 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -78,7 +78,6 @@ class Terminal(Gtk.VBox): vte = None terminalbox = None scrollbar = None - scrollbar_position = None titlebar = None searchbar = None @@ -241,19 +240,9 @@ class Terminal(Gtk.VBox): terminalbox = Gtk.HBox() self.scrollbar = Gtk.VScrollbar(self.vte.get_vadjustment()) - self.scrollbar.set_no_show_all(True) - self.scrollbar_position = self.config['scrollbar_position'] - if self.scrollbar_position not in ('hidden', 'disabled'): - self.scrollbar.show() - - if self.scrollbar_position == 'left': - func = terminalbox.pack_end - else: - func = terminalbox.pack_start - - func(self.vte, True, True, 0) - func(self.scrollbar, False, True, 0) + terminalbox.pack_start(self.vte, True, True, 0) + terminalbox.pack_start(self.scrollbar, False, True, 0) terminalbox.show_all() return(terminalbox) @@ -775,16 +764,14 @@ class Terminal(Gtk.VBox): self.vte.set_scroll_on_keystroke(self.config['scroll_on_keystroke']) self.vte.set_scroll_on_output(self.config['scroll_on_output']) - if self.scrollbar_position != self.config['scrollbar_position']: - self.scrollbar_position = self.config['scrollbar_position'] - if self.config['scrollbar_position'] in ['disabled', 'hidden']: - self.scrollbar.hide() - else: - self.scrollbar.show() - if self.config['scrollbar_position'] == 'left': # FIXME FOR GTK3: moving the scrollbar to the other side (by changing prefs) doesn't work - self.reorder_child(self.scrollbar, 0) - elif self.config['scrollbar_position'] == 'right': - self.reorder_child(self.vte, 0) + if self.config['scrollbar_position'] in ['disabled', 'hidden']: + self.scrollbar.hide() + else: + self.scrollbar.show() + if self.config['scrollbar_position'] == 'left': + self.terminalbox.reorder_child(self.scrollbar, 0) + elif self.config['scrollbar_position'] == 'right': + self.terminalbox.reorder_child(self.vte, 0) self.vte.set_rewrap_on_resize(self.config['rewrap_on_resize'])