mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 12:19:16 +02:00
SynEdit: Pas-HL, added different modes to highlight "string", "Ansistring", "exit", "break", ...
git-svn-id: trunk@27961 -
This commit is contained in:
parent
63b63bb2c5
commit
427e10011c
@ -62,6 +62,8 @@ uses
|
|||||||
SynEditStrConst;
|
SynEditStrConst;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TSynPasStringMode = (spsmDefault, spsmStringOnly, spsmNone);
|
||||||
|
|
||||||
TtkTokenKind = (tkAsm, tkComment, tkIdentifier, tkKey, tkNull, tkNumber,
|
TtkTokenKind = (tkAsm, tkComment, tkIdentifier, tkKey, tkNull, tkNumber,
|
||||||
tkSpace, tkString, tkSymbol, {$IFDEF SYN_LAZARUS}tkDirective, {$ENDIF}
|
tkSpace, tkString, tkSymbol, {$IFDEF SYN_LAZARUS}tkDirective, {$ENDIF}
|
||||||
tkUnknown);
|
tkUnknown);
|
||||||
@ -235,10 +237,12 @@ type
|
|||||||
TSynPasSyn = class(TSynCustomFoldHighlighter)
|
TSynPasSyn = class(TSynCustomFoldHighlighter)
|
||||||
private
|
private
|
||||||
fAsmStart: Boolean;
|
fAsmStart: Boolean;
|
||||||
|
FExtendedKeywordsMode: Boolean;
|
||||||
FNestedComments: boolean;
|
FNestedComments: boolean;
|
||||||
FStartCodeFoldBlockLevel: integer;
|
FStartCodeFoldBlockLevel: integer;
|
||||||
FPasStartLevel: Smallint;
|
FPasStartLevel: Smallint;
|
||||||
fRange: TRangeStates;
|
fRange: TRangeStates;
|
||||||
|
FStringKeywordMode: TSynPasStringMode;
|
||||||
FSynPasRangeInfo: TSynPasRangeInfo;
|
FSynPasRangeInfo: TSynPasRangeInfo;
|
||||||
FAtLineStart: Boolean; // Line had only spaces or comments sofar
|
FAtLineStart: Boolean; // Line had only spaces or comments sofar
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
@ -284,6 +288,8 @@ type
|
|||||||
procedure GrowNodeInfoList;
|
procedure GrowNodeInfoList;
|
||||||
function GetPasCodeFoldRange: TSynPasSynRange;
|
function GetPasCodeFoldRange: TSynPasSynRange;
|
||||||
procedure SetCompilerMode(const AValue: TPascalCompilerMode);
|
procedure SetCompilerMode(const AValue: TPascalCompilerMode);
|
||||||
|
procedure SetExtendedKeywordsMode(const AValue: Boolean);
|
||||||
|
procedure SetStringKeywordMode(const AValue: TSynPasStringMode);
|
||||||
function TextComp(aText: PChar): Boolean;
|
function TextComp(aText: PChar): Boolean;
|
||||||
function KeyHash: Integer;
|
function KeyHash: Integer;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -317,6 +323,7 @@ type
|
|||||||
function Func55: TtkTokenKind;
|
function Func55: TtkTokenKind;
|
||||||
function Func56: TtkTokenKind;
|
function Func56: TtkTokenKind;
|
||||||
function Func57: TtkTokenKind;
|
function Func57: TtkTokenKind;
|
||||||
|
function Func58: TtkTokenKind;
|
||||||
function Func59: TtkTokenKind;
|
function Func59: TtkTokenKind;
|
||||||
function Func60: TtkTokenKind;
|
function Func60: TtkTokenKind;
|
||||||
function Func61: TtkTokenKind;
|
function Func61: TtkTokenKind;
|
||||||
@ -527,6 +534,10 @@ protected
|
|||||||
property NestedComments: boolean read FNestedComments write FNestedComments;
|
property NestedComments: boolean read FNestedComments write FNestedComments;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
property D4syntax: boolean read FD4syntax write SetD4syntax default true;
|
property D4syntax: boolean read FD4syntax write SetD4syntax default true;
|
||||||
|
property ExtendedKeywordsMode: Boolean
|
||||||
|
read FExtendedKeywordsMode write SetExtendedKeywordsMode default False;
|
||||||
|
property StringKeywordMode: TSynPasStringMode
|
||||||
|
read FStringKeywordMode write SetStringKeywordMode default spsmDefault;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TSynFreePascalSyn }
|
{ TSynFreePascalSyn }
|
||||||
@ -658,6 +669,7 @@ begin
|
|||||||
fIdentFuncTable[55] := @Func55;
|
fIdentFuncTable[55] := @Func55;
|
||||||
fIdentFuncTable[56] := @Func56;
|
fIdentFuncTable[56] := @Func56;
|
||||||
fIdentFuncTable[57] := @Func57;
|
fIdentFuncTable[57] := @Func57;
|
||||||
|
fIdentFuncTable[58] := @Func58;
|
||||||
fIdentFuncTable[59] := @Func59;
|
fIdentFuncTable[59] := @Func59;
|
||||||
fIdentFuncTable[60] := @Func60;
|
fIdentFuncTable[60] := @Func60;
|
||||||
fIdentFuncTable[61] := @Func61;
|
fIdentFuncTable[61] := @Func61;
|
||||||
@ -871,6 +883,22 @@ begin
|
|||||||
//DebugLn(['TSynPasSyn.SetCompilerMode FCompilerMode=',ord(FCompilerMode),' FNestedComments=',FNestedComments]);
|
//DebugLn(['TSynPasSyn.SetCompilerMode FCompilerMode=',ord(FCompilerMode),' FNestedComments=',FNestedComments]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynPasSyn.SetExtendedKeywordsMode(const AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FExtendedKeywordsMode = AValue then exit;
|
||||||
|
FExtendedKeywordsMode := AValue;
|
||||||
|
FAttributeChangeNeedScan := True;
|
||||||
|
DefHighlightChange(self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynPasSyn.SetStringKeywordMode(const AValue: TSynPasStringMode);
|
||||||
|
begin
|
||||||
|
if FStringKeywordMode = AValue then exit;
|
||||||
|
FStringKeywordMode := AValue;
|
||||||
|
FAttributeChangeNeedScan := True;
|
||||||
|
DefHighlightChange(self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynPasSyn.GrowNodeInfoList;
|
procedure TSynPasSyn.GrowNodeInfoList;
|
||||||
begin
|
begin
|
||||||
if FNodeInfoCount < length(FNodeInfoList) then
|
if FNodeInfoCount < length(FNodeInfoList) then
|
||||||
@ -1049,6 +1077,9 @@ begin
|
|||||||
else StartPascalCodeFoldBlock(cfbtBeginEnd);
|
else StartPascalCodeFoldBlock(cfbtBeginEnd);
|
||||||
//debugln('TSynPasSyn.Func37 BEGIN ',dbgs(ord(TopPascalCodeFoldBlockType)),' LineNumber=',dbgs(fLineNumber),' ',dbgs(MinimumCodeFoldBlockLevel),' ',dbgs(CurrentCodeFoldBlockLevel));
|
//debugln('TSynPasSyn.Func37 BEGIN ',dbgs(ord(TopPascalCodeFoldBlockType)),' LineNumber=',dbgs(fLineNumber),' ',dbgs(MinimumCodeFoldBlockLevel),' ',dbgs(CurrentCodeFoldBlockLevel));
|
||||||
end else
|
end else
|
||||||
|
if FExtendedKeywordsMode and KeyComp('Break') then
|
||||||
|
Result := tkKey
|
||||||
|
else
|
||||||
Result := tkIdentifier;
|
Result := tkIdentifier;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1187,6 +1218,14 @@ begin
|
|||||||
if KeyComp('Xor') then Result := tkKey else Result := tkIdentifier;
|
if KeyComp('Xor') then Result := tkKey else Result := tkIdentifier;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSynPasSyn.Func58: TtkTokenKind;
|
||||||
|
begin
|
||||||
|
if FExtendedKeywordsMode and KeyComp('Exit') then
|
||||||
|
Result := tkKey
|
||||||
|
else
|
||||||
|
Result := tkIdentifier;
|
||||||
|
end;
|
||||||
|
|
||||||
function TSynPasSyn.Func59: TtkTokenKind;
|
function TSynPasSyn.Func59: TtkTokenKind;
|
||||||
begin
|
begin
|
||||||
if KeyComp('Safecall') and (TopPascalCodeFoldBlockType in ProcModifierAllowed) then
|
if KeyComp('Safecall') and (TopPascalCodeFoldBlockType in ProcModifierAllowed) then
|
||||||
@ -1438,7 +1477,10 @@ end;
|
|||||||
|
|
||||||
function TSynPasSyn.Func87: TtkTokenKind;
|
function TSynPasSyn.Func87: TtkTokenKind;
|
||||||
begin
|
begin
|
||||||
if KeyComp('String') then Result := tkKey else Result := tkIdentifier;
|
if (FStringKeywordMode in [spsmDefault, spsmStringOnly]) and KeyComp('String') then
|
||||||
|
Result := tkKey
|
||||||
|
else
|
||||||
|
Result := tkIdentifier;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynPasSyn.Func88: TtkTokenKind;
|
function TSynPasSyn.Func88: TtkTokenKind;
|
||||||
@ -1644,10 +1686,13 @@ begin
|
|||||||
if KeyComp('Register') and (TopPascalCodeFoldBlockType in ProcModifierAllowed) then
|
if KeyComp('Register') and (TopPascalCodeFoldBlockType in ProcModifierAllowed) then
|
||||||
Result := tkKey
|
Result := tkKey
|
||||||
else
|
else
|
||||||
if KeyComp('Platform') then
|
if KeyComp('Platform') then
|
||||||
Result := tkKey
|
Result := tkKey
|
||||||
else
|
else
|
||||||
Result := tkIdentifier;
|
if FExtendedKeywordsMode and KeyComp('Continue') then
|
||||||
|
Result := tkKey
|
||||||
|
else
|
||||||
|
Result := tkIdentifier;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynPasSyn.Func102: TtkTokenKind;
|
function TSynPasSyn.Func102: TtkTokenKind;
|
||||||
@ -1759,7 +1804,10 @@ end;
|
|||||||
|
|
||||||
function TSynPasSyn.Func128: TtkTokenKind;
|
function TSynPasSyn.Func128: TtkTokenKind;
|
||||||
begin
|
begin
|
||||||
if KeyComp('Widestring') then Result := tkKey else Result := tkIdentifier;
|
if (FStringKeywordMode in [spsmDefault]) and KeyComp('Widestring') then
|
||||||
|
Result := tkKey
|
||||||
|
else
|
||||||
|
Result := tkIdentifier;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynPasSyn.Func129: TtkTokenKind;
|
function TSynPasSyn.Func129: TtkTokenKind;
|
||||||
@ -1779,7 +1827,7 @@ end;
|
|||||||
|
|
||||||
function TSynPasSyn.Func130: TtkTokenKind;
|
function TSynPasSyn.Func130: TtkTokenKind;
|
||||||
begin
|
begin
|
||||||
if KeyComp('Ansistring') then
|
if (FStringKeywordMode in [spsmDefault]) and KeyComp('Ansistring') then
|
||||||
Result := tkKey
|
Result := tkKey
|
||||||
else
|
else
|
||||||
if KeyComp('Enumerator') and (TopPascalCodeFoldBlockType in [cfbtClassSection]) then
|
if KeyComp('Enumerator') and (TopPascalCodeFoldBlockType in [cfbtClassSection]) then
|
||||||
@ -2063,6 +2111,8 @@ end;
|
|||||||
constructor TSynPasSyn.Create(AOwner: TComponent);
|
constructor TSynPasSyn.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
FStringKeywordMode := spsmDefault;
|
||||||
|
FExtendedKeywordsMode := False;
|
||||||
CreateDividerDrawConfig;
|
CreateDividerDrawConfig;
|
||||||
fD4syntax := true;
|
fD4syntax := true;
|
||||||
fAsmAttri := TSynHighlighterAttributes.Create(SYNS_AttrAssembler, SYNS_XML_AttrAssembler);
|
fAsmAttri := TSynHighlighterAttributes.Create(SYNS_AttrAssembler, SYNS_XML_AttrAssembler);
|
||||||
|
Loading…
Reference in New Issue
Block a user