aboutsummaryrefslogtreecommitdiff
path: root/ui/widget
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-04 01:09:55 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-04 01:09:55 +0300
commit2a02f518b2eb5903e49a74224f4ca74461c379b8 (patch)
treed3d2e19073513b3d3472b3db38b17109d915d3d0 /ui/widget
parent122b2441c991a941193769569c532d8b0e198904 (diff)
Highlight whole room list row even if room name is short
Diffstat (limited to 'ui/widget')
-rw-r--r--ui/widget/util.go12
1 files changed, 12 insertions, 0 deletions
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)
+}