Recent

Author Topic: synedit TSynEditMarkupHighlightAllMulti set colors  (Read 240 times)

BubikolRamios

  • Full Member
  • ***
  • Posts: 240
synedit TSynEditMarkupHighlightAllMulti set colors
« on: July 08, 2022, 06:37:02 am »
Last line does not work, how to set that ?
Code: Pascal  [Select][+][-]
  1. var
  2.   YourMarkup:TSynEditMarkupHighlightAllMulti;
  3.  
  4. begin
  5.   YourMarkup := TSynEditMarkupHighlightAllMulti.create(SynEdit1);
  6.  
  7.   SynEdit1.MarkupManager.AddMarkUp(YourMarkup);
  8.  
  9.   YourMarkup.BGColor := clYellow;
  10.  
  11. end;
  12.  
  13.  
lazarus-2.0.12-fpc-3.2.0-win32/win64

dje

  • Full Member
  • ***
  • Posts: 107
Re: synedit TSynEditMarkupHighlightAllMulti set colors
« Reply #1 on: July 08, 2022, 09:05:17 am »
The property TSynEditMarkup.BGColor "reader" calls TSynEditMarkup.GetBGColor()
The code for GetBGColor is
Code: Pascal  [Select][+][-]
  1. function TSynEditMarkup.GetBGColor : TColor;
  2. begin
  3.   result := fMarkupInfo.Background;
  4. end;

fMarkupInfo is avaliable though the MarkupInfo property. Therefore, try:

Code: Pascal  [Select][+][-]
  1. YourMarkup.MarkupInfo.Background := clYellow


BubikolRamios

  • Full Member
  • ***
  • Posts: 240
Re: synedit TSynEditMarkupHighlightAllMulti set colors
« Reply #2 on: July 08, 2022, 10:16:20 am »
Thanks.

Not to open new thread.

1. If I set only background to clYellow, foreground becomes white, from default black. How is that ?

2.https://wiki.freepascal.org/Colors

gold $FFD700 seems wrong, background turns out kind of blue

Code: Pascal  [Select][+][-]
  1.  YourMarkup.MarkupInfo.Background := $FFD700;
  2.  

?
lazarus-2.0.12-fpc-3.2.0-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8253
  • Debugger - SynEdit - and more
    • wiki
Re: synedit TSynEditMarkupHighlightAllMulti set colors
« Reply #3 on: July 08, 2022, 05:32:21 pm »
I am not sure why it changes the foreground....

Maybe...
There is some code that if foreground and background are equal, then one of them would be changed...

unit LazSynTextArea
Code: Pascal  [Select][+][-]
  1. function TLazSynPaintTokenBreaker.GetNextHighlighterTokenEx(out
  2.   ATokenInfo: TLazSynDisplayTokenInfoEx): Boolean;
  3. ...
  4.   // Deal with equal colors
  5.   // TODO: Map to RGB first
  6.   if (FMarkupTokenAttr.Background = FMarkupTokenAttr.Foreground) then begin // or if diff(gb,fg) < x
  7.     if FMarkupTokenAttr.Background = BackgroundColor then
  8.       FMarkupTokenAttr.Foreground := not(FMarkupTokenAttr.Background) and $00ffffff // or maybe ForegroundColor ?
  9.     else
  10.       FMarkupTokenAttr.Foreground := BackgroundColor;
  11.   end;
  12.  

But that code would require exact equality....


So if your colors are equal...
Otherwise it may require some debugging.

 

TinyPortal © 2005-2018