mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 09:20:49 +02:00
SynEdit: Fold at unit, implementation, program,...
git-svn-id: trunk@18025 -
This commit is contained in:
parent
8b165499cd
commit
45a82235cd
@ -98,7 +98,9 @@ type
|
||||
cfbtUses,
|
||||
cfbtVarType,
|
||||
cfbtClass,
|
||||
cfbtClassSection
|
||||
cfbtClassSection,
|
||||
cfbtUnitSection,
|
||||
cfbtProgram
|
||||
);
|
||||
TPascalCompilerMode = (
|
||||
pcmObjFPC,
|
||||
@ -758,8 +760,14 @@ begin
|
||||
EndCodeFoldBlock;
|
||||
if TopPascalCodeFoldBlockType = cfbtProcedure then
|
||||
EndCodeFoldBlock;
|
||||
if TopPascalCodeFoldBlockType = cfbtProgram then
|
||||
EndCodeFoldBlock;
|
||||
end
|
||||
else begin
|
||||
else if TopPascalCodeFoldBlockType = cfbtUnitSection then begin
|
||||
EndCodeFoldBlockLastLine;
|
||||
if TopPascalCodeFoldBlockType = cfbtBeginEnd then // "Unit".."end."
|
||||
EndCodeFoldBlock;
|
||||
end else begin
|
||||
if TopPascalCodeFoldBlockType = cfbtClassSection then
|
||||
EndCodeFoldBlock;
|
||||
if TopPascalCodeFoldBlockType = cfbtClass then
|
||||
@ -1001,7 +1009,10 @@ end;
|
||||
|
||||
function TSynPasSyn.Func64: TtkTokenKind;
|
||||
begin
|
||||
if KeyComp('Unit') then Result := tkKey
|
||||
if KeyComp('Unit') then begin
|
||||
if TopPascalCodeFoldBlockType=cfbtNone then StartPascalCodeFoldBlock(cfbtBeginEnd);
|
||||
Result := tkKey;
|
||||
end
|
||||
else if KeyComp('Uses') then begin
|
||||
if rsAfterSemicolon in fRange then begin
|
||||
if TopPascalCodeFoldBlockType=cfbtVarType then EndCodeFoldBlockLastLine;
|
||||
@ -1090,6 +1101,8 @@ begin
|
||||
if not(rsAfterEqual in fRange) and
|
||||
(fRange * [rsInterface, rsImplementation] = []) then begin
|
||||
if TopPascalCodeFoldBlockType=cfbtVarType then EndCodeFoldBlockLastLine;
|
||||
if TopPascalCodeFoldBlockType=cfbtUnitSection then EndCodeFoldBlockLastLine;
|
||||
StartPascalCodeFoldBlock(cfbtUnitSection);
|
||||
fRange := fRange + [rsInterface, rsAtSemicolon];
|
||||
// Interface has no ";", implicit end of statement
|
||||
end;
|
||||
@ -1126,6 +1139,7 @@ function TSynPasSyn.Func88: TtkTokenKind;
|
||||
begin
|
||||
if KeyComp('Program') then begin
|
||||
fRange := fRange - [rsInterface] + [rsImplementation];
|
||||
if TopPascalCodeFoldBlockType=cfbtNone then StartPascalCodeFoldBlock(cfbtProgram);
|
||||
Result := tkKey;
|
||||
end
|
||||
else Result := tkIdentifier;
|
||||
@ -1343,6 +1357,8 @@ begin
|
||||
if KeyComp('Finalization') then begin
|
||||
TSynPasSynRange(CodeFoldRange).BracketNestLevel := 0; // Reset in case of partial code
|
||||
if TopPascalCodeFoldBlockType=cfbtVarType then EndCodeFoldBlockLastLine;
|
||||
if TopPascalCodeFoldBlockType=cfbtUnitSection then EndCodeFoldBlockLastLine;
|
||||
StartPascalCodeFoldBlock(cfbtUnitSection);
|
||||
fRange := fRange - [rsInterface] + [rsImplementation, rsAtSemicolon];
|
||||
Result := tkKey
|
||||
end
|
||||
@ -1389,6 +1405,8 @@ begin
|
||||
if KeyComp('Implementation') then begin
|
||||
TSynPasSynRange(CodeFoldRange).BracketNestLevel := 0; // Reset in case of partial code
|
||||
if TopPascalCodeFoldBlockType=cfbtVarType then EndCodeFoldBlockLastLine;
|
||||
if TopPascalCodeFoldBlockType=cfbtUnitSection then EndCodeFoldBlockLastLine;
|
||||
StartPascalCodeFoldBlock(cfbtUnitSection);
|
||||
fRange := fRange - [rsInterface] + [rsImplementation, rsAtSemicolon];
|
||||
// implicit end of statement
|
||||
Result := tkKey;
|
||||
@ -1406,6 +1424,8 @@ begin
|
||||
if KeyComp('Initialization') then begin
|
||||
TSynPasSynRange(CodeFoldRange).BracketNestLevel := 0; // Reset in case of partial code
|
||||
if TopPascalCodeFoldBlockType=cfbtVarType then EndCodeFoldBlockLastLine;
|
||||
if TopPascalCodeFoldBlockType=cfbtUnitSection then EndCodeFoldBlockLastLine;
|
||||
StartPascalCodeFoldBlock(cfbtUnitSection);
|
||||
fRange := fRange - [rsInterface] + [rsImplementation, rsAtSemicolon];
|
||||
Result := tkKey;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user