menu(3X)

okay bestie, sit down, hydrate, and let me tell you about menu β€” the literal blueprint for presenting menus in curses windows. no cap, this one's a whole library.


✨ NAME ✨

menu β€” present menus in curses windows πŸŽ€


🌸 SYNOPSIS 🌸

#include <menu.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

so the menu library is giving terminal-independent facilities for composing menu systems on character-cell terminals. icon behavior, truly. 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 rides on the curses libraries, so a curses initialization routine such as initscr must be called before you use any of these functions. mandatory. non-negotiable. and when you link? you link with the options -lmenu -lcurses. that's the vibe. πŸ’…

πŸ’œ Current Default Values for Item Attributes

the menu library keeps a default value for item attributes, lowkey like a little settings drawer. you can get or set this default by calling the appropriate get_ or set_ routine with a NULL item pointer. and listen β€” changing this default with a set_ function affects future item creations, but does not change the rendering of items that already exist. past items are past items, bestie. 🫢

🌈 Routine Name Index

here's the roster, the main character list, mapping every menu routine to the manual page that describes it:

  • current_item β€” mitem_current(3X)
  • free_item β€” mitem_new(3X)
  • free_menu β€” menu_new(3X)
  • item_count β€” menu_items(3X)
  • item_description β€” mitem_name(3X)
  • item_index β€” mitem_current(3X)
  • item_init β€” menu_hook(3X)
  • item_name β€” mitem_name(3X)
  • item_opts β€” mitem_opts(3X)
  • item_opts_off β€” mitem_opts(3X)
  • item_opts_on β€” mitem_opts(3X)
  • item_term β€” menu_hook(3X)
  • item_userptr β€” mitem_userptr(3X)
  • item_value β€” mitem_value(3X)
  • item_visible β€” mitem_visible(3X)
  • menu_back β€” menu_attributes(3X)
  • menu_driver β€” menu_driver(3X)
  • menu_fore β€” menu_attributes(3X)
  • menu_format β€” menu_format(3X)
  • menu_grey β€” menu_attributes(3X)
  • menu_init β€” menu_hook(3X)
  • menu_items β€” menu_items(3X)
  • menu_mark β€” menu_mark(3X)
  • menu_opts β€” menu_opts(3X)
  • menu_opts_off β€” menu_opts(3X)
  • menu_opts_on β€” menu_opts(3X)
  • menu_pad β€” menu_attributes(3X)
  • menu_pattern β€” menu_pattern(3X)
  • menu_request_by_name β€” menu_requestname(3X)
  • menu_request_name β€” menu_requestname(3X)
  • menu_spacing β€” menu_spacing(3X)
  • menu_sub β€” menu_win(3X)
  • menu_term β€” menu_hook(3X)
  • menu_userptr β€” menu_userptr(3X)
  • menu_win β€” menu_win(3X)
  • new_item β€” mitem_new(3X)
  • new_menu β€” menu_new(3X)
  • pos_menu_cursor β€” menu_cursor(3X)
  • post_menu β€” menu_post(3X)
  • scale_menu β€” menu_win(3X)
  • set_current_item β€” mitem_current(3X)
  • set_item_init β€” menu_hook(3X)
  • set_item_opts β€” mitem_opts(3X)
  • set_item_term β€” menu_hook(3X)
  • set_item_userptr β€” mitem_userptr(3X)
  • set_item_value β€” mitem_value(3X)
  • set_menu_back β€” menu_attributes(3X)
  • set_menu_fore β€” menu_attributes(3X)
  • set_menu_format β€” menu_format(3X)
  • set_menu_grey β€” menu_attributes(3X)
  • set_menu_init β€” menu_hook(3X)
  • set_menu_items β€” menu_items(3X)
  • set_menu_mark β€” menu_mark(3X)
  • set_menu_opts β€” mitem_opts(3X)
  • set_menu_pad β€” menu_attributes(3X)
  • set_menu_pattern β€” menu_pattern(3X)
  • set_menu_spacing β€” menu_spacing(3X)
  • set_menu_sub β€” menu_win(3X)
  • set_menu_term β€” menu_hook(3X)
  • set_menu_userptr β€” menu_userptr(3X)
  • set_menu_win β€” menu_win(3X)
  • set_top_row β€” mitem_current(3X)
  • top_row β€” mitem_current(3X)
  • unpost_menu β€” menu_post(3X)

πŸ”₯ RETURN VALUE πŸ”₯

routines that return pointers return NULL on error. that's the universal "nope" signal πŸ™ˆ

routines that return an integer return one of these error codes, and each one is telling you exactly what went wrong:

  • E_OK β€” the routine succeeded. slay. we love to see it ✨
  • E_BAD_ARGUMENT β€” routine detected an incorrect or out-of-range argument. you handed it something cursed πŸ’€
  • E_BAD_STATE β€” routine was called from an initialization or termination function. wrong place, wrong time.
  • E_NO_MATCH β€” character failed to match. no match found, bestie 😭
  • E_NO_ROOM β€” menu is too large for its window. it's giving "doesn't fit" πŸŽ€
  • E_NOT_CONNECTED β€” no items are connected to the menu. it's empty, it's lonely πŸ¦‹
  • E_NOT_POSTED β€” the menu has not been posted.
  • E_NOT_SELECTABLE β€” the designated item cannot be selected. sorry, that one's off-limits.
  • E_POSTED β€” the menu is already posted. we been knew.
  • E_REQUEST_DENIED β€” the menu driver could not process the request. denied. πŸ’…
  • E_SYSTEM_ERROR β€” system error occurred (see errno(3)).
  • E_UNKNOWN_COMMAND β€” the menu driver code saw an unknown request code. who is she? never heard of her.

πŸ“ NOTES πŸ“

fun fact: the header file menu.h itself includes the header file curses.h. free include, no extra work. you're welcome πŸ’–


πŸ‘‘ PORTABILITY πŸ‘‘

these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions. so if you're time-traveling, adjust expectations accordingly 🌸

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

it is not part of X/Open Curses. no cap.

aside from ncurses, there are few implementations:

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

🌟 AUTHORS 🌟

Juergen Pfeifer. manual pages and adaptation for ncurses by Eric S. Raymond. legends, honestly 🫢


πŸ’« SEE ALSO πŸ’«

curses(3X) and related pages whose names begin β€œmenu_” for detailed descriptions of the entry points. iykyk 🌈


and that's the whole page, bestie β€” this was menu(3X) from ncurses 6.6, dated 2025-11-11. go forth and build the cutest little terminal menus ever. periodt πŸ’…βœ¨

πŸ“¦ where this page comes from