aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go2
-rw-r--r--termui/help_bar.go16
-rw-r--r--termui/label_select.go2
-rw-r--r--termui/show_bug.go2
4 files changed, 14 insertions, 8 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index d4e4552e..b2361907 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -128,7 +128,7 @@ func (bt *bugTable) layout(g *gocui.Gui) error {
v.Frame = false
v.FgColor = gocui.ColorWhite
- _, _ = fmt.Fprint(v, bugTableHelp.Render())
+ _, _ = fmt.Fprint(v, bugTableHelp.Render(maxX))
}
_, err = g.SetCurrentView(bugTableView)
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()
}
diff --git a/termui/label_select.go b/termui/label_select.go
index dc5adc2e..dfba20a6 100644
--- a/termui/label_select.go
+++ b/termui/label_select.go
@@ -153,7 +153,7 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
v.FgColor = gocui.ColorWhite
}
v.Clear()
- _, _ = fmt.Fprint(v, labelSelectHelp.Render())
+ _, _ = fmt.Fprint(v, labelSelectHelp.Render(maxX))
if _, err = g.SetViewOnTop(labelSelectInstructionsView); err != nil {
return err
}
diff --git a/termui/show_bug.go b/termui/show_bug.go
index 74eccd36..6296c445 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -105,7 +105,7 @@ func (sb *showBug) layout(g *gocui.Gui) error {
}
v.Clear()
- _, _ = fmt.Fprint(v, showBugHelp.Render())
+ _, _ = fmt.Fprint(v, showBugHelp.Render(maxX))
_, err = g.SetViewOnTop(showBugInstructionView)
if err != nil {