TERMKEY_IN...T_POSITION(3)

✨ TERMKEY_IN...T_POSITION(3) ✨

okay bestie so this is a page from the Library Functions Manual and it's all about termkey_interpret_position β€” the girl whose whole job is decoding those lil cursor position report events πŸ’…


🌸 NAME 🌸

termkey_interpret_position β€” interpret opaque cursor position event data

like, it takes the mystery box that is a position event and tells you what's inside πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <termkey.h>

TermKeyResult termkey_interpret_position(TermKey *tk, const TermKeyKey *key,
    int *line, int *col);

Link with -ltermkey.

ngl if you forget the -ltermkey the linker is gonna be so dramatic about it 😭 don't do that to her

πŸ’– DESCRIPTION πŸ’–

So termkey_interpret_position() does the thing where it fills in the variables sitting behind the pointers you passed in, based on the cursor position report event it finds in key. The vibe is: you call this when termkey_getkey(3) or one of her friends handed you back a key event whose type is TERMKEY_TYPE_POSITION. That's your green light, periodt ✨

Any pointer can instead be given as NULL if you don't want that value back. Not interested in the line? Pass NULL, she won't be offended, she's not like that 🫢

The line and col variables get filled in with the actual cursor position, and it's indexed from 1 (yes bestie, 1, not 0, this is not one of those zero-indexed situations, we're counting like humans here 🌈).

⚠️ and here's the tea: because the TermKeyKey structure only has a limited number of bytes to work with, line and col are capped β€” line maxes out at 2047 and col maxes out at 4095. That's just how much room she has, no cap 🧚

⭐ RETURN VALUE ⭐

If you hand her a key event of type TERMKEY_TYPE_POSITION, she returns TERMKEY_RES_KEY and she will touch the variables whose pointers you passed in, exactly like described above. Iconic behaviour, ate, no notes πŸ‘‘

For any other event type she returns TERMKEY_RES_NONE, and what happens to those variables you pointed at is undefined. Not "kinda weird", not "probably fine" β€” undefined. So don't be out here reading them like they mean something πŸ’€


🌈 SEE ALSO 🌈

the whole squad, go say hi πŸŽ€


okay that's the whole page!! this one lives in the Library Functions Manual, and she's filed under the very dramatic-looking name TERMKEY_IN...T_POSITION(3) (the ... is just the man page system being extra about the long function name, iykyk). no version or date info came along with her, so that's all we've got β€” love that for us πŸ’œ

stay hydrated, read your return values, and remember: TERMKEY_RES_NONE means hands off πŸ”₯πŸ¦‹πŸ’–