vt: add bell effect callback and move types into Effects

Add GHOSTTY_TERMINAL_OPT_BELL so C consumers can receive bell
notifications during VT processing. The bell trampoline follows
the same pattern as write_pty.

Move the C function pointer typedefs (WritePtyFn, BellFn) into
the Effects struct namespace to keep callback types co-located
with their storage and trampolines.
This commit is contained in:
Mitchell Hashimoto
2026-03-24 06:56:51 -07:00
parent b91cc867a8
commit b49e9f37ff
2 changed files with 41 additions and 5 deletions

View File

@@ -154,6 +154,19 @@ typedef void (*GhosttyTerminalWritePtyFn)(GhosttyTerminal terminal,
const uint8_t* data,
size_t len);
/**
* Callback function type for bell.
*
* Called when the terminal receives a BEL character (0x07).
*
* @param terminal The terminal handle
* @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA
*
* @ingroup terminal
*/
typedef void (*GhosttyTerminalBellFn)(GhosttyTerminal terminal,
void* userdata);
/**
* Terminal option identifiers.
*
@@ -178,6 +191,14 @@ typedef enum {
* Input type: GhosttyTerminalWritePtyFn*
*/
GHOSTTY_TERMINAL_OPT_WRITE_PTY = 1,
/**
* Callback invoked when the terminal receives a BEL character
* (0x07). Set to NULL to ignore bell events.
*
* Input type: GhosttyTerminalBellFn*
*/
GHOSTTY_TERMINAL_OPT_BELL = 2,
} GhosttyTerminalOption;
/**