mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-21 00:10:29 +00:00
parent
ef89697b59
commit
f0ad01d1ec
3 changed files with 6 additions and 3 deletions
|
|
@ -117,7 +117,7 @@ func HandleCommand(input string, view *View) {
|
|||
case "set":
|
||||
SetOption(view, args)
|
||||
case "quit":
|
||||
if view.CanClose("Quit anyway? ") {
|
||||
if view.CanClose("Quit anyway? (yes, no, save) ") {
|
||||
screen.Fini()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ func main() {
|
|||
switch e.Key() {
|
||||
case tcell.KeyCtrlQ:
|
||||
// Make sure not to quit if there are unsaved changes
|
||||
if view.CanClose("Quit anyway? ") {
|
||||
if view.CanClose("Quit anyway? (yes, no, save) ") {
|
||||
screen.Fini()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,6 +196,9 @@ func (v *View) CanClose(msg string) bool {
|
|||
if !canceled {
|
||||
if strings.ToLower(quit) == "yes" || strings.ToLower(quit) == "y" {
|
||||
return true
|
||||
} else if strings.ToLower(quit) == "save" || strings.ToLower(quit) == "s" {
|
||||
v.Save()
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -276,7 +279,7 @@ func (v *View) SelectAll() {
|
|||
// OpenFile opens a new file in the current view
|
||||
// It makes sure that the current buffer can be closed first (unsaved changes)
|
||||
func (v *View) OpenFile() {
|
||||
if v.CanClose("Continue? ") {
|
||||
if v.CanClose("Continue? (yes, no, save) ") {
|
||||
filename, canceled := messenger.Prompt("File to open: ")
|
||||
if canceled {
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue