}
for _, t := range tabs {
- for _, v := range t.views {
+ for _, v := range t.Views {
v.Save(false)
}
}
// Make sure not to quit if there are unsaved changes
if v.CanClose() {
v.CloseBuffer()
- if len(tabs[curTab].views) > 1 {
+ if len(tabs[curTab].Views) > 1 {
v.splitNode.Delete()
tabs[v.TabNum].Cleanup()
tabs[v.TabNum].Resize()
} else if len(tabs) > 1 {
- if len(tabs[v.TabNum].views) == 1 {
+ if len(tabs[v.TabNum].Views) == 1 {
tabs = tabs[:v.TabNum+copy(tabs[v.TabNum:], tabs[v.TabNum+1:])]
for i, t := range tabs {
t.SetNum(i)
closeAll := true
for _, tab := range tabs {
- for _, v := range tab.views {
+ for _, v := range tab.Views {
if !v.CanClose() {
closeAll = false
}
if shouldQuit {
for _, tab := range tabs {
- for _, v := range tab.views {
+ for _, v := range tab.Views {
v.CloseBuffer()
}
}
curTab = len(tabs) - 1
if len(tabs) == 2 {
for _, t := range tabs {
- for _, v := range t.views {
+ for _, v := range t.Views {
v.ToggleTabbar()
}
}
}
curView := tabs[curTab].CurView
- for i := len(tabs[curTab].views) - 1; i >= 0; i-- {
- view := tabs[curTab].views[i]
+ 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)
}
tab := tabs[curTab]
- if tab.CurView < len(tab.views)-1 {
+ if tab.CurView < len(tab.Views)-1 {
tab.CurView++
} else {
tab.CurView = 0
if tab.CurView > 0 {
tab.CurView--
} else {
- tab.CurView = len(tab.views) - 1
+ tab.CurView = len(tab.Views) - 1
}
if usePlugin {
if path != "" {
for _, tab := range tabs {
- for _, view := range tab.views {
+ for _, view := range tab.Views {
if view.Buf.Path == path {
return view.Buf
}
curTab = len(tabs) - 1
if len(tabs) == 2 {
for _, t := range tabs {
- for _, v := range t.views {
+ for _, v := range t.Views {
v.ToggleTabbar()
}
}
found := false
for _, t := range tabs {
- v := t.views[t.CurView]
+ v := t.Views[t.CurView]
if v.Buf.GetName() == args[0] {
curTab = v.TabNum
found = true
}
wd, _ := os.Getwd()
for _, tab := range tabs {
- for _, view := range tab.views {
+ for _, view := range tab.Views {
if len(view.Buf.name) == 0 {
continue
}
curTab = len(tabs) - 1
if len(tabs) == 2 {
for _, t := range tabs {
- for _, v := range t.views {
+ for _, v := range t.Views {
v.ToggleTabbar()
}
}
m.HandleEvent(event, m.history[historyType])
m.Clear()
- for _, v := range tabs[curTab].views {
+ for _, v := range tabs[curTab].Views {
v.Display()
}
DisplayTabs()
}
}
- for _, v := range tabs[curTab].views {
+ for _, v := range tabs[curTab].Views {
v.Display()
}
DisplayTabs()
InitColorscheme()
for _, tab := range tabs {
- for _, v := range tab.views {
+ for _, v := range tab.Views {
v.Buf.UpdateRules()
}
}
tab.SetNum(len(tabs))
tabs = append(tabs, tab)
for _, t := range tabs {
- for _, v := range t.views {
+ for _, v := range t.Views {
v.Center(false)
}
LoadPlugins()
for _, t := range tabs {
- for _, v := range t.views {
+ for _, v := range t.Views {
GlobalPluginCall("onViewOpen", v)
GlobalPluginCall("onBufferOpen", v.Buf)
}
case <-updateterm:
continue
case vnum := <-closeterm:
- tabs[curTab].views[vnum].CloseTerminal()
+ tabs[curTab].Views[vnum].CloseTerminal()
case event = <-events:
}
if CurView().mouseReleased {
// We loop through each view in the current tab and make sure the current view
// is the one being clicked in
- for _, v := range tabs[curTab].views {
+ for _, v := range tabs[curTab].Views {
if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height {
tabs[curTab].CurView = v.Num
}
} else if e.Buttons() == tcell.WheelUp || e.Buttons() == tcell.WheelDown {
var view *View
x, y := e.Position()
- for _, v := range tabs[curTab].views {
+ for _, v := range tabs[curTab].Views {
if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height {
- view = tabs[curTab].views[v.Num]
+ view = tabs[curTab].Views[v.Num]
}
}
if view != nil {
// LoadSyntaxFiles()
InitColorscheme()
for _, tab := range tabs {
- for _, view := range tab.views {
+ for _, view := range tab.Views {
view.Buf.UpdateRules()
}
}
if len(tabs) != 0 {
if _, ok := CurView().Buf.Settings[option]; ok {
for _, tab := range tabs {
- for _, view := range tab.views {
+ for _, view := range tab.Views {
SetLocalOption(option, value, view)
}
}
// If it is being turned off, we have to hash every open buffer
var empty [16]byte
for _, tab := range tabs {
- for _, v := range tab.views {
+ for _, v := range tab.Views {
if !nativeValue.(bool) {
if v.Buf.origHash == empty {
data, err := ioutil.ReadFile(v.Buf.AbsPath)
copy(l.parent.children[splitIndex+1:], l.parent.children[splitIndex:])
l.parent.children[splitIndex] = NewLeafNode(newView, l.parent)
- tab.views = append(tab.views, nil)
- copy(tab.views[splitIndex+1:], tab.views[splitIndex:])
- tab.views[splitIndex] = newView
+ tab.Views = append(tab.Views, nil)
+ copy(tab.Views[splitIndex+1:], tab.Views[splitIndex:])
+ tab.Views[splitIndex] = newView
tab.CurView = splitIndex
} else {
l.parent.children[search(l.parent.children, l)] = s
l.parent = s
- tab.views = append(tab.views, nil)
- copy(tab.views[splitIndex+1:], tab.views[splitIndex:])
- tab.views[splitIndex] = newView
+ tab.Views = append(tab.Views, nil)
+ copy(tab.Views[splitIndex+1:], tab.Views[splitIndex:])
+ tab.Views[splitIndex] = newView
tab.CurView = splitIndex
}
copy(l.parent.children[splitIndex+1:], l.parent.children[splitIndex:])
l.parent.children[splitIndex] = NewLeafNode(newView, l.parent)
- tab.views = append(tab.views, nil)
- copy(tab.views[splitIndex+1:], tab.views[splitIndex:])
- tab.views[splitIndex] = newView
+ tab.Views = append(tab.Views, nil)
+ copy(tab.Views[splitIndex+1:], tab.Views[splitIndex:])
+ tab.Views[splitIndex] = newView
tab.CurView = splitIndex
} else {
s.parent = l.parent
newView := NewView(buf)
newView.TabNum = l.parent.tabNum
- newView.Num = len(tab.views)
+ newView.Num = len(tab.Views)
if splitIndex == 1 {
s.children = []Node{l, NewLeafNode(newView, s)}
} else {
l.parent.children[search(l.parent.children, l)] = s
l.parent = s
- tab.views = append(tab.views, nil)
- copy(tab.views[splitIndex+1:], tab.views[splitIndex:])
- tab.views[splitIndex] = newView
+ tab.Views = append(tab.Views, nil)
+ copy(tab.Views[splitIndex+1:], tab.Views[splitIndex:])
+ tab.Views[splitIndex] = newView
tab.CurView = splitIndex
}
l.parent.children = l.parent.children[:len(l.parent.children)-1]
tab := tabs[l.parent.tabNum]
- j := findView(tab.views, l.view)
- copy(tab.views[j:], tab.views[j+1:])
- tab.views[len(tab.views)-1] = nil // or the zero value of T
- tab.views = tab.views[:len(tab.views)-1]
+ j := findView(tab.Views, l.view)
+ copy(tab.Views[j:], tab.Views[j+1:])
+ tab.Views[len(tab.Views)-1] = nil // or the zero value of T
+ tab.Views = tab.Views[:len(tab.Views)-1]
- for i, v := range tab.views {
+ for i, v := range tab.Views {
v.Num = i
}
if tab.CurView > 0 {
// This contains all the views in this tab
// There is generally only one view per tab, but you can have
// multiple views with splits
- views []*View
+ Views []*View
// This is the current view for this tab
CurView int
// NewTabFromView creates a new tab and puts the given view in the tab
func NewTabFromView(v *View) *Tab {
t := new(Tab)
- t.views = append(t.views, v)
- t.views[0].Num = 0
+ t.Views = append(t.Views, v)
+ t.Views[0].Num = 0
t.tree = new(SplitTree)
t.tree.kind = VerticalSplit
- t.tree.children = []Node{NewLeafNode(t.views[0], t.tree)}
+ t.tree.children = []Node{NewLeafNode(t.Views[0], t.tree)}
w, h := screen.Size()
t.tree.width = w
// SetNum sets all this tab's views to have the correct tab number
func (t *Tab) SetNum(num int) {
t.tree.tabNum = num
- for _, v := range t.views {
+ for _, v := range t.Views {
v.TabNum = num
}
}
t.tree.ResizeSplits()
- for i, v := range t.views {
+ for i, v := range t.Views {
v.Num = i
if v.Type == vtTerm {
v.term.Resize(v.Width, v.Height)
// CurView returns the current view
func CurView() *View {
curTab := tabs[curTab]
- return curTab.views[curTab.CurView]
+ return curTab.Views[curTab.CurView]
}
// TabbarString returns the string that should be displayed in the tabbar
} else {
str += " "
}
- buf := t.views[t.CurView].Buf
+ buf := t.Views[t.CurView].Buf
str += buf.GetName()
if buf.Modified() {
str += " +"