Code::Blocks Forums

User forums => Help => Topic started by: vix on January 13, 2010, 08:18:09 am

Title: feature request: different colors for C-style and C++-style comments
Post by: vix on January 13, 2010, 08:18:09 am
Some years ago I've already posted a request for some modifications to syntax coloring for C/C++ code (see http://forums.codeblocks.org/index.php/topic,5357.0.html (http://forums.codeblocks.org/index.php/topic,5357.0.html)), but I know that request was really specific and not of general interest.
Recently I noticed that CodeLite has a nice feature that I think could be useful: in a C/C++ source file you can set two different colors
one for C++-style comments
Code
// This is a C++ style comment
and a different one C-style comments
Code
/*
This is a C-style comment
*/
In C::B these two comments are colored in the same way.
What do ypu think about this idea?

Thanks
vix
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: ollydbg on January 13, 2010, 09:12:17 am
This is done in the scintilla lexer.
For example, I'm using NotePad++, which use scintilla too, I can config the comment with different color.
See the screen shot below. Note: I'm opening a *.asy file. which has a custom lexer.
So, I suggest you need to search in Scintilla and SciTE (http://www.scintilla.org/)

[attachment deleted by admin]
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: vix on January 13, 2010, 01:13:53 pm
Quote
For example, I'm using NotePad++, which use scintilla too, I can config the comment with different color.
I understand that Scintilla lexer can be customized to get what I need.
The screenshot you posted shows two interesting parameters "Comment Open" and "Comment Close" that unfortunately C::B doesn't support.
I think that C::B is a really fantastic IDE (easy integration with compiler and debugger, for example), but as a pure editor is less powerful than other ones (Notepad++, for example)  :(

I tried to implement some modifications to the lexer_*.xml files into my Nightly Build installation, but nothing changes.
Should I recompile C::B from sources if I want to modify a lexer_*.xml file?
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: ollydbg on January 13, 2010, 01:19:31 pm
sorry, I know little about the Scintilla lexer, I think you can ask on the Scintilla forum. :D.
By the way, it seems C::B can change both "C" and "c++" comment to the same color.
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: oBFusCATed on January 13, 2010, 01:21:01 pm
vix: have you run the src/update.bat or src/update scripts?
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: vix on January 13, 2010, 01:28:23 pm
Quote
vix: have you run the src/update.bat or src/update scripts?
From this question I think the the answer to mine is "yes, I must recompile C::B from the sources

Quote
By the way, it seems C::B can change both "C" and "c++" comment to the same color.
Yes, but maybe a little modification to the lexer should be enough.
Now I'm going to check
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: dmoore on January 13, 2010, 04:47:58 pm
try attached lexer file (unzip to share/Codeblocks/lexers)

[attachment deleted by admin]
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: vix on January 13, 2010, 05:10:05 pm
dmoore: you modified the lexer exactly as I tried this morning, but unfortunately nothing changes if I overwrite the lexer of the Nightly Build. I think I have to recompile C::B after overwriting the lexer, but I found a lot of compilation errors...  :(
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: danselmi on January 13, 2010, 05:40:08 pm
dmoores lexer configuration worked for me (without recompiling cb).

you have to modify the lexer configuration in the output-dir (not in the source tree)
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: vix on January 14, 2010, 08:13:08 am
I have the last Nightly Build (svn 6080) installed on my Win XP SP2, so I overwrite the
C:\Programmi\CodeBlocks\share\CodeBlocks\lexers\lexer_cpp.xml with the one posted by dmoore.
I started C::B but inside Settings >> Editor >> Syntax Highlighting >> C/C++ I can't see the two new items Comment line and Comment line (documentation) that have been created into the lexer

I've been trying to recompile C::B from the sources (and in the past I was able to do that, because I tested the wxAUI branch before merged into trunk) but I find a lot of errors. This is the first time I try to recompile C::B since I replaced the standard MinGW with the TDM-MinGW.
I have to look deeper...
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: oBFusCATed on January 14, 2010, 08:27:18 am
You  (probably)  have to rebuild you wxwidgets with the new compiler, if you haven't done so.
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: vix on January 14, 2010, 01:56:09 pm
I was able to get the lexr working deleting the User "codeblocks" folder, launching C::B (so that the folder is re-created), changing the syntax highlighting from the default, then manually merging my old default.conf with the new one (to mantain all my other custom settings).
Now it works very well, and I think the modified lexer could be put into the C::B trunk.

Quote
You  (probably)  have to rebuild you wxwidgets with the new compiler, if you haven't done so.
I haven't done yet, but when I tried there are errors in wxwidgets compilation...
I've been thinking to go back to the default MinGW instead of TDM-MinGW
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: oBFusCATed on January 14, 2010, 08:09:32 pm
No need, TDM compiles wxWidgets... you need the uber bat file of Morten:)
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: ollydbg on January 15, 2010, 07:06:58 am
@vix tdm gcc works quite well. I used it for nearly one year.
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: MortenMacFly on January 15, 2010, 07:10:40 am
@vix tdm gcc works quite well. I used it for nearly one year.
For C/C++, yes. Not so for Fortran. But it's a known issue.
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: vix on January 15, 2010, 01:22:31 pm
I've been able to recompile wxWidgets without errors but I had to compile a debug build before being able to build a release one.
Then I've compiled C::B without problems
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: ollydbg on January 15, 2010, 01:25:31 pm
I've been able to recompile wxWidgets without errors but I had to compile a debug build before being able to build a release one.
Strange. You can just build a release version of wxWidgets library. using these command:
Code
mingw32-make -f makefile.gcc  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: vix on January 15, 2010, 01:41:32 pm
Quote
Strange. You can just build a release version of wxWidgets library. using these command:
Code
mingw32-make -f makefile.gcc  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release
Yes, with MinGW this worked, but with TDM-GCC I have some strange "syntax errors" while creating libwxmsw28ud.a library in release build...
Title: Re: feature request: different colors for C-style and C++-style comments
Post by: ollydbg on January 15, 2010, 01:52:01 pm
Yes, with MinGW this worked, but with TDM-GCC I have some strange "syntax errors" while creating libwxmsw28ud.a library in release build...
TDM GCC 4.4.1-2 works here. :D