mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-02 09:21:40 +02:00
more standardising modes
This commit is contained in:
parent
88ae550b93
commit
b3a7acbdad
@ -141,21 +141,17 @@ func (gui *Gui) handleInfoClick(g *gocui.Gui, v *gocui.View) error {
|
||||
cx, _ := v.Cursor()
|
||||
width, _ := v.Size()
|
||||
|
||||
// if we're in the normal context there will be a donate button here
|
||||
if width-cx <= len(gui.Tr.SLocalize("(reset)")) {
|
||||
if gui.State.Modes.Filtering.Active() {
|
||||
return gui.exitFilterMode()
|
||||
}
|
||||
if gui.State.Modes.Diffing.Active() {
|
||||
return gui.exitDiffMode()
|
||||
}
|
||||
if gui.GitCommand.PatchManager.Active() {
|
||||
return gui.handleResetPatch()
|
||||
}
|
||||
} else {
|
||||
if width-cx > len(gui.Tr.SLocalize("(reset)")) {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, mode := range gui.modeStatuses() {
|
||||
if mode.isActive() {
|
||||
return mode.reset()
|
||||
}
|
||||
}
|
||||
|
||||
// if we're not in an active mode we show the donate button
|
||||
if cx <= len(gui.Tr.SLocalize("Donate"))+len(INFO_SECTION_PADDING) {
|
||||
return gui.OSCommand.OpenLink("https://github.com/sponsors/jesseduffield")
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
type modeStatus struct {
|
||||
isActive func() bool
|
||||
description func() string
|
||||
onReset func() error
|
||||
reset func() error
|
||||
}
|
||||
|
||||
func (gui *Gui) modeStatuses() []modeStatus {
|
||||
@ -18,30 +18,44 @@ func (gui *Gui) modeStatuses() []modeStatus {
|
||||
{
|
||||
isActive: gui.State.Modes.Diffing.Active,
|
||||
description: func() string {
|
||||
return utils.ColoredString(fmt.Sprintf("%s %s %s", gui.Tr.SLocalize("showingGitDiff"), "git diff "+gui.diffStr(), utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)), color.FgMagenta)
|
||||
return utils.ColoredString(
|
||||
fmt.Sprintf("%s %s %s", gui.Tr.SLocalize("showingGitDiff"), "git diff "+gui.diffStr(), utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)),
|
||||
color.FgMagenta,
|
||||
)
|
||||
},
|
||||
onReset: gui.exitDiffMode,
|
||||
reset: gui.exitDiffMode,
|
||||
},
|
||||
{
|
||||
isActive: gui.State.Modes.Filtering.Active,
|
||||
description: func() string {
|
||||
return utils.ColoredString(fmt.Sprintf("%s '%s' %s", gui.Tr.SLocalize("filteringBy"), gui.State.Modes.Filtering.Path, utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)), color.FgRed, color.Bold)
|
||||
return utils.ColoredString(
|
||||
fmt.Sprintf("%s '%s' %s", gui.Tr.SLocalize("filteringBy"), gui.State.Modes.Filtering.Path, utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)),
|
||||
color.FgRed,
|
||||
color.Bold,
|
||||
)
|
||||
},
|
||||
onReset: gui.exitFilterMode,
|
||||
reset: gui.exitFilterMode,
|
||||
},
|
||||
{
|
||||
isActive: gui.GitCommand.PatchManager.Active,
|
||||
description: func() string {
|
||||
return utils.ColoredString(fmt.Sprintf("%s %s", gui.Tr.SLocalize("buildingPatch"), utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)), color.FgYellow, color.Bold)
|
||||
return utils.ColoredString(
|
||||
fmt.Sprintf("%s %s", gui.Tr.SLocalize("buildingPatch"), utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)),
|
||||
color.FgYellow,
|
||||
color.Bold,
|
||||
)
|
||||
},
|
||||
onReset: gui.handleResetPatch,
|
||||
reset: gui.handleResetPatch,
|
||||
},
|
||||
{
|
||||
isActive: gui.State.Modes.CherryPicking.Active,
|
||||
description: func() string {
|
||||
return utils.ColoredString(fmt.Sprintf("%d commits copied", len(gui.State.Modes.CherryPicking.CherryPickedCommits)), color.FgCyan)
|
||||
return utils.ColoredString(
|
||||
fmt.Sprintf("%d commits copied %s", len(gui.State.Modes.CherryPicking.CherryPickedCommits), utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)),
|
||||
color.FgCyan,
|
||||
)
|
||||
},
|
||||
onReset: gui.exitCherryPickingMode,
|
||||
reset: gui.exitCherryPickingMode,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func (gui *Gui) handleTopLevelReturn(g *gocui.Gui, v *gocui.View) error {
|
||||
|
||||
for _, mode := range gui.modeStatuses() {
|
||||
if mode.isActive() {
|
||||
return mode.onReset()
|
||||
return mode.reset()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user