procedure TSynPasSyn.DoInitNode(var Node: TSynFoldNodeInfo;
FinishingABlock: Boolean; ABlockType: Pointer; aActions: TSynFoldActions;
AIsFold: Boolean);
var
PasBlockType: TPascalCodeFoldBlockType;
EndOffs: Integer;
OneLine: Boolean;
begin
PasBlockType := TPascalCodeFoldBlockType(PtrUint(ABlockType));
if FinishingABlock then
EndOffs := -1
else
EndOffs := +1;
//inherited DoInitNode(Node, FinishingABlock, ABlockType, aActions, AIsFold);
aActions := aActions + [sfaMultiLine];
if (not FinishingABlock) and (ABlockType <> nil) then begin
if (PasBlockType in [cfbtIfThen,cfbtForDo,cfbtWhileDo,cfbtWithDo,cfbtIfElse]) then
//Include( aActions, sfaOutlineKeepLevelOnSameLine);
Include( aActions, sfaOutlineKeepLevel);
//if (PasBlockType in [cfbtIfElse]) then
// Include( aActions, sfaOutlineMergeLevelOnWrongCol);
if (PasBlockType in [cfbtClassSection]) then
Include( aActions, sfaOutlineMergeParent);
if (PasBlockType in [cfbtProcedure]) then
aActions := aActions + [sfaOutlineKeepLevel,sfaOutlineNoColor];
//if (PasBlockType in [cfbtProcedure]) and (InProcLevel > 0) then //nested
// aActions := aActions + [sfaOutlineForceIndent];
if (PasBlockType in [cfbtExcept]) then
Include( aActions, sfaOutlineMergeParent);
// if (PasBlockType in [cfbtIfThen, cfbtClass,cfbtRecord]) then
// aActions := aActions + [sfaOutlineNoLine];
end;
Node.LineIndex := LineIndex;
Node.LogXStart := Run;
Node.LogXEnd := Run + fStringLen;
Node.FoldType := Pointer({%H-}PtrInt(ABlockType)); //Pointer(PtrUInt(PasBlockType));
Node.FoldTypeCompatible := Pointer(PtrUInt(PascalFoldTypeCompatibility[PasBlockType]));
Node.FoldAction := aActions;
case PasBlockType of
cfbtRegion:
begin
node.FoldGroup := FOLDGROUP_REGION;
if AIsFold then
Node.FoldLvlStart := FSynPasRangeInfo.EndLevelRegion
else
Node.FoldLvlStart := 0;
Node.NestLvlStart := FSynPasRangeInfo.EndLevelRegion;
OneLine := FinishingABlock and (Node.FoldLvlStart > FSynPasRangeInfo.MinLevelRegion);
end;
cfbtIfDef:
begin
node.FoldGroup := FOLDGROUP_IFDEF;
if AIsFold then
Node.FoldLvlStart := FSynPasRangeInfo.EndLevelIfDef
else
Node.FoldLvlStart := 0;
Node.NestLvlStart := FSynPasRangeInfo.EndLevelIfDef;
OneLine := FinishingABlock and (Node.FoldLvlStart > FSynPasRangeInfo.MinLevelIfDef);
end;
else
begin
//inherited DoInitNode(Node, FinishingABlock, ABlockType, aActions, AIsFold);
node.FoldGroup := FOLDGROUP_PASCAL;
if AIsFold then begin
Node.FoldLvlStart := PasCodeFoldRange.CodeFoldStackSize;
Node.NestLvlStart := PasCodeFoldRange.NestFoldStackSize;
OneLine := FinishingABlock and (Node.FoldLvlStart > PasCodeFoldRange.MinimumCodeFoldBlockLevel); // MinimumCodeFoldBlockLevel);
end else begin
Node.FoldLvlStart := PasCodeFoldRange.NestFoldStackSize; // CodeFoldStackSize; ? but fails test // Todo: zero?
Node.NestLvlStart := PasCodeFoldRange.NestFoldStackSize;
OneLine := FinishingABlock and (Node.NestLvlStart > PasCodeFoldRange.MinimumNestFoldBlockLevel); // MinimumCodeFoldBlockLevel);
end;
end;
end;
Node.NestLvlEnd := Node.NestLvlStart + EndOffs;
if not (sfaFold in aActions) then
EndOffs := 0;
Node.FoldLvlEnd := Node.FoldLvlStart + EndOffs;
if OneLine then // find opening node
RepairSingleLineNode(Node);
end;