Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: lordnoxx on January 19, 2011, 03:11:28 pm

Title: No Syntax Highlighting for C++ Code
Post by: lordnoxx 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.

Title: Re: No Syntax Highlighting for C++ Code
Post by: oBFusCATed 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...
Title: Re: No Syntax Highlighting for C++ Code
Post by: lordnoxx 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....).
Title: Re: No Syntax Highlighting for C++ Code
Post by: oBFusCATed 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.
Title: Re: No Syntax Highlighting for C++ Code
Post by: ollydbg 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
Title: Re: No Syntax Highlighting for C++ Code
Post by: oBFusCATed on January 19, 2011, 05:34:40 pm
ollydbg: The question is: does scintilla support such thing...
Title: Re: No Syntax Highlighting for C++ Code
Post by: ollydbg 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.


Title: Re: No Syntax Highlighting for C++ Code
Post by: lordnoxx 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
#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?
Title: Re: No Syntax Highlighting for C++ Code
Post by: MortenMacFly 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."?
Title: Re: No Syntax Highlighting for C++ Code
Post by: lordnoxx on January 20, 2011, 07:10:19 pm
Saving the file after declaring the type changes nothing. What does "CC the next line" mean?
Title: Re: No Syntax Highlighting for C++ Code
Post by: MortenMacFly 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).
Title: Re: No Syntax Highlighting for C++ Code
Post by: lordnoxx on January 20, 2011, 09:05:39 pm
(STRG+SPACE). also only works after reopening the project.