2020-08-22 03:44:03 +02:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import (
|
2022-01-19 09:32:27 +02:00
|
|
|
"fmt"
|
|
|
|
|
2021-12-30 04:35:10 +02:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
2021-07-27 15:00:37 +02:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
2020-08-22 03:44:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type modeStatus struct {
|
|
|
|
isActive func() bool
|
|
|
|
description func() string
|
2020-08-23 01:23:59 +02:00
|
|
|
reset func() error
|
2020-08-22 03:44:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) modeStatuses() []modeStatus {
|
|
|
|
return []modeStatus{
|
|
|
|
{
|
|
|
|
isActive: gui.State.Modes.Diffing.Active,
|
|
|
|
description: func() string {
|
2022-01-19 09:32:27 +02:00
|
|
|
return gui.withResetButton(
|
|
|
|
fmt.Sprintf(
|
|
|
|
"%s %s",
|
2022-01-16 05:46:53 +02:00
|
|
|
gui.c.Tr.LcShowingGitDiff,
|
2022-01-19 09:32:27 +02:00
|
|
|
"git diff "+gui.diffStr(),
|
|
|
|
),
|
|
|
|
style.FgMagenta,
|
2020-08-23 01:23:59 +02:00
|
|
|
)
|
2020-08-22 03:44:03 +02:00
|
|
|
},
|
2020-08-23 01:23:59 +02:00
|
|
|
reset: gui.exitDiffMode,
|
2020-08-22 03:44:03 +02:00
|
|
|
},
|
|
|
|
{
|
2022-01-16 05:46:53 +02:00
|
|
|
isActive: gui.git.Patch.PatchManager.Active,
|
2020-08-22 03:44:03 +02:00
|
|
|
description: func() string {
|
2022-01-16 05:46:53 +02:00
|
|
|
return gui.withResetButton(gui.c.Tr.LcBuildingPatch, style.FgYellow.SetBold())
|
2020-08-22 03:44:03 +02:00
|
|
|
},
|
2021-04-06 01:50:09 +02:00
|
|
|
reset: gui.handleResetPatch,
|
2020-08-22 03:44:03 +02:00
|
|
|
},
|
|
|
|
{
|
2021-04-06 01:50:09 +02:00
|
|
|
isActive: gui.State.Modes.Filtering.Active,
|
2020-08-22 03:44:03 +02:00
|
|
|
description: func() string {
|
2022-01-19 09:32:27 +02:00
|
|
|
return gui.withResetButton(
|
|
|
|
fmt.Sprintf(
|
|
|
|
"%s '%s'",
|
2022-01-16 05:46:53 +02:00
|
|
|
gui.c.Tr.LcFilteringBy,
|
2022-01-19 09:32:27 +02:00
|
|
|
gui.State.Modes.Filtering.GetPath(),
|
|
|
|
),
|
|
|
|
style.FgRed,
|
2020-08-23 01:23:59 +02:00
|
|
|
)
|
2020-08-22 03:44:03 +02:00
|
|
|
},
|
2021-04-06 01:50:09 +02:00
|
|
|
reset: gui.exitFilterMode,
|
2020-08-22 03:44:03 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
isActive: gui.State.Modes.CherryPicking.Active,
|
|
|
|
description: func() string {
|
2022-01-19 09:32:27 +02:00
|
|
|
return gui.withResetButton(
|
|
|
|
fmt.Sprintf(
|
|
|
|
"%d commits copied",
|
|
|
|
len(gui.State.Modes.CherryPicking.CherryPickedCommits),
|
|
|
|
),
|
|
|
|
style.FgCyan,
|
2020-08-23 01:23:59 +02:00
|
|
|
)
|
2020-08-22 03:44:03 +02:00
|
|
|
},
|
2022-01-31 13:11:34 +02:00
|
|
|
reset: gui.helpers.CherryPick.Reset,
|
2020-08-22 03:44:03 +02:00
|
|
|
},
|
2021-10-31 23:58:58 +02:00
|
|
|
{
|
|
|
|
isActive: func() bool {
|
2022-01-16 05:46:53 +02:00
|
|
|
return gui.git.Status.WorkingTreeState() != enums.REBASE_MODE_NONE
|
2021-10-31 23:58:58 +02:00
|
|
|
},
|
|
|
|
description: func() string {
|
2022-01-16 05:46:53 +02:00
|
|
|
workingTreeState := gui.git.Status.WorkingTreeState()
|
2022-01-19 09:32:27 +02:00
|
|
|
return gui.withResetButton(
|
|
|
|
formatWorkingTreeState(workingTreeState), style.FgYellow,
|
2021-10-31 23:58:58 +02:00
|
|
|
)
|
|
|
|
},
|
2022-01-31 13:11:34 +02:00
|
|
|
reset: gui.helpers.Rebase.AbortMergeOrRebaseWithConfirm,
|
2021-10-31 23:58:58 +02:00
|
|
|
},
|
2022-01-19 09:32:27 +02:00
|
|
|
{
|
|
|
|
isActive: func() bool {
|
2022-01-31 13:11:34 +02:00
|
|
|
return gui.State.Model.BisectInfo.Started()
|
2022-01-19 09:32:27 +02:00
|
|
|
},
|
|
|
|
description: func() string {
|
|
|
|
return gui.withResetButton("bisecting", style.FgGreen)
|
|
|
|
},
|
2022-01-31 13:11:34 +02:00
|
|
|
reset: gui.helpers.Bisect.Reset,
|
2022-01-19 09:32:27 +02:00
|
|
|
},
|
2020-08-22 03:44:03 +02:00
|
|
|
}
|
|
|
|
}
|
2022-01-19 09:32:27 +02:00
|
|
|
|
|
|
|
func (gui *Gui) withResetButton(content string, textStyle style.TextStyle) string {
|
|
|
|
return textStyle.Sprintf(
|
|
|
|
"%s %s",
|
|
|
|
content,
|
2022-01-16 05:46:53 +02:00
|
|
|
style.AttrUnderline.Sprint(gui.c.Tr.ResetInParentheses),
|
2022-01-19 09:32:27 +02:00
|
|
|
)
|
|
|
|
}
|