vt: add title_changed effect callback

Add GHOSTTY_TERMINAL_OPT_TITLE_CHANGED so C consumers are notified
when the terminal title changes via OSC 0 or OSC 2 sequences. The
callback has the same fire-and-forget shape as bell.
This commit is contained in:
Mitchell Hashimoto
2026-03-24 07:06:09 -07:00
parent f9c34b40f0
commit 6f18d44ed6
2 changed files with 97 additions and 0 deletions

View File

@@ -201,6 +201,21 @@ typedef GhosttyString (*GhosttyTerminalEnquiryFn)(GhosttyTerminal terminal,
typedef GhosttyString (*GhosttyTerminalXtversionFn)(GhosttyTerminal terminal,
void* userdata);
/**
* Callback function type for title_changed.
*
* Called when the terminal title changes via escape sequences
* (e.g. OSC 0 or OSC 2). The new title can be queried from the
* terminal after the callback returns.
*
* @param terminal The terminal handle
* @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA
*
* @ingroup terminal
*/
typedef void (*GhosttyTerminalTitleChangedFn)(GhosttyTerminal terminal,
void* userdata);
/**
* Terminal option identifiers.
*
@@ -249,6 +264,15 @@ typedef enum {
* Input type: GhosttyTerminalXtversionFn*
*/
GHOSTTY_TERMINAL_OPT_XTVERSION = 4,
/**
* Callback invoked when the terminal title changes via escape
* sequences (e.g. OSC 0 or OSC 2). Set to NULL to ignore title
* change events.
*
* Input type: GhosttyTerminalTitleChangedFn*
*/
GHOSTTY_TERMINAL_OPT_TITLE_CHANGED = 5,
} GhosttyTerminalOption;
/**