TT_PATTERN_CALLBACK_ADD(3)

πŸ“¦
version 2.5.3 Β· 2 versions
, in nixos 26.05

πŸ’… tt_pattern_callback_add β€” ok so this is the one that hooks your callback into a pattern πŸ‘‘

Bestie, welcome to the tt_pattern_callback_add(library call) page β€” yes that's the manual name, no I'm not gonna make you scroll for it. This is a library call in the ToolTalk world, and it is, genuinely, the moment your pattern stops being a shy little wallflower and starts running a function every time the right message shows up. Slay.


✨ NAME ✨

tt_pattern_callback_add β€” register a message-matching callback function. That's it, that's the whole vibe: you hand over a function and it gets called when stuff matches. πŸŽ€


🌸 SYNOPSIS 🌸

#include <Tt/tt_c.h>
Tt_status tt_pattern_callback_add(
Tt_pattern m,
Tt_message_callback f);

Literally just two arguments. m is your pattern, f is your callback. Iconic minimalism. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's what's actually happening: tt_pattern_callback_add registers a callback function that will be automatically invoked by tt_message_receive(3) whenever a message matches the pattern. Like, you don't call it yourself, you just set it up and tt_message_receive(3) does the doorbell-ringing for you. No cap.

The callback is defined in Tt/tt_c.h - Tttt_c(5) β€” that's where the shape of it lives, go look.

Now the flow, because this part is lowkey the whole plot 🫢:

  • If the callback returns TT_CALLBACK_CONTINUE, other callbacks will be run. Passing the baton, very generous of it.
  • If no callback returns TT_CALLBACK_PROCESSED, tt_message_receive(3) returns the message. So the message still surfaces. Good.
  • If the callback returns TT_CALLBACK_PROCESSED, no further callbacks will be invoked for this event, and tt_message_receive(3) does not return the message. You ate it. It's gone. That's the deal. πŸ’€

The m argument is the opaque handle for the pattern involved in this operation.

The f argument is the message callback to be run.


πŸ”₯ RETURN VALUE πŸ”₯

Upon successful completion, the tt_pattern_callback_add function returns the status of the operation as one of the following Tt_status values:

  • TT_OK β€” The operation completed successfully. We love a clean win. ✨
  • TT_ERR_NOMP β€” The ttsession(1) process is not running and the ToolTalk service cannot restart it. Rude. 😭
  • TT_ERR_POINTER β€” The pointer passed does not point to an object of the correct type for this operation. Wrong shape, wrong energy, vibe check failed. πŸ™ˆ

🧚 SEE ALSO 🧚

Go read them, they're all part of the same friend group. 🌈


ok bye bestie, go register some callbacks 🌸 β€” that was tt_pattern_callback_add(library call), same title up top and down at the bottom, and yeah the footer's just the manual name again β€” no extra version or date info hiding in there, so consider this the cute sign-off instead. πŸ’–

πŸ“¦ where this page comes from