synedit: format code a bit before actual changes

git-svn-id: trunk@17520 -
This commit is contained in:
paul 2008-11-22 16:05:59 +00:00
parent 26cb90f023
commit 77626ad67a

View File

@ -39,64 +39,68 @@ type
TSynEditMarkupSpecialLine = class(TSynEditMarkup) TSynEditMarkupSpecialLine = class(TSynEditMarkup)
private private
fOnSpecialLineColors : TSpecialLineColorsEvent; FOnSpecialLineColors: TSpecialLineColorsEvent;
fOnSpecialLineMarkup : TSpecialLineMarkupEvent; FOnSpecialLineMarkup: TSpecialLineMarkupEvent;
bSpecialLine : Boolean; FSpecialLine : Boolean;
public public
constructor Create(ASynEdit : TCustomControl); constructor Create(ASynEdit: TCustomControl);
Procedure PrepareMarkupForRow(aRow : Integer); override; procedure PrepareMarkupForRow(ARow: Integer); override;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override; function GetMarkupAttributeAtRowCol(const ARow, ACol: Integer): TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override; function GetNextMarkupColAfterRowCol(const ARow, ACol: Integer): Integer; override;
property OnSpecialLineColors: TSpecialLineColorsEvent property OnSpecialLineColors: TSpecialLineColorsEvent
read fOnSpecialLineColors write fOnSpecialLineColors; read FOnSpecialLineColors write FOnSpecialLineColors;
property OnSpecialLineMarkup: TSpecialLineMarkupEvent property OnSpecialLineMarkup: TSpecialLineMarkupEvent
read fOnSpecialLineMarkup write fOnSpecialLineMarkup; read FOnSpecialLineMarkup write FOnSpecialLineMarkup;
end; end;
implementation implementation
{ TSynEditMarkupBracket } { TSynEditMarkupBracket }
constructor TSynEditMarkupSpecialLine.Create(ASynEdit : TCustomControl); constructor TSynEditMarkupSpecialLine.Create(ASynEdit: TCustomControl);
begin begin
inherited Create(ASynEdit); inherited Create(ASynEdit);
MarkupInfo.Style := []; MarkupInfo.Style := [];
MarkupInfo.StyleMask := []; MarkupInfo.StyleMask := [];
end; end;
procedure TSynEditMarkupSpecialLine.PrepareMarkupForRow(aRow : Integer); procedure TSynEditMarkupSpecialLine.PrepareMarkupForRow(ARow: Integer);
var var
colFg, colBg : TColor; colFg, colBg: TColor;
begin begin
bSpecialLine := False; FSpecialLine := False;
if Assigned(fOnSpecialLineMarkup) then if Assigned(FOnSpecialLineMarkup) then
fOnSpecialLineMarkup(SynEdit, aRow, bSpecialLine, MarkupInfo); FOnSpecialLineMarkup(SynEdit, ARow, FSpecialLine, MarkupInfo);
if Assigned(fOnSpecialLineColors) then begin if Assigned(FOnSpecialLineColors) then
If bSpecialLine then begin begin
if FSpecialLine then
begin
colFg := MarkupInfo.Foreground; colFg := MarkupInfo.Foreground;
colBg := MarkupInfo.Background; colBg := MarkupInfo.Background;
end else begin end else
begin
colFg := clNone; colFg := clNone;
colBg := clNone; colBg := clNone;
end; end;
fOnSpecialLineColors(SynEdit, aRow, bSpecialLine, colFg, colBg); FOnSpecialLineColors(SynEdit, ARow, FSpecialLine, colFg, colBg);
MarkupInfo.Foreground := colFg; MarkupInfo.Foreground := colFg;
MarkupInfo.Background := colBg; MarkupInfo.Background := colBg;
end; end;
end; end;
function TSynEditMarkupSpecialLine.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; function TSynEditMarkupSpecialLine.GetMarkupAttributeAtRowCol(const ARow, ACol : Integer): TSynSelectedColor;
begin begin
Result := nil; Result := nil;
if bSpecialLine then result := MarkupInfo; if FSpecialLine then
Result := MarkupInfo;
end; end;
function TSynEditMarkupSpecialLine.GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; function TSynEditMarkupSpecialLine.GetNextMarkupColAfterRowCol(const ARow, ACol : Integer): Integer;
begin begin
result := -1; // always valid for the whole line Result := -1; // always valid for the whole line
end; end;
end. end.