Add 'Unsplit' action and VSplit and HSplit actions

This commit adds the 'Unsplit' action used to close all splits except
the current one.

It also adds the 'VSplit' and 'HSplit' actions which open empty
vertical/horizontal splits so you can bind them to keys.

Closes #228
This commit is contained in:
Zachary Yedidia
2016-10-04 11:08:32 -04:00
parent 3037d72bcb
commit 3733e7e223
4 changed files with 56 additions and 1 deletions

View File

@@ -1445,6 +1445,55 @@ func (v *View) NextTab(usePlugin bool) bool {
return false
}
// VSplitBinding opens an empty vertical split
func (v *View) VSplitBinding(usePlugin bool) bool {
if usePlugin && !PreActionCall("VSplit", v) {
return false
}
v.VSplit(NewBuffer([]byte{}, ""))
if usePlugin {
return PostActionCall("VSplit", v)
}
return false
}
// HSplitBinding opens an empty horizontal split
func (v *View) HSplitBinding(usePlugin bool) bool {
if usePlugin && !PreActionCall("HSplit", v) {
return false
}
v.HSplit(NewBuffer([]byte{}, ""))
if usePlugin {
return PostActionCall("HSplit", v)
}
return false
}
// Unsplit closes all splits in the current tab except the active one
func (v *View) Unsplit(usePlugin bool) bool {
if usePlugin && !PreActionCall("Unsplit", v) {
return false
}
curView := tabs[curTab].curView
for i := len(tabs[curTab].views) - 1; i >= 0; i-- {
view := tabs[curTab].views[i]
if view != nil && view.Num != curView {
view.Quit(true)
// messenger.Message("Quit ", view.Buf.Path)
}
}
if usePlugin {
return PostActionCall("Unsplit", v)
}
return false
}
// NextSplit changes the view to the next split
func (v *View) NextSplit(usePlugin bool) bool {
if usePlugin && !PreActionCall("NextSplit", v) {

View File

@@ -79,6 +79,9 @@ var bindingActions = map[string]func(*View, bool) bool{
"NextTab": (*View).NextTab,
"NextSplit": (*View).NextSplit,
"PreviousSplit": (*View).PreviousSplit,
"Unsplit": (*View).Unsplit,
"VSplit": (*View).VSplitBinding,
"HSplit": (*View).HSplitBinding,
"ToggleMacro": (*View).ToggleMacro,
"PlayMacro": (*View).PlayMacro,

File diff suppressed because one or more lines are too long

View File

@@ -187,6 +187,9 @@ AddTab
PreviousTab
NextTab
NextSplit
Unsplit
VSplit
HSplit
PreviousSplit
ToggleMacro
PlayMacro