Author Topic: Using the scroll highlight with custom colors  (Read 2307 times)

pmsteinm

  • Community Member
  • Posts: 78
  • Hero Points: 0
Using the scroll highlight with custom colors
« on: February 25, 2013, 10:56:18 pm »
I'm trying to modify a macro that uses streams to highlight text in various colors to also show these matches on the scroll bar highlight.

I think I need to do this to create what I want:
      int scrollMarkerId = _ScrollMarkupAdd(p_window_id,someLine,markerType,1);
      _ScrollMarkupSetTypeColor(scrollMarkerId,colorId);

But I don't see anything and I don't get any error message.  Is there something else I have to do to make it display that scroll highlights?

chrisant

  • Senior Community Member
  • Posts: 1413
  • Hero Points: 131
Re: Using the scroll highlight with custom colors
« Reply #1 on: February 26, 2013, 04:43:29 am »
I don't see code for allocating a new color, assigning an rgb value to the allocated color, allocating a new scroll markup id, or assigning the allocated color to the allocated scroll markup id.

Here's the basic outline for usage, including the "overhead" calls for allocating everything and setting them up.

Code: [Select]
#if __VERSION__ >= 17
// Declare variables (not static).
int s_colorScrollMarkup = -1;
int s_markertypeScrollMarkup = -1;

// Macro initialization.
definit()
{
   if ( arg( 1 ) != 'L' )
   {
      s_markertypeScrollMarkup = -1;
   }
   else
   {
      if ( s_markertypeScrollMarkup != -1 )
         _ScrollMarkupRemoveAllType( s_markertypeScrollMarkup );
   }
}

// Demand-initialization for colors; can be called repeatedly.
static void EnsureScrollMarkupInitialized()
{
   if ( s_colorScrollMarkup == -1 )
      s_colorScrollMarkup = _AllocColor();
   _default_color( s_colorScrollMarkup, 0, _rgb( 0xcc, 0xbb, 0x00 ), 0 );

   if ( s_markertypeScrollMarkup == -1 )
   {
      s_markertypeScrollMarkup = _ScrollMarkupAllocType();
      _ScrollMarkupSetTypeColor( s_markertypeScrollMarkup, s_colorScrollMarkup );
   }
}

// Sample function...
_command void DoIt() name_info(','VSARG2_READ_ONLY|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   EnsureScrollMarkupInitialized();
   _ScrollMarkupRemoveAllType( s_markertypeScrollMarkup );

   // HERE IS AN EXAMPLE OF ADDING SCROLL MARKUP.
   // LINE_NUM = starting line number to mark.
   // COUNT_OF_LINES = number of lines to mark.
   _ScrollMarkupAdd( view_id, LINE_NUM, s_markertypeScrollMarkup, COUNT_OF_LINES );
}
#endif
« Last Edit: February 26, 2013, 04:50:21 am by chrisant »