diff options
author | Jesse Duffield Duffield <jesseduffieldduffield@Jesses-MacBook-Pro-3.local> | 2019-02-25 22:11:35 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-02 17:49:30 +1100 |
commit | 8c0ea8f45fde1dfddd23198fcb06ae77468e3a3a (patch) | |
tree | ba923f1b86c26327ceec9f12de619265229bf642 /pkg/gui/gui.go | |
parent | afbc028ad6f2b8a580f6b22d13f3313ba5c44cf6 (diff) |
mouse support
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r-- | pkg/gui/gui.go | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index b4a55cc45..b3b219153 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -23,6 +23,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/updates" + "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sirupsen/logrus" ) @@ -274,13 +275,14 @@ func (gui *Gui) onFocus(v *gocui.View) error { func (gui *Gui) layout(g *gocui.Gui) error { g.Highlight = true width, height := g.Size() - version := gui.Config.GetVersion() + donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.SLocalize("Donate")) + version := donate + " " + gui.Config.GetVersion() 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(version), 1) + optionsVersionBoundary := width - max(len(utils.Decolorise(version)), 1) minimumHeight := 16 minimumWidth := 10 @@ -355,20 +357,22 @@ func (gui *Gui) layout(g *gocui.Gui) error { branchesView.FgColor = gocui.ColorWhite } - if v, err := g.SetView("commits", 0, commitsBranchesBoundary+panelSpacing, leftSideWidth, commitsStashBoundary, gocui.TOP|gocui.BOTTOM); err != nil { + commitsView, err := g.SetView("commits", 0, commitsBranchesBoundary+panelSpacing, leftSideWidth, commitsStashBoundary, gocui.TOP|gocui.BOTTOM) + if err != nil { if err.Error() != "unknown view" { return err } - v.Title = gui.Tr.SLocalize("CommitsTitle") - v.FgColor = gocui.ColorWhite + commitsView.Title = gui.Tr.SLocalize("CommitsTitle") + commitsView.FgColor = gocui.ColorWhite } - if v, err := g.SetView("stash", 0, commitsStashBoundary+panelSpacing, leftSideWidth, optionsTop, gocui.TOP|gocui.RIGHT); err != nil { + stashView, err := g.SetView("stash", 0, commitsStashBoundary+panelSpacing, leftSideWidth, optionsTop, gocui.TOP|gocui.RIGHT) + if err != nil { if err.Error() != "unknown view" { return err } - v.Title = gui.Tr.SLocalize("StashTitle") - v.FgColor = gocui.ColorWhite + stashView.Title = gui.Tr.SLocalize("StashTitle") + stashView.FgColor = gocui.ColorWhite } if v, err := g.SetView("options", appStatusOptionsBoundary-1, optionsTop, optionsVersionBoundary-1, optionsTop+2, 0); err != nil { @@ -465,6 +469,13 @@ func (gui *Gui) layout(g *gocui.Gui) error { listViews := map[*gocui.View]int{ filesView: gui.State.Panels.Files.SelectedLine, branchesView: gui.State.Panels.Branches.SelectedLine, + commitsView: gui.State.Panels.Commits.SelectedLine, + stashView: gui.State.Panels.Stash.SelectedLine, + } + + // menu view might not exist so we check to be safe + if menuView, err := gui.g.View("menu"); err == nil { + listViews[menuView] = gui.State.Panels.Menu.SelectedLine } for view, selectedLine := range listViews { // check if the selected line is now out of view and if so refocus it @@ -543,6 +554,8 @@ func (gui *Gui) Run() error { } defer g.Close() + g.Mouse = true + gui.g = g // TODO: always use gui.g rather than passing g around everywhere if err := gui.SetColorScheme(); err != nil { @@ -622,3 +635,11 @@ func (gui *Gui) quit(g *gocui.Gui, v *gocui.View) error { } return gocui.ErrQuit } + +func (gui *Gui) handleDonate(g *gocui.Gui, v *gocui.View) error { + cx, _ := v.Cursor() + if cx > len(gui.Tr.SLocalize("Donate")) { + return nil + } + return gui.OSCommand.OpenLink("https://donorbox.org/lazygit") +} |