Some questions

General Discussion on RSyntaxTextArea.

Moderator: robert

Some questions

Postby misi » Wed Jan 18, 2012 9:34 am

Hi,

first: this is a great tool. Very nice work.

I have some questions:

1. I need a listener, which will be called, when something has changed by key or mouseclick.
2. When I add your component to my application, there is not shortcut for a keystroke like Strg-X. Am I doing something wrong?
3. Can I expand a format? Example: for an internal reason, we need in css, something like @xyz.any.possible.string@, which will be parsed later. Can this field be highlighted?

Michael
misi
 
Posts: 1
Joined: Wed Jan 18, 2012 8:35 am

Re: Some questions

Postby robert » Thu Jan 19, 2012 1:10 am

Hi Michael,

Glad you find RSTA useful!

  1. Simply add a standard DocumentListener to the text area's document. RSTA is a simple JTextComponent like any other.

    Code: Select all
    textArea.getDocument().addDocumentListener(new MyDocumentListener());

  2. All standard keyboard shortcuts should be there, and more. Are you using 1.5.x or the 2.0 beta? And is your application running as an applet? I know applets have some restrictions when it comes to clipboard access, though I thought it was just reading from it, not necessarily writing to it.
  3. Are you asking if you make RSTA use a specific type of highlighting, but make it also colorize additional tokens that you define? If so then no, it's not necessarily easy. You can try using TokenMakerMaker, which is an attempt at a GUI tool that generates a custom TokenMaker class (e.g. a scanner) or your user-defined language. It hides all the RSTA-specific yuckiness from you, and generates both a .java file to include in your project, as well as the JFlex .flex file it was generated from. Naturally, it's somewhat limited in what it can generate, but it might be sufficient for your needs. It's designed to handle simple languages with C-style syntax. I've always wanted to update it to include the ability to find tokens by regexes (probably what you'll need for CSS I'm thinking), but never get around to it.

Also, you could create your own TokenMaker without using the TokenMakerMaker program. It's not officially documented, but you can follow the instructions in this old thread. You'd start with the CSSTokenMaker.flex file, and could possibly just add this one line to the YYINITIAL state, if I'm understanding you cocrrectly:

Code: Select all
"@"[A-Za-z0-9\.]+"@"   { addToken(Token.VARIABLE); }


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


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 3 guests