mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-04 03:48:07 +02:00
ask question button
This commit is contained in:
parent
764bd556f3
commit
84b0c3df4f
@ -5,6 +5,8 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const INFO_SECTION_PADDING = " "
|
||||||
|
|
||||||
func (gui *Gui) mainSectionChildren() []*boxlayout.Box {
|
func (gui *Gui) mainSectionChildren() []*boxlayout.Box {
|
||||||
currentWindow := gui.currentWindow()
|
currentWindow := gui.currentWindow()
|
||||||
|
|
||||||
|
@ -187,32 +187,6 @@ func (gui *Gui) handleMouseDownSecondary() error {
|
|||||||
return nil
|
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) {
|
func (gui *Gui) fetch(canPromptForCredentials bool, span string) (err error) {
|
||||||
gui.Mutexes.FetchMutex.Lock()
|
gui.Mutexes.FetchMutex.Lock()
|
||||||
defer gui.Mutexes.FetchMutex.Unlock()
|
defer gui.Mutexes.FetchMutex.Unlock()
|
||||||
|
51
pkg/gui/information_panel.go
Normal file
51
pkg/gui/information_panel.go
Normal file
@ -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
|
||||||
|
}
|
@ -1,28 +1,11 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/fatih/color"
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
)
|
)
|
||||||
|
|
||||||
const SEARCH_PREFIX = "search: "
|
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 {
|
func (gui *Gui) createAllViews() error {
|
||||||
viewNameMappings := []struct {
|
viewNameMappings := []struct {
|
||||||
|
@ -233,6 +233,7 @@ type TranslationSet struct {
|
|||||||
CannotRebaseOntoFirstCommit string
|
CannotRebaseOntoFirstCommit string
|
||||||
CannotSquashOntoSecondCommit string
|
CannotSquashOntoSecondCommit string
|
||||||
Donate string
|
Donate string
|
||||||
|
AskQuestion string
|
||||||
PrevLine string
|
PrevLine string
|
||||||
NextLine string
|
NextLine string
|
||||||
PrevHunk string
|
PrevHunk string
|
||||||
@ -888,6 +889,7 @@ func englishTranslationSet() TranslationSet {
|
|||||||
CannotRebaseOntoFirstCommit: "You cannot interactive rebase onto the first commit",
|
CannotRebaseOntoFirstCommit: "You cannot interactive rebase onto the first commit",
|
||||||
CannotSquashOntoSecondCommit: "You cannot squash/fixup onto the second commit",
|
CannotSquashOntoSecondCommit: "You cannot squash/fixup onto the second commit",
|
||||||
Donate: "Donate",
|
Donate: "Donate",
|
||||||
|
AskQuestion: "Ask Question",
|
||||||
PrevLine: "select previous line",
|
PrevLine: "select previous line",
|
||||||
NextLine: "select next line",
|
NextLine: "select next line",
|
||||||
PrevHunk: "select previous hunk",
|
PrevHunk: "select previous hunk",
|
||||||
|
Loading…
Reference in New Issue
Block a user