Author Topic: No Syntax Highlighting for C++ Code  (Read 9506 times)

Offline lordnoxx

  • Single posting newcomer
  • *
  • Posts: 5
No Syntax Highlighting for C++ Code
« on: January 19, 2011, 03:11:28 pm »
Hi everybody.
I just turned to code::blocks runnning it on Windows XP. But now i have a problem regarding syntax highlighting and code completion for C++ code. Please have a look on the attached image. There you can see that "ofstream" and "cout" e.g. are not highlighted.
When i type "dataus." there is no popup of the completion list. What is going wrong here?
Btw: I don't have any similar problems with pure C code.


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13003
    • Travis build status
Re: No Syntax Highlighting for C++ Code
« Reply #1 on: January 19, 2011, 03:38:28 pm »
c::b version? 10.05?
if so, and you want better CC use some of the latest nightlies...

btw the syntax highlight looks ok, c::b doesn't support context/semantic highlight...
(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 lordnoxx

  • Single posting newcomer
  • *
  • Posts: 5
Re: No Syntax Highlighting for C++ Code
« Reply #2 on: January 19, 2011, 04:00:57 pm »
Yes it is 10.05. After reopening the project the completion list appears when typing "dataus.". Then i get the whole bunch of what is in the ofstream class. Hmm ok...i also figured out, that there ist also no highlighting when using structs.

I just thougt it should always look like as if you declare "int i;" e.g with the "int" getting blue. Wouldn't it be nice if also class-names and struct-names are highlighted when declaring an instance of them? Just like with the basic data types (int, char, float....).

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13003
    • Travis build status
Re: No Syntax Highlighting for C++ Code
« Reply #3 on: January 19, 2011, 04:38:03 pm »
int is a keyword, so it is highlighted as such.
For the others you're talking about semantic highlight which is hard.
(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: 5295
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: No Syntax Highlighting for C++ Code
« Reply #4 on: January 19, 2011, 04:55:46 pm »
int is a keyword, so it is highlighted as such.
For the others you're talking about semantic highlight which is hard.
hopefully libclang can help us to do this :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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13003
    • Travis build status
Re: No Syntax Highlighting for C++ Code
« Reply #5 on: January 19, 2011, 05:34:40 pm »
ollydbg: The question is: does scintilla support such thing...
(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: 5295
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: No Syntax Highlighting for C++ Code
« Reply #6 on: January 20, 2011, 02:22:27 am »
ollydbg: The question is: does scintilla support such thing...

to highlight some text in scintilla,

1, scintilla has some(many) keyword groups, each groups can have different text styles(color, bold, italic....)

2, We just  add/remove these groups dynamically when we switch translation unit. the clang can supply a full AST, and also we can create a AST interator, and walk through the AST, and build these groups.

3, once the groups are built, it's the scintilla's duty to high light the text.

BTW:
Codelite IDE has this kind of feature, and I have even post some code snippet of Codelite to show how it correct/build the groups in C::B's forum several days ago.


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 lordnoxx

  • Single posting newcomer
  • *
  • Posts: 5
Re: No Syntax Highlighting for C++ Code
« Reply #7 on: January 20, 2011, 06:19:47 pm »
Hey guys. I am back. I think i found a bug in c::b 10.05. I am not sure this still exists in the latest nightly build but i post it anyway.
OK...i have the following code:

Code: [Select]
#include <iostream>
#include <fstream>

using namespace std;

int main()
{

    fstream hhh;

    hhh.
   
    return 0;
}


When typing "hhh." there should appear the code completion list. But it does not...until i close the project and reopen it. Then it works.
Can you guys confirm this?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9607
Re: No Syntax Highlighting for C++ Code
« Reply #8 on: January 20, 2011, 06:35:04 pm »
Can you guys confirm this?
What happens if you save after you declared the type (fstream hhh;) and then CC the next line "hhh."?
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 lordnoxx

  • Single posting newcomer
  • *
  • Posts: 5
Re: No Syntax Highlighting for C++ Code
« Reply #9 on: January 20, 2011, 07:10:19 pm »
Saving the file after declaring the type changes nothing. What does "CC the next line" mean?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9607
Re: No Syntax Highlighting for C++ Code
« Reply #10 on: January 20, 2011, 08:38:27 pm »
Saving the file after declaring the type changes nothing. What does "CC the next line" mean?
Do the code complete operation (STRG+SPACE).
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 lordnoxx

  • Single posting newcomer
  • *
  • Posts: 5
Re: No Syntax Highlighting for C++ Code
« Reply #11 on: January 20, 2011, 09:05:39 pm »
(STRG+SPACE). also only works after reopening the project.