Decouple escaping from quitting
When a user is not entering text into a prompt, the 'q' key should immediately quit the application. On the other hand, the 'esc' key should cancel/close/go-back to the previous context. If we're at the surface level (nothing to cancel/close) and the user hits the escape key, the default behaviour is to close the app, however we now have a `quitOnTopLevelReturn` config key to override this. I actually think from the beginning we should have made this config option default to false rather than true which is the default this PR gives it, but I don't want to anger too many people familiar with the existing behaviour.
This commit is contained in:
@@ -278,6 +278,7 @@ update:
|
||||
reporting: 'undetermined' # one of: 'on' | 'off' | 'undetermined'
|
||||
splashUpdatesIndex: 0
|
||||
confirmOnQuit: false
|
||||
quitOnTopLevelReturn: true
|
||||
keybinding:
|
||||
universal:
|
||||
quit: 'q'
|
||||
|
||||
@@ -217,7 +217,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
ViewName: "",
|
||||
Key: gui.getKey("universal.return"),
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleQuit,
|
||||
Handler: gui.handleTopLevelReturn,
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
@@ -848,12 +848,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
Handler: gui.handleMenuClose,
|
||||
Description: gui.Tr.SLocalize("closeMenu"),
|
||||
},
|
||||
{
|
||||
ViewName: "menu",
|
||||
Key: gui.getKey("universal.quit"),
|
||||
Handler: gui.handleMenuClose,
|
||||
Description: gui.Tr.SLocalize("closeMenu"),
|
||||
},
|
||||
{
|
||||
ViewName: "information",
|
||||
Key: gocui.MouseLeft,
|
||||
|
||||
@@ -25,7 +25,7 @@ func (gui *Gui) handleMenuSelect(g *gocui.Gui, v *gocui.View) error {
|
||||
|
||||
func (gui *Gui) renderMenuOptions() error {
|
||||
optionsMap := map[string]string{
|
||||
fmt.Sprintf("%s/%s", gui.getKeyDisplay("universal.return"), gui.getKeyDisplay("universal.quit")): gui.Tr.SLocalize("close"),
|
||||
gui.getKeyDisplay("universal.return"): gui.Tr.SLocalize("close"),
|
||||
fmt.Sprintf("%s %s", gui.getKeyDisplay("universal.prevItem"), gui.getKeyDisplay("universal.nextItem")): gui.Tr.SLocalize("navigate"),
|
||||
gui.getKeyDisplay("universal.select"): gui.Tr.SLocalize("execute"),
|
||||
}
|
||||
|
||||
@@ -34,6 +34,14 @@ func (gui *Gui) handleQuit(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.quit(v)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleTopLevelReturn(g *gocui.Gui, v *gocui.View) error {
|
||||
if gui.Config.GetUserConfig().GetBool("quitOnTopLevelReturn") {
|
||||
return gui.handleQuit(g, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) quit(v *gocui.View) error {
|
||||
if gui.State.Updating {
|
||||
return gui.createUpdateQuitConfirmation(gui.g, v)
|
||||
|
||||
@@ -513,7 +513,8 @@ func (gui *Gui) renderGlobalOptions() error {
|
||||
return gui.renderOptionsMap(map[string]string{
|
||||
fmt.Sprintf("%s/%s", gui.getKeyDisplay("universal.scrollUpMain"), gui.getKeyDisplay("universal.scrollDownMain")): gui.Tr.SLocalize("scroll"),
|
||||
fmt.Sprintf("%s %s %s %s", gui.getKeyDisplay("universal.prevBlock"), gui.getKeyDisplay("universal.nextBlock"), gui.getKeyDisplay("universal.prevItem"), gui.getKeyDisplay("universal.nextItem")): gui.Tr.SLocalize("navigate"),
|
||||
fmt.Sprintf("%s/%s", gui.getKeyDisplay("universal.return"), gui.getKeyDisplay("universal.quit")): gui.Tr.SLocalize("close"),
|
||||
gui.getKeyDisplay("universal.return"): gui.Tr.SLocalize("cancel"),
|
||||
gui.getKeyDisplay("universal.quit"): gui.Tr.SLocalize("quit"),
|
||||
gui.getKeyDisplay("universal.optionMenu"): gui.Tr.SLocalize("menu"),
|
||||
"1-5": gui.Tr.SLocalize("jump"),
|
||||
})
|
||||
|
||||
@@ -249,6 +249,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
||||
}, &i18n.Message{
|
||||
ID: "close",
|
||||
Other: "close",
|
||||
}, &i18n.Message{
|
||||
ID: "quit",
|
||||
Other: "quit",
|
||||
}, &i18n.Message{
|
||||
ID: "SureResetThisCommit",
|
||||
Other: "Are you sure you want to reset to this commit?",
|
||||
|
||||
Reference in New Issue
Block a user