menu_format(3X)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

okay bestie, so this is a library call page from ncurses β€” it's the one that tells a MENU how big it's allowed to be on screen, and also lets you ask a menu how big it thinks it is. two functions, one page, both iconic in their own way πŸŽ€


🌸 NAME 🌸

set_menu_format, menu_format β€” set and get menu sizes, fr fr. one sets, one gets, that's the whole vibe check.


✨ SYNOPSIS ✨

#include <menu.h>

int set_menu_format(MENU *menu, int rows, int cols);
void menu_format(const MENU *menu, int *rows, int *cols);

like, yes, that's the whole thing. go off πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so set_menu_format sets the maximum display size of the given menu. that's the ceiling, the limit, the "you may not pass" line for how much screen real estate this menu gets. 🚧

and here's the tea β€” if that size is too small to display all the menu items, the menu will be made scrollable. so it's not broken, bestie, it just scrolls. you're welcome. 😌

but reverse that vibe and it gets spicy: if the size is larger than the menu's subwindow and the subwindow is too small to display all menu items, post_menu will fail. like. it just won't post. no cap, that's a real trap, watch out for it πŸ’€

🚨 the default format is 16 rows, 1 column. write that down.

calling set_menu_format with a null menu pointer will change this default. yes, the global default, not one menu's. slippery slope, iykyk 🫢

also β€” a zero row or column argument to set_menu_format is interpreted as a request not to change the current value. so passing 0 is basically you saying "nah leave that one alone, i'm only here for the other one." lowkey efficient ✨

then there's menu_format, which returns the maximum-size constraints for the given menu into the storage addressed by rows and cols. you hand it pointers, it fills them in. main character energy of a function that just delivers 🎁


🌈 RETURN VALUE 🌈

so these routines return one of the following β€” yes, menu_format returns void and set_menu_format returns an int, but the error codes below are the whole zoo. buckle up πŸ’œ

  • E_OK β€” the routine succeeded. slay. that's it, that's the good one πŸŽ‰
  • E_SYSTEM_ERROR β€” a system error occurred (see errno(3)). not your fault, the system is having a moment 😭
  • E_BAD_ARGUMENT β€” the routine detected an incorrect or out-of-range argument. you gave it something unhinged, bestie πŸ™ˆ
  • E_POSTED β€” the menu is already posted. it's out there, living its life, you can't touch it rn πŸ’…
  • E_NOT_CONNECTED β€” no items are connected to the menu. it's giving empty group chat. ghost town. πŸ«₯

🧚 PORTABILITY 🧚

these routines emulate the System V menu library. so they're cosplaying the classics, respectfully 🎭

they were not supported on Version 7 or BSD versions. nope, not invited to that party 🌸


πŸ‘‘ AUTHORS πŸ‘‘

Juergen Pfeifer. and manual pages plus adaptation for new curses by Eric S. Raymond. absolute legends, both of them, we stan 🫢


πŸ’– SEE ALSO πŸ’–

  • curses(3X)
  • menu(3X)

and that's the page, bestie!! this lovely thing lives in ncurses 6.5, dated 2024-03-16, and it's filed under menu_format(3X) in the Library calls section. go format a menu, you got this πŸ’…βœ¨πŸŽ€πŸ’–

πŸ“¦ where this page comes from