return tw
}
+func (w *TabWindow) Resize(width, height int) {
+ w.width = width
+}
+
func (w *TabWindow) LocFromVisual(vloc buffer.Loc) int {
x := -w.hscroll
func (w *TabWindow) Scroll(amt int) {
w.hscroll += amt
- w.hscroll = util.Clamp(w.hscroll, 0, w.TotalSize()-w.width)
+ s := w.TotalSize()
+ w.hscroll = util.Clamp(w.hscroll, 0, s-w.width)
+
+ if s-w.width <= 0 {
+ w.hscroll = 0
+ }
}
func (w *TabWindow) TotalSize() int {
sum := 2
for _, n := range w.Names {
- sum += utf8.RuneCountInString(n) + 4
+ sum += runewidth.StringWidth(n) + 4
}
return sum - 4
}
w.active = a
x := 2
s := w.TotalSize()
+
for i, n := range w.Names {
c := utf8.RuneCountInString(n)
if i == a {
}
x += c + 4
}
+
+ if s-w.width <= 0 {
+ w.hscroll = 0
+ }
}
func (w *TabWindow) Display() {
c = ' '
}
if x == w.width-1 && !done {
- screen.Screen.SetContent(w.width-1, w.Y, '>', nil, config.DefStyle.Reverse(true))
+ screen.SetContent(w.width-1, w.Y, '>', nil, config.DefStyle.Reverse(true))
x++
break
} else if x == 0 && w.hscroll > 0 {
- screen.Screen.SetContent(0, w.Y, '<', nil, config.DefStyle.Reverse(true))
+ screen.SetContent(0, w.Y, '<', nil, config.DefStyle.Reverse(true))
} else if x >= 0 && x < w.width {
- screen.Screen.SetContent(x, w.Y, c, nil, config.DefStyle.Reverse(true))
+ screen.SetContent(x, w.Y, c, nil, config.DefStyle.Reverse(true))
}
x++
}