mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 13:19:28 +02:00
SynEdit: allow saving of fold-state
git-svn-id: trunk@20655 -
This commit is contained in:
parent
6a8abe6f0f
commit
faf5069a69
@ -438,10 +438,12 @@ type
|
||||
|
||||
procedure AquirePrimarySelection;
|
||||
function GetDefSelectionMode: TSynSelectionMode;
|
||||
function GetFoldState: String;
|
||||
function GetUndoList: TSynEditUndoList;
|
||||
function GetDividerDrawLevel: Integer; deprecated;
|
||||
procedure SetDefSelectionMode(const AValue: TSynSelectionMode);
|
||||
procedure SetDividerDrawLevel(const AValue: Integer); deprecated;
|
||||
procedure SetFoldState(const AValue: String);
|
||||
procedure SetMouseActions(const AValue: TSynEditMouseActions);
|
||||
procedure SetMouseSelActions(const AValue: TSynEditMouseActions);
|
||||
procedure SurrenderPrimarySelection;
|
||||
@ -838,6 +840,7 @@ type
|
||||
public
|
||||
property BlockBegin: TPoint read GetBlockBegin write SetBlockBegin;
|
||||
property BlockEnd: TPoint read GetBlockEnd write SetBlockEnd;
|
||||
property FoldState: String read GetFoldState write SetFoldState;
|
||||
property CanPaste: Boolean read GetCanPaste;
|
||||
property CanRedo: boolean read GetCanRedo;
|
||||
property CanUndo: boolean read GetCanUndo;
|
||||
@ -1326,6 +1329,11 @@ begin
|
||||
Result := FBlockSelection.SelectionMode;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetFoldState: String;
|
||||
begin
|
||||
Result := FFoldedLinesView.GetFoldDescription(0, 0, -1, -1, True);
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetDividerDrawLevel: Integer;
|
||||
begin
|
||||
Result := fHighlighter.DrawDividerLevel;
|
||||
@ -3426,11 +3434,11 @@ var
|
||||
FTextDrawer.FrameEndX := -1;
|
||||
LastFSX := -1;
|
||||
LastFEX := -1;
|
||||
CharWidths := FFoldedLinesView.GetPhysicalCharWidths(CurLine);
|
||||
//CharWidths := FFoldedLinesView.GetPhysicalCharWidths(CurLine);
|
||||
CharWidths := FTheLinesView.GetPhysicalCharWidths(CurTextIndex);
|
||||
|
||||
fMarkupManager.PrepareMarkupForRow(FFoldedLinesView.TextIndex[CurLine]+1);
|
||||
fMarkupManager.PrepareMarkupForRow(CurTextIndex+1);
|
||||
// Get the line.
|
||||
sLine := FFoldedLinesView[CurLine];
|
||||
// Update the rcLine rect to this line.
|
||||
rcLine.Top := rcLine.Bottom;
|
||||
Inc(rcLine.Bottom, fTextHeight);
|
||||
@ -3449,6 +3457,7 @@ var
|
||||
ForceEto := False;
|
||||
|
||||
if not Assigned(fHighlighter) then begin
|
||||
sLine := FFoldedLinesView[CurLine];
|
||||
DrawHiLightMarkupToken(nil, PChar(Pointer(sLine)), Length(sLine));
|
||||
end else begin
|
||||
// draw splitter line
|
||||
@ -3486,7 +3495,7 @@ var
|
||||
// of the invalid area with the correct colors.
|
||||
PaintHighlightToken(TRUE);
|
||||
|
||||
fMarkupManager.FinishMarkupForRow(FFoldedLinesView.TextIndex[CurLine]+1);
|
||||
fMarkupManager.FinishMarkupForRow(CurTextIndex+1);
|
||||
end;
|
||||
CurLine:=-1;
|
||||
end;
|
||||
@ -4938,6 +4947,14 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetFoldState(const AValue: String);
|
||||
begin
|
||||
FFoldedLinesView.Lock;
|
||||
FFoldedLinesView.ApplyFoldDescription(0, 0, -1, -1, PChar(AValue), length(AValue), True);
|
||||
TopLine := TopLine; // Todo: reset topline on foldedview
|
||||
FFoldedLinesView.UnLock;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetMouseActions(const AValue: TSynEditMouseActions);
|
||||
begin
|
||||
if AValue = nil then
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -396,7 +396,7 @@ type
|
||||
procedure UnknownProc;
|
||||
procedure SetD4syntax(const Value: boolean);
|
||||
procedure InitNode(var Node: TSynFoldNodeInfo; EndOffs: Integer;
|
||||
ABlockType: TPascalCodeFoldBlockType);
|
||||
ABlockType: TPascalCodeFoldBlockType; aActions: TSynFoldActions);
|
||||
procedure CreateDividerDrawConfig;
|
||||
procedure DestroyDividerDrawConfig;
|
||||
procedure InitFoldConfig;
|
||||
@ -2676,8 +2676,8 @@ function TSynPasSyn.FoldTypeAtNodeIndex(ALineIndex, FoldIndex: Integer;
|
||||
var
|
||||
act: TSynFoldActions;
|
||||
begin
|
||||
act := [sfaOpen];
|
||||
if UseCloseNodes then act := [sfaClose];
|
||||
act := [sfaOpen, sfaFold];
|
||||
if UseCloseNodes then act := [sfaClose, sfaFold];
|
||||
case TPascalCodeFoldBlockType(PtrUInt(GetFoldNodeInfo(ALineIndex, FoldIndex, act).FoldType)) of
|
||||
cfbtRegion:
|
||||
Result := 2;
|
||||
@ -2820,7 +2820,7 @@ end;
|
||||
|
||||
|
||||
procedure TSynPasSyn.InitNode(var Node: TSynFoldNodeInfo; EndOffs: Integer;
|
||||
ABlockType: TPascalCodeFoldBlockType);
|
||||
ABlockType: TPascalCodeFoldBlockType; aActions: TSynFoldActions);
|
||||
var
|
||||
OneLine: Boolean;
|
||||
i: Integer;
|
||||
@ -2829,6 +2829,7 @@ begin
|
||||
Node.LogXStart := Run;
|
||||
Node.LogXEnd := Run + fStringLen;
|
||||
Node.FoldType := Pointer(PtrInt(ABlockType));
|
||||
Node.FoldAction := aActions;
|
||||
case ABlockType of
|
||||
cfbtRegion:
|
||||
begin
|
||||
@ -2862,13 +2863,11 @@ begin
|
||||
if i >= 0 then begin
|
||||
FNodeInfoList[i].FoldAction := FNodeInfoList[i].FoldAction
|
||||
- [sfaOpen, sfaFold] + [sfaOneLineOpen];
|
||||
Include(Node.FoldAction, sfaOneLineClose);
|
||||
Node.FoldAction := Node.FoldAction + [sfaOneLineClose] - [sfaClose, sfaFold];
|
||||
end;
|
||||
end;
|
||||
if ABlockType in PascalWordTrippletRanges then
|
||||
Node.FoldAction := [sfaMarkup]
|
||||
else
|
||||
Node.FoldAction := [];
|
||||
Include(Node.FoldAction, sfaMarkup);
|
||||
end;
|
||||
|
||||
procedure TSynPasSyn.StartCustomCodeFoldBlock(ABlockType: TPascalCodeFoldBlockType);
|
||||
@ -2876,9 +2875,7 @@ begin
|
||||
if not FFoldConfig[ABlockType] then exit;
|
||||
if FCatchNodeInfo then begin // exclude subblocks, because they do not increase the foldlevel yet
|
||||
GrowNodeInfoList;
|
||||
InitNode(FNodeInfoList[FNodeInfoCount], +1, ABlockType);
|
||||
FNodeInfoList[FNodeInfoCount].FoldAction :=
|
||||
FNodeInfoList[FNodeInfoCount].FoldAction + [sfaOpen, sfaFold];
|
||||
InitNode(FNodeInfoList[FNodeInfoCount], +1, ABlockType, [sfaOpen, sfaFold]);
|
||||
inc(FNodeInfoCount);
|
||||
end;
|
||||
case ABlockType of
|
||||
@ -2894,10 +2891,7 @@ begin
|
||||
if not FFoldConfig[ABlockType] then exit;
|
||||
if FCatchNodeInfo then begin // exclude subblocks, because they do not increase the foldlevel yet
|
||||
GrowNodeInfoList;
|
||||
InitNode(FNodeInfoList[FNodeInfoCount], -1, ABlockType);
|
||||
if not(sfaOneLineClose in FNodeInfoList[FNodeInfoCount].FoldAction) then
|
||||
FNodeInfoList[FNodeInfoCount].FoldAction :=
|
||||
FNodeInfoList[FNodeInfoCount].FoldAction + [sfaClose, sfaFold];
|
||||
InitNode(FNodeInfoList[FNodeInfoCount], -1, ABlockType, [sfaClose, sfaFold]);
|
||||
inc(FNodeInfoCount);
|
||||
end;
|
||||
case ABlockType of
|
||||
@ -2924,15 +2918,16 @@ function TSynPasSyn.StartPascalCodeFoldBlock(
|
||||
var
|
||||
p: PtrInt;
|
||||
FoldBlock: Boolean;
|
||||
act: TSynFoldActions;
|
||||
begin
|
||||
FoldBlock := FFoldConfig[ABlockType];
|
||||
p := 0;
|
||||
if FCatchNodeInfo then begin // exclude subblocks, because they do not increase the foldlevel yet
|
||||
GrowNodeInfoList;
|
||||
InitNode(FNodeInfoList[FNodeInfoCount], +1, ABlockType);
|
||||
act := [sfaOpen];
|
||||
if FoldBlock then
|
||||
include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaFold);
|
||||
include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaOpen);
|
||||
include(act, sfaFold);
|
||||
InitNode(FNodeInfoList[FNodeInfoCount], +1, ABlockType, act);
|
||||
inc(FNodeInfoCount);
|
||||
end;
|
||||
if not FoldBlock then
|
||||
@ -2944,18 +2939,17 @@ end;
|
||||
procedure TSynPasSyn.EndPascalCodeFoldBlock(NoMarkup: Boolean = False);
|
||||
var
|
||||
DecreaseLevel: Boolean;
|
||||
act: TSynFoldActions;
|
||||
begin
|
||||
DecreaseLevel := TopCodeFoldBlockType < CountPascalCodeFoldBlockOffset;
|
||||
if FCatchNodeInfo then begin // exclude subblocks, because they do not increase the foldlevel yet
|
||||
GrowNodeInfoList;
|
||||
InitNode(FNodeInfoList[FNodeInfoCount], -1, TopPascalCodeFoldBlockType);
|
||||
act := [sfaClose];
|
||||
if DecreaseLevel then
|
||||
include(act, sfaFold);
|
||||
InitNode(FNodeInfoList[FNodeInfoCount], -1, TopPascalCodeFoldBlockType, act);
|
||||
if NoMarkup then
|
||||
exclude(FNodeInfoList[FNodeInfoCount].FoldAction, sfaMarkup);
|
||||
if DecreaseLevel then
|
||||
if not(sfaOneLineClose in FNodeInfoList[FNodeInfoCount].FoldAction) then begin
|
||||
include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaFold);
|
||||
include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaClose);
|
||||
end;
|
||||
inc(FNodeInfoCount);
|
||||
end;
|
||||
EndCodeFoldBlock(DecreaseLevel);
|
||||
|
Loading…
Reference in New Issue
Block a user