📄 synhighlighterunreal.pas
字号:
else {add}
begin
inc(Run);
FExtTokenID := xtkAdd;
end;
end;
end;
procedure TSynUnrealSyn.PointProc;
begin
fTokenID := tkSymbol;
if (FLine[Run + 1] = '.') and (FLine[Run + 2] = '.') then
begin {ellipse}
inc(Run, 3);
FExtTokenID := xtkEllipse;
end
else {point}
begin
inc(Run);
FExtTokenID := xtkPoint;
end;
end;
procedure TSynUnrealSyn.RoundCloseProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkRoundClose;
dec(FRoundCount);
end;
procedure TSynUnrealSyn.RoundOpenProc;
begin
inc(Run);
FTokenID := tkSymbol;
FExtTokenID := xtkRoundOpen;
inc(FRoundCount);
end;
procedure TSynUnrealSyn.SemiColonProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkSemiColon;
end;
procedure TSynUnrealSyn.SlashProc;
begin
case FLine[Run + 1] of
'/': {c++ style comments}
begin
fTokenID := tkComment;
inc(Run, 2);
while not (fLine[Run] in [#0, #10, #13]) do Inc(Run);
end;
'*': {c style comments}
begin
fTokenID := tkComment;
if fRange <> rsDirectiveComment then
fRange := rsAnsiC;
inc(Run, 2);
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, #13:
begin
if fRange = rsDirectiveComment then
fRange := rsAnsiC;
break;
end;
else inc(Run);
end;
end;
'=': {divide assign}
begin
inc(Run, 2);
fTokenID := tkSymbol;
FExtTokenID := xtkDivideAssign;
end;
else {divide}
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkDivide;
end;
end;
end;
procedure TSynUnrealSyn.SpaceProc;
begin
inc(Run);
fTokenID := tkSpace;
while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run);
end;
procedure TSynUnrealSyn.SquareCloseProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkSquareClose;
dec(FSquareCount);
end;
procedure TSynUnrealSyn.SquareOpenProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkSquareOpen;
inc(FSquareCount);
end;
procedure TSynUnrealSyn.StarProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {multiply assign}
begin
inc(Run, 2);
FExtTokenID := xtkMultiplyAssign;
end;
else {star}
begin
inc(Run);
FExtTokenID := xtkStar;
end;
end;
end;
procedure TSynUnrealSyn.StringProc;
begin
fTokenID := tkString;
if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2);
repeat
case FLine[Run] of
#0, #10, #13: break;
#92: {backslash}
case FLine[Run + 1] of
#10: inc(Run); {line continuation character}
#34: inc(Run); {escaped quote doesn't count}
#92: inc(Run);
end;
end;
inc(Run);
until FLine[Run] = #34;
if FLine[Run] <> #0 then inc(Run);
end;
procedure TSynUnrealSyn.DollarSignProc;
begin
fTokenID := tkSymbol;
inc(run);
end;
procedure TSynUnrealSyn.TildeProc;
begin
inc(Run); {bitwise complement}
fTokenId := tkSymbol;
FExtTokenID := xtkBitComplement;
end;
procedure TSynUnrealSyn.XOrSymbolProc;
begin
fTokenID := tkSymbol;
Case FLine[Run + 1] of
'=': {xor assign}
begin
inc(Run, 2);
FExtTokenID := xtkXorAssign;
end;
else {xor}
begin
inc(Run);
FExtTokenID := xtkXor;
end;
end;
end;
procedure TSynUnrealSyn.UnknownProc;
begin
{$IFDEF SYN_MBCSSUPPORT}
if FLine[Run] in LeadBytes then
Inc(Run, 2)
else
{$ENDIF}
inc(Run);
fTokenID := tkUnknown;
end;
procedure TSynUnrealSyn.Next;
begin
fTokenPos := Run;
case fRange of
rsAnsiC, rsDirectiveComment: AnsiCProc;
rsDirective: DirectiveProc;
else
begin
fRange := rsUnknown;
fProcTable[fLine[Run]];
end;
end;
end;
function TSynUnrealSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
begin
case Index of
SYN_ATTR_COMMENT : Result := fCommentAttri;
SYN_ATTR_KEYWORD : Result := fKeyAttri;
SYN_ATTR_WHITESPACE: Result := fSpaceAttri;
SYN_ATTR_STRING : Result := fStringAttri;
SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri;
SYN_ATTR_SYMBOL : Result := fSymbolAttri;
else
Result := nil;
end;
end;
function TSynUnrealSyn.GetEol: Boolean;
begin
Result := fTokenID = tkNull;
end;
function TSynUnrealSyn.GetRange: Pointer;
begin
Result := Pointer(fRange);
end;
function TSynUnrealSyn.GetToken: String;
var
Len: LongInt;
begin
Len := Run - fTokenPos;
SetString(Result, (FLine + fTokenPos), Len);
end;
function TSynUnrealSyn.GetTokenID: TtkTokenKind;
begin
Result := fTokenId;
end;
function TSynUnrealSyn.GetExtTokenID: TxtkTokenKind;
begin
Result := FExtTokenID;
end;
function TSynUnrealSyn.IsFilterStored: Boolean;
begin
Result := fDefaultFilter <> SYNS_FilterCPP;
end; { IsFilterStored }
function TSynUnrealSyn.GetTokenAttribute: TSynHighlighterAttributes;
begin
case fTokenID of
tkComment: Result := fCommentAttri;
tkDirective: Result := fDirecAttri;
tkIdentifier: Result := fIdentifierAttri;
tkKey: Result := fKeyAttri;
tkKey2: Result := fKey2Attri;
tkNumber: Result := fNumberAttri;
tkSpace: Result := fSpaceAttri;
tkString: Result := fStringAttri;
tkString2: Result := fString2Attri;
tkSymbol: Result := fSymbolAttri;
tkUnknown: Result := fInvalidAttri;
else Result := nil;
end;
end;
function TSynUnrealSyn.GetTokenKind: integer;
begin
Result := Ord(GetTokenID);
end;
function TSynUnrealSyn.GetTokenPos: Integer;
begin
Result := fTokenPos;
end;
procedure TSynUnrealSyn.ResetRange;
begin
fRange:= rsUnknown;
end;
procedure TSynUnrealSyn.SetRange(Value: Pointer);
begin
fRange := TRangeState(Value);
end;
procedure TSynUnrealSyn.EnumUserSettings(settings: TStrings);
begin
{ returns the user settings that exist in the registry }
{$IFNDEF SYN_CLX}
with TBetterRegistry.Create do
begin
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKeyReadOnly('\SOFTWARE\Borland\C++Builder') then
begin
try
GetKeyNames(settings);
finally
CloseKey;
end;
end;
finally
Free;
end;
end;
{$ENDIF}
end;
function TSynUnrealSyn.UseUserSettings(settingIndex: integer): boolean;
// Possible parameter values:
// index into TStrings returned by EnumUserSettings
// Possible return values:
// true : settings were read and used
// false: problem reading settings or invalid version specified - old settings
// were preserved
{$IFNDEF SYN_CLX}
function ReadCPPBSettings(settingIndex: integer): boolean;
function ReadCPPBSetting(settingTag: string; attri: TSynHighlighterAttributes; key: string): boolean;
function ReadCPPB1(settingTag: string; attri: TSynHighlighterAttributes; name: string): boolean;
var
i: integer;
begin
for i := 1 to Length(name) do
if name[i] = ' ' then name[i] := '_';
Result := attri.LoadFromBorlandRegistry(HKEY_CURRENT_USER,
'\SOFTWARE\Borland\C++Builder\'+settingTag+'\Highlight',name,true);
end; { ReadCPPB1 }
function ReadCPPB3OrMore(settingTag: string; attri: TSynHighlighterAttributes; key: string): boolean;
begin
Result := attri.LoadFromBorlandRegistry(HKEY_CURRENT_USER,
'\Software\Borland\C++Builder\'+settingTag+'\Editor\Highlight',
key,false);
end; { ReadCPPB3OrMore }
begin { ReadCPPBSetting }
try
if (settingTag[1] = '1')
then Result := ReadCPPB1(settingTag,attri,key)
else Result := ReadCPPB3OrMore(settingTag,attri,key);
except Result := false; end;
end; { ReadCPPBSetting }
var
tmpStringAttri : TSynHighlighterAttributes;
tmpNumberAttri : TSynHighlighterAttributes;
tmpKeyAttri : TSynHighlighterAttributes;
tmpSymbolAttri : TSynHighlighterAttributes;
tmpCommentAttri : TSynHighlighterAttributes;
tmpIdentifierAttri: TSynHighlighterAttributes;
tmpInvalidAttri : TSynHighlighterAttributes;
tmpSpaceAttri : TSynHighlighterAttributes;
tmpDirecAttri : TSynHighlighterAttributes;
s : TStringList;
begin { ReadCPPBSettings }
s := TStringList.Create;
try
EnumUserSettings(s);
if settingIndex >= s.Count then Result := false
else begin
tmpStringAttri := TSynHighlighterAttributes.Create('');
tmpNumberAttri := TSynHighlighterAttributes.Create('');
tmpKeyAttri := TSynHighlighterAttributes.Create('');
tmpSymbolAttri := TSynHighlighterAttributes.Create('');
tmpCommentAttri := TSynHighlighterAttributes.Create('');
tmpIdentifierAttri:= TSynHighlighterAttributes.Create('');
tmpInvalidAttri := TSynHighlighterAttributes.Create('');
tmpSpaceAttri := TSynHighlighterAttributes.Create('');
tmpDirecAttri := TSynHighlighterAttributes.Create('');
tmpStringAttri .Assign(fStringAttri);
tmpNumberAttri .Assign(fNumberAttri);
tmpKeyAttri .Assign(fKeyAttri);
tmpSymbolAttri .Assign(fSymbolAttri);
tmpCommentAttri .Assign(fCommentAttri);
tmpIdentifierAttri.Assign(fIdentifierAttri);
tmpInvalidAttri .Assign(fInvalidAttri);
tmpSpaceAttri .Assign(fSpaceAttri);
tmpDirecAttri .Assign(fDirecAttri);
Result := ReadCPPBSetting(s[settingIndex],fCommentAttri,'Comment') and
ReadCPPBSetting(s[settingIndex],fIdentifierAttri,'Identifier') and
ReadCPPBSetting(s[settingIndex],fInvalidAttri,'Illegal Char') and
ReadCPPBSetting(s[settingIndex],fKeyAttri,'Reserved word') and
ReadCPPBSetting(s[settingIndex],fNumberAttri,'Integer') and
ReadCPPBSetting(s[settingIndex],fSpaceAttri,'Whitespace') and
ReadCPPBSetting(s[settingIndex],fStringAttri,'String') and
ReadCPPBSetting(s[settingIndex],fSymbolAttri,'Symbol') and
ReadCPPBSetting(s[settingIndex],fDirecAttri,'Preprocessor');
if not Result then begin
fStringAttri .Assign(tmpStringAttri);
fString2Attri .Assign(tmpStringAttri);
fNumberAttri .Assign(tmpNumberAttri);
fKeyAttri .Assign(tmpKeyAttri);
fKey2Attri .Assign(tmpKeyAttri);
fSymbolAttri .Assign(tmpSymbolAttri);
fCommentAttri .Assign(tmpCommentAttri);
fIdentifierAttri.Assign(tmpIdentifierAttri);
fInvalidAttri.Assign(tmpInvalidAttri);
fSpaceAttri .Assign(tmpSpaceAttri);
fDirecAttri .Assign(tmpDirecAttri);
end;
tmpStringAttri .Free;
tmpNumberAttri .Free;
tmpKeyAttri .Free;
tmpSymbolAttri .Free;
tmpCommentAttri .Free;
tmpIdentifierAttri.Free;
tmpInvalidAttri .Free;
tmpSpaceAttri .Free;
tmpDirecAttri .Free;
end;
finally s.Free; end;
end; { ReadCPPBSettings }
{$ENDIF}
begin
{$IFDEF SYN_CLX}
Result := False;
{$ELSE}
Result := ReadCPPBSettings(settingIndex);
{$ENDIF}
end; { TSynUnrealSyn.UseUserSettings }
function TSynUnrealSyn.GetIdentChars: TSynIdentChars;
begin
Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z'];
end;
class function TSynUnrealSyn.GetLanguageName: string;
begin
Result := SYNS_LangUnreal;
end;
class function TSynUnrealSyn.GetCapabilities: TSynHighlighterCapabilities;
begin
Result := inherited GetCapabilities + [hcUserSettings];
end;
function TSynUnrealSyn.GetSampleSource: string;
begin
Result := '//----Comment-----------------------------------------------------------'#13#10+
'class TestObject expands Object native;'#13#10+
#13#10+
'#exec MESH IMPORT MESH=Something ANIVFILE=MODELS\Something.3D DATAFILE=MODELS\Something.3D X=0 Y=0 Z=0 MLOD=0'#13#10+
#13#10+
'var() Sound HitSound;'#13#10+
'function Cast()'#13#10+
'{'#13#10+
' Super.Cast();'#13#10+
' CastTime = 50;'#13#10+
' GatherEffect = Spawn( class''SomethingCorona'',,, GetStartLoc(), Pawn(Owner).ViewRotation );'#13#10+
' GatherEffect.SetFollowPawn( Pawn(Owner) );'#13#10+
'}'#13#10+
#13#10+
'defaultproperties'#13#10+
'{'#13#10+
' PickupMessage="You have picked up a thing."'#13#10+
'}';
end;
initialization
MakeIdentTable;
{$IFNDEF SYN_CPPB_1}
RegisterPlaceableHighlighter(TSynUnrealSyn);
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -