diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-10 16:20:35 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-10 22:32:13 +1100 |
commit | e85310c0a92a89167530241bdc3fc5f66a48706d (patch) | |
tree | f7989a8b002d2d5aa847460cae112aac9f64b669 /pkg/gui/gui.go | |
parent | cd17b46b55e312b3ba4e3ab9d3d96a8eeb20fded (diff) |
add mouse support
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r-- | pkg/gui/gui.go | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 8a14fde36..b69b30965 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -118,12 +118,18 @@ type stashPanelState struct { type menuPanelState struct { SelectedLine int + OnPress func(g *gocui.Gui, v *gocui.View) error } type commitFilesPanelState struct { SelectedLine int } +type statusPanelState struct { + pushables string + pullables string +} + type panelStates struct { Files *filePanelState Branches *branchPanelState @@ -133,6 +139,7 @@ type panelStates struct { LineByLine *lineByLinePanelState Merging *mergingPanelState CommitFiles *commitFilesPanelState + Status *statusPanelState } type guiState struct { @@ -179,6 +186,7 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma Conflicts: []commands.Conflict{}, EditHistory: stack.New(), }, + Status: &statusPanelState{}, }, } @@ -257,7 +265,7 @@ func (gui *Gui) onFocusChange() error { for _, view := range gui.g.Views() { view.Highlight = view == currentView } - return gui.setMainTitle() + return nil } func (gui *Gui) onFocusLost(v *gocui.View, newView *gocui.View) error { @@ -683,6 +691,8 @@ func (gui *Gui) Run() error { } defer g.Close() + g.Log = gui.Log + if gui.Config.GetUserConfig().GetBool("gui.mouseEvents") { g.Mouse = true } @@ -795,3 +805,31 @@ func (gui *Gui) setColorScheme() error { return nil } + +func (gui *Gui) handleMouseDownMain(g *gocui.Gui, v *gocui.View) error { + if gui.popupPanelFocused() { + return nil + } + + switch g.CurrentView().Name() { + case "files": + return gui.enterFile(false, v.SelectedLineIdx()) + case "commitFiles": + return gui.enterCommitFile(v.SelectedLineIdx()) + } + + return nil +} + +func (gui *Gui) handleMouseDownSecondary(g *gocui.Gui, v *gocui.View) error { + if gui.popupPanelFocused() { + return nil + } + + switch g.CurrentView().Name() { + case "files": + return gui.enterFile(true, v.SelectedLineIdx()) + } + + return nil +} |