Author Topic: Occurrences highlighting  (Read 31239 times)

Offline danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 203
Occurrences highlighting
« on: July 23, 2008, 01:37:48 pm »
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]

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Occurrences highlighting
« Reply #1 on: July 23, 2008, 02:22:26 pm »
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."

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Occurrences highlighting
« Reply #2 on: July 23, 2008, 02:25:44 pm »
Very nice feature !!
Is it possible to highlight only whole words with same case ?

Dje

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Occurrences highlighting
« Reply #3 on: July 23, 2008, 02:33:07 pm »
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 :-)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Occurrences highlighting
« Reply #4 on: July 23, 2008, 02:56:13 pm »
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."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Occurrences highlighting
« Reply #5 on: July 23, 2008, 03:05:39 pm »
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,...
Quote
when 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 :)
« Last Edit: July 23, 2008, 03:10:30 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Occurrences highlighting
« Reply #6 on: July 23, 2008, 03:10:00 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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Occurrences highlighting
« Reply #7 on: July 23, 2008, 03:11:00 pm »
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."

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Occurrences highlighting
« Reply #8 on: July 23, 2008, 03:13:43 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.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Occurrences highlighting
« Reply #9 on: July 23, 2008, 03:22:04 pm »
go ahead and commit  8)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Occurrences highlighting
« Reply #10 on: July 23, 2008, 03:35:47 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 203
Re: Occurrences highlighting
« Reply #11 on: July 23, 2008, 05:39:32 pm »
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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Occurrences highlighting
« Reply #12 on: July 23, 2008, 05:46:11 pm »
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."

Offline danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 203
Re: Occurrences highlighting
« Reply #13 on: July 24, 2008, 03:11:47 pm »
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:
Code
<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


Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Occurrences highlighting
« Reply #14 on: July 24, 2008, 03:21:41 pm »
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