win(3MENU)

πŸ’– win β€” bestie, let's talk menu windows πŸ’–

okay so real talk, this is from the win(3MENU) page in the library calls section, and it's literally all about making and breaking menu window and subwindow associations. like, matchmaking but for curses windows 🫢


✨ NAME ✨

menu_win β€” make and break menu window and subwindow associations πŸ’…


🌸 SYNOPSIS 🌸

#include <menu.h>

int set_menu_win(MENU *menu, WINDOW *win);
WINDOW *menu_win(const MENU *menu);

int set_menu_sub(MENU *menu, WINDOW *sub);
WINDOW *menu_sub(const MENU *menu);

int scale_menu(const MENU *menu, int *rows, int *columns);

πŸ¦‹ DESCRIPTION πŸ¦‹

so every menu has an associated pair of curses windows, no cap. they come as a duo, main character energy πŸ‘‘

  • the menu window displays any title and border associated with the window
  • the menu subwindow displays the items of the menu that are currently available for selection

the first four functions get and set those windows. and here's the tea: it is not necessary to set either window β€” by default, the driver code uses stdscr for both. so if you do nothing, it still works. lowkey iconic of it πŸ’–

in the set_ functions:

  • a window argument of NULL is treated as though it were stsdcr. (yes, that's spelled exactly like that in the source, bestie β€” I'm not fixing it, that's the vibe 😭)
  • a menu argument of NULL is treated as a request to change the system default menu window or subwindow

and the function scale_menu returns the minimum size required for the subwindow of menu. it's giving "how much room do I need" energy πŸ“βœ¨


🌈 RETURN VALUE 🌈

  • routines that return pointers return NULL on error
  • routines that return an integer return one of the following error codes:
  • E_OK β€” the routine succeeded. we love a success story πŸ’š
  • E_SYSTEM_ERROR β€” system error occurred (see errno(3)). it's giving chaos πŸ™ˆ
  • E_BAD_ARGUMENT β€” routine detected an incorrect or out-of-range argument. bestie, what did you pass in πŸ’€
  • E_POSTED β€” the menu has already been posted. it's already out there, you can't do that again 🚫
  • E_NOT_CONNECTED β€” no items are connected to the menu. an empty menu is just a sad little box 😭

πŸŽ€ PORTABILITY πŸŽ€

these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions. so like, vintage but make it specific πŸ•°οΈ


πŸ‘‘ AUTHORS πŸ‘‘

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. absolute legends, fr fr 🫢


πŸ”₯ SEE ALSO πŸ”₯

  • ncurses(3NCURSES)
  • curses_variables(3NCURSES)
  • menu(3MENU)

go read those too, iykyk πŸ“šβœ¨

and that's the whole page, bestie!! this one's from ncurses 6.6, dated 2024-12-28, filed under win(3MENU). slay, go associate some windows πŸ’…πŸ’–πŸŒˆ

πŸ“¦ where this page comes from