mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-06 15:10:27 +09:00
@@ -1008,7 +1008,7 @@ func (v *View) OpenFile(usePlugin bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if v.CanClose("Continue? (y,n,s) ", 'y', 'n', 's') {
|
||||
if v.CanClose() {
|
||||
filename, canceled := messenger.Prompt("File to open: ", "Open", FileCompletion)
|
||||
if canceled {
|
||||
return false
|
||||
@@ -1308,7 +1308,7 @@ func (v *View) Quit(usePlugin bool) bool {
|
||||
}
|
||||
|
||||
// Make sure not to quit if there are unsaved changes
|
||||
if v.CanClose("Quit anyway? (y,n,s) ", 'y', 'n', 's') {
|
||||
if v.CanClose() {
|
||||
v.CloseBuffer()
|
||||
if len(tabs[curTab].views) > 1 {
|
||||
v.splitNode.Delete()
|
||||
@@ -1354,7 +1354,7 @@ func (v *View) QuitAll(usePlugin bool) bool {
|
||||
closeAll := true
|
||||
for _, tab := range tabs {
|
||||
for _, v := range tab.views {
|
||||
if !v.CanClose("Quit anyway? (y,n,s) ", 'y', 'n', 's') {
|
||||
if !v.CanClose() {
|
||||
closeAll = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,15 +183,15 @@ func (v *View) ScrollDown(n int) {
|
||||
// If there are unsaved changes, the user will be asked if the view can be closed
|
||||
// causing them to lose the unsaved changes
|
||||
// The message is what to print after saying "You have unsaved changes. "
|
||||
func (v *View) CanClose(msg string, responses ...rune) bool {
|
||||
func (v *View) CanClose() bool {
|
||||
if v.Buf.IsModified {
|
||||
char, canceled := messenger.LetterPrompt("You have unsaved changes. "+msg, responses...)
|
||||
char, canceled := messenger.LetterPrompt("Save changes to "+v.Buf.Name+" before closing? (y,n,esc) ", 'y', 'n')
|
||||
if !canceled {
|
||||
if char == 'y' {
|
||||
return true
|
||||
} else if char == 's' {
|
||||
v.Save(true)
|
||||
return true
|
||||
} else if char == 'n' {
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -231,7 +231,7 @@ func (v *View) CloseBuffer() {
|
||||
|
||||
// ReOpen reloads the current buffer
|
||||
func (v *View) ReOpen() {
|
||||
if v.CanClose("Continue? (y,n,s) ", 'y', 'n', 's') {
|
||||
if v.CanClose() {
|
||||
screen.Clear()
|
||||
v.Buf.ReOpen()
|
||||
v.Relocate()
|
||||
|
||||
Reference in New Issue
Block a user