ipython/ipython — pull request #2467 by detrout (2012-10-04 16:56:28+00:00)
Title: Clickable links

This implements a mechanism for selecting hyperlinks in the rich text editor.

It's using QtGui.QTextEdit's anchorAt to determine the existence of a link, so links that are printed without being wrapped in aren't going to be detected.

The implementation conditionally adds "Open Link" and "Copy Link Anchor" as inspired by gnome-terminal. (I didn't spend very much time thinking about the order of menu options)

A typical browser security feature is to show the user the target of a link before they can actually select it, I implemented that by adding a tooltop when the mouse hovers over an anchor.

That was implemented by turning on mouseMoveEvent messages on the rich QTextEdit controland checking to see if an anchor is under the current mouse position. If it is and its a different anchor than what we're currently displaying (or not displaying) it'll pop up the tooltip.

The advantage to storing the displayed anchor in ConsoleWidget._anchor allows me to be sure that the thing the user is opening was displayed to to them, and to prevent the tooltip from constantly getting redrawn as you move the mouse around the link.

The plain text control QPlainTextEdit does have the anchorAt method, but I was imagining lacked any way to receive html text so I didn't bother turning on the mouse move tracking for it.