Added Ctrl+C support (*cough*)
This commit is contained in:
parent
c3c26681e1
commit
80142da589
25
UApp.pas
25
UApp.pas
|
@ -26,7 +26,7 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, CustApp, RegExpr, Math,
|
Classes, SysUtils, CustApp, RegExpr, Math,
|
||||||
UFilter, UWriter;
|
UFilter, UWriter, Crt;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -48,6 +48,8 @@ type
|
||||||
//Logfile handling
|
//Logfile handling
|
||||||
procedure DumpFile(AFileName: String);
|
procedure DumpFile(AFileName: String);
|
||||||
procedure PollFile(AFileName: String);
|
procedure PollFile(AFileName: String);
|
||||||
|
//Key Handling
|
||||||
|
function CheckQuit: Boolean;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
@ -236,10 +238,13 @@ begin
|
||||||
Reset(logFile);
|
Reset(logFile);
|
||||||
|
|
||||||
// Filter log
|
// Filter log
|
||||||
while not EOF(logFile) do
|
while (not Terminated) and (not EOF(logFile)) do
|
||||||
begin
|
begin
|
||||||
Readln(logFile, line);
|
Readln(logFile, line);
|
||||||
FilterLine(line);
|
FilterLine(line);
|
||||||
|
|
||||||
|
if CheckQuit then
|
||||||
|
Terminate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
CloseFile(logFile);
|
CloseFile(logFile);
|
||||||
|
@ -263,7 +268,7 @@ begin
|
||||||
bufPos := 0;
|
bufPos := 0;
|
||||||
bufMax := 0;
|
bufMax := 0;
|
||||||
lastSize := 0;
|
lastSize := 0;
|
||||||
while true do
|
while not Terminated do
|
||||||
begin
|
begin
|
||||||
currentSize := FileSize(f);
|
currentSize := FileSize(f);
|
||||||
if currentSize > lastSize then
|
if currentSize > lastSize then
|
||||||
|
@ -333,10 +338,24 @@ begin
|
||||||
|
|
||||||
lastSize := currentSize;
|
lastSize := currentSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
|
|
||||||
|
if CheckQuit then
|
||||||
|
Terminate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// This is necessary since we use CRT, which captures all keys.
|
||||||
|
// Therefore Ctrl+C will by default no longer send SIGINT.
|
||||||
|
function TLogFilterApplication.CheckQuit: Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if KeyPressed then
|
||||||
|
if ReadKey = ^C then
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TLogFilterApplication.Create(TheOwner: TComponent);
|
constructor TLogFilterApplication.Create(TheOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
|
|
Loading…
Reference in New Issue