Own syntax schemes

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Re: Own syntax schemes

Postby omadawn » Tue Aug 21, 2012 4:28 am

Alrightythen

Modified the .jlex file per directions and it's working. Now I need to figure out what my colors should be for various components.

Thanks again for the assistance and the beautiful library it is pretty awesome.


I even implemented a completion provider which was also pretty darned simple.

The completion provider is having a similar issue. If I type HT and hit ctrl+space it comes up with a list of my samples. Including things like HTTP::respond however if I continue to type it closes the list once I get to HTTP if I try and hit crtl+space again it starts over.

I'm not terribly worried about this particular issue. I can select the correct component from the pull down list. Now that syntax highlighting is fully featured I'm pretty much ready to start giving it to other people in my organization who will use it.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Own syntax schemes

Postby robert » Tue Aug 21, 2012 1:02 pm

The completion provider is having a similar issue. If I type HT and hit ctrl+space it comes up with a list of my samples. Including things like HTTP::respond however if I continue to type it closes the list once I get to HTTP if I try and hit crtl+space again it starts over.


Are you extending DefaultCompletionProvider? If so, be sure to extend the isValidChar(char) method to include ':'. That method dictates what characters are considered "word" characters as far as code completion is concerned.

java code:

protected boolean isValidChar(char ch) {
return ch==':' || super.isValidChar(ch);
}
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby omadawn » Wed Aug 22, 2012 2:11 am

Actually I'm not extending it for this. I just instantiated an instance of DefaultCompletionProvider then ran a whole bunch of:
provider.addCompletion(new BasicCompletion(provider, word));


That seems pretty straight forward thought. i've added your notes to my bug list and extend it when it becomes more of an issue. TY again.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Own syntax schemes

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

Copied, paste, added '_', done.

It works it was just as simple as it seemed. Thank you again.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Own syntax schemes

Postby omadawn » Thu Sep 27, 2012 3:03 am

So I published my editor out to my company's community resource as well as sending it to a bunch (read everyone I could talk into trying it) of my coworkers. To my surprise the single most common request was automatic (no ctrl+space) autocomplete. In fact it's one of the very few questions I've even ever gotten twice but it's come back from about a quarter to a third of my testers.

I already have a document listener implemented. I needed it for one of the features but can't remember which. ^_^ It seems like I should be able to just call whatever mechanism gets called by ctrl+space in the doc listener but even though I've peeked through the javadocs and code this magical mechanism still remains illusive. Do you have any advice on how I can make autocomplete happen without requiring ctrl+space?

Also if this is a feature that you would like to have available in the RSTA source itself (optionally of course) then let me know and I'll see if I can hack it into the RSTA source instead of implementing it myself.
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Own syntax schemes

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

On your CompletionProvider, try calling:

java code:

public void setAutoActivationRules(boolean letters, String others);


This determines what characters will automatically display the completion popup. You'll want to pass "true" for the "letters" parameter, and can add anything else (such as "_", ":", etc.) in the "others" parameter. I believe all characters in "others" will have to be accepted by your isValidChar() override of course, for everything to work properly.

You can also tweak the delay after which the popup appears, by calling AutoCompletion.setAutoActivationDelay(int ms) on your AutoCompletion instance. You can set it to 0 to have the popup display automatically, if folks want that as well. I personally find that really annoying, but I know Visual Studio does it (at least, it used to do it). It might be more useful if the completion popup displays as you're typing any character. Ideally it would be an option the users could set in your application. :)

Hope this helps!
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

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

Yeah there's a few things that I want to set as options. I need to add a separate preferences section for them. Things like auto close braces, etc.


So I was messing around trying to 'figure out how to get this to work.' and I found setAutoActivation(boolean). I thought I had seen a thread say this wasn't yet supported. It must have been old. You were probably assuming I had tried that already.
Needless to say it works now. ^_^
omadawn
 
Posts: 38
Joined: Sat Jul 21, 2012 7:39 pm

Re: Own syntax schemes

Postby bax » Fri Nov 30, 2012 7:35 am

Hi, guess this is the right thread to propose a new language to be supported.
Drools.
There are a few keywords to highlight : [ 'import', 'dialect', 'rule', 'when', 'then', 'end', 'global' '$<var_name>'].
The folding should be straightforward as the file consists of imports, global declarations and a lot of rules, every rule having a well determined structure :
rule "rule name"
when
// preconditions
then
// do smth
end

Of course the entire language reference has a lot of other details about language structure.
Language reference

It's a language that gains popularity our days.
Thank you.
bax
 
Posts: 4
Joined: Fri Nov 16, 2012 4:42 pm

Previous

Return to Help

Who is online

Users browsing this forum: No registered users and 6 guests

cron