menu_userptr(3MENU)

okay so this is menu_userptr(3MENU) from the library calls corner of the ncurses world, and it's genuinely such a cute lil pair of functions, like the emotional support pocket of the menu library πŸŽ€


🌸 NAME 🌸

set_item_userptr, item_userptr β€” associate application data with a menu item πŸ’–

like. you get to tuck your own lil thing inside a menu item and it just… lives there. no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <menu.h>

int set_item_userptr(ITEM *item, void *userptr);
void *item_userptr(const ITEM *item);

πŸ’… DESCRIPTION πŸ’…

so here's the vibe: every single menu item has a field that exists purely for application-specific data β€” and like, the menu-driver code just leaves it alone. doesn't touch it. doesn't look at it. it's yours. main character energy fr fr πŸ‘‘

these two functions are the getter and the setter for that field. one of them sets it, one of them gets it. iconic behaviour, honestly.


⭐ RETURN VALUE ⭐

  • item_userptr returns a pointer β€” and yeah, that pointer can be NULL, that's allowed, it's fine, deep breaths 🫢. it does not set errno.
  • set_item_userptr always returns E_OK, which is the success value. always. every time. no drama, no surprises, slay πŸ’…

🌈 PORTABILITY 🌈

  • these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions, so like, if you're time-travelling back there, sorry bestie 😭
  • the user pointer is a void pointer. they chose not to leave it as a char pointer, and the reason is SVr4 compatibility. periodt.

πŸ‘‘ AUTHORS πŸ‘‘

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. absolute legends, we stan 🧚


πŸ”₯ SEE ALSO πŸ”₯

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

ncurses 6.6 Β· 2024-12-28 β€” and that's the whole page bestie, go forth and stash ur data in ur menu items, ily πŸ’œπŸŒΈ

πŸ“¦ where this page comes from