keybound(3X)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’– keybound(3X) β€” Library calls πŸ’–

okay bestie, welcome to the keybound page, it's giving niche-but-iconic and I'm obsessed πŸŽ€


✨ NAME ✨

keybound β€” get the definition of a curses function key code πŸ‘‘


🌸 SYNOPSIS 🌸

#include <curses.h>

char * keybound(int key-code, int count);

πŸ¦‹ DESCRIPTION πŸ¦‹

So keybound is an ncurses extension, and what it does is let a curses app grab the value of the string that's bound to the function key key-code πŸ’… (peep wgetch(3X) for the deets β€” and if you're on the wide-character API, that's wget_wch(3X) for you specifically 🫢).

By default, those bindings are string capabilities coming straight out of the terminfo database entry that matches your terminal type. no cap, that's just where they live 🌈

Now here's the slay part: your app can override those definitions with define_key(3X), and it can do it non-destructively and repeatedly β€” like it's pushing new definitions onto a stack. it's giving stack energy fr fr πŸ“šβœ¨

The count parameter is how you access the *n*th most recently defined binding. and 0? that one selects the binding that actually gets used on input. periodt πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

If key-code corresponds to a function key that's defined by the application or by the terminal type in use, keybound allocates and returns a string β€” and heads up, that string must be freed by the application 🫢 don't leave it hanging bestie, that's a leak 😭

keybound returns NULL if key-code is not positive, or if it doesn't correspond to a key code definition. that's it, that's the whole vibe check πŸ’€


🌈 EXTENSIONS 🌈

keybound is an ncurses extension ✨


πŸ’œ PORTABILITY πŸ’œ

If you're using ncurses extensions, you should condition your use of them on whether the NCURSES_VERSION preprocessor macro is visible. fr fr, gate it πŸ‘‘


πŸ‘‘ AUTHORS πŸ‘‘

Thomas Dickey πŸ’–


πŸŽ€ SEE ALSO πŸŽ€

  • curses(3X)
  • define_key(3X)
  • keyok(3X)
  • key_defined(3X)
  • terminfo(5)

πŸ¦‹ quick reminder bestie: NULL means free nothing, a real string means free() it. the way that memory management is literally main character energy πŸ˜­πŸ’…

and that's the whole page, mwah πŸ’‹ this one's from ncurses 6.6, dated 2024-12-28 β€” yes it's serving vintage but it's still iconic, bye bestie πŸŽ€βœ¨

πŸ“¦ where this page comes from