TokenMaker with ignorecase-support?

Questions on using RSyntaxTextArea should go here.

Moderator: robert

TokenMaker with ignorecase-support?

Postby silver » Sun Apr 08, 2012 1:36 pm

Hi,

is it possible to add "ignorecase"-support to the rsyntaxtextare for a style?

For example "SyntaxConstants.SYNTAX_STYLE_JAVA" highlights the reserved word "break" but not "Break".
Or must I create a own Style with the col "TokenMakerMaker" for all words and variants like "breaK" or "breAk"?
I use version 2.0.2, many thanks.

Martin

Code: Select all
 
...
JPanel contentPane = new JPanel(new BorderLayout());
      RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
      textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
      textArea.setCodeFoldingEnabled(true);
      textArea.setAntiAliasingEnabled(true);
      contentPane.add(new RTextScrollPane(textArea))0;
...
silver
 
Posts: 3
Joined: Wed Feb 29, 2012 5:27 pm

Re: TokenMaker with ignorecase-support?

Postby silver » Mon Apr 09, 2012 5:11 pm

Maybe it is possible to modified the "parser" to handle the "content" and the "tokens" always with "toLowerCase" ?

Example: "content" --> user insert "brEak"
the parser modified "brEak" with toLowerCase --> "break" and then checks the tokenlist?
silver
 
Posts: 3
Joined: Wed Feb 29, 2012 5:27 pm

Re: TokenMaker with ignorecase-support?

Postby robert » Tue Apr 10, 2012 2:24 am

Hi Martin,

Unfortunately there's no "easy" way to toggle whether the Java highlighting is case sensitive per se. You can get around this in one of the following two ways, however, in order of increasing difficulty:

  • Download TokenMakerMaker from RSyntaxTextArea's SVN repository and use that to create a clone of Java syntax highlighting. It should be very easy to add all keywords, data types, and comment types. Note that TokenMakerMaker has been revisited since that blog entry and has more features now than it did then (I plan on creating a new blog entry about its new features soon).
  • Build your own version of RSyntaxTextArea with the Java highlighting modified to not be case sensitive. To do this, download the RSTA source and JFlex. Then, modify org/fife/ui/rsyntaxtextarea/modes/JavaTokenMaker.flex so that it includesan "%ignorecase% statement between its existing "%unicode" and "%type ..." statements near the top of the file, like so:

    Code: Select all
    %unicode
    %ignorecase
    %type org.fife.ui.rsyntaxtextarea.Token


    Then, follow the instructions at the top of the .flex file on how to build the corresponding .java file via JFlex and modify it by hand to add the final tweaks necessary for it to work in RSyntaxTextArea.

I know the second item sounds daunting, but it really isn't! Though I do think the TokenMakerMaker route might be the best solution for you. Besides a new blog post about its new functionality, I also plan on making a pre-compiled version available soon as well (currently you must build and/or run it from source).
User avatar
robert
 
Posts: 760
Joined: Sat May 10, 2008 5:16 pm

Re: TokenMaker with ignorecase-support?

Postby silver » Thu Apr 12, 2012 6:03 pm

Hi robert,

thanks for the fast answer. I think I wait for the new features in TokenMakerMaker and the instrutcion in the upcoming blog entry. Maybe the great tools has a checkbox "ignorecase" in the keywords-section ;).

But I will test to second option too, but I a absolute noob in flex/jflex.

Martin
silver
 
Posts: 3
Joined: Wed Feb 29, 2012 5:27 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests