TERMKEY_STRPKEY(3)
π TERMKEY_STRPKEY(3) π
okay bestie, welcome to the Library Functions Manual page for termkey_strpkey β literally the glow-up your string-parsing era needed β¨
πΈ NAME πΈ
termkey_strpkey β parse a string representing a key event π
β¨ SYNOPSIS β¨
#include <termkey.h>
char *termkey_strpkey(TermKey *tk, const char *str,
TermKeyKey *key, TermKeyFormat format);
Link with -ltermkey. π«Ά
π DESCRIPTION π
termkey_strpkey(3) takes a string buffer holding a human-readable representation of a key event and parses it. Then it fills the key structure from the results of that parsing β it's giving the same energy as the strptime(3) standard library function, no cap. π
The format argument says what format the string is expected to be in, and it's a bitmask of these constants, bestie:
TERMKEY_FORMAT_LONGMODβ expect full modifier names, like"Shift-", instead of the abbreviation"S-".TERMKEY_FORMAT_CARETCTRLβ if the only modifier isTERMKEY_MOD_CTRLon a plain letter, accept it as"^X"instead of"Ctrl-X". iconic.TERMKEY_FORMAT_ALTISMETAβ expect the name"Meta"or the letter"M"instead of"Alt"or"A".TERMKEY_FORMAT_SPACEMODβ expect spaces instead of hyphens to separate the modifier name(s) from the base key name.TERMKEY_FORMAT_LOWERMODβ expect lowercase for the modifier name.TERMKEY_FORMAT_LOWERSPACEβ expect lowercase with spaces in for the key name instead of camelCase (so for example"page down"instead of"PageDown").TERMKEY_FORMAT_MOUSE_POSβ expect a mouse event to be followed by its position rendered as"@ (col,line)". π
Before it returns, this function canonicalises the key structure according to the rules given for termkey_canonicalise(3). main character behaviour fr fr.
Heads up bestie π theTERMKEY_FORMAT_WRAPBRACKEToption is currently not supported bytermkey_strpkey(). And when it returns aTERMKEY_TYPE_UNICODEkey structure, this function will fill in theutf8member. π
β RETURN VALUE β
After a successful parse, termkey_strpkey() returns a pointer to the first character of the input it did not consume. π«°
- If the input string has more characters, that pointer points at the first character beyond.
- If the entire input string was consumed, it points at a null byte.
- If
termkey_strpkey()fails to parse, it returnsNULL.
careful babe!! after a failed parse, thekeystructure may contain partial or invalid results. The structure will only be valid if the function returns a non-NULLresult. don't be trusting it otherwise π
π SEE ALSO π
termkey_new(3), termkey_strfkey(3), termkey_keycmp(3), termkey(7)
and that's the whole vibe π this was TERMKEY_STRPKEY(3) from the Library Functions Manual, and yes she really does sign off with her own name twice like the icon she is ππ
slay, go parse something bestie β¨π¦
π¦ where this page comes from
- alpine 3.24: libtermkey-doc 0.22-r4 Β· MIT
- debian trixie: libtermkey-dev 0.22-2+b1 Β· MIT
- epel 10: libtermkey-devel 0.22-2.el10_0 Β· MIT
- epel 9: libtermkey-devel 0.22-2.el9 Β· MIT
- fedora 43: libtermkey-devel 0.22-11.fc43 Β· MIT
- fedora 43: libtermkey-devel 0.22-11.fc43 Β· MIT
- fedora 44: libtermkey-devel 0.22-12.fc44 Β· MIT
- fedora 44: libtermkey-devel 0.22-12.fc44 Β· MIT
- nixos 26.05: libtermkey 0.22
- nixpkgs unstable: libtermkey 0.22
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- ubuntu questing: libtermkey-dev 0.22-2
- ubuntu resolute: libtermkey-dev 0.22-2build1 Β· MIT
- ubuntu stonking: libtermkey-dev 0.22-3 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms