* Fixed highlighting being a bit too optimistic
* Added support for separator lines
This commit is contained in:
parent
685e9eafc1
commit
deb749f44a
24
UApp.pas
24
UApp.pas
|
@ -40,6 +40,8 @@ type
|
||||||
FCommandFileName: String;
|
FCommandFileName: String;
|
||||||
FLogFileName: String;
|
FLogFileName: String;
|
||||||
FWriter: TWriterList;
|
FWriter: TWriterList;
|
||||||
|
FSeparator: String;
|
||||||
|
FFirstMatch: Boolean;
|
||||||
procedure DoRun; override;
|
procedure DoRun; override;
|
||||||
procedure ProcessCommand(ACommand, AParams: String);
|
procedure ProcessCommand(ACommand, AParams: String);
|
||||||
procedure WriteContent(AContent: String; AFilters: TFilterList;
|
procedure WriteContent(AContent: String; AFilters: TFilterList;
|
||||||
|
@ -145,6 +147,9 @@ begin
|
||||||
if HasOption('html') then
|
if HasOption('html') then
|
||||||
FWriter.Add(THTMLWriter.Create(GetOptionValue('html')));
|
FWriter.Add(THTMLWriter.Create(GetOptionValue('html')));
|
||||||
|
|
||||||
|
// Whatever happens next, we haven't had a match yet.
|
||||||
|
FFirstMatch := True;
|
||||||
|
|
||||||
if HasOption('p', 'poll') then
|
if HasOption('p', 'poll') then
|
||||||
PollFile(FLogFileName)
|
PollFile(FLogFileName)
|
||||||
else
|
else
|
||||||
|
@ -177,6 +182,10 @@ begin
|
||||||
begin
|
begin
|
||||||
FCurrentLineFilter.SetFollowUp(AParams);
|
FCurrentLineFilter.SetFollowUp(AParams);
|
||||||
end;
|
end;
|
||||||
|
'separator':
|
||||||
|
begin
|
||||||
|
FSeparator := StringReplace(AParams, '\n', sLineBreak, [rfReplaceAll]);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -205,7 +214,11 @@ begin
|
||||||
offset := AFilters[i].Expression.MatchLen[0];
|
offset := AFilters[i].Expression.MatchLen[0];
|
||||||
|
|
||||||
group := AFilters[i].Group;
|
group := AFilters[i].Group;
|
||||||
if group < Length(AGroupRanges) then
|
if group = $FF then
|
||||||
|
begin
|
||||||
|
highlight.Start := matchPos;
|
||||||
|
highlight.Length := offset;
|
||||||
|
end else if group < Length(AGroupRanges) then
|
||||||
begin
|
begin
|
||||||
if (matchPos + offset < AGroupRanges[group].StartIdx) or
|
if (matchPos + offset < AGroupRanges[group].StartIdx) or
|
||||||
(matchPos > AGroupRanges[group].EndIdx) then
|
(matchPos > AGroupRanges[group].EndIdx) then
|
||||||
|
@ -222,8 +235,7 @@ begin
|
||||||
{$endif}
|
{$endif}
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
highlight.Start := matchPos;
|
continue;
|
||||||
highlight.Length := offset;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
highlight.FGColor := AFilters[i].FGColor;
|
highlight.FGColor := AFilters[i].FGColor;
|
||||||
|
@ -269,8 +281,14 @@ begin
|
||||||
begin
|
begin
|
||||||
if lineFilter.Matches(ALine, groupRanges) then
|
if lineFilter.Matches(ALine, groupRanges) then
|
||||||
begin
|
begin
|
||||||
|
if (FSeparator <> '') and (not FFirstMatch) then
|
||||||
|
WriteLn(FSeparator);
|
||||||
FCurrentLineFilter := lineFilter; //Remember the last matching filter
|
FCurrentLineFilter := lineFilter; //Remember the last matching filter
|
||||||
WriteContent(ALine, lineFilter.Filters, groupRanges);
|
WriteContent(ALine, lineFilter.Filters, groupRanges);
|
||||||
|
|
||||||
|
//Now it's definitely no longer a first match ...
|
||||||
|
FFirstMatch := False;
|
||||||
|
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue