Bulit in support for highlighting variables?

General Discussion on RSyntaxTextArea.

Moderator: robert

Bulit in support for highlighting variables?

Postby omadawn » Sat Aug 04, 2012 2:56 am

Is there built in support for highlighting variables in languages which do not use any special designator like $? Languages like Java and TCL.

I've seen some comments on how to generate a completion provider if you want autocompletion for variables you've declared but didn't see anything on simply highlighting them.

Thanks
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Bulit in support for highlighting variables?

Postby robert » Mon Aug 06, 2012 3:35 am

Unfortunately, there's no built-in support for this. Such a feature really requires semantic knowledge of the language being highlighted, and thus is very language-specific.
User avatar
robert
 
Posts: 796
Joined: Sat May 10, 2008 5:16 pm

Re: Bulit in support for highlighting variables?

Postby omadawn » Tue Aug 07, 2012 9:24 pm

I went through the javadocs looking but hadn't seen anything so I didn't think so. I was just hoping. I figured if it existed it would be language specific and was hoping there was a '.setHighlightUserVariables(boolean)' method on the built in syntax schemes or something I could enable. ^_^

Since it's TCL based and TCL does us the courtesy of using set in front of the creation of variables I suppose I could extend the tokenMaker (Now that I know how. Thank you again) and implement this myself.

Do you have any reasonably straight forward recommendations for how I'd trigger that? IE based on a 'text changed' event or is there some more appropriate event that I should go off in order to avoid seriously bogging down my code?
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Bulit in support for highlighting variables?

Postby robert » Fri Aug 10, 2012 12:40 pm

Swing has javax.swing.text.DocumentListener which allows you to get notified when the Document of a text component is modified. That's probably what you'd want to use.
User avatar
robert
 
Posts: 796
Joined: Sat May 10, 2008 5:16 pm

Re: Bulit in support for highlighting variables?

Postby omadawn » Sat Aug 18, 2012 12:07 am

I was hoping that RSTA would have some easier function that would solve my problem like it seems to for nearly everything else that I'm doing. ^_^ I was hoping to not have to resort to a documentListener I briefly looked at implementing one of those and it didn't seem as simple as most of what I've been able to do w/ RSTA.

TY.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Bulit in support for highlighting variables?

Postby omadawn » Sun Aug 19, 2012 7:54 pm

Ok, I implemented a document listener to do some updates on my nav tree and it was actually pretty simple. Guess I was nervous for nothing. I probably looked at that when I was first figuring out the swing stuff and just didn't want to have to override yet another swing method. TY again.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron