parent
bd0b6bc3f4
commit
3e3ba96fb9
|
@ -0,0 +1,2 @@
|
|||
lib/
|
||||
*.lps
|
2
UApp.pas
2
UApp.pas
|
@ -250,6 +250,8 @@ begin
|
|||
Writeln(' specifies the filename with filter commands');
|
||||
Writeln(' -f --logfile=<filename>');
|
||||
Writeln(' specifies the logfile to be parsed');
|
||||
Writeln(' --html=<filename>');
|
||||
Writeln(' outputs filtered results in a formatted HTML file');
|
||||
Writeln(' -h --help');
|
||||
Writeln(' show this help screen');
|
||||
end;
|
||||
|
|
48
UWriter.pas
48
UWriter.pas
|
@ -5,7 +5,7 @@ unit UWriter;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, UFilter, crt, fgl;
|
||||
Classes, SysUtils, UFilter, crt, fgl, htmlelements;
|
||||
|
||||
type
|
||||
TWriter = class
|
||||
|
@ -38,6 +38,18 @@ type
|
|||
|
||||
implementation
|
||||
|
||||
const
|
||||
htmlColors: array[0..15] of String[6] = (
|
||||
'000000', '000066', '003300', '0099CC', '990000', '990033', '663300',
|
||||
'CCCCCC', '666666', '66CCFF', '66FF66', '99FFCC', 'FF8080', 'FF80B2',
|
||||
'FFFF00', 'FFFFFF'
|
||||
);
|
||||
cssColors: array[0..15] of String = (
|
||||
'Black', 'Blue', 'Green', 'Cyan', 'Red', 'Magenta', 'Brown', 'LightGray',
|
||||
'DarkGray', 'LightBlue', 'LightGreen', 'LightCyan', 'LightRed',
|
||||
'LightMagenta', 'Yellow', 'White'
|
||||
);
|
||||
|
||||
{ THTMLWriter }
|
||||
|
||||
procedure THTMLWriter.WriteLine(AContent: String);
|
||||
|
@ -50,20 +62,50 @@ constructor THTMLWriter.Create(AFileName: String);
|
|||
begin
|
||||
FFileStream := TFileStream.Create(AFileName, fmCreate);
|
||||
WriteLine('<html>');
|
||||
WriteLine('<body>');
|
||||
WriteLine('<body><samp>');
|
||||
end;
|
||||
|
||||
destructor THTMLWriter.Destroy;
|
||||
begin
|
||||
WriteLine('</body>');
|
||||
WriteLine('</samp></body>');
|
||||
WriteLine('</html>');
|
||||
FFileStream.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure THTMLWriter.WriteContent(AContent: String; AHighlights: THighlights);
|
||||
var
|
||||
matchPos, offset, lastPos: Integer;
|
||||
highlight: THighlight;
|
||||
htmlContent, style: String;
|
||||
begin
|
||||
lastPos := 1;
|
||||
htmlContent := '';
|
||||
|
||||
for highlight in AHighlights do
|
||||
begin
|
||||
matchPos := highlight.Start;
|
||||
offset := highlight.Length;
|
||||
htmlContent := htmlContent + EscapeHTML(Copy(AContent, lastPos,
|
||||
matchPos - lastPos));
|
||||
|
||||
style := '';
|
||||
if highlight.FGColor < 16 then
|
||||
style := 'color: ' + cssColors[highlight.FGColor] + ';';
|
||||
if highlight.BGColor < 15 then
|
||||
style := style + 'background-color: ' + cssColors[highlight.BGColor] + ';';
|
||||
|
||||
if style <> '' then
|
||||
htmlContent := htmlContent + '<span style="' + style + '">';
|
||||
htmlContent := htmlContent + EscapeHTML(Copy(AContent, matchPos, offset));
|
||||
if style <> '' then
|
||||
htmlContent := htmlContent + '</span>';
|
||||
lastPos := matchPos + offset;
|
||||
end;
|
||||
|
||||
htmlContent := htmlContent + EscapeHTML(Copy(AContent, lastPos, Length(AContent)));
|
||||
|
||||
WriteLine(htmlContent + '<br/>');
|
||||
end;
|
||||
|
||||
{ TConsoleWriter }
|
||||
|
|
Loading…
Reference in New Issue