summaryrefslogtreecommitdiff
path: root/ui/buffers.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ui/buffers.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/ui/buffers.go b/ui/buffers.go
index c126408..8285fc6 100644
--- a/ui/buffers.go
+++ b/ui/buffers.go
@@ -419,27 +419,35 @@ func (bs *BufferList) idx(netID, title string) int {
return -1
}
-func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width, height int) {
+func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width, height int, offset *int) {
+ if y0+len(bs.list)-*offset < height {
+ *offset = y0 + len(bs.list) - height
+ if *offset < 0 {
+ *offset = 0
+ }
+ }
+
width--
drawVerticalLine(screen, x0+width, y0, height)
clearArea(screen, x0, y0, width, height)
indexPadding := 1 + int(math.Ceil(math.Log10(float64(len(bs.list)))))
- for i, b := range bs.list {
+ for i, b := range bs.list[*offset:] {
+ bi := *offset + i
x := x0
y := y0 + i
st := tcell.StyleDefault
if b.unread {
st = st.Bold(true)
- } else if i == bs.current {
+ } else if bi == bs.current {
st = st.Underline(true)
}
- if i == bs.clicked {
+ if bi == bs.clicked {
st = st.Reverse(true)
}
if bs.showBufferNumbers {
indexSt := st.Foreground(tcell.ColorGray)
- indexText := fmt.Sprintf("%d:", i)
+ indexText := fmt.Sprintf("%d:", bi)
printString(screen, &x, y, Styled(indexText, indexSt))
x = x0 + indexPadding
}
@@ -448,7 +456,7 @@ func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width,
if b.title == "" {
title = b.netName
} else {
- if i == bs.clicked {
+ if bi == bs.clicked {
screen.SetContent(x, y, ' ', nil, tcell.StyleDefault.Reverse(true))
screen.SetContent(x+1, y, ' ', nil, tcell.StyleDefault.Reverse(true))
}
@@ -458,7 +466,7 @@ func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width,
title = truncate(title, width-(x-x0), "\u2026")
printString(screen, &x, y, Styled(title, st))
- if i == bs.clicked {
+ if bi == bs.clicked {
st := tcell.StyleDefault.Reverse(true)
for ; x < x0+width; x++ {
screen.SetContent(x, y, ' ', nil, st)