示例#1
0
文件: menus.go 项目: mpatraw/gocurse
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
}
示例#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)
}
示例#3
0
文件: menu.go 项目: zozor/gocurse
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
}