diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 2e0f6a67d..7000e74ae 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -55,6 +55,7 @@ File Content Search: Index Search: Quick Access: + Rename: Current Action Keyword Done Enabled diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 12df6c145..28609c86d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -47,6 +47,16 @@ namespace Flow.Launcher.Plugin.Explorer.Search internal async Task> SearchAsync(Query query, CancellationToken token) { var results = new HashSet(PathEqualityComparator.Instance); + if (ActionKeywordMatch(query, Settings.ActionKeyword.RenameActionKeyword)) + { + return new List() + { + new Result(){ + Title = "Done", + AutoCompleteText = "test" + } + }; + } // This allows the user to type the below action keywords and see/search the list of quick folder links if (ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword) @@ -151,6 +161,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search keyword == Settings.IndexSearchActionKeyword, Settings.ActionKeyword.QuickAccessActionKeyword => Settings.QuickAccessKeywordEnabled && keyword == Settings.QuickAccessActionKeyword, + Settings.ActionKeyword.RenameActionKeyword => Settings.RenameActionKeywordEnabled && keyword == Settings.RenameActionKeyword, _ => throw new ArgumentOutOfRangeException(nameof(allowedActionKeyword), allowedActionKeyword, "actionKeyword out of range") }; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 77540f3a8..ac0e54062 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -1,13 +1,14 @@ -using Flow.Launcher.Plugin.Everything.Everything; -using Flow.Launcher.Plugin.Explorer.Search; -using Flow.Launcher.Plugin.Explorer.Search.Everything; -using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; -using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex; -using System; +using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Text.Json.Serialization; +using Flow.Launcher.Plugin.Everything.Everything; +using Flow.Launcher.Plugin.Explorer.Search; +using Flow.Launcher.Plugin.Explorer.Search.Everything; using Flow.Launcher.Plugin.Explorer.Search.IProvider; +using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; +using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex; +using Flow.Launcher.Plugin.Explorer.ViewModels; namespace Flow.Launcher.Plugin.Explorer { @@ -17,7 +18,8 @@ namespace Flow.Launcher.Plugin.Explorer public ObservableCollection QuickAccessLinks { get; set; } = new(); - public ObservableCollection IndexSearchExcludedSubdirectoryPaths { get; set; } = new ObservableCollection(); + public ObservableCollection IndexSearchExcludedSubdirectoryPaths { get; set; } = + new ObservableCollection(); public string EditorPath { get; set; } = ""; @@ -43,7 +45,8 @@ namespace Flow.Launcher.Plugin.Explorer public bool SearchActionKeywordEnabled { get; set; } = true; - public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword; + public string FileContentSearchActionKeyword { get; set; } = + Constants.DefaultContentSearchActionKeyword; public bool FileContentSearchKeywordEnabled { get; set; } = true; @@ -58,7 +61,8 @@ namespace Flow.Launcher.Plugin.Explorer public string QuickAccessActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; public bool QuickAccessKeywordEnabled { get; set; } - + public string RenameActionKeyword { get; set; } = "re:"; + public bool RenameActionKeywordEnabled { get; set; } = true; public bool WarnWindowsSearchServiceOff { get; set; } = true; @@ -67,9 +71,8 @@ namespace Flow.Launcher.Plugin.Explorer public bool ShowCreatedDateInPreviewPanel { get; set; } = true; public bool ShowModifiedDateInPreviewPanel { get; set; } = true; - - public bool ShowFileAgeInPreviewPanel { get; set; } = false; + public bool ShowFileAgeInPreviewPanel { get; set; } = false; public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd"; @@ -80,44 +83,55 @@ namespace Flow.Launcher.Plugin.Explorer #region SearchEngine - private EverythingSearchManager EverythingManagerInstance => _everythingManagerInstance ??= new EverythingSearchManager(this); - private WindowsIndexSearchManager WindowsIndexSearchManager => _windowsIndexSearchManager ??= new WindowsIndexSearchManager(this); + private EverythingSearchManager EverythingManagerInstance => + _everythingManagerInstance ??= new EverythingSearchManager(this); + private WindowsIndexSearchManager WindowsIndexSearchManager => + _windowsIndexSearchManager ??= new WindowsIndexSearchManager(this); - - public IndexSearchEngineOption IndexSearchEngine { get; set; } = IndexSearchEngineOption.WindowsIndex; - [JsonIgnore] - public IIndexProvider IndexProvider => IndexSearchEngine switch - { - IndexSearchEngineOption.Everything => EverythingManagerInstance, - IndexSearchEngineOption.WindowsIndex => WindowsIndexSearchManager, - _ => throw new ArgumentOutOfRangeException(nameof(IndexSearchEngine)) - }; - - public PathEnumerationEngineOption PathEnumerationEngine { get; set; } = PathEnumerationEngineOption.WindowsIndex; + public IndexSearchEngineOption IndexSearchEngine { get; set; } = + IndexSearchEngineOption.WindowsIndex; [JsonIgnore] - public IPathIndexProvider PathEnumerator => PathEnumerationEngine switch - { - PathEnumerationEngineOption.Everything => EverythingManagerInstance, - PathEnumerationEngineOption.WindowsIndex => WindowsIndexSearchManager, - _ => throw new ArgumentOutOfRangeException(nameof(PathEnumerationEngine)) - }; + public IIndexProvider IndexProvider => + IndexSearchEngine switch + { + IndexSearchEngineOption.Everything => EverythingManagerInstance, + IndexSearchEngineOption.WindowsIndex => WindowsIndexSearchManager, + _ => throw new ArgumentOutOfRangeException(nameof(IndexSearchEngine)) + }; + + public PathEnumerationEngineOption PathEnumerationEngine { get; set; } = + PathEnumerationEngineOption.WindowsIndex; - public ContentIndexSearchEngineOption ContentSearchEngine { get; set; } = ContentIndexSearchEngineOption.WindowsIndex; [JsonIgnore] - public IContentIndexProvider ContentIndexProvider => ContentSearchEngine switch - { - ContentIndexSearchEngineOption.Everything => EverythingManagerInstance, - ContentIndexSearchEngineOption.WindowsIndex => WindowsIndexSearchManager, - _ => throw new ArgumentOutOfRangeException(nameof(ContentSearchEngine)) - }; + public IPathIndexProvider PathEnumerator => + PathEnumerationEngine switch + { + PathEnumerationEngineOption.Everything => EverythingManagerInstance, + PathEnumerationEngineOption.WindowsIndex => WindowsIndexSearchManager, + _ => throw new ArgumentOutOfRangeException(nameof(PathEnumerationEngine)) + }; + + public ContentIndexSearchEngineOption ContentSearchEngine { get; set; } = + ContentIndexSearchEngineOption.WindowsIndex; + + [JsonIgnore] + public IContentIndexProvider ContentIndexProvider => + ContentSearchEngine switch + { + ContentIndexSearchEngineOption.Everything => EverythingManagerInstance, + ContentIndexSearchEngineOption.WindowsIndex => WindowsIndexSearchManager, + _ => throw new ArgumentOutOfRangeException(nameof(ContentSearchEngine)) + }; public enum PathEnumerationEngineOption { [Description("plugin_explorer_engine_windows_index")] WindowsIndex, + [Description("plugin_explorer_engine_everything")] Everything, + [Description("plugin_explorer_path_enumeration_engine_none")] DirectEnumeration } @@ -126,6 +140,7 @@ namespace Flow.Launcher.Plugin.Explorer { [Description("plugin_explorer_engine_windows_index")] WindowsIndex, + [Description("plugin_explorer_engine_everything")] Everything, } @@ -134,6 +149,7 @@ namespace Flow.Launcher.Plugin.Explorer { [Description("plugin_explorer_engine_windows_index")] WindowsIndex, + [Description("plugin_explorer_engine_everything")] Everything, } @@ -152,9 +168,10 @@ namespace Flow.Launcher.Plugin.Explorer public bool EnableEverythingContentSearch { get; set; } = false; - public bool EverythingEnabled => IndexSearchEngine == IndexSearchEngineOption.Everything || - PathEnumerationEngine == PathEnumerationEngineOption.Everything || - ContentSearchEngine == ContentIndexSearchEngineOption.Everything; + public bool EverythingEnabled => + IndexSearchEngine == IndexSearchEngineOption.Everything + || PathEnumerationEngine == PathEnumerationEngineOption.Everything + || ContentSearchEngine == ContentIndexSearchEngineOption.Everything; public bool EverythingSearchFullPath { get; set; } = false; public bool EverythingEnableRunCount { get; set; } = true; @@ -167,47 +184,78 @@ namespace Flow.Launcher.Plugin.Explorer PathSearchActionKeyword, FileContentSearchActionKeyword, IndexSearchActionKeyword, - QuickAccessActionKeyword + QuickAccessActionKeyword, + RenameActionKeyword } - internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch - { - ActionKeyword.SearchActionKeyword => SearchActionKeyword, - ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword, - ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword, - ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword, - ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword, - _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyWord property not found") - }; + internal string GetActionKeyword(ActionKeyword actionKeyword) => + actionKeyword switch + { + ActionKeyword.SearchActionKeyword => SearchActionKeyword, + ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword, + ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword, + ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword, + ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword, + ActionKeyword.RenameActionKeyword => RenameActionKeyword, + _ + => throw new ArgumentOutOfRangeException( + nameof(actionKeyword), + actionKeyword, + "ActionKeyWord property not found" + ) + }; - internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch - { - ActionKeyword.SearchActionKeyword => SearchActionKeyword = keyword, - ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword, - ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword, - ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword, - ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword = keyword, - _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyWord property not found") - }; + internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => + _ = actionKeyword switch + { + ActionKeyword.SearchActionKeyword => SearchActionKeyword = keyword, + ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword, + ActionKeyword.FileContentSearchActionKeyword + => FileContentSearchActionKeyword = keyword, + ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword, + ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword = keyword, + ActionKeyword.RenameActionKeyword => RenameActionKeyword = keyword, + _ + => throw new ArgumentOutOfRangeException( + nameof(actionKeyword), + actionKeyword, + "ActionKeyWord property not found" + ) + }; - internal bool GetActionKeywordEnabled(ActionKeyword actionKeyword) => actionKeyword switch - { - ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled, - ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled, - ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled, - ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled, - ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled, - _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyword enabled status not defined") - }; + internal bool GetActionKeywordEnabled(ActionKeyword actionKeyword) => + actionKeyword switch + { + ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled, + ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled, + ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled, + ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled, + ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled, + ActionKeyword.RenameActionKeyword => RenameActionKeywordEnabled, + _ + => throw new ArgumentOutOfRangeException( + nameof(actionKeyword), + actionKeyword, + "ActionKeyword enabled status not defined" + ) + }; - internal void SetActionKeywordEnabled(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch - { - ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable, - ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable, - ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled = enable, - ActionKeyword.FileContentSearchActionKeyword => FileContentSearchKeywordEnabled = enable, - ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled = enable, - _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "ActionKeyword enabled status not defined") - }; + internal void SetActionKeywordEnabled(ActionKeyword actionKeyword, bool enable) => + _ = actionKeyword switch + { + ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable, + ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable, + ActionKeyword.IndexSearchActionKeyword => IndexSearchKeywordEnabled = enable, + ActionKeyword.FileContentSearchActionKeyword + => FileContentSearchKeywordEnabled = enable, + ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled = enable, + ActionKeyword.RenameActionKeyword => RenameActionKeywordEnabled = enable, + _ + => throw new ArgumentOutOfRangeException( + nameof(actionKeyword), + actionKeyword, + "ActionKeyword enabled status not defined" + ) + }; } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 5aa6a13be..48ea82155 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -279,7 +279,9 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels new(Settings.ActionKeyword.IndexSearchActionKeyword, "plugin_explorer_actionkeywordview_indexsearch"), new(Settings.ActionKeyword.QuickAccessActionKeyword, - "plugin_explorer_actionkeywordview_quickaccess") + "plugin_explorer_actionkeywordview_quickaccess"), + new (Settings.ActionKeyword.RenameActionKeyword, + "plugin_explorer_actionkeywordview_rename") }; }