aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/room-list.go2
-rw-r--r--ui/widget/util.go12
2 files changed, 13 insertions, 1 deletions
diff --git a/ui/room-list.go b/ui/room-list.go
index 11fa6b9..3ef64c3 100644
--- a/ui/room-list.go
+++ b/ui/room-list.go
@@ -718,7 +718,7 @@ func (list *RoomList) Draw(screen tcell.Screen) {
lineWidth -= len(unreadMessageCount) + 1
}
- widget.WriteLine(screen, tview.AlignLeft, text, x, y, lineWidth, style)
+ widget.WriteLinePadded(screen, tview.AlignLeft, text, x, y, lineWidth, style)
y++
if y >= bottomLimit {
diff --git a/ui/widget/util.go b/ui/widget/util.go
index dd94bdd..cd4f99f 100644
--- a/ui/widget/util.go
+++ b/ui/widget/util.go
@@ -20,6 +20,8 @@ import (
"github.com/mattn/go-runewidth"
"maunium.net/go/tcell"
"maunium.net/go/tview"
+ "fmt"
+ "strconv"
)
func WriteLineSimple(screen tcell.Screen, line string, x, y int) {
@@ -57,3 +59,13 @@ func WriteLine(screen tcell.Screen, align int, line string, x, y, maxWidth int,
}
}
}
+
+func WriteLinePadded(screen tcell.Screen, align int, line string, x, y, maxWidth int, style tcell.Style) {
+ padding := strconv.Itoa(maxWidth)
+ if align == tview.AlignRight {
+ line = fmt.Sprintf("%"+padding+"s", line)
+ } else {
+ line = fmt.Sprintf("%-"+padding+"s", line)
+ }
+ WriteLine(screen, tview.AlignLeft, line, x, y, maxWidth, style)
+}