6 "github.com/zyedidia/tcell"
10 // This contains all the views in this tab
11 // There is generally only one view per tab, but you can have
12 // multiple views with splits
14 // This is the current view for this tab
16 // Generally this is the name of the current view's buffer
20 func NewTabFromView(v *View) *Tab {
22 t.views = append(t.views, v)
27 func (t *Tab) SetNum(num int) {
28 for _, v := range t.views {
33 // CurView returns the current view
34 func CurView() *View {
35 curTab := tabs[curTab]
36 return curTab.views[curTab.curView]
39 func TabbarString() (string, map[int]int) {
41 indicies := make(map[int]int)
43 for i, t := range tabs {
49 str += t.views[t.curView].Buf.Name
55 indicies[len(str)-1] = i + 1
61 func TabbarHandleMouseEvent(event tcell.Event) bool {
66 switch e := event.(type) {
67 case *tcell.EventMouse:
69 if button == tcell.Button1 {
74 str, indicies := TabbarString()
80 for k := range indicies {
81 keys = append(keys, k)
84 for _, k := range keys {
86 tabnum = indicies[k] - 1
103 str, _ := TabbarString()
105 tabBarStyle := defStyle.Reverse(true)
106 if style, ok := colorscheme["tabbar"]; ok {
110 // Maybe there is a unicode filename?
111 fileRunes := []rune(str)
112 w, _ := screen.Size()
113 for x := 0; x < w; x++ {
114 if x < len(fileRunes) {
115 screen.SetContent(x, 0, fileRunes[x], nil, tabBarStyle)
117 screen.SetContent(x, 0, ' ', nil, tabBarStyle)