summaryrefslogtreecommitdiffstats
path: root/pkg/gui/types/context.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-12-30 23:24:24 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-04-30 13:19:52 +1000
commit8edad826caf2fa48bfad33f9f8c4f3ba49a052da (patch)
tree0b49145e4f656e72441199b5a5c30176c898d7a7 /pkg/gui/types/context.go
parent826128a8e03fb50f7287029ebac93c85712faecb (diff)
Begin refactoring gui
This begins a big refactor of moving more code out of the Gui struct into contexts, controllers, and helpers. We also move some code into structs in the gui package purely for the sake of better encapsulation
Diffstat (limited to 'pkg/gui/types/context.go')
-rw-r--r--pkg/gui/types/context.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go
index e88d0d0f9..ef57e06bc 100644
--- a/pkg/gui/types/context.go
+++ b/pkg/gui/types/context.go
@@ -72,6 +72,10 @@ type IBaseContext interface {
// our list controller can come along and wrap it in a list-specific click handler.
// We'll need to think of a better way to do this.
AddOnClickFn(func() error)
+
+ AddOnRenderToMainFn(func() error)
+ AddOnFocusFn(func(OnFocusOpts) error)
+ AddOnFocusLostFn(func(OnFocusLostOpts) error)
}
type Context interface {
@@ -83,6 +87,16 @@ type Context interface {
HandleRenderToMain() error
}
+type DiffableContext interface {
+ Context
+
+ // Returns the current diff terminals of the currently selected item.
+ // in the case of a branch it returns both the branch and it's upstream name,
+ // which becomes an option when you bring up the diff menu, but when you're just
+ // flicking through branches it will be using the local branch name.
+ GetDiffTerminals() []string
+}
+
type IListContext interface {
Context
@@ -150,6 +164,9 @@ type HasKeybindings interface {
GetKeybindings(opts KeybindingsOpts) []*Binding
GetMouseKeybindings(opts KeybindingsOpts) []*gocui.ViewMouseBinding
GetOnClick() func() error
+ GetOnRenderToMain() func() error
+ GetOnFocus() func(OnFocusOpts) error
+ GetOnFocusLost() func(OnFocusLostOpts) error
}
type IController interface {