Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Contributions to C::B => Topic started by: Flippeh on October 01, 2007, 08:58:29 pm

Title: SmartHighlight
Post by: Flippeh on October 01, 2007, 08:58:29 pm
First on, sorry if this is the wrong section - i couldn't find any better. Feel free to move if its wrong  :)

So on to my suggestion.

Imagine the following...
Code
class MyClass
{
   // ...
}

int main()
{
   MyClass something;
   // ...
}

Wouldn't it be great, if the "MyClass" in front of the "something" gets highlighted like "int", "char" or "double" or any other default data type would? Its really 'boring', to see it in the default black color..

IDEs like Visual Studio do this already.

Would it be possible to add this any time?
Title: Re: SmartHighlight
Post by: XayC on October 01, 2007, 09:12:41 pm
While, of course, possible, I don't think you can expect it being implemented soon. First because Code Completion still has more important things to fix/implement (including a complete redesign), and second because, from what I know, color highlights are done by the text editor (Scintilla) automatically on a predefined set of language keywords, so it would require changes both in the editor code and in the code completion.

Regards, XayC
Title: Re: SmartHighlight
Post by: orel on November 02, 2007, 10:51:13 am
IDEs like Visual Studio do this already.

I develop every day at work with VS 2005, and haven't seen such feature (maybe are you speaking about 2008 ?), the only way to have some new keywords highlighted in the editor is to define them 'by hand'.

And i find the way to define new keywords much user-friendly in CB than VS. In CB you just have to go to Settings/Editor/Syntax Highlighting/.
I VS you have to create a file named 'UserType.dat', populate it with your keywords set and place this file in one of VS installation dirs.
Title: Re: SmartHighlight
Post by: AngleWyrm on December 18, 2007, 08:57:01 am
You can get this effect by defining "user keywords".

Settings->Editor->Syntax Hilighting.
Click the "Keywords..." button, and then scroll the "set" to #2.

Here, there will be a blank area in which to define any user keywords. If these words are then encountered in the code (not in comments), then they will be highlighted using whatever color choices were made for "user keywords".
Title: Re: SmartHighlight
Post by: fchen on March 18, 2008, 08:31:16 am
IDEs like Visual Studio do this already.

I think he mean a plug-in for Visual Studio called "Visual Assistant". It has many cool features. I think Code::Blocks should learn from it.
Title: Re: SmartHighlight
Post by: eranif on April 13, 2008, 02:04:11 pm
Quote
on a predefined set of language keywords, so it would require changes both in the editor code

This is not entirely correct...
Scintilla also defines other key word set, that can be used for this purpose for example, you can
handle this in the OnSave(), and update the key words, followed by a call to Colourise().

So doing something like this:
Code
OnFileSave()
{
  wxString keyword = GetKeyWords();
  wxScintilla::SetKeyWords(1, keywords);
  wxSCintilla::Colourise();
}

this will give u the required results.

However, you still need to implement the 'GetKeyWords()' method, which is another story ;)

Eran