📄 synhighlighteridl.pas
字号:
if KeyComp('custom') then Result := tkKey else
if KeyComp('sequence') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func98: TtkTokenKind;
begin
if KeyComp('private') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func101: TtkTokenKind;
begin
if KeyComp('unsigned') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func102: TtkTokenKind;
begin
if KeyComp('readonly') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func107: TtkTokenKind;
begin
if KeyComp('struct') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func108: TtkTokenKind;
begin
if KeyComp('context') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func117: TtkTokenKind;
begin
if KeyComp('wstring') then Result := tkDatatype else Result := tkIdentifier;
end;
function TSynIdlSyn.Func120: TtkTokenKind;
begin
if KeyComp('exception') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func125: TtkTokenKind;
begin
if KeyComp('attribute') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func128: TtkTokenKind;
begin
if KeyComp('truncatable') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func136: TtkTokenKind;
begin
if KeyComp('valuetype') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.Func152: TtkTokenKind;
begin
if KeyComp('supports') then Result := tkKey else Result := tkIdentifier;
end;
function TSynIdlSyn.AltFunc: TtkTokenKind;
begin
Result := tkIdentifier;
end;
function TSynIdlSyn.IdentKind(MayBe: PChar): TtkTokenKind;
var
HashKey: Integer;
begin
fToIdent := MayBe;
HashKey := KeyHash(MayBe);
if HashKey <= MaxKey then
Result := fIdentFuncTable[HashKey]
else
Result := tkIdentifier;
end;
procedure TSynIdlSyn.MakeMethodTables;
var
I: Char;
begin
for I := #0 to #255 do
case I of
#0 : fProcTable[I] := NullProc;
#10 : fProcTable[I] := LFProc;
#13 : fProcTable[I] := CRProc;
'/' : fProcTable[I] := CommentOpenProc;
'"' : fProcTable[I] := StringOpenProc;
'''' : fProcTable[I] := CharOpenProc;
'#' : fProcTable[I] := PreProcessorProc;
#1..#9,
#11,
#12,
#14..#32 : fProcTable[I] := SpaceProc;
'A'..'Z',
'a'..'z',
'_' : fProcTable[I] := IdentProc;
'0'..'9' : fProcTable[I] := NumberProc;
'-', '+',
'*', '\',
',', '.',
'[', ']',
'{', '}',
'<', '>',
'(', ')',
'=', '?',
':', ';' : fProcTable[I] := SymbolProc;
else
fProcTable[I] := UnknownProc;
end;
end;
procedure TSynIdlSyn.SpaceProc;
begin
fTokenID := tkSpace;
repeat
inc(Run);
until not (fLine[Run] in [#1..#32]);
end;
procedure TSynIdlSyn.NullProc;
begin
fTokenID := tkNull;
end;
procedure TSynIdlSyn.NumberProc;
begin
inc(Run);
fTokenID := tkNumber;
while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do
begin
case FLine[Run] of
'.': if FLine[Run + 1] = '.' then
Break;
end;
inc(Run);
end;
end; { NumberProc }
procedure TSynIdlSyn.CRProc;
begin
fTokenID := tkSpace;
inc(Run);
if fLine[Run] = #10 then
inc(Run);
end;
procedure TSynIdlSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end;
procedure TSynIdlSyn.CommentOpenProc;
begin
Inc(Run);
if (fLine[Run] = '*') then
begin
fRange := rsComment;
CommentProc;
fTokenID := tkComment;
end
else if (fLine[Run] = '/') then
begin
while not (fLine[Run] in [#0, #10, #13]) do
Inc(Run);
fTokenID := tkComment;
end
else
fTokenID := tkSymbol;
end;
procedure TSynIdlSyn.CommentProc;
begin
case fLine[Run] of
#0: NullProc;
#10: LFProc;
#13: CRProc;
else
begin
fTokenID := tkComment;
repeat
if (fLine[Run] = '*') and
(fLine[Run + 1] = '/') then
begin
Inc(Run, 2);
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 TSynIdlSyn.StringOpenProc;
begin
Inc(Run);
fRange := rsString;
StringProc;
fTokenID := tkString;
end;
procedure TSynIdlSyn.StringProc;
begin
fTokenID := tkString;
repeat
if (fLine[Run] = '"') then
begin
Inc(Run);
fRange := rsUnKnown;
Break;
end
else if (fLine[Run] = '\') then
Inc(Run);
if not (fLine[Run] in [#0, #10, #13]) then
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
procedure TSynIdlSyn.CharOpenProc;
begin
Inc(Run);
fRange := rsChar;
CharProc;
fTokenID := tkString;
end;
procedure TSynIdlSyn.CharProc;
begin
fTokenID := tkString;
repeat
if (fLine[Run] = '''') then
begin
Inc(Run);
fRange := rsUnKnown;
Break;
end;
if not (fLine[Run] in [#0, #10, #13]) then
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
procedure TSynIdlSyn.PreProcessorProc;
var
Directive: String;
begin
Directive := '';
while not (fLine[Run] in [#0, #9, #10, #13, #32]) do
begin
Directive := Directive + fLine[Run];
Inc(Run);
end;
if (AnsiCompareStr(Directive, '#include') = 0) then
fTokenID := tkPreprocessor
else if (AnsiCompareStr(Directive, '#pragma') = 0) then
fTokenID := tkPreprocessor
else
fTokenID := tkIdentifier;
end; { PreProcessorProc }
constructor TSynIdlSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment);
fCommentAttri.Style := [fsItalic];
fCommentAttri.Foreground := clNavy;
AddAttribute(fCommentAttri);
fDatatypeAttri := TSynHighLighterAttributes.Create(SYNS_AttrDatatype);
fDatatypeAttri.Style := [fsBold];
fDatatypeAttri.Foreground := clTeal;
AddAttribute(fDatatypeAttri);
fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier);
AddAttribute(fIdentifierAttri);
fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord);
fKeyAttri.Style := [fsBold];
AddAttribute(fKeyAttri);
fNumberAttri := TSynHighLighterAttributes.Create(SYNS_AttrNumber);
fNumberAttri.Foreground := clBlue;
AddAttribute(fNumberAttri);
fPreprocessorAttri := TSynHighLighterAttributes.Create(SYNS_AttrPreprocessor);
fPreprocessorAttri.Foreground := clRed;
AddAttribute(fPreprocessorAttri);
fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSpace);
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString);
fStringAttri.Foreground := clBlue;
AddAttribute(fStringAttri);
fSymbolAttri := TSynHighLighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fDefaultFilter := SYNS_FilterCORBAIDL;
fRange := rsUnknown;
end;
procedure TSynIdlSyn.SetLine(NewValue: String; LineNumber: Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end;
procedure TSynIdlSyn.IdentProc;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
while Identifiers[fLine[Run]] do
Inc(Run);
end;
procedure TSynIdlSyn.SymbolProc;
begin
Inc(Run);
fTokenID := tkSymbol;
end;
procedure TSynIdlSyn.UnknownProc;
begin
{$IFDEF SYN_MBCSSUPPORT}
if FLine[Run] in LeadBytes then
Inc(Run, 2)
else
{$ENDIF}
inc(Run);
fTokenID := tkUnknown;
end;
procedure TSynIdlSyn.Next;
begin
fTokenPos := Run;
case fRange of
rsComment: CommentProc;
else
begin
fRange := rsUnknown;
fProcTable[fLine[Run]];
end;
end;
end;
function TSynIdlSyn.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 TSynIdlSyn.GetEol: Boolean;
begin
Result := fTokenID = tkNull;
end;
function TSynIdlSyn.GetToken: String;
var
Len: LongInt;
begin
Len := Run - fTokenPos;
SetString(Result, (FLine + fTokenPos), Len);
end;
function TSynIdlSyn.GetTokenID: TtkTokenKind;
begin
Result := fTokenId;
end;
function TSynIdlSyn.GetTokenAttribute: TSynHighLighterAttributes;
begin
case GetTokenID of
tkComment: Result := fCommentAttri;
tkDatatype: Result := fDatatypeAttri;
tkIdentifier: Result := fIdentifierAttri;
tkKey: Result := fKeyAttri;
tkNumber: Result := fNumberAttri;
tkPreprocessor: Result := fPreprocessorAttri;
tkSpace: Result := fSpaceAttri;
tkString: Result := fStringAttri;
tkSymbol: Result := fSymbolAttri;
tkUnknown: Result := fIdentifierAttri;
else
Result := nil;
end;
end;
function TSynIdlSyn.GetTokenKind: integer;
begin
Result := Ord(fTokenId);
end;
function TSynIdlSyn.GetTokenPos: Integer;
begin
Result := fTokenPos;
end;
function TSynIdlSyn.GetIdentChars: TSynIdentChars;
begin
Result := ['_', 'a'..'z', 'A'..'Z'] + TSynSpecialChars;
end;
function TSynIdlSyn.GetSampleSource: string;
begin
Result := '/* CORBA IDL sample source */'#13#10 +
'#include <sample.idl>'#13#10 +
#13#10 +
'const string TestString = "Hello World";'#13#10 +
'const long TestLong = 10;'#13#10 +
#13#10 +
'module TestModule {'#13#10 +
' interface DemoInterface {'#13#10 +
' boolean HelloWorld(in string Message);'#13#10 +
' }'#13#10 +
'}';
end;
function TSynIdlSyn.IsFilterStored: Boolean;
begin
Result := fDefaultFilter <> SYNS_FilterCORBAIDL;
end;
class function TSynIdlSyn.GetLanguageName: string;
begin
Result := SYNS_LangCORBAIDL;
end;
procedure TSynIdlSyn.ResetRange;
begin
fRange := rsUnknown;
end;
procedure TSynIdlSyn.SetRange(Value: Pointer);
begin
fRange := TRangeState(Value);
end;
function TSynIdlSyn.GetRange: Pointer;
begin
Result := Pointer(fRange);
end;
initialization
MakeIdentTable;
{$IFNDEF SYN_CPPB_1}
RegisterPlaceableHighlighter(TSynIdlSyn);
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -