Author Topic: enable and disable highlight matching symbols under cursor  (Read 6927 times)

frank_lv

  • Community Member
  • Posts: 30
  • Hero Points: 0
I think the function  ‘ highlight matching symbols under cursor ’ is a very good and useful function.
But can I control it enable\disable by command , not set it in the Option Menu .

Graeme

  • Senior Community Member
  • Posts: 2274
  • Hero Points: 294
Re: enable and disable highlight matching symbols under cursor
« Reply #1 on: April 08, 2009, 06:45:49 am »
This code seems to work.  It has to fudge around with save_pos restore_pos to get the highlight state to update immediately.  The prev_word call is to get it to work when the cursor is already on the last line of the file.  If you have performance problems, see def_highlight_symbols_max_matches and def_highlight_symbols_max_bufsize in the help file (use search).  Alternatively, have a look at _UpdateContextHighlights and the call to _update_current_symbol to see how to force an immediate update without three calls to the render function.  There might be some easier way to force an immediate update but I couldn't find it.

Graeme


Code: [Select]
#include "slick.sh"

_command toggle_highlight_matching_symbols() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _str ext = _Filename2LangId(_mdi.p_child.p_buf_name);
   _SetLanguageOption(ext,'codehelp',_GetCodehelpFlags(ext) ^ VSCODEHELPFLAG_HIGHLIGHT_TAGS);
   typeless p;
   save_pos(p);
   next_word();
   _UpdateContextHighlights(true);
   prev_word();
   _UpdateContextHighlights(true);
   restore_pos(p);
   _UpdateContextHighlights(true);
}



Graeme

  • Senior Community Member
  • Posts: 2274
  • Hero Points: 294
Re: enable and disable highlight matching symbols under cursor
« Reply #2 on: April 08, 2009, 08:53:43 am »
Correction  - remove VSARG2_MACRO and VSARG2_MARK - they are hangovers from something else and shouldn't be there.

Graeme

frank_lv

  • Community Member
  • Posts: 30
  • Hero Points: 0
Re: enable and disable highlight matching symbols under cursor
« Reply #3 on: April 08, 2009, 11:07:35 am »
It is work very well, thanks!

marksun

  • Community Member
  • Posts: 23
  • Hero Points: 4
Re: enable and disable highlight matching symbols under cursor
« Reply #4 on: April 09, 2009, 05:07:29 am »
Or, if you'd like the ability to highlight particular symbols and keep them highlighted until you choose to remove the highlighting you could take a look at the Symbol Highlighting macro I posted in the user macros section (http://community.slickedit.com/index.php?topic=4701.0).

I liked the built in one, but wanted both more control over when the highlighting went away and the ability to have more than one symbol being highlighted at the same time.