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

Use our new hyperlink support in the information view

This commit is contained in:
Stefan Haller
2024-08-16 11:32:52 +02:00
parent b411897a5a
commit bbd779b437
3 changed files with 4 additions and 29 deletions

View File

@ -14,8 +14,8 @@ func (gui *Gui) informationStr() string {
}
if gui.g.Mouse {
donate := style.FgMagenta.SetUnderline().Sprint(gui.c.Tr.Donate)
askQuestion := style.FgYellow.SetUnderline().Sprint(gui.c.Tr.AskQuestion)
donate := style.FgMagenta.Sprint(style.PrintHyperlink(gui.c.Tr.Donate, constants.Links.Donate))
askQuestion := style.FgYellow.Sprint(style.PrintHyperlink(gui.c.Tr.AskQuestion, constants.Links.Discussions))
return fmt.Sprintf("%s %s %s", donate, askQuestion, gui.Config.GetVersion())
} else {
return gui.Config.GetVersion()
@ -39,28 +39,5 @@ func (gui *Gui) handleInfoClick() error {
return activeMode.Reset()
}
var title, url string
// if we're not in an active mode we show the donate button
if cx <= utils.StringWidth(gui.c.Tr.Donate) {
url = constants.Links.Donate
title = gui.c.Tr.Donate
} else if cx <= utils.StringWidth(gui.c.Tr.Donate)+1+utils.StringWidth(gui.c.Tr.AskQuestion) {
url = constants.Links.Discussions
title = gui.c.Tr.AskQuestion
}
err := gui.os.OpenLink(url)
if err != nil {
// Opening the link via the OS failed for some reason. (For example, this
// can happen if the `os.openLink` config key references a command that
// doesn't exist, or that errors when called.)
//
// In that case, rather than crash the app, fall back to simply showing a
// dialog asking the user to visit the URL.
placeholders := map[string]string{"url": url}
message := utils.ResolvePlaceholderString(gui.c.Tr.PleaseGoToURL, placeholders)
return gui.c.Alert(title, message)
}
return nil
}