@@ -31,15 +31,26 @@ func (w *TabWindow) Resize(width, height int) {
3131
3232func (w * TabWindow ) LocFromVisual (vloc buffer.Loc ) int {
3333 x := - w .hscroll
34-
34+ tabactiverunes , tabinactiverunes , tabdivrunes := GetTabRunes ()
3535 for i , n := range w .Names {
36- x ++
36+ if i == w .active {
37+ x += len (tabactiverunes ) / 2
38+ } else {
39+ x += len (tabinactiverunes ) / 2
40+ }
41+
3742 s := util .CharacterCountInString (n )
3843 if vloc .Y == w .Y && vloc .X < x + s {
3944 return i
4045 }
4146 x += s
42- x += 1 + int (config .GetGlobalOption ("tabdist" ).(float64 ))
47+
48+ if i == w .active {
49+ x += len (tabactiverunes ) - len (tabactiverunes )/ 2
50+ } else {
51+ x += len (tabinactiverunes ) - len (tabinactiverunes )/ 2
52+ }
53+ x += len (tabdivrunes )
4354 if x >= w .Width {
4455 break
4556 }
@@ -92,6 +103,39 @@ func (w *TabWindow) SetActive(a int) {
92103 }
93104}
94105
106+ func GetTabRunes () ([]rune , []rune , []rune ) {
107+ var tabactivechars string
108+ var tabinactivechars string
109+ var tabdivchars string
110+ for _ , entry := range strings .Split (config .GetGlobalOption ("tabbarchars" ).(string ), "," ) {
111+ split := strings .SplitN (entry , "=" , 2 )
112+ if len (split ) < 2 {
113+ continue
114+ }
115+ key , val := split [0 ], split [1 ]
116+ switch key {
117+ case "active" :
118+ tabactivechars = val
119+ case "inactive" :
120+ tabinactivechars = val
121+ case "div" :
122+ tabdivchars = val
123+ }
124+ }
125+
126+ if utf8 .RuneCountInString (tabactivechars ) < 2 {
127+ tabactivechars = ""
128+ }
129+ if utf8 .RuneCountInString (tabinactivechars ) < 2 {
130+ tabinactivechars = ""
131+ }
132+
133+ tabactiverunes := []rune (tabactivechars )
134+ tabinactiverunes := []rune (tabinactivechars )
135+ tabdivrunes := []rune (tabdivchars )
136+ return tabactiverunes , tabinactiverunes , tabdivrunes
137+ }
138+
95139func (w * TabWindow ) Display () {
96140 x := - w .hscroll
97141 done := false
@@ -155,46 +199,22 @@ func (w *TabWindow) Display() {
155199 }
156200 }
157201
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- }
202+ tabactiverunes , tabinactiverunes , tabdivrunes := GetTabRunes ()
203+ leftactiverunes := tabactiverunes [0 : len (tabactiverunes )/ 2 ]
204+ rightactiverunes := tabactiverunes [len (tabactiverunes )/ 2 :]
205+
206+ leftinactiverunes := tabinactiverunes [0 : len (tabinactiverunes )/ 2 ]
207+ rightinactiverunes := tabinactiverunes [len (tabinactiverunes )/ 2 :]
176208
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 )
193209 for i , n := range w .Names {
194210 if i == w .active {
195- draw (tabactiverunes [0 ], 1 , true , true , false )
211+ for j := 0 ; j < len (leftactiverunes ); j ++ {
212+ draw (leftactiverunes [j ], 1 , true , true , false )
213+ }
196214 } else {
197- draw (tabinactiverunes [0 ], 1 , false , true , false )
215+ for j := 0 ; j < len (leftinactiverunes ); j ++ {
216+ draw (leftinactiverunes [j ], 1 , false , true , false )
217+ }
198218 }
199219
200220 for _ , c := range n {
@@ -206,12 +226,16 @@ func (w *TabWindow) Display() {
206226 }
207227
208228 if i == w .active {
209- draw (tabactiverunes [1 ], 1 , true , true , false )
229+ for j := 0 ; j < len (rightactiverunes ); j ++ {
230+ draw (rightactiverunes [j ], 1 , true , true , false )
231+ }
210232 } else {
211- draw (tabinactiverunes [1 ], 1 , false , true , false )
233+ for j := 0 ; j < len (rightinactiverunes ); j ++ {
234+ draw (rightinactiverunes [j ], 1 , false , true , false )
235+ }
212236 }
213237
214- for j := 0 ; j < tabdist ; j ++ {
238+ for j := 0 ; j < len ( tabdivrunes ) ; j ++ {
215239 draw (tabdivrunes [j ], 1 , false , false , true )
216240 }
217241
0 commit comments