menu_hook(3X)
β¨ menu_hook β setting hooks so your app can do the lil automatic thing β¨
okay bestie, pull up a chair because this is the menu_hook(3X) page from the ncurses library-calls girlies, and it's literally about letting your app sneak little callback functions into the menu machinery π
πΈ 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 whole vibe of letting you set hook functions that get called at various points while menu_driver is doing its automatic processing of input event codes. it's giving "let me inject my own little moment into your pipeline" and honestly? iconic.
set_item_initβ sets a hook that gets called at menu-post time AND every single time the selected item changes (after the change, so you're seeing the new reality, not the old one β¨). anditem_inithands you back the current item init hook, if there is one β orNULLif there's no such hook, no cap.set_item_termβ sets a hook that gets called at menu-unpost time AND each time the selected item changes (before the change, so catch it while it's still the old item π). anditem_termreturns the current item term hook, if any βNULLif there isn't one.set_menu_initβ sets a hook called at menu-post time and just after the top row on the menu changes, once it's posted.menu_initreturns the current menu init hook, if any βNULLif there is none, fr fr.set_menu_termβ sets a hook called at menu-unpost time and just before the top row on the menu changes, once it's posted.menu_termreturns the current menu term hook, if any βNULLif there's no such hook.
not me realizing "post" and "unpost" are the main character events here β every one of these hooks is anchored to posting, unposting, item changes, or top-row changes. that's the whole map, bestie πΊοΈπ
π RETURN VALUE π
the routines that return pointers return NULL on error. (yes, that's the item_init, item_term, menu_init and menu_term girlies π«Ά)
the other routines return one of these:
E_OKβ the routine succeeded. slay. βE_SYSTEM_ERRORβ a system error occurred (go peek aterrno(3), it knows what happened π).
π§ 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 to those, this is a no π
π AUTHORS π
Juergen Pfeifer. manual pages and adaptation for new curses by Eric S. Raymond. absolute legends, we stan π«Ά
β SEE ALSO β
curses(3X)menu(3X)
and that's the page, bestie!! this whole thing ships with ncurses 6.6, dated 2024-12-28, and it's filed under menu_hook(3X) in the Library calls section πβ¨ go forth and hook responsibly ππ¦
π¦ where this page comes from
- alpine 3.24: ncurses-doc 6.6_p20260516-r0 Β· X11
- arch rolling: ncurses 6.6-2 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- Copyright 2018-2023,2024 Thomas E. Dickey
- Copyright 1998-2007,2010 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms