Can anyone of you suggest, how to create syntax highlighting functionality
I would like a code snippet.

Please,
Anurag

Recommended Answers

All 4 Replies

Please be much more specific. You want to color words in a terminal? Or are you using a GUI?

Hey Dave,

I want the words in the terminal/CMD to be colored.
I'm on Win Xp and use Dev C++ 4.9.9.2

Anurag

As in normal colored text? No code-detecting or whatever?

#include <iostream>
#include <windows.h>

int main()
{
    HANDLE hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute (hConsole, FOREGROUND_BLUE);
    std::cout << "Something like this perhaps?\n";
}

(only for windows of-course)

Yeah, exactly
Buy only the syntax to be highlighted.
For Eg.
I open something.cpp
Then The Cpp syntax such as include,int,void,typedef..should be highlighted.
I know its a complex task, but any help will be appreciated.
Anurag

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.