Author Topic: _StreamMarkerSetTextColor  (Read 3074 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
_StreamMarkerSetTextColor
« on: July 04, 2015, 12:32:03 AM »
Despite its name this function sets the background to the specified color, not the text.
OK, but it appears to always set the text color to black.


Is there a way to set text color to something else?


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6938
  • Hero Points: 531
Re: _StreamMarkerSetTextColor
« Reply #1 on: July 05, 2015, 12:34:37 PM »
I didn't have a problem:

   int ColorIndex=_AllocColor(0xff00,0xff);
   int type=_MarkerTypeAlloc();
   StreamMarkerIndex=_StreamMarkerAdd(0,_nrseek(),2,false,0,type,"message");
   _StreamMarkerSetTextColor(StreamMarkerIndex,ColorIndex);


I noticed that not all _AllocColor() flags are documented (F_INHERIT_COLOR_AND_STYLE,F_INHERIT_FG_COLOR, AND F_INHERIT_BG_COLOR) but from your post issue, these flags are probably not what you want.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: _StreamMarkerSetTextColor
« Reply #2 on: July 05, 2015, 09:50:31 PM »
HM... so I did make a mistake, but there is still a problem.

Given this SlickC code:
_command void colorize() name_info(',')
{
    "String"

    int ColorIndex=_AllocColor(0xff00,0xff, F_INHERIT_FG_COLOR);
    int type=_MarkerTypeAlloc();
    StreamMarkerIndex=_StreamMarkerAdd(0,_nrseek(),2,false,0,type,"message");
    _StreamMarkerSetTextColor(StreamMarkerIndex,ColorIndex);
}

When you highlight a string or a keyword, the background is red and the text turns green.
When you highlight the function name, then the text stays black as expected.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6938
  • Hero Points: 531
Re: _StreamMarkerSetTextColor
« Reply #3 on: July 06, 2015, 02:18:26 AM »
When you use inherit, you can't know for sure what will happen. All I can say is you might like what it does or you might not. It's a complicated color contrast algorithm. If there isn't enough contrast, it won't inherit the color because it would look really bad.
« Last Edit: July 06, 2015, 09:30:04 AM by Clark »

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: _StreamMarkerSetTextColor
« Reply #4 on: July 06, 2015, 10:14:33 PM »
Interesting about contrast ... What algorithm is used?
(Request: Expose the color contrast function to script)
I used one I found on Wikipedia ... so when highlighting text it will try to pick colors that will be readable.
(That's why I was writing sqrt and cubert functions --- oddly missing from Slick math support).

Is there a way for a script to get notified when the slick colors are changed?
(A call_list macro?)