TERMKEY_KEYNAME2SYM(3)

πŸ’– termkey_keyname2sym β€” bestie's guide to nameβ†’symbol glow-ups πŸ’–

okay so this is page termkey_keyname2sym(3) from the Library Functions Manual of the termkey crew, and it's honestly giving "tiny function, big main character energy". let's get into it 🫢


✨ NAME ✨

termkey_keyname2sym β€” look up a symbolic key value for a string name. yes bestie, it's exactly what it sounds like 🌸


✨ SYNOPSIS ✨

#include <termkey.h>

TermKeySym termkey_keyname2sym(TermKey *tk, const char *keyname);

Link with -ltermkey.

fr fr do not forget that -ltermkey at link time, she will NOT link herself πŸ’…

✨ DESCRIPTION ✨

so termkey_keyname2sym() goes and looks up the symbolic key value that the given string name represents. the comparison is case-sensitive β€” no lowercase shortcuts, no vibes-based matching, it's giving strict queen πŸ‘‘

if the given name is not found, you get TERMKEY_SYM_UNKNOWN back instead. like, she looked everywhere, nothing, unknown, periodt πŸ’€

this function is the inverse of termkey_get_keyname(3), and it's also a more specific form of termkey_lookup_keyname(3) β€” because this one only recognises names as complete strings. no partial matching, no "close enough", full string or nothing πŸŽ€

now here's the lowkey tea: because the key names are stored in an array indexed by the symbol number, this function has to do a linear search of the names. it's not a hash map moment, it's a walk-the-whole-list moment 😭

so the recommended vibe is: use this function only when converting key names into symbolic values during your program's initialisation. get it done up front, then do efficient comparisons while the program is actually running. future you will be obsessed with past you for this 🌈


✨ RETURN VALUE ✨

termkey_keyname2sym() returns a symbolic key constant, or TERMKEY_SYM_UNKNOWN if it couldn't find your name. that's the whole deal, no secret third option ⭐


✨ SEE ALSO ✨


and that's the page!! this absolute icon lives in the Library Functions Manual, filed under TERMKEY_KEYNAME2SYM(3), and yeah the footer is literally just the name again because even manpages love a callback πŸ’œ mwah, go initialise your key names early bestie, ily πŸ¦‹πŸ’–βœ¨