vt: add size effect callback for XTWINOPS queries

Add GHOSTTY_TERMINAL_OPT_SIZE so C consumers can respond to
XTWINOPS size queries (CSI 14/16/18 t). The callback receives a
GhosttySizeReportSize out-pointer and returns true if the size is
available, or false to silently ignore the query. The trampoline
converts the bool + out-pointer pattern to the optional that the
Zig handler expects.
This commit is contained in:
Mitchell Hashimoto
2026-03-24 07:09:50 -07:00
parent 6f18d44ed6
commit 424e9b57ca
2 changed files with 113 additions and 0 deletions

View File

@@ -13,6 +13,7 @@
#include <ghostty/vt/types.h>
#include <ghostty/vt/allocator.h>
#include <ghostty/vt/modes.h>
#include <ghostty/vt/size_report.h>
#include <ghostty/vt/grid_ref.h>
#include <ghostty/vt/screen.h>
#include <ghostty/vt/point.h>
@@ -216,6 +217,24 @@ typedef GhosttyString (*GhosttyTerminalXtversionFn)(GhosttyTerminal terminal,
typedef void (*GhosttyTerminalTitleChangedFn)(GhosttyTerminal terminal,
void* userdata);
/**
* Callback function type for size queries (XTWINOPS).
*
* Called in response to XTWINOPS size queries (CSI 14/16/18 t).
* Return true and fill *out_size with the current terminal geometry,
* or return false to silently ignore the query.
*
* @param terminal The terminal handle
* @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA
* @param[out] out_size Pointer to store the terminal size information
* @return true if size was filled, false to ignore the query
*
* @ingroup terminal
*/
typedef bool (*GhosttyTerminalSizeFn)(GhosttyTerminal terminal,
void* userdata,
GhosttySizeReportSize* out_size);
/**
* Terminal option identifiers.
*
@@ -273,6 +292,14 @@ typedef enum {
* Input type: GhosttyTerminalTitleChangedFn*
*/
GHOSTTY_TERMINAL_OPT_TITLE_CHANGED = 5,
/**
* Callback invoked in response to XTWINOPS size queries
* (CSI 14/16/18 t). Set to NULL to silently ignore size queries.
*
* Input type: GhosttyTerminalSizeFn*
*/
GHOSTTY_TERMINAL_OPT_SIZE = 6,
} GhosttyTerminalOption;
/**