menu(3MENU)

okay bestie, sit DOWN, because this is the menu(3MENU) page and it's genuinely one of the most useful things in the whole curses cinematic universe πŸ’…


✨ NAME ✨

menu β€” present menus in curses windows. that's it, that's the vibe 🌸


✨ SYNOPSIS ✨

#include <menu.h>

✨ DESCRIPTION ✨

so the menu library gives you terminal-independent facilities for composing menu systems on character-cell terminals. it's giving "build a whole interactive UI and don't worry about which terminal you're on" energy ✨

it comes in two flavors of routine:

  • item routines β€” they create and modify menu items.
  • menu routines β€” they group items into menus, display menus on the screen, and handle interaction with the user.

the menu library uses the curses libraries, so you have to call a curses initialization routine such as initscr before using any of these functions. no initscr, no menu, no exceptions, periodt 😀

and to actually use the menu library, link with the options -lmenu -lcurses. don't forget the -lcurses bestie, i'm begging πŸ™ˆ

πŸ’– Current Default Values for Item Attributes πŸ’–

the menu library maintains a default value for item attributes. you can get or set this default by calling the appropriate get_ or set_ routine with a NULL item pointer πŸ‘‘

⚠️ heads up: changing this default with a set_ function affects future item creations, but does not change the rendering of items already created. the past is the past, bestie πŸ’€

πŸ¦‹ Routine Name Index πŸ¦‹

the following list covers each menu routine and the name of the manual page on which it is described. the original calls the columns curses Routine Name and Manual Page Name β€” here they are, one icon per line 🌈

  • current_item β€” menu_current(3MENU)
  • free_item β€” menu_new(3MENU)
  • free_menu β€” new(3MENU)
  • item_count β€” items(3MENU)
  • item_description β€” menu_name(3MENU)
  • item_index β€” menu_current(3MENU)
  • item_init β€” hook(3MENU)
  • item_name β€” menu_name(3MENU)
  • item_opts β€” menu_opts(3MENU)
  • item_opts_off β€” menu_opts(3MENU)
  • item_opts_on β€” menu_opts(3MENU)
  • item_term β€” hook(3MENU)
  • item_userptr β€” menu_userptr(3MENU)
  • item_value β€” menu_value(3MENU)
  • item_visible β€” menu_visible(3MENU)
  • menu_back β€” attributes(3MENU)
  • menu_driver β€” driver(3MENU)
  • menu_fore β€” attributes(3MENU)
  • menu_format β€” format(3MENU)
  • menu_grey β€” attributes(3MENU)
  • menu_init β€” hook(3MENU)
  • menu_items β€” items(3MENU)
  • menu_mark β€” mark(3MENU)
  • menu_opts β€” opts(3MENU)
  • menu_opts_off β€” opts(3MENU)
  • menu_opts_on β€” opts(3MENU)
  • menu_pad β€” attributes(3MENU)
  • menu_pattern β€” pattern(3MENU)
  • menu_request_by_name β€” requestname(3MENU)
  • menu_request_name β€” requestname(3MENU)
  • menu_spacing β€” spacing(3MENU)
  • menu_sub β€” win(3MENU)
  • menu_term β€” hook(3MENU)
  • menu_userptr β€” userptr(3MENU)
  • menu_win β€” win(3MENU)
  • new_item β€” menu_new(3MENU)
  • new_menu β€” new(3MENU)
  • pos_menu_cursor β€” cursor(3MENU)
  • post_menu β€” post(3MENU)
  • scale_menu β€” win(3MENU)
  • set_current_item β€” menu_current(3MENU)
  • set_item_init β€” hook(3MENU)
  • set_item_opts β€” menu_opts(3MENU)
  • set_item_term β€” hook(3MENU)
  • set_item_userptr β€” menu_userptr(3MENU)
  • set_item_value β€” menu_value(3MENU)
  • set_menu_back β€” attributes(3MENU)
  • set_menu_fore β€” attributes(3MENU)
  • set_menu_format β€” format(3MENU)
  • set_menu_grey β€” attributes(3MENU)
  • set_menu_init β€” hook(3MENU)
  • set_menu_items β€” items(3MENU)
  • set_menu_mark β€” mark(3MENU)
  • set_menu_opts β€” menu_opts(3MENU)
  • set_menu_pad β€” attributes(3MENU)
  • set_menu_pattern β€” pattern(3MENU)
  • set_menu_spacing β€” spacing(3MENU)
  • set_menu_sub β€” win(3MENU)
  • set_menu_term β€” hook(3MENU)
  • set_menu_userptr β€” userptr(3MENU)
  • set_menu_win β€” win(3MENU)
  • set_top_row β€” menu_current(3MENU)
  • top_row β€” menu_current(3MENU)
  • unpost_menu β€” post(3MENU)

iykyk, that's the whole squad 🫢


✨ RETURN VALUE ✨

routines that return pointers return NULL on error. routines that return an integer return one of these error codes, and bestie, you're gonna want to memorize these πŸ’…

  • E_OK β€” the routine succeeded. slay πŸŽ‰
  • E_BAD_ARGUMENT β€” routine detected an incorrect or out-of-range argument. 😭
  • E_BAD_STATE β€” routine was called from an initialization or termination function. wrong place, wrong time πŸ’€
  • E_NO_MATCH β€” character failed to match.
  • E_NO_ROOM β€” menu is too large for its window. it's giving claustrophobia 🫠
  • E_NOT_CONNECTED β€” no items are connected to the menu.
  • E_NOT_POSTED β€” the menu has not been posted.
  • E_NOT_SELECTABLE β€” the designated item cannot be selected.
  • E_POSTED β€” the menu is already posted. relax, it's already up there βœ‹
  • E_REQUEST_DENIED β€” the menu driver could not process the request.
  • E_SYSTEM_ERROR β€” system error occurred (see errno(3)).
  • E_UNKNOWN_COMMAND β€” the menu driver code saw an unknown request code. who even are you πŸ‘€

✨ NOTES ✨

the header file menu.h itself includes the header file curses.h. so like, it's already in the group chat πŸ₯°


✨ PORTABILITY ✨

these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions. history lesson, sorry bestie πŸ“š

a menu facility was documented in SVr4.2's Character User Interface Programming document.

it is not part of X/Open Curses. nope, not invited 🚫

aside from ncurses, there are few implementations:

  • systems based on SVr4 source code, e.g., Solaris.
  • NetBSD curses.

so yeah, it's a small circle. exclusive fr fr πŸŽ€


✨ AUTHORS ✨

Juergen Pfeifer. manual pages and adaptation for ncurses by Eric S. Raymond. absolute icons, no cap πŸ‘‘


✨ SEE ALSO ✨

ncurses(3NCURSES) and related pages whose names begin β€œmenu_” for detailed descriptions of the entry points. go read those next, bestie, they're the deep lore πŸ¦‹


and that's the whole page!! this was ncurses 6.6, dated 2025-11-11, dropping under the name menu(3MENU) β€” stay cutesy, stay curses-y, and don't forget initscr πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from