pattern(3MENU)

✨ pattern β€” bestie, it's the menu pattern buffer era ✨

soooo this is pattern(3MENU), a lil' library-calls moment from your fave ncurses family. Two functions, one shared brain cell (the pattern buffer), and a whole lot of will it match or will it not energy. Let's get into it πŸ’…


🌸 SYNOPSIS 🌸

#include <menu.h>

int set_menu_pattern(MENU *menu, const char *pattern);
char *menu_pattern(const MENU *menu);

okay so that's the whole vibe up top β€” one setter, one getter, both hanging out in <menu.h> like the iconic duo they are 🫢


πŸŽ€ DESCRIPTION πŸŽ€

Every single menu out here has an associated pattern match buffer, no exceptions. Think of it like the menu's little notes app πŸ“. As input events that are printable characters roll in, they get appended to this match buffer and then tested for a match β€” and the whole matching situation is described over in driver(3MENU) if you wanna go read the lore, bestie, it's giving lore.

set_menu_pattern sets the pattern buffer for the given menu and tries to find the first matching item. Two-for-one, we love efficiency ✨. So here's the tea:

  • if it succeeds, that matched item becomes the current item β€” slay, the menu moved πŸŽ‰
  • if it fails, the current item does not change. Nothing happens. It simply sits there. Periodt.

menu_pattern is the chill one β€” it just returns the pattern buffer of the given menu. That's it. That's the function. πŸ’–


⭐ RETURN VALUE ⭐

So menu_pattern returns a pointer, and here's the breakdown bestie, stay with me:

  • it's NULL if the menu parameter is NULL β€” no menu, no pointer, tragic
  • otherwise it's a pointer to a string, and that string is empty if no pattern has been set yet
  • and ngl, it does not set errno. It's just not that kind of function 😌

Meanwhile set_menu_pattern is the one that can actually fail on you, and it may return these error codes:

  • E_OK β€” the routine succeeded πŸ₯³ slay
  • E_BAD_ARGUMENT β€” the routine detected an incorrect or out-of-range argument. Girl, what did you pass it πŸ’€
  • E_BAD_STATE β€” the routine was called from an initialization or termination function. Wrong place, wrong time, read the room πŸ™ˆ
  • E_NOT_CONNECTED β€” no items are connected to menu. An empty menu is not beating the lonely allegations 😭
  • E_NO_MATCH β€” the character failed to match. Close but no cigar, it's giving flop πŸ˜”
  • E_SYSTEM_ERROR β€” a system error occurred (see errno(3)). Not our fault, blame the system fr fr

πŸ¦‹ PORTABILITY πŸ¦‹

These routines emulate the System V menu library, so they're out here doing an impression of the classics 🎭. They were not supported on Version 7 or BSD versions β€” so if you're on ancient BSD energy, this is not your moment, bestie, sorry not sorry.


πŸ‘‘ AUTHORS πŸ‘‘

Juergen Pfeifer.</purl> Manual pages and adaptation for new curses by Eric S. Raymond. Legends, honestly, we stan 🌈


🌟 SEE ALSO 🌟

  • ncurses(3NCURSES)
  • menu(3MENU)

and that's the whole page, bestie β€” go forth and pattern-match, you've got this πŸ’–βœ¨

this lil' manual moment comes to you from ncurses 6.6, dated 2024-12-28 β€” xoxo, pattern(3MENU), signing off πŸŽ€

πŸ“¦ where this page comes from