unit UMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SynEditHighlighter, SynHighlighterPas, SynEditCodeFolding, SynEdit;
type
TForm1 =
class(TForm)
Editor: TSynEdit;
HighlighterPas: TSynPasSyn;
OpenDialog: TOpenDialog;
btnOpen: TButton;
procedure btnOpenClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure EditorChange(Sender: TObject);
private
{ Private-Deklarationen }
FFilename:
String;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnOpenClick(Sender: TObject);
begin
if OpenDialog.Execute
then
begin
FFilename := OpenDialog.FileName;
Editor.Lines.LoadFromFile(FFilename);
Editor.InitCodeFolding;
Editor.Repaint;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Editor.CodeFolding.Enabled := True;
Editor.CodeFolding.FolderBarColor := clWindow;
Editor.CodeFolding.FolderBarLinesColor := clGray;
Editor.CodeFolding.CollapsedLineColor := clBtnFace;
Editor.CodeFolding.HighlighterFoldRegions := True;
Editor.CodeFolding.IndentGuides := True;
Editor.CodeFolding.ShowCollapsedLine := True;
Editor.CodeFolding.CollapsedCodeHint := True;
Editor.CodeFolding.FoldRegions. Add(rtKeyWord, False, False, True, '
begin', '
end');
//In OnChange von Synedit -> Editor.ReScanForFoldRanges;
end;
procedure TForm1.EditorChange(Sender: TObject);
begin
Editor.ReScanForFoldRanges;
end;
end.