1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-09-16 09:16:26 +02:00

hide donate button if mouse events are disabled

This commit is contained in:
Jesse Duffield
2019-03-03 14:28:16 +11:00
parent f68166e858
commit 8305d8e72f
2 changed files with 14 additions and 9 deletions

View File

@@ -275,14 +275,17 @@ func (gui *Gui) onFocus(v *gocui.View) error {
func (gui *Gui) layout(g *gocui.Gui) error {
g.Highlight = true
width, height := g.Size()
donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.SLocalize("Donate"))
version := donate + " " + gui.Config.GetVersion()
information := gui.Config.GetVersion()
if gui.g.Mouse {
donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.SLocalize("Donate"))
information = donate + " " + information
}
leftSideWidth := width / 3
statusFilesBoundary := 2
filesBranchesBoundary := 2 * height / 5 // height - 20
commitsBranchesBoundary := 3 * height / 5 // height - 10
commitsStashBoundary := height - 5 // height - 5
optionsVersionBoundary := width - max(len(utils.Decolorise(version)), 1)
optionsVersionBoundary := width - max(len(utils.Decolorise(information)), 1)
minimumHeight := 16
minimumWidth := 10
@@ -308,10 +311,8 @@ func (gui *Gui) layout(g *gocui.Gui) error {
g.SetViewOnTop("limit")
}
return nil
} else {
_, _ = g.SetViewOnBottom("limit")
}
_, _ = g.SetViewOnBottom("limit")
g.DeleteView("limit")
optionsTop := height - 2
@@ -428,14 +429,14 @@ func (gui *Gui) layout(g *gocui.Gui) error {
}
}
if v, err := g.SetView("version", optionsVersionBoundary-1, optionsTop, width, optionsTop+2, 0); err != nil {
if v, err := g.SetView("information", optionsVersionBoundary-1, optionsTop, width, optionsTop+2, 0); err != nil {
if err.Error() != "unknown view" {
return err
}
v.BgColor = gocui.ColorDefault
v.FgColor = gocui.ColorGreen
v.Frame = false
if err := gui.renderString(g, "version", version); err != nil {
if err := gui.renderString(g, "information", information); err != nil {
return err
}
@@ -637,6 +638,10 @@ func (gui *Gui) quit(g *gocui.Gui, v *gocui.View) error {
}
func (gui *Gui) handleDonate(g *gocui.Gui, v *gocui.View) error {
if !gui.g.Mouse {
return nil
}
cx, _ := v.Cursor()
if cx > len(gui.Tr.SLocalize("Donate")) {
return nil

View File

@@ -437,7 +437,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Modifier: gocui.ModNone,
Handler: gui.handleMenuClose,
}, {
ViewName: "version",
ViewName: "information",
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleDonate,