oscargus / jsyntaxpane

Automatically exported from code.google.com/p/jsyntaxpane
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 martin.z...@consol.de on 8 Jul 2010 at 10:03

Attachments:

GoogleCodeExporter commented 9 years ago
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 ayman.al...@gmail.com on 9 Jul 2010 at 2:38

GoogleCodeExporter commented 9 years ago
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 martin.z...@consol.de on 14 Jul 2010 at 11:50