Author Topic: Occurrences highlighting  (Read 31256 times)

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Occurrences highlighting
« Reply #30 on: November 13, 2012, 04:51:00 pm »
Interesting :)
However, I see that sometimes it can get very difficult to see what you have selected, precisely because of the highlight of occurrences.

See this as an example:

Code
int main()
{
    // try to select these Foos:
    if( SomeBool )  Foo( 1 );
    else            Foo( 2 );
   
    // but not this one:
    return Foo( 0 );
}

The selection color should get painted over the highlights, and not under it. As it is now, I can't see which ocurrences I have selected and which ones not. Another option could be to mix colors or use some transparency.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Occurrences highlighting
« Reply #31 on: November 13, 2012, 05:37:35 pm »


Don't undstand your problem. The first one is highlighted, the other two are highligted and selected. Typing will replace into the lower two.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Occurrences highlighting
« Reply #32 on: November 13, 2012, 05:42:33 pm »
(especially since non-patched occurrence highlighting doesn't do 1-character and 2-character selections, such as variable names like i, or pt, or it).
Thomas, this is possible if you use the "Incremental Search" plugin. Just enable the IS Toolbar from the menu, then enter even single character "words" into the search field and press "highlight". I find this really useful very often.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Occurrences highlighting
« Reply #33 on: November 13, 2012, 05:43:09 pm »
Ok, I'll try to post a screenshot when I get home so that you see what I mean.

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: Occurrences highlighting
« Reply #34 on: November 13, 2012, 05:49:34 pm »
I also think the highlighting and selection is confusing... see screenshot: I just double-clicked on the the first "cb_unused", but it's hard to tell which one is really selected...

[attachment deleted by admin]
« Last Edit: November 13, 2012, 05:51:32 pm by daniloz »

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Occurrences highlighting
« Reply #35 on: November 13, 2012, 05:53:08 pm »
Thanks daniloz, you saved me the work :) I think in that screenshot the first one is selected and the rest aren't, but one has to really focus to see it...

And by the way, the problem also happens for single selection. It is just less of a problem (it is easy to remember what you selected if it's only one thing ;) )
« Last Edit: November 13, 2012, 05:56:06 pm by carra »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Occurrences highlighting
« Reply #36 on: November 13, 2012, 05:57:53 pm »
(especially since non-patched occurrence highlighting doesn't do 1-character and 2-character selections, such as variable names like i, or pt, or it).
Thomas, this is possible if you use the "Incremental Search" plugin. Just enable the IS Toolbar from the menu, then enter even single character "words" into the search field and press "highlight". I find this really useful very often.
I've just patched the code to if(selection.Length() > 0) (therefore me referring to "unpatched"), which always works nicely, and doesn't ignore whitespace (used to trim whitespace, but it's even better without). Whitespace helps finding for example all occurrences of i without highlighting the one in while. Unluckily, it doesn't work nearly as well for for(Blah::iterator it = blah.begin; ...) f(*it); because it won't find the *it --- this is why finding (syntax aware) references would be so interesting.

Try and rename a single-letter variable (say, i) in a function that has more than 5 lines. It's a nightmare, and actually you should better stay away from it alltogether. When you are doing that kind of thing for a shadow warning, you spend 15-20 minutes on those 5 lines just to be sure you've not forgotten one, as that would modify the wrong variable in the wrong scope. And even then you feel bad about it afterwards. What's worst, the compiler won't even be able to warn you when it happens...

(Lesson to learn: don't use single-letter variables if you can help it. At least not in non-trivial code with several nested blocks.)
« Last Edit: November 13, 2012, 06:00:04 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Occurrences highlighting
« Reply #37 on: November 13, 2012, 08:30:04 pm »
Try and rename a single-letter variable (say, i) in a function that has more than 5 lines.
Technically its possible: Scintilla offers multiple selections (not necessarily bound together)  an also writing to multiple selections. CC could offer the interface to local variables, bringing both together allows what you want.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Occurrences highlighting
« Reply #38 on: November 13, 2012, 08:40:57 pm »
I find I get by pretty well with "match case + whole word" or regexp replaces. Something more interactive might be nice, but it might also be a lot of work for small result. Slightly offtopic, but, IMO, it would also be useful to be able to perform operations on the items in the find in files results list.

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: Occurrences highlighting
« Reply #39 on: November 14, 2012, 08:30:22 am »
I find I get by pretty well with "match case + whole word" or regexp replaces. Something more interactive might be nice, but it might also be a lot of work for small result.

I have to disagree with you here. I do agree that from a developer perspective "match case + whole word" or regexp replaces is just fine and the work for implementing something more interactive is not worth...

However, IMHO, from a typical user perspective, I think that would be a very nice feature because:

1- the user maybe is not acquainted with regexp
2- the user may feel more safe if there's something interactive to do the replaces, i.e. he may fell that he's not missing something

I'm fine with the actual "match case + whole word" or regexp replaces, but wanted to leave my 2 cents here....

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Occurrences highlighting
« Reply #40 on: November 14, 2012, 10:28:58 am »
Replace with "match regex" is not very usable. First, I've often seen it fail when it should work, especially when the regex contains properly escaped special characters such as ( or * or \ (incidentially this seems to work right now that I've mentioned it, but I've seen it fail with expressions that were 100% correct before), and second, merely having to bring up the dialog and writing the expression is a lot of work, which makes it less competitive.

Selecting a variable is a matter of holding down shift and pressing the arrow key (possibly 3-4 times), or doing a double-click with the mouse.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."