Fix adjusting linenumbers in SQL log when user changed the max linecount in preferences.

This commit is contained in:
Ansgar Becker
2007-10-10 18:17:35 +00:00
parent 07564f217e
commit b7b652da67
2 changed files with 23 additions and 9 deletions

View File

@ -612,6 +612,7 @@ type
function GetVTreeDataArray( VT: TBaseVirtualTree ): PVTreeDataArray;
procedure ActivateFileLogging;
procedure DeactivateFileLogging;
procedure TrimSQLLog;
end;
type
@ -1208,13 +1209,7 @@ begin
SynMemoSQLLog.Lines.Add( String(msg) );
// Delete first line(s)
while SynMemoSQLLog.Lines.Count > prefLogsqlnum do
begin
SynMemoSQLLog.Lines.Delete(0);
// Increase first displayed number in gutter so it doesn't lie about the log entries
SynMemoSQLLog.Gutter.LineNumberStart := SynMemoSQLLog.Gutter.LineNumberStart + 1;
end;
TrimSQLLog;
// Scroll to last line and repaint
SynMemoSQLLog.GotoLineAndCenter( SynMemoSQLLog.Lines.Count );
@ -1231,6 +1226,26 @@ begin
end;
{**
Delete first line(s) in SQL log and adjust LineNumberStart in gutter
Called by LogSQL and preferences dialog
}
procedure TMDIChild.TrimSQLLog;
var
i : Integer;
begin
i := 0;
while SynMemoSQLLog.Lines.Count > prefLogsqlnum do
begin
SynMemoSQLLog.Lines.Delete(0);
inc(i);
end;
// Increase first displayed number in gutter so it doesn't lie about the log entries
if i > 0 then
SynMemoSQLLog.Gutter.LineNumberStart := SynMemoSQLLog.Gutter.LineNumberStart + i;
end;
procedure TMDIChild.ReadDatabasesAndTables(Sender: TObject);
var
tnode : TTreeNode;

View File

@ -205,8 +205,6 @@ begin
cwin.SynSQLSyn1.CommentAttri.Foreground := self.pnlComments.Color;
cwin.SynSQLSyn1.TablenameAttri.Foreground := self.pnlTablenames.Color;
cwin.SynMemoQuery.ActiveLineColor := self.pnlActiveLine.Color;
while cwin.SynMemoSQLLog.Lines.Count > updownLogSQLNum.Position do
cwin.SynMemoSQLLog.Lines.Delete(0);
cwin.gridData.Font := self.Panel8.font;
cwin.gridQuery.Font := self.Panel8.font;
cwin.DBMemo1.Font := self.Panel8.font;
@ -216,6 +214,7 @@ begin
cwin.gridQuery.Options := cwin.gridQuery.Options + [dgAlwaysShowEditor];
cwin.prefRememberFilters := chkRememberFilters.Checked;
cwin.prefLogsqlnum := self.updownLogSQLNum.Position;
cwin.TrimSQLLog;
if chkLogToFile.Checked then
cwin.ActivateFileLogging
else if cwin.prefLogToFile then