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 (http://developer.berlios.de/patch/?func=detailpatch&patch_id=3180&group_id=5358) 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:
std::cout << '\n;
std::cout << \n';
std::cout << "Hello, world!\n;
std::cout << Hello, world!\n";
std::cout << "Hello, \
world;
// etc, could be anything
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
Hi oBFusCATed,
1. Yep, sure. The whitespace patch is:
diff -uNrp codeblocks-10.05-release/src/sdk/cbeditor.cpp codeblocks-10.05-release.new/src/sdk/cbeditor.cpp
--- codeblocks-10.05-release/src/sdk/cbeditor.cpp 2010-05-22 16:10:05.000000000 +0600
+++ codeblocks-10.05-release.new/src/sdk/cbeditor.cpp 2011-06-30 15:48:42.496262953 +0600
@@ -1678,7 +1678,8 @@ bool cbEditor::Save()
{
if(m_pData->m_strip_trailing_spaces)
{
- m_pData->StripTrailingSpaces();
+ // very annoying call
+ //m_pData->StripTrailingSpaces();
}
if(m_pData->m_ensure_consistent_line_ends)
{
2. I've learned these steps from Fedora's custom kernel tutorial (http://fedoraproject.org/wiki/Docs/CustomKernel).
At first, you should have some rpm and yum utils:
$ su -c 'yum install rpmdevtools yum-utils'
Then you set up rpm development tree. After that you'll see ~/rpmbuild/SPECS, ~/rpmbuild/RPMS, ~/rpmbuild/BUILD and so on. I have done this in my home directory:
Then you have to download the source package (say, for codeblocks the source RPM would be codeblocks-10.05-4.fc14.src.rpm), install its dependencies and the package itself:
$ yumdownloader --source codeblocks
$ su -c 'yum-builddep codeblocks-10.05-4.fc14.src.rpm'
$ rpm -ihv codeblocks-10.05-4.fc14.src.rpm
Note, that the last rpm command should be executed under regular user (non-root). The original source archive and all the patches of your distribution will be installed to ~/rpmbuild/SOURCES without any hierarchy (which is not really convenient, when developing several rpms).
Next step is to prepare the source tree, using the .spec file for your package:
$ cd ~/rpmbuild/SPECS
$ rpmbuild -bb --target=$(uname -m) codeblocks.spec
After that you will have the sources deployed to ~/rpmbuild/BUILD/codeblocks-10.05-release
Then you should copy the original source tree:
$ cd ~/rpmbuild/BUILD
$ cp -r codeblocks-10.05-release codeblocks-10.05-release.new
Then you modify the sources in codeblocks-10.05-release.new as you wish.
After you're done with editing, you make a patch using diff and put it to the ~/rpmbuild/SOURCES directory:
$ cd ~/rpmbuild/BUILD
$ diff -uNrp codeblocks-10.05-release codeblocks-10.05-release.new > ../SOURCES/codeblocks-my.patch
Then you should edit .spec-file in order to include your patch to RPM build. Spec-files have similar structure, but its content differs, so you should check your package's spec. What you have to do is: find list of patches, add your own patch to the list, find the patch commands and add your patching command there. You should also change release number, so that your newly build packages are not messed with the original. For ~/rpmbuild/SPECS/codeblocks.spec:
Name: codeblocks
Version: 10.05
Release: 4%{?dist} # here you put your release. For example, 4a%{?dist}, then packages will have version 10.05-4a.fc14
Summary: An open source, cross platform, free C++ IDE
Group: Development/Tools
here go distribution patches:
Patch2: %{name}-dso.patch
# update for tinyxml 2.6
Patch3: %{name}-tinyxml-26.patch
# D support - svn revisions 6553-6556
Patch4: %{name}-10.05-D.patch
# we add our own patch to the list:
Patch5: %{name}-my.patch # %{name} will be substituted with "codeblocks"
here goes patch application:
%prep
%setup -q -n %{name}-%{version}-release
%patch1 -p1 -b .tinyxml
%patch2 -p1 -b .dso
%patch3 -p1 -b .tinyxml-26
%patch4 -p1 -b .D
# we add our own patch
%patch5 -p1 -b .my
After these steps all you have to do is to build the rpms using the modified .spec:
$ rpmbuild -bb --target=$(uname -m) codeblocks.spec
You will have your RPMs under ~/rpmbuild/RPMS/<architecture>/
I also add these packages to exclude statement in /etc/yum.conf, so that they are not crashed by update.
Hope this helps.
Cheers!