TERMKEY_LOOKUP_KEYNAME(3)

πŸ’– NAME πŸ’–

termkey_lookup_keyname β€” bestie, this is the one that looks up a symbolic key value for a string name πŸ’…


✨ SYNOPSIS ✨

#include <termkey.h>

char *termkey_lookup_keyname(TermKey *tk, const char *keyname,
           TermKeySym *sym);

Link with -ltermkey.


🌸 DESCRIPTION 🌸

okay so termkey_lookup_keyname() takes a string name and goes looking for the symbolic key value it represents, no cap. And heads up β€” this comparison is case-sensitive, so don't come at it with your chaotic lowercase energy and expect it to match.

The symbolic value it finds gets written into the variable that sym is addressing. πŸ“

The way this works is it's a glow-up of termkey_keyname2sym(3) β€” like, a more general form of it, because it can spot a symbolic key name sitting inside a longer string and hand you back a pointer to the rest of the input that comes after the key name. main character behavior honestly.

⚠️ lowkey important: because the key names are stored in an array that's indexed by the symbol number, this function has to do a linear search of the names. so like, not fast bestie. πŸ’€

The way that you should use this is: keep it restricted to converting key names into symbolic values during your program's initialisation, so that while the program is actually running you can do efficient comparisons instead. efficiency era 🧚✨


πŸŽ€ RETURN VALUE πŸŽ€

termkey_lookup_keyname() returns a pointer to the first character after a recognised name β€” like, right where the key name ends and the rest begins. 🫢

But if the string does not begin with the name of a recognised symbolic key, you get NULL. not a single match, nothing, ghosted 😭


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie πŸ’œ this one lives in the Library Functions Manual under TERMKEY_LOOKUP_KEYNAME(3) β€” periodt, go read it, ily, mwah πŸŽ€βœ¨