summaryrefslogtreecommitdiff
path: root/ui/buffers.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2021-10-19 21:13:25 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-10-19 21:13:25 +0200
commitce78dab820c632550c7e767e4601d0d4d2e34de2 (patch)
treec14d06b0f2d44a6052e0c9d4daa294f7d61a641e /ui/buffers.go
parentDon't forget to close outgoing chan on debug (diff)
Only show buffer numbers when necessary
Saves space also removed non-edition related method IsCommand out of editor.go
Diffstat (limited to 'ui/buffers.go')
-rw-r--r--ui/buffers.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/buffers.go b/ui/buffers.go
index bf045ca..79d2cf6 100644
--- a/ui/buffers.go
+++ b/ui/buffers.go
@@ -191,6 +191,8 @@ type BufferList struct {
tlInnerWidth int
tlHeight int
+
+ showBufferNumbers bool
}
// NewBufferList returns a new BufferList.
@@ -223,6 +225,10 @@ func (bs *BufferList) To(i int) bool {
return false
}
+func (bs *BufferList) ShowBufferNumbers(enabled bool) {
+ bs.showBufferNumbers = enabled
+}
+
func (bs *BufferList) Next() {
bs.current = (bs.current + 1) % len(bs.list)
bs.list[bs.current].highlights = 0
@@ -386,11 +392,13 @@ func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width,
if i == bs.clicked {
st = st.Reverse(true)
}
- indexText := fmt.Sprintf("%d:", i)
- for ; x < x0+indexPadding-len(indexText); x++ {
- screen.SetContent(x, y, ' ', nil, tcell.StyleDefault)
+ if bs.showBufferNumbers {
+ 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)))
}
- 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 {