News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

No Syntax Highlighting for C++ Code

Started by lordnoxx, January 19, 2011, 03:11:28 PM

Previous topic - Next topic

lordnoxx

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.


oBFusCATed

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

lordnoxx

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

oBFusCATed

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

ollydbg

Quote from: 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.
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.

oBFusCATed

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

ollydbg

Quote from: oBFusCATed on January 19, 2011, 05:34:40 PM
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.

lordnoxx

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:


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

MortenMacFly

Quote from: lordnoxx on January 20, 2011, 06:19:47 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: [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]

lordnoxx

Saving the file after declaring the type changes nothing. What does "CC the next line" mean?

MortenMacFly

Quote from: 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?
Do the code complete operation (STRG+SPACE).
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]

lordnoxx

(STRG+SPACE). also only works after reopening the project.