From 31db8b4b61df270cb30a30b0207d84a68ee4791b Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 8 Mar 2010 07:10:49 +0000 Subject: [PATCH] Display focused row and column number of active grid in status bar --- source/main.dfm | 1 + source/main.pas | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/source/main.dfm b/source/main.dfm index 3106cbf6..87627dba 100644 --- a/source/main.dfm +++ b/source/main.dfm @@ -1248,6 +1248,7 @@ object MainForm: TMainForm OnEditing = DataGridEditing OnEnter = ValidateControls OnExit = ValidateControls + OnFocusChanged = DataGridFocusChanged OnFocusChanging = DataGridFocusChanging OnGetText = AnyGridGetText OnPaintText = AnyGridPaintText diff --git a/source/main.pas b/source/main.pas index e616d632..7b0410e0 100644 --- a/source/main.pas +++ b/source/main.pas @@ -780,6 +780,7 @@ type procedure DatabaseChanged(Database: String); function GetBlobContent(Results: TMySQLQuery; Column: Integer): String; procedure DoSearchReplace; + procedure UpdateLineCharPanel; public Connection: TMySQLConnection; SessionName: String; @@ -3873,9 +3874,7 @@ begin if QueryTabActive then RefreshQueryHelpers; ValidateQueryControls(Sender); - - if not QueryTabActive then // Empty panel with "Line:Char" - showstatus('', 1); + UpdateLineCharPanel; end; procedure TMainForm.RefreshQueryHelpers; @@ -4335,12 +4334,9 @@ end; procedure TMainForm.SynMemoQueryStatusChange(Sender: TObject; Changes: TSynStatusChanges); -var - sm: TSynMemo; begin - sm := Sender as TSynMemo; ValidateQueryControls(Sender); - showstatus(FormatNumber(sm.CaretY)+' : '+FormatNumber(sm.CaretX), 1); + UpdateLineCharPanel; end; @@ -6924,6 +6920,13 @@ begin end; +procedure TMainForm.DataGridFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; + Column: TColumnIndex); +begin + UpdateLineCharPanel; +end; + + {** DataGrid: invoke update or insert routine } @@ -9187,5 +9190,28 @@ begin end; +procedure TMainForm.UpdateLineCharPanel; +var + x, y: Int64; + Grid: TVirtualStringTree; +begin + // Fill panel with "Line:Char" + x := -1; + y := -1; + Grid := ActiveGrid; + if Assigned(Grid) and Grid.Focused then begin + if Assigned(Grid.FocusedNode) then + y := Grid.FocusedNode.Index+1; + x := Grid.FocusedColumn+1; + end else if QueryTabActive and ActiveQueryMemo.Focused then begin + x := ActiveQueryMemo.CaretX; + y := ActiveQueryMemo.CaretY; + end; + if (x > -1) and (y > -1) then + ShowStatus(FormatNumber(y)+' : '+FormatNumber(x), 1) + else + ShowStatus('', 1); +end; + end.