Recognize www. as links

This commit is contained in:
Kiooeht 2011-12-23 22:15:22 -08:00
parent f6b45fb32f
commit 646e6414ae
2 changed files with 5 additions and 2 deletions

View file

@ -405,6 +405,7 @@ class PesterText(QtGui.QTextEdit):
if event.modifiers() == QtCore.Qt.ControlModifier: if event.modifiers() == QtCore.Qt.ControlModifier:
QtGui.QApplication.clipboard().setText(url) QtGui.QApplication.clipboard().setText(url)
else: else:
if not unicode(url).startswith("http"): url = "http://" + url
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode)) QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode))
QtGui.QTextEdit.mousePressEvent(self, event) QtGui.QTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):

View file

@ -13,6 +13,7 @@ _gtag_begin = re.compile(r'(?i)<g[a-f]>')
_ctag_end = re.compile(r'(?i)</c>') _ctag_end = re.compile(r'(?i)</c>')
_ctag_rgb = re.compile(r'\d+,\d+,\d+') _ctag_rgb = re.compile(r'\d+,\d+,\d+')
_urlre = re.compile(r"(?i)https?://[^\s]+") _urlre = re.compile(r"(?i)https?://[^\s]+")
_url2re = re.compile(r"(?i)www.[^\s]+")
_memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)") _memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)")
_handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)") _handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)")
_imgre = re.compile(r"""(?i)<img src=['"](\S+)['"]\s*/>""") _imgre = re.compile(r"""(?i)<img src=['"](\S+)['"]\s*/>""")
@ -152,7 +153,8 @@ def lexMessage(string):
lexlist = [(mecmd, _mecmdre), lexlist = [(mecmd, _mecmdre),
(colorBegin, _ctag_begin), (colorBegin, _gtag_begin), (colorBegin, _ctag_begin), (colorBegin, _gtag_begin),
(colorEnd, _ctag_end), (imagelink, _imgre), (colorEnd, _ctag_end), (imagelink, _imgre),
(hyperlink, _urlre), (memolex, _memore), (hyperlink, _urlre), (hyperlink, _url2re),
(memolex, _memore),
(chumhandlelex, _handlere), (chumhandlelex, _handlere),
(smiley, _smilere)] (smiley, _smilere)]
@ -428,7 +430,7 @@ smiledict = {
":olliesouty:": "olliesouty.gif", ":olliesouty:": "olliesouty.gif",
":billiards:": "poolballS.gif", ":billiards:": "poolballS.gif",
":billiardslarge:": "poolballL.gif", ":billiardslarge:": "poolballL.gif",
":whatdidyoudo:": "whatdidyoudo.gif", ":whatdidyoudo:": "whatdidyoudo.gif",
} }
if ostools.isOSXBundle(): if ostools.isOSXBundle():