diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-10-15 16:59:50 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-10-15 16:59:50 +0200 |
commit | cbd23107efb21e521e13d4915b9c4dcb93a414a1 (patch) | |
tree | 90f4f249ecf130ccb03f3d18f805e56b55de6ed5 | |
parent | 50426cda3a11b6112c11c75cd5a5ee96b67ed354 (diff) |
WIP Make it searchablefocus-main-view
Doesn't work very well yet, but it gives you a taste of what it could look like.
-rw-r--r-- | pkg/gui/context/diff_context.go | 53 | ||||
-rw-r--r-- | pkg/gui/context/setup.go | 22 |
2 files changed, 55 insertions, 20 deletions
diff --git a/pkg/gui/context/diff_context.go b/pkg/gui/context/diff_context.go new file mode 100644 index 000000000..3763fedc2 --- /dev/null +++ b/pkg/gui/context/diff_context.go @@ -0,0 +1,53 @@ +package context + +import ( + "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gui/types" +) + +type DiffContext struct { + *SimpleContext + *SearchTrait + + c *ContextCommon +} + +var _ types.ISearchableContext = (*DiffContext)(nil) + +func NewDiffContext( + view *gocui.View, + windowName string, + key types.ContextKey, + + c *ContextCommon, +) *DiffContext { + ctx := &DiffContext{ + SimpleContext: NewSimpleContext( + NewBaseContext(NewBaseContextOpts{ + Kind: types.MAIN_CONTEXT, + View: view, + WindowName: windowName, + Key: key, + Focusable: true, + HighlightOnFocus: true, + })), + SearchTrait: NewSearchTrait(c), + c: c, + } + + // TODO: copied from PatchExplorerContext. Do we need something like this? + // ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper( + // func(selectedLineIdx int) error { + // ctx.GetMutex().Lock() + // defer ctx.GetMutex().Unlock() + // ctx.NavigateTo(ctx.c.Context().IsCurrent(ctx), selectedLineIdx) + // return nil + // }), + // ) + + return ctx +} + +func (self *DiffContext) ModelSearchResults(searchStr string, caseSensitive bool) []gocui.SearchPosition { + return nil +} diff --git a/pkg/gui/context/setup.go b/pkg/gui/context/setup.go index 11b0e0006..b46e5b8f4 100644 --- a/pkg/gui/context/setup.go +++ b/pkg/gui/context/setup.go @@ -57,26 +57,8 @@ func NewContextTree(c *ContextCommon) *ContextTree { Focusable: false, }), ), - Diff: NewSimpleContext( - NewBaseContext(NewBaseContextOpts{ - Kind: types.MAIN_CONTEXT, - View: c.Views().Diff, - WindowName: "main", - Key: DIFF_MAIN_CONTEXT_KEY, - Focusable: true, - HighlightOnFocus: true, - }), - ), - DiffSecondary: NewSimpleContext( - NewBaseContext(NewBaseContextOpts{ - Kind: types.MAIN_CONTEXT, - View: c.Views().DiffSecondary, - WindowName: "secondary", - Key: DIFF_SECONDARY_CONTEXT_KEY, - Focusable: true, - HighlightOnFocus: true, - }), - ), + Diff: NewDiffContext(c.Views().Diff, "main", DIFF_MAIN_CONTEXT_KEY, c), + DiffSecondary: NewDiffContext(c.Views().DiffSecondary, "secondary", DIFF_SECONDARY_CONTEXT_KEY, c), Staging: NewPatchExplorerContext( c.Views().Staging, "main", |