Author Topic: feature request: different colors for C-style and C++-style comments  (Read 8474 times)

Offline vix

  • Multiple posting newcomer
  • *
  • Posts: 60
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), 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: [Select]
// This is a C++ style commentand a different one C-style comments
Code: [Select]
/*
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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5242
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: feature request: different colors for C-style and C++-style comments
« Reply #1 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

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

Offline vix

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: feature request: different colors for C-style and C++-style comments
« Reply #2 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?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5242
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: feature request: different colors for C-style and C++-style comments
« Reply #3 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.
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12821
    • Travis build status
Re: feature request: different colors for C-style and C++-style comments
« Reply #4 on: January 13, 2010, 01:21:01 pm »
vix: have you run the src/update.bat or src/update scripts?
(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!]

Offline vix

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: feature request: different colors for C-style and C++-style comments
« Reply #5 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

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: feature request: different colors for C-style and C++-style comments
« Reply #6 on: January 13, 2010, 04:47:58 pm »
try attached lexer file (unzip to share/Codeblocks/lexers)

[attachment deleted by admin]

Offline vix

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: feature request: different colors for C-style and C++-style comments
« Reply #7 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...  :(

Offline danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 202
Re: feature request: different colors for C-style and C++-style comments
« Reply #8 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)

Offline vix

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: feature request: different colors for C-style and C++-style comments
« Reply #9 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...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12821
    • Travis build status
Re: feature request: different colors for C-style and C++-style comments
« Reply #10 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.
(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!]

Offline vix

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: feature request: different colors for C-style and C++-style comments
« Reply #11 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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12821
    • Travis build status
Re: feature request: different colors for C-style and C++-style comments
« Reply #12 on: January 14, 2010, 08:09:32 pm »
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!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5242
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: feature request: different colors for C-style and C++-style comments
« Reply #13 on: January 15, 2010, 07:06:58 am »
@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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9603
Re: feature request: different colors for C-style and C++-style comments
« Reply #14 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline vix

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: feature request: different colors for C-style and C++-style comments
« Reply #15 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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5242
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: feature request: different colors for C-style and C++-style comments
« Reply #16 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: [Select]
mingw32-make -f makefile.gcc  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release
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.

Offline vix

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: feature request: different colors for C-style and C++-style comments
« Reply #17 on: January 15, 2010, 01:41:32 pm »
Quote
Strange. You can just build a release version of wxWidgets library. using these command:
Code: [Select]
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...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5242
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: feature request: different colors for C-style and C++-style comments
« Reply #18 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
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.