aboutsummaryrefslogtreecommitdiffstats
path: root/termui/help_bar.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-08-22 15:27:57 +0200
committerMichael Muré <batolettre@gmail.com>2020-08-22 15:27:57 +0200
commit8eb7faf67c403e9692fa7faa0a3f2d74fa774330 (patch)
tree452106ca9239045b4358b22612069b790b62bc3e /termui/help_bar.go
parent9ce84fc1a310e04ab63661f5fc3963a9de317981 (diff)
downloadgit-bug-8eb7faf67c403e9692fa7faa0a3f2d74fa774330.tar.gz
termui: help bar background goes all the width
Diffstat (limited to 'termui/help_bar.go')
-rw-r--r--termui/help_bar.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/termui/help_bar.go b/termui/help_bar.go
index eb6facb6..78f8ebca 100644
--- a/termui/help_bar.go
+++ b/termui/help_bar.go
@@ -4,6 +4,8 @@ import (
"fmt"
"strings"
+ text "github.com/MichaelMure/go-term-text"
+
"github.com/MichaelMure/git-bug/util/colors"
)
@@ -12,13 +14,17 @@ type helpBar []struct {
text string
}
-func (hb helpBar) Render() string {
+func (hb helpBar) Render(maxX int) string {
var builder strings.Builder
- for i, entry := range hb {
- if i != 0 {
- builder.WriteByte(' ')
- }
+ for _, entry := range hb {
builder.WriteString(colors.BlueBg(fmt.Sprintf("[%s] %s", entry.keys, entry.text)))
+ builder.WriteByte(' ')
+ }
+
+ l := text.Len(builder.String())
+ if l < maxX {
+ builder.WriteString(colors.BlueBg(strings.Repeat(" ", maxX-l)))
}
+
return builder.String()
}