"github.com/zyedidia/tcell"
)
+// The TabList is a list of tabs and a window to display the tab bar
+// at the top of the screen
type TabList struct {
*display.TabWindow
List []*Tab
}
+// NewTabList creates a TabList from a list of buffers by creating a Tab
+// for each buffer
func NewTabList(bufs []*buffer.Buffer) *TabList {
w, h := screen.Screen.Size()
tl := new(TabList)
return tl
}
+// UpdateNames makes sure that the list of names the tab window has access to is
+// correct
func (t *TabList) UpdateNames() {
t.Names = t.Names[:0]
for _, p := range t.List {
}
}
+// AddTab adds a new tab to this TabList
func (t *TabList) AddTab(p *Tab) {
t.List = append(t.List, p)
t.Resize()
t.UpdateNames()
}
+// RemoveTab removes a tab with the given id from the TabList
func (t *TabList) RemoveTab(id uint64) {
for i, p := range t.List {
if len(p.Panes) == 0 {
}
}
+// Resize resizes all elements within the tab list
+// One thing to note is that when there is only 1 tab
+// the tab bar should not be drawn so resizing must take
+// that into account
func (t *TabList) Resize() {
w, h := screen.Screen.Size()
InfoBar.Resize(w, h-1)
}
}
+// HandleEvent checks for a resize event or a mouse event on the tab bar
+// otherwise it will forward the event to the currently active tab
func (t *TabList) HandleEvent(event tcell.Event) {
switch e := event.(type) {
case *tcell.EventResize:
t.List[t.Active()].HandleEvent(event)
}
+// Display updates the names and then displays the tab bar
func (t *TabList) Display() {
t.UpdateNames()
if len(t.List) > 1 {
}
}
+// Tabs is the global tab list
var Tabs *TabList
func InitTabs(bufs []*buffer.Buffer) {
resizing *views.Node // node currently being resized
}
+// NewTabFromBuffer creates a new tab from the given buffer
func NewTabFromBuffer(x, y, width, height int, b *buffer.Buffer) *Tab {
t := new(Tab)
t.Node = views.NewRoot(x, y, width, height)
v := p.GetView()
inpane := mx >= v.X && mx < v.X+v.Width && my >= v.Y && my < v.Y+v.Height
if inpane {
- t.active = i
- p.SetActive(true)
- } else {
- p.SetActive(false)
+ t.SetActive(i)
+ break
}
}
case tcell.ButtonNone: