Recent

Author Topic: [SOLVED] squiggly line in SynEdit?  (Read 3192 times)

EganSolo

  • Sr. Member
  • ****
  • Posts: 290
[SOLVED] squiggly line in SynEdit?
« on: December 22, 2016, 12:20:17 am »
Context: I am writing an IDE for an inference-based programming language. I created my own highlighter that relies on the parser for this language to provide the proper attribute. This has the benefit of debugging the scanner and tokenizer while editing, which is great.

Question: Whenever I encounter an error, I would like to highlight it the way Lazarus IDE does by drawing a squiggly line beneath the error.

Does the SynEdit component offer this feature? If not, what would it take to extend SynEdit to do this? I don't mind doing the work as long as it doesn't take me too far off course from my present endeavor.

Your suggestions are welcome!

Thanks
« Last Edit: December 24, 2016, 09:58:13 am by EganSolo »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9911
  • Debugger - SynEdit - and more
    • wiki
Re: squiggly line in SynEdit?
« Reply #1 on: December 22, 2016, 01:38:19 am »
it does, yes.

look at the highlight color config. It has a border that can be drawn.
set the border to bottom only, and zickzack

-----------------
you can do that as part of the HL,
Or you can add a Markup class that can do extra highlights

EganSolo

  • Sr. Member
  • ****
  • Posts: 290
Re: squiggly line in SynEdit?
« Reply #2 on: December 22, 2016, 02:05:12 am »
Martin,

Thank you (as usual :) )

Great response.

 :)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: squiggly line in SynEdit?
« Reply #3 on: December 22, 2016, 12:22:24 pm »
You can build your own markups with TSynEditMarkupHighlightMatches.

Base class:
Code: Pascal  [Select][+][-]
  1.   { TprimeMarkupBase }
  2.  
  3.   TprimeMarkupBase = class(TSynEditMarkupHighlightMatches)
  4.   public
  5.     constructor Create(p_SynEdit : TSynEditBase);
  6.     destructor Destroy; override;
  7.     procedure AddMark(p_Start, p_Finish: TPoint);
  8.     procedure ClearMarks;
  9.     property Matches;
  10.   end;
  11.  
Code: Pascal  [Select][+][-]
  1. constructor TprimeMarkupBase.Create(p_SynEdit: TSynEditBase);
  2. begin
  3.   inherited Create(p_SynEdit);
  4. end;
  5.  
  6. destructor TprimeMarkupBase.Destroy;
  7. begin
  8.   Lines := nil;
  9.   inherited Destroy;
  10. end;
  11.  
  12. procedure TprimeMarkupBase.AddMark(p_Start, p_Finish: TPoint);
  13. var
  14.   r: TSynMarkupHighAllMatch;
  15. begin
  16.   r.StartPoint := p_Start;
  17.   r.EndPoint := p_Finish;
  18.   Matches[Matches.Count] := r;
  19. end;
  20.  
  21. procedure TprimeMarkupBase.ClearMarks;
  22. begin
  23.   Matches.Count := 0;
  24. end;
  25.  

Error class:
Code: Pascal  [Select][+][-]
  1.   { TprimeErrorMarkup }
  2.  
  3.   TprimeErrorMarkup = class(TprimeMarkupBase)
  4.   public
  5.     constructor Create(ASynEdit : TSynEditBase; AColor: TColor);
  6.   end;
  7.  
Code: Pascal  [Select][+][-]
  1. constructor TprimeErrorMarkup.Create(ASynEdit: TSynEditBase; AColor: TColor);
  2. begin
  3.   inherited Create(ASynEdit);
  4.   MarkupInfo.Clear;
  5.   MarkupInfo.FrameColor := AColor;
  6.   MarkupInfo.FrameEdges := sfeBottom;
  7.   MarkupInfo.FrameStyle := slsWaved;
  8.   MarkupInfo.FramePriority := 50;
  9.  
  10.   Markupinfo.Background := AColor;
  11.   Markupinfo.BackAlpha := 20;
  12.  
  13.   Matches.Capacity := 1000;
  14. end;
  15.  

Now you can add an instance of this markup to the Markupmanager of your Synedit and
use AddMark() to add a marks for your error.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

 

TinyPortal © 2005-2018