diff --git a/source/apphelpers.pas b/source/apphelpers.pas index fe287a00..2da0db0f 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -14,7 +14,7 @@ uses System.Win.Registry, System.DateUtils, System.Generics.Collections, System.Contnrs, System.StrUtils, System.AnsiStrings, Winapi.TlHelp32, System.Types, dbconnection, dbstructures, dbstructures.mysql, SynMemo, Vcl.Menus, Winapi.WinInet, gnugettext, Vcl.Themes, System.Character, Vcl.ImgList, System.UITypes, Vcl.ActnList, Winapi.WinSock, System.IOUtils, Vcl.StdCtrls, Vcl.ComCtrls, - Winapi.CommCtrl, Winapi.KnownFolders, SynUnicode; + Winapi.CommCtrl, Winapi.KnownFolders, SynUnicode, SynEdit; type @@ -45,6 +45,8 @@ type FModified: Boolean; procedure SetModified(Value: Boolean); protected + FMainSynMemo: TSynMemo; // Main editor in case of routine, view, trigger or event + FMainSynMemoPreviousTopLine: Integer; function ObjectExists: Boolean; public DBObject: TDBObject; @@ -1883,6 +1885,8 @@ begin // Do not set alClient via DFM! In conjunction with ExplicitXXX properties that // repeatedly breaks the GUI layout when you reload the project Align := alClient; + FMainSynMemo := nil; + DBObject := nil; TranslateComponent(Self); end; @@ -1908,10 +1912,16 @@ var popup: TPopupMenu; Item: TMenuItem; i: Integer; + IsRefresh: Boolean; begin Mainform.ShowStatusMsg(_('Initializing editor ...')); Mainform.LogSQL(Self.ClassName+'.Init, using object "'+Obj.Name+'"', lcDebug); TExtForm.FixControls(Self); + IsRefresh := Assigned(DBObject) and DBObject.IsSameAs(Obj); + if IsRefresh and Assigned(FMainSynMemo) then + FMainSynMemoPreviousTopLine := FMainSynMemo.TopLine + else + FMainSynMemoPreviousTopLine := 0; DBObject := TDBObject.Create(Obj.Connection); DBObject.Assign(Obj); Mainform.UpdateEditorTab; @@ -1976,6 +1986,7 @@ begin Result := mrOk; if Modified then begin ObjType := _(LowerCase(DBObject.ObjType)); + // Todo: no save button for objects without minimum requirements, such as name. See #1134 if DBObject.Name <> '' then Msg := f_('Save modified %s "%s"?', [ObjType, DBObject.Name]) else diff --git a/source/event_editor.pas b/source/event_editor.pas index 1c669324..b4c5b085 100644 --- a/source/event_editor.pas +++ b/source/event_editor.pas @@ -80,6 +80,7 @@ begin comboEveryInterval.Items := Explode('|', 'YEAR|QUARTER|MONTH|DAY|HOUR|MINUTE|WEEK|SECOND|YEAR_MONTH|'+ 'DAY_HOUR|DAY_MINUTE|DAY_SECOND|HOUR_MINUTE|HOUR_SECOND|MINUTE_SECOND'); grpState.Items := Explode('|', 'Enable|Disable|Disable on slave'); + FMainSynMemo := SynMemoBody; end; @@ -187,6 +188,7 @@ begin SynMemoBody.Text := rx.Match[1]; rx.Free; + SynMemoBody.TopLine := FMainSynMemoPreviousTopLine; end; radioScheduleClick(Self); diff --git a/source/routine_editor.pas b/source/routine_editor.pas index ef895538..ca107825 100644 --- a/source/routine_editor.pas +++ b/source/routine_editor.pas @@ -114,6 +114,7 @@ begin Mainform.SynCompletionProposal.AddEditor(SynMemoBody); Parameters := TRoutineParamList.Create; editName.MaxLength := NAME_LEN; + FMainSynMemo := SynMemoBody; end; @@ -164,6 +165,7 @@ begin lblDisabledWhy.Visible := Obj.Body = ''; PageControlMain.Enabled := not lblDisabledWhy.Visible; SynMemoBody.Enabled := PageControlMain.Enabled; + SynMemoBody.TopLine := FMainSynMemoPreviousTopLine; end else begin editName.Text := ''; end; diff --git a/source/trigger_editor.pas b/source/trigger_editor.pas index 49f58244..8f48f2f2 100644 --- a/source/trigger_editor.pas +++ b/source/trigger_editor.pas @@ -76,6 +76,7 @@ begin SynCompletionProposalStatement.Options := Mainform.SynCompletionProposal.Options; SynCompletionProposalStatement.TimerInterval := Mainform.SynCompletionProposal.TimerInterval; SynCompletionProposalStatement.Margin := Mainform.SynCompletionProposal.Margin; + FMainSynMemo := SynMemoBody; end; @@ -140,6 +141,7 @@ begin end; end; SynMemoBody.Text := Body; + SynMemoBody.TopLine := FMainSynMemoPreviousTopLine; Found := True; break; end; diff --git a/source/view.pas b/source/view.pas index 85335a57..1822847f 100644 --- a/source/view.pas +++ b/source/view.pas @@ -64,6 +64,7 @@ begin editName.MaxLength := NAME_LEN; comboSecurity.Items.Add('Definer'); comboSecurity.Items.Add('Invoker'); + FMainSynMemo := SynMemoBody; end; @@ -103,6 +104,7 @@ begin rgAlgorithm.Enabled := editName.Enabled; rgCheck.Enabled := rgAlgorithm.Enabled; SynMemoBody.Enabled := rgAlgorithm.Enabled; + SynMemoBody.TopLine := FMainSynMemoPreviousTopLine; end else begin // Create mode editName.Text := '';