Remove duplicate regexps, move to a seperate method and pass the delimiter patterns in as optional arguments.
Re-call if the first regexp fails to compile. Split the regexps back up like g-t.
This commit is contained in:
commit
e901e72730
37
terminator
37
terminator
|
@ -136,24 +136,29 @@ class TerminatorTerm:
|
||||||
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.matches['full_uri'] = self._vte.match_add ('''[[:<:]](news:|telnet:|nntp:|file:/|https?:|ftps?:|webcal:)//([-A-Za-z0-9]+(:[-A-Za-z0-9,?;.:/!%$^*&~"#']+)?@)?[-A-Za-z0-9.]+(:[0-9]+)?(/[-A-Za-z0-9_$.+!*(),;:@&=?/~#%]*[^]'.}>) \t\r\n,\"])?[[:>:]]/?''')
|
self.add_matches()
|
||||||
if self.matches['full_uri'] == -1:
|
|
||||||
self.matches['full_uri'] = self._vte.match_add ('''\<(news:|telnet:|nntp:|file:/|https?:|ftps?:|webcal:)//([-A-Za-z0-9]+(:[-A-Za-z0-9,?;.:/!%$^*&~"#']+)?@)?[-A-Za-z0-9.]+(:[0-9]+)?(/[-A-Za-z0-9_$.+!*(),;:@&=?/~#%]*[^]'.}>) \t\r\n,\"])?\>/?''')
|
|
||||||
|
|
||||||
self.matches['addr_only'] = self._vte.match_add ('''[[:<:]](www|ftp)[-A-Za-z0-9]*\.[-A-Za-z0-9.]+(:[0-9]+)?(/[-A-Za-z0-9_$.+!*(),;:@&=?/~#%]*[^]'.}>) \t\r\n,\"])?[[:>:]]/?''')
|
|
||||||
if self.matches['addr_only'] == -1:
|
|
||||||
self.matches['addr_only'] = self._vte.match_add ('''\<(www|ftp)[-A-Za-z0-9]*\.[-A-Za-z0-9.]+(:[0-9]+)?(/[-A-Za-z0-9_$.+!*(),;:@&=?/~#%]*[^]'.}>) \t\r\n,\"])?\>/?''')
|
|
||||||
|
|
||||||
self.matches['email'] = self._vte.match_add ('''[[:<:]](mailto:)?[a-z0-9][a-z0-9.-]*@[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)+[[:>:]]''')
|
|
||||||
if self.matches['email'] == -1:
|
|
||||||
self.matches['email'] = self._vte.match_add ('''\<(mailto:)?[a-z0-9][a-z0-9.-]*@[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)+\>''')
|
|
||||||
|
|
||||||
self.matches['nntp'] = self._vte.match_add ('''[[:<:]]news:[-A-Z\^_a-z{|}~!"#$%&'()*+,./0-9;:=?`]+@[-A-Za-z0-9.]+(:[0-9]+)?[[:>:]]''')
|
|
||||||
if self.matches['nntp'] == -1:
|
|
||||||
self.matches['nntp'] = self._vte.match_add ('''\<news:[-A-Z\^_a-z{|}~!"#$%&'()*+,./0-9;:=?`]+@[-A-Za-z0-9.]+(:[0-9]+)?\>''')
|
|
||||||
|
|
||||||
self.spawn_child ()
|
self.spawn_child ()
|
||||||
|
|
||||||
|
def add_matches (self, lboundry="[[:<:]]", rboundry="[[:>:]]"):
|
||||||
|
userchars = "-A-Za-z0-9"
|
||||||
|
passchars = "-A-Za-z0-9,?;.:/!%$^*&~\"#'"
|
||||||
|
hostchars = "-A-Za-z0-9"
|
||||||
|
pathchars = "-A-Za-z0-9_$.+!*(),;:@&=?/~#%"
|
||||||
|
schemes = "(news:|telnet:|nntp:|file:/|https?:|ftps?:|webcal:)"
|
||||||
|
user = "[" + userchars + "]+(:[" + passchars + "]+)?"
|
||||||
|
urlpath = "/[" + pathchars + "]*[^]'.}>) \t\r\n,\\\"]"
|
||||||
|
|
||||||
|
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 lboundry != "\\<":
|
||||||
|
self.add_matches(lboundry = "\\<", rboundry = "\\>")
|
||||||
|
else:
|
||||||
|
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-z0-9][a-z0-9.-]*@[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)+" + rboundry)
|
||||||
|
self.matches['nntp'] = self._vte.match_add (lboundry + '''news:[-A-Z\^_a-z{|}~!"#$%&'()*+,./0-9;:=?`]+@[-A-Za-z0-9.]+(:[0-9]+)?''' + rboundry)
|
||||||
|
|
||||||
def spawn_child (self, event=None):
|
def spawn_child (self, event=None):
|
||||||
update_records = self.conf.update_records
|
update_records = self.conf.update_records
|
||||||
login = self.conf.login_shell
|
login = self.conf.login_shell
|
||||||
|
|
Loading…
Reference in New Issue