News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Comment the word first(Stream-comment)

Started by Loaden, April 23, 2010, 01:43:20 AM

Previous topic - Next topic

Loaden

If we have not selected, in SVN6204 version, CB will comment current line.
But we can do it use Box-comment too.

In many cases, we only need one word comment.
Example:
void OnKeyUp(wxKeyEvent& /*evt*/)
{
}

Index: src/src/main.cpp

===================================================================

--- src/src/main.cpp (revision 6204)

+++ src/src/main.cpp (working copy)

@@ -3287,9 +3287,13 @@

        {
            int startPos = stc->GetSelectionStart();
            int endPos   = stc->GetSelectionEnd();
-            if ( startPos == endPos ) { // if nothing selected stream comment current line
-                startPos = stc->PositionFromLine  (stc->LineFromPosition(startPos));
-                endPos   = stc->GetLineEndPosition(stc->LineFromPosition(startPos));
+            if ( startPos == endPos ) { // if nothing selected stream comment current *word* first
+                startPos = stc->WordStartPosition(stc->GetCurrentPos(), true);
+                endPos   = stc->WordEndPosition  (stc->GetCurrentPos(), true);
+                if ( startPos == endPos ) { // if nothing selected stream comment current line
+                    startPos = stc->PositionFromLine  (stc->LineFromPosition(startPos));
+                    endPos   = stc->GetLineEndPosition(stc->LineFromPosition(startPos));
+                }
            }
            else {
                /**



[attachment deleted by admin]

oBFusCATed

I've tested it and there are 3 problems:

1. "TestClass *|test", stream commenting here will do "TestClass */*test*/" and this is a warning in VC8+.
    I think it is better to do "TestClass * /*test*/
2. The selection after the commenting is broken. "TestClass *>/*test<*/ .
    '>' is placed where the selection starts, '<' is placed where the selection ends.
   The expected result is "TestClass *>/*test*/<"
3. "TestClass*|   test", in this case the white spaces have not been ignored and the word 'test' is not found.
    The result of stream commenting is that the whole line is commented.

This feature is great, I'll keep using it if I don't forget about it:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Loaden

Quote from: oBFusCATed on April 23, 2010, 09:52:58 AM
I've tested it and there are 3 problems:

1. "TestClass *|test", stream commenting here will do "TestClass */*test*/" and this is a warning in VC8+.
   I think it is better to do "TestClass * /*test*/
2. The selection after the commenting is broken. "TestClass *>/*test<*/ .
   '>' is placed where the selection starts, '<' is placed where the selection ends.
  The expected result is "TestClass *>/*test*/<"
3. "TestClass*|   test", in this case the white spaces have not been ignored and the word 'test' is not found.
   The result of stream commenting is that the whole line is commented.

This feature is great, I'll keep using it if I don't forget about it:)

1. TestClass * /*test*/; can not build use MinGW 4.4.3, here is the error log:
Quoteerror: expected unqualified-id before ';' token|
2. Yes, in current patch, it's not handle this case.
3. Because in current position, the current word is a blank space, but not be "test".

oBFusCATed

Quote from: Loaden on April 23, 2010, 05:35:58 PM
1. TestClass * /*test*/; can not build use MinGW 4.4.3, here is the error log:
Quoteerror: expected unqualified-id before ';' token|
2. Yes, in current patch, it's not handle this case.
3. Because in current position, the current word is a blank space, but not be "test".
1. The code I've shown is not full, so the build error is expected.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]