summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-29 10:11:15 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-29 11:37:29 +1100
commita2790cfe8e6705ebd81c63df2154ec82cb645ae3 (patch)
treeba41523fe4726471a8dfab7c29c93a0365dcb67b /pkg/gui/gui.go
parent624ae45ebb3f54499a25c4eba0844fa971277c34 (diff)
rename to filtered mode
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go40
1 files changed, 23 insertions, 17 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index a3f110427..b9ca704bd 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -217,12 +217,12 @@ type guiState struct {
PrevMainHeight int
OldInformation string
StartupStage int // one of INITIAL and COMPLETE. Allows us to not load everything at once
- LogScope string // the filename that gets passed to git log
+ FilterPath string // the filename that gets passed to git log
}
// for now the split view will always be on
// NewGui builds a new gui handler
-func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *commands.OSCommand, tr *i18n.Localizer, config config.AppConfigurer, updater *updates.Updater, logScope string) (*Gui, error) {
+func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *commands.OSCommand, tr *i18n.Localizer, config config.AppConfigurer, updater *updates.Updater, filterPath string) (*Gui, error) {
initialState := &guiState{
Files: make([]*commands.File, 0),
@@ -250,9 +250,9 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma
EditHistory: stack.New(),
},
},
- SideView: nil,
- Ptmx: nil,
- LogScope: logScope,
+ SideView: nil,
+ Ptmx: nil,
+ FilterPath: filterPath,
}
gui := &Gui{
@@ -511,8 +511,8 @@ func (gui *Gui) layout(g *gocui.Gui) error {
donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.SLocalize("Donate"))
information = donate + " " + information
}
- if gui.inScopedMode() {
- information = utils.ColoredString(fmt.Sprintf("%s '%s' %s", gui.Tr.SLocalize("scopingTo"), gui.State.LogScope, utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)), color.FgRed, color.Bold)
+ if gui.inFilterMode() {
+ information = utils.ColoredString(fmt.Sprintf("%s '%s' %s", gui.Tr.SLocalize("filteringBy"), gui.State.FilterPath, utils.ColoredString(gui.Tr.SLocalize("(reset)"), color.Underline)), color.FgRed, color.Bold)
} else if len(gui.State.CherryPickedCommits) > 0 {
information = utils.ColoredString(fmt.Sprintf("%d commits copied", len(gui.State.CherryPickedCommits)), color.FgCyan)
}
@@ -804,7 +804,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
if gui.g.CurrentView() == nil {
initialView := gui.getFilesView()
- if gui.inScopedMode() {
+ if gui.inFilterMode() {
initialView = gui.getCommitsView()
}
if _, err := gui.g.SetCurrentView(initialView.Name()); err != nil {
@@ -993,7 +993,7 @@ func (gui *Gui) Run() error {
}
defer g.Close()
- if gui.inScopedMode() {
+ if gui.inFilterMode() {
gui.State.ScreenMode = SCREEN_HALF
} else {
gui.State.ScreenMode = SCREEN_NORMAL
@@ -1123,10 +1123,9 @@ func (gui *Gui) handleInfoClick(g *gocui.Gui, v *gocui.View) error {
// if we're in the normal context there will be a donate button here
// if we have ('reset') at the end then
- if gui.inScopedMode() {
+ if gui.inFilterMode() {
if width-cx <= len(gui.Tr.SLocalize("(reset)")) {
- gui.State.LogScope = ""
- return gui.Errors.ErrRestart
+ return gui.exitFilterMode()
} else {
return nil
}
@@ -1177,13 +1176,20 @@ func (gui *Gui) handleMouseDownSecondary(g *gocui.Gui, v *gocui.View) error {
return nil
}
-func (gui *Gui) inScopedMode() bool {
- return gui.State.LogScope != ""
+func (gui *Gui) inFilterMode() bool {
+ return gui.State.FilterPath != ""
}
-func (gui *Gui) validateNotInScopedMode() (bool, error) {
- if gui.inScopedMode() {
- return false, gui.createErrorPanel("command not available in scoped mode. Either exit scoped mode or restart lazygit")
+func (gui *Gui) validateNotInFilterMode() (bool, error) {
+ if gui.inFilterMode() {
+ return false, gui.createConfirmationPanel(gui.g, gui.g.CurrentView(), true, gui.Tr.SLocalize("MustExitFilterModeTitle"), gui.Tr.SLocalize("MustExitFilterModePrompt"), func(*gocui.Gui, *gocui.View) error {
+ return gui.exitFilterMode()
+ }, nil)
}
return true, nil
}
+
+func (gui *Gui) exitFilterMode() error {
+ gui.State.FilterPath = ""
+ return gui.Errors.ErrRestart
+}