📄 synhighlightervb.pas
字号:
begin
if KeyComp('variant') then Result := tkKey else
if KeyComp('datepart') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func87: TtkTokenKind;
begin
if KeyComp('string') then Result := tkKey else
if KeyComp('nothing') then Result := tkKey else
if KeyComp('isnull') then Result := tkKey else
if KeyComp('getobject') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func89: TtkTokenKind;
begin
if KeyComp('option') then Result := tkKey else
if KeyComp('option') then Result := tkKey else
if KeyComp('option') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func91: TtkTokenKind;
begin
if KeyComp('private') then Result := tkKey else
if KeyComp('datevalue') then Result := tkKey else
if KeyComp('fileattr') then Result := tkKey else
if KeyComp('isarray') then Result := tkKey else
if KeyComp('fileattr') then Result := tkKey else
if KeyComp('filecopy') then Result := tkKey else
if KeyComp('getattr') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func94: TtkTokenKind;
begin
if KeyComp('dateserial') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func96: TtkTokenKind;
begin
if KeyComp('return') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func97: TtkTokenKind;
begin
if KeyComp('environ') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func98: TtkTokenKind;
begin
if KeyComp('explicit') then Result := tkKey else
if KeyComp('explicit') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func99: TtkTokenKind;
begin
if KeyComp('typename') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func101: TtkTokenKind;
begin
if KeyComp('system') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func102: TtkTokenKind;
begin
if KeyComp('function') then Result := tkKey else
if KeyComp('version') then Result := tkKey else
if KeyComp('sendkeys') then Result := tkKey else
if KeyComp('iserror') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func103: TtkTokenKind;
begin
if KeyComp('setattr') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func104: TtkTokenKind;
begin
if KeyComp('doevents') then Result := tkKey else
if KeyComp('strcomp') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func105: TtkTokenKind;
begin
if KeyComp('randomize') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func107: TtkTokenKind;
begin
if KeyComp('isempty') then Result := tkKey else
if KeyComp('currency') then Result := tkKey else
if KeyComp('vartype') then Result := tkKey else
if KeyComp('createobject') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func108: TtkTokenKind;
begin
if KeyComp('timevalue') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func109: TtkTokenKind;
begin
if KeyComp('filedatetime') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func111: TtkTokenKind;
begin
if KeyComp('isnumeric') then Result := tkKey else
if KeyComp('strconv') then Result := tkKey else
if KeyComp('timeserial') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func114: TtkTokenKind;
begin
if KeyComp('appactivate') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func116: TtkTokenKind;
begin
if KeyComp('attribute') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func118: TtkTokenKind;
begin
if KeyComp('ismissing') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.Func133: TtkTokenKind;
begin
if KeyComp('property') then Result := tkKey else Result := tkIdentifier;
end;
function TSynVBSyn.AltFunc: TtkTokenKind;
begin
Result := tkIdentifier;
end;
function TSynVBSyn.IdentKind(MayBe: PChar): TtkTokenKind;
var
HashKey: Integer;
begin
fToIdent := MayBe;
HashKey := KeyHash(MayBe);
if HashKey < 134 then Result := fIdentFuncTable[HashKey] else Result := tkIdentifier;
end;
procedure TSynVBSyn.MakeMethodTables;
var
I: Char;
begin
for I := #0 to #255 do
case I of
'&': fProcTable[I] := SymbolProc;
#39: fProcTable[I] := ApostropheProc;
'}': fProcTable[I] := SymbolProc;
'{': fProcTable[I] := SymbolProc;
#13: fProcTable[I] := CRProc;
':': fProcTable[I] := SymbolProc;
',': fProcTable[I] := SymbolProc;
'#': fProcTable[I] := DateProc;
'=': fProcTable[I] := SymbolProc;
'^': fProcTable[I] := SymbolProc;
'>': fProcTable[I] := GreaterProc;
'A'..'Z', 'a'..'z', '_': fProcTable[I] := IdentProc;
#10: fProcTable[I] := LFProc;
'<': fProcTable[I] := LowerProc;
'-': fProcTable[I] := SymbolProc;
#0: fProcTable[I] := NullProc;
'0'..'9': fProcTable[I] := NumberProc;
'+': fProcTable[I] := SymbolProc;
'.': fProcTable[I] := SymbolProc;
')': fProcTable[I] := SymbolProc;
'(': fProcTable[I] := SymbolProc;
';': fProcTable[I] := SymbolProc;
'/': fProcTable[I] := SymbolProc;
#1..#9, #11, #12, #14..#32: fProcTable[I] := SpaceProc;
'*': fProcTable[I] := SymbolProc;
#34: fProcTable[I] := StringProc;
else fProcTable[I] := UnknownProc;
end;
end;
constructor TSynVBSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment);
fCommentAttri.Style:= [fsItalic];
AddAttribute(fCommentAttri);
fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier);
AddAttribute(fIdentifierAttri);
fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord);
fKeyAttri.Style:= [fsBold];
AddAttribute(fKeyAttri);
fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
AddAttribute(fNumberAttri);
fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fDefaultFilter := SYNS_FilterVisualBASIC;
end;
procedure TSynVBSyn.SetLine(NewValue: String; LineNumber: Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end;
procedure TSynVBSyn.SymbolProc;
begin
inc(Run);
fTokenId := tkSymbol;
end;
procedure TSynVBSyn.ApostropheProc;
begin
fTokenID := tkComment;
repeat
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
procedure TSynVBSyn.CRProc;
begin
fTokenID := tkSpace;
Inc(Run);
if fLine[Run] = #10 then Inc(Run);
end;
procedure TSynVBSyn.DateProc;
begin
fTokenID := tkString;
repeat
case FLine[Run] of
#0, #10, #13: break;
end;
inc(Run);
until FLine[Run] = '#';
if FLine[Run] <> #0 then inc(Run);
end;
procedure TSynVBSyn.GreaterProc;
begin
fTokenID := tkSymbol;
Inc(Run);
if fLine[Run] = '=' then Inc(Run);
end;
procedure TSynVBSyn.IdentProc;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
while Identifiers[fLine[Run]] do inc(Run);
end;
procedure TSynVBSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end;
procedure TSynVBSyn.LowerProc;
begin
fTokenID := tkSymbol;
Inc(Run);
if fLine[Run] in ['=', '>'] then Inc(Run);
end;
procedure TSynVBSyn.NullProc;
begin
fTokenID := tkNull;
end;
procedure TSynVBSyn.NumberProc;
begin
inc(Run);
fTokenID := tkNumber;
while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do inc(Run);
end;
procedure TSynVBSyn.SpaceProc;
begin
inc(Run);
fTokenID := tkSpace;
while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run);
end;
procedure TSynVBSyn.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;
end;
inc(Run);
until FLine[Run] = #34;
if FLine[Run] <> #0 then inc(Run);
end;
procedure TSynVBSyn.UnknownProc;
begin
{$IFDEF SYN_MBCSSUPPORT}
if FLine[Run] in LeadBytes then
Inc(Run, 2)
else
{$ENDIF}
inc(Run);
fTokenID := tkUnknown;
end;
procedure TSynVBSyn.Next;
begin
fTokenPos := Run;
fProcTable[fLine[Run]];
end;
function TSynVBSyn.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 TSynVBSyn.GetEol: Boolean;
begin
Result := fTokenID = tkNull;
end;
function TSynVBSyn.GetToken: String;
var
Len: LongInt;
begin
Len := Run - fTokenPos;
SetString(Result, (FLine + fTokenPos), Len);
end;
function TSynVBSyn.GetTokenID: TtkTokenKind;
begin
Result := fTokenId;
end;
function TSynVBSyn.GetTokenAttribute: TSynHighlighterAttributes;
begin
case GetTokenID of
tkComment: Result := fCommentAttri;
tkIdentifier: Result := fIdentifierAttri;
tkKey: Result := fKeyAttri;
tkNumber: Result := fNumberAttri;
tkSpace: Result := fSpaceAttri;
tkString: Result := fStringAttri;
tkSymbol: Result := fSymbolAttri;
tkUnknown: Result := fIdentifierAttri;
else Result := nil;
end;
end;
function TSynVBSyn.GetTokenKind: integer;
begin
Result := Ord(fTokenId);
end;
function TSynVBSyn.GetTokenPos: Integer;
begin
Result := fTokenPos;
end;
function TSynVBSyn.GetIdentChars: TSynIdentChars;
begin
Result := TSynValidStringChars;
end;
function TSynVBSyn.IsFilterStored: Boolean;
begin
Result := fDefaultFilter <> SYNS_FilterVisualBASIC;
end;
class function TSynVBSyn.GetLanguageName: string;
begin
Result := SYNS_LangVisualBASIC;
end;
function TSynVBSyn.GetSampleSource: String;
begin
Result := ''' Syntax highlighting'#13#10+
'Function PrintNumber'#13#10+
' Dim Number'#13#10+
' Dim X'#13#10+
''#13#10+
' Number = 123456'#13#10+
' Response.Write "The number is " & number'#13#10+
''#13#10+
' For I = 0 To Number'#13#10+
' X = X + &h4c'#13#10+
' X = X - &o8'#13#10+
' X = X + 1.0'#13#10+
' Next'#13#10+
''#13#10+
' I = I + @; '' illegal character'#13#10+
'End Function';
end;
initialization
MakeIdentTable;
{$IFNDEF SYN_CPPB_1}
RegisterPlaceableHighlighter(TSynVBSyn);
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -