mitem_current(3X)
β¨ mitem_current β set and get current_menu_item β¨
okay bestie, this is a page from the Library calls girlies of the ncurses manual β it's mitem_current(3X) and it's literally all about knowing which menu item is the one ππ
πΈ NAME πΈ
mitem_current β set and get current_menu_item
π SYNOPSIS π
#include <menu.h>
int set_current_item(MENU *menu, ITEM *item);
ITEM *current_item(const MENU *menu);
int set_top_row(MENU *menu, int row);
int top_row(const MENU *menu);
int item_index(const ITEM *item);
π DESCRIPTION π
okay so first up: set_current_item sets the current item β that's the item where the menu cursor is sitting, its little main character spot β¨. And current_item hands you back a pointer to the current item in the menu you passed in. π«Ά
Next, set_top_row sets the top row of the menu so it shows the row you gave it. Heads up though: the top row starts out at 0, and it gets reset back to that value every single time the O_ROWMAJOR option is toggled. periodt. π And the item leftmost on that given row becomes the current one. Meanwhile top_row returns the number of the top menu row that's currently being displayed. π
And last but never least, item_index returns the (zero-origin) index of item inside the menu's item pointer list. yes zero-origin, so don't come at it counting from 1 bestie π
π₯ RETURN VALUE π₯
current_item returns a pointer β and yeah, it may be NULL, so vibe check it before you dereference, fr fr. It does not set errno.
top_row and item_index return ERR (that's the general curses error value, the classic π) if their menu parameter is NULL.
set_current_item and set_top_row return one of these:
E_OKβ the routine succeeded. slay, we love to see it πE_BAD_ARGUMENTβ routine detected an incorrect or out-of-range argument. something was giving wrong vibes πE_BAD_STATEβ routine was called from an initialization or termination function. wrong place, wrong time, bestie πE_NOT_CONNECTEDβ no items are connected to the menu. it's giving lonely in here πE_SYSTEM_ERRORβ system error occurred (seeerrno(3)). go checkerrno, 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 on those, no item for you, sorry bestie π«
Also, the SVr4 menu library documentation specifies the top_row and index_item error value as -1 (which is the value of ERR). yeah they said index_item there, not item_index β I'm just reporting the lore as it was written πβ¨
π AUTHORS π
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. legends, honestly π«Ά
π¦ SEE ALSO π¦
curses(3X), menu(3X)
and that's the whole page bestie!! this was ncurses 6.6, dated 2024-12-28 β written down here with all the love and zero facts lost πβ¨π
π¦ 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-2006,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