SynEdit: improved bat, ini highlighter by VRODE

git-svn-id: trunk@28770 -
This commit is contained in:
martin 2010-12-19 19:02:56 +00:00
parent 3dffaaee76
commit cdb10f937d
2 changed files with 14 additions and 3 deletions

View File

@ -72,6 +72,8 @@ type
TSynBatSyn = class(TSynCustomHighlighter)
private
fEcho: Boolean;
fIgnoreComment: Boolean;
fLine: PChar;
fLineNumber: Integer;
fProcTable: array[#0..#255] of TProcTableProc;
@ -234,7 +236,7 @@ var
Temp: PChar;
begin
Temp := fToIdent;
if Length(aKey) = fStringLen then
if not fEcho and (Length(aKey) = fStringLen) then
begin
Result := True;
for i := 1 to fStringLen do
@ -291,7 +293,11 @@ end;
function TSynBatSyn.Func31: TtkTokenKind;
begin
if KeyComp('echo') then Result := tkKey else Result := tkIdentifier;
if KeyComp('echo') then begin
Result := tkKey;
fEcho := True;
end
else Result := tkIdentifier;
end;
function TSynBatSyn.Func34: TtkTokenKind;
@ -413,6 +419,8 @@ procedure TSynBatSyn.SetLine({$IFDEF FPC}const {$ENDIF}NewValue: String; LineNum
begin
fLine := PChar(NewValue);
Run := 0;
fEcho := False;
fIgnoreComment := False;
fLineNumber := LineNumber;
Next;
end;
@ -474,7 +482,7 @@ end;
procedure TSynBatSyn.REMCommentProc;
begin
if (FLine[Run+1] in ['E','e']) and (FLine[Run+2] in ['M','m'])
if not fIgnoreComment and (FLine[Run+1] in ['E','e']) and (FLine[Run+2] in ['M','m'])
and (FLine[Run+3] < #33) then //Fiala
begin
fTokenID := tkComment;
@ -522,6 +530,7 @@ procedure TSynBatSyn.Next;
begin
fTokenPos := Run;
fProcTable[fLine[Run]];
if FTokenID <> tkSpace then fIgnoreComment := True;
end;
function TSynBatSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;

View File

@ -174,6 +174,7 @@ begin
fSectionAttri.Style := [fsBold];
AddAttribute(fSectionAttri);
fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrKey);
fKeyAttri.Foreground := clBlue;
AddAttribute(fKeyAttri);
fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
AddAttribute(fNumberAttri);
@ -182,6 +183,7 @@ begin
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
fSymbolAttri.Foreground := clRed;
AddAttribute(fSymbolAttri);
SetAttributesOnChange(@DefHighlightChange);