Hey guys,
sorry for the bad rep.
But, recently i've obtained a code in c++ which highlights c# syntax in a Richtextbox.
LINK
I think the basic idea behind it is to specify an array of strings, and now the program should search and highlight the defined strings in a file.

Any help.

Anurag

Recommended Answers

All 11 Replies

Member Avatar for iamthwee

I'd just use an engine already out there ... Much like Daniweb does.

I didn't understand.
Please can you explain what is an engine?

Member Avatar for iamthwee

What I mean is . . . You download a program which already does all the hard work (parsing etc)

http://qbnz.com/highlighter/

Then you can use that to colour your code however you wish! I'm not sure if the source code is released or how much effort is required to port that to c++. It seems like it's only available for use with php and html.

I reckon if you want to this this yourself, and build an accurate syntax highlighter, you'll have to use regular expressions, especially for multiple nesting within comments and quotes.

I think we have Colorer Take 5 To port it to c++
I don't know how to port it..

Member Avatar for iamthwee

I think we have Colorer Take 5 To port it to c++
I don't know how to port it..

Looks like that only interfaces with certain IDEs. I don't think that will help.

How does daniweb do it?
I don't think we have "<code></code>" in C++
:P

Member Avatar for iamthwee

How does daniweb do it?

It uses geSHi, but that uses php with regular expressions and formats the output in HTML.

To stand any hope of doing this properly you will need to use regular expressions.

for eg:
if i define a n array of strings as equal to include,void,int,float etc.
and then ask the program to search for the strings and then highlight them...
Then i think it will be fine.

But my main problem is finding a specific string in a paragraph of code.

Anurag

Member Avatar for iamthwee

for eg:
if i define a n array of strings as equal to include,void,int,float etc.
and then ask the program to search for the strings and then highlight them...
Then i think it will be fine.

Not if you want it to be accurate.

But my main problem is finding a specific string in a paragraph of code.

If you can't to this then this is a bit beyond your capabilities.

Allright, thanks....
I'll try somethin' "in my capability"

Member Avatar for iamthwee

I'm not saying you can't try doing a simple one . . . for learning purposes it might be a good idea.

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.