SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => SlickEdit User Macros => Topic started by: Ruhh on October 05, 2011, 05:29:53 PM

Title: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: Ruhh on October 05, 2011, 05:29:53 PM
Description
This module implements commands for highlighting all occurrences of current word, selected text or regular expression with one of 7 predefined colors. Tested in SlickEdit 15.

This is a re-implementation of my old CodeWright macro. I use multiple highlights when analyzing huge log files generated by our system.

Commands
'highlight_textN' commands, where N is from 1 to 7, highlight all occurrences of current word or selected text with color N. Selected text can not span more than current line. If cursor is on existing highlight then that highlight is cleared.

'highlight_reN' commands, where N is from 1 to 7, prompt user for a Perl regular expression and highlight all occurrences with color N.

'highlight_text_clear_all' command clears all highlights created with 'highlight_textN' or 'highlight_reN' commands.

'highlight_text_bind_keys' command binds 'highlight_textN', 'highlight_reN' and 'highlight_text_clear_all' commands all at once. Default bindings are Ctrl-1 to Ctrl-7, Ctrl-Shift-1 to Ctrl-Shift-7 and Ctrl-0 keys respectively. Customize this command to your taste.

By default searching for text to highlight is case-insensitive and not restricted to whole words. Two commands 'highlight_text_toggle_case_sensitive' and 'highlight_text_toggle_whole_word' toggle the flags.

Installation

Customization
Predefined colors are stored in 's_colors' array. You can change them to your taste. It is trivial to add more colors: add a color entry into 's_colors' and then add new 'highlight_textN'/'highlight_reN' commands.

Acknowledgements
Thanks to marksun for SymHighlight macro which I used as a starting point.
Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: taiwuchiang on July 01, 2012, 01:05:00 AM
I just upgraded to V17 and seems the macro doesn't work for V17 anymore. It was working fine on V16 but during the upgrade process the new version complained a compiler error for a line in the macro file.
Anybody knows what have been changed in the macro language in the new V17 and possibly a fix for it? I used this highlight macro a lot and can't live without it. Thanks.
Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: Graeme on July 01, 2012, 01:19:28 AM
I just downloaded it  - it loaded ok in V17.  Have you tried loading it manually?

Do you remember what the specific error message was or what line number?
Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: tangb4c on October 10, 2012, 09:57:43 AM
Nice work!
It don't works at V17. Solution like this:
replace all occurrences of VSARG2_READ_ONLY in the highlight_text.e with VSARG2_READ_ONLY|VSARG2_MARK

end solution.

some tips:
I add a function in highlight_text.e. like this:
Code: [Select]
static int g_highlight_index = 0;
_command void highlight_text() name_info (','VSARG2_READ_ONLY|VSARG2_MARK |VSARG2_REQUIRES_EDITORCTL|VSARG2_LINEHEX)
{
   highlightCurrentText (++g_highlight_index%g_highlightInfo._length());
}
To bind a key(like F7) to highlight_text, you could highlight selected texts with cycle color.

Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: tangb4c on October 10, 2012, 09:59:53 AM
perverted verification code,god daamn it !!!
 >:( >:( >:(
Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: Dan112123 on March 28, 2013, 04:29:32 PM
I wonder if there is a way to make it Highlight all occurrences of selected word, just like Visual Studio does. I double click a work and it highlights all of the occurrences of that word.
 
Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: chandlerzhang on June 24, 2013, 12:22:03 AM
I wonder if there is a way to make it Highlight all occurrences of selected word, just like Visual Studio does. I double click a work and it highlights all of the occurrences of that word.

try _command void quick_mark_all_occurences() name_info(','VSARG2_MARK|VSARG2_EDITORCTL|VSARG2_READ_ONLY)
{
     if (_select_type()!='') {
      begin_select();
      _deselect();
   }
   
   _str cw = cur_word(auto sc);
   mark_all_occurences(cw, /* search_text */
                       'WHP,XSC',/* search_options */
                       VSSEARCHRANGE_CURRENT_PROC, /* search_range */
                       0,/* mfflags */
                       0,/* grep_id */
                       1,/* show_hilite */
                       0,/* list_all */
                       0,/* show_bookmarks */
                       1);/* scroll_markup */
}

try this and bind this command to double-click.
Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: stsimmer on March 10, 2020, 11:23:23 AM
Hi, anybody know is it work with SlickEdit Pro 2019 (v24.0.1.0 64-bit) on Linux?
Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: jporkkahtc on March 10, 2020, 02:13:20 PM
Did you run the macro 'symtagload' ?
There is a Readme file that notes this.
Title: Re: Highlighting all occurences of text or regular expression with one of 7 colors
Post by: stsimmer on March 10, 2020, 03:01:56 PM
I do next:
1.Download highlight_text.e file
2. Put it near user.cfg.xml, in folder /home/<my_user_name>/.slickedit/24.0.1/...
3. Open and replace all occurrences of VSARG2_READ_ONLY in the highlight_text.e with VSARG2_READ_ONLY|VSARG2_MARK,
    add function highlight_text()... as described previously.
4. Save all, reopen my SlickEdit Pro 2019 (v24.0.1.0 64-bit) Linux
5.From menu Macro->Load module take new version of highlight_text.e
   And recived error …
“Unable to load module '/home/stas/.slickedit/24.0.1/highlight_text.e'.  Incorrect version”
Is it possible to fix?