Code::Blocks Forums

User forums => Help => Topic started by: killerbot on February 12, 2006, 11:18:08 pm

Title: Explanation on an extension of TO DO list
Post by: killerbot on February 12, 2006, 11:18:08 pm
Things apply on svn versions after revision 1991 !!

When you add a TO DO item in your project (by right clicking : add to-do item), you can have the 'comment' code being inserted in 3 places :
  - on the line above the current line (current line, is the line on which you right clicked)
  - on the line below the current line
  - on the current line (exactly where the caret is now)

I'dd like to elaborate on the last option.
The caret is positioned on the spot where you right clicked, so it might be possible that you right clicked somewhere in the middle of a line of code.

An example :
Code
int x = 25 + 78;

Suppose we right clicked just before the 7 of 78.
Say we added a to-do item of cpp style with text "test" on the "exactly where the caret is now", then we would insert on the position just before the 7 the following piece of code :
Code
// TODO (ldc##): test
It is obvious that this would break the correct syntax of the code, since we would get :
Code
int x = 25 + // TODO (ldc##): test78;

Now there are some solutions, either we can do as in the past, don't allow cpp style (//...) in the "exact" caret option, and make c-style comments out of them (/*...*/). This was the old behaviour.

Today, we provide some more choices to the user, but to accomplish that we ask the user explicitly. We allow 3 possibilities :
 1) keep C++ style and move it to the end of the line
Code
int x = 25 + 78;// TODO (ldc##): test
2) switch it to c style
Code
int x = 25 + /* TODO (ldc##): test*/78;
3) keep it as C++ style and don't change the insertion position (probably the most dangerous choice, but if you want, well it's available, and if you break things, don't complain ... ;-))

So if you don't like the c-style comments, you can do it the c++ style now.
Title: Re: Explanation on an extension of TO DO list
Post by: Game_Ender on February 13, 2006, 03:13:20 am
Thanks for the addition.

I don't think "/* */" are "c-style" comments.  C has both "//" and "/* */" comments.  The difference is between block comments "/* */" and line comments "//".  Not "c-style" and "cpp-style". 
Title: Re: Explanation on an extension of TO DO list
Post by: Ceniza on February 13, 2006, 05:29:09 am
Comments in the // form were supposedly added in C++, so they received the name "C++-style comments" and the ones inherited from C (/* */) "C-style comments". C then borrowed the C++ ones too.

Anyway, enough of compilers' history.

I think it's more important to read well than making the TODO plugin smarter :P

EDIT: bleh, I just saw that has been committed already.
Title: Re: Explanation on an extension of TO DO list
Post by: thomas on February 13, 2006, 09:00:40 am
Quote
EDIT: bleh, I just saw that has been committed already.
"bleh" is how I feel :lol:

The one annoyance with that plugin was not that it misplaced the comments, but that it did not remember the settings of the comboboxes.
Right now, it is so extra-smart that I am forced to edit every item by hand after inserting it...