summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-05-27 14:14:43 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-03 12:54:13 +1000
commita9e2c8129f6e1cdfd58446d7ce5080fcabc2ea04 (patch)
tree272c6f737052d6e06f71c6e1e9ce355410238f1a /pkg/gui/gui.go
parentfd861826bc11754caf4ee4651dbadf9544792d1f (diff)
Introduce filtered list view model
We're going to start supporting filtering of list views
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index b922c5f77..106aee7a9 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -201,7 +201,7 @@ type GuiRepoState struct {
SplitMainPanel bool
LimitCommits bool
- Searching searchingState
+ SearchState *types.SearchState
StartupStage types.StartupStage // Allows us to not load everything at once
ContextMgr *ContextMgr
@@ -256,8 +256,12 @@ func (self *GuiRepoState) SetScreenMode(value types.WindowMaximisation) {
self.ScreenMode = value
}
-func (self *GuiRepoState) IsSearching() bool {
- return self.Searching.isSearching
+func (self *GuiRepoState) InSearchPrompt() bool {
+ return self.SearchState.SearchType() != types.SearchTypeNone
+}
+
+func (self *GuiRepoState) GetSearchState() *types.SearchState {
+ return self.SearchState
}
func (self *GuiRepoState) SetSplitMainPanel(value bool) {
@@ -268,12 +272,6 @@ func (self *GuiRepoState) GetSplitMainPanel() bool {
return self.SplitMainPanel
}
-type searchingState struct {
- view *gocui.View
- isSearching bool
- searchString string
-}
-
func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, reuseState bool) error {
var err error
gui.git, err = commands.NewGitCommand(
@@ -358,6 +356,7 @@ func (gui *Gui) resetState(startArgs appTypes.StartArgs, reuseState bool) types.
ContextMgr: NewContextMgr(gui, contextTree),
Contexts: contextTree,
WindowViewNameMap: initialWindowViewNameMap(contextTree),
+ SearchState: types.NewSearchState(),
}
gui.RepoStateMap[Repo(currentDir)] = gui.State
@@ -584,11 +583,12 @@ func (gui *Gui) Run(startArgs appTypes.StartArgs) error {
})
deadlock.Opts.Disable = !gui.Debug
- gui.g.OnSearchEscape = gui.onSearchEscape
if err := gui.Config.ReloadUserConfig(); err != nil {
return nil
}
userConfig := gui.UserConfig
+
+ gui.g.OnSearchEscape = func() error { gui.helpers.Search.Cancel(); return nil }
gui.g.SearchEscapeKey = keybindings.GetKey(userConfig.Keybinding.Universal.Return)
gui.g.NextSearchMatchKey = keybindings.GetKey(userConfig.Keybinding.Universal.NextMatch)
gui.g.PrevSearchMatchKey = keybindings.GetKey(userConfig.Keybinding.Universal.PrevMatch)