diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/arrangement.go | 2 | ||||
-rw-r--r-- | pkg/gui/global_handlers.go | 26 | ||||
-rw-r--r-- | pkg/gui/information_panel.go | 51 | ||||
-rw-r--r-- | pkg/gui/layout.go | 17 | ||||
-rw-r--r-- | pkg/i18n/english.go | 2 |
5 files changed, 55 insertions, 43 deletions
diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go index 93e49fe46..f5fd02d23 100644 --- a/pkg/gui/arrangement.go +++ b/pkg/gui/arrangement.go @@ -5,6 +5,8 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) +const INFO_SECTION_PADDING = " " + func (gui *Gui) mainSectionChildren() []*boxlayout.Box { currentWindow := gui.currentWindow() diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index eee09a546..6e098fb6c 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -187,32 +187,6 @@ func (gui *Gui) handleMouseDownSecondary() error { return nil } -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.Tr.ResetInParentheses) { - return nil - } - return mode.reset() - } - } - - // if we're not in an active mode we show the donate button - if cx <= len(gui.Tr.Donate)+len(INFO_SECTION_PADDING) { - return gui.OSCommand.OpenLink("https://github.com/sponsors/jesseduffield") - } - return nil -} - func (gui *Gui) fetch(canPromptForCredentials bool, span string) (err error) { gui.Mutexes.FetchMutex.Lock() defer gui.Mutexes.FetchMutex.Unlock() diff --git a/pkg/gui/information_panel.go b/pkg/gui/information_panel.go new file mode 100644 index 000000000..10292026d --- /dev/null +++ b/pkg/gui/information_panel.go @@ -0,0 +1,51 @@ +package gui + +import ( + "fmt" + + "github.com/fatih/color" +) + +func (gui *Gui) informationStr() string { + for _, mode := range gui.modeStatuses() { + if mode.isActive() { + return mode.description() + } + } + + if gui.g.Mouse { + donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.Donate) + askQuestion := color.New(color.FgYellow, color.Underline).Sprint(gui.Tr.AskQuestion) + 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.Tr.ResetInParentheses) { + return nil + } + return mode.reset() + } + } + + // if we're not in an active mode we show the donate button + if cx <= len(gui.Tr.Donate) { + return gui.OSCommand.OpenLink("https://github.com/sponsors/jesseduffield") + } else if cx <= len(gui.Tr.Donate)+1+len(gui.Tr.AskQuestion) { + return gui.OSCommand.OpenLink("https://github.com/jesseduffield/lazygit/discussions") + } + return nil +} diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index 9846e67ef..07ffb2814 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -1,28 +1,11 @@ package gui import ( - "github.com/fatih/color" "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/theme" ) const SEARCH_PREFIX = "search: " -const INFO_SECTION_PADDING = " " - -func (gui *Gui) informationStr() string { - for _, mode := range gui.modeStatuses() { - if mode.isActive() { - return mode.description() - } - } - - if gui.g.Mouse { - donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.Donate) - return donate + " " + gui.Config.GetVersion() - } else { - return gui.Config.GetVersion() - } -} func (gui *Gui) createAllViews() error { viewNameMappings := []struct { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 97791f014..98c219620 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -233,6 +233,7 @@ type TranslationSet struct { CannotRebaseOntoFirstCommit string CannotSquashOntoSecondCommit string Donate string + AskQuestion string PrevLine string NextLine string PrevHunk string @@ -888,6 +889,7 @@ func englishTranslationSet() TranslationSet { CannotRebaseOntoFirstCommit: "You cannot interactive rebase onto the first commit", CannotSquashOntoSecondCommit: "You cannot squash/fixup onto the second commit", Donate: "Donate", + AskQuestion: "Ask Question", PrevLine: "select previous line", NextLine: "select next line", PrevHunk: "select previous hunk", |