diff --git a/UApp.pas b/UApp.pas index 7bf122b..fa3a00c 100644 --- a/UApp.pas +++ b/UApp.pas @@ -40,6 +40,8 @@ type FCommandFileName: String; FLogFileName: String; FWriter: TWriterList; + FSeparator: String; + FFirstMatch: Boolean; procedure DoRun; override; procedure ProcessCommand(ACommand, AParams: String); procedure WriteContent(AContent: String; AFilters: TFilterList; @@ -145,6 +147,9 @@ begin if HasOption('html') then FWriter.Add(THTMLWriter.Create(GetOptionValue('html'))); + // Whatever happens next, we haven't had a match yet. + FFirstMatch := True; + if HasOption('p', 'poll') then PollFile(FLogFileName) else @@ -177,6 +182,10 @@ begin begin FCurrentLineFilter.SetFollowUp(AParams); end; + 'separator': + begin + FSeparator := StringReplace(AParams, '\n', sLineBreak, [rfReplaceAll]); + end; end; end; @@ -205,7 +214,11 @@ begin offset := AFilters[i].Expression.MatchLen[0]; 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 if (matchPos + offset < AGroupRanges[group].StartIdx) or (matchPos > AGroupRanges[group].EndIdx) then @@ -222,8 +235,7 @@ begin {$endif} end else begin - highlight.Start := matchPos; - highlight.Length := offset; + continue; end; highlight.FGColor := AFilters[i].FGColor; @@ -269,8 +281,14 @@ begin begin if lineFilter.Matches(ALine, groupRanges) then begin + if (FSeparator <> '') and (not FFirstMatch) then + WriteLn(FSeparator); FCurrentLineFilter := lineFilter; //Remember the last matching filter WriteContent(ALine, lineFilter.Filters, groupRanges); + + //Now it's definitely no longer a first match ... + FFirstMatch := False; + Break; end; end;