## How would I turn console error output into "Links" to files?

### How would I turn console error output into "Links" to files?

Hey there, I've been using ST2 for a while now and it's by far the best application around! I know how amazingly customisable it is so I was wondering if this was possible and how to go about it.

So when I compile code (Using the Pawn compiler) I get errors/warnings that look like this:

Code: Select all
E:\Games\Projects\SA-MP\ScavengeSurvive\gamemodes\../scripts/Items/timebomb.pwn(3) : error <error number>: <error name>

Or
Code: Select all
<directory>(<line number>) : <error number> : <error description>

And I was wondering, could I somehow turn that first part (I'm sure I could isolate/identify the first part with something like SSCANF or RegEx) into a link to that file? So I can just double or single click that part of the error to jump straight to that file ("E:\Games\Projects\SA-MP\ScavengeSurvive\gamemodes\../scripts/Items/timebomb.pwn") and that line (3)?

My files are included using "../scripts/Folder/File" so I assume the "../" would work fine with opening files etc. I can easily change to using backslashes too if need be.

How would I go about this? I haven't really delved into plugin development for this application yet but I would give it a try if someone would let me know what kind of level of difficulty something like this would be :p (I've been coding C/Pawn for about 3 years)

Thanks in advance for any help!
Southclaw

Posts: 6
Joined: Wed Apr 10, 2013 8:31 pm

### Re: How would I turn console error output into "Links" to files?

I would also be interested in the correct way to do this (particularly in Sublime Text 3). I'm trying to update the Cscope plugin to be compatible with Sublime Text 3. It generates output that sure looks like the "Find Results" window, but the file links aren't followed. What special work do I need to do to generate text in a new window view that will allow me to click on the file references and have them opened in Sublime?

The original Cscope plugin is here and I haven't changed much in the way it formats it's output. I hope to submit my changes (once working) to the original author:
https://github.com/ameyp/CscopeSublime

The output is formatted like so:

Code: Select all
In folder C:\path\to\projectFound 2 matches for C symbol: schwankyRoutine--------------------------------------------------.\api\schwanky_api.h:   944 [scope: <global>] extern int schwankyRoutine(int *thing,.\src\schwanky.c:  2413 [scope: k] int k(int *thing,

Do I need complete paths? Is the "[scope:..." throwing it off? I couldn't find any documentation on how that is supposed to work.
arnisandy

Posts: 6
Joined: Thu Jul 05, 2012 1:29 pm

### Re: How would I turn console error output into "Links" to files?

you can set result_file_regex setting of view or output_panel as fallows

view.settings().set("result_file_regex","^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$") and you can change the regex by yourself waterup Posts: 8 Joined: Thu Apr 11, 2013 3:29 am ### Re: How would I turn console error output into "Links" to files? If you are using a build system (which you should) than you can just modify it to include a "file_regex" setting which does the same as @waterup proposed but without a plugin. See http://docs.sublimetext.info/en/latest/ ... ml#options. FichteFoll Posts: 407 Joined: Fri Mar 16, 2012 11:49 pm Location: Germany ### Re: How would I turn console error output into "Links" to files? Thanks for the replies, I'm using SublimeText2 right now. I've looked at the "file_regex" and it's almost working, I've never used RegEx before though (been meaning to learn for ages) How would I "regex-ify" the error string? All I need is the path and line number from this: Code: Select all E:\Games\Projects\SA-MP\ScavengeSurvive\gamemodes\../scripts/SSS/Char/Animations.pwn(15) : error 017: undefined symbol "symbol" "E:\Games\Projects\SA-MP\ScavengeSurvive\gamemodes\../scripts/SSS/Char/Animations.pwn" being the path and (15) being the line number. Right now, I'm using Code: Select all (...*?)(([0-9])) and it ends up with this file path: E:\Games\Projects\SA-MP\ScavengeSurvive\gamemodes\../scripts/SSS/Char/Animations.pwn( That trailing bracket at the end is the last issue to resolve, would be awesome if someone would help me with the regex Southclaw Posts: 6 Joined: Wed Apr 10, 2013 8:31 pm ### Re: How would I turn console error output into "Links" to files? Code: Select all (...*?)(([0-9])) Means: Code: Select all 1:(Match any character; then match any character; then match an indefinite amount of characters UNTIL the next pattern matches)2:( 3:(match 0-9)) And translates to "match at least 2 (because of ..) characters and then everything until you find the first number. Note: "N:()" are the capturing groups. What you are searching for is: Code: Select all (.*?)$$([0-9]+)$$ FichteFoll Posts: 407 Joined: Fri Mar 16, 2012 11:49 pm Location: Germany ### Re: How would I turn console error output into "Links" to files? Thanks, guys! arnisandy Posts: 6 Joined: Thu Jul 05, 2012 1:29 pm ### Re: How would I turn console error output into "Links" to files? Just to follow up, here's the code I that worked successfully to allow the output results to be clickable for the updated CScope plugin. Note that I also had to update the output generated in the output view to show the full path to the file. While I might have been able to set a working directory for the relative paths I felt the output would be more consistent to mimic the standard Find Results output. So output like: Code: Select all In folder C:\workspace\schwanky_appFound 2 matches for C symbol: doSchwankyStuff--------------------------------------------------C:\workspace\schwanky_app\schwanky_api.h: 863 [scope: <global>] int doSchwankyStuff(int stuff);C:\workspace\schwanky_app\schwanky_api.c: 619 [scope: doSchwankyStuff] int doSchwankyStuff(int stuff) can be processed in the results command like this: Code: Select all class CscopeDisplayResultsCommand(sublime_plugin.TextCommand): def run(self, edit, symbol, output): cscope_view = self.view.window().new_file() cscope_view.set_scratch(True) cscope_view.settings().set("result_file_regex",r'(^([a-zA-Z]:)?([\\/][a-zA-Z0-9._-]+)+([\\/])?)') cscope_view.settings().set("result_line_regex",r'^[\s]*([0-9]+) \S+') cscope_view.set_name("Cscope - " + symbol) cscope_view.insert(edit, 0, output) if get_setting("display_outline") == True: symbol_regions = cscope_view.find_all(symbol, sublime.LITERAL) cscope_view.add_regions('cscopesublime-outlines', symbol_regions[1:], "text.find-in-files", "", sublime.DRAW_OUTLINED) cscope_view.set_syntax_file(CSCOPE_SYNTAX_FILE) I think a build system might likely have been able to implement the functionality of this plugin, but since I was already walking down the road of updating the existing plugin I implemented as such. Thank you for the help, guys! arnisandy Posts: 6 Joined: Thu Jul 05, 2012 1:29 pm ### Re: How would I turn console error output into "Links" to files? Your first regexp is overkill. r"(.*):$" would work just fine. And except for the missing get_setting definition (which is probably part of the plugin you're editing) it looks fine.

But does F4 (for the next "error") also work on standard views? I thought that was only possible with output panels.
FichteFoll

Posts: 407
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany