TERMKEY_KEYCMP(3)

πŸ’– TERMKEY_KEYCMP(3) πŸ’–

okay bestie, welcome to the termkey_keycmp page from the Library Functions Manual ✨ this one's short and sweet and honestly kinda iconic.


🌸 NAME 🌸

termkey_keycmp β€” compare two key events πŸ†š


✨ SYNOPSIS ✨

like, here's the whole vibe, no cap:

#include <termkey.h>

int termkey_keycmp(TermKey *tk, const TermKeyKey *key1,
             const TermKeyKey *key2);

and you gotta link it up, periodt:

-ltermkey

πŸ¦‹ DESCRIPTION πŸ¦‹

so termkey_keycmp() takes two key structures and gives them a total ordering πŸ’… it hands you back a value that's negative, zero, or positive β€” telling you whether the structures you gave it are increasing, identical, or decreasing. it's giving sort function energy, fr fr.

but wait, plot twist: before it even compares anything, it takes copies of both referenced structures and canonicalises them according to the rules in termkey_canonicalise(3). so yeah, your originals stay untouched, we're just working with glow-ups of them πŸ’–

when the two structures are of differing type, here's the order, lowkey important so pay attention:

  1. TERMKEY_TYPE_UNICODE
  2. TERMKEY_TYPE_KEYSYM
  3. TERMKEY_TYPE_FUNCTION
  4. TERMKEY_TYPE_MOUSE

and how each one gets sorted:

  • Unicode structures are ordered by codepoint πŸ”€
  • keysym structures are ordered by keysym number πŸ”’
  • function structures are ordered by function key number 🎹
  • mouse structures are ordered opaquely by an unspecified but consistent ordering 🐭✨ (yes, mysterious. yes, still consistent. we love a chaotic-but-reliable icon.)

and within all of those values, keys that differ in modifier bits get ordered by the modifiers. that's the whole tea β˜•


πŸ‘‘ RETURN VALUE πŸ‘‘

termkey_keycmp() returns an integer that is greater than, equal to, or less than zero, indicating the relation between the two key structures you handed it. that's it, that's the whole return, slay 🫢


🌈 SEE ALSO 🌈

go read these next bestie, they're all connected iykyk:


okay that's the page!! mwah πŸ’‹ this was TERMKEY_KEYCMP(3) from the Library Functions Manual β€” the footer just says TERMKEY_KEYCMP(3) again, no extra version or date lore to spill, so that's all we got. hope you understood it, ily, go sort some keys πŸŽ€πŸ¦‹πŸ’œ