summaryrefslogtreecommitdiff
path: root/ui/buffers.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2021-07-14 22:44:03 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-07-15 09:18:01 +0200
commit5109024ac6023da89135c8cb60562ef3c1d409fa (patch)
tree43992421d65cbf04d1c253d6caea4789734c6a56 /ui/buffers.go
parentui: Introduce a vertical member list on channels (diff)
Make buffers indexed, and refer to indexes with /BUFFER
Fixes: #29
Diffstat (limited to 'ui/buffers.go')
-rw-r--r--ui/buffers.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/buffers.go b/ui/buffers.go
index 94e2a4e..3f2ae4a 100644
--- a/ui/buffers.go
+++ b/ui/buffers.go
@@ -1,6 +1,8 @@
package ui
import (
+ "fmt"
+ "math"
"strings"
"time"
@@ -396,6 +398,7 @@ func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width,
screen.SetContent(x0+width, y, 0x2502, nil, st)
}
+ indexPadding := 1 + int(math.Ceil(math.Log10(float64(len(bs.list)))))
for i, b := range bs.list {
st = tcell.StyleDefault
x := x0
@@ -408,7 +411,12 @@ func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width,
if i == bs.clicked {
st = st.Reverse(true)
}
- title := truncate(b.title, width, "\u2026")
+ indexText := fmt.Sprintf("%d:", i)
+ for ; x < x0+indexPadding-len(indexText); x++ {
+ screen.SetContent(x, y, ' ', nil, tcell.StyleDefault)
+ }
+ printString(screen, &x, y, Styled(indexText, st.Foreground(tcell.ColorGrey)))
+ title := truncate(b.title, width-(x-x0), "\u2026")
printString(screen, &x, y, Styled(title, st))
if 0 < b.highlights {
st = st.Foreground(tcell.ColorRed).Reverse(true)