aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/include
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-07 18:29:21 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-07 18:29:21 +0300
commitdcfe11a7588fcd42471159453810abc9b7720a57 (patch)
treec32a77266028e73ca2382b96c96f8438a5fcd621 /vendor/libghostty-vt/include
parent2dfed860103c4e4505ac7f25def9fe37da1e1e6a (diff)
build: update libghostty-vt vendor
vendor ghostty 063ac3e and remove the musl libc++ link workaround. expose the new selection formatter and hyperlink uri apis for follow-up rendering work. add manual artifact validation for static linux builds.
Diffstat (limited to 'vendor/libghostty-vt/include')
-rw-r--r--vendor/libghostty-vt/include/ghostty.h5
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt.h8
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/build_info.h16
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/device.h3
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/focus.h3
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/formatter.h15
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/grid_ref.h26
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/key/encoder.h36
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/key/event.h6
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/kitty_graphics.h775
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/modes.h4
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/mouse/encoder.h9
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/mouse/event.h6
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/osc.h26
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/point.h5
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/render.h130
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/screen.h80
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/selection.h53
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/sgr.h16
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/size_report.h3
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/style.h5
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/sys.h210
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/terminal.h229
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/types.h138
24 files changed, 1642 insertions, 165 deletions
diff --git a/vendor/libghostty-vt/include/ghostty.h b/vendor/libghostty-vt/include/ghostty.h
index afc20bb3..b099741f 100644
--- a/vendor/libghostty-vt/include/ghostty.h
+++ b/vendor/libghostty-vt/include/ghostty.h
@@ -364,7 +364,6 @@ typedef enum {
} ghostty_input_trigger_tag_e;
typedef union {
- ghostty_input_key_e translated;
ghostty_input_key_e physical;
uint32_t unicode;
// catch_all has no payload
@@ -1078,6 +1077,7 @@ GHOSTTY_API bool ghostty_config_get(ghostty_config_t, void*, const char*, uintpt
GHOSTTY_API ghostty_input_trigger_s ghostty_config_trigger(ghostty_config_t,
const char*,
uintptr_t);
+GHOSTTY_API bool ghostty_config_key_is_binding(ghostty_config_t, ghostty_input_key_s);
GHOSTTY_API uint32_t ghostty_config_diagnostics_count(ghostty_config_t);
GHOSTTY_API ghostty_diagnostic_s ghostty_config_get_diagnostic(ghostty_config_t, uint32_t);
GHOSTTY_API ghostty_string_s ghostty_config_open_path(void);
@@ -1089,7 +1089,6 @@ GHOSTTY_API void ghostty_app_tick(ghostty_app_t);
GHOSTTY_API void* ghostty_app_userdata(ghostty_app_t);
GHOSTTY_API void ghostty_app_set_focus(ghostty_app_t, bool);
GHOSTTY_API bool ghostty_app_key(ghostty_app_t, ghostty_input_key_s);
-GHOSTTY_API bool ghostty_app_key_is_binding(ghostty_app_t, ghostty_input_key_s);
GHOSTTY_API void ghostty_app_keyboard_changed(ghostty_app_t);
GHOSTTY_API void ghostty_app_open_config(ghostty_app_t);
GHOSTTY_API void ghostty_app_update_config(ghostty_app_t, ghostty_config_t);
@@ -1115,6 +1114,8 @@ GHOSTTY_API void ghostty_surface_set_focus(ghostty_surface_t, bool);
GHOSTTY_API void ghostty_surface_set_occlusion(ghostty_surface_t, bool);
GHOSTTY_API void ghostty_surface_set_size(ghostty_surface_t, uint32_t, uint32_t);
GHOSTTY_API ghostty_surface_size_s ghostty_surface_size(ghostty_surface_t);
+GHOSTTY_API uint64_t ghostty_surface_foreground_pid(ghostty_surface_t);
+GHOSTTY_API ghostty_string_s ghostty_surface_tty_name(ghostty_surface_t);
GHOSTTY_API void ghostty_surface_set_color_scheme(ghostty_surface_t,
ghostty_color_scheme_e);
GHOSTTY_API ghostty_input_mods_e ghostty_surface_key_translation_mods(ghostty_surface_t,
diff --git a/vendor/libghostty-vt/include/ghostty/vt.h b/vendor/libghostty-vt/include/ghostty/vt.h
index 2a52f4b0..649ab1d4 100644
--- a/vendor/libghostty-vt/include/ghostty/vt.h
+++ b/vendor/libghostty-vt/include/ghostty/vt.h
@@ -98,6 +98,11 @@
* grid refs to inspect cell codepoints, row wrap state, and cell styles.
*/
+/** @example c-vt-kitty-graphics/src/main.c
+ * This example demonstrates how to use the system interface to install a
+ * PNG decoder callback and send a Kitty Graphics Protocol image.
+ */
+
#ifndef GHOSTTY_VT_H
#define GHOSTTY_VT_H
@@ -118,11 +123,14 @@ extern "C" {
#include <ghostty/vt/osc.h>
#include <ghostty/vt/sgr.h>
#include <ghostty/vt/style.h>
+#include <ghostty/vt/sys.h>
#include <ghostty/vt/key.h>
+#include <ghostty/vt/kitty_graphics.h>
#include <ghostty/vt/modes.h>
#include <ghostty/vt/mouse.h>
#include <ghostty/vt/paste.h>
#include <ghostty/vt/screen.h>
+#include <ghostty/vt/selection.h>
#include <ghostty/vt/size_report.h>
#include <ghostty/vt/wasm.h>
diff --git a/vendor/libghostty-vt/include/ghostty/vt/build_info.h b/vendor/libghostty-vt/include/ghostty/vt/build_info.h
index 7f77a769..8573556f 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/build_info.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/build_info.h
@@ -35,11 +35,12 @@ extern "C" {
/**
* Build optimization mode.
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_OPTIMIZE_DEBUG = 0,
GHOSTTY_OPTIMIZE_RELEASE_SAFE = 1,
GHOSTTY_OPTIMIZE_RELEASE_SMALL = 2,
GHOSTTY_OPTIMIZE_RELEASE_FAST = 3,
+ GHOSTTY_OPTIMIZE_MODE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyOptimizeMode;
/**
@@ -47,7 +48,7 @@ typedef enum {
*
* Each variant documents the expected output pointer type.
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Invalid data type. Never results in any data extraction. */
GHOSTTY_BUILD_INFO_INVALID = 0,
@@ -108,12 +109,21 @@ typedef enum {
GHOSTTY_BUILD_INFO_VERSION_PATCH = 8,
/**
+ * The pre metadata string (e.g. "alpha", "beta", "dev"). Has zero length if
+ * no pre metadata is present.
+ *
+ * Output type: GhosttyString *
+ */
+ GHOSTTY_BUILD_INFO_VERSION_PRE = 9,
+
+ /**
* The build metadata string (e.g. commit hash). Has zero length if
* no build metadata is present.
*
* Output type: GhosttyString *
*/
- GHOSTTY_BUILD_INFO_VERSION_BUILD = 9,
+ GHOSTTY_BUILD_INFO_VERSION_BUILD = 10,
+ GHOSTTY_BUILD_INFO_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyBuildInfo;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/device.h b/vendor/libghostty-vt/include/ghostty/vt/device.h
index fdf6bca7..0a156728 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/device.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/device.h
@@ -71,9 +71,10 @@ extern "C" {
*
* @ingroup terminal
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_COLOR_SCHEME_LIGHT = 0,
GHOSTTY_COLOR_SCHEME_DARK = 1,
+ GHOSTTY_COLOR_SCHEME_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyColorScheme;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/focus.h b/vendor/libghostty-vt/include/ghostty/vt/focus.h
index 6e4c9502..b9940f79 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/focus.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/focus.h
@@ -35,11 +35,12 @@ extern "C" {
/**
* Focus event types for focus reporting mode (mode 1004).
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Terminal window gained focus */
GHOSTTY_FOCUS_GAINED = 0,
/** Terminal window lost focus */
GHOSTTY_FOCUS_LOST = 1,
+ GHOSTTY_FOCUS_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyFocusEvent;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/formatter.h b/vendor/libghostty-vt/include/ghostty/vt/formatter.h
index 81efdb27..358e95f6 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/formatter.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/formatter.h
@@ -11,6 +11,7 @@
#include <stddef.h>
#include <stdint.h>
#include <ghostty/vt/allocator.h>
+#include <ghostty/vt/selection.h>
#include <ghostty/vt/types.h>
#include <ghostty/vt/terminal.h>
@@ -36,7 +37,7 @@ extern "C" {
*
* @ingroup formatter
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Plain text (no escape sequences). */
GHOSTTY_FORMATTER_FORMAT_PLAIN,
@@ -45,6 +46,7 @@ typedef enum {
/** HTML with inline styles. */
GHOSTTY_FORMATTER_FORMAT_HTML,
+ GHOSTTY_FORMATTER_FORMAT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyFormatterFormat;
/**
@@ -107,13 +109,6 @@ typedef struct {
} GhosttyFormatterTerminalExtra;
/**
- * Opaque handle to a formatter instance.
- *
- * @ingroup formatter
- */
-typedef struct GhosttyFormatterImpl* GhosttyFormatter;
-
-/**
* Options for creating a terminal formatter.
*
* @ingroup formatter
@@ -133,6 +128,10 @@ typedef struct {
/** Extra terminal state to include in styled output. */
GhosttyFormatterTerminalExtra extra;
+
+ /** Optional selection to restrict output to a range.
+ * If NULL, the entire screen is formatted. */
+ const GhosttySelection *selection;
} GhosttyFormatterTerminalOptions;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/grid_ref.h b/vendor/libghostty-vt/include/ghostty/vt/grid_ref.h
index d3489ea7..1f9f52b9 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/grid_ref.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/grid_ref.h
@@ -110,6 +110,32 @@ GHOSTTY_API GhosttyResult ghostty_grid_ref_graphemes(const GhosttyGridRef *ref,
size_t *out_len);
/**
+ * Get the hyperlink URI for the cell at the grid reference's position.
+ *
+ * Writes the URI bytes into the provided buffer. If the cell has no
+ * hyperlink, out_len is set to 0 and GHOSTTY_SUCCESS is returned.
+ *
+ * If the buffer is too small (or NULL), the function returns
+ * GHOSTTY_OUT_OF_SPACE and writes the required number of bytes to
+ * out_len. The caller can then retry with a sufficiently sized buffer.
+ *
+ * @param ref Pointer to the grid reference
+ * @param buf Output buffer for the URI bytes (may be NULL)
+ * @param buf_len Size of the output buffer in bytes
+ * @param[out] out_len On success, the number of bytes written. On
+ * GHOSTTY_OUT_OF_SPACE, the required buffer size in bytes.
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the ref's
+ * node is NULL, GHOSTTY_OUT_OF_SPACE if the buffer is too small
+ *
+ * @ingroup grid_ref
+ */
+GHOSTTY_API GhosttyResult ghostty_grid_ref_hyperlink_uri(
+ const GhosttyGridRef *ref,
+ uint8_t *buf,
+ size_t buf_len,
+ size_t *out_len);
+
+/**
* Get the style of the cell at the grid reference's position.
*
* @param ref Pointer to the grid reference
diff --git a/vendor/libghostty-vt/include/ghostty/vt/key/encoder.h b/vendor/libghostty-vt/include/ghostty/vt/key/encoder.h
index 9d8282ce..3aeec659 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/key/encoder.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/key/encoder.h
@@ -64,7 +64,7 @@ typedef uint8_t GhosttyKittyKeyFlags;
*
* @ingroup key
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Option key is not treated as alt */
GHOSTTY_OPTION_AS_ALT_FALSE = 0,
/** Option key is treated as alt */
@@ -73,6 +73,7 @@ typedef enum {
GHOSTTY_OPTION_AS_ALT_LEFT = 2,
/** Only right option key is treated as alt */
GHOSTTY_OPTION_AS_ALT_RIGHT = 3,
+ GHOSTTY_OPTION_AS_ALT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyOptionAsAlt;
/**
@@ -83,27 +84,36 @@ typedef enum {
*
* @ingroup key
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Terminal DEC mode 1: cursor key application mode (value: bool) */
GHOSTTY_KEY_ENCODER_OPT_CURSOR_KEY_APPLICATION = 0,
-
+
/** Terminal DEC mode 66: keypad key application mode (value: bool) */
GHOSTTY_KEY_ENCODER_OPT_KEYPAD_KEY_APPLICATION = 1,
-
+
/** Terminal DEC mode 1035: ignore keypad with numlock (value: bool) */
GHOSTTY_KEY_ENCODER_OPT_IGNORE_KEYPAD_WITH_NUMLOCK = 2,
-
+
/** Terminal DEC mode 1036: alt sends escape prefix (value: bool) */
GHOSTTY_KEY_ENCODER_OPT_ALT_ESC_PREFIX = 3,
-
+
/** xterm modifyOtherKeys mode 2 (value: bool) */
GHOSTTY_KEY_ENCODER_OPT_MODIFY_OTHER_KEYS_STATE_2 = 4,
-
+
/** Kitty keyboard protocol flags (value: GhosttyKittyKeyFlags bitmask) */
GHOSTTY_KEY_ENCODER_OPT_KITTY_FLAGS = 5,
-
+
/** macOS option-as-alt setting (value: GhosttyOptionAsAlt) */
GHOSTTY_KEY_ENCODER_OPT_MACOS_OPTION_AS_ALT = 6,
+
+ /** Backarrow key mode (value: bool)
+ * See https://vt100.net/dec/ek-vt3xx-tp-002.pdf page 170
+ * If `false` (the default), `backspace` emits 0x7f
+ * If `true`, `backspace` emits 0x08
+ */
+ GHOSTTY_KEY_ENCODER_OPT_BACKARROW_KEY_MODE = 7,
+
+ GHOSTTY_KEY_ENCODER_OPT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyKeyEncoderOption;
/**
@@ -203,17 +213,17 @@ GHOSTTY_API void ghostty_key_encoder_setopt_from_terminal(GhosttyKeyEncoder enco
* size_t required = 0;
* GhosttyResult result = ghostty_key_encoder_encode(encoder, event, NULL, 0, &required);
* assert(result == GHOSTTY_OUT_OF_SPACE);
- *
+ *
* // Allocate buffer of required size
* char *buf = malloc(required);
- *
+ *
* // Encode with properly sized buffer
* size_t written = 0;
* result = ghostty_key_encoder_encode(encoder, event, buf, required, &written);
* assert(result == GHOSTTY_SUCCESS);
- *
+ *
* // Use the encoded sequence...
- *
+ *
* free(buf);
* @endcode
*
@@ -224,7 +234,7 @@ GHOSTTY_API void ghostty_key_encoder_setopt_from_terminal(GhosttyKeyEncoder enco
* char buf[128];
* size_t written = 0;
* GhosttyResult result = ghostty_key_encoder_encode(encoder, event, buf, sizeof(buf), &written);
- *
+ *
* if (result == GHOSTTY_SUCCESS) {
* // Write the encoded sequence to the terminal
* write(pty_fd, buf, written);
diff --git a/vendor/libghostty-vt/include/ghostty/vt/key/event.h b/vendor/libghostty-vt/include/ghostty/vt/key/event.h
index bcc9d8de..eba433c6 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/key/event.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/key/event.h
@@ -28,13 +28,14 @@ typedef struct GhosttyKeyEventImpl *GhosttyKeyEvent;
*
* @ingroup key
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Key was released */
GHOSTTY_KEY_ACTION_RELEASE = 0,
/** Key was pressed */
GHOSTTY_KEY_ACTION_PRESS = 1,
/** Key is being repeated (held down) */
GHOSTTY_KEY_ACTION_REPEAT = 2,
+ GHOSTTY_KEY_ACTION_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyKeyAction;
/**
@@ -103,7 +104,7 @@ typedef uint16_t GhosttyMods;
*
* @ingroup key
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_KEY_UNIDENTIFIED = 0,
// Writing System Keys (W3C § 3.1.1)
@@ -296,6 +297,7 @@ typedef enum {
GHOSTTY_KEY_COPY,
GHOSTTY_KEY_CUT,
GHOSTTY_KEY_PASTE,
+ GHOSTTY_KEY_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyKey;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/kitty_graphics.h b/vendor/libghostty-vt/include/ghostty/vt/kitty_graphics.h
new file mode 100644
index 00000000..9bace3a3
--- /dev/null
+++ b/vendor/libghostty-vt/include/ghostty/vt/kitty_graphics.h
@@ -0,0 +1,775 @@
+/**
+ * @file kitty_graphics.h
+ *
+ * Kitty graphics protocol
+ *
+ * See @ref kitty_graphics for a full usage guide.
+ */
+
+#ifndef GHOSTTY_VT_KITTY_GRAPHICS_H
+#define GHOSTTY_VT_KITTY_GRAPHICS_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <ghostty/vt/allocator.h>
+#include <ghostty/vt/selection.h>
+#include <ghostty/vt/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup kitty_graphics Kitty Graphics
+ *
+ * API for inspecting images and placements stored via the
+ * [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/).
+ *
+ * The central object is @ref GhosttyKittyGraphics, an opaque handle to
+ * the image storage associated with a terminal's active screen. From it
+ * you can iterate over placements and look up individual images.
+ *
+ * ## Obtaining a KittyGraphics Handle
+ *
+ * A @ref GhosttyKittyGraphics handle is obtained from a terminal via
+ * ghostty_terminal_get() with @ref GHOSTTY_TERMINAL_DATA_KITTY_GRAPHICS.
+ * The handle is borrowed from the terminal and remains valid until the
+ * next mutating terminal call (e.g. ghostty_terminal_vt_write() or
+ * ghostty_terminal_reset()).
+ *
+ * Before images can be stored, Kitty graphics must be enabled on the
+ * terminal by setting a non-zero storage limit with
+ * @ref GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_STORAGE_LIMIT, and a PNG
+ * decoder callback must be installed via ghostty_sys_set() with
+ * @ref GHOSTTY_SYS_OPT_DECODE_PNG.
+ *
+ * @snippet c-vt-kitty-graphics/src/main.c kitty-graphics-decode-png
+ *
+ * ## Iterating Placements
+ *
+ * Placements are inspected through a @ref GhosttyKittyGraphicsPlacementIterator.
+ * The typical workflow is:
+ *
+ * 1. Create an iterator with ghostty_kitty_graphics_placement_iterator_new().
+ * 2. Populate it from the storage with ghostty_kitty_graphics_get() using
+ * @ref GHOSTTY_KITTY_GRAPHICS_DATA_PLACEMENT_ITERATOR.
+ * 3. Optionally filter by z-layer with
+ * ghostty_kitty_graphics_placement_iterator_set().
+ * 4. Advance with ghostty_kitty_graphics_placement_next() and read
+ * per-placement data with ghostty_kitty_graphics_placement_get().
+ * 5. For each placement, look up its image with
+ * ghostty_kitty_graphics_image() to access pixel data and dimensions.
+ * 6. Free the iterator with ghostty_kitty_graphics_placement_iterator_free().
+ *
+ * ## Looking Up Images
+ *
+ * Given an image ID (obtained from a placement via
+ * @ref GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_IMAGE_ID), call
+ * ghostty_kitty_graphics_image() to get a @ref GhosttyKittyGraphicsImage
+ * handle. From this handle, ghostty_kitty_graphics_image_get() provides
+ * the image dimensions, pixel format, compression, and a borrowed pointer
+ * to the raw pixel data.
+ *
+ * ## Rendering Helpers
+ *
+ * Several functions assist with rendering a placement:
+ *
+ * - ghostty_kitty_graphics_placement_pixel_size() — rendered pixel
+ * dimensions accounting for source rect and aspect ratio.
+ * - ghostty_kitty_graphics_placement_grid_size() — number of grid
+ * columns and rows the placement occupies.
+ * - ghostty_kitty_graphics_placement_viewport_pos() — viewport-relative
+ * grid position (may be negative for partially scrolled placements).
+ * - ghostty_kitty_graphics_placement_source_rect() — resolved source
+ * rectangle in pixels, clamped to image bounds.
+ * - ghostty_kitty_graphics_placement_rect() — bounding rectangle as a
+ * @ref GhosttySelection.
+ *
+ * ## Lifetime and Thread Safety
+ *
+ * All handles borrowed from the terminal (GhosttyKittyGraphics,
+ * GhosttyKittyGraphicsImage) are invalidated by any mutating terminal
+ * call. The placement iterator is independently owned and must be freed
+ * by the caller, but the data it yields is only valid while the
+ * underlying terminal is not mutated.
+ *
+ * ## Example
+ *
+ * The following example creates a terminal, sends a Kitty graphics
+ * image, then iterates placements and prints image metadata:
+ *
+ * @snippet c-vt-kitty-graphics/src/main.c kitty-graphics-main
+ *
+ * @{
+ */
+
+/**
+ * Queryable data kinds for ghostty_kitty_graphics_get().
+ *
+ * @ingroup kitty_graphics
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ /** Invalid / sentinel value. */
+ GHOSTTY_KITTY_GRAPHICS_DATA_INVALID = 0,
+
+ /**
+ * Populate a pre-allocated placement iterator with placement data from
+ * the storage. Iterator data is only valid as long as the underlying
+ * terminal is not mutated.
+ *
+ * Output type: GhosttyKittyGraphicsPlacementIterator *
+ */
+ GHOSTTY_KITTY_GRAPHICS_DATA_PLACEMENT_ITERATOR = 1,
+ GHOSTTY_KITTY_GRAPHICS_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttyKittyGraphicsData;
+
+/**
+ * Queryable data kinds for ghostty_kitty_graphics_placement_get().
+ *
+ * @ingroup kitty_graphics
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ /** Invalid / sentinel value. */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_INVALID = 0,
+
+ /**
+ * The image ID this placement belongs to.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_IMAGE_ID = 1,
+
+ /**
+ * The placement ID.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_PLACEMENT_ID = 2,
+
+ /**
+ * Whether this is a virtual placement (unicode placeholder).
+ *
+ * Output type: bool *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_IS_VIRTUAL = 3,
+
+ /**
+ * Pixel offset from the left edge of the cell.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_X_OFFSET = 4,
+
+ /**
+ * Pixel offset from the top edge of the cell.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_Y_OFFSET = 5,
+
+ /**
+ * Source rectangle x origin in pixels.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_X = 6,
+
+ /**
+ * Source rectangle y origin in pixels.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_Y = 7,
+
+ /**
+ * Source rectangle width in pixels (0 = full image width).
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_WIDTH = 8,
+
+ /**
+ * Source rectangle height in pixels (0 = full image height).
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_HEIGHT = 9,
+
+ /**
+ * Number of columns this placement occupies.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_COLUMNS = 10,
+
+ /**
+ * Number of rows this placement occupies.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_ROWS = 11,
+
+ /**
+ * Z-index for this placement.
+ *
+ * Output type: int32_t *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_Z = 12,
+
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttyKittyGraphicsPlacementData;
+
+/**
+ * Z-layer classification for kitty graphics placements.
+ *
+ * Based on the kitty protocol z-index conventions:
+ * - BELOW_BG: z < INT32_MIN/2 (drawn below cell background)
+ * - BELOW_TEXT: INT32_MIN/2 <= z < 0 (above background, below text)
+ * - ABOVE_TEXT: z >= 0 (above text)
+ * - ALL: no filtering (current behavior)
+ *
+ * @ingroup kitty_graphics
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ GHOSTTY_KITTY_PLACEMENT_LAYER_ALL = 0,
+ GHOSTTY_KITTY_PLACEMENT_LAYER_BELOW_BG = 1,
+ GHOSTTY_KITTY_PLACEMENT_LAYER_BELOW_TEXT = 2,
+ GHOSTTY_KITTY_PLACEMENT_LAYER_ABOVE_TEXT = 3,
+ GHOSTTY_KITTY_PLACEMENT_LAYER_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttyKittyPlacementLayer;
+
+/**
+ * Settable options for ghostty_kitty_graphics_placement_iterator_set().
+ *
+ * @ingroup kitty_graphics
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ /**
+ * Set the z-layer filter for the iterator.
+ *
+ * Input type: GhosttyKittyPlacementLayer *
+ */
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPTION_LAYER = 0,
+ GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPTION_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttyKittyGraphicsPlacementIteratorOption;
+
+/**
+ * Pixel format of a Kitty graphics image.
+ *
+ * @ingroup kitty_graphics
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ GHOSTTY_KITTY_IMAGE_FORMAT_RGB = 0,
+ GHOSTTY_KITTY_IMAGE_FORMAT_RGBA = 1,
+ GHOSTTY_KITTY_IMAGE_FORMAT_PNG = 2,
+ GHOSTTY_KITTY_IMAGE_FORMAT_GRAY_ALPHA = 3,
+ GHOSTTY_KITTY_IMAGE_FORMAT_GRAY = 4,
+ GHOSTTY_KITTY_IMAGE_FORMAT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttyKittyImageFormat;
+
+/**
+ * Compression of a Kitty graphics image.
+ *
+ * @ingroup kitty_graphics
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ GHOSTTY_KITTY_IMAGE_COMPRESSION_NONE = 0,
+ GHOSTTY_KITTY_IMAGE_COMPRESSION_ZLIB_DEFLATE = 1,
+ GHOSTTY_KITTY_IMAGE_COMPRESSION_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttyKittyImageCompression;
+
+/**
+ * Queryable data kinds for ghostty_kitty_graphics_image_get().
+ *
+ * @ingroup kitty_graphics
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ /** Invalid / sentinel value. */
+ GHOSTTY_KITTY_IMAGE_DATA_INVALID = 0,
+
+ /**
+ * The image ID.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_IMAGE_DATA_ID = 1,
+
+ /**
+ * The image number.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_IMAGE_DATA_NUMBER = 2,
+
+ /**
+ * Image width in pixels.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_IMAGE_DATA_WIDTH = 3,
+
+ /**
+ * Image height in pixels.
+ *
+ * Output type: uint32_t *
+ */
+ GHOSTTY_KITTY_IMAGE_DATA_HEIGHT = 4,
+
+ /**
+ * Pixel format of the image.
+ *
+ * Output type: GhosttyKittyImageFormat *
+ */
+ GHOSTTY_KITTY_IMAGE_DATA_FORMAT = 5,
+
+ /**
+ * Compression of the image.
+ *
+ * Output type: GhosttyKittyImageCompression *
+ */
+ GHOSTTY_KITTY_IMAGE_DATA_COMPRESSION = 6,
+
+ /**
+ * Borrowed pointer to the raw pixel data. Valid as long as the
+ * underlying terminal is not mutated.
+ *
+ * Output type: const uint8_t **
+ */
+ GHOSTTY_KITTY_IMAGE_DATA_DATA_PTR = 7,
+
+ /**
+ * Length of the raw pixel data in bytes.
+ *
+ * Output type: size_t *
+ */
+ GHOSTTY_KITTY_IMAGE_DATA_DATA_LEN = 8,
+
+ GHOSTTY_KITTY_IMAGE_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttyKittyGraphicsImageData;
+
+/**
+ * Combined rendering geometry for a placement in a single sized struct.
+ *
+ * Combines the results of ghostty_kitty_graphics_placement_pixel_size(),
+ * ghostty_kitty_graphics_placement_grid_size(),
+ * ghostty_kitty_graphics_placement_viewport_pos(), and
+ * ghostty_kitty_graphics_placement_source_rect() into one call. This is
+ * an optimization over calling those four functions individually,
+ * particularly useful in environments with high per-call overhead such
+ * as FFI or Cgo.
+ *
+ * This struct uses the sized-struct ABI pattern. Initialize with
+ * GHOSTTY_INIT_SIZED(GhosttyKittyGraphicsPlacementRenderInfo) before calling
+ * ghostty_kitty_graphics_placement_render_info().
+ *
+ * @ingroup kitty_graphics
+ */
+typedef struct {
+ /** Size of this struct in bytes. Must be set to sizeof(GhosttyKittyGraphicsPlacementRenderInfo). */
+ size_t size;
+ /** Rendered width in pixels. */
+ uint32_t pixel_width;
+ /** Rendered height in pixels. */
+ uint32_t pixel_height;
+ /** Number of grid columns the placement occupies. */
+ uint32_t grid_cols;
+ /** Number of grid rows the placement occupies. */
+ uint32_t grid_rows;
+ /** Viewport-relative column (may be negative for partially visible placements). */
+ int32_t viewport_col;
+ /** Viewport-relative row (may be negative for partially visible placements). */
+ int32_t viewport_row;
+ /** False when the placement is fully off-screen or virtual. */
+ bool viewport_visible;
+ /** Resolved source rectangle x origin in pixels. */
+ uint32_t source_x;
+ /** Resolved source rectangle y origin in pixels. */
+ uint32_t source_y;
+ /** Resolved source rectangle width in pixels. */
+ uint32_t source_width;
+ /** Resolved source rectangle height in pixels. */
+ uint32_t source_height;
+} GhosttyKittyGraphicsPlacementRenderInfo;
+
+/**
+ * Get data from a kitty graphics storage instance.
+ *
+ * The output pointer must be of the appropriate type for the requested
+ * data kind.
+ *
+ * Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.
+ *
+ * @param graphics The kitty graphics handle
+ * @param data The type of data to extract
+ * @param[out] out Pointer to store the extracted data
+ * @return GHOSTTY_SUCCESS on success
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_get(
+ GhosttyKittyGraphics graphics,
+ GhosttyKittyGraphicsData data,
+ void* out);
+
+/**
+ * Look up a Kitty graphics image by its image ID.
+ *
+ * Returns NULL if no image with the given ID exists or if Kitty graphics
+ * are disabled at build time.
+ *
+ * @param graphics The kitty graphics handle
+ * @param image_id The image ID to look up
+ * @return An opaque image handle, or NULL if not found
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyKittyGraphicsImage ghostty_kitty_graphics_image(
+ GhosttyKittyGraphics graphics,
+ uint32_t image_id);
+
+/**
+ * Get data from a Kitty graphics image.
+ *
+ * The output pointer must be of the appropriate type for the requested
+ * data kind.
+ *
+ * @param image The image handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param data The data kind to query
+ * @param[out] out Pointer to receive the queried value
+ * @return GHOSTTY_SUCCESS on success
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_image_get(
+ GhosttyKittyGraphicsImage image,
+ GhosttyKittyGraphicsImageData data,
+ void* out);
+
+/**
+ * Get multiple data fields from a Kitty graphics image in a single call.
+ *
+ * This is an optimization over calling ghostty_kitty_graphics_image_get()
+ * repeatedly, particularly useful in environments with high per-call
+ * overhead such as FFI or Cgo.
+ *
+ * Each element in the keys array specifies a data kind, and the
+ * corresponding element in the values array receives the result.
+ * The type of each values[i] pointer must match the output type
+ * documented for keys[i].
+ *
+ * Processing stops at the first error; on success out_written
+ * is set to count, on error it is set to the index of the
+ * failing key (i.e. the number of values successfully written).
+ *
+ * @param image The image handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param count Number of key/value pairs
+ * @param keys Array of data kinds to query
+ * @param values Array of output pointers (types must match each key's
+ * documented output type)
+ * @param[out] out_written On return, receives the number of values
+ * successfully written (may be NULL)
+ * @return GHOSTTY_SUCCESS if all queries succeed
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_image_get_multi(
+ GhosttyKittyGraphicsImage image,
+ size_t count,
+ const GhosttyKittyGraphicsImageData* keys,
+ void** values,
+ size_t* out_written);
+
+/**
+ * Create a new placement iterator instance.
+ *
+ * All fields except the allocator are left undefined until populated
+ * via ghostty_kitty_graphics_get() with
+ * GHOSTTY_KITTY_GRAPHICS_DATA_PLACEMENT_ITERATOR.
+ *
+ * @param allocator Pointer to allocator, or NULL to use the default allocator
+ * @param[out] out_iterator On success, receives the created iterator handle
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_MEMORY on allocation
+ * failure
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_iterator_new(
+ const GhosttyAllocator* allocator,
+ GhosttyKittyGraphicsPlacementIterator* out_iterator);
+
+/**
+ * Free a placement iterator.
+ *
+ * @param iterator The iterator handle to free (may be NULL)
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API void ghostty_kitty_graphics_placement_iterator_free(
+ GhosttyKittyGraphicsPlacementIterator iterator);
+
+/**
+ * Set an option on a placement iterator.
+ *
+ * Use GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPTION_LAYER with a
+ * GhosttyKittyPlacementLayer value to filter placements by z-layer.
+ * The filter is applied during iteration: ghostty_kitty_graphics_placement_next()
+ * will skip placements that do not match the configured layer.
+ *
+ * The default layer is GHOSTTY_KITTY_PLACEMENT_LAYER_ALL (no filtering).
+ *
+ * @param iterator The iterator handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param option The option to set
+ * @param value Pointer to the value (type depends on option; NULL returns
+ * GHOSTTY_INVALID_VALUE)
+ * @return GHOSTTY_SUCCESS on success
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_iterator_set(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ GhosttyKittyGraphicsPlacementIteratorOption option,
+ const void* value);
+
+/**
+ * Advance the placement iterator to the next placement.
+ *
+ * If a layer filter has been set via
+ * ghostty_kitty_graphics_placement_iterator_set(), only placements
+ * matching that layer are returned.
+ *
+ * @param iterator The iterator handle (may be NULL)
+ * @return true if advanced to the next placement, false if at the end
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API bool ghostty_kitty_graphics_placement_next(
+ GhosttyKittyGraphicsPlacementIterator iterator);
+
+/**
+ * Get data from the current placement in a placement iterator.
+ *
+ * Call ghostty_kitty_graphics_placement_next() at least once before
+ * calling this function.
+ *
+ * @param iterator The iterator handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param data The data kind to query
+ * @param[out] out Pointer to receive the queried value
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the
+ * iterator is NULL or not positioned on a placement
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_get(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ GhosttyKittyGraphicsPlacementData data,
+ void* out);
+
+/**
+ * Get multiple data fields from the current placement in a single call.
+ *
+ * This is an optimization over calling ghostty_kitty_graphics_placement_get()
+ * repeatedly, particularly useful in environments with high per-call
+ * overhead such as FFI or Cgo.
+ *
+ * Each element in the keys array specifies a data kind, and the
+ * corresponding element in the values array receives the result.
+ * The type of each values[i] pointer must match the output type
+ * documented for keys[i].
+ *
+ * Processing stops at the first error; on success out_written
+ * is set to count, on error it is set to the index of the
+ * failing key (i.e. the number of values successfully written).
+ *
+ * @param iterator The iterator handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param count Number of key/value pairs
+ * @param keys Array of data kinds to query
+ * @param values Array of output pointers (types must match each key's
+ * documented output type)
+ * @param[out] out_written On return, receives the number of values
+ * successfully written (may be NULL)
+ * @return GHOSTTY_SUCCESS if all queries succeed
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_get_multi(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ size_t count,
+ const GhosttyKittyGraphicsPlacementData* keys,
+ void** values,
+ size_t* out_written);
+
+/**
+ * Compute the grid rectangle occupied by the current placement.
+ *
+ * Uses the placement's pin, the image dimensions, and the terminal's
+ * cell/pixel geometry to calculate the bounding rectangle. Virtual
+ * placements (unicode placeholders) return GHOSTTY_NO_VALUE.
+ *
+ * @param terminal The terminal handle
+ * @param image The image handle for this placement's image
+ * @param iterator The placement iterator positioned on a placement
+ * @param[out] out_selection On success, receives the bounding rectangle
+ * as a selection with rectangle=true
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if any handle
+ * is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE for
+ * virtual placements or when Kitty graphics are disabled
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_rect(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ GhosttyKittyGraphicsImage image,
+ GhosttyTerminal terminal,
+ GhosttySelection* out_selection);
+
+/**
+ * Compute the rendered pixel size of the current placement.
+ *
+ * Takes into account the placement's source rectangle, specified
+ * columns/rows, and aspect ratio to calculate the final rendered
+ * pixel dimensions.
+ *
+ * @param iterator The placement iterator positioned on a placement
+ * @param image The image handle for this placement's image
+ * @param terminal The terminal handle
+ * @param[out] out_width On success, receives the width in pixels
+ * @param[out] out_height On success, receives the height in pixels
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if any handle
+ * is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE when
+ * Kitty graphics are disabled
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_pixel_size(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ GhosttyKittyGraphicsImage image,
+ GhosttyTerminal terminal,
+ uint32_t* out_width,
+ uint32_t* out_height);
+
+/**
+ * Compute the grid cell size of the current placement.
+ *
+ * Returns the number of columns and rows that the placement occupies
+ * in the terminal grid. If the placement specifies explicit columns
+ * and rows, those are returned directly; otherwise they are calculated
+ * from the pixel size and cell dimensions.
+ *
+ * @param iterator The placement iterator positioned on a placement
+ * @param image The image handle for this placement's image
+ * @param terminal The terminal handle
+ * @param[out] out_cols On success, receives the number of columns
+ * @param[out] out_rows On success, receives the number of rows
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if any handle
+ * is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE when
+ * Kitty graphics are disabled
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_grid_size(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ GhosttyKittyGraphicsImage image,
+ GhosttyTerminal terminal,
+ uint32_t* out_cols,
+ uint32_t* out_rows);
+
+/**
+ * Get the viewport-relative grid position of the current placement.
+ *
+ * Converts the placement's internal pin to viewport-relative column and
+ * row coordinates. The returned coordinates represent the top-left
+ * corner of the placement in the viewport's grid coordinate space.
+ *
+ * The row value can be negative when the placement's origin has
+ * scrolled above the top of the viewport. For example, a 4-row
+ * image that has scrolled up by 2 rows returns row=-2, meaning
+ * its top 2 rows are above the visible area but its bottom 2 rows
+ * are still on screen. Embedders should use these coordinates
+ * directly when computing the destination rectangle for rendering;
+ * the embedder is responsible for clipping the portion of the image
+ * that falls outside the viewport.
+ *
+ * Returns GHOSTTY_SUCCESS for any placement that is at least
+ * partially visible in the viewport. Returns GHOSTTY_NO_VALUE when
+ * the placement is completely outside the viewport (its bottom edge
+ * is above the viewport or its top edge is at or below the last
+ * viewport row), or when the placement is a virtual (unicode
+ * placeholder) placement.
+ *
+ * @param iterator The placement iterator positioned on a placement
+ * @param image The image handle for this placement's image
+ * @param terminal The terminal handle
+ * @param[out] out_col On success, receives the viewport-relative column
+ * @param[out] out_row On success, receives the viewport-relative row
+ * (may be negative for partially visible placements)
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if fully
+ * off-screen or virtual, GHOSTTY_INVALID_VALUE if any handle
+ * is NULL or the iterator is not positioned
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_viewport_pos(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ GhosttyKittyGraphicsImage image,
+ GhosttyTerminal terminal,
+ int32_t* out_col,
+ int32_t* out_row);
+
+/**
+ * Get the resolved source rectangle for the current placement.
+ *
+ * Applies kitty protocol semantics: a width or height of 0 in the
+ * placement means "use the full image dimension", and the resulting
+ * rectangle is clamped to the actual image bounds. The returned
+ * values are in pixels and are ready to use for texture sampling.
+ *
+ * @param iterator The placement iterator positioned on a placement
+ * @param image The image handle for this placement's image
+ * @param[out] out_x Source rect x origin in pixels
+ * @param[out] out_y Source rect y origin in pixels
+ * @param[out] out_width Source rect width in pixels
+ * @param[out] out_height Source rect height in pixels
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if any
+ * handle is NULL or the iterator is not positioned
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_source_rect(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ GhosttyKittyGraphicsImage image,
+ uint32_t* out_x,
+ uint32_t* out_y,
+ uint32_t* out_width,
+ uint32_t* out_height);
+
+/**
+ * Get all rendering geometry for a placement in a single call.
+ *
+ * Combines pixel size, grid size, viewport position, and source
+ * rectangle into one struct. Initialize with
+ * GHOSTTY_INIT_SIZED(GhosttyKittyGraphicsPlacementRenderInfo).
+ *
+ * When viewport_visible is false, the placement is fully off-screen
+ * or is a virtual placement; viewport_col and viewport_row may
+ * contain meaningless values in that case.
+ *
+ * @param iterator The iterator positioned on a placement
+ * @param image The image handle for this placement's image
+ * @param terminal The terminal handle
+ * @param[out] out_info Pointer to receive the rendering geometry
+ * @return GHOSTTY_SUCCESS on success
+ *
+ * @ingroup kitty_graphics
+ */
+GHOSTTY_API GhosttyResult ghostty_kitty_graphics_placement_render_info(
+ GhosttyKittyGraphicsPlacementIterator iterator,
+ GhosttyKittyGraphicsImage image,
+ GhosttyTerminal terminal,
+ GhosttyKittyGraphicsPlacementRenderInfo* out_info);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GHOSTTY_VT_KITTY_GRAPHICS_H */
diff --git a/vendor/libghostty-vt/include/ghostty/vt/modes.h b/vendor/libghostty-vt/include/ghostty/vt/modes.h
index 513aaf5a..8e1fd911 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/modes.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/modes.h
@@ -70,6 +70,7 @@ extern "C" {
#define GHOSTTY_MODE_REVERSE_WRAP (ghostty_mode_new(45, false)) /**< Reverse wrap */
#define GHOSTTY_MODE_ALT_SCREEN_LEGACY (ghostty_mode_new(47, false)) /**< Alternate screen (legacy) */
#define GHOSTTY_MODE_KEYPAD_KEYS (ghostty_mode_new(66, false)) /**< Application keypad */
+#define GHOSTTY_MODE_BACKARROW_KEY_MODE (ghostty_mode_new(67, false)) /**< Backarrow key mode (DECBKM) */
#define GHOSTTY_MODE_LEFT_RIGHT_MARGIN (ghostty_mode_new(69, false)) /**< Left/right margin mode */
#define GHOSTTY_MODE_NORMAL_MOUSE (ghostty_mode_new(1000, false)) /**< Normal mouse tracking */
#define GHOSTTY_MODE_BUTTON_MOUSE (ghostty_mode_new(1002, false)) /**< Button-event mouse tracking */
@@ -146,7 +147,7 @@ static inline bool ghostty_mode_ansi(GhosttyMode mode) {
* These correspond to the Ps2 parameter in a DECRPM response
* sequence (CSI ? Ps1 ; Ps2 $ y).
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Mode is not recognized */
GHOSTTY_MODE_REPORT_NOT_RECOGNIZED = 0,
/** Mode is set (enabled) */
@@ -157,6 +158,7 @@ typedef enum {
GHOSTTY_MODE_REPORT_PERMANENTLY_SET = 3,
/** Mode is permanently reset */
GHOSTTY_MODE_REPORT_PERMANENTLY_RESET = 4,
+ GHOSTTY_MODE_REPORT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyModeReportState;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/mouse/encoder.h b/vendor/libghostty-vt/include/ghostty/vt/mouse/encoder.h
index 744b9930..d84d863c 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/mouse/encoder.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/mouse/encoder.h
@@ -30,7 +30,7 @@ typedef struct GhosttyMouseEncoderImpl *GhosttyMouseEncoder;
*
* @ingroup mouse
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Mouse reporting disabled. */
GHOSTTY_MOUSE_TRACKING_NONE = 0,
@@ -45,6 +45,7 @@ typedef enum {
/** Any-event tracking mode. */
GHOSTTY_MOUSE_TRACKING_ANY = 4,
+ GHOSTTY_MOUSE_TRACKING_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyMouseTrackingMode;
/**
@@ -52,12 +53,13 @@ typedef enum {
*
* @ingroup mouse
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_MOUSE_FORMAT_X10 = 0,
GHOSTTY_MOUSE_FORMAT_UTF8 = 1,
GHOSTTY_MOUSE_FORMAT_SGR = 2,
GHOSTTY_MOUSE_FORMAT_URXVT = 3,
GHOSTTY_MOUSE_FORMAT_SGR_PIXELS = 4,
+ GHOSTTY_MOUSE_FORMAT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyMouseFormat;
/**
@@ -105,7 +107,7 @@ typedef struct {
*
* @ingroup mouse
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Mouse tracking mode (value: GhosttyMouseTrackingMode). */
GHOSTTY_MOUSE_ENCODER_OPT_EVENT = 0,
@@ -120,6 +122,7 @@ typedef enum {
/** Whether to enable motion deduplication by last cell (value: bool). */
GHOSTTY_MOUSE_ENCODER_OPT_TRACK_LAST_CELL = 4,
+ GHOSTTY_MOUSE_ENCODER_OPT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyMouseEncoderOption;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/mouse/event.h b/vendor/libghostty-vt/include/ghostty/vt/mouse/event.h
index 5b72735f..a24b0c07 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/mouse/event.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/mouse/event.h
@@ -27,7 +27,7 @@ typedef struct GhosttyMouseEventImpl *GhosttyMouseEvent;
*
* @ingroup mouse
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Mouse button was pressed. */
GHOSTTY_MOUSE_ACTION_PRESS = 0,
@@ -36,6 +36,7 @@ typedef enum {
/** Mouse moved. */
GHOSTTY_MOUSE_ACTION_MOTION = 2,
+ GHOSTTY_MOUSE_ACTION_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyMouseAction;
/**
@@ -43,7 +44,7 @@ typedef enum {
*
* @ingroup mouse
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_MOUSE_BUTTON_UNKNOWN = 0,
GHOSTTY_MOUSE_BUTTON_LEFT = 1,
GHOSTTY_MOUSE_BUTTON_RIGHT = 2,
@@ -56,6 +57,7 @@ typedef enum {
GHOSTTY_MOUSE_BUTTON_NINE = 9,
GHOSTTY_MOUSE_BUTTON_TEN = 10,
GHOSTTY_MOUSE_BUTTON_ELEVEN = 11,
+ GHOSTTY_MOUSE_BUTTON_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyMouseButton;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/osc.h b/vendor/libghostty-vt/include/ghostty/vt/osc.h
index c8649809..9409ebc7 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/osc.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/osc.h
@@ -13,26 +13,6 @@
#include <ghostty/vt/types.h>
#include <ghostty/vt/allocator.h>
-/**
- * Opaque handle to an OSC parser instance.
- *
- * This handle represents an OSC (Operating System Command) parser that can
- * be used to parse the contents of OSC sequences.
- *
- * @ingroup osc
- */
-typedef struct GhosttyOscParserImpl *GhosttyOscParser;
-
-/**
- * Opaque handle to a single OSC command.
- *
- * This handle represents a parsed OSC (Operating System Command) command.
- * The command can be queried for its type and associated data.
- *
- * @ingroup osc
- */
-typedef struct GhosttyOscCommandImpl *GhosttyOscCommand;
-
/** @defgroup osc OSC Parser
*
* OSC (Operating System Command) sequence parser and command handling.
@@ -59,7 +39,7 @@ typedef struct GhosttyOscCommandImpl *GhosttyOscCommand;
*
* @ingroup osc
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_OSC_COMMAND_INVALID = 0,
GHOSTTY_OSC_COMMAND_CHANGE_WINDOW_TITLE = 1,
GHOSTTY_OSC_COMMAND_CHANGE_WINDOW_ICON = 2,
@@ -83,6 +63,7 @@ typedef enum {
GHOSTTY_OSC_COMMAND_CONEMU_XTERM_EMULATION = 20,
GHOSTTY_OSC_COMMAND_CONEMU_COMMENT = 21,
GHOSTTY_OSC_COMMAND_KITTY_TEXT_SIZING = 22,
+ GHOSTTY_OSC_COMMAND_TYPE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyOscCommandType;
/**
@@ -93,7 +74,7 @@ typedef enum {
*
* @ingroup osc
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Invalid data type. Never results in any data extraction. */
GHOSTTY_OSC_DATA_INVALID = 0,
@@ -108,6 +89,7 @@ typedef enum {
* the same parser instance. Memory is owned by the parser.
*/
GHOSTTY_OSC_DATA_CHANGE_WINDOW_TITLE_STR = 1,
+ GHOSTTY_OSC_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyOscCommandData;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/point.h b/vendor/libghostty-vt/include/ghostty/vt/point.h
index f152a5c4..8b717f49 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/point.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/point.h
@@ -42,7 +42,7 @@ typedef struct {
*
* @ingroup point
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Active area where the cursor can move. */
GHOSTTY_POINT_TAG_ACTIVE = 0,
@@ -54,7 +54,8 @@ typedef enum {
/** Scrollback history only (before active area). */
GHOSTTY_POINT_TAG_HISTORY = 3,
-} GhosttyPointTag;
+ GHOSTTY_POINT_TAG_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+ } GhosttyPointTag;
/**
* Point value union.
diff --git a/vendor/libghostty-vt/include/ghostty/vt/render.h b/vendor/libghostty-vt/include/ghostty/vt/render.h
index 163a4e1d..d1a3687d 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/render.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/render.h
@@ -82,32 +82,11 @@ extern "C" {
*/
/**
- * Opaque handle to a render state instance.
- *
- * @ingroup render
- */
-typedef struct GhosttyRenderStateImpl* GhosttyRenderState;
-
-/**
- * Opaque handle to a render-state row iterator.
- *
- * @ingroup render
- */
-typedef struct GhosttyRenderStateRowIteratorImpl* GhosttyRenderStateRowIterator;
-
-/**
- * Opaque handle to render-state row cells.
- *
- * @ingroup render
- */
-typedef struct GhosttyRenderStateRowCellsImpl* GhosttyRenderStateRowCells;
-
-/**
* Dirty state of a render state after update.
*
* @ingroup render
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Not dirty at all; rendering can be skipped. */
GHOSTTY_RENDER_STATE_DIRTY_FALSE = 0,
@@ -116,6 +95,7 @@ typedef enum {
/** Global state changed; renderer should redraw everything. */
GHOSTTY_RENDER_STATE_DIRTY_FULL = 2,
+ GHOSTTY_RENDER_STATE_DIRTY_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRenderStateDirty;
/**
@@ -123,7 +103,7 @@ typedef enum {
*
* @ingroup render
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Bar cursor (DECSCUSR 5, 6). */
GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BAR = 0,
@@ -135,6 +115,7 @@ typedef enum {
/** Hollow block cursor. */
GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BLOCK_HOLLOW = 3,
+ GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRenderStateCursorVisualStyle;
/**
@@ -142,7 +123,7 @@ typedef enum {
*
* @ingroup render
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Invalid / sentinel value. */
GHOSTTY_RENDER_STATE_DATA_INVALID = 0,
@@ -206,6 +187,7 @@ typedef enum {
/** Whether the cursor is on the tail of a wide character (bool).
* Only valid when CURSOR_VIEWPORT_HAS_VALUE is true. */
GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_WIDE_TAIL = 17,
+ GHOSTTY_RENDER_STATE_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRenderStateData;
/**
@@ -213,9 +195,10 @@ typedef enum {
*
* @ingroup render
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Set dirty state (GhosttyRenderStateDirty). */
GHOSTTY_RENDER_STATE_OPTION_DIRTY = 0,
+ GHOSTTY_RENDER_STATE_OPTION_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRenderStateOption;
/**
@@ -223,7 +206,7 @@ typedef enum {
*
* @ingroup render
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Invalid / sentinel value. */
GHOSTTY_RENDER_STATE_ROW_DATA_INVALID = 0,
@@ -238,6 +221,7 @@ typedef enum {
* valid as long as the underlying render state is not updated.
* It is unsafe to use cell data after updating the render state. */
GHOSTTY_RENDER_STATE_ROW_DATA_CELLS = 3,
+ GHOSTTY_RENDER_STATE_ROW_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRenderStateRowData;
/**
@@ -245,9 +229,10 @@ typedef enum {
*
* @ingroup render
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Set dirty state for the current row (bool). */
GHOSTTY_RENDER_STATE_ROW_OPTION_DIRTY = 0,
+ GHOSTTY_RENDER_STATE_ROW_OPTION_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRenderStateRowOption;
/**
@@ -346,8 +331,36 @@ GHOSTTY_API GhosttyResult ghostty_render_state_update(GhosttyRenderState state,
* @ingroup render
*/
GHOSTTY_API GhosttyResult ghostty_render_state_get(GhosttyRenderState state,
- GhosttyRenderStateData data,
- void* out);
+ GhosttyRenderStateData data,
+ void* out);
+
+/**
+ * Get multiple data fields from a render state in a single call.
+ *
+ * Each element in the keys array specifies a data kind, and the
+ * corresponding element in the values array receives the result.
+ *
+ * Processing stops at the first error; on success out_written
+ * is set to count, on error it is set to the index of the
+ * failing key (i.e. the number of values successfully written).
+ *
+ * @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param count Number of key/value pairs
+ * @param keys Array of data kinds to query
+ * @param values Array of output pointers (types must match each key's
+ * documented output type)
+ * @param[out] out_written On return, receives the number of values
+ * successfully written (may be NULL)
+ * @return GHOSTTY_SUCCESS if all queries succeed
+ *
+ * @ingroup render
+ */
+GHOSTTY_API GhosttyResult ghostty_render_state_get_multi(
+ GhosttyRenderState state,
+ size_t count,
+ const GhosttyRenderStateData* keys,
+ void** values,
+ size_t* out_written);
/**
* Set an option on a render state.
@@ -449,6 +462,34 @@ GHOSTTY_API GhosttyResult ghostty_render_state_row_get(
void* out);
/**
+ * Get multiple data fields from the current row in a single call.
+ *
+ * Each element in the keys array specifies a data kind, and the
+ * corresponding element in the values array receives the result.
+ *
+ * Processing stops at the first error; on success out_written
+ * is set to count, on error it is set to the index of the
+ * failing key (i.e. the number of values successfully written).
+ *
+ * @param iterator The iterator handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param count Number of key/value pairs
+ * @param keys Array of data kinds to query
+ * @param values Array of output pointers (types must match each key's
+ * documented output type)
+ * @param[out] out_written On return, receives the number of values
+ * successfully written (may be NULL)
+ * @return GHOSTTY_SUCCESS if all queries succeed
+ *
+ * @ingroup render
+ */
+GHOSTTY_API GhosttyResult ghostty_render_state_row_get_multi(
+ GhosttyRenderStateRowIterator iterator,
+ size_t count,
+ const GhosttyRenderStateRowData* keys,
+ void** values,
+ size_t* out_written);
+
+/**
* Set an option on the current row in a render-state row iterator.
*
* The `value` pointer must point to a value of the type corresponding to the
@@ -496,7 +537,7 @@ GHOSTTY_API GhosttyResult ghostty_render_state_row_cells_new(
*
* @ingroup render
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Invalid / sentinel value. */
GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_INVALID = 0,
@@ -530,6 +571,7 @@ typedef enum {
* color, in which case the caller should use whatever default foreground
* color it wants (e.g. the terminal foreground). */
GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_FG_COLOR = 6,
+ GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRenderStateRowCellsData;
/**
@@ -586,6 +628,34 @@ GHOSTTY_API GhosttyResult ghostty_render_state_row_cells_get(
void* out);
/**
+ * Get multiple data fields from the current cell in a single call.
+ *
+ * Each element in the keys array specifies a data kind, and the
+ * corresponding element in the values array receives the result.
+ *
+ * Processing stops at the first error; on success out_written
+ * is set to count, on error it is set to the index of the
+ * failing key (i.e. the number of values successfully written).
+ *
+ * @param cells The row cells handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param count Number of key/value pairs
+ * @param keys Array of data kinds to query
+ * @param values Array of output pointers (types must match each key's
+ * documented output type)
+ * @param[out] out_written On return, receives the number of values
+ * successfully written (may be NULL)
+ * @return GHOSTTY_SUCCESS if all queries succeed
+ *
+ * @ingroup render
+ */
+GHOSTTY_API GhosttyResult ghostty_render_state_row_cells_get_multi(
+ GhosttyRenderStateRowCells cells,
+ size_t count,
+ const GhosttyRenderStateRowCellsData* keys,
+ void** values,
+ size_t* out_written);
+
+/**
* Free a row cells instance.
*
* @param cells The row cells handle to free (may be NULL)
diff --git a/vendor/libghostty-vt/include/ghostty/vt/screen.h b/vendor/libghostty-vt/include/ghostty/vt/screen.h
index 89b4825f..9f639b58 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/screen.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/screen.h
@@ -57,7 +57,7 @@ typedef uint64_t GhosttyRow;
*
* @ingroup screen
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** A single codepoint (may be zero for empty). */
GHOSTTY_CELL_CONTENT_CODEPOINT = 0,
@@ -69,6 +69,7 @@ typedef enum {
/** No text; background color as RGB. */
GHOSTTY_CELL_CONTENT_BG_COLOR_RGB = 3,
+ GHOSTTY_CELL_CONTENT_TAG_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyCellContentTag;
/**
@@ -78,7 +79,7 @@ typedef enum {
*
* @ingroup screen
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Not a wide character, cell width 1. */
GHOSTTY_CELL_WIDE_NARROW = 0,
@@ -90,6 +91,7 @@ typedef enum {
/** Spacer at end of soft-wrapped line for a wide character. */
GHOSTTY_CELL_WIDE_SPACER_HEAD = 3,
+ GHOSTTY_CELL_WIDE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyCellWide;
/**
@@ -100,7 +102,7 @@ typedef enum {
*
* @ingroup screen
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Regular output content, such as command output. */
GHOSTTY_CELL_SEMANTIC_OUTPUT = 0,
@@ -109,6 +111,7 @@ typedef enum {
/** Content that is part of a shell prompt. */
GHOSTTY_CELL_SEMANTIC_PROMPT = 2,
+ GHOSTTY_CELL_SEMANTIC_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyCellSemanticContent;
/**
@@ -119,7 +122,7 @@ typedef enum {
*
* @ingroup screen
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Invalid data type. Never results in any data extraction. */
GHOSTTY_CELL_DATA_INVALID = 0,
@@ -201,6 +204,7 @@ typedef enum {
* Output type: GhosttyColorRgb *
*/
GHOSTTY_CELL_DATA_COLOR_RGB = 11,
+ GHOSTTY_CELL_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyCellData;
/**
@@ -211,7 +215,7 @@ typedef enum {
*
* @ingroup screen
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** No prompt cells in this row. */
GHOSTTY_ROW_SEMANTIC_NONE = 0,
@@ -220,6 +224,7 @@ typedef enum {
/** Prompt cells exist and this is a continuation line. */
GHOSTTY_ROW_SEMANTIC_PROMPT_CONTINUATION = 2,
+ GHOSTTY_ROW_SEMANTIC_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRowSemanticPrompt;
/**
@@ -230,7 +235,7 @@ typedef enum {
*
* @ingroup screen
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Invalid data type. Never results in any data extraction. */
GHOSTTY_ROW_DATA_INVALID = 0,
@@ -289,6 +294,7 @@ typedef enum {
* Output type: bool *
*/
GHOSTTY_ROW_DATA_DIRTY = 8,
+ GHOSTTY_ROW_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyRowData;
/**
@@ -308,8 +314,35 @@ typedef enum {
* @ingroup screen
*/
GHOSTTY_API GhosttyResult ghostty_cell_get(GhosttyCell cell,
- GhosttyCellData data,
- void *out);
+ GhosttyCellData data,
+ void *out);
+
+/**
+ * Get multiple data fields from a cell in a single call.
+ *
+ * Each element in the keys array specifies a data kind, and the
+ * corresponding element in the values array receives the result.
+ *
+ * Processing stops at the first error; on success out_written
+ * is set to count, on error it is set to the index of the
+ * failing key (i.e. the number of values successfully written).
+ *
+ * @param cell The cell value
+ * @param count Number of key/value pairs
+ * @param keys Array of data kinds to query
+ * @param values Array of output pointers (types must match each key's
+ * documented output type)
+ * @param[out] out_written On return, receives the number of values
+ * successfully written (may be NULL)
+ * @return GHOSTTY_SUCCESS if all queries succeed
+ *
+ * @ingroup screen
+ */
+GHOSTTY_API GhosttyResult ghostty_cell_get_multi(GhosttyCell cell,
+ size_t count,
+ const GhosttyCellData* keys,
+ void** values,
+ size_t* out_written);
/**
* Get data from a row.
@@ -328,8 +361,35 @@ GHOSTTY_API GhosttyResult ghostty_cell_get(GhosttyCell cell,
* @ingroup screen
*/
GHOSTTY_API GhosttyResult ghostty_row_get(GhosttyRow row,
- GhosttyRowData data,
- void *out);
+ GhosttyRowData data,
+ void *out);
+
+/**
+ * Get multiple data fields from a row in a single call.
+ *
+ * Each element in the keys array specifies a data kind, and the
+ * corresponding element in the values array receives the result.
+ *
+ * Processing stops at the first error; on success out_written
+ * is set to count, on error it is set to the index of the
+ * failing key (i.e. the number of values successfully written).
+ *
+ * @param row The row value
+ * @param count Number of key/value pairs
+ * @param keys Array of data kinds to query
+ * @param values Array of output pointers (types must match each key's
+ * documented output type)
+ * @param[out] out_written On return, receives the number of values
+ * successfully written (may be NULL)
+ * @return GHOSTTY_SUCCESS if all queries succeed
+ *
+ * @ingroup screen
+ */
+GHOSTTY_API GhosttyResult ghostty_row_get_multi(GhosttyRow row,
+ size_t count,
+ const GhosttyRowData* keys,
+ void** values,
+ size_t* out_written);
/** @} */
diff --git a/vendor/libghostty-vt/include/ghostty/vt/selection.h b/vendor/libghostty-vt/include/ghostty/vt/selection.h
new file mode 100644
index 00000000..9f878fad
--- /dev/null
+++ b/vendor/libghostty-vt/include/ghostty/vt/selection.h
@@ -0,0 +1,53 @@
+/**
+ * @file selection.h
+ *
+ * Selection range type for specifying a region of terminal content.
+ */
+
+#ifndef GHOSTTY_VT_SELECTION_H
+#define GHOSTTY_VT_SELECTION_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <ghostty/vt/grid_ref.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup selection Selection
+ *
+ * A selection range defined by two grid references that identifies a
+ * contiguous or rectangular region of terminal content.
+ *
+ * @{
+ */
+
+/**
+ * A selection range defined by two grid references.
+ *
+ * This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.
+ *
+ * @ingroup selection
+ */
+typedef struct {
+ /** Size of this struct in bytes. Must be set to sizeof(GhosttySelection). */
+ size_t size;
+
+ /** Start of the selection range (inclusive). */
+ GhosttyGridRef start;
+
+ /** End of the selection range (inclusive). */
+ GhosttyGridRef end;
+
+ /** Whether the selection is rectangular (block) rather than linear. */
+ bool rectangle;
+} GhosttySelection;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GHOSTTY_VT_SELECTION_H */
diff --git a/vendor/libghostty-vt/include/ghostty/vt/sgr.h b/vendor/libghostty-vt/include/ghostty/vt/sgr.h
index 01ea3a35..8eec11dc 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/sgr.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/sgr.h
@@ -48,16 +48,6 @@ extern "C" {
#endif
/**
- * Opaque handle to an SGR parser instance.
- *
- * This handle represents an SGR (Select Graphic Rendition) parser that can
- * be used to parse SGR sequences and extract individual text attributes.
- *
- * @ingroup sgr
- */
-typedef struct GhosttySgrParserImpl* GhosttySgrParser;
-
-/**
* SGR attribute tags.
*
* These values identify the type of an SGR attribute in a tagged union.
@@ -65,7 +55,7 @@ typedef struct GhosttySgrParserImpl* GhosttySgrParser;
*
* @ingroup sgr
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_SGR_ATTR_UNSET = 0,
GHOSTTY_SGR_ATTR_UNKNOWN = 1,
GHOSTTY_SGR_ATTR_BOLD = 2,
@@ -97,6 +87,7 @@ typedef enum {
GHOSTTY_SGR_ATTR_BRIGHT_FG_8 = 28,
GHOSTTY_SGR_ATTR_BG_256 = 29,
GHOSTTY_SGR_ATTR_FG_256 = 30,
+ GHOSTTY_SGR_ATTR_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttySgrAttributeTag;
/**
@@ -104,13 +95,14 @@ typedef enum {
*
* @ingroup sgr
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_SGR_UNDERLINE_NONE = 0,
GHOSTTY_SGR_UNDERLINE_SINGLE = 1,
GHOSTTY_SGR_UNDERLINE_DOUBLE = 2,
GHOSTTY_SGR_UNDERLINE_CURLY = 3,
GHOSTTY_SGR_UNDERLINE_DOTTED = 4,
GHOSTTY_SGR_UNDERLINE_DASHED = 5,
+ GHOSTTY_SGR_UNDERLINE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttySgrUnderline;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/size_report.h b/vendor/libghostty-vt/include/ghostty/vt/size_report.h
index 98c67c5e..da33e5e5 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/size_report.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/size_report.h
@@ -40,7 +40,7 @@ extern "C" {
*
* Determines the output format for the terminal size report.
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** In-band size report (mode 2048): ESC [ 48 ; rows ; cols ; height ; width t */
GHOSTTY_SIZE_REPORT_MODE_2048 = 0,
/** XTWINOPS text area size in pixels: ESC [ 4 ; height ; width t */
@@ -49,6 +49,7 @@ typedef enum {
GHOSTTY_SIZE_REPORT_CSI_16_T = 2,
/** XTWINOPS text area size in characters: ESC [ 8 ; rows ; cols t */
GHOSTTY_SIZE_REPORT_CSI_18_T = 3,
+ GHOSTTY_SIZE_REPORT_STYLE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttySizeReportStyle;
/**
diff --git a/vendor/libghostty-vt/include/ghostty/vt/style.h b/vendor/libghostty-vt/include/ghostty/vt/style.h
index ac049560..b6bf860e 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/style.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/style.h
@@ -46,11 +46,12 @@ typedef uint16_t GhosttyStyleId;
*
* @ingroup style
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
GHOSTTY_STYLE_COLOR_NONE = 0,
GHOSTTY_STYLE_COLOR_PALETTE = 1,
GHOSTTY_STYLE_COLOR_RGB = 2,
-} GhosttyStyleColorTag;
+ GHOSTTY_STYLE_COLOR_TAG_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+ } GhosttyStyleColorTag;
/**
* Style color value union.
diff --git a/vendor/libghostty-vt/include/ghostty/vt/sys.h b/vendor/libghostty-vt/include/ghostty/vt/sys.h
new file mode 100644
index 00000000..ae905969
--- /dev/null
+++ b/vendor/libghostty-vt/include/ghostty/vt/sys.h
@@ -0,0 +1,210 @@
+/**
+ * @file sys.h
+ *
+ * System interface - runtime-swappable implementations for external dependencies.
+ */
+
+#ifndef GHOSTTY_VT_SYS_H
+#define GHOSTTY_VT_SYS_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <ghostty/vt/types.h>
+#include <ghostty/vt/allocator.h>
+
+/** @defgroup sys System Interface
+ *
+ * Runtime-swappable function pointers for operations that depend on
+ * external implementations (e.g. image decoding).
+ *
+ * These are process-global settings that must be configured at startup
+ * before any terminal functionality that depends on them is used.
+ * Setting these enables various optional features of the terminal. For
+ * example, setting a PNG decoder enables PNG image support in the Kitty
+ * Graphics Protocol.
+ *
+ * Use ghostty_sys_set() with a `GhosttySysOption` to install or clear
+ * an implementation. Passing NULL as the value clears the implementation
+ * and disables the corresponding feature.
+ *
+ * ## Example
+ *
+ * ### Defining a PNG decode callback
+ * @snippet c-vt-kitty-graphics/src/main.c kitty-graphics-decode-png
+ *
+ * ### Installing the callback and sending a PNG image
+ * @snippet c-vt-kitty-graphics/src/main.c kitty-graphics-main
+ *
+ * @{
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Result of decoding an image.
+ *
+ * The `data` buffer must be allocated through the allocator provided to
+ * the decode callback. The library takes ownership and will free it
+ * with the same allocator.
+ */
+typedef struct {
+ /** Image width in pixels. */
+ uint32_t width;
+
+ /** Image height in pixels. */
+ uint32_t height;
+
+ /** Pointer to the decoded RGBA pixel data. */
+ uint8_t* data;
+
+ /** Length of the pixel data in bytes. */
+ size_t data_len;
+} GhosttySysImage;
+
+/**
+ * Log severity levels for the log callback.
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ GHOSTTY_SYS_LOG_LEVEL_ERROR = 0,
+ GHOSTTY_SYS_LOG_LEVEL_WARNING = 1,
+ GHOSTTY_SYS_LOG_LEVEL_INFO = 2,
+ GHOSTTY_SYS_LOG_LEVEL_DEBUG = 3,
+ GHOSTTY_SYS_LOG_LEVEL_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttySysLogLevel;
+
+/**
+ * Callback type for logging.
+ *
+ * When installed, internal library log messages are delivered through
+ * this callback instead of being discarded. The embedder is responsible
+ * for formatting and routing log output.
+ *
+ * @p scope is the log scope name as UTF-8 bytes (e.g. "osc", "kitty").
+ * When the log is unscoped (default scope), @p scope_len is 0.
+ *
+ * All pointer arguments are only valid for the duration of the callback.
+ * The callback must be safe to call from any thread.
+ *
+ * @param userdata The userdata pointer set via GHOSTTY_SYS_OPT_USERDATA
+ * @param level The severity level of the log message
+ * @param scope Pointer to the scope name bytes
+ * @param scope_len Length of the scope name in bytes
+ * @param message Pointer to the log message bytes
+ * @param message_len Length of the log message in bytes
+ */
+typedef void (*GhosttySysLogFn)(
+ void* userdata,
+ GhosttySysLogLevel level,
+ const uint8_t* scope,
+ size_t scope_len,
+ const uint8_t* message,
+ size_t message_len);
+
+/**
+ * Callback type for PNG decoding.
+ *
+ * Decodes raw PNG data into RGBA pixels. The output pixel data must be
+ * allocated through the provided allocator. The library takes ownership
+ * of the buffer and will free it with the same allocator.
+ *
+ * @param userdata The userdata pointer set via GHOSTTY_SYS_OPT_USERDATA
+ * @param allocator The allocator to use for the output pixel buffer
+ * @param data Pointer to the raw PNG data
+ * @param data_len Length of the raw PNG data in bytes
+ * @param[out] out On success, filled with the decoded image
+ * @return true on success, false on failure
+ */
+typedef bool (*GhosttySysDecodePngFn)(
+ void* userdata,
+ const GhosttyAllocator* allocator,
+ const uint8_t* data,
+ size_t data_len,
+ GhosttySysImage* out);
+
+/**
+ * System option identifiers for ghostty_sys_set().
+ */
+typedef enum GHOSTTY_ENUM_TYPED {
+ /**
+ * Set the userdata pointer passed to all sys callbacks.
+ *
+ * Input type: void* (or NULL)
+ */
+ GHOSTTY_SYS_OPT_USERDATA = 0,
+
+ /**
+ * Set the PNG decode function.
+ *
+ * When set, the terminal can accept PNG images via the Kitty
+ * Graphics Protocol. When cleared (NULL value), PNG decoding is
+ * unsupported and PNG image data will be rejected.
+ *
+ * Input type: GhosttySysDecodePngFn (function pointer, or NULL)
+ */
+ GHOSTTY_SYS_OPT_DECODE_PNG = 1,
+
+ /**
+ * Set the log callback.
+ *
+ * When set, internal library log messages are delivered to this
+ * callback. When cleared (NULL value), log messages are silently
+ * discarded.
+ *
+ * Use ghostty_sys_log_stderr as a convenience callback that
+ * writes formatted messages to stderr.
+ *
+ * Which log levels are emitted depends on the build mode of the
+ * library and is not configurable at runtime. Debug builds emit
+ * all levels (debug and above). Release builds emit info and
+ * above; debug-level messages are compiled out entirely and will
+ * never reach the callback.
+ *
+ * Input type: GhosttySysLogFn (function pointer, or NULL)
+ */
+ GHOSTTY_SYS_OPT_LOG = 2,
+ GHOSTTY_SYS_OPT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+} GhosttySysOption;
+
+/**
+ * Set a system-level option.
+ *
+ * Configures a process-global implementation function. These should be
+ * set once at startup before using any terminal functionality that
+ * depends on them.
+ *
+ * @param option The option to set
+ * @param value Pointer to the value (type depends on the option),
+ * or NULL to clear it
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the
+ * option is not recognized
+ */
+GHOSTTY_API GhosttyResult ghostty_sys_set(GhosttySysOption option,
+ const void* value);
+
+/**
+ * Built-in log callback that writes to stderr.
+ *
+ * Formats each message as "[level](scope): message\n".
+ * Can be passed directly to ghostty_sys_set():
+ *
+ * @code
+ * ghostty_sys_set(GHOSTTY_SYS_OPT_LOG, &ghostty_sys_log_stderr);
+ * @endcode
+ */
+GHOSTTY_API void ghostty_sys_log_stderr(void* userdata,
+ GhosttySysLogLevel level,
+ const uint8_t* scope,
+ size_t scope_len,
+ const uint8_t* message,
+ size_t message_len);
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+
+#endif /* GHOSTTY_VT_SYS_H */
diff --git a/vendor/libghostty-vt/include/ghostty/vt/terminal.h b/vendor/libghostty-vt/include/ghostty/vt/terminal.h
index b466bd84..0e6d048e 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/terminal.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/terminal.h
@@ -16,6 +16,7 @@
#include <ghostty/vt/modes.h>
#include <ghostty/vt/size_report.h>
#include <ghostty/vt/grid_ref.h>
+#include <ghostty/vt/kitty_graphics.h>
#include <ghostty/vt/screen.h>
#include <ghostty/vt/point.h>
#include <ghostty/vt/style.h>
@@ -155,13 +156,6 @@ extern "C" {
*/
/**
- * Opaque handle to a terminal instance.
- *
- * @ingroup terminal
- */
-typedef struct GhosttyTerminalImpl* GhosttyTerminal;
-
-/**
* Terminal initialization options.
*
* @ingroup terminal
@@ -186,7 +180,7 @@ typedef struct {
*
* @ingroup terminal
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Scroll to the top of the scrollback. */
GHOSTTY_SCROLL_VIEWPORT_TOP,
@@ -195,6 +189,7 @@ typedef enum {
/** Scroll by a delta amount (up is negative). */
GHOSTTY_SCROLL_VIEWPORT_DELTA,
+ GHOSTTY_SCROLL_VIEWPORT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyTerminalScrollViewportTag;
/**
@@ -227,12 +222,13 @@ typedef struct {
*
* @ingroup terminal
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** The primary (normal) screen. */
GHOSTTY_TERMINAL_SCREEN_PRIMARY = 0,
/** The alternate screen. */
GHOSTTY_TERMINAL_SCREEN_ALTERNATE = 1,
+ GHOSTTY_TERMINAL_SCREEN_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyTerminalScreen;
/**
@@ -254,26 +250,6 @@ typedef struct {
} GhosttyTerminalScrollbar;
/**
- * Selection bounds for terminal text extraction.
- *
- * The start and end points may be in any supported point coordinate system
- * (active, viewport, screen, or history). Text is always returned in reading
- * order. Set `rectangle` to true for rectangular selection semantics.
- *
- * @ingroup terminal
- */
-typedef struct {
- /** Selection start point. */
- GhosttyPoint start;
-
- /** Selection end point. */
- GhosttyPoint end;
-
- /** Whether to treat the selection as a rectangle. */
- bool rectangle;
-} GhosttyTerminalSelection;
-
-/**
* Callback function type for bell.
*
* Called when the terminal receives a BEL character (0x07).
@@ -420,7 +396,7 @@ typedef GhosttyString (*GhosttyTerminalXtversionFn)(GhosttyTerminal terminal,
*
* @ingroup terminal
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/**
* Opaque userdata pointer passed to all callbacks.
*
@@ -554,6 +530,69 @@ typedef enum {
* Input type: GhosttyColorRgb[256]*
*/
GHOSTTY_TERMINAL_OPT_COLOR_PALETTE = 14,
+
+ /**
+ * Set the Kitty image storage limit in bytes.
+ *
+ * Applied to all initialized screens (primary and alternate).
+ * A value of zero disables the Kitty graphics protocol entirely,
+ * deleting all stored images and placements. A NULL value pointer
+ * is equivalent to zero (disables). Has no effect when Kitty graphics
+ * are disabled at build time.
+ *
+ * Input type: uint64_t*
+ */
+ GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_STORAGE_LIMIT = 15,
+
+ /**
+ * Enable or disable Kitty image loading via the file medium.
+ *
+ * A NULL value pointer is a no-op. Has no effect when Kitty graphics
+ * are disabled at build time.
+ *
+ * Input type: bool*
+ */
+ GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_FILE = 16,
+
+ /**
+ * Enable or disable Kitty image loading via the temporary file medium.
+ *
+ * A NULL value pointer is a no-op. Has no effect when Kitty graphics
+ * are disabled at build time.
+ *
+ * Input type: bool*
+ */
+ GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_TEMP_FILE = 17,
+
+ /**
+ * Enable or disable Kitty image loading via the shared memory medium.
+ *
+ * A NULL value pointer is a no-op. Has no effect when Kitty graphics
+ * are disabled at build time.
+ *
+ * Input type: bool*
+ */
+ GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_SHARED_MEM = 18,
+
+ /**
+ * Set the maximum bytes the APC handler will buffer for all protocols.
+ * This prevents malicious input from causing unbounded memory allocation.
+ * A NULL value pointer removes all overrides, reverting to the built-in
+ * defaults.
+ *
+ * Input type: size_t*
+ */
+ GHOSTTY_TERMINAL_OPT_APC_MAX_BYTES = 19,
+
+ /**
+ * Set the maximum bytes the APC handler will buffer for Kitty graphics
+ * protocol data. A NULL value pointer removes the override, reverting
+ * to the built-in default.
+ *
+ * Input type: size_t*
+ */
+ GHOSTTY_TERMINAL_OPT_APC_MAX_BYTES_KITTY = 20,
+ GHOSTTY_TERMINAL_OPT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyTerminalOption;
/**
@@ -564,7 +603,7 @@ typedef enum {
*
* @ingroup terminal
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Invalid data type. Never results in any data extraction. */
GHOSTTY_TERMINAL_DATA_INVALID = 0,
@@ -776,6 +815,60 @@ typedef enum {
* Output type: GhosttyColorRgb[256] *
*/
GHOSTTY_TERMINAL_DATA_COLOR_PALETTE_DEFAULT = 25,
+
+ /**
+ * The Kitty image storage limit in bytes for the active screen.
+ *
+ * A value of zero means the Kitty graphics protocol is disabled.
+ * Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.
+ *
+ * Output type: uint64_t *
+ */
+ GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_STORAGE_LIMIT = 26,
+
+ /**
+ * Whether the file medium is enabled for Kitty image loading on the
+ * active screen.
+ *
+ * Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.
+ *
+ * Output type: bool *
+ */
+ GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_FILE = 27,
+
+ /**
+ * Whether the temporary file medium is enabled for Kitty image loading
+ * on the active screen.
+ *
+ * Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.
+ *
+ * Output type: bool *
+ */
+ GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_TEMP_FILE = 28,
+
+ /**
+ * Whether the shared memory medium is enabled for Kitty image loading
+ * on the active screen.
+ *
+ * Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.
+ *
+ * Output type: bool *
+ */
+ GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_SHARED_MEM = 29,
+
+ /**
+ * The Kitty graphics image storage for the active screen.
+ *
+ * Returns a borrowed pointer to the image storage. The pointer is valid
+ * until the next mutating terminal call (e.g. ghostty_terminal_vt_write()
+ * or ghostty_terminal_reset()).
+ *
+ * Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.
+ *
+ * Output type: GhosttyKittyGraphics *
+ */
+ GHOSTTY_TERMINAL_DATA_KITTY_GRAPHICS = 30,
+ GHOSTTY_TERMINAL_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyTerminalData;
/**
@@ -965,6 +1058,39 @@ GHOSTTY_API GhosttyResult ghostty_terminal_get(GhosttyTerminal terminal,
void *out);
/**
+ * Get multiple data fields from a terminal in a single call.
+ *
+ * This is an optimization over calling ghostty_terminal_get()
+ * repeatedly, particularly useful in environments with high per-call
+ * overhead such as FFI or Cgo.
+ *
+ * Each element in the keys array specifies a data kind, and the
+ * corresponding element in the values array receives the result.
+ * The type of each values[i] pointer must match the output type
+ * documented for keys[i].
+ *
+ * Processing stops at the first error; on success out_written
+ * is set to count, on error it is set to the index of the
+ * failing key (i.e. the number of values successfully written).
+ *
+ * @param terminal The terminal handle (may be NULL)
+ * @param count Number of key/value pairs
+ * @param keys Array of data kinds to query
+ * @param values Array of output pointers (types must match each key's
+ * documented output type)
+ * @param[out] out_written On return, receives the number of values
+ * successfully written (may be NULL)
+ * @return GHOSTTY_SUCCESS if all queries succeed
+ *
+ * @ingroup terminal
+ */
+GHOSTTY_API GhosttyResult ghostty_terminal_get_multi(GhosttyTerminal terminal,
+ size_t count,
+ const GhosttyTerminalData* keys,
+ void** values,
+ size_t* out_written);
+
+/**
* Resolve a point in the terminal grid to a grid reference.
*
* Resolves the given point (which can be in active, viewport, screen,
@@ -995,32 +1121,37 @@ GHOSTTY_API GhosttyResult ghostty_terminal_grid_ref(GhosttyTerminal terminal,
GhosttyGridRef *out_ref);
/**
- * Read terminal text for an arbitrary selection.
+ * Convert a grid reference back to a point in the given coordinate system.
*
- * Formats the selected region as plain text using Ghostty's native selection
- * semantics. Soft-wrapped lines are unwrapped and trailing whitespace is
- * trimmed on non-blank lines.
+ * This is the inverse of ghostty_terminal_grid_ref(): given a grid reference,
+ * it returns the x/y coordinates in the requested coordinate system (active,
+ * viewport, screen, or history).
*
- * The returned buffer is allocated using the provided allocator, or the
- * default allocator if NULL is passed. Free it with ghostty_free(), passing
- * the same allocator pointer and returned length.
+ * The grid reference must have been obtained from the same terminal instance.
+ * Like all grid references, it is only valid until the next mutating terminal
+ * call.
+ *
+ * Not every grid reference is representable in every coordinate system. For
+ * example, a cell in scrollback history cannot be expressed in active
+ * coordinates, and a cell that has scrolled off the visible area cannot be
+ * expressed in viewport coordinates. In these cases, the function returns
+ * GHOSTTY_NO_VALUE.
*
* @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)
- * @param selection The selection bounds to read
- * @param allocator Pointer to allocator, or NULL to use the default allocator
- * @param[out] out_ptr On success, set to the allocated output buffer
- * @param[out] out_len On success, set to the output length in bytes
+ * @param ref Pointer to the grid reference to convert
+ * @param tag The target coordinate system
+ * @param[out] out On success, set to the coordinate in the requested system (may be NULL)
* @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal
- * is NULL or the selection points are out of bounds,
- * GHOSTTY_OUT_OF_MEMORY on allocation failure
+ * or ref is NULL/invalid, GHOSTTY_NO_VALUE if the ref falls outside
+ * the requested coordinate system
*
* @ingroup terminal
*/
-GHOSTTY_API GhosttyResult ghostty_terminal_read_text(GhosttyTerminal terminal,
- GhosttyTerminalSelection selection,
- const GhosttyAllocator* allocator,
- uint8_t** out_ptr,
- size_t* out_len);
+GHOSTTY_API GhosttyResult ghostty_terminal_point_from_grid_ref(
+ GhosttyTerminal terminal,
+ const GhosttyGridRef *ref,
+ GhosttyPointTag tag,
+ GhosttyPointCoordinate *out);
/** @} */
diff --git a/vendor/libghostty-vt/include/ghostty/vt/types.h b/vendor/libghostty-vt/include/ghostty/vt/types.h
index 8f0be776..e0be0b77 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/types.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/types.h
@@ -7,6 +7,7 @@
#ifndef GHOSTTY_VT_TYPES_H
#define GHOSTTY_VT_TYPES_H
+#include <limits.h>
#include <stddef.h>
#include <stdint.h>
@@ -33,9 +34,44 @@
#endif
/**
+ * Enum int-sizing helpers.
+ *
+ * The Zig side backs all C enums with c_int, so the C declarations
+ * must use int as their underlying type to maintain ABI compatibility.
+ *
+ * C23 (detected via __STDC_VERSION__ >= 202311L) supports explicit
+ * enum underlying types with `enum : int { ... }`. For pre-C23
+ * compilers, which are free to choose any type that can represent
+ * all values (C11 §6.7.2.2), we add an INT_MAX sentinel as the last
+ * entry to force the compiler to use int.
+ *
+ * INT_MAX is used rather than a fixed constant like 0xFFFFFFFF
+ * because enum constants must have type int (which is signed).
+ * Values above INT_MAX overflow signed int and are a constraint
+ * violation in standard C; compilers that accept them interpret them
+ * as negative values via two's complement, which can collide with
+ * legitimate negative enum values.
+ *
+ * Usage:
+ * @code
+ * typedef enum GHOSTTY_ENUM_TYPED {
+ * FOO_A = 0,
+ * FOO_B = 1,
+ * FOO_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
+ * } Foo;
+ * @endcode
+ */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+#define GHOSTTY_ENUM_TYPED : int
+#else
+#define GHOSTTY_ENUM_TYPED
+#endif
+#define GHOSTTY_ENUM_MAX_VALUE INT_MAX
+
+/**
* Result codes for libghostty-vt operations.
*/
-typedef enum {
+typedef enum GHOSTTY_ENUM_TYPED {
/** Operation completed successfully */
GHOSTTY_SUCCESS = 0,
/** Operation failed due to failed allocation */
@@ -46,8 +82,108 @@ typedef enum {
GHOSTTY_OUT_OF_SPACE = -3,
/** The requested value has no value */
GHOSTTY_NO_VALUE = -4,
+ GHOSTTY_RESULT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
} GhosttyResult;
+/* ---- Opaque handles ---- */
+
+/**
+ * Opaque handle to a terminal instance.
+ *
+ * @ingroup terminal
+ */
+typedef struct GhosttyTerminalImpl* GhosttyTerminal;
+
+/**
+ * Opaque handle to a Kitty graphics image storage.
+ *
+ * Obtained via ghostty_terminal_get() with
+ * GHOSTTY_TERMINAL_DATA_KITTY_GRAPHICS. The pointer is borrowed from
+ * the terminal and remains valid until the next mutating terminal call
+ * (e.g. ghostty_terminal_vt_write() or ghostty_terminal_reset()).
+ *
+ * @ingroup kitty_graphics
+ */
+typedef struct GhosttyKittyGraphicsImpl* GhosttyKittyGraphics;
+
+/**
+ * Opaque handle to a Kitty graphics image.
+ *
+ * Obtained via ghostty_kitty_graphics_image() with an image ID. The
+ * pointer is borrowed from the storage and remains valid until the next
+ * mutating terminal call.
+ *
+ * @ingroup kitty_graphics
+ */
+typedef const struct GhosttyKittyGraphicsImageImpl* GhosttyKittyGraphicsImage;
+
+/**
+ * Opaque handle to a Kitty graphics placement iterator.
+ *
+ * @ingroup kitty_graphics
+ */
+typedef struct GhosttyKittyGraphicsPlacementIteratorImpl* GhosttyKittyGraphicsPlacementIterator;
+
+/**
+ * Opaque handle to a render state instance.
+ *
+ * @ingroup render
+ */
+typedef struct GhosttyRenderStateImpl* GhosttyRenderState;
+
+/**
+ * Opaque handle to a render-state row iterator.
+ *
+ * @ingroup render
+ */
+typedef struct GhosttyRenderStateRowIteratorImpl* GhosttyRenderStateRowIterator;
+
+/**
+ * Opaque handle to render-state row cells.
+ *
+ * @ingroup render
+ */
+typedef struct GhosttyRenderStateRowCellsImpl* GhosttyRenderStateRowCells;
+
+/**
+ * Opaque handle to an SGR parser instance.
+ *
+ * This handle represents an SGR (Select Graphic Rendition) parser that can
+ * be used to parse SGR sequences and extract individual text attributes.
+ *
+ * @ingroup sgr
+ */
+typedef struct GhosttySgrParserImpl* GhosttySgrParser;
+
+/**
+ * Opaque handle to a formatter instance.
+ *
+ * @ingroup formatter
+ */
+typedef struct GhosttyFormatterImpl* GhosttyFormatter;
+
+/**
+ * Opaque handle to an OSC parser instance.
+ *
+ * This handle represents an OSC (Operating System Command) parser that can
+ * be used to parse the contents of OSC sequences.
+ *
+ * @ingroup osc
+ */
+typedef struct GhosttyOscParserImpl* GhosttyOscParser;
+
+/**
+ * Opaque handle to a single OSC command.
+ *
+ * This handle represents a parsed OSC (Operating System Command) command.
+ * The command can be queried for its type and associated data.
+ *
+ * @ingroup osc
+ */
+typedef struct GhosttyOscCommandImpl* GhosttyOscCommand;
+
+/* ---- Common value types ---- */
+
/**
* A borrowed byte string (pointer + length).
*