From 181a0732691275ce1882e4415c38fe543aa1ba8c Mon Sep 17 00:00:00 2001 From: Alexey-t Date: Thu, 15 Sep 2016 14:05:33 +0300 Subject: [PATCH] restore last tab in side-panel --- app/formmain.pas | 26 ++++++++++++++++++++++++-- app/formmain_frame_proc.inc | 10 ++++++++++ app/formmain_loadsave.inc | 15 +++++++++++++++ app/formmain_themes.inc | 4 ++-- app/readme/history.txt | 1 + 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/app/formmain.pas b/app/formmain.pas index b388c7b6d04..618ed35776a 100644 --- a/app/formmain.pas +++ b/app/formmain.pas @@ -589,6 +589,7 @@ TfmMain = class(TForm) procedure FrameLexerChange(Sender: TObject); procedure FrameOnEditorClickEndSelect(Sender: TObject; APrevPnt, ANewPnt: TPoint); procedure FrameOnEditorClickMoveCaret(Sender: TObject; APrevPnt, ANewPnt: TPoint); + function GetTabNameLeft: string; procedure InitToolbar; function IsAllowedToOpenFileNow: boolean; function IsThemeNameExist(const AName: string; AThemeUI: boolean): boolean; @@ -598,8 +599,9 @@ TfmMain = class(TForm) procedure MsgStatusAlt(const S: string; const NSeconds: integer); procedure SetFullScreen_Universal(AValue: boolean); procedure SetFullScreen_Win32(AValue: boolean); - procedure SetThemeSyntax(AValue: string); - procedure SetThemeUi(AValue: string); + procedure SetTabNameLeft(const AValue: string); + procedure SetThemeSyntax(const AValue: string); + procedure SetThemeUi(const AValue: string); function SFindOptionsToTextHint: string; procedure StatusResize(Sender: TObject); procedure TreeGetSyntaxRange(ANode: TTreeNode; out P1, P2: TPoint); @@ -613,6 +615,7 @@ TfmMain = class(TForm) procedure DoOps_SaveHistory_GroupView(c: TJsonConfig); procedure DoOps_LoadHistory; procedure DoOps_LoadHistory_GroupView(c: TJsonConfig); + procedure DoOps_LoadHistory_AfterOnStart; procedure DoOps_SaveSession(fn_session: string); procedure DoOps_LoadSession(fn_session: string); procedure DoOps_LoadOptionsAndApplyAll; @@ -772,6 +775,7 @@ TfmMain = class(TForm) property ShowBottom: boolean read GetShowBottom write SetShowBottom; property ThemeUi: string read FThemeUi write SetThemeUi; property ThemeSyntax: string read FThemeSyntax write SetThemeSyntax; + property TabNameLeft: string read GetTabNameLeft write SetTabNameLeft; function DoPyEvent(AEd: TATSynEdit; AEvent: TAppPyEvent; const AParams: array of string): string; procedure DoPyCommand(const AModule, AMethod: string; const AParam: string=''); end; @@ -1391,6 +1395,7 @@ procedure TfmMain.FormShow(Sender: TObject); DoPyEvent(CurrentEditor, cEventOnFocus, []); DoPyEvent(CurrentEditor, cEventOnStart, []); + DoOps_LoadHistory_AfterOnStart; ActiveControl:= CurrentEditor; UpdateStatus; @@ -2719,6 +2724,23 @@ procedure TfmMain.SetFullScreen_Win32(AValue: boolean); end; end; +procedure TfmMain.SetTabNameLeft(const AValue: string); +var + D: TATTabData; + i: integer; +begin + for i:= 0 to TabsLeft.TabCount-1 do + begin + D:= TabsLeft.GetTabData(i); + if Assigned(D) then + if D.TabCaption=AValue then + begin + TabsLeft.TabIndex:= i; + Break + end; + end; +end; + procedure TfmMain.DoEditorsLock(ALock: boolean); var diff --git a/app/formmain_frame_proc.inc b/app/formmain_frame_proc.inc index f1c1b20f322..58bccfa151e 100644 --- a/app/formmain_frame_proc.inc +++ b/app/formmain_frame_proc.inc @@ -178,6 +178,16 @@ begin end; end; +function TfmMain.GetTabNameLeft: string; +var + D: TATTabData; +begin + Result:= ''; + D:= TabsLeft.GetTabData(TabsLeft.TabIndex); + if Assigned(D) then + Result:= D.TabCaption; +end; + procedure TfmMain.FrameOnEditorClickEndSelect(Sender: TObject; APrevPnt, ANewPnt: TPoint); var diff --git a/app/formmain_loadsave.inc b/app/formmain_loadsave.inc index 25753616f3e..de792bec6ef 100644 --- a/app/formmain_loadsave.inc +++ b/app/formmain_loadsave.inc @@ -34,6 +34,7 @@ begin c.SetValue('show_bottom', ShowBottom); c.SetValue('size_side', PanelLeft.Width); c.SetValue('size_bottom', PanelBottom.Height); + c.SetValue('tab_left', TabNameLeft); end; ////recents @@ -269,6 +270,20 @@ begin c.SetValue('/gr/p1_y', Groups.Panel1.Height); end; + +procedure TfmMain.DoOps_LoadHistory_AfterOnStart; +var + c: TJSONConfig; +begin + c:= TJSONConfig.Create(nil); + try + c.Filename:= GetAppPath(cFileOptHistory); + TabNameLeft:= c.GetValue('tab_left', ''); + finally + FreeAndNil(c); + end; +end; + procedure TfmMain.DoOps_LoadHistory; const cReservePixels=70; diff --git a/app/formmain_themes.inc b/app/formmain_themes.inc index ab4c11b5671..a9033ae34c5 100644 --- a/app/formmain_themes.inc +++ b/app/formmain_themes.inc @@ -239,7 +239,7 @@ begin end; end; -procedure TfmMain.SetThemeUi(AValue: string); +procedure TfmMain.SetThemeUi(const AValue: string); begin if FThemeUi=AValue then Exit; FThemeUi:= AValue; @@ -257,7 +257,7 @@ begin DoApplyTheme; end; -procedure TfmMain.SetThemeSyntax(AValue: string); +procedure TfmMain.SetThemeSyntax(const AValue: string); begin if FThemeSyntax=AValue then Exit; FThemeSyntax:= AValue; diff --git a/app/readme/history.txt b/app/readme/history.txt index caeac7194c1..17cc9eccd16 100644 --- a/app/readme/history.txt +++ b/app/readme/history.txt @@ -6,6 +6,7 @@ 1.4.7 + Windows: Python 3.5 * del built-in commands to comment/uncomment; now plugin Comments (by kvichans) preinstalled for this, with more options and config dlg ++ restore last tab in side-panel + lexers JS, Python: keywords async/await 1.4.6