Recent

Author Topic: How enabling SynEditMarkupIfDef?  (Read 2623 times)

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
How enabling SynEditMarkupIfDef?
« on: December 31, 2015, 07:30:15 am »
is there a simple demo for enabling TSynEditMarkupIfDef?


I want to blend one of two {$ifdef} ~ {$else}
Below is the code. I do this, but don't know what next step to play with ..



 
Code: Pascal  [Select][+][-]
  1.  
  2.   TForm1 = class(TForm)
  3.     CheckBox1: TCheckBox;
  4.     Panel1: TPanel;
  5.     StatusBar1: TStatusBar;
  6.     SynEdit1: TSynEdit;
  7.     SynPasSyn1: TSynPasSyn;
  8.     procedure FormCreate(Sender: TObject);
  9.   private
  10.     { private declarations }
  11.     FMI : TSynEditMarkupIfDef;
  12.   public
  13.     { public declarations }
  14.   end;
  15.  
  16.  
  17. var
  18.   Form1: TForm1;
  19.  
  20.  
  21. implementation
  22.  
  23.  
  24. {$R *.lfm}
  25. type
  26.   TSEhack = class(TSynEdit);
  27. { TForm1 }
  28.  
  29.  
  30. procedure TForm1.FormCreate(Sender: TObject);
  31. begin
  32.   FMI := TSynEditMarkupIfDef.Create(Self.SynEdit1);
  33.  // FMi.FoldView := TSynEditFoldedView( TSEhack(SynEdit1).FoldedTextBuffer);
  34.   Self.SynEdit1.MarkupManager.AddMarkUp(FMi);
  35.   FMi.Highlighter := self.SynPasSyn1;
  36.   FMi.MarkupInfoDisabled.ForeAlpha:=128;
  37.   FMI.MarkupInfoDisabled.Foreground:= clSilver;
  38. end;
  39.  
  40.  
  41. end.      


my code to test with SynMarkupIfDef is :
Code: Pascal  [Select][+][-]
  1. function TSynPasSyn.StartPascalCodeFoldBlock(ABlockType: TPascalCodeFoldBlockType;
  2.   OnlyEnabled: Boolean): TSynCustomCodeFoldBlock;
  3. var
  4.   p: PtrInt;
  5.   FoldBlock, BlockEnabled: Boolean;
  6.   act: TSynFoldActions;
  7.   nd: TSynFoldNodeInfo;
  8. begin
  9.   BlockEnabled := FFoldConfig[ord(ABlockType)].Enabled;
  10.   if (not BlockEnabled) and OnlyEnabled then
  11.     exit(nil);
  12.   FoldBlock := BlockEnabled and (FFoldConfig[ord(ABlockType)].Modes * [fmFold, fmHide] <> []);
  13.   p := 0;
  14.  
  15.  
  16.   if not FoldBlock then
  17.     p := PtrInt(CountPascalCodeFoldBlockOffset);
  18.   {$ifdef PASFOLD}
  19.   Result:=TSynCustomCodeFoldBlock(StartCodeFoldBlock(p+Pointer(PtrInt(ABlockType)), FoldBlock));
  20.   {$else}
  21.   Result:=TSynCustomCodeFoldBlock(StartCodeFoldBlock(p+Pointer(PtrInt(ABlockType)), FoldBlock));
  22.   {$endif}
  23.   InIfdefProcsMade := Min(InIfdefProcsMade +1,255);
  24. end;  


help !
« Last Edit: December 31, 2015, 08:20:13 am by x2nie »
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: How enabling SynEditMarkupIfDef?
« Reply #1 on: December 31, 2015, 07:50:49 am »
Here is my application.


How can I enable the blended color or $IFDEF in my application to be similar of what Lazarus did?
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10829
  • Debugger - SynEdit - and more
    • wiki
Re: How enabling SynEditMarkupIfDef?
« Reply #2 on: December 31, 2015, 09:09:24 am »
the ifdef markup does not compute what is active and what not (it can not do that, as it does not know which param will be passed to fpc)

you need to tell it about each ifdef node, and if it is active or not. search ide/sourceeditor.pp
In the IDE the info comes from  codetools

 

TinyPortal © 2005-2018