summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/vertical_scroll_controller.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-08-06 18:50:52 +1000
committerJesse Duffield <jessedduffield@gmail.com>2022-08-07 11:16:03 +1000
commit7410acd1aaa97f678295a328264360802346b33a (patch)
tree51dc6b5dfc8c0b67711ff644a6bc32480e6eaea8 /pkg/gui/controllers/vertical_scroll_controller.go
parent445a625b56a79be6cee7ec1ee35fe9f4fcc2daad (diff)
move merge conflicts code into controller
Diffstat (limited to 'pkg/gui/controllers/vertical_scroll_controller.go')
-rw-r--r--pkg/gui/controllers/vertical_scroll_controller.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/pkg/gui/controllers/vertical_scroll_controller.go b/pkg/gui/controllers/vertical_scroll_controller.go
new file mode 100644
index 000000000..3f3e9d177
--- /dev/null
+++ b/pkg/gui/controllers/vertical_scroll_controller.go
@@ -0,0 +1,70 @@
+package controllers
+
+import (
+ "github.com/jesseduffield/gocui"
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
+)
+
+// given we have no fields here, arguably we shouldn't even need this factory
+// struct, but we're maintaining consistency with the other files.
+type VerticalScrollControllerFactory struct {
+ controllerCommon *controllerCommon
+}
+
+func NewVerticalScrollControllerFactory(c *controllerCommon) *VerticalScrollControllerFactory {
+ return &VerticalScrollControllerFactory{controllerCommon: c}
+}
+
+func (self *VerticalScrollControllerFactory) Create(context types.Context) types.IController {
+ return &VerticalScrollController{
+ baseController: baseController{},
+ controllerCommon: self.controllerCommon,
+ context: context,
+ }
+}
+
+type VerticalScrollController struct {
+ baseController
+ *controllerCommon
+
+ context types.Context
+}
+
+func (self *VerticalScrollController) Context() types.Context {
+ return self.context
+}
+
+func (self *VerticalScrollController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
+ return []*types.Binding{}
+}
+
+func (self *VerticalScrollController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
+ return []*gocui.ViewMouseBinding{
+ {
+ ViewName: self.context.GetViewName(),
+ Key: gocui.MouseWheelUp,
+ Handler: func(gocui.ViewMouseBindingOpts) error {
+ return self.HandleScrollUp()
+ },
+ },
+ {
+ ViewName: self.context.GetViewName(),
+ Key: gocui.MouseWheelDown,
+ Handler: func(gocui.ViewMouseBindingOpts) error {
+ return self.HandleScrollDown()
+ },
+ },
+ }
+}
+
+func (self *VerticalScrollController) HandleScrollUp() error {
+ self.context.GetViewTrait().ScrollUp(self.c.UserConfig.Gui.ScrollHeight)
+
+ return nil
+}
+
+func (self *VerticalScrollController) HandleScrollDown() error {
+ self.context.GetViewTrait().ScrollDown(self.c.UserConfig.Gui.ScrollHeight)
+
+ return nil
+}