summaryrefslogtreecommitdiffstats
path: root/pkg/gui/types
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-16 14:46:53 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit1dd7307fde033dae5fececac15810a99e26c3d91 (patch)
tree4e851c9e3229a6fe3b4191f6311d05d7a9142960 /pkg/gui/types
parenta90b6efded49abcfa2516db794d7875b0396f558 (diff)
start moving commit panel handlers into controller
more and more move rebase commit refreshing into existing abstraction and more and more WIP and more handling clicks properly fix merge conflicts update cheatsheet lots more preparation to start moving things into controllers WIP better typing expand on remotes controller moving more code into controllers
Diffstat (limited to 'pkg/gui/types')
-rw-r--r--pkg/gui/types/common_commands.go7
-rw-r--r--pkg/gui/types/context.go87
-rw-r--r--pkg/gui/types/keybindings.go9
-rw-r--r--pkg/gui/types/refresh.go1
4 files changed, 104 insertions, 0 deletions
diff --git a/pkg/gui/types/common_commands.go b/pkg/gui/types/common_commands.go
new file mode 100644
index 000000000..74bfd603b
--- /dev/null
+++ b/pkg/gui/types/common_commands.go
@@ -0,0 +1,7 @@
+package types
+
+type CheckoutRefOptions struct {
+ WaitingStatus string
+ EnvVars []string
+ OnRefNotFound func(ref string) error
+}
diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go
new file mode 100644
index 000000000..833d1cba6
--- /dev/null
+++ b/pkg/gui/types/context.go
@@ -0,0 +1,87 @@
+package types
+
+import "github.com/jesseduffield/lazygit/pkg/config"
+
+type ContextKind int
+
+const (
+ SIDE_CONTEXT ContextKind = iota
+ MAIN_CONTEXT
+ TEMPORARY_POPUP
+ PERSISTENT_POPUP
+ EXTRAS_CONTEXT
+)
+
+type Context interface {
+ HandleFocus(opts ...OnFocusOpts) error
+ HandleFocusLost() error
+ HandleRender() error
+ HandleRenderToMain() error
+ GetKind() ContextKind
+ GetViewName() string
+ GetWindowName() string
+ SetWindowName(string)
+ GetKey() ContextKey
+ SetParentContext(Context)
+
+ // we return a bool here to tell us whether or not the returned value just wraps a nil
+ GetParentContext() (Context, bool)
+ GetOptionsMap() map[string]string
+}
+
+type OnFocusOpts struct {
+ ClickedViewName string
+ ClickedViewLineIdx int
+}
+
+type ContextKey string
+
+type HasKeybindings interface {
+ Keybindings(
+ getKey func(key string) interface{},
+ config config.KeybindingConfig,
+ guards KeybindingGuards,
+ ) []*Binding
+}
+
+type IController interface {
+ HasKeybindings
+ Context() Context
+}
+
+type IListContext interface {
+ HasKeybindings
+ GetSelectedItem() (ListItem, bool)
+ GetSelectedItemId() string
+
+ HandlePrevLine() error
+ HandleNextLine() error
+ HandleScrollLeft() error
+ HandleScrollRight() error
+ HandleNextPage() error
+ HandleGotoTop() error
+ HandleGotoBottom() error
+ HandlePrevPage() error
+ HandleClick(onClick func() error) error
+
+ OnSearchSelect(selectedLineIdx int) error
+ FocusLine()
+ HandleRenderToMain() error
+
+ GetPanelState() IListPanelState
+
+ Context
+}
+
+type IListPanelState interface {
+ SetSelectedLineIdx(int)
+ GetSelectedLineIdx() int
+}
+
+type ListItem interface {
+ // ID is a SHA when the item is a commit, a filename when the item is a file, 'stash@{4}' when it's a stash entry, 'my_branch' when it's a branch
+ ID() string
+
+ // Description is something we would show in a message e.g. '123as14: push blah' for a commit
+ Description() string
+}
diff --git a/pkg/gui/types/keybindings.go b/pkg/gui/types/keybindings.go
index abe3f84d0..7d1befc1b 100644
--- a/pkg/gui/types/keybindings.go
+++ b/pkg/gui/types/keybindings.go
@@ -16,3 +16,12 @@ type Binding struct {
Tag string // e.g. 'navigation'. Used for grouping things in the cheatsheet
OpensMenu bool
}
+
+// A guard is a decorator which checks something before executing a handler
+// and potentially early-exits if some precondition hasn't been met.
+type Guard func(func() error) func() error
+
+type KeybindingGuards struct {
+ OutsideFilterMode Guard
+ NoPopupPanel Guard
+}
diff --git a/pkg/gui/types/refresh.go b/pkg/gui/types/refresh.go
index d0cbe02ba..3a7e6db17 100644
--- a/pkg/gui/types/refresh.go
+++ b/pkg/gui/types/refresh.go
@@ -5,6 +5,7 @@ type RefreshableView int
const (
COMMITS RefreshableView = iota
+ REBASE_COMMITS
BRANCHES
FILES
STASH