MENUS(3) Library Functions Manual MENUS(3)
NAME
menusmenu library
LIBRARY
Curses Menu Library (libmenu, -lmenu)
SYNOPSIS
#include <menu.h>
DESCRIPTION
The menus library provides a terminal independent menu system using the curses(3) library. Before using the menus functions the terminal must be set up by curses(3) using the initscr() function or similar. Programs using menus functions must be linked with the curses(3) library.
 
The menus library provides facilities for defining menu items, placing a menu on the terminal screen, assign pre- and post-change operations and setting the attributes of both the menu and its items.
Defining default attributes for menus and items
The menus library allows any settable attribute or option of both the menu and item objects to be defined such that any new menu or item automatically inherits the value as default. Setting the default value will not affect any item or menu that has already been created but will be applied to subsequent objects. To set the default attribute or option the set routine is passed a NULL pointer in the item or menu parameter when calling the set routine. The current default value can be retrieved by calling the get routine with a NULL pointer for the item or menu parameter.
 
function name
manual page name
current_item
free_item
free_menu
item_count
item_description
item_init
item_opts_off
item_opts_on
item_selected
item_term
item_userptr
item_value
item_visible
menu_driver
menu_format
menu_init
menu_items
menu_mark
menu_opts
menu_opts_off
menu_opts_on
menu_pattern
menu_sub
menu_term
menu_unmark
menu_userptr
men_win
new_menu
pos_menu_cursor
post_menu
scale_menu
set_current_item
set_item_init
set_item_opts
set_item_term
set_item_userptr
set_item_value
set_menu_back
set_menu_fore
set_menu_format
set_menu_grey
set_menu_init
set_menu_items
set_menu_mark
set_menu_opts
set_menu_pad
set_menu_pattern
set_menu_sub
set_menu_term
set_menu_unmark
set_menu_userptr
set_menu_win
unpost_menu
RETURN VALUES
Any function returning a string pointer will return NULL if an error occurs. Functions returning an integer will return one of the following:
 
E_OK
The function was successful.
E_SYSTEM_ERROR
There was a system error during the call.
E_BAD_ARGUMENT
One or more of the arguments passed to the function was incorrect.
E_POSTED
The menu is already posted.
E_CONNECTED
An item was already connected to a menu.
E_BAD_STATE
The function was called from within an initialization or termination routine.
E_NO_ROOM
The menu does not fit within the subwindow.
E_NOT_POSTED
The menu is not posted.
E_UNKNOWN_COMMAND
The menu driver does not recognize the request passed to it.
E_NO_MATCH
The character search failed to find a match.
E_NOT_SELECTABLE
The item could not be selected.
E_NOT_CONNECTED
The item is not connected to a menu.
E_REQUEST_DENIED
The menu driver could not process the request.
SEE ALSO
NOTES
This implementation of the menus library does depart in behaviour subtly from the original AT & T implementation. Some of the more notable departures are:
 
unmark
The original implementation did not have a marker for an unmarked field the mark was only displayed next to a field when it had been marked using the REQ_TOGGLE_ITEM. In this implementation a separate marker can be used to indicate an unmarked item. This can be set using set_menu_unmark function. There is no requirement for the mark and unmark strings to be the same length. Room will be left for the longest of the two. The unmark string is optional, if it is not set then menus defaults to the old behaviour.
item marking
In the original implementation the current item was considered selected and hence had the mark string displayed next to it. This implementation does not do this because the Author considers the effect too confusing. Especially in the case of a multiple selection menu because there was no way to tell if the current item is selected or not without shifting off of it. Since the current item is displayed using the foreground attribute it was deemed unnecessary to also display the mark string against the current item.
 
The option O_RADIO and the function item_selected() are NetBSD extensions and must not be used in portable code.