Autocomplete and Language Add-on

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Autocomplete and Language Add-on

Postby groggy » Sun Feb 17, 2013 1:24 am

Hey guys,

I have a very similar question. I cannot find a download link for the two RSyntaxtextarea Add-ons
Autocomplete and the Language thing. So I wanted to ask if anyone know a link for the newest version of the Add-ons
groggy
 
Posts: 34
Joined: Sun Feb 17, 2013 1:11 am

Re: Autocomplete and Language Add-on

Postby robert » Sun Feb 17, 2013 7:18 pm

Hi Groggy,

The latest AutoComplete can be grabbed from SourceForge, just like RSTA itself:

https://sourceforge.net/projects/rsyntaxtextarea/files/

The RSTALanguageSupport project is not available on SourceForge yet (though I should probably put it there, as it's "good enough" for some of its languages now). Since it's been less stable than RSTA, AutoComplete, and SpellChecker, it's been only available through its Subversion respository here:

http://svn.fifesoft.com/svn/RSyntaxTextArea

You'd need to check out the trunk of the "RSTALanguageSupport" project in that repository. You'll probably need to check out RSyntaxTextArea and AutoComplete along with it, as it may well depend on new features in those libraries not yet in the binaries posted to SourceForge.

Let me know if you have any questions!
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm

Re: Autocomplete and Language Add-on

Postby groggy » Mon Mar 04, 2013 9:43 pm

Thank for the answer :) I just forget to go online ^^ I've got one more question:
In the little article about rsta and its functions you wrote sth about macros... What do you meen with that?
groggy
 
Posts: 34
Joined: Sun Feb 17, 2013 1:11 am

Re: Autocomplete and Language Add-on

Postby robert » Tue Mar 05, 2013 4:16 am

Macros are simply recordings of actions in an RSyntaxTextArea that can be played back. You can set up an application so that the user can choose to "record" a set of actions in the editor, then play them back later. The relevant methods on the RSyntaxTextArea class (inherited from RTextArea, but see Javadoc for all RSTA classes here):

  • public static void beginRecordingMacro()
  • public static void endRecordingMacro()
  • public static void loadMacro(Macro)
  • public static Macro getCurrentMacro()

The Macro class encapsulates the set of actions. It can be loaded and saved to disk via its constructors and its saveToFile() method. Macros are saved as simple XML representations of the actions to execute.

The idea is that an application that supported macros would have say a menu item, "Begin Recording Macro". On clicking it, all editor actions (typing, selecting text, etc.) are recorded to a Macro instance (via textArea.beginRecordingMacro()). A second menu item, "End Recording Macro", is clicked, resulting in textArea.endRecordingMacro() being called. The user can then be prompted for macro name, and the macro saved to a file. The application could display a list of previously recorded macros, say in a menu, for the user to play back.

RText used to have this functionality, but it was removed in favor of scripted macros (Groovy and JavaScript). It's kind of a shame really, as the two are not the same functionality, so perhaps I'll add it back some day...
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm

Re: Autocomplete and Language Add-on

Postby Guest » Tue Mar 05, 2013 5:11 pm

Thanks ro set your a great help :)

I wanted to create my own style so I checked out your examples and found sth strange : there are two tokens for reserved words. I put two different colors on them but I couldn't see any difference! Most of the time I'm using java as syntax style. Can you tell me which words or category of words each token represents?
Guest
 

Re: Autocomplete and Language Add-on

Postby groggy » Tue Mar 05, 2013 5:13 pm

Sorry I forget to login ^^
groggy
 
Posts: 34
Joined: Sun Feb 17, 2013 1:11 am

Re: Autocomplete and Language Add-on

Postby robert » Thu Mar 07, 2013 4:23 am

With the built-in Java syntax highlighting, only the keyword "return" is painted with TokenTypes.RESERVED_WORD_2. It's highlighted (possibly) differently because it denotes an exit point for a method, which users may like to make stand out over other keywords.

More generally though, each language is free to use the two different keyword types however they want (perhaps some language indeed has two different logical types of keywords), but for the built-in languages, I believe RESERVED_WORD_2 is either used for "return" only (C, C++, Java, etc.), or not used at all.
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm

Re: Autocomplete and Language Add-on

Postby groggy » Thu Mar 07, 2013 9:05 pm

Anso if I load the XML files would I GET xml code or already " parsed code" and if not how Can I parse it?
groggy
 
Posts: 34
Joined: Sun Feb 17, 2013 1:11 am

Re: Autocomplete and Language Add-on

Postby robert » Fri Mar 08, 2013 1:57 pm

I'm sorry, I don't understand what you're asking. Simply setting the syntax style to SYNTAX_STYLE_XML will get you syntax highlighting. You'd set up syntax highlighting and code folding like so:

java code:

textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
textArea.setCodeFoldingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(textArea);


If by "parsed code" you mean squiggle underlining for syntax errors, then no, that doesn't come automatically. You have to use RSTALanguageSupport and enable it on the RSTA instance, as described in the project's readme file:

java code:

RSyntaxTextArea textArea = new RSyntaxTextArea(25, 70);
LanguageSupportFactory.get().register(textArea);
...
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm

Re: Autocomplete and Language Add-on

Postby groggy » Fri Mar 08, 2013 4:02 pm

I meant the macro xml files. If I save them and open them as a normal "file" I just geTt xml code. My question is if there is a method or class I dunno which converts the XML file to a "normal" text so the user can see easily what he did
groggy
 
Posts: 34
Joined: Sun Feb 17, 2013 1:11 am

Next

Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron