Author Topic: An improved “quick-highlight”  (Read 11315 times)

Ding Zhaojie

  • Senior Community Member
  • Posts: 193
  • Hero Points: 37
An improved “quick-highlight”
« on: December 18, 2008, 04:06:02 am »
Works as "quick-highlight" but...
* quick highlights word in all buffers (like SourceInsight)
* supports multiple highlight colors (Add your favorite color in hl_color_tbl)
* allows un-highlight a single word

Install:
1. load highlight.e
2. Open tbfind.e, import highlight.e and call hl_reset() at the end of clear_highlights() funtion.
3. reload tbfind.e, so you can use clear-highlights command to clear all highlights now
4. bind a key or menu item for hl-word command.

Usage:
* run hl-word to highlight the word in all buffers.
* run hl-word again to un-highlight the word.
« Last Edit: December 18, 2008, 04:14:56 am by Ding Zhaojie »

beaver

  • Community Member
  • Posts: 6
  • Hero Points: 1
Re: An improved “quick-highlight”
« Reply #1 on: January 14, 2009, 10:10:22 pm »
Hi Ding,

I have been looking for this feature for a while. Previously, I used gvim editor in my development and I have scrips that will do multiple highlights. When I switched to SE, I missed that feature :(

Anyway, I followed your instructions to install highlight.e but ran across some issues in step2:
     2. Open tbfind.e, import highlight.e and call hl_reset() at the end of clear_highlights() funtion.
   
Do I import the file correctly? I copied the file "highlight.e" to ../Slickedit/macros directory and added the following lines to tbfind.e
     #import "highlight.e"
     _command void clear_highlights()
    {    .
         .
         hl_reset();
    }
I was able to reload tbfind.e (Macro->Load Module...) without any problem. But when I do highlighting, I get these errors:

 Stack trace written to file: /tmp/vsstack.aa
 Procedure hl-reset not found
tbfind.ex 25069 clear_highlights()   p_window_id: 74   p_object: OI_FORM   p_name:
vi.ex 1847 vi_search(first_buf_id,uI@P*#)   p_window_id: 74   p_object: OI_FORM   p_name:
ex.ex 1020 ex_search_mode()   p_window_id: 74   p_object: OI_FORM   p_name: [/right][/center]

What do I need to do to fix these errors?

Thanks in advance..

-Beaver



     

beaver

  • Community Member
  • Posts: 6
  • Hero Points: 1
Re: An improved “quick-highlight”
« Reply #2 on: January 14, 2009, 10:16:57 pm »
BTW.. I forget to mention that I'm using slickedit2007 and running on linux environment. Here are the details:
 
SlickEdit Version 12.0.3.0
Red Hat Enterprise Linux WS release 4 (Nahant Update 2)

Thanks,

-Beaver
 

chrisant

  • Senior Community Member
  • Posts: 1413
  • Hero Points: 131
Re: An improved “quick-highlight”
« Reply #3 on: January 15, 2009, 12:53:04 am »
You reloaded the tbfind.e module.
Did you also load the highlight.e module?

Copying the highlight.e file isn't enough, you have to load the module, too.

beaver

  • Community Member
  • Posts: 6
  • Hero Points: 1
Re: An improved “quick-highlight”
« Reply #4 on: January 18, 2009, 08:44:49 am »
Christant, thanks for your replied.

I did load the highlight.e before i reloaded the tbfinde.

I think the problem is when the hl_reset() function is being call inside tbfind.e file. Somehow the declaration for hl_reset() has to be visible. I thought having #import in tbfind.e will resolve this problem but apparently it does not.

-Beaver

chrisant

  • Senior Community Member
  • Posts: 1413
  • Hero Points: 131
Re: An improved “quick-highlight”
« Reply #5 on: January 18, 2009, 11:23:30 am »
What happens when you try to invoke the "hl_word" command from the SlickEdit command line?

Ding Zhaojie

  • Senior Community Member
  • Posts: 193
  • Hero Points: 37
Re: An improved “quick-highlight”
« Reply #6 on: January 19, 2009, 01:42:54 am »
I have not tried it in v12 yet. I think it might because there is something wrong in compiling so the hightlight.e has not been loaded successfully. Load it again and watch the result (the result will show on the status bar).
« Last Edit: January 19, 2009, 03:50:15 am by Ding Zhaojie »

jporkka

  • Senior Community Member
  • Posts: 136
  • Hero Points: 6
Re: An improved “quick-highlight”
« Reply #7 on: January 22, 2009, 06:30:20 pm »
I like this, but I don't like the limitation of highlighting words only.
By using the "get_quick_search_word" function, I enhanced it to use the word at the cursor or the current selection.
Then, if there is no selection, hl_word behaves as it does now. If there is a selection, it uses the selected text for highlighting (just like quick_search). Note that when highlighting a selection, the matching is also case-insensitive.


dunkers

  • Senior Community Member
  • Posts: 594
  • Hero Points: 27
Re: An improved “quick-highlight”
« Reply #8 on: January 25, 2009, 09:59:45 pm »
Notepad++ has this, but slightly enhanced: if you double click a string then all other instances of that new selection are highlighted. Saves the right click... I haven't yet decided if it's really useful or really annoying. This highlight for SE is a great step in that direction, thanks Ding.
« Last Edit: January 25, 2009, 10:02:13 pm by dunkers »

Ding Zhaojie

  • Senior Community Member
  • Posts: 193
  • Hero Points: 37
Re: An improved “quick-highlight”
« Reply #9 on: January 26, 2009, 04:32:30 pm »
Notepad++ has this, but slightly enhanced: if you double click a string then all other instances of that new selection are highlighted. Saves the right click... I haven't yet decided if it's really useful or really annoying. This highlight for SE is a great step in that direction, thanks Ding.
Yeah I've tried Notepad++. It is convenient while reading codes but very annoying while writing codes.

But I have another macro implemented a "IDA-like" highlighting manner. The idea was borrowed from IDA Pro: it highlights the words automatically (even without double click on it). I like to bind the "ida-like-highlight" command to Ctrl+Shift+H and turn it on while analyzing codes.
« Last Edit: January 29, 2009, 08:14:59 am by Ding Zhaojie »

dunkers

  • Senior Community Member
  • Posts: 594
  • Hero Points: 27
Re: An improved “quick-highlight”
« Reply #10 on: January 26, 2009, 05:13:13 pm »
I'll take a look, thanks. Not sure that I'd remember to turn it on, and leaving it on could be excessively annoying, but as a work displacement activity this is great :)

Ding Zhaojie

  • Senior Community Member
  • Posts: 193
  • Hero Points: 37
Re: An improved “quick-highlight”
« Reply #11 on: January 29, 2009, 07:42:58 am »
I'll take a look, thanks. Not sure that I'd remember to turn it on, and leaving it on could be excessively annoying, but as a work displacement activity this is great :)

