diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-06-03 13:50:26 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-03 12:54:14 +1000 |
commit | 3ca1292fb4d688559c81f08c449d14ae4031e60b (patch) | |
tree | 7eb7977396cb1b50350bb887787b6a1a8cfa671d /pkg | |
parent | 13c1103815e791966615647726000f2e3a7de828 (diff) |
Show filter status similar to what we show with search
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/context.go | 2 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/search_helper.go | 27 | ||||
-rw-r--r-- | pkg/i18n/english.go | 2 |
3 files changed, 16 insertions, 15 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go index e9a15870b..fde888a1c 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -235,7 +235,7 @@ func (self *ContextMgr) ActivateContext(c types.Context, opts types.OnFocusOpts) return err } - self.gui.helpers.Search.DisplaySearchInfoIfSearching(c) + self.gui.helpers.Search.DisplaySearchStatusIfSearching(c) desiredTitle := c.Title() if desiredTitle != "" { diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index 294ce9dbf..7d552a373 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -1,8 +1,12 @@ package helpers import ( + "fmt" + "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/theme" ) // NOTE: this helper supports both filtering and searching. Filtering is when @@ -60,31 +64,26 @@ func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) err return nil } -func (self *SearchHelper) DisplayFilterPrompt(context types.IFilterableContext) { +func (self *SearchHelper) DisplayFilterStatus(context types.IFilterableContext) { state := self.searchState() state.Context = context searchString := context.GetFilter() self.searchPrefixView().SetContent(self.c.Tr.FilterPrefix) + promptView := self.promptView() - promptView.ClearTextArea() - promptView.TextArea.TypeString(searchString) - promptView.RenderTextArea() + keybindingConfig := self.c.UserConfig.Keybinding + promptView.SetContent(fmt.Sprintf("matches for '%s' ", searchString) + theme.OptionsFgColor.Sprintf(self.c.Tr.ExitTextFilterMode, keybindings.Label(keybindingConfig.Universal.Return))) } -func (self *SearchHelper) DisplaySearchPrompt(context types.ISearchableContext) { +func (self *SearchHelper) DisplaySearchStatus(context types.ISearchableContext) { state := self.searchState() state.Context = context - searchString := context.GetSearchString() + self.searchPrefixView().SetContent(self.c.Tr.SearchPrefix) _ = context.GetView().SelectCurrentSearchResult() - - promptView := self.promptView() - promptView.ClearTextArea() - promptView.TextArea.TypeString(searchString) - promptView.RenderTextArea() } func (self *SearchHelper) searchState() *types.SearchState { @@ -199,15 +198,15 @@ func (self *SearchHelper) OnPromptContentChanged(searchString string) { } } -func (self *SearchHelper) DisplaySearchInfoIfSearching(c types.Context) { +func (self *SearchHelper) DisplaySearchStatusIfSearching(c types.Context) { if searchableContext, ok := c.(types.ISearchableContext); ok { if searchableContext.IsSearching() { - self.DisplaySearchPrompt(searchableContext) + self.DisplaySearchStatus(searchableContext) } } if filterableContext, ok := c.(types.IFilterableContext); ok { if filterableContext.IsFiltering() { - self.DisplayFilterPrompt(filterableContext) + self.DisplayFilterStatus(filterableContext) } } } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index e59d5e4df..62b9c0015 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -539,6 +539,7 @@ type TranslationSet struct { SearchPrefix string FilterPrefix string ExitSearchMode string + ExitTextFilterMode string Actions Actions Bisect Bisect } @@ -1226,6 +1227,7 @@ func EnglishTranslationSet() TranslationSet { CopyPatchToClipboard: "Copy patch to clipboard", NoMatchesFor: "No matches for '%s' %s", ExitSearchMode: "%s: Exit search mode", + ExitTextFilterMode: "%s: Exit filter mode", MatchesFor: "matches for '%s' (%d of %d) %s", // lowercase because it's after other text SearchKeybindings: "%s: Next match, %s: Previous match, %s: Exit search mode", SearchPrefix: "Search: ", |