mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 09:39:06 +02:00
SynEdit: jscript highlighter, added FAtLineStart for hide-fold action
git-svn-id: trunk@52177 -
This commit is contained in:
parent
958c6dc9b7
commit
7f8685674a
@ -76,6 +76,7 @@ type
|
|||||||
TSynJScriptSyn = class(TSynCustomFoldHighlighter{TSynCustomHighLighter})
|
TSynJScriptSyn = class(TSynCustomFoldHighlighter{TSynCustomHighLighter})
|
||||||
private
|
private
|
||||||
FBracketAttri: TSynHighlighterAttributes;
|
FBracketAttri: TSynHighlighterAttributes;
|
||||||
|
FAtLineStart: Boolean;
|
||||||
fRange: TRangeState;
|
fRange: TRangeState;
|
||||||
fLine: PChar;
|
fLine: PChar;
|
||||||
fLineNumber: Integer;
|
fLineNumber: Integer;
|
||||||
@ -1560,6 +1561,7 @@ begin
|
|||||||
fLine := PChar(NewValue);
|
fLine := PChar(NewValue);
|
||||||
Run := 0;
|
Run := 0;
|
||||||
fLineNumber := LineNumber;
|
fLineNumber := LineNumber;
|
||||||
|
FAtLineStart := True;
|
||||||
Next;
|
Next;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1775,6 +1777,8 @@ begin
|
|||||||
CommentProc
|
CommentProc
|
||||||
else
|
else
|
||||||
fProcTable[fLine[Run]];
|
fProcTable[fLine[Run]];
|
||||||
|
if FAtLineStart and not(FTokenID in [tkSpace, tkComment]) then
|
||||||
|
FAtLineStart := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynJScriptSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
|
function TSynJScriptSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
|
||||||
@ -1879,31 +1883,7 @@ end;
|
|||||||
function TSynJScriptSyn.StartJScriptCodeFoldBlock(
|
function TSynJScriptSyn.StartJScriptCodeFoldBlock(
|
||||||
ABlockType: TJScriptFoldBlockType; OnlyEnabled: Boolean
|
ABlockType: TJScriptFoldBlockType; OnlyEnabled: Boolean
|
||||||
): TSynCustomCodeFoldBlock;
|
): TSynCustomCodeFoldBlock;
|
||||||
{var
|
|
||||||
p: PtrInt;
|
|
||||||
FoldBlock, BlockEnabled: Boolean;
|
|
||||||
act: TSynFoldActions;
|
|
||||||
nd: TSynFoldNodeInfo;}
|
|
||||||
begin
|
begin
|
||||||
{BlockEnabled := FFoldConfig[ord(ABlockType)].Enabled;
|
|
||||||
if (not BlockEnabled) and OnlyEnabled then
|
|
||||||
exit(nil);
|
|
||||||
FoldBlock := BlockEnabled and (FFoldConfig[ord(ABlockType)].Modes * [fmFold, fmHide] <> []);
|
|
||||||
p := 0;
|
|
||||||
|
|
||||||
if IsCollectingNodeInfo then begin // exclude subblocks, because they do not increase the foldlevel yet
|
|
||||||
act := [sfaOpen, sfaOpenFold]; //TODO: sfaOpenFold not for cfbtIfThen
|
|
||||||
if BlockEnabled then
|
|
||||||
act := act + FFoldConfig[ord(ABlockType)].FoldActions;
|
|
||||||
if not FAtLineStart then
|
|
||||||
act := act - [sfaFoldHide];
|
|
||||||
DoInitNode(nd, False, Pointer(PtrInt(ABlockType)), act, FoldBlock);
|
|
||||||
CollectingNodeInfoList.Add(nd);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if not FoldBlock then
|
|
||||||
p := PtrInt(CountPascalCodeFoldBlockOffset);}
|
|
||||||
//Result:=TSynCustomCodeFoldBlock(StartCodeFoldBlock(p+Pointer(PtrInt(ABlockType)), FoldBlock));
|
|
||||||
Result:=StartCodeFoldBlock(Pointer(PtrInt(ABlockType)) );
|
Result:=StartCodeFoldBlock(Pointer(PtrInt(ABlockType)) );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1917,6 +1897,8 @@ procedure TSynJScriptSyn.DoInitNode(var Node: TSynFoldNodeInfo;
|
|||||||
AIsFold: Boolean);
|
AIsFold: Boolean);
|
||||||
begin
|
begin
|
||||||
inherited DoInitNode(Node, FinishingABlock, ABlockType, aActions, AIsFold);
|
inherited DoInitNode(Node, FinishingABlock, ABlockType, aActions, AIsFold);
|
||||||
|
if not FAtLineStart then
|
||||||
|
Node.FoldAction := Node.FoldAction - [sfaFoldHide];
|
||||||
if (ABlockType <> nil) and (TJScriptFoldBlockType(PtrUInt(ABlockType)) = jsbFunction) then
|
if (ABlockType <> nil) and (TJScriptFoldBlockType(PtrUInt(ABlockType)) = jsbFunction) then
|
||||||
Include( Node.FoldAction, sfaOutlineKeepLevel);
|
Include( Node.FoldAction, sfaOutlineKeepLevel);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user