News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Occurrences highlighting

Started by danselmi, July 23, 2008, 01:37:48 PM

Previous topic - Next topic

carra

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:

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.

thomas



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."

MortenMacFly

Quote from: thomas on November 13, 2012, 03:58:21 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

carra

Ok, I'll try to post a screenshot when I get home so that you see what I mean.

daniloz

#34
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]

carra

#35
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 ;) )

thomas

#36
Quote from: MortenMacFly on November 13, 2012, 05:42:33 PM
Quote from: thomas on November 13, 2012, 03:58:21 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.)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

MortenMacFly

Quote from: thomas on November 13, 2012, 05:57:53 PMTry 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

dmoore

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.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

daniloz

Quote from: dmoore 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.

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....

thomas

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."