Own syntax schemes

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Re: Own syntax schemes

Postby robert » Tue Dec 01, 2009 12:18 pm

I'll revisit this after the next release, which should hopefully be soon (sometime this week).
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby pitoniakm@msn.com » Tue Dec 01, 2009 8:12 pm

many thanks... :)
pitoniakm@msn.com
 

Re: Own syntax schemes

Postby cent01 » Sun Jan 31, 2010 1:22 pm

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

Postby robert » Wed Feb 03, 2010 1:50 pm

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).
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby pitoniakm@msn.com » Sun Mar 28, 2010 1:27 pm

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);
public void clearAddedHighlightedIdentifiers();
pitoniakm@msn.com
 

Re: Own syntax schemes

Postby robert » Fri Apr 09, 2010 12:05 pm

I skimmed back over this thread, and if I'm understanding my original suggestion correctly ( :D ), 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.
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby Taneeda » Mon Apr 16, 2012 6:48 am

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{...}?
Image
User avatar
Taneeda
 
Posts: 10
Joined: Fri Jun 19, 2009 12:35 pm
Location: Oldenburg, Germany

Re: Own syntax schemes

Postby robert » Mon Apr 16, 2012 9:54 pm

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...
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm

Re: Own syntax schemes

Postby Taneeda » Tue Apr 24, 2012 4:56 pm

yes, sure, I'd be glad to help :)
Image
User avatar
Taneeda
 
Posts: 10
Joined: Fri Jun 19, 2009 12:35 pm
Location: Oldenburg, Germany

Re: Own syntax schemes

Postby robert » Thu Apr 26, 2012 1:38 pm

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);
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm

PreviousNext

Return to Help

Who is online

Users browsing this forum: Google [Bot] and 3 guests