Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
[ Patch #3180 ] Single quote, double quote and curly brace completion patch
dpurgin:
Hi everyone,
CB is a masterpiece, but I've found a few things, that were very annoying for me after using Carbide.c++ IDE based on Eclipse. I've submitted a little patch for 10.05-release, and here what it does:
Single and double quote completion revised (C/C++ style quotes)
When opening a string or character, CB automatically appends closing quote for the entered one. This is awesome, but when you have to re-factor such a code, CB adds closing quotes no matter if it is needed or not. For example, we have code:
--- Code: --- std::cout << '\n;
std::cout << \n';
std::cout << "Hello, world!\n;
std::cout << Hello, world!\n";
std::cout << "Hello, \
world;
// etc, could be anything
--- End code ---
You put closing or opening quote respectively, but CB automatically adds another one. This patch checks whether we're currently starting a string, ended by closing quote, or closing a string, started with quote (with respect of carry in multi-character strings). If so, no additional quote is added. If we're inside the string, then additional quote is added to divide the current string. Checking is performed based on line content, because I found lexer (namely, GetStyleAtPos() call) not precise enough.
Curly braces completion revised
This patch makes curly brace auto-completion a little bit more context-sensitive. Whenever you put an opening curly brace, the code checks whether the next line is not empty. If it is empty, then behavior is not altered - we put a new line and a closing brace after it. But when the next line is not empty and contains some code, then behavior depends on the next line's indentation. If the next line is indented more, than the current one, then we find the end of indented block (until line indentation is less or equal to current line indentation) and put closing curly brace right after the indented block (if there is one, do nothing). If next line indentation is less, that the current one, then behavior is the same as putting opening curly brace before an empty line. If next line is indented just as the current line, than we do not add a closing curly brace, as it is not clear, where the coder wants to put the closing brace.
Whitespace stripping when saving: turned off
This is the most annoying thing for me. I save my code often and quite often put a carret on an indented new line. When I save my code, I don't really want to lose the indentation.
I hope, this would be useful for somebody.
Cheers,
Dmitriy
ollydbg:
Very interesting patch, but it would be better that the patch is against the trunk (not 10.05)
dpurgin:
Thanks for reply and interest!
The reason I've made this patch for 10.05 is very simple: I have an RPM Linux distribution and it is more convenient to patch codeblocks from source-rpm and then rebuild binary rpms. Thus I get a "native" distro's codeblocks with my patch.
I've checked trunk out and, as far as I can see, the quote refinement is already partly implemented. I'll merge rest of my code a bit later.
ollydbg:
Ok, I will test it when you update the patch. :D
oBFusCATed:
dpurgin: thanks for the contribution, I don't use the quote/brace completion, but will test the white space patch.
I have two questions:
1. Can you extract the white-spaces changes, so they can be tested separately?
2. Can you describe the steps you use to build your patched binary packages. I'm on centos at work and need to build debugger branch rpm-s, but last time I've failed to do so :(
Navigation
[0] Message Index
[#] Next page
Go to full version