Page 1 of 2
[PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Tue Nov 25, 2008 3:10 am
by evilissimo
Hi,
I am new to CodeLite but I really like it. I've been missing an editor feature which I promptly reported and implemented (because I really love this feature in Visual Studio's Visual Assist X Plugin)
The feature is for auto closing brackets if you type any of (, [, or { it will add the corresponding counter part on the same line and keeps the caret infront of it. So you edit in-between
Is the corresponding feature request:
https://sourceforge.net/tracker/index.p ... tid=979963
The patch I have attached is also adding an option to the editor menu in the misc tab which is by default disabled. So it's possible to turn it on and off (if it sucks for example
)
Regards,
Vinzenz
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Tue Nov 25, 2008 10:10 am
by eranif
evilissimo wrote:Hi,
I am new to CodeLite but I really like it. I've been missing an editor feature which I promptly reported and implemented (because I really love this feature in Visual Studio's Visual Assist X Plugin)
The feature is for auto closing brackets if you type any of (, [, or { it will add the corresponding counter part on the same line and keeps the caret infront of it. So you edit in-between
Is the corresponding feature request:
https://sourceforge.net/tracker/index.p ... tid=979963
The patch I have attached is also adding an option to the editor menu in the misc tab which is by default disabled. So it's possible to turn it on and off (if it sucks for example
)
Regards,
Vinzenz
Thanks for the patch, however I did not accept it for the below reasons, (but I did use your idea):
1) Since this is more of an editor feature and not something which is only relevant to C++ (for example it is useful for XML editing as well), I added the implementation at the editor level and not the context level (i.e. instead of context_cpp.cpp I added the insertion code at cl_editor.cpp)
2) The settings -> editor -> misc is not the correct place for it, so I moved it to settings -> editor -> general under Guides section
3) using EditorConfigST::Get()->GetLongValue() is an expensive operation which I prefer not to call it every time user types ([{ (since it involves querying the XML which is quite large), so:
- I moved the settings to OptionsConfig (since this is the correct place for options of type settings -> editor -> general
- It is being kept as member of LEditor class, and been initialized at SetProperties() which is called whenever the 'Settings' dialog is dismissed
4) I made the code a bit more smart: If the counter part already exist, dont add another one
But as you can guess, I liked the idea so I took the liberty of implementing it myself (hope you don't mind
)
Committed in SVN trunk.
Eran
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Tue Nov 25, 2008 1:50 pm
by evilissimo
Hi,
no I don't mind of course
I just did a quick implementation for it without really knowing the code, design or any idea behind it. I just missed this feature so I modified my version
And a good move to optimize it right away
Also I like that you added the check for the counter part
I just started using this editor on Saturday and did not really spend much time with the code I just wanted to have this done for me
Thanks for your quick response
Regards,
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Tue Nov 25, 2008 1:55 pm
by eranif
Another thing that we both missed:
- CodeLite will now ignore this feature while in comment or string
in SVN trunk
Eran
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Tue Nov 25, 2008 8:29 pm
by evilissimo
Hi,
I've improved the whole thing a bit to the behavior I'd expect/like to see. Have a try if you like it
I removed the check for the counter part because you cannot do them nested with the same behaviour however have a try
Regards,
Vinzenz 'evilissimo' Feenstra
2340288_improvement.diff.tar.bz2
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Wed Nov 26, 2008 4:33 am
by eranif
Applied in SVN trunk
Eran
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Wed Nov 26, 2008 1:11 pm
by denk_mal
Hi Eran,
I believe the general tab needs a scrollbar
I found some (very usefull) options that where new for me when I made the settings window greater.
should I post a feature request?
denk_mal
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Wed Nov 26, 2008 5:11 pm
by eranif
denk_mal wrote:should I post a feature request?
No... since resizing the dialog will solve this (when installing clean codelite, the dialog will show all items, you can remove the file C:\Program Files\CodeLite\config\codelite.xml to get "clean" state")
@evilissimo
You might want to update SVN and give your feature a try: Scott (sdolim) improved it significantly!
Eran
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Wed Nov 26, 2008 7:45 pm
by evilissimo
Now this is awesome
It's even better than with Visual Assist X
Thanks a lot
Re: [PATCH] Auto Closing Brackets (Opt-in feature) [2340288]
Posted: Wed Nov 26, 2008 11:04 pm
by sdolim
I have a problem with the size of the settings dialog. My Windows box is a Fujitsu Lifebook P1610, with a screen resolution of 1280x768.
The dialog has grown so big now that it goes off the bottom of the screen. I can't reach the bottom few settings on the General tab, nor can I get to the OK/Cancel buttons -- I use Tab/Enter/ESC (blindly) to close the dialog.
I think that with some rearrangement of the options the dialog could be made smaller. Or, there's that scrollbar idea.
What do you think Eran? I'm willing to work on it if you approve the idea.
Scott