Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SynEdit: How to do background highlighting of multiple text regions given start and stop positions?

Tags:

delphi

synedit

Using: Delphi XE2, Windows VCL forms application, 32-bit

I'm using the SynEdit control to display text. I'm already using the TSynHTMLSyn syntax highlighter with the control to properly highlight HTML and JS code.

I'm also doing a diff on this text (using Angus Johnson's TDiff) with another version of the text to find: deletions, additions and changes. I need to highlight each of these type of changes with a different color ie RED for deletion, BLUE for additions, and GREEN for changes.

My questions:

  1. Is it possible to implement?
  2. If yes, then how?

TIA.

like image 818
Steve F Avatar asked Oct 30 '13 05:10

Steve F


1 Answers

Try to use TSynEdit.onSpecialLineColors event, e.g.

procedure TfmRunScript.EditorSpecialLineColors(Sender: TObject;
  Line: Integer; var Special: Boolean; var FG, BG: TColor);
begin
 if Line = ErrorLine then
  begin
   Special := True;
   BG := clMaroon;
   FG := clWhite;
  end;
end;
like image 142
Pavlo Golub Avatar answered Nov 06 '22 12:11

Pavlo Golub