hook(3MENU)

πŸ’– hook(3MENU) β€” library calls, but make it make sense πŸ’–

okay bestie, gather round, because today we're talking about menu_hook, and it's literally the "set hooks for automatic invocation by applications" situation. no cap, this is the glow-up that lets your app sneak its own little functions into the menu's autopilot. πŸͺβœ¨


✨ NAME ✨

menu_hook β€” set hooks for automatic invocation by applications πŸŽ€


🌸 SYNOPSIS 🌸

#include <menu.h>

int set_item_init(MENU *menu, Menu_Hook func);
Menu_Hook item_init(const MENU *menu);

int set_item_term(MENU *menu, Menu_Hook func);
Menu_Hook item_term(const MENU *menu);

int set_menu_init(MENU *menu, Menu_Hook func);
Menu_Hook menu_init(const MENU *menu);

int set_menu_term(MENU *menu, Menu_Hook func);
Menu_Hook menu_term(const MENU *menu);

πŸ’… DESCRIPTION πŸ’…

so these functions are the main character energy of the whole page β€” they let you set hook functions that get called at various points in the automatic processing of input event codes by menu_driver. it's giving "you get a callback, you get a callback, everybody gets a callback." πŸ¦‹

  • set_item_init β€” sets a hook to be called at menu-post time and each time the selected item changes (after the change, iykyk). and item_init returns the current item init hook, if any (NULL if there is no such hook). πŸ“
  • set_item_term β€” sets a hook to be called at menu-unpost time and each time the selected item changes (before the change, bestie, the timing matters). and item_term returns the current item term hook, if any (NULL if there is no such hook). 🧚
  • set_menu_init β€” sets a hook to be called at menu-post time and just after the top row on the menu changes once it is posted. and menu_init returns the current menu init hook, if any (NULL if there is no such hook). πŸ’œ
  • set_menu_term β€” sets a hook to be called at menu-unpost time and just before the top row on the menu changes once it is posted. and menu_term returns the current menu term hook, if any (NULL if there is no such hook). 🌈

πŸ”₯ RETURN VALUE πŸ”₯

the routines that return pointers? they return NULL on error. simple as that. 😭

every other routine returns one of these iconic little values:

  • E_OK β€” the routine succeeded. slay. πŸ‘‘
  • E_SYSTEM_ERROR β€” a system error occurred (peep errno(3)). πŸ’€

🫢 PORTABILITY 🫢

these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions, so don't come for them, they simply weren't invited. πŸ™ˆ


⭐ AUTHORS ⭐

Juergen Pfeifer. manual pages and adaptation for new curses by Eric S. Raymond. legends only. πŸŽ€


πŸ‘€ SEE ALSO πŸ‘€

ncurses(3NCURSES), menu(3MENU)


that's the whole vibe, bestie β€” go forth and hook responsibly πŸ’– this has been the ncurses 6.6 era, dated 2024-12-28, signing off with maximum main character energy. periodt. ✨

πŸ“¦ where this page comes from