Hello,
I have an idea for a new feature, but I don't know where to start/what to modify, can you help me?
Here is the idea:
When I type a very long function definition/declaration/call, I hit enter to make the line shorter an more readable.
The current behavior on this action is to send the cursor at the beginning of the next line + 1 tab (I think).
I want to make it to go to the first opening bracket '(', so I can type:
void mylongfunc(int param1, 'hit enter here and directly go to the bracket and type the second param'
int param2, ' ... and so on so forth'
The MS VC has that feature for function definitions, I want to expand it to definitions and callings.
Where do I need to hack :lol: :P?
Best regards,
Teodor
open codeblocks.cbp
ctrl-shift-f, search the project for SMART INDENTING
I would think that you won't need to hand parse the text. You should be able to use the lexing info in scintilla to find the position of the opening brace.
You can look into this thread for a reference:
http://forums.next.codeblocks.org/index.php/topic,10361.0.html
Thank you,
I'll take a look at it, tonight.
Yesterday, I've done some experimenting and I have the basic feature working.
I need to polish it and add some improvements.
Then I'll show it, so more testing can be done.
Here is the patch,
It only one major problem:
a = 5 + my_func(long_arg1, long_arg2, --> hit enter it works
long_arg3, long_arg4); --> hit enter and the cursor goes to
| --> here :(
a = 5 + my_func(long_arg1, long_arg2); --> here it works
| --> cursor is here after enter is hit
Is there a way to get the indent level of the previous statement or something similar.
It can stay that way, it is not mega annoying, but I prefer to make it better?
Feedback is welcome :)
p.p. Patch is attached to the post
[attachment deleted by admin]
a = 5 + my_func(long_arg1, long_arg2, --> hit First enter it works
long_arg3, long_arg4); --> hit Second enter and the cursor goes to
| --> here :(
Great!
I'm not quite understand your idea.
Where should the cursor be after the second enter? :D
It should be like this below?:
a = 5 + my_func(long_arg1, long_arg2, --> hit First enter it works
long_arg3, long_arg4); --> hit Second enter and the cursor goes to
| --> here :(
Thanks.
Yes, it should go to the position of "a".
but won't your patch do this?
cout<<"(";<-- press enter
|<-- cursor position
also, why not indent for other types of braces
slightly off-topic, but one reason I despise this feature is that it encourages coders to do this:
void my_func(
int arg1, // random gibberish comment
char *arg2,
myclass arg3, // random gibberish comment
)
instead of
// comment
void my_func(int arg1, char *arg2, myclass arg3);
even worse when they then do similar crap with the call, reducing the number of effective loc that I can fit on screen without really enhancing readability of the code.
Quote from: dmoore on May 13, 2009, 05:42:15 PM
but won't your patch do this?
cout<<"(";<-- press enter
|<-- cursor position
no, but
cout << "(" <<
will break it :(
Any ideas what I can do to fix it?
Quote
also, why not indent for other types of braces
The '{' are handled by the indenter, '[' are not used on multiple lines (if there are no strange overloads :) ),
< require some more parsing (to distinguish if it is used in template or as operation).
Quote
slightly off-topic, but one reason I despise this feature is that it encourages coders to do this:
void my_func(
int arg1, // random gibberish comment
char *arg2,
myclass arg3, // random gibberish comment
)
instead of
// comment
void my_func(int arg1, char *arg2, myclass arg3);
Isn't that a problem of the coding standard/programmer? C::B is just a tool.
And if it is such a problem a config option could be added that is off by default.
Quote
even worse when they then do similar crap with the call, reducing the number of effective loc that I can fit on screen without really enhancing readability of the code.
Do you talk about this:
api_with_many_params(param1, // here we set something
param2, // here we set something else
param3, // here we set something else
param4, // here we set something else
);
Hello again,
Here is the latest version of the patch.
I've fixed lots of problems, while using it (the patch wasn't working in lots of cases)
I've fixed the cout/quotes problem (the braces inside strings are ignored).
I've also made the patch to work when "Use Tab character" option is used (I think, I do the best I can in this mode).
I hope that someone from the devs team will find some time to review it,
so I can further polish it (fix bugs, some commenting, configuration option ...).
After that I hope it will be applied to trunk.
Best regards,
Teodor Petrov
[attachment deleted by admin]
Quote from: oBFusCATed on May 21, 2009, 10:13:54 PM
I hope that someone from the devs team will find some time to review it,
I reviewed the past versions, too but in fact (sorry to say this) it was more annoying than helpful. Will try this one for sure. Looking forward to it! :-)
Don't be sorry, the patch version1 was totally broken.
Please report any problems you find.