Author Topic: URI link jump to line  (Read 134 times)

sulliwk06

  • Junior Community Member
  • Posts: 3
  • Hero Points: 1
URI link jump to line
« on: October 12, 2017, 06:06:52 pm »
I've been trying to wrestle with this for a while with no luck, so I thought I would ask if anyone has found a way to do it.  I'd like to add some links to my code to jump to a particular line in a particular file.

For example:
file://path\to\file#line=475

The closest method I could find to do that was to change the "Open Application" In "Options>Languages>File Extension Manager" to point to a batch file I made which parses out the line number and calls "vs "%Filename%" "-#goto-line %LineNumber%"".
The problem is that it seems I can't even get my batch file called because the file protocol recognizes that "path\to\file#line=475" isn't a file, giving me the error "Windows cannot find 'file...' Make sure you typed the name correctly, and then try again."

Does anyone have another way of doing something like this?  Should I make this some feature request?

I am running SlickEdit 2012 (v17.0.3.0 64-bit)

Graeme

  • Senior Community Member
  • Posts: 1980
  • Hero Points: 226
Re: URI link jump to line
« Reply #1 on: October 13, 2017, 10:44:54 am »
Not sure if this is what you're looking for but if you put the cursor on the line with file:// and run the command flink it will open that file at the specified line.  If the line starts with http it will open it in a browser.  Right click in slick edit window and select "edit this menu" and add the flink command to the menu if you want to be able to do right click -> flink.

Code: [Select]
_command void flink() name_info(',')
{
   _str s1, s2, s3;
   
   get_line(s1);
   if ( pos('http',s1) == 1  ) {
      safe_goto_url(s1);
      return;
   }
   parse s1 with 'file://' s2 '#line=' s3;
   s2 = maybe_quote_filename(s2);
   if ( file_exists(s2) ) {
      edit(s2);
      goto_line(s3);
   }
   else {
      message("no such file " :+ s2);
   }
}


Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2213
  • Hero Points: 275
Re: URI link jump to line
« Reply #2 on: October 13, 2017, 11:22:39 pm »
If your target file is in your workspace and is something that has tagging (or can have tags, like HTML or XML with the "id" tag), you could use tagging to make this work for you:

XML:
<mytag id="JUMP_TO_ME">

C++:
// JUMP_TO_ME  <-- Ctrl+Dot here