summaryrefslogtreecommitdiffstats
path: root/src/widgets/help.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/help.go')
-rw-r--r--src/widgets/help.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/widgets/help.go b/src/widgets/help.go
index eaa6f59..54ddfbc 100644
--- a/src/widgets/help.go
+++ b/src/widgets/help.go
@@ -45,7 +45,11 @@ func NewHelpMenu() *HelpMenu {
}
func (self *HelpMenu) Resize(termWidth, termHeight int) {
- textWidth := 53
+ var textWidth = 0
+ for _, line := range strings.Split(KEYBINDS, "\n") {
+ textWidth = maxInt(len(line), textWidth)
+ }
+ textWidth += 2
textHeight := 22
x := (termWidth - textWidth) / 2
y := (termHeight - textHeight) / 2
@@ -65,3 +69,10 @@ func (self *HelpMenu) Draw(buf *ui.Buffer) {
}
}
}
+
+func maxInt(a int, b int) int {
+ if a > b {
+ return a
+ }
+ return b
+}