📄 synhighlighterinno.pas
字号:
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
fStringAttri.Foreground := clBlue;
AddAttribute(fStringAttri);
fConstantAttri := TSynHighlighterAttributes.Create('Constant');
fConstantAttri.Style := [fsBold, fsItalic];
fConstantAttri.Foreground := clTeal;
AddAttribute(fConstantAttri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
//Parameters
fParamAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor);
fParamAttri.Style := [fsBold];
fParamAttri.Foreground := clOlive;
AddAttribute(fParamAttri);
fSectionAttri := TSynHighlighterAttributes.Create(SYNS_AttrSection);
fSectionAttri.Style := [fsBold];
fSectionAttri.Foreground := clTeal;
AddAttribute(fSectionAttri);
fDirectiveAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective);
fDirectiveAttri.Foreground := clRed;
AddAttribute(fDirectiveAttri);
SetAttributesOnChange(DefHighlightChange);
EnumerateKeywords(Ord(tkKey), Keywords, IdentChars, DoAddKeyword);
EnumerateKeywords(Ord(tkParameter), Parameters, IdentChars, DoAddKeyword);
EnumerateKeywords(Ord(tkKeyOrParameter), KeyOrParameter, IdentChars, //mh 2001-02-07
DoAddKeyword);
MakeMethodTables;
fDefaultFilter := SYNS_FilterInno;
end;
destructor TSynInnoSyn.Destroy;
begin
fKeywords.Free;
inherited Destroy;
end;
procedure TSynInnoSyn.SetLine(NewValue: string; LineNumber: Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end;
procedure TSynInnoSyn.SymbolProc;
var
I: Integer;
begin
if fLine[Run] = '#' then begin
for I := Run-1 downto 0 do
if fLine[I] > ' ' then begin
// If the '#' is not the first non-whitespace character on the
// line, then it isn't the start of a directive.
fTokenID := tkSymbol;
inc(Run);
Exit;
end;
fTokenID := tkDirective;
repeat
Inc(Run);
until (fLine[Run] in [#0, #10, #13]);
end
else begin
fTokenID := tkSymbol;
inc(Run);
end;
end;
procedure TSynInnoSyn.CRProc;
begin
fTokenID := tkSpace;
inc(Run);
if fLine[Run] = #10 then inc(Run);
end;
procedure TSynInnoSyn.EqualProc;
begin
// If any word has equal (=) symbol,
// then the immediately followed text is treated as string
// (though it does not have quotes)
fTokenID := tkString;
repeat
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
procedure TSynInnoSyn.IdentProc;
var
LookAhead: integer;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
{begin} //mh 2001-02-07
// while Identifiers[fLine[Run]] do inc(Run);
if fTokenID = tkKeyOrParameter then begin
LookAhead := Run;
while fLine[LookAhead] in [#9, ' '] do
Inc(LookAhead);
if fLine[LookAhead] = ':' then
fTokenID := tkKey
else
fTokenID := tkParameter;
end;
{end} //mh 2001-02-07
end;
procedure TSynInnoSyn.SectionProc;
begin
// if it is not column 0 mark as tkParameter and get out of here
if Run > 0 then
begin
fTokenID := tkUnknown;
inc(Run);
Exit;
end;
// this is column 0 ok it is a Section
fTokenID := tkSection;
repeat
Inc(Run);
if fLine[Run] = ']' then
begin
Inc(Run);
break;
end;
until fLine[Run] in [#0, #10, #13];
end;
procedure TSynInnoSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end;
procedure TSynInnoSyn.NullProc;
begin
fTokenID := tkNull;
end;
procedure TSynInnoSyn.NumberProc;
begin
fTokenID := tkNumber;
repeat
Inc(Run);
until not (fLine[Run] in ['0'..'9']);
end;
procedure TSynInnoSyn.ConstantProc;
var
BraceLevel, LastOpenBrace: Integer;
begin
{ Much of this is based on code from the SkipPastConst function in IS's
CmnFunc2 unit. [jr] }
if fLine[Run + 1] = '{' then begin
{ '{{' is not a constant }
fTokenID := tkUnknown;
Inc(Run, 2);
Exit;
end;
fTokenID := tkConstant;
BraceLevel := 1;
LastOpenBrace := Low(Integer);
repeat
Inc(Run);
case fLine[Run] of
'{': begin
if LastOpenBrace <> Run-1 then begin
Inc(BraceLevel);
LastOpenBrace := Run;
end
else
{ Skip over '{{' when in an embedded constant }
Dec(BraceLevel);
end;
'}': begin
Dec (BraceLevel);
if BraceLevel = 0 then begin
Inc(Run);
Break;
end;
end;
{$IFDEF SYN_MBCSSUPPORT}
else
if fLine[Run] in LeadBytes then
Inc(Run);
{$ENDIF}
end;
until fLine[Run] in [#0, #10, #13];
end;
procedure TSynInnoSyn.SpaceProc;
begin
fTokenID := tkSpace;
repeat
Inc(Run);
until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]);
end;
procedure TSynInnoSyn.SemiColonProc;
var
I: Integer;
begin
for I := Run-1 downto 0 do
if fLine[I] > ' ' then begin
// If the semicolon is not the first non-whitespace character on the
// line, then it isn't the start of a comment.
fTokenID := tkUnknown;
inc(Run);
Exit;
end;
fTokenID := tkComment;
repeat
Inc(Run);
until (fLine[Run] in [#0, #10, #13]);
end;
procedure TSynInnoSyn.StringProc;
begin
fTokenID := tkString;
{begin} //mh 2001-02-07
(*
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);
*)
repeat
Inc(Run);
if fLine[Run] = '"' then begin
Inc(Run);
if fLine[Run] <> '"' then // embedded "" does not end the string
break;
end;
until fLine[Run] in [#0, #10, #13];
{end} //mh 2001-02-07
end;
procedure TSynInnoSyn.UnknownProc;
begin
inc(Run);
fTokenID := tkUnknown;
end;
procedure TSynInnoSyn.Next;
begin
fTokenPos := Run;
fProcTable[fLine[Run]];
end;
function TSynInnoSyn.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 TSynInnoSyn.GetEol: Boolean;
begin
Result := (fTokenId = tkNull);
end;
function TSynInnoSyn.GetToken: String;
var
Len: LongInt;
begin
Len := Run - fTokenPos;
SetString(Result, (FLine + fTokenPos), Len);
end;
function TSynInnoSyn.GetTokenAttribute: TSynHighlighterAttributes;
begin
case fTokenID of
tkComment: Result := fCommentAttri;
tkParameter: Result := fParamAttri;
tkSection: Result := fSectionAttri;
tkIdentifier: Result := fIdentifierAttri;
tkKey: Result := fKeyAttri;
tkNumber: Result := fNumberAttri;
tkSpace: Result := fSpaceAttri;
tkString: Result := fStringAttri;
tkConstant: Result := fConstantAttri;
tkSymbol: Result := fSymbolAttri;
tkUnknown: Result := fIdentifierAttri;
tkDirective: Result := fDirectiveAttri;
else
Result := nil;
end;
end;
function TSynInnoSyn.GetTokenKind: integer;
begin
Result := Ord(fTokenId);
end;
function TSynInnoSyn.GetTokenID: TtkTokenKind;
begin
Result := fTokenId;
end;
function TSynInnoSyn.GetTokenPos: Integer;
begin
Result := fTokenPos;
end;
function TSynInnoSyn.GetIdentChars: TSynIdentChars;
begin
Result := TSynValidStringChars;
end;
{$IFNDEF SYN_CPPB_1} class {$ENDIF}
function TSynInnoSyn.GetLanguageName: string;
begin
Result := SYNS_LangInno;
end;
procedure TSynInnoSyn.DoAddKeyword(AKeyword: string; AKind: integer);
var
HashValue: integer;
begin
HashValue := KeyHash(PChar(AKeyword));
fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind);
end;
initialization
MakeIdentTable;
{$IFNDEF SYN_CPPB_1}
RegisterPlaceableHighlighter(TSynInnoSyn);
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -