News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

feature request: different colors for C-style and C++-style comments

Started by vix, January 13, 2010, 08:18:09 AM

Previous topic - Next topic

vix

Some years ago I've already posted a request for some modifications to syntax coloring for C/C++ code (see http://forums.next.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
// This is a C++ style comment
and a different one C-style comments
/*
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

ollydbg

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

[attachment deleted by admin]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

vix

QuoteFor 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?

ollydbg

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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

(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!]

vix

Quotevix: 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

QuoteBy 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

dmoore

try attached lexer file (unzip to share/Codeblocks/lexers)

[attachment deleted by admin]
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

vix

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...  :(

danselmi

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)
spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]

vix

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...

oBFusCATed

You  (probably)  have to rebuild you wxwidgets with the new compiler, if you haven't done so.
(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!]

vix

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.

QuoteYou  (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

oBFusCATed

No need, TDM compiles wxWidgets... you need the uber bat file of Morten:)
(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!]

ollydbg

@vix tdm gcc works quite well. I used it for nearly one year.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

MortenMacFly

Quote from: ollydbg on January 15, 2010, 07:06:58 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]