📄 synhighlightermsg.pas
字号:
case I of
#0: fProcTable[I] := NullProc;
#10: fProcTable[I] := LFProc;
#13: fProcTable[I] := CRProc;
'{': fProcTable[I] := BraceCommentOpenProc;
'''': fProcTable[I] := StringOpenProc;
#1..#9,
#11,
#12,
#14..#32 : fProcTable[I] := SpaceProc;
'A'..'Z', 'a'..'z', '_': fProcTable[I] := IdentProc;
'-', '+', '*', '/', '\', ',', '"', '[', ']', ':', ';': fProcTable[I] := SymbolProc;
'|': fProcTable[I] := TerminatorProc;
else
fProcTable[I] := UnknownProc;
end;
end;
procedure TSynMsgSyn.SpaceProc;
begin
fTokenID := tkSpace;
repeat
inc(Run);
until not (fLine[Run] in [#1..#32]);
end;
procedure TSynMsgSyn.NullProc;
begin
fTokenID := tkNull;
end;
procedure TSynMsgSyn.CRProc;
begin
fTokenID := tkSpace;
inc(Run);
if fLine[Run] = #10 then
inc(Run);
end;
procedure TSynMsgSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end;
procedure TSynMsgSyn.BraceCommentOpenProc;
begin
Inc(Run);
fRange := rsBraceComment;
BraceCommentProc;
fTokenID := tkComment;
end;
procedure TSynMsgSyn.BraceCommentProc;
begin
case fLine[Run] of
#0: NullProc;
#10: LFProc;
#13: CRProc;
else
begin
fTokenID := tkComment;
repeat
if (fLine[Run] = '}') then
begin
Inc(Run, 1);
fRange := rsUnKnown;
Break;
end;
if not (fLine[Run] in [#0, #10, #13]) then
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
end;
end;
procedure TSynMsgSyn.StringOpenProc;
begin
Inc(Run);
fRange := rsString;
StringProc;
fTokenID := tkString;
end;
procedure TSynMsgSyn.StringProc;
begin
fTokenID := tkString;
repeat
if (fLine[Run] = '''') then
begin
Inc(Run, 1);
fRange := rsUnKnown;
Break;
end;
if not (fLine[Run] in [#0, #10, #13]) then
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
constructor TSynMsgSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment);
fCommentAttri.Style := [fsItalic];
fCommentAttri.Foreground := clNavy;
AddAttribute(fCommentAttri);
fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier);
AddAttribute(fIdentifierAttri);
fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord);
fKeyAttri.Style := [fsBold];
AddAttribute(fKeyAttri);
fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSpace);
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fSymbolAttri := TSynHighLighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
fTerminatorAttri := TSynHighLighterAttributes.Create(SYNS_AttrTerminator);
AddAttribute(fTerminatorAttri);
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fDefaultFilter := SYNS_FilterSynGenMsgfiles;
fRange := rsUnknown;
end;
procedure TSynMsgSyn.SetLine(NewValue: String; LineNumber: Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end;
procedure TSynMsgSyn.IdentProc;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
while Identifiers[fLine[Run]] do
Inc(Run);
end;
procedure TSynMsgSyn.SymbolProc;
begin
Inc(Run);
fTokenID := tkSymbol;
end;
procedure TSynMsgSyn.TerminatorProc;
begin
Inc(Run);
if (fLine[Run] = '>') and (fLine[Run + 1] = '<') and (fLine[Run + 2] = '|') then
begin
fTokenID := tkTerminator;
Inc(Run, 3);
end
else
fTokenID := tkSymbol;
end;
procedure TSynMsgSyn.UnknownProc;
begin
{$IFDEF SYN_MBCSSUPPORT}
if FLine[Run] in LeadBytes then
Inc(Run, 2)
else
{$ENDIF}
inc(Run);
fTokenID := tkUnknown;
end;
procedure TSynMsgSyn.Next;
begin
fTokenPos := Run;
case fRange of
rsBraceComment: BraceCommentProc;
else
begin
fRange := rsUnknown;
fProcTable[fLine[Run]];
end;
end;
end;
function TSynMsgSyn.GetDefaultAttribute(Index: integer): TSynHighLighterAttributes;
begin
case Index of
SYN_ATTR_COMMENT : Result := fCommentAttri;
SYN_ATTR_IDENTIFIER : Result := fIdentifierAttri;
SYN_ATTR_KEYWORD : Result := fKeyAttri;
SYN_ATTR_STRING : Result := fStringAttri;
SYN_ATTR_WHITESPACE : Result := fSpaceAttri;
SYN_ATTR_SYMBOL : Result := fSymbolAttri;
else
Result := nil;
end;
end;
function TSynMsgSyn.GetEol: Boolean;
begin
Result := fTokenID = tkNull;
end;
function TSynMsgSyn.GetToken: String;
var
Len: LongInt;
begin
Len := Run - fTokenPos;
SetString(Result, (FLine + fTokenPos), Len);
end;
function TSynMsgSyn.GetTokenID: TtkTokenKind;
begin
Result := fTokenId;
end;
function TSynMsgSyn.GetTokenAttribute: TSynHighLighterAttributes;
begin
case GetTokenID of
tkComment: Result := fCommentAttri;
tkIdentifier: Result := fIdentifierAttri;
tkKey: Result := fKeyAttri;
tkSpace: Result := fSpaceAttri;
tkString: Result := fStringAttri;
tkSymbol: Result := fSymbolAttri;
tkTerminator: Result := fTerminatorAttri;
tkUnknown: Result := fIdentifierAttri;
else
Result := nil;
end;
end;
function TSynMsgSyn.GetTokenKind: integer;
begin
Result := Ord(fTokenId);
end;
function TSynMsgSyn.GetTokenPos: Integer;
begin
Result := fTokenPos;
end;
function TSynMsgSyn.GetIdentChars: TSynIdentChars;
begin
Result := ['_', 'a'..'z', 'A'..'Z'] + TSynSpecialChars;
end;
function TSynMsgSyn.GetSampleSource: string;
begin
Result := 'TSynSampleSyn {first identifier is the class name }'#13#10 +
'tk {second identifier is the prefix }'#13#10 +
'IdentStart ''a''..''z'':: ''a''..''z''::'#13#10 +
'KEYS'#13#10 +
'Sample'#13#10 +
'Source'#13#10 +
'|><|';
end;
function TSynMsgSyn.IsFilterStored: Boolean;
begin
Result := fDefaultFilter <> SYNS_FilterSynGenMsgfiles;
end;
class function TSynMsgSyn.GetLanguageName: string;
begin
Result := SYNS_LangSynGenMsgfiles;
end;
procedure TSynMsgSyn.ResetRange;
begin
fRange := rsUnknown;
end;
procedure TSynMsgSyn.SetRange(Value: Pointer);
begin
fRange := TRangeState(Value);
end;
function TSynMsgSyn.GetRange: Pointer;
begin
Result := Pointer(fRange);
end;
initialization
MakeIdentTable;
{$IFNDEF SYN_CPPB_1}
RegisterPlaceableHighlighter(TSynMsgSyn);
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -