1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/information_panel.go

53 lines
1.2 KiB
Go
Raw Normal View History

2021-04-11 13:52:04 +02:00
package gui
import (
"fmt"
2021-04-11 15:32:20 +02:00
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/gui/style"
2021-04-11 13:52:04 +02:00
)
func (gui *Gui) informationStr() string {
for _, mode := range gui.modeStatuses() {
if mode.isActive() {
return mode.description()
}
}
if gui.g.Mouse {
donate := style.FgMagenta.SetUnderline().Sprint(gui.c.Tr.Donate)
askQuestion := style.FgYellow.SetUnderline().Sprint(gui.c.Tr.AskQuestion)
2021-04-11 13:52:04 +02:00
return fmt.Sprintf("%s %s %s", donate, askQuestion, gui.Config.GetVersion())
} else {
return gui.Config.GetVersion()
}
}
func (gui *Gui) handleInfoClick() error {
if !gui.g.Mouse {
return nil
}
view := gui.Views.Information
cx, _ := view.Cursor()
width, _ := view.Size()
for _, mode := range gui.modeStatuses() {
if mode.isActive() {
if width-cx > len(gui.c.Tr.ResetInParentheses) {
2021-04-11 13:52:04 +02:00
return nil
}
return mode.reset()
}
}
// if we're not in an active mode we show the donate button
if cx <= len(gui.c.Tr.Donate) {
2022-02-06 04:42:17 +02:00
return gui.os.OpenLink(constants.Links.Donate)
} else if cx <= len(gui.c.Tr.Donate)+1+len(gui.c.Tr.AskQuestion) {
2022-02-06 04:42:17 +02:00
return gui.os.OpenLink(constants.Links.Discussions)
2021-04-11 13:52:04 +02:00
}
return nil
}