fixed & re-activated custom folded region

This commit is contained in:
Basile Burg 2015-02-06 21:18:46 +01:00
parent 294994dfc5
commit efd84ef8a5
1 changed files with 22 additions and 12 deletions

View File

@ -72,11 +72,12 @@ type
TRangeKinds = set of TRangeKind; TRangeKinds = set of TRangeKind;
// defines the ranges which can be folded // defines the ranges which can be folded
TFoldKinds = set of (fkBrackets, fkComments1, fkComments2, fkStrings); TFoldKinds = set of (fkBrackets, fkComments1, fkComments2, fkStrings, fkRegion);
// internal class used to keep trace of the useful informations of the previous line // internal class used to keep trace of the useful informations of the previous line
TSynD2SynRange = class(TSynCustomHighlighterRange) TSynD2SynRange = class(TSynCustomHighlighterRange)
private private
namedRegionCount: Integer;
nestedCommentsCount: Integer; nestedCommentsCount: Integer;
tokenStringBracketsCount: Integer; tokenStringBracketsCount: Integer;
rangeKinds: TRangeKinds; rangeKinds: TRangeKinds;
@ -218,6 +219,7 @@ begin
rangeKinds := src_t.rangeKinds; rangeKinds := src_t.rangeKinds;
nestedCommentsCount := src_t.nestedCommentsCount; nestedCommentsCount := src_t.nestedCommentsCount;
tokenStringBracketsCount := src_t.tokenStringBracketsCount; tokenStringBracketsCount := src_t.tokenStringBracketsCount;
namedRegionCount := src_t.namedRegionCount;
end; end;
end; end;
@ -235,6 +237,7 @@ begin
if src_t.nestedCommentsCount <> nestedCommentsCount then exit(1); if src_t.nestedCommentsCount <> nestedCommentsCount then exit(1);
if src_t.tokenStringBracketsCount <> tokenStringBracketsCount then exit(1); if src_t.tokenStringBracketsCount <> tokenStringBracketsCount then exit(1);
if src_t.rString <> rString then exit(1); if src_t.rString <> rString then exit(1);
if src_t.namedRegionCount <> namedRegionCount then exit(1);
exit(0); exit(0);
end; end;
end; end;
@ -243,6 +246,7 @@ procedure TSynD2SynRange.Clear;
begin begin
inherited; inherited;
nestedCommentsCount := 0; nestedCommentsCount := 0;
namedRegionCount := 0;
tokenStringBracketsCount := 0; tokenStringBracketsCount := 0;
rangeKinds := []; rangeKinds := [];
rString := false; rString := false;
@ -473,23 +477,29 @@ begin
exit; exit;
end; end;
// line comment // line comment / region beg-end
if (fCurrRange.rangeKinds = []) or (fCurrRange.rangeKinds = [rkAsm]) then if readDelim(reader, fTokStop, '//') then if (fCurrRange.rangeKinds = []) or (fCurrRange.rangeKinds = [rkAsm]) then if readDelim(reader, fTokStop, '//') then
begin begin
fTokKind := tkCommt; fTokKind := tkCommt;
if readDelim(reader, fTokStop, '/') then if readDelim(reader, fTokStop, '/') then
fTokKind := tkDDocs; fTokKind := tkDDocs;
readLine(reader, fTokStop); readLine(reader, fTokStop);
//if fTokStop - fTokStart > 4 then if (fkRegion in fFoldKinds) and (fTokStop - fTokStart > 4) then
//begin begin
// Dec(reader,4); Dec(reader,4);
// Dec(fTokStop,4); Dec(fTokStop,4);
// if reader = '---+'#10 then if reader = '---+'#10 then
// StartCodeFoldBlock(nil) begin
// else if reader = '----'#10 then fCurrRange.namedRegionCount += 1;
// EndCodeFoldBlock(); StartCodeFoldBlock(nil);
// readLine(reader, fTokStop); end
//end; else if (reader = '----'#10) and (fCurrRange.namedRegionCount > 0) then
begin
EndCodeFoldBlock();
fCurrRange.namedRegionCount -= 1;
end;
readLine(reader, fTokStop);
end;
exit; exit;
end else readerReset; end else readerReset;