In Xcode, URLs are clickable, draggable and colored brightly so as to make easily navigable CGI pages. Is this possible in TextMate?
-- Gnarlie
On Mar 19, 2011, at 4:28 AM, Gnarlodious wrote:
In Xcode, URLs are clickable, draggable and colored brightly so as to make easily navigable CGI pages. Is this possible in TextMate?
Everything except making them clickable is possible. The first catch is to use a syntax that recognizes URLs, the plain text grammar does this. For coloring: once it's matched you can customize the color with a theme by using it's scope. For opening the url we use the enter key while the caret is inside the url (enter not return).
On Mar 21, 2011, at 2:49 AM, Michael Sheets wrote:
On Mar 19, 2011, at 4:28 AM, Gnarlodious wrote:
In Xcode, URLs are clickable, draggable and colored brightly so as to make easily navigable CGI pages. Is this possible in TextMate?
Everything except making them clickable is possible.
It's also worth pointing out that there is the textmate url scheme (see http://blog.macromates.com/2007/the-textmate-url-scheme/). It's not quite what you want, I know, but it seems like it would be possible to run your document through a command, parse it for links, add textmate-capable links, and present the output in an HTML window.
At that point, though, it might be easier to see if you could write a command that takes the current selection/word, and opens it as a textmate url.
Just spitballing, but maybe something like
#!/usr/bin/ruby file = "file://" + STDIN.read url = "txmt://open?url="+file `open #{url}`
(I'm much more familiar with Ruby than Bash; it could probably be written in a single Bash line, but there it is)
In fact, I just tried it out, with input set to "Selected Text" or "Word", discard the output. Works just fine, assuming you have a full file path (didn't spend any cycles figuring out what to do with a project-relative URL...)
The downside of this, in light of what you're originally asking, is that you need to fully select the file or the link won't work, plus it's not a simple click, it's a select, then press keyboard shortcut, but that's probably still an improvement over not having any in-file linking.
Hope that helps...seems like with the right amount of elbow grease, you could get something pretty slick rolling.
+dru