mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-25 18:55:28 -06:00
WIP Make it searchable
Doesn't work very well yet, but it gives you a taste of what it could look like.
This commit is contained in:
parent
50426cda3a
commit
cbd23107ef
53
pkg/gui/context/diff_context.go
Normal file
53
pkg/gui/context/diff_context.go
Normal file
@ -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
|
||||||
|
}
|
@ -57,26 +57,8 @@ func NewContextTree(c *ContextCommon) *ContextTree {
|
|||||||
Focusable: false,
|
Focusable: false,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
Diff: NewSimpleContext(
|
Diff: NewDiffContext(c.Views().Diff, "main", DIFF_MAIN_CONTEXT_KEY, c),
|
||||||
NewBaseContext(NewBaseContextOpts{
|
DiffSecondary: NewDiffContext(c.Views().DiffSecondary, "secondary", DIFF_SECONDARY_CONTEXT_KEY, c),
|
||||||
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,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
Staging: NewPatchExplorerContext(
|
Staging: NewPatchExplorerContext(
|
||||||
c.Views().Staging,
|
c.Views().Staging,
|
||||||
"main",
|
"main",
|
||||||
|
Loading…
Reference in New Issue
Block a user