CodeTemplate related request

Questions on using RSyntaxTextArea should go here.

Moderator: robert

CodeTemplate related request

Postby omatzura » Sat Nov 15, 2008 3:52 pm

Hi!

Could you please make the CodeTemplate-related classes and methods public so we can provide our own CodeTemplate management?

Thanks in advance!

/Ole
eviware.com
omatzura
 
Posts: 3
Joined: Mon Oct 06, 2008 7:39 pm

Re: CodeTemplate related request

Postby robert » Sat Nov 15, 2008 10:25 pm

Certainly. Could you be more specific about what you'd like to do though?

The code template functionality needs a little work for this to happen, but it is certainly doable. What is it lacking that you would like to be able to do?
User avatar
robert
 
Posts: 805
Joined: Sat May 10, 2008 5:16 pm

Re: CodeTemplate related request

Postby omatzura » Sat Nov 15, 2008 11:26 pm

Great!

I want to be able to add/remove CodeTemplates dynamically, this seems to require the following:

1) make CodeTemplate and CodeTemplateManager classes public
2) make the getCodeTemplateManager method in RSyntaxTextArea public so I can work with it directly
3) make CodeTemplateManager.getTemplates/replaceTemplates public, and maybe also provide a removeTemplate method

Also, I will want to create dynamic CodeTemplates (ie not with static before/afterText), so maybe refactoring the CodeTemplate class into an interface that only contains id-related and getContentToInsert methods and then implementing the current in a "StaticCodeTemplate" class. Not sure of course how this works with your save/load routines, maybe saveTo/loadFrom would be in this interface, or an optional "PersistableCodeTemplate" sub-interface that can be implemented for templates that should be compatible with the existing load/save code.. Anyway, this is not really required, I can just override the getContentToInsert method and ignore the others for now if I can add my own CodeTemplates after 1-3 above

Thanks for your help!

regards,

/Ole
eviware.com

P.S. If you would consider letting me be committer I could do this myself...
omatzura
 
Posts: 3
Joined: Mon Oct 06, 2008 7:39 pm

Re: CodeTemplate related request

Postby robert » Tue Dec 02, 2008 5:05 am

FYI - If you check out the latest from Subversion, there's the beginning of your request in there. Really more of the latter half of it, but it's a start.

CodeTemplate is now a public interface and you should be able to add your own implementations via RSyntaxTextArea#addCodeTemplate(). The previous CodeTemplate implementation is now the "StaticCodeTemplate" class, as you suggested. Templates are now loaded & saved via XMLEncoder/Decoder, so persistence should not be a problem as long as your CodeTemplates are JavaBeans.

Also note that I've changed the template insertion keystroke from just space to ctrl+space. I'm not sure if I like it better this way or not...
User avatar
robert
 
Posts: 805
Joined: Sat May 10, 2008 5:16 pm

Re: CodeTemplate related request

Postby robert » Thu Dec 11, 2008 1:04 pm

You can now remove templates at runtime. I think this fulfills all of your original request. Please check out the latest from Subversion. Now all access to CodeTemplates must be done through the CodeTemplateManager, not through RSyntaxTextArea. The getCodeTemplateManager() method is public.

Let me know how this works out for you!
User avatar
robert
 
Posts: 805
Joined: Sat May 10, 2008 5:16 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests