Author Topic: highlight of the select variable problem  (Read 10807 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5220
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
highlight of the select variable problem
« 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++.



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.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: highlight of the select variable problem
« Reply #1 on: October 07, 2009, 05:00:17 am »
Hello,ollydbg:
read these codes:
Code: [Select]
        if( cfg->ReadBool(_T("/highlight_occurrence/enabled"), true)
                && selectedText.Len() > 2   
in     void HighlightOccurrences() in cbeditor.cpp
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5220
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: highlight of the select variable problem
« Reply #2 on: October 07, 2009, 05:24:16 am »
Hello,ollydbg:
read these codes:
Code: [Select]
       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: [Select]
selectedText.Len()>0
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.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: highlight of the select variable problem
« Reply #3 on: October 07, 2009, 07:13:41 am »
Maybe for some kind of Optimization.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: highlight of the select variable problem
« Reply #4 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9493
Re: highlight of the select variable problem
« Reply #5 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..?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: highlight of the select variable problem
« Reply #6 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.

Offline mariocup

  • Developer
  • Lives here!
  • *****
  • Posts: 587
Re: highlight of the select variable problem
« Reply #7 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]

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: highlight of the select variable problem
« Reply #8 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

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: highlight of the select variable problem
« Reply #9 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

Offline mariocup

  • Developer
  • Lives here!
  • *****
  • Posts: 587
Re: highlight of the select variable problem
« Reply #10 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11821
    • Travis build status
Re: highlight of the select variable problem
« Reply #11 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
(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!]

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: highlight of the select variable problem
« Reply #12 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
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: highlight of the select variable problem
« Reply #13 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...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5220
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: highlight of the select variable problem
« Reply #14 on: October 07, 2009, 10:36:34 am »
+1 for adding advance button.
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.

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: highlight of the select variable problem
« Reply #15 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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5220
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: highlight of the select variable problem
« Reply #16 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.
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.

Offline wf

  • Single posting newcomer
  • *
  • Posts: 2
Re: highlight of the select variable problem
« Reply #17 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: [Select]
if (a == b)
     return
We return at the beginnig of function. Test it someone please.
^_^

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11821
    • Travis build status
Re: highlight of the select variable problem
« Reply #18 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.
(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!]