1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

add mouse support

This commit is contained in:
Jesse Duffield
2019-11-10 16:20:35 +11:00
parent cd17b46b55
commit e85310c0a9
20 changed files with 420 additions and 125 deletions

View File

@ -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
}