Add QuitAll action to close all splits and tabs at once

See #239
This commit is contained in:
Zachary Yedidia
2016-08-30 17:38:46 -04:00
parent 8bdaacaa5e
commit b6f5db3692
4 changed files with 36 additions and 1 deletions

View File

@@ -1322,6 +1322,39 @@ func (v *View) Quit(usePlugin bool) bool {
return false
}
// QuitAll quits the whole editor; all splits and tabs
func (v *View) QuitAll(usePlugin bool) bool {
if usePlugin && !PreActionCall("QuitAll", v) {
return false
}
closeAll := true
for _, tab := range tabs {
for _, v := range tab.views {
if !v.CanClose("Quit anyway? (y,n,s) ", 'y', 'n', 's') {
closeAll = false
}
}
}
if closeAll {
for _, tab := range tabs {
for _, v := range tab.views {
v.CloseBuffer()
}
}
if usePlugin {
PostActionCall("QuitAll", v)
}
screen.Fini()
os.Exit(0)
}
return false
}
// AddTab adds a new tab with an empty buffer
func (v *View) AddTab(usePlugin bool) bool {
if usePlugin && !PreActionCall("AddTab", v) {

View File

@@ -72,6 +72,7 @@ var bindingActions = map[string]func(*View, bool) bool{
"ShellMode": (*View).ShellMode,
"CommandMode": (*View).CommandMode,
"Quit": (*View).Quit,
"QuitAll": (*View).QuitAll,
"AddTab": (*View).AddTab,
"PreviousTab": (*View).PreviousTab,
"NextTab": (*View).NextTab,

File diff suppressed because one or more lines are too long

View File

@@ -169,6 +169,7 @@ ClearStatus
ShellMode
CommandMode
Quit
QuitAll
AddTab
PreviousTab
NextTab