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 (see errno(3)). go check errno, 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