func (m *Menu) SetActive(i int) {
	if i < 0 || i >= len(m.entries) {
		return
	}
	if !m.entries[i].Disabled {
		m.active = m.idxToPos(i)
	}
	m.dirty = true
}
SetActive updates the active entry among entries. It may be used
to launch the menu at a specific default starting index.
package ui
import (
	"fmt"
	"github.com/anaseto/gruid"
)
type MenuConfig struct {
	Grid    gruid.Grid   
	Entries []MenuEntry  
	Keys    MenuKeys     
	Box     *Box         
	Style   MenuStyle
}
type MenuEntry struct {
	Text StyledText
	Disabled bool
	Keys []gruid.Key
}
type MenuKeys struct {
	Up       []gruid.Key  
	Down     []gruid.Key  
	Left     []gruid.Key  
	Right    []gruid.Key  
	PageDown []gruid.Key  
	PageUp   []gruid.Key  
	Invoke   []gruid.Key  
	Quit     []gruid.Key  
}
type MenuStyle struct {
	Layout  gruid.Point  
	Active  gruid.Style  
	PageNum gruid.Style  
}
type Menu struct {
	grid    gruid.Grid
	entries []MenuEntry
	table   map[gruid.Point]item
	points  []gruid.Point
	pages   gruid.Point
	size    gruid.Point  
	box     *Box
	style   MenuStyle
	active  gruid.Point
	action  MenuAction
	keys    MenuKeys
	layout  gruid.Point  
	dirty   bool         
	drawn   gruid.Grid   
}
type item struct {
	grid gruid.Grid   
	i    int          
	page gruid.Point  
}
type MenuAction int
const (
	MenuPass MenuAction = iota
	MenuMove
	MenuInvoke
	MenuQuit
)
func NewMenu(cfg MenuConfig) *Menu {
	m := &Menu{
		grid:    cfg.Grid,
		entries: cfg.Entries,
		box:     cfg.Box,
		style:   cfg.Style,
		keys:    cfg.Keys,
	}
	if m.keys.Invoke == nil {
		m.keys.Invoke = []gruid.Key{gruid.KeyEnter}
	}
	if m.keys.Down == nil {
		m.keys.Down = []gruid.Key{gruid.KeyArrowDown, "j"}
	}
	if m.keys.Up == nil {
		m.keys.Up = []gruid.Key{gruid.KeyArrowUp, "k"}
	}
	if m.keys.Left == nil {
		m.keys.Left = []gruid.Key{gruid.KeyArrowLeft, "h"}
	}
	if m.keys.Right == nil {
		m.keys.Right = []gruid.Key{gruid.KeyArrowRight, "l"}
	}
	if m.keys.PageDown == nil {
		m.keys.PageDown = []gruid.Key{gruid.KeyPageDown}
	}
	if m.keys.PageUp == nil {
		m.keys.PageUp = []gruid.Key{gruid.KeyPageUp}
	}
	if m.keys.Quit == nil {
		m.keys.Quit = []gruid.Key{gruid.KeyEscape, "q", "Q"}
	}
	m.placeItems()
	m.cursorAtFirstChoice()
	m.dirty = true
	return m
}
func (m *Menu) Active() int {
	return m.table[m.active].i
}
func (m *Menu) ActiveBounds() gruid.Range {
	return m.table[m.active].grid.Bounds()
}
func (m *Menu) Bounds() gruid.Range {
	return m.pageGrid().Bounds()
}
func (m *Menu) Action() MenuAction {
	return m.action
}
func (m *Menu) SetEntries(entries []MenuEntry) {
	m.entries = entries
	m.placeItems()
	if !m.contains(m.active) {
		m.cursorAtLastChoice()
	}
	m.dirty = true
}
func (m *Menu) SetBox(b *Box) {
	m.box = b
	m.placeItems()
	m.dirty = true
}
func (m *Menu) contains(p gruid.Point) bool {
	_, ok := m.table[p]
	return ok
}