📄 synhighlighterunreal.pas
字号:
end;
function TSynUnrealSyn.Func210: TtkTokenKind;
begin
if KeyComp('DEFAULTPROPERTIES') then Result := tkKey else Result := tkIdentifier;
end;
function TSynUnrealSyn.Func218: TtkTokenKind;
begin
if KeyComp('EXPORTSTRUCTS') then Result := tkKey else Result := tkIdentifier;
end;
function TSynUnrealSyn.Func238: TtkTokenKind;
begin
if KeyComp('DONTCOLLAPSECATEGORIES') then Result := tkKey else Result := tkIdentifier;
end;
function TSynUnrealSyn.AltFunc: TtkTokenKind;
begin
Result := tkIdentifier;
end;
function TSynUnrealSyn.IdentKind(MayBe: PChar): TtkTokenKind;
var HashKey: Integer;
begin
fToIdent := MayBe;
HashKey := KeyHash(MayBe);
if HashKey < MAXIDENTTABLE + 1 then Result := fIdentFuncTable[HashKey] else Result := tkIdentifier;
end;
procedure TSynUnrealSyn.MakeMethodTables;
var
I: Char;
begin
for I := #0 to #255 do
case I of
'&': fProcTable[I] := AndSymbolProc;
#39: fProcTable[I] := AsciiCharProc;
'}': fProcTable[I] := BraceCloseProc;
'{': fProcTable[I] := BraceOpenProc;
#13: fProcTable[I] := CRProc;
':': fProcTable[I] := ColonProc;
',': fProcTable[I] := CommaProc;
'#': fProcTable[I] := DirectiveProc;
'=': fProcTable[I] := EqualProc;
'>': fProcTable[I] := GreaterProc;
'?': fProcTable[I] := QuestionProc;
'A'..'Z', 'a'..'z', '_': fProcTable[I] := IdentProc;
#10: fProcTable[I] := LFProc;
'<': fProcTable[I] := LowerProc;
'-': fProcTable[I] := MinusProc;
'%': fProcTable[I] := ModSymbolProc;
'!': fProcTable[I] := NotSymbolProc;
#0: fProcTable[I] := NullProc;
'0'..'9': fProcTable[I] := NumberProc;
'|': fProcTable[I] := OrSymbolProc;
'+': fProcTable[I] := PlusProc;
'.': fProcTable[I] := PointProc;
')': fProcTable[I] := RoundCloseProc;
'(': fProcTable[I] := RoundOpenProc;
';': fProcTable[I] := SemiColonProc;
'/': fProcTable[I] := SlashProc;
#1..#9, #11, #12, #14..#32: fProcTable[I] := SpaceProc;
']': fProcTable[I] := SquareCloseProc;
'[': fProcTable[I] := SquareOpenProc;
'*': fProcTable[I] := StarProc;
#34: fProcTable[I] := StringProc;
'$', '@': fProcTable[I] := DollarSignProc;
'~': fProcTable[I] := TildeProc;
'^': fProcTable[I] := XOrSymbolProc;
else fProcTable[I] := UnknownProc;
end;
end;
constructor TSynUnrealSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment);
fCommentAttri.Style:= [fsItalic];
AddAttribute(fCommentAttri);
fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier);
AddAttribute(fIdentifierAttri);
fInvalidAttri := TSynHighlighterAttributes.Create(SYNS_AttrIllegalChar);
AddAttribute(fInvalidAttri);
fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord);
fKeyAttri.Style:= [fsBold];
AddAttribute(fKeyAttri);
fKey2Attri := TSynHighlighterAttributes.Create(SYNS_AttrSecondReservedWord);
fKey2Attri.Style:= [fsBold];
AddAttribute(fKey2Attri);
fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
AddAttribute(fNumberAttri);
fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
fSpaceAttri.Foreground := clWindow;
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fString2Attri := TSynHighlighterAttributes.Create(SYNS_AttrSingleString);
AddAttribute(fString2Attri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
fDirecAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective);
AddAttribute(fDirecAttri);
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fRange := rsUnknown;
fDefaultFilter := SYNS_FilterCPP;
end; { Create }
procedure TSynUnrealSyn.SetLine(NewValue: String; LineNumber:Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end; { SetLine }
procedure TSynUnrealSyn.AnsiCProc;
begin
fTokenID := tkComment;
case FLine[Run] of
#0:
begin
NullProc;
exit;
end;
#10:
begin
LFProc;
exit;
end;
#13:
begin
CRProc;
exit;
end;
end;
while FLine[Run] <> #0 do
case FLine[Run] of
'*':
if fLine[Run + 1] = '/' then
begin
inc(Run, 2);
if fRange = rsDirectiveComment then
fRange := rsDirective
else
fRange := rsUnKnown;
break;
end else
inc(Run);
#10: break;
#13: break;
else inc(Run);
end;
end;
procedure TSynUnrealSyn.AndSymbolProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {and assign}
begin
inc(Run, 2);
FExtTokenID := xtkAndAssign;
end;
'&': {logical and}
begin
inc(Run, 2);
FExtTokenID := xtkLogAnd;
end;
else {and}
begin
inc(Run);
FExtTokenID := xtkAnd;
end;
end;
end;
procedure TSynUnrealSyn.AsciiCharProc;
begin
fTokenID := tkString2;
repeat
case FLine[Run] of
#0, #10, #13: break;
#92: {backslash}
{if we have an escaped single quote it doesn't count}
if FLine[Run + 1] = #39 then inc(Run);
end;
inc(Run);
until FLine[Run] = #39;
if FLine[Run] <> #0 then inc(Run);
end;
procedure TSynUnrealSyn.BraceCloseProc;
begin
inc(Run);
fTokenId := tkSymbol;
FExtTokenID := xtkBraceClose;
end;
procedure TSynUnrealSyn.BraceOpenProc;
begin
inc(Run);
fTokenId := tkSymbol;
FExtTokenID := xtkBraceOpen;
end;
procedure TSynUnrealSyn.CRProc;
begin
fTokenID := tkSpace;
Inc(Run);
if fLine[Run + 1] = #10 then Inc(Run);
end;
procedure TSynUnrealSyn.ColonProc;
begin
fTokenID := tkSymbol;
Case FLine[Run + 1] of
':': {scope resolution operator}
begin
inc(Run, 2);
FExtTokenID := xtkScopeResolution;
end;
else {colon}
begin
inc(Run);
FExtTokenID := xtkColon;
end;
end;
end;
procedure TSynUnrealSyn.CommaProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkComma;
end;
procedure TSynUnrealSyn.DirectiveProc;
begin
if fLine[Run] in [#0, #10, #13] then begin
if (Run <= 0) then
fRange := rsUnknown;
fProcTable[fLine[Run]];
end else begin
fTokenID := tkDirective;
while TRUE do
case fLine[Run] of
'/': // comment?
begin
if fLine[Run + 1] = '/' then // is end of directive as well
break
else if fLine[Run + 1] = '*' then begin // might be embedded only
fRange := rsDirectiveComment;
break;
end else
Inc(Run);
end;
#0, #10, #13:
begin
fRange := rsUnknown;
break;
end;
else Inc(Run);
end;
end;
end;
procedure TSynUnrealSyn.EqualProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {logical equal}
begin
inc(Run, 2);
FExtTokenID := xtkLogEqual;
end;
else {assign}
begin
inc(Run);
FExtTokenID := xtkAssign;
end;
end;
end;
procedure TSynUnrealSyn.GreaterProc;
begin
fTokenID := tkSymbol;
Case FLine[Run + 1] of
'=': {greater than or equal to}
begin
inc(Run, 2);
FExtTokenID := xtkGreaterThanEqual;
end;
'>':
begin
if FLine[Run + 2] = '=' then {shift right assign}
begin
inc(Run, 3);
FExtTokenID := xtkShiftRightAssign;
end
else {shift right}
begin
inc(Run, 2);
FExtTokenID := xtkShiftRight;
end;
end;
else {greater than}
begin
inc(Run);
FExtTokenID := xtkGreaterThan;
end;
end;
end;
procedure TSynUnrealSyn.QuestionProc;
begin
fTokenID := tkSymbol; {conditional}
FExtTokenID := xtkQuestion;
inc(Run);
end;
procedure TSynUnrealSyn.IdentProc;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
while Identifiers[fLine[Run]] do inc(Run);
end;
procedure TSynUnrealSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end;
procedure TSynUnrealSyn.LowerProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {less than or equal to}
begin
inc(Run, 2);
FExtTokenID := xtkLessThanEqual;
end;
'<':
begin
if FLine[Run + 2] = '=' then {shift left assign}
begin
inc(Run, 3);
FExtTokenID := xtkShiftLeftAssign;
end
else {shift left}
begin
inc(Run, 2);
FExtTokenID := xtkShiftLeft;
end;
end;
else {less than}
begin
inc(Run);
FExtTokenID := xtkLessThan;
end;
end;
end;
procedure TSynUnrealSyn.MinusProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {subtract assign}
begin
inc(Run, 2);
FExtTokenID := xtkSubtractAssign;
end;
'-': {decrement}
begin
inc(Run, 2);
FExtTokenID := xtkDecrement;
end;
'>': {arrow}
begin
inc(Run, 2);
FExtTokenID := xtkArrow;
end;
else {subtract}
begin
inc(Run);
FExtTokenID := xtkSubtract;
end;
end;
end;
procedure TSynUnrealSyn.ModSymbolProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {mod assign}
begin
inc(Run, 2);
FExtTokenID := xtkModAssign;
end;
else {mod}
begin
inc(Run);
FExtTokenID := xtkMod;
end;
end;
end;
procedure TSynUnrealSyn.NotSymbolProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {not equal}
begin
inc(Run, 2);
FExtTokenID := xtkNotEqual;
end;
else {not}
begin
inc(Run);
FExtTokenID := xtkLogComplement;
end;
end;
end;
procedure TSynUnrealSyn.NullProc;
begin
fTokenID := tkNull;
end;
procedure TSynUnrealSyn.NumberProc;
begin
inc(Run);
fTokenID := tkNumber;
while FLine[Run] in
['0'..'9', 'A'..'F', 'a'..'f', '.', 'u', 'U', 'l', 'L', 'x', 'X'] do
begin
case FLine[Run] of
'.':
if FLine[Run + 1] = '.' then break;
end;
inc(Run);
end;
end;
procedure TSynUnrealSyn.OrSymbolProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {or assign}
begin
inc(Run, 2);
FExtTokenID := xtkIncOrAssign;
end;
'|': {logical or}
begin
inc(Run, 2);
FExtTokenID := xtkLogOr;
end;
else {or}
begin
inc(Run);
FExtTokenID := xtkIncOr;
end;
end;
end;
procedure TSynUnrealSyn.PlusProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {add assign}
begin
inc(Run, 2);
FExtTokenID := xtkAddAssign;
end;
'+': {increment}
begin
inc(Run, 2);
FExtTokenID := xtkIncrement;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -