hyperlinking example

Questions on using RSyntaxTextArea should go here.

Moderator: robert

hyperlinking example

Postby omadawn » Tue Sep 11, 2012 6:38 am

I'm poking around trying to figure out how to get it to support hyperlinks. I see how to check an editor pane to see if it is supported but not how to generate the links themselves.

Is there a sample out there?
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: hyperlinking example

Postby robert » Wed Sep 12, 2012 1:30 pm

Unfortunately, only links of the form "www. ...", "http:// ...", etc. are currently supported. Are you looking to create hyperlinks to other files, or with other "display" text than the token's lexeme?

The dirty details of how it works:

A TokenMaker creates hyperlinks by setting a specific property on a Token it creates. See for example the <EOLCOMMENT> and <DOCCOMMENT> sections at the bottom of JavaTokenMaker.flex. A snippet:

Code: Select all
<EOL_COMMENT> {
   [^hwf\n]+   {}
   {URL}      { int temp=zzStartRead; addToken(start,zzStartRead-1, Token.COMMENT_EOL); addHyperlinkToken(temp,zzMarkedPos-1, Token.COMMENT_EOL); start = zzMarkedPos; }
   [hwf]      {}
   \n         { addToken(start,zzStartRead-1, Token.COMMENT_EOL); addNullToken(); return firstToken; }
   <<EOF>>      { addToken(start,zzStartRead-1, Token.COMMENT_EOL); addNullToken(); return firstToken; }

}


Here, there's a pattern {URL} that matches (virtually?) all URL's starting with http/file/ftp, etc. If one is found, we call addHyperlinkToken(), which eventually calls a method in the parent AbstractJFLexCTokenMaker class:

java code:

public void addToken(char[] array, int start, int end, int tokenType,
int startOffset, boolean hyperlink) {
super.addToken(array, start,end, tokenType, startOffset, hyperlink);
zzStartRead = zzMarkedPos;
}


That last boolean argument being set to true makes the token underlined and clickable when Ctrl+hovered over.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: hyperlinking example

Postby omadawn » Thu Sep 13, 2012 7:15 am

I am actually trying to create web hyper links but poking around in the RSTA code and from your document there I'm starting to think I am misunderstanding the functionality.
If I'm reading it correctly now it seems like what the 'hyperlinking' functionality does is if I have a link like http://www.somedomain.com somewhere in my code then having hyperlinking enabled will make RSTA turn that into a clickable link.

What I actually need to do is have the regular functions of the language be clickable links. Our code is fully documented online. I actually think looking at it that tooltips might be a better way to get what I want but I don't see how to do that either.

Here's some sample iRules code:

when HTTP_REQUEST {
HTTP::redirect https://[HTTP::host][HTTP::uri]
}


I wanted double clicking on
HTTP::redirect
HTTP::host
HTTP::uri
To take me to their corresponding online documentation.


But I just had a thought that perhaps it would be better, instead of just building this list of links to actually pull down the summaries and build a tool tip for them so that if you hover over them they pull up the summary. I can have a clickable link within the tooltip for those who want 'further documentation' can't I?

So then the question is... How do I create these tooltips. I wasn't able to glean that from the code or the forum.






If you care what the iRule does is when we recieve an HTTP request we issue a redirect to https://<whatever domain name they requested>/<whatever URI they requested>
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: hyperlinking example

Postby omadawn » Thu Sep 13, 2012 8:28 am

Ok, I figured out how to make my own tooltips. I have to write a parser. I've copied your TaskTagParser and I'm modifying it to show other tags.
I've tried a couple of mechanisms for adding a hyperlink in the tooltip and none are working so that question still stands. Is it possible? if so how?



On a side note
Task tag parser seems to just show a tool tip with the task itself. Does it also then provide some sort of mechanism I could use to get a tasks list and display it in another window or something?
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: hyperlinking example

Postby robert » Thu Sep 13, 2012 1:34 pm

Looking at the code, it appears that hyperlinks in tool tips isn't handled as well as hyperlinks in auto-complete description windows...

Anyway, If I'm understanding you correctly, what you're looking for is a way to build your own tool tip for when the user hovers the mouse over some text, and have that tool tip contain a clickable link that goes to some online doc, is that right? If so then it looks like you're (unfortunately) correct. RSTA only allows Parsers to add extra tool tips to it. If you check out the SpellChecker project from the RSyntaxTextArea SVN, or check out the source from SourceForge, you can examine the SpellingParser class to see an example. It identifies misspelled words, and if the user hovers over them in the editor, they get a tool tip with replacement suggestions. Clicking on one of the suggestions replaces the text in the editor.

As for getting the ParserNotices returned by a Parser, I believe currently the application has to call textArea.getParserNotices() and iterate through them, identifying those that came from a particular Parser somehow (either by ParserNotice subclass type, or checking notice.getParser() against a reference to the actual Parser, etc.). RText uses RSTA and has a docked window to display both the Task Items and all misspelled words in a document (from the TaskTagParser and SpellChecker, respectively).
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: hyperlinking example

Postby omadawn » Fri Sep 14, 2012 7:39 am

I just finished getting the tooltips working and populated. I literally just spent the past several hours writing a web scraper to parse my companies online documentation and build a file with all the text I want to include. Then I took your task parser and gave it a baby. I plan on building in the task list functionality at some point as well but I'll be putting that off for a while. The underlying support is still there in the parser I'm just not sure when I'll do the actual task list itself.

The tool tip texts can't contain clickable hyperlinks? That is unfortunate. I might have to start poking around in your code. ^_^ Being able to go to the online documentation is going to be hugely important. I'm only pulling down the command summaries and syntax overviews. I have no interest in putting the whole web page into the tool tip. I'm already stuffing the link into the tooltip I just need to be able to click it.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: hyperlinking example

Postby robert » Tue Sep 18, 2012 2:50 am

Aye, that's an area that needs improvement. The code completion "description" window, that pops up beside the completion choices window, does support clickable links, but unfortunately the tool tips do not.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: hyperlinking example

Postby omadawn » Thu Sep 27, 2012 2:55 am

You've mentioned checking out from CVS. I've only grabbed the source from sourceforge. How do I get the source out of CVS I believe is what you're using? Clickable links is a requirement for my editor and I prefer the idea of having them be clickable links within tooltip text. I intend to hack it into your code and would like to send my changes back to you. How would you like them?
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: hyperlinking example

Postby robert » Thu Sep 27, 2012 1:21 pm

It's actually a Subversion repository, found here:

http://svn.fifesoft.com/svn/RSyntaxTextArea

That repository has all of the RSTA-related projects in it. You'll want to check out the trunk of the RSyntaxTextArea project, and if you want to mess with any other code, such as AutoComplete, you can grab it there as well.

As far as changes, by far the best approach would be to create a patch file via Eclipse or whatever IDE you're using, and send it to me.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: hyperlinking example

Postby omadawn » Fri Sep 28, 2012 6:28 am

Will do ty.

Subversion was what I was thinking. I typed cvs by reflex.

I'm going to just start saying rcs and let that mean what whomever I'm talking to is using. ^_^

I've finally been won over by git myself.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 6 guests

cron