mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 05:40:48 +02:00
SynEdit: add Interface to Markup classes
git-svn-id: trunk@18072 -
This commit is contained in:
parent
6e84e44ae3
commit
99066aee96
@ -147,6 +147,7 @@ const
|
||||
{$ENDIF}
|
||||
|
||||
type
|
||||
TSynEditMarkupClass = SynEditMarkup.TSynEditMarkupClass;
|
||||
TSynReplaceAction = (raCancel, raSkip, raReplace, raReplaceAll);
|
||||
|
||||
ESynEditError = class(Exception);
|
||||
@ -464,12 +465,13 @@ type
|
||||
function GetCanUndo: Boolean;
|
||||
function GetCaretXY: TPoint;
|
||||
function GetFont: TFont;
|
||||
function GetMarkup(Index: integer): TSynEditMarkup;
|
||||
function GetMarkupByClass(Index: TSynEditMarkupClass): TSynEditMarkup;
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
function GetCaretX : Integer;
|
||||
function GetCaretY : Integer;
|
||||
function GetHighlightAllColor : TSynSelectedColor;
|
||||
function GetHighlightCaretColor: TSynSelectedColor;
|
||||
function GetHighlightCaretTime: integer;
|
||||
function GetIncrementColor : TSynSelectedColor;
|
||||
function GetLineHighlightColor: TSynSelectedColor;
|
||||
function GetLineNumberColor: TSynSelectedColor;
|
||||
@ -481,7 +483,6 @@ type
|
||||
function GetMouseLinkColor : TSynSelectedColor;
|
||||
procedure SetBracketHighlightStyle(
|
||||
const AValue: TSynEditBracketHighlightStyle);
|
||||
procedure SetHighlightCaretTime(const AValue: integer);
|
||||
procedure SetOnGutterClick(const AValue : TGutterClickEvent);
|
||||
procedure SetRealLines(const AValue : TStrings);
|
||||
procedure SetSelectedColor(const AValue : TSynSelectedColor);
|
||||
@ -898,6 +899,11 @@ type
|
||||
property OnKeyPress;
|
||||
property OnProcessCommand: TProcessCommandEvent
|
||||
read FOnProcessCommand write FOnProcessCommand;
|
||||
function MarkupCount: Integer;
|
||||
property Markup[Index: integer]: TSynEditMarkup
|
||||
read GetMarkup;
|
||||
property MarkupByClass[Index: TSynEditMarkupClass]: TSynEditMarkup
|
||||
read GetMarkupByClass;
|
||||
protected
|
||||
property BookMarkOptions: TSynBookMarkOpt
|
||||
read fBookMarkOpt write fBookMarkOpt;
|
||||
@ -939,7 +945,6 @@ type
|
||||
property IncrementColor: TSynSelectedColor read GetIncrementColor;
|
||||
property HighlightAllColor: TSynSelectedColor read GetHighlightAllColor;
|
||||
property HighlightCaretColor: TSynSelectedColor read GetHighlightCaretColor;
|
||||
property HighlightCaretTime: integer read GetHighlightCaretTime write SetHighlightCaretTime;
|
||||
property BracketMatchColor: TSynSelectedColor read GetBracketMatchColor;
|
||||
property MouseLinkColor: TSynSelectedColor read GetMouseLinkColor;
|
||||
property LineNumberColor: TSynSelectedColor read GetLineNumberColor;
|
||||
@ -1724,6 +1729,11 @@ begin
|
||||
Result := FCaret.LineText;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetMarkupByClass(Index: TSynEditMarkupClass): TSynEditMarkup;
|
||||
begin
|
||||
Result := fMarkupManager.MarkupByClass[Index];
|
||||
end;
|
||||
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
function TCustomSynEdit.GetHighlightAllColor : TSynSelectedColor;
|
||||
begin
|
||||
@ -1735,11 +1745,6 @@ begin
|
||||
result := fMarkupHighCaret.MarkupInfo;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetHighlightCaretTime: integer;
|
||||
begin
|
||||
Result := fMarkupHighCaret.WaitTime;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetIncrementColor : TSynSelectedColor;
|
||||
begin
|
||||
result := fMarkupSelection.MarkupInfoIncr;
|
||||
@ -1803,11 +1808,6 @@ begin
|
||||
fMarkupBracket.HighlightStyle := AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetHighlightCaretTime(const AValue: integer);
|
||||
begin
|
||||
FMarkupHighCaret.WaitTime := AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetOnGutterClick(const AValue : TGutterClickEvent);
|
||||
begin
|
||||
fGutter.OnGutterClick := AValue;
|
||||
@ -3993,6 +3993,11 @@ begin
|
||||
inherited Invalidate;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.MarkupCount: Integer;
|
||||
begin
|
||||
Result := FMarkupManager.Count;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.PasteFromClipboard;
|
||||
var
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
@ -4131,6 +4136,11 @@ begin
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function TCustomSynEdit.GetMarkup(Index: integer): TSynEditMarkup;
|
||||
begin
|
||||
Result := fMarkupManager.Markup[Index];
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetCaretX(Value: Integer);
|
||||
begin
|
||||
SetCaretXY(Point(Value, CaretY));
|
||||
|
@ -33,6 +33,8 @@ type
|
||||
TInvalidateLines = procedure(FirstLine, LastLine: integer) of Object;
|
||||
|
||||
type
|
||||
TSynEditMarkupClass = class of TSynEditMarkup;
|
||||
|
||||
{ TSynEditMarkup }
|
||||
|
||||
TSynEditMarkup = class(TObject)
|
||||
@ -43,12 +45,14 @@ type
|
||||
fTopLine, FLinesInWindow : Integer;
|
||||
fSynEdit : TCustomControl;
|
||||
fInvalidateLinesMethod : TInvalidateLines;
|
||||
FEnabled: Boolean;
|
||||
|
||||
function GetBGColor : TColor;
|
||||
function GetFGColor : TColor;
|
||||
function GetFrameColor: TColor;
|
||||
function GetStyle : TFontStyles;
|
||||
procedure SetBGColor(const AValue : TColor);
|
||||
procedure SetEnabled(const AValue: Boolean);
|
||||
procedure SetFGColor(const AValue : TColor);
|
||||
procedure SetFrameColor(const AValue : TColor);
|
||||
procedure SetStyle(const AValue : TFontStyles);
|
||||
@ -91,6 +95,7 @@ type
|
||||
property BGColor : TColor read GetBGColor;
|
||||
property FrameColor: TColor read GetFrameColor;
|
||||
property Style : TFontStyles read GetStyle;
|
||||
property Enabled: Boolean read FEnabled write SetEnabled;
|
||||
property Lines : TSynEditStrings read fLines write SetLines;
|
||||
property Caret : TPoint read fCaret write SetCaret;
|
||||
property TopLine : Integer read fTopLine write SetTopLine;
|
||||
@ -103,6 +108,8 @@ type
|
||||
TSynEditMarkupManager = class(TSynEditMarkup) { TODO: Forward onchange calls to all others }
|
||||
private
|
||||
fMarkUpList : TList;
|
||||
function GetMarkup(Index: integer): TSynEditMarkup;
|
||||
function GetMarkupByClass(Index: TSynEditMarkupClass): TSynEditMarkup;
|
||||
|
||||
protected
|
||||
procedure SetInvalidateLinesMethod(const AValue : TInvalidateLines); override;
|
||||
@ -115,6 +122,11 @@ type
|
||||
destructor Destroy; override;
|
||||
|
||||
Procedure AddMarkUp(aMarkUp : TSynEditMarkup);
|
||||
function Count: Integer;
|
||||
property Markup[Index: integer]: TSynEditMarkup
|
||||
read GetMarkup;
|
||||
property MarkupByClass[Index: TSynEditMarkupClass]: TSynEditMarkup
|
||||
read GetMarkupByClass;
|
||||
|
||||
Procedure PrepareMarkupForRow(aRow : Integer); override;
|
||||
Procedure FinishMarkupForRow(aRow : Integer); override;
|
||||
@ -160,6 +172,12 @@ begin
|
||||
fMarkupInfo.Background := AValue;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkup.SetEnabled(const AValue: Boolean);
|
||||
begin
|
||||
if AValue = FEnabled then exit;
|
||||
FEnabled := AValue;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkup.SetFGColor(const AValue : TColor);
|
||||
begin
|
||||
if fMarkupInfo.Foreground = AValue then exit;
|
||||
@ -325,12 +343,18 @@ begin
|
||||
fMarkUpList.Add(aMarkUp);
|
||||
end;
|
||||
|
||||
function TSynEditMarkupManager.Count: Integer;
|
||||
begin
|
||||
Result := fMarkUpList.Count;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupManager.FinishMarkupForRow(aRow : Integer);
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
for i := 0 to fMarkUpList.Count-1 do
|
||||
TSynEditMarkup(fMarkUpList[i]).FinishMarkupForRow(aRow);
|
||||
if TSynEditMarkup(fMarkUpList[i]).Enabled then
|
||||
TSynEditMarkup(fMarkUpList[i]).FinishMarkupForRow(aRow);
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupManager.EndMarkup;
|
||||
@ -338,7 +362,8 @@ var
|
||||
i : integer;
|
||||
begin
|
||||
for i := 0 to fMarkUpList.Count-1 do
|
||||
TSynEditMarkup(fMarkUpList[i]).EndMarkup;
|
||||
if TSynEditMarkup(fMarkUpList[i]).Enabled then
|
||||
TSynEditMarkup(fMarkUpList[i]).EndMarkup;
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupManager.PrepareMarkupForRow(aRow : Integer);
|
||||
@ -346,7 +371,8 @@ var
|
||||
i : integer;
|
||||
begin
|
||||
for i := 0 to fMarkUpList.Count-1 do
|
||||
TSynEditMarkup(fMarkUpList[i]).PrepareMarkupForRow(aRow);
|
||||
if TSynEditMarkup(fMarkUpList[i]).Enabled then
|
||||
TSynEditMarkup(fMarkUpList[i]).PrepareMarkupForRow(aRow);
|
||||
end;
|
||||
|
||||
function TSynEditMarkupManager.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
|
||||
@ -358,6 +384,7 @@ begin
|
||||
Result := nil;
|
||||
|
||||
for i := 0 to fMarkUpList.Count-1 do begin
|
||||
if not TSynEditMarkup(fMarkUpList[i]).Enabled then continue;
|
||||
c := TSynEditMarkup(fMarkUpList[i]).GetMarkupAttributeAtRowCol(aRow, aCol);
|
||||
if assigned(c) then begin
|
||||
if not Assigned(Result) then begin
|
||||
@ -388,6 +415,7 @@ begin
|
||||
then exit(-1);
|
||||
Result := TSynEditMarkup(fMarkUpList[0]).GetNextMarkupColAfterRowCol(aRow, aCol);
|
||||
for i := 1 to fMarkUpList.Count-1 do begin
|
||||
if not TSynEditMarkup(fMarkUpList[i]).Enabled then continue;
|
||||
j := TSynEditMarkup(fMarkUpList[i]).GetNextMarkupColAfterRowCol(aRow, aCol);
|
||||
if ((j>0) and (j < Result)) or (Result<0) then Result := j;
|
||||
end;
|
||||
@ -406,6 +434,21 @@ begin
|
||||
TSynEditMarkup(fMarkUpList[i]).TextChanged(aFirstCodeLine, aLastCodeLine);
|
||||
end;
|
||||
|
||||
function TSynEditMarkupManager.GetMarkup(Index: integer): TSynEditMarkup;
|
||||
begin
|
||||
Result := TSynEditMarkup(fMarkUpList[Index]);
|
||||
end;
|
||||
|
||||
function TSynEditMarkupManager.GetMarkupByClass(Index: TSynEditMarkupClass): TSynEditMarkup;
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
Result := nil;
|
||||
for i := 0 to fMarkUpList.Count-1 do
|
||||
if TSynEditMarkup(fMarkUpList[i]).ClassType = Index then
|
||||
exit(TSynEditMarkup(fMarkUpList[i]));
|
||||
end;
|
||||
|
||||
procedure TSynEditMarkupManager.SetInvalidateLinesMethod(const AValue : TInvalidateLines);
|
||||
var
|
||||
i : integer;
|
||||
|
Loading…
Reference in New Issue
Block a user