// NewMenu returns a menu with a given configuration.
NewMenu returns a menu with a given configuration.
// NewMenu returns a menu with a given configuration .
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 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 , " " } } if m . keys . Up == nil { m . keys . Up = [ ] gruid . Key { gruid . KeyArrowUp , " " } } if m . keys . Left == nil { m . keys . Left = [ ] gruid . Key { gruid . KeyArrowLeft , " " } } if m . keys . Right == nil { m . keys . Right = [ ] gruid . Key { gruid . KeyArrowRight , " " } } 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 , " " , " " } } m . placeItems ( ) m . cursorAtFirstChoice ( ) m . dirty = true return m }
NewMenu returns a menu with a given configuration.
NewMenu returns a menu with a given configuration .