Each time while SE starts, the ida-like-highlight feature will be disabled automatically so it will never bother you :)

dunkers

  • Senior Community Member
  • Posts: 594
  • Hero Points: 27
Re: An improved “quick-highlight”
« Reply #12 on: January 29, 2009, 11:57:54 am »
Takes some getting used to. I seem to have lost the quickhighlight hilights somewhere along the line: it says it's highlighting but nothing is.

tomek

  • Community Member
  • Posts: 9
  • Hero Points: 0
Re: An improved “quick-highlight”
« Reply #13 on: February 02, 2009, 04:05:48 pm »
Will highlight.e macro work with Slick Edit v 11.0.2 on Windows? I am getting the following error when I try to load highlight.e

"Identifier 'CFG-SYMBOL-HIGHLIGHT' not declared"

thomas
« Last Edit: February 02, 2009, 04:59:08 pm by tomek »

Ding Zhaojie

  • Senior Community Member
  • Posts: 193
  • Hero Points: 37
Re: An improved “quick-highlight”
« Reply #14 on: February 04, 2009, 03:37:12 am »
Will highlight.e macro work with Slick Edit v 11.0.2 on Windows? I am getting the following error when I try to load highlight.e

"Identifier 'CFG-SYMBOL-HIGHLIGHT' not declared"
I'm not quite sure if it could work with v11. But I think just remove the CFG-SYMBOL-HIGHLIGHT in the color table might works. The symbol highlight feature was introduced in v13 so v11 does not have this color.