TICKIT_STR...IMIT_BYTES(3)

✨ TICKIT_STR...IMIT_BYTES(3) ✨

okay bestie, so this one's from the Library Functions Manual and it's literally the page about setting limit fields in string position counters. yes it's a mouthful, we'll get through it together πŸ’–


🌸 NAME 🌸

tickit_stringpos_limit_... β€” set limit fields in string position counters


πŸŽ€ SYNOPSIS πŸŽ€

#include <tickit.h>

void tickit_stringpos_limit_bytes(TickitStringPos *pos, size_t bytes);
void tickit_stringpos_limit_codepoints(TickitStringPos *pos, int codepoints);
void tickit_stringpos_limit_graphemes(TickitStringPos *pos, int graphemes);
void tickit_stringpos_limit_columns(TickitStringPos *pos, int columns);
void tickit_stringpos_limit_none(TickitStringPos *pos);

#define INIT_TICKIT_STRINGPOS_LIMIT_BYTES(bytes)
#define INIT_TICKIT_STRINGPOS_LIMIT_CODEPOINTS(codepoints)
#define INIT_TICKIT_STRINGPOS_LIMIT_GRAPHEMES(grahpemes)
#define INIT_TICKIT_STRINGPOS_LIMIT_COLUMNS(columns)
#define INIT_TICKIT_STRINGPOS_LIMIT_NONE

Link with -ltickit.
ngl that grahpemes typo in the macro is canon now, we do not touch it, we simply respect it πŸ™ˆ

πŸ’… DESCRIPTION πŸ’…

okay so the first four of these functions? each one sets one of the counter fields in pos to the value you hand it, and sets the other three to -1. and why do we care? because that's how you build a limit counter β€” the thing that makes tickit_utf8_count(3) or tickit_utf8_countmore(3) stop dead at whatever position you chose. it's giving βœ‹ stop right there βœ‹ energy.

the final function is the chill one: it just initialises all four fields to -1, no limits, no rules, free spirit 🌈

each of them also exists as a macro, and the macros are the ones you want when you're initialising a brand new TickitStringPos variable. like:

TickitStringPos limit = INIT_TICKIT_STRINGPOS_LIMIT_BYTES(b);

see how clean that is?? main character variable declaration fr fr πŸ‘‘


⭐ RETURN VALUE ⭐

the functions all return no value. like, none. zero. void queen πŸ’€

the macros, though? they expand to a struct initialiser expression. so they're doing something, bestie, they're just doing it in expression form ✨


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, no cap 🫢 shoutout to the TICKIT_STR...IMIT_BYTES(3) page in the Library Functions Manual for having us β€” ily, go read the SEE ALSO list, it's short but it ate πŸ’–