aboutsummaryrefslogtreecommitdiffstats
path: root/termui/help_bar.go
diff options
context:
space:
mode:
Diffstat (limited to 'termui/help_bar.go')
-rw-r--r--termui/help_bar.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/termui/help_bar.go b/termui/help_bar.go
new file mode 100644
index 00000000..78f8ebca
--- /dev/null
+++ b/termui/help_bar.go
@@ -0,0 +1,30 @@
+package termui
+
+import (
+ "fmt"
+ "strings"
+
+ text "github.com/MichaelMure/go-term-text"
+
+ "github.com/MichaelMure/git-bug/util/colors"
+)
+
+type helpBar []struct {
+ keys string
+ text string
+}
+
+func (hb helpBar) Render(maxX int) string {
+ var builder strings.Builder
+ 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()
+}