r459 breaks; regexp probing, since \< is valid in both POSIX and GNU regexps; they just don't mean the same thing. This means on !GNU, URL matching silently breaks and POSIX word boundries are never tried.

Since the VTE-warning is annoying people, rather than back it out, try to make everyone happy; Linux now only uses GNU, !Linux always probes, and there's now a try_posix_regexp configuration option who's default reflects this.  Hopefully we will Just Work in most environments.
This commit is contained in:
Thomas Hurst 2008-08-03 03:09:38 +01:00
parent bcb60d1807
commit 2d6f1c0485
3 changed files with 38 additions and 15 deletions

View File

@ -175,5 +175,9 @@ Default value: \fBFalse\fR
.B extreme_tabs \fB(boolean)\fR .B extreme_tabs \fB(boolean)\fR
If set to True, tabs can be created within other tabs. Be warned that this can be very confusing and hard to use. If set to True, tabs can be created within other tabs. Be warned that this can be very confusing and hard to use.
Default value: \fBFalse\fR Default value: \fBFalse\fR
.TP
.B try_posix_regexp \fB(boolean)\fR
If set to True, URL matching regexps will try to use POSIX style first, and fall back on GNU style on failure. If you are on Linux but URL matches don't work, try setting this to True. If you are not on Linux, but you get VTE warnings on startup saying "Error compiling regular expression", set this to False to silence them (they are otherwise harmless).
Default value: \fBFalse\fR on Linux, \fBTrue\fR otherwise.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR gnome\-terminal(1) .BR gnome\-terminal(1)

View File

@ -32,7 +32,7 @@ AttributeError. This is by design. If you want to look something
up, set a default for it first.""" up, set a default for it first."""
# import standard python libs # import standard python libs
import os, sys, re import os, platform, sys, re
# import unix-lib # import unix-lib
import pwd import pwd
@ -132,6 +132,7 @@ class TerminatorConfValuestore:
'copy_on_selection' : False, 'copy_on_selection' : False,
'close_button_on_tab' : True, 'close_button_on_tab' : True,
'enable_real_transparency' : False, 'enable_real_transparency' : False,
'try_posix_regexp' : platform.system() != 'Linux',
} }
def __getattr__ (self, keyname): def __getattr__ (self, keyname):

View File

