diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e40b4ef..d0734052 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ -# v3.9.19 +# v3.9.19-dev ## Enhancements - Completion, changed defaults so that `.` does not validate but instead close, leaving typed text as-is. - To apply changes, set editopr option `closeCompletionCharsWithSpace` to `*+-/^=~><%.` and `closeCompletionChars` to `,;)}]!`. + To apply the changes on on exisint installation, set editor option `closeCompletionCharsWithSpace` to `*+-/^=~><%.` and `closeCompletionChars` to `,;)}]!`. - Completion, while menu opened, Backspace had for effect to also delete next char. This was an old workaround that has no reason to be maintained anymore. +- Editor status bar, added a context menu with casually useful actions related to the editor filename (open containing folder, copy file name, cd in terminal, etc.) ## Bugs fixed diff --git a/src/u_editor.lfm b/src/u_editor.lfm index b87337f3..530ab851 100644 --- a/src/u_editor.lfm +++ b/src/u_editor.lfm @@ -20,8 +20,8 @@ inherited EditorWidget: TEditorWidget ClientWidth = 465 object editorStatus: TStatusBar[0] Left = 0 - Height = 21 - Top = 375 + Height = 19 + Top = 377 Width = 465 BorderSpacing.Bottom = 2 Panels = < @@ -50,6 +50,7 @@ inherited EditorWidget: TEditorWidget end end inherited toolbar: TDexedToolBar + Height = 30 Width = 457 end end @@ -281,4 +282,24 @@ inherited EditorWidget: TEditorWidget OnClick = MenuItem8Click end end + object mnuCurFile: TPopupMenu[4] + Left = 216 + Top = 16 + object mnuCurFileShowInMiniExpl: TMenuItem + Caption = 'Show in mini explorer' + OnClick = mnuCurFileShowInMiniExplClick + end + object mnuCurFileShellOpen: TMenuItem + Caption = 'Open containing folder' + OnClick = mnuCurFileShellOpenClick + end + object mnuCurrFileCdInConsole: TMenuItem + Caption = 'cd in terminal' + OnClick = mnuCurrFileCdInConsoleClick + end + object mnuCurFileCopyName: TMenuItem + Caption = 'Copy filename' + OnClick = mnuCurFileCopyNameClick + end + end end diff --git a/src/u_editor.pas b/src/u_editor.pas index 1861f269..efb5eb27 100644 --- a/src/u_editor.pas +++ b/src/u_editor.pas @@ -10,7 +10,7 @@ uses SynPluginSyncroEdit, SynEdit, SynHighlighterMulti, AnchorDocking, u_dialogs, u_widget, u_interfaces, u_synmemo, u_dlang, u_common, u_dcd, u_observer, u_sharedres, u_controls, u_writableComponent, u_dsgncontrols, LMessages, - SynEditTypes; + SynEditTypes, Clipbrd; type @@ -62,6 +62,10 @@ type MenuItem14: TMenuItem; MenuItem15: TMenuItem; MenuItem16: TMenuItem; + mnuCurFileCopyName: TMenuItem; + mnuCurFileShowInMiniExpl: TMenuItem; + mnuCurFileShellOpen: TMenuItem; + mnuCurrFileCdInConsole: TMenuItem; mnuEdTabWidth2: TMenuItem; mnuEdTabWidth3: TMenuItem; mnuEdTabWidth4: TMenuItem; @@ -107,8 +111,13 @@ type macRecorder: TSynMacroRecorder; editorStatus: TStatusBar; mnuEditor: TPopupMenu; + mnuCurFile: TPopupMenu; procedure FormShortCut(var Msg: TLMKey; var Handled: Boolean); procedure FormShow(Sender: TObject); + procedure mnuCurFileCopyNameClick(Sender: TObject); + procedure mnuCurFileShellOpenClick(Sender: TObject); + procedure mnuCurFileShowInMiniExplClick(Sender: TObject); + procedure mnuCurrFileCdInConsoleClick(Sender: TObject); procedure mnuedDdocTmpClick(Sender: TObject); procedure mnuedGotolineClick(Sender: TObject); procedure mnuedNextWarnClick(Sender: TObject); @@ -171,6 +180,7 @@ type procedure focusedEditorChanged; procedure memoCmdProcessed(Sender: TObject; var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer); procedure setDetectModuleName(value: boolean); + procedure statusBarContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean); // procedure docNew(document: TDexedMemo); procedure docClosing(document: TDexedMemo); @@ -427,6 +437,7 @@ begin editorStatus.Panels[2].Width := ScaleX(125, 96); editorStatus.Panels[3].Width := ScaleX(105, 96); editorStatus.Panels[4].Width := ScaleX(2000, 96); + editorStatus.OnContextPopup := @statusBarContextPopup; fTokList := TLexTokenList.Create; @@ -1085,6 +1096,50 @@ begin fDoc.Visible:=true; end; +procedure TEditorWidget.statusBarContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean); +begin + handled := false; + if fDoc.fileName.fileExists then + begin + handled := true; + if editorStatus.GetPanelIndexAt(MousePos.X, MousePos.Y).equals(4) then + begin + MousePos := editorStatus.ClientToScreen(MousePos); + mnuCurFile.PopUp(MousePos.X, MousePos.Y); + end; + end; +end; + +procedure TEditorWidget.mnuCurFileCopyNameClick(Sender: TObject); +begin + if fDoc.fileName.fileExists then + Clipboard.AsText := fDoc.fileName; +end; + +procedure TEditorWidget.mnuCurFileShellOpenClick(Sender: TObject); +begin + if fDoc.fileName.fileExists then + shellOpen(fDoc.fileName.extractFileDir, false); +end; + +procedure TEditorWidget.mnuCurFileShowInMiniExplClick(Sender: TObject); +begin + if fDoc.fileName.fileExists then + getExplorer().browse(fDoc.fileName.extractFileDir); +end; + +procedure TEditorWidget.mnuCurrFileCdInConsoleClick(Sender: TObject); +var + t: ITerminal; +begin + if fDoc.fileName.fileExists then + begin + t := getTerminal(); + if assigned(t) then + t.cd(fDoc.fileName.extractFileDir); + end; +end; + procedure TEditorWidget.mnuedGotolineClick(Sender: TObject); begin if fDoc.isAssigned then diff --git a/src/u_interfaces.pas b/src/u_interfaces.pas index 0de359c1..f3a4e88b 100644 --- a/src/u_interfaces.pas +++ b/src/u_interfaces.pas @@ -379,6 +379,14 @@ type function currentLocation: string; end; + (** + * Single service related to build-in file explorer. + *) + ITerminal = interface(ISingleService) + // does a cd + procedure cd(const location: string); + end; + (** * Single service provided by the options editor. @@ -499,6 +507,7 @@ type function getMainMenu: IMainMenu; inline; function getCodeFormatting: ICodeFormatting; inline; function getLifeTimeManager: ILifetimeManager; inline; + function getTerminal: ITerminal; inline; const DCompiler2String: array[DCompiler] of string = ('dmd', 'gdc', 'gdmd', 'ldc', 'ldmd', @@ -676,6 +685,11 @@ function getLifeTimeManager: ILifetimeManager; inline; begin exit(EntitiesConnector.getSingleService('ILifetimeManager') as ILifetimeManager); end; + +function getTerminal: ITerminal; inline; +begin + exit(EntitiesConnector.getSingleService('ITerminal') as ITerminal); +end; {$ENDREGION} function usingCompilerInfo(value: DCompiler; translateToWrapper: boolean): string; diff --git a/src/u_term.lfm b/src/u_term.lfm index 0e4de3b6..39e0a66e 100644 --- a/src/u_term.lfm +++ b/src/u_term.lfm @@ -39,6 +39,7 @@ inherited TermWidget: TTermWidget end end inherited toolbar: TDexedToolBar + Height = 30 Width = 666 end end diff --git a/src/u_term.pas b/src/u_term.pas index 22921388..b244e44f 100644 --- a/src/u_term.pas +++ b/src/u_term.pas @@ -70,7 +70,7 @@ type { TTermWidget } - TTermWidget = class(TDexedWidget, IDocumentObserver, IProjectObserver, IMiniExplorerObserver) + TTermWidget = class(TDexedWidget, IDocumentObserver, IProjectObserver, IMiniExplorerObserver, ITerminal) Panel1: TPanel; ScrollBar1: TScrollBar; procedure ContentPaint(Sender: TObject); @@ -108,6 +108,10 @@ type procedure SetVisible(Value: boolean); override; public + + function singleServiceName: string; + procedure cd(const location: string); + constructor create(aOwner: TComponent); override; destructor destroy; override; end; @@ -272,6 +276,7 @@ begin fOpts.loadFromFile(f); EntitiesConnector.addObserver(fOpts); + EntitiesConnector.addSingleService(self); end; destructor TTermWidget.destroy; @@ -304,6 +309,16 @@ begin fDisableScrollBarSync := false; end; +procedure TTermWidget.cd(const location: string); +begin + checkDirectory(location); +end; + +function TTermWidget.singleServiceName: string; +begin + result := 'ITerminal'; +end; + procedure TTermWidget.SetVisible(Value: boolean); begin inherited;