Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: ollydbg on October 07, 2009, 04:04:51 am

Title: highlight of the select variable problem
Post by: ollydbg on October 07, 2009, 04:04:51 am
Hi, it seems there are some difference of the highlight mechanism between CB and notepad++.

If I only select a variable which has only a character. In notepad++, all the other variable will be highlighted. But in CB, this can't work.

See the screen of both CB and notepad++.

(http://i683.photobucket.com/albums/vv194/ollydbg_cb/2009-10-07095351.png)

(http://i683.photobucket.com/albums/vv194/ollydbg_cb/2009-10-07095356.png)
Title: Re: highlight of the select variable problem
Post by: blueshake on October 07, 2009, 05:00:17 am
Hello,ollydbg:
read these codes:
Code
        if( cfg->ReadBool(_T("/highlight_occurrence/enabled"), true)
                && selectedText.Len() > 2   
in     void HighlightOccurrences() in cbeditor.cpp
Title: Re: highlight of the select variable problem
Post by: ollydbg on October 07, 2009, 05:24:16 am
Hello,ollydbg:
read these codes:
Code
        if( cfg->ReadBool(_T("/highlight_occurrence/enabled"), true)
                && selectedText.Len() > 2  
in     void HighlightOccurrences() in cbeditor.cpp

Thanks.
But, my question is: Why the selectedText.Len() should larger than 2?
I think it should be

Code
selectedText.Len()>0
Title: Re: highlight of the select variable problem
Post by: blueshake on October 07, 2009, 07:13:41 am
Maybe for some kind of Optimization.
Title: Re: highlight of the select variable problem
Post by: Jenna on October 07, 2009, 07:21:19 am
Highlight Occurrences does not highlight all occurrences of a variable, but all occurrences of a character.
And it is called from UpdeteUI.

It searches the whole editor for occurrences and sets the indicator-style for it (and for the second control in split-mode) so the decision to ignore selections with less than three characters was made, not to slow down the IDE too much.
Title: Re: highlight of the select variable problem
Post by: MortenMacFly on October 07, 2009, 07:29:17 am
the decision to ignore selections with less than three characters was made, not to slow down the IDE too much.
Wasn't that configurable via editor settings or alike..?!
Title: Re: highlight of the select variable problem
Post by: Jenna on October 07, 2009, 07:38:29 am
the decision to ignore selections with less than three characters was made, not to slow down the IDE too much.
Wasn't that configurable via editor settings or alike..?!
I don't think so, but it can be done easily, of course.
But such an option should have a warning, that it might slow down performance when processing large files.
Title: Re: highlight of the select variable problem
Post by: mariocup on October 07, 2009, 08:47:30 am
Please do not make it configurable. To be honest if you look e.g. at the current editor settings (see attachment) there are so many settings for character encoding that user will really get confused. We should rather think about removing some settings and not make all configurable since the usability will suffer. If we have more and more settings it will come the day that we have such a confusing dialog like eclipse and user will need one day to find a setting how to configure the font size. Such things will frustrate new users. So we should keep the benefit that codeblocks is an easy to use IDE  :D

BTW: Although it has nothing to do with the functionality of Code::Blocks I find it disturbing that the text of some checkbox differ in case.
e.g.
try to detect latin-2
relative filename
Highlight Colour

etc.

I would suggest to use a capital letter at the beginning of a sentence and then only lowercase.

The other thing is the inconsistency of writing words. In some dialogs (e.g. general tab we write "case-sensitive" (highlight occurences) and in code completion tab we write "case sensitive"). Other examples are for the Todo, To-do (see attachment)

[attachment deleted by admin]
Title: Re: highlight of the select variable problem
Post by: dje on October 07, 2009, 09:34:21 am
Hello!

Please do not make it configurable. To be honest if you look e.g. at the current editor settings (see attachment) there are so many settings for character encoding that user will really get confused. We should rather think about removing some settings and not make all configurable since the usability will suffer. If we have more and more settings it will come the day that we have such a confusing dialog like eclipse and user will need one day to find a setting how to configure the font size. Such things will frustrate new users. So we should keep the benefit that codeblocks is an easy to use IDE  :D
Another solution is to display most common/used/important settings on a panel and put on it an "Advanced" button to display all other ones showing a hidden panel or with a new dialog. That way, it is still possible to have a fine granularity in settings without loosing the work...

Dje
Title: Re: highlight of the select variable problem
Post by: daniloz on October 07, 2009, 09:40:12 am
I really like Dje solutions and I would like to have the option to configure the highlight selection length (without having to recompile C::B as I just did to set it to zero  :D ).

Just my 2 cents...

daniloz
Title: Re: highlight of the select variable problem
Post by: mariocup on October 07, 2009, 09:51:35 am
Quote
Another solution is to display most common/used/important settings on a panel and put on it an "Advanced" button to display all other ones showing a hidden panel or with a new dialog. That way, it is still possible to have a fine granularity in settings without loosing the work...

This sounds reasonable to have such as advanced settings.
Title: Re: highlight of the select variable problem
Post by: oBFusCATed on October 07, 2009, 10:16:44 am
+1 for adding advance button

Another thing that would be quite useful is if there is a way to save all the settings in some kind of a profile.
That is, because different projects have different requirements for the editor, for example:

proj1:
tab 3, use spaces, eol = unix
proj2:
tab 4, not use spaces, eol = win

And if there is a way to export the profile to external file, one can be able to give his profile to a co-worker and everybody will edit files in the project the same, so the formating issues/commits will be less frequent.
An extreme variant will be to put profiles in the project (cbp file), so the switching of the profile will be automatic
Title: Re: highlight of the select variable problem
Post by: blueshake on October 07, 2009, 10:21:47 am
Quote
And if there is a way to export the profile to external file, one can be able to give his profile to a co-worker and everybody will edit files in the project the same, so the formating issues/commits will be less frequent.

Agreed. :D
Title: Re: highlight of the select variable problem
Post by: daniloz on October 07, 2009, 10:35:18 am
And if there is a way to export the profile to external file, one can be able to give his profile to a co-worker and everybody will edit files in the project the same, so the formating issues/commits will be less frequent.

+1 for this very nice and wanted  8) feature...
Title: Re: highlight of the select variable problem
Post by: ollydbg on October 07, 2009, 10:36:34 am
+1 for adding advance button.
Title: Re: highlight of the select variable problem
Post by: dje on October 07, 2009, 10:42:48 am
And if there is a way to export the profile to external file, one can be able to give his profile to a co-worker and everybody will edit files in the project the same, so the formating issues/commits will be less frequent.

+1 for this very nice and wanted  8) feature...
yes, but it is also possible to configure astyle properly and include an astyle step before commiting in the configuration management tool.

Dje
Title: Re: highlight of the select variable problem
Post by: ollydbg on March 02, 2011, 02:36:07 pm
sorry for bump the old thread, I found a patch here:
http://developer.berlios.de/patch/?func=detailpatch&patch_id=3130&group_id=5358

the author said that "no cpu overload detected", it that true?
sometimes I still need to hightlight one char variable.
thanks.
Title: Re: highlight of the select variable problem
Post by: wf on March 02, 2011, 06:31:26 pm
I'm using this on windows + Process Explorer for monitoring cpu load. There is no cpu overload because if no text selected:
Code
if (a == b)
     return
We return at the beginnig of function. Test it someone please.
Title: Re: highlight of the select variable problem
Post by: oBFusCATed on February 02, 2013, 02:39:15 am
I've just committed patch #3130, which makes it possible to set the minimum of characters to 1.
The default is still 3, so the current behaviour should be unchanged.

About the slowness, yes there is slowness if the setting is set at 1 and I select 'e' in codecompletion.cpp for example.
It take 1-2 seconds to select all the occurrences. But generally it works OK.