@ -147,8 +147,7 @@ class TerminatorTerm (gtk.VBox):
self._vte.connect ("grab-focus", self.on_vte_focus) self._vte.connect ("grab-focus", self.on_vte_focus)
self._vte.connect ("focus-out-event", self.on_vte_focus_out) self._vte.connect ("focus-out-event", self.on_vte_focus_out)
self._vte.connect ("focus-in-event", self.on_vte_focus_in) self._vte.connect ("focus-in-event", self.on_vte_focus_in)
self._vte.connect ("resize-window", self.on_resize_window)
exit_action = self.conf.exit_action exit_action = self.conf.exit_action
if exit_action == "restart": if exit_action == "restart":
@ -161,7 +160,7 @@ class TerminatorTerm (gtk.VBox):
self._vte.add_events (gtk.gdk.ENTER_NOTIFY_MASK) self._vte.add_events (gtk.gdk.ENTER_NOTIFY_MASK)
self._vte.connect ("enter_notify_event", self.on_vte_notify_enter) self._vte.connect ("enter_notify_event", self.on_vte_notify_enter)
self.add_matches() self.add_matches(posix = self.conf.try_posix_regexp)
dbg ('SEGBUG: Setting http_proxy') dbg ('SEGBUG: Setting http_proxy')
env_proxy = os.getenv ('http_proxy') env_proxy = os.getenv ('http_proxy')
@ -187,10 +186,16 @@ class TerminatorTerm (gtk.VBox):
dbg ('openurl: url_show failed. No URL for you') dbg ('openurl: url_show failed. No URL for you')
pass pass
def on_resize_window(self, widget, width, height):
dbg ('Resize window triggered on %s: %dx%d' % (widget, width, height))
def on_drag_begin(self, widget, drag_context, data): def on_drag_begin(self, widget, drag_context, data):
dbg ('Drag begins') dbg ('Drag begins')
widget.drag_source_set_icon_pixbuf(self.terminator.icon_theme.load_icon (APP_NAME, 48, 0)) widget.drag_source_set_icon_pixbuf(self.terminator.icon_theme.load_icon (APP_NAME, 48, 0))
def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data): def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data):
dbg ("Drag data get") dbg ("Drag data get")
selection_data.set("vte",info, str(data.terminator.term_list.index (self))) selection_data.set("vte",info, str(data.terminator.term_list.index (self)))
@ -218,6 +223,7 @@ class TerminatorTerm (gtk.VBox):
#context.paint() #context.paint()
return False return False
def on_drag_motion(self, widget, drag_context, x, y, time, data): def on_drag_motion(self, widget, drag_context, x, y, time, data):
dbg ("Drag Motion on ") dbg ("Drag Motion on ")
""" """
@ -285,6 +291,7 @@ text/plain
parent = widget.get_parent() parent = widget.get_parent()
dbg ('Drag drop on %s'%parent) dbg ('Drag drop on %s'%parent)
def on_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time, data): def on_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time, data):
dbg ("Drag Data Received") dbg ("Drag Data Received")
if selection_data.type == 'text/plain': if selection_data.type == 'text/plain':
@ -317,6 +324,7 @@ text/plain
data.terminator.add(self, widgetsrc,pos) data.terminator.add(self, widgetsrc,pos)
return return
def get_location(self, vte, x, y): def get_location(self, vte, x, y):
pos = "" pos = ""
#get the diagonales function for the receiving widget #get the diagonales function for the receiving widget
@ -345,7 +353,8 @@ text/plain
pos = "bottom" pos = "bottom"
return pos return pos
def add_matches (self, lboundry="\\<", rboundry="\\>"):
def add_matches (self, posix = True):
userchars = "-A-Za-z0-9" userchars = "-A-Za-z0-9"
passchars = "-A-Za-z0-9,?;.:/!%$^*&~\"#'" passchars = "-A-Za-z0-9,?;.:/!%$^*&~\"#'"
hostchars = "-A-Za-z0-9" hostchars = "-A-Za-z0-9"
@ -354,14 +363,23 @@ text/plain
user = "[" + userchars + "]+(:[" + passchars + "]+)?" user = "[" + userchars + "]+(:[" + passchars + "]+)?"
urlpath = "/[" + pathchars + "]*[^]'.}>) \t\r\n,\\\"]" urlpath = "/[" + pathchars + "]*[^]'.}>) \t\r\n,\\\"]"
dbg ('add_matches: trying a Linux-friendly match') if posix:
dbg ('add_matches: Trying POSIX URL regexps. Set try_posix_regexp = False in config to only try GNU if you get (harmless) VTE warnings.')
lboundry = "[[:<:]]"
rboundry = "[[:>:]]"
else: # GNU
dbg ('add_matches: Trying GNU URL regexps. Set try_posix_regexp = True in config if URLs are not detected.')
lboundry = "\\<"
rboundry = "\\>"
self.matches['full_uri'] = self._vte.match_add(lboundry + schemes + "//(" + user + "@)?[" + hostchars +".]+(:[0-9]+)?(" + urlpath + ")?" + rboundry + "/?") self.matches['full_uri'] = self._vte.match_add(lboundry + schemes + "//(" + user + "@)?[" + hostchars +".]+(:[0-9]+)?(" + urlpath + ")?" + rboundry + "/?")
# FreeBSD works with [[:<:]], Linux works with \<
if self.matches['full_uri'] == -1: if self.matches['full_uri'] == -1:
if lboundry != "[[:<:]]": if posix:
err ('add_matches: Linux match failed, trying alternative') err ('add_matches: POSIX match failed, trying GNU')
self.add_matches(lboundry = "[[:<:]]", rboundry = "[[:<:]]") self.add_matches(posix = False)
else:
err ('add_matches: Failed adding URL match patterns')
else: else:
self.matches['addr_only'] = self._vte.match_add (lboundry + "(www|ftp)[" + hostchars + "]*\.[" + hostchars + ".]+(:[0-9]+)?(" + urlpath + ")?" + rboundry + "/?") self.matches['addr_only'] = self._vte.match_add (lboundry + "(www|ftp)[" + hostchars + "]*\.[" + hostchars + ".]+(:[0-9]+)?(" + urlpath + ")?" + rboundry + "/?")
self.matches['email'] = self._vte.match_add (lboundry + "(mailto:)?[a-zA-Z0-9][a-zA-Z0-9.+-]*@[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z0-9][a-zA-Z0-9-]+[.a-zA-Z0-9-]*" + rboundry) self.matches['email'] = self._vte.match_add (lboundry + "(mailto:)?[a-zA-Z0-9][a-zA-Z0-9.+-]*@[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z0-9][a-zA-Z0-9-]+[.a-zA-Z0-9-]*" + rboundry)