Beispiel #1
0
func NewMenu(items []*Item) (*Menu, error) {
	menu := (*Menu)(C.new_menu((**C.ITEM)(void(&items[0]))))
	if menu == nil {
		return nil, MenusError{"NewMenu failed"}
	}
	return menu, nil
}
Beispiel #2
0
// NewMenu returns a pointer to a new menu.
func NewMenu(items []*MenuItem) (*Menu, error) {
	citems := make([]*C.ITEM, len(items)+1)
	for index, item := range items {
		citems[index] = item.item
	}
	citems[len(items)] = nil
	var menu *C.MENU
	var err error
	menu, err = C.new_menu((**C.ITEM)(&citems[0]))
	return &Menu{menu}, ncursesError(err)
}
Beispiel #3
0
func NewMenu(items []*Item) (*Menu, error) {
	item := make([]*C.ITEM, 0, len(items))
	for _, i := range items {
		item = append(item, i.item)
	}

	menu := &Menu{C.new_menu(&item[0])}

	if menu == nil {
		return nil, Error
	}
	return menu, nil
}