66 "github.com/zyedidia/micro/v2/internal/config"
77 "github.com/zyedidia/micro/v2/internal/screen"
88 "github.com/zyedidia/micro/v2/internal/util"
9+ "strings"
10+ "unicode/utf8"
911)
1012
1113type TabWindow struct {
@@ -37,7 +39,7 @@ func (w *TabWindow) LocFromVisual(vloc buffer.Loc) int {
3739 return i
3840 }
3941 x += s
40- x += 3
42+ x += 1 + int ( config . GetGlobalOption ( "tabdist" ).( float64 ))
4143 if x >= w .Width {
4244 break
4345 }
@@ -111,12 +113,27 @@ func (w *TabWindow) Display() {
111113 if style , ok := config .Colorscheme ["tabbar.active" ]; ok {
112114 tabBarActiveStyle = style
113115 }
116+ tabBarInactiveStyle := tabBarStyle
117+ if style , ok := config .Colorscheme ["tabbar.inactive" ]; ok {
118+ tabBarInactiveStyle = style
119+ }
120+ tabBarDivStyle := tabBarStyle
121+ if style , ok := config .Colorscheme ["tabbar.div" ]; ok {
122+ tabBarDivStyle = style
123+ }
114124
115- draw := func (r rune , n int , active bool , tab bool ) {
125+ draw := func (r rune , n int , active bool , tab bool , div bool ) {
116126 style := tabBarStyle
117- if active {
118- style = tabBarActiveStyle
127+ if tab {
128+ if active {
129+ style = tabBarActiveStyle
130+ } else {
131+ style = tabBarInactiveStyle
132+ }
133+ } else if div {
134+ style = tabBarDivStyle
119135 }
136+
120137 for i := 0 ; i < n ; i ++ {
121138 rw := runewidth .RuneWidth (r )
122139 for j := 0 ; j < rw ; j ++ {
@@ -138,27 +155,64 @@ func (w *TabWindow) Display() {
138155 }
139156 }
140157
158+ var tabactivechars string
159+ var tabinactivechars string
160+ var tabdivchars string
161+ for _ , entry := range strings .Split (config .GetGlobalOption ("tabchars" ).(string ), "," ) {
162+ split := strings .SplitN (entry , "=" , 2 )
163+ if len (split ) < 2 {
164+ continue
165+ }
166+ key , val := split [0 ], split [1 ]
167+ switch key {
168+ case "active" :
169+ tabactivechars = val
170+ case "inactive" :
171+ tabinactivechars = val
172+ case "div" :
173+ tabdivchars = val
174+ }
175+ }
176+
177+ if utf8 .RuneCountInString (tabactivechars ) < 2 {
178+ tabactivechars += strings .Repeat (" " , 2 - utf8 .RuneCountInString (tabactivechars ))
179+ }
180+ if utf8 .RuneCountInString (tabinactivechars ) < 2 {
181+ tabinactivechars += strings .Repeat (" " , 2 - utf8 .RuneCountInString (tabinactivechars ))
182+ }
183+ if utf8 .RuneCountInString (tabinactivechars ) < 2 {
184+ tabinactivechars += strings .Repeat (" " , 2 - utf8 .RuneCountInString (tabinactivechars ))
185+ }
186+ tabdist := int (config .GetGlobalOption ("tabdist" ).(float64 ))
187+ if utf8 .RuneCountInString (tabdivchars ) < tabdist {
188+ tabdivchars += strings .Repeat (" " , tabdist - utf8 .RuneCountInString (tabdivchars ))
189+ }
190+ tabactiverunes := []rune (tabactivechars )
191+ tabinactiverunes := []rune (tabinactivechars )
192+ tabdivrunes := []rune (tabdivchars )
141193 for i , n := range w .Names {
142194 if i == w .active {
143- draw ('[' , 1 , true , true )
195+ draw (tabactiverunes [ 0 ] , 1 , true , true , false )
144196 } else {
145- draw (' ' , 1 , false , true )
197+ draw (tabinactiverunes [ 0 ] , 1 , false , true , false )
146198 }
147199
148200 for _ , c := range n {
149- draw (c , 1 , i == w .active , true )
201+ draw (c , 1 , i == w .active , true , false )
150202 }
151203
152204 if i == len (w .Names )- 1 {
153205 done = true
154206 }
155207
156208 if i == w .active {
157- draw (']' , 1 , true , true )
158- draw (' ' , 2 , true , false )
209+ draw (tabactiverunes [1 ], 1 , true , true , false )
159210 } else {
160- draw (' ' , 1 , false , true )
161- draw (' ' , 2 , false , false )
211+ draw (tabinactiverunes [1 ], 1 , false , true , false )
212+ }
213+
214+ for j := 0 ; j < tabdist ; j ++ {
215+ draw (tabdivrunes [j ], 1 , false , false , true )
162216 }
163217
164218 if x >= w .Width {
@@ -167,6 +221,6 @@ func (w *TabWindow) Display() {
167221 }
168222
169223 if x < w .Width {
170- draw (' ' , w .Width - x , false , globalTabReverse )
224+ draw (' ' , w .Width - x , false , false , false )
171225 }
172226}
0 commit comments