mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:59:08 +02:00
SynEdit: add FoldProvider.Enabled
git-svn-id: trunk@63295 -
This commit is contained in:
parent
680762bdbf
commit
30c89b1f2f
@ -295,6 +295,7 @@ type
|
|||||||
|
|
||||||
TSynEditFoldProvider = class
|
TSynEditFoldProvider = class
|
||||||
private
|
private
|
||||||
|
FEnabled: boolean;
|
||||||
FHighlighter: TSynCustomFoldHighlighter;
|
FHighlighter: TSynCustomFoldHighlighter;
|
||||||
FLines : TSynEditStrings;
|
FLines : TSynEditStrings;
|
||||||
FSelection: TSynEditSelection;
|
FSelection: TSynEditSelection;
|
||||||
@ -309,7 +310,7 @@ type
|
|||||||
protected
|
protected
|
||||||
property HighLighterWithLines: TSynCustomFoldHighlighter read GetHighLighterWithLines;
|
property HighLighterWithLines: TSynCustomFoldHighlighter read GetHighLighterWithLines;
|
||||||
public
|
public
|
||||||
//constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
// Info about Folds opening on ALineIdx
|
// Info about Folds opening on ALineIdx
|
||||||
@ -331,6 +332,7 @@ type
|
|||||||
property HighLighter: TSynCustomFoldHighlighter read FHighlighter write SetHighLighter;
|
property HighLighter: TSynCustomFoldHighlighter read FHighlighter write SetHighLighter;
|
||||||
property FoldsAvailable: Boolean read GetFoldsAvailable;
|
property FoldsAvailable: Boolean read GetFoldsAvailable;
|
||||||
property NestedFoldsList: TLazSynEditNestedFoldsList read GetNestedFoldsList;
|
property NestedFoldsList: TLazSynEditNestedFoldsList read GetNestedFoldsList;
|
||||||
|
property Enabled: boolean read FEnabled write FEnabled;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFoldChangedHandlerList }
|
{ TFoldChangedHandlerList }
|
||||||
@ -2887,6 +2889,8 @@ var
|
|||||||
c: Integer;
|
c: Integer;
|
||||||
begin
|
begin
|
||||||
Result := [];
|
Result := [];
|
||||||
|
if not FEnabled then
|
||||||
|
exit;
|
||||||
if (FSelection <> nil) and (FSelection.SelAvail) then begin
|
if (FSelection <> nil) and (FSelection.SelAvail) then begin
|
||||||
if (FSelection.FirstLineBytePos.Y < ALineIdx+1) and
|
if (FSelection.FirstLineBytePos.Y < ALineIdx+1) and
|
||||||
(FSelection.LastLineBytePos.Y > ALineIdx+1)
|
(FSelection.LastLineBytePos.Y > ALineIdx+1)
|
||||||
@ -2936,8 +2940,10 @@ end;
|
|||||||
|
|
||||||
function TSynEditFoldProvider.GetFoldsAvailable: Boolean;
|
function TSynEditFoldProvider.GetFoldsAvailable: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := (FHighlighter <> nil) or
|
Result := FEnabled and (
|
||||||
((FSelection <> nil) and FSelection.SelAvail);
|
(FHighlighter <> nil) or
|
||||||
|
((FSelection <> nil) and FSelection.SelAvail)
|
||||||
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynEditFoldProvider.GetHighLighterWithLines: TSynCustomFoldHighlighter;
|
function TSynEditFoldProvider.GetHighLighterWithLines: TSynCustomFoldHighlighter;
|
||||||
@ -2963,6 +2969,12 @@ begin
|
|||||||
FNestedFoldsList.Lines := FLines;
|
FNestedFoldsList.Lines := FLines;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
constructor TSynEditFoldProvider.Create;
|
||||||
|
begin
|
||||||
|
FEnabled := True;
|
||||||
|
inherited Create;
|
||||||
|
end;
|
||||||
|
|
||||||
destructor TSynEditFoldProvider.Destroy;
|
destructor TSynEditFoldProvider.Destroy;
|
||||||
begin
|
begin
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
@ -2971,6 +2983,9 @@ end;
|
|||||||
|
|
||||||
function TSynEditFoldProvider.FoldOpenCount(ALineIdx: Integer; AType: Integer = 0): Integer;
|
function TSynEditFoldProvider.FoldOpenCount(ALineIdx: Integer; AType: Integer = 0): Integer;
|
||||||
begin
|
begin
|
||||||
|
if not FEnabled then
|
||||||
|
exit(0);
|
||||||
|
|
||||||
if (FHighlighter = nil) or (ALineIdx < 0) then begin
|
if (FHighlighter = nil) or (ALineIdx < 0) then begin
|
||||||
if (AType=0) and (FSelection <> nil) and FSelection.SelAvail and (FSelection.FirstLineBytePos.Y=ALineIdx+1) then exit(1);
|
if (AType=0) and (FSelection <> nil) and FSelection.SelAvail and (FSelection.FirstLineBytePos.Y=ALineIdx+1) then exit(1);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user