+ return str, indicies
+}
+
+// TabbarHandleMouseEvent checks the given mouse event if it is clicking on the tabbar
+// If it is it changes the current tab accordingly
+// This function returns true if the tab is changed
+func TabbarHandleMouseEvent(event tcell.Event) bool {
+ // There is no tabbar displayed if there are less than 2 tabs
+ if len(tabs) <= 1 {
+ return false
+ }
+
+ switch e := event.(type) {
+ case *tcell.EventMouse:
+ button := e.Buttons()
+ // Must be a left click
+ if button == tcell.Button1 {
+ x, y := e.Position()
+ if y != 0 {
+ return false
+ }
+ str, indicies := TabbarString()
+ if x >= len(str) {
+ return false
+ }
+ var tabnum int
+ var keys []int
+ for k := range indicies {
+ keys = append(keys, k)
+ }
+ sort.Ints(keys)
+ for _, k := range keys {
+ if x <= k {
+ tabnum = indicies[k] - 1
+ break
+ }
+ }
+ curTab = tabnum
+ return true
+ }
+ }
+
+ return false
+}
+
+// DisplayTabs displays the tabbar at the top of the editor if there are multiple tabs
+func DisplayTabs() {
+ if len(tabs) <= 1 {
+ return
+ }
+
+ str, _ := TabbarString()