2020-03-29 01:31:34 +02:00
|
|
|
package gui
|
|
|
|
|
|
|
|
func (gui *Gui) validateNotInFilterMode() (bool, error) {
|
2020-08-22 03:44:03 +02:00
|
|
|
if gui.State.Modes.Filtering.Active() {
|
2020-08-15 08:38:16 +02:00
|
|
|
err := gui.ask(askOpts{
|
2020-11-16 11:38:26 +02:00
|
|
|
title: gui.Tr.MustExitFilterModeTitle,
|
|
|
|
prompt: gui.Tr.MustExitFilterModePrompt,
|
|
|
|
handleConfirm: gui.exitFilterMode,
|
2020-08-15 08:36:39 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return false, err
|
2020-03-29 01:31:34 +02:00
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) exitFilterMode() error {
|
2021-04-03 02:32:14 +02:00
|
|
|
return gui.clearFiltering()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) clearFiltering() error {
|
|
|
|
gui.State.Modes.Filtering.Reset()
|
|
|
|
if gui.State.ScreenMode == SCREEN_HALF {
|
|
|
|
gui.State.ScreenMode = SCREEN_NORMAL
|
|
|
|
}
|
|
|
|
|
|
|
|
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{COMMITS}})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) setFiltering(path string) error {
|
|
|
|
gui.State.Modes.Filtering.SetPath(path)
|
|
|
|
if gui.State.ScreenMode == SCREEN_NORMAL {
|
|
|
|
gui.State.ScreenMode = SCREEN_HALF
|
|
|
|
}
|
|
|
|
|
2021-04-03 06:56:11 +02:00
|
|
|
if err := gui.pushContext(gui.State.Contexts.BranchCommits); err != nil {
|
2021-04-03 02:32:14 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{COMMITS}, then: func() {
|
2021-04-03 06:56:11 +02:00
|
|
|
gui.State.Contexts.BranchCommits.GetPanelState().SetSelectedLineIdx(0)
|
2021-04-03 02:32:14 +02:00
|
|
|
}})
|
2020-03-29 01:31:34 +02:00
|
|
|
}
|