menu_current(3MENU)

okay so bestie, welcome to the 3MENU corner of the manual β€” this is a library call page and it's about which item the cursor is vibing on and which row is at the top. buckle up πŸŽ€


✨ 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 ✨

so, first up: set_current_item sets the current item β€” that's the item the menu cursor is sitting on, main character energy only πŸ‘‘. and current_item hands you back a pointer to the current item in the menu you passed in. easy.

then we've got set_top_row, which sets the top row of the menu so it displays the row you asked for. heads up bestie: the top row starts at 0, and it gets reset back to that value whenever the O_ROWMAJOR option is toggled πŸ”. the item leftmost on the given row becomes current. and top_row returns the number of the top menu row that's currently being displayed.

last one: item_index returns the zero-origin index of item in the menu's item pointer list. zero-origin means it counts from 0, not 1, no cap πŸ“Œ


✨ RETURN VALUE ✨

  • current_item returns a pointer β€” and yeah, it may be NULL. it does not set errno.
  • top_row and item_index return ERR (the general curses error value) if their menu parameter is NULL. 😭
  • set_current_item and set_top_row return one of these:
  • E_OK β€” the routine succeeded. slay ✨
  • E_BAD_ARGUMENT β€” the routine detected an incorrect or out-of-range argument. πŸ™ˆ
  • E_BAD_STATE β€” the routine was called from an initialization or termination function. wrong place, wrong time fr fr
  • E_NOT_CONNECTED β€” no items are connected to the menu. it's giving empty πŸ’€
  • E_SYSTEM_ERROR β€” a system error occurred (see errno(3)).

✨ 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 back there, good luck bestie πŸ•°οΈ

also, the SVr4 menu library documentation specifies the top_row and index_item error value as -1 β€” which, fun fact, is the value of ERR 🀝


✨ AUTHORS ✨

Juergen Pfeifer. manual pages and adaptation for new curses by Eric S. Raymond. kings πŸ‘‘


✨ SEE ALSO ✨

ncurses(3NCURSES), menu(3MENU) πŸ¦‹


and that's the whole page, bestie!! this was ncurses 6.6, dated 2024-12-28, on the menu_current(3MENU) page β€” mwah, go read menu(3MENU) next, ily πŸ’œπŸŒΈ

πŸ“¦ where this page comes from