You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

44 lines
889 B

package app
import (
"fmt"
"strings"
"git.brettb.xyz/goinv/client/internal/ui/style"
"github.com/rivo/tview"
)
func makeMenu(menuItems [][]string) *tview.TextView {
menu := tview.NewTextView().
SetDynamicColors(true).
SetWrap(true).
SetTextAlign(tview.AlignCenter)
menu.SetBackgroundColor(style.BgColor)
var menuList []string
for i, v := range menuItems {
key, item := genMenuItem(v)
if i == len(menuItems)-1 {
item += " "
}
menuList = append(menuList, key+item)
}
fmt.Fprintf(menu, "%s", strings.Join(menuList, " "))
return menu
}
func genMenuItem(items []string) (string, string) {
key := fmt.Sprintf("[%s::b] <%s>[-:-:-]", style.GetColorHex(style.MenuBgColor), items[0])
desc := fmt.Sprintf("[%s:%s:b] %s [-:-:-]",
style.GetColorHex(style.MenuFgColor),
style.GetColorHex(style.MenuBgColor),
strings.ToUpper(items[1]))
return key, desc
}