Files
0linux/spackgui/frmlogfile.pas
2023-10-06 15:59:41 +02:00

195 lines
5.4 KiB
ObjectPascal

{
********************************************************************************
SPackGui
Copyright (C) 2012-2013 Geoffray Levasseur <geoffray.levasseurbrandin@numericable.fr>.
Copyright (C) <date> <add your name and mail address here>
http://www.geoffray-levasseur.org/
http://0.tuxfamilly.org/
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
********************************************************************************
Description:
logfile viewer
********************************************************************************
}
unit frmLogFile;
{$include ../common/defines.inc}
interface
uses
Classes, SysUtils, FileUtil, SynEdit, SynHighlighterAny, Forms, Controls,
Graphics, Dialogs, Menus;
type
{ TfLogView }
TfLogView = class(TForm)
dlgFont: TFontDialog;
mnuPopSelectAll: TMenuItem;
mnuPopSep1: TMenuItem;
mnuPopCopy: TMenuItem;
mnuFont: TMenuItem;
mnuSep4: TMenuItem;
mnuUpdate: TMenuItem;
mnuSep3: TMenuItem;
mmMainMenu: TMainMenu;
mnuCopy: TMenuItem;
mnuSep2: TMenuItem;
mnuSelectAll: TMenuItem;
mnuEdit: TMenuItem;
mnuClose: TMenuItem;
mnuSep1: TMenuItem;
mnuSaveAs: TMenuItem;
mnuFile: TMenuItem;
dlgSave: TSaveDialog;
pmEditor: TPopupMenu;
seEditor: TSynEdit;
SynAnySyn: TSynAnySyn;
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure mnuCloseClick(Sender: TObject);
procedure mnuCopyClick(Sender: TObject);
procedure mnuFontClick(Sender: TObject);
procedure mnuSaveAsClick(Sender: TObject);
procedure mnuSelectAllClick(Sender: TObject);
procedure mnuUpdateClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
fLogView: TfLogView;
implementation
{$R *.lfm}
uses
uDebug, uIconManager, uCommon, uStrings;
{ TfLogView }
procedure TfLogView.mnuUpdateClick(Sender: TObject);
var
X, Y: Integer;
begin
PrintLnDbg(Format(rsInfoLoadingLogFile, [sLogFileName]), vlHigh);
X := 0;
Y := 0;
if seEditor.Lines.Count <> 0 then
begin
X := seEditor.CaretX;
Y := seEditor.CaretY;
seEditor.ClearAll;
end;
Flush(tLogFile);
seEditor.Lines.LoadFromFile(sLogFileName);
seEditor.CaretX := X;
seEditor.CaretY := Y;
end;
procedure TfLogView.mnuSelectAllClick(Sender: TObject);
begin
seEditor.SelectAll;
end;
procedure TfLogView.mnuCopyClick(Sender: TObject);
begin
seEditor.CopyToClipboard;
end;
procedure TfLogView.mnuFontClick(Sender: TObject);
begin
dlgFont.Options := [fdEffects, fdFixedPitchOnly, fdForceFontExist];
dlgFont.Font := seEditor.Font;
if dlgFont.Execute then
begin
seEditor.Font := dlgFont.Font;
iniMain.WriteString(Self.Name, rsConfNameLogFontName, seEditor.Font.Name);
iniMain.WriteInteger(Self.Name, rsConfNameLogFontSize, seEditor.Font.Size);
end;
end;
procedure TfLogView.mnuCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfLogView.FormCreate(Sender: TObject);
begin
mmMainMenu.Images := ilDefault;
mnuCopy.ImageIndex := icCopy;
mnuClose.ImageIndex := icClose;
mnuSaveAs.ImageIndex := icSave;
mnuSelectAll.ImageIndex := icSelectAll;
mnuUpdate.ImageIndex := icRefresh;
mnuFont.ImageIndex := icFontSettings;
LoadWindowGeometry(Self);
seEditor.Font.Name := iniMain.ReadString(Self.Name, rsConfNameLogFontName,
seEditor.Font.Name);
seEditor.Font.Size := iniMain.ReadInteger(Self.Name, rsConfNameLogFontSize,
seEditor.Font.Size);
SynAnySyn.KeyWords.Add(rsBaseDebug);
SynAnySyn.KeyWords.Add(rsBaseError);
SynAnySyn.KeyWords.Add(rsBaseWarning);
SynAnySyn.KeyWords.Add(rsBaseInfo);
end;
procedure TfLogView.FormActivate(Sender: TObject);
begin
mnuUpdateClick(nil);
end;
procedure TfLogView.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
try
SaveWindowGeometry(Self);
except
PrintLnDbg(rsErrorCannotSaveConf, vlLow);
end;
end;
procedure TfLogView.mnuSaveAsClick(Sender: TObject);
begin
if dlgSave.Execute then
seEditor.Lines.SaveToFile(dlgSave.FileName);
end;
end.