jsyntaxpane icon indicating copy to clipboard operation
jsyntaxpane copied to clipboard

New action for handling closing character of a pair (of brackets, quotes, parentheses)

Open GoogleCodeExporter opened this issue 9 years ago • 2 comments

Here's the code for an action which makes handling of parentheses, quotes etc. 
more comfortable:

Right now, if you type some code in JSyntaxPane, PairAction will neatly add the 
closing character of a pair when you type the opening character.
However, there's no special handling yet for typing the closing character - 
e.g. when you're typing code it often happens to me that I enter the closing 
parenthesis because I forgot that it had been added automatically, so I end up 
with two closing parentheses...

The new action takes care of that: when the action determines that the 
character you typed is the closing character of such a pair, and the character 
at the caret position is that same character, it simply skip over that 
character. 

I attached the code for the new action and a patch for the 
(JavaSyntaxKit-)config.properties I used to test it.

Cheers,
  Martin

Original issue reported on code.google.com by [email protected] on 8 Jul 2010 at 10:03

Attachments:

GoogleCodeExporter avatar May 01 '15 11:05 GoogleCodeExporter

This sounds good.  I do that insert of double quotes myself.
However, I think a bit more than this needed.  Like for example if you open a 
pair, and then press backspace, you would probably want to delete both pair 
items.
This backspace could be yet another PairBackSpaceAction kind of thing.
But then what about having some "smart" completion that will insert the pair's 
close item only if it is needed.  Similar to what NetBeans and possibly other 
IDE's would do.  It might not be that hard since the pair match tokens are 
parsed and a find Pair method is already defined in the SyntaxDocument.
What do you think?

Original comment by [email protected] on 9 Jul 2010 at 2:38

  • Added labels: Component-UI, OpSys-All, Priority-Low, Type-Enhancement

GoogleCodeExporter avatar May 01 '15 11:05 GoogleCodeExporter

You're right, this is not really enough, this needs a bit more work.

I will try and 
a) check how NetBeans and/or Eclipse behave
b) try to get jsyntaxpane to behave in a similar way

Whenever I'll find the time to do this ;-)

Original comment by [email protected] on 14 Jul 2010 at 11:50

GoogleCodeExporter avatar May 01 '15 11:05 GoogleCodeExporter