News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Occurrences highlighting

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

Previous topic - Next topic

danselmi

With this patch the editor will highlight (draw a red box aroud) all occurences in the current document of the selected text.
The feature is selectabel/deselectable throught the editor settings dialog.

screenshot attached

patch id: 002525.


[attachment deleted by admin]
spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]

thomas

I'm not quite happy yet because of two things:
1. it triggers from UpdateUI which means it adds a lot of overhead to typing and even moving the mouse
2. on a second thought, there's only one thing


Other than that: Great! Works nicely. I'll have a look if I find something better to hook it into.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

dje

Very nice feature !!
Is it possible to highlight only whole words with same case ?

Dje

killerbot

very nice. I think once Thomas has found a better cpu relaxing idea, and the case issue is solved this is a very nice addition :-)

thomas

Bah... UpdateUI is the official event for selection changes, and there's nothing else. But it's possible to do a quick range test at the beginning, and return without searching through all the text, that should eleminate the overhead almost entirely. Just compiling.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

thomas

#5
Works fine. No measurable difference between with feature or without when editing and scrolling, and such.

It does eat some CPU while doing the highlighting (around 24-25% on my system, on files 200+ kB), but I guess it's obvious that this isn't free :)

Commit? :)

EDIT:
Wait a second,...
Quotewhen the case issue is solved
I think that's an implementation feature, not an issue. But sure, it could be customized. I personally would like to be able to highlight multiple words too, for example.
But... that's only tweaking on details... in principle, it works nicely :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Biplab

Quote from: thomas on July 23, 2008, 03:05:39 PM
Commit? :)

It'd be a nice feature addition. I'm going ahead with the commit. :)
Be a part of the solution, not a part of the problem.

thomas

Eh, how are you going ahead, if you don't have the code? :P
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Biplab

Quote from: thomas on July 23, 2008, 03:11:00 PM
Eh, how are you going ahead, if you don't have the code? :P

It's in Berlios. ;)
Be a part of the solution, not a part of the problem.

killerbot


MortenMacFly

Quote from: killerbot on July 23, 2008, 03:22:04 PM
go ahead and commit  8)
Already done and working nice over here... Cool stuff! 8)
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]

danselmi

I am glad that you like it.

I dont' believe that the patch to reduce CPU consumption works yet!
If you select old_a the highlight occurences feature only marks the compare operation but no assignment to old_a.
With other words: the static variables old_a and old_b have to get assigned the "current" value of a and b which will be "old" in the next run!

regards daniel
spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]

thomas

You're right, one line got lost on the merge... committing that one. Thanks :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

danselmi

Hi,

Dje asked to highlight only words with same case.
I use cb for c++ and vhdl development. VHDL is not not case sensitive, c++ is case sensitive.

Would it not be nice to store some info about the language together with the lexer configuration?
Example for c/c++ configuration:
<LanguageAttributes
  LineComment="//"
  StreamCommentStart="/*"
  StreamCommentEnd="*/"
  BoxCommentStart="/* "
  BoxCommentMid=" * "
  BoxCommentEnd=" */"
  CaseSensitive="1"/>

And define an interface (like the colorset) to get these information during runtime.
(something like Manager::Get()->GetEditorManager()->GetLanguageAttributeSet()->GetCommentToken(lang) )

So we have not to change main.cpp from cb for every new language and the plugins/app can also get these information:

  • Occurrence highlighting likes to know if the language is case sensitive or not
  • Code Statistics only collects these infos about file comments in its config dialog
  • For the todo plugin it should be relatively easy to generate a dynamic line parser (boost::spirit) to find the todos not only in c/c++ files
  • Other things we don't know yet.

What do you think?

regards daniel

spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]

dje

Hi !

I think it depends more on the user preferences, needs and context than on programming language.
That's why I think there should be check boxes in the editor configuration panel to set behaviour and store the options in default.conf.

I would also add that editors/IDE I used that had this feature used generally whole words and case sensitivity.

Dje