Own syntax schemes

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Re: Own syntax schemes

I'll revisit this after the next release, which should hopefully be soon (sometime this week).

robert

Posts: 837
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

many thanks...
pitoniakm@msn.com

Re: Own syntax schemes

Hello.
I try to specify my own simple syntax scheme. I can generate the TokenMaker implementation by jflex, but more suitable using the simple api to add keywords hilighting as above with addHighlightedIdentifier. Or to do the custom TokenMaker with TokenMakerMaker. Above was the post with betaversion of this sofware. Is it possible to get the beta? I agry test it by using for generation TokenMaker for my app and do bug report and other feedback.
cent01

Posts: 1
Joined: Sun Jan 31, 2010 1:06 pm

Re: Own syntax schemes

Is it possible to get the beta?

Sure, I'll send it to you ASAP. I think I'm actually almost ready to drop the source into a SVN repository. I've just been spread so thin lately that I haven't gotten as much progress done on this as I'd like (as always).

robert

Posts: 837
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

robert,

changed companies and am finally back on this issue...
any chance i could bribe you to do the dynamic addition of new keywords we spoke about before now?

the ability to add keywords via:

public void addHighlightedIdentifier(String word, int tokenType);
public boolean removeHighlightedIdentifier(String word);
pitoniakm@msn.com

Re: Own syntax schemes

I skimmed back over this thread, and if I'm understanding my original suggestion correctly ( ), it would be a somewhat limited solution. If I were to add methods such as "addHighlightedIdentifier()" to the TokenMaker interface (and implementations in AbstractTokenMaker so they were always there), you'd only be able to use this feature by using RSyntaxDocument.setTokenMaker(TokenMaker):

java code:

JavaTokenMaker tm = new JavaTokenMaker();tm.addHighlightedIdentifier("customKeyword", Token.RESERVED_WORD);((RSyntaxDocument)textArea.getDocument()).setSyntaxStyle(tm);


If your application had multiple instances of RSTA, whenever you wanted to update the keywords, you'd have to loop through each one:

java code:

for (int i=0; i<textAreas.size(); i++) {   RSyntaxTextArea textArea = textAreas.get(i);   JavaTokenMaker tm = (JavaTokenMaker)((RSyntaxDocument)textArea.getDocument()).getTokenMaker(); // Method does not exist currently   tm.clearAddedHighlightedIdentifiers();   // Add new identifiers}


Not very clean, but as I imagine this to be an uncommon need it may be sufficient. I'd like to see something cleaner though.

robert

Posts: 837
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

That was a long time ago since i used RSyntaxTextArea the last time, about two years... at the moment i try to create a latex ide with java, so i need syntax highlighting and i remembered me to RSystanxTextArea. This is a great editor component and i want to use it again, but i don't know how create syntax highlighting to latex documents. I need custom highlighting to highlight some special characters, parts of the text document.

At the weekend i tried to implement a basic highlighting example with JFlex, but it doesn't worked. I think i should spend more time to JFlex ^^

What would be the preferred way to add syntax highlighting to RSyntaxTextArea? At the developers: How do you implement syntax highlighting to a new language? Maybe, could you give a basic example, with multi line highlighting with or without JFlex?

Greetz

Edit:
Just a moment later, i found the TokenMakerMaker tool, looks exactly to that what i need
--> http://fifesoft.com/blog/?p=510

Edit:
I tried the TokenMakerMaker. Looks nice and works perfect to highlight simple keywords.
I noticed, the { and } chars will be highlighted with border. Is it possible to add functionality to TMM to add more identifiers to highlight with border? Additionally, is it possible to set the color to the string inside the { }, e.g. inside \title{asdasd}? What about folding, e.g. between \begin{...} and \end{...}?

Taneeda

Posts: 10
Joined: Fri Jun 19, 2009 12:35 pm
Location: Oldenburg, Germany

Re: Own syntax schemes

Taneeda,

TokenMakerMaker is a little too basic of a tool to highlight something like Latex for the moment. Highlighting stuff in curly braces might be doable in the future if it is updated to support using regexes as keywords/functions/data types (i.e. highlight all stuff matching "{\w+}" as a function, for example).

But the other features might be a little trickier for TokenMakerMaker. Latex is a language others want (see this poll), so perhaps I should bite the bullet and add it as a proper supported language. Would you be able to provide feedback if I worked on this? Since I don't use it personally I'd want a real user to verify that the highlighting is as you'd expect. We should be able to add code folding support as well, as long as it's something relatively simple like matching \begin{...} and \end{...} tokens like you mentioned.

Just let me know...

robert

Posts: 837
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

yes, sure, I'd be glad to help

Taneeda

Posts: 10
Joined: Fri Jun 19, 2009 12:35 pm
Location: Oldenburg, Germany

Re: Own syntax schemes

I've made a first pass at LaTeX syntax highlighting and code folding. I'm relying on you (or anybody else) to tell me what's wrong or missing Either grab it from SVN, or use the pre-built jar I've uploaded here:

http://fifesoft.com/temp/rsyntaxtextarea.jar

Use it like normal:

java code:

textArea.setSyntaxStyle(SyntaxConstants.SYNTAX_STYLE_LATEX);textArea.setCodeFoldingEnabled(true);


robert

Posts: 837
Joined: Sat May 10, 2008 5:16 pm

PreviousNext