]> git.lizzy.rs Git - micro.git/commitdiff
Make tab views array public
authorZachary Yedidia <zyedidia@gmail.com>
Sat, 3 Mar 2018 00:50:33 +0000 (19:50 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Sat, 3 Mar 2018 00:50:33 +0000 (19:50 -0500)
Ref #1024

cmd/micro/actions.go
cmd/micro/buffer.go
cmd/micro/command.go
cmd/micro/messenger.go
cmd/micro/micro.go
cmd/micro/settings.go
cmd/micro/split_tree.go
cmd/micro/tab.go

index 5b64a4d53cac80bd2f4154421b34b3b40166bb31..b9af7f6dc946285149ed99777b30dbb4b06c2ceb 100644 (file)
@@ -947,7 +947,7 @@ func (v *View) SaveAll(usePlugin bool) bool {
                }
 
                for _, t := range tabs {
-                       for _, v := range t.views {
+                       for _, v := range t.Views {
                                v.Save(false)
                        }
                }
@@ -1804,12 +1804,12 @@ func (v *View) Quit(usePlugin bool) bool {
                // 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)
@@ -1848,7 +1848,7 @@ func (v *View) QuitAll(usePlugin bool) bool {
 
                closeAll := true
                for _, tab := range tabs {
-                       for _, v := range tab.views {
+                       for _, v := range tab.Views {
                                if !v.CanClose() {
                                        closeAll = false
                                }
@@ -1861,7 +1861,7 @@ func (v *View) QuitAll(usePlugin bool) bool {
 
                        if shouldQuit {
                                for _, tab := range tabs {
-                                       for _, v := range tab.views {
+                                       for _, v := range tab.Views {
                                                v.CloseBuffer()
                                        }
                                }
@@ -1893,7 +1893,7 @@ func (v *View) AddTab(usePlugin bool) bool {
                curTab = len(tabs) - 1
                if len(tabs) == 2 {
                        for _, t := range tabs {
-                               for _, v := range t.views {
+                               for _, v := range t.Views {
                                        v.ToggleTabbar()
                                }
                        }
@@ -1986,8 +1986,8 @@ func (v *View) Unsplit(usePlugin bool) bool {
                }
 
                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)
@@ -2009,7 +2009,7 @@ func (v *View) NextSplit(usePlugin bool) bool {
                }
 
                tab := tabs[curTab]
-               if tab.CurView < len(tab.views)-1 {
+               if tab.CurView < len(tab.Views)-1 {
                        tab.CurView++
                } else {
                        tab.CurView = 0
@@ -2033,7 +2033,7 @@ func (v *View) PreviousSplit(usePlugin bool) bool {
                if tab.CurView > 0 {
                        tab.CurView--
                } else {
-                       tab.CurView = len(tab.views) - 1
+                       tab.CurView = len(tab.Views) - 1
                }
 
                if usePlugin {
index 5a0eb99563c9aed5f191a29f8e8599a46039a58b..b255fc00648c538ee513f37d45bb0ca44cfba25c 100644 (file)
@@ -131,7 +131,7 @@ func NewBuffer(reader io.Reader, size int64, path string) *Buffer {
 
        if path != "" {
                for _, tab := range tabs {
-                       for _, view := range tab.views {
+                       for _, view := range tab.Views {
                                if view.Buf.Path == path {
                                        return view.Buf
                                }
index 89f2d22fd586f85f8adc6c98f7cb31cf0d20a12d..976880d7a159922f9da08560c23e00eee19f03ad 100644 (file)
@@ -246,7 +246,7 @@ func Raw(args []string) {
        curTab = len(tabs) - 1
        if len(tabs) == 2 {
                for _, t := range tabs {
-                       for _, v := range t.views {
+                       for _, v := range t.Views {
                                v.ToggleTabbar()
                        }
                }
@@ -262,7 +262,7 @@ func TabSwitch(args []string) {
 
                        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
@@ -293,7 +293,7 @@ func Cd(args []string) {
                }
                wd, _ := os.Getwd()
                for _, tab := range tabs {
-                       for _, view := range tab.views {
+                       for _, view := range tab.Views {
                                if len(view.Buf.name) == 0 {
                                        continue
                                }
@@ -444,7 +444,7 @@ func NewTab(args []string) {
                curTab = len(tabs) - 1
                if len(tabs) == 2 {
                        for _, t := range tabs {
-                               for _, v := range t.views {
+                               for _, v := range t.Views {
                                        v.ToggleTabbar()
                                }
                        }
index b6ea2571e69706570cb037603a6098e35f3ec957..29f96e38ace6e7b88c665ee648f44ffa7731a911 100644 (file)
@@ -338,7 +338,7 @@ func (m *Messenger) Prompt(prompt, placeholder, historyType string, completionTy
                m.HandleEvent(event, m.history[historyType])
 
                m.Clear()
-               for _, v := range tabs[curTab].views {
+               for _, v := range tabs[curTab].Views {
                        v.Display()
                }
                DisplayTabs()
index 9b0bc751007e0b4eb63896cd599014f521e338c9..dc35ed2708f853b0a9c45bbc1b076200fe067892 100644 (file)
@@ -236,7 +236,7 @@ func RedrawAll() {
                }
        }
 
-       for _, v := range tabs[curTab].views {
+       for _, v := range tabs[curTab].Views {
                v.Display()
        }
        DisplayTabs()
@@ -268,7 +268,7 @@ func LoadAll() {
        InitColorscheme()
 
        for _, tab := range tabs {
-               for _, v := range tab.views {
+               for _, v := range tab.Views {
                        v.Buf.UpdateRules()
                }
        }
@@ -380,7 +380,7 @@ func main() {
                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)
                        }
 
@@ -459,7 +459,7 @@ func main() {
        LoadPlugins()
 
        for _, t := range tabs {
-               for _, v := range t.views {
+               for _, v := range t.Views {
                        GlobalPluginCall("onViewOpen", v)
                        GlobalPluginCall("onBufferOpen", v.Buf)
                }
@@ -505,7 +505,7 @@ func main() {
                case <-updateterm:
                        continue
                case vnum := <-closeterm:
-                       tabs[curTab].views[vnum].CloseTerminal()
+                       tabs[curTab].Views[vnum].CloseTerminal()
                case event = <-events:
                }
 
@@ -535,7 +535,7 @@ func main() {
                                                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
                                                                }
@@ -544,9 +544,9 @@ func main() {
                                        } 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 {
index cf1b209316ee5cb02568625e727fdf616317e456..5052054834998fd67ca821500ad7d38af4fa27cc 100644 (file)
@@ -320,7 +320,7 @@ func SetOption(option, value string) error {
                // LoadSyntaxFiles()
                InitColorscheme()
                for _, tab := range tabs {
-                       for _, view := range tab.views {
+                       for _, view := range tab.Views {
                                view.Buf.UpdateRules()
                        }
                }
@@ -343,7 +343,7 @@ func SetOption(option, value string) error {
        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)
                                }
                        }
@@ -389,7 +389,7 @@ func SetLocalOption(option, value string, view *View) error {
                // 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)
index 63b7ae0c644b72206208cc17e17a90e4e750818d..e34c37f1335865b1d146557afd922c1a61da94b2 100644 (file)
@@ -70,9 +70,9 @@ func (l *LeafNode) VSplit(buf *Buffer, splitIndex int) {
                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 {
@@ -94,9 +94,9 @@ func (l *LeafNode) VSplit(buf *Buffer, splitIndex int) {
                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
        }
@@ -123,9 +123,9 @@ func (l *LeafNode) HSplit(buf *Buffer, splitIndex int) {
                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 {
@@ -139,7 +139,7 @@ func (l *LeafNode) HSplit(buf *Buffer, splitIndex int) {
                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 {
@@ -148,9 +148,9 @@ func (l *LeafNode) HSplit(buf *Buffer, splitIndex int) {
                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
        }
@@ -167,12 +167,12 @@ func (l *LeafNode) Delete() {
        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 {
index b03736705d684809185a8d16ec4d77b2bd91c8cb..0998779aee2887542186ea086e5a3f312566fe70 100644 (file)
@@ -14,7 +14,7 @@ type Tab struct {
        // 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
 
@@ -24,12 +24,12 @@ type Tab struct {
 // 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
@@ -50,7 +50,7 @@ func NewTabFromView(v *View) *Tab {
 // 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
        }
 }
@@ -76,7 +76,7 @@ func (t *Tab) Resize() {
 
        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)
@@ -87,7 +87,7 @@ func (t *Tab) Resize() {
 // 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
@@ -103,7 +103,7 @@ func TabbarString() (string, map[int]int) {
                } else {
                        str += " "
                }
-               buf := t.views[t.CurView].Buf
+               buf := t.Views[t.CurView].Buf
                str += buf.GetName()
                if buf.Modified() {
                        str += " +"