/* automatically generated by rust-bindgen 0.72.1 */
// Generated from Ghostty 8fc5815978aa198ddefcea3ca8c199220cb02805.
pub const GHOSTTY_COLOR_NAMED_BLACK: u32 = 0;
pub const GHOSTTY_COLOR_NAMED_RED: u32 = 1;
pub const GHOSTTY_COLOR_NAMED_GREEN: u32 = 2;
pub const GHOSTTY_COLOR_NAMED_YELLOW: u32 = 3;
pub const GHOSTTY_COLOR_NAMED_BLUE: u32 = 4;
pub const GHOSTTY_COLOR_NAMED_MAGENTA: u32 = 5;
pub const GHOSTTY_COLOR_NAMED_CYAN: u32 = 6;
pub const GHOSTTY_COLOR_NAMED_WHITE: u32 = 7;
pub const GHOSTTY_COLOR_NAMED_BRIGHT_BLACK: u32 = 8;
pub const GHOSTTY_COLOR_NAMED_BRIGHT_RED: u32 = 9;
pub const GHOSTTY_COLOR_NAMED_BRIGHT_GREEN: u32 = 10;
pub const GHOSTTY_COLOR_NAMED_BRIGHT_YELLOW: u32 = 11;
pub const GHOSTTY_COLOR_NAMED_BRIGHT_BLUE: u32 = 12;
pub const GHOSTTY_COLOR_NAMED_BRIGHT_MAGENTA: u32 = 13;
pub const GHOSTTY_COLOR_NAMED_BRIGHT_CYAN: u32 = 14;
pub const GHOSTTY_COLOR_NAMED_BRIGHT_WHITE: u32 = 15;
pub const GHOSTTY_DA_CONFORMANCE_VT100: u32 = 1;
pub const GHOSTTY_DA_CONFORMANCE_VT101: u32 = 1;
pub const GHOSTTY_DA_CONFORMANCE_VT102: u32 = 6;
pub const GHOSTTY_DA_CONFORMANCE_VT125: u32 = 12;
pub const GHOSTTY_DA_CONFORMANCE_VT131: u32 = 7;
pub const GHOSTTY_DA_CONFORMANCE_VT132: u32 = 4;
pub const GHOSTTY_DA_CONFORMANCE_VT220: u32 = 62;
pub const GHOSTTY_DA_CONFORMANCE_VT240: u32 = 62;
pub const GHOSTTY_DA_CONFORMANCE_VT320: u32 = 63;
pub const GHOSTTY_DA_CONFORMANCE_VT340: u32 = 63;
pub const GHOSTTY_DA_CONFORMANCE_VT420: u32 = 64;
pub const GHOSTTY_DA_CONFORMANCE_VT510: u32 = 65;
pub const GHOSTTY_DA_CONFORMANCE_VT520: u32 = 65;
pub const GHOSTTY_DA_CONFORMANCE_VT525: u32 = 65;
pub const GHOSTTY_DA_CONFORMANCE_LEVEL_2: u32 = 62;
pub const GHOSTTY_DA_CONFORMANCE_LEVEL_3: u32 = 63;
pub const GHOSTTY_DA_CONFORMANCE_LEVEL_4: u32 = 64;
pub const GHOSTTY_DA_CONFORMANCE_LEVEL_5: u32 = 65;
pub const GHOSTTY_DA_FEATURE_COLUMNS_132: u32 = 1;
pub const GHOSTTY_DA_FEATURE_PRINTER: u32 = 2;
pub const GHOSTTY_DA_FEATURE_REGIS: u32 = 3;
pub const GHOSTTY_DA_FEATURE_SIXEL: u32 = 4;
pub const GHOSTTY_DA_FEATURE_SELECTIVE_ERASE: u32 = 6;
pub const GHOSTTY_DA_FEATURE_USER_DEFINED_KEYS: u32 = 8;
pub const GHOSTTY_DA_FEATURE_NATIONAL_REPLACEMENT: u32 = 9;
pub const GHOSTTY_DA_FEATURE_TECHNICAL_CHARACTERS: u32 = 15;
pub const GHOSTTY_DA_FEATURE_LOCATOR: u32 = 16;
pub const GHOSTTY_DA_FEATURE_TERMINAL_STATE: u32 = 17;
pub const GHOSTTY_DA_FEATURE_WINDOWING: u32 = 18;
pub const GHOSTTY_DA_FEATURE_HORIZONTAL_SCROLLING: u32 = 21;
pub const GHOSTTY_DA_FEATURE_ANSI_COLOR: u32 = 22;
pub const GHOSTTY_DA_FEATURE_RECTANGULAR_EDITING: u32 = 28;
pub const GHOSTTY_DA_FEATURE_ANSI_TEXT_LOCATOR: u32 = 29;
pub const GHOSTTY_DA_FEATURE_CLIPBOARD: u32 = 52;
pub const GHOSTTY_DA_DEVICE_TYPE_VT100: u32 = 0;
pub const GHOSTTY_DA_DEVICE_TYPE_VT220: u32 = 1;
pub const GHOSTTY_DA_DEVICE_TYPE_VT240: u32 = 2;
pub const GHOSTTY_DA_DEVICE_TYPE_VT330: u32 = 18;
pub const GHOSTTY_DA_DEVICE_TYPE_VT340: u32 = 19;
pub const GHOSTTY_DA_DEVICE_TYPE_VT320: u32 = 24;
pub const GHOSTTY_DA_DEVICE_TYPE_VT382: u32 = 32;
pub const GHOSTTY_DA_DEVICE_TYPE_VT420: u32 = 41;
pub const GHOSTTY_DA_DEVICE_TYPE_VT510: u32 = 61;
pub const GHOSTTY_DA_DEVICE_TYPE_VT520: u32 = 64;
pub const GHOSTTY_DA_DEVICE_TYPE_VT525: u32 = 65;
pub const GHOSTTY_MODS_SHIFT: u32 = 1;
pub const GHOSTTY_MODS_CTRL: u32 = 2;
pub const GHOSTTY_MODS_ALT: u32 = 4;
pub const GHOSTTY_MODS_SUPER: u32 = 8;
pub const GHOSTTY_MODS_CAPS_LOCK: u32 = 16;
pub const GHOSTTY_MODS_NUM_LOCK: u32 = 32;
pub const GHOSTTY_MODS_SHIFT_SIDE: u32 = 64;
pub const GHOSTTY_MODS_CTRL_SIDE: u32 = 128;
pub const GHOSTTY_MODS_ALT_SIDE: u32 = 256;
pub const GHOSTTY_MODS_SUPER_SIDE: u32 = 512;
pub const GHOSTTY_KITTY_KEY_DISABLED: u32 = 0;
pub const GHOSTTY_KITTY_KEY_DISAMBIGUATE: u32 = 1;
pub const GHOSTTY_KITTY_KEY_REPORT_EVENTS: u32 = 2;
pub const GHOSTTY_KITTY_KEY_REPORT_ALTERNATES: u32 = 4;
pub const GHOSTTY_KITTY_KEY_REPORT_ALL: u32 = 8;
pub const GHOSTTY_KITTY_KEY_REPORT_ASSOCIATED: u32 = 16;
pub const GHOSTTY_KITTY_KEY_ALL: u32 = 31;
pub mod GhosttyResult {
#[doc = " Result codes for libghostty-vt operations."]
pub type Type = ::std::os::raw::c_int;
#[doc = " Operation completed successfully"]
pub const GHOSTTY_SUCCESS: Type = 0;
#[doc = " Operation failed due to failed allocation"]
pub const GHOSTTY_OUT_OF_MEMORY: Type = -1;
#[doc = " Operation failed due to invalid value"]
pub const GHOSTTY_INVALID_VALUE: Type = -2;
#[doc = " Operation failed because the provided buffer was too small"]
pub const GHOSTTY_OUT_OF_SPACE: Type = -3;
#[doc = " The requested value has no value"]
pub const GHOSTTY_NO_VALUE: Type = -4;
#[doc = " Operation failed while reading from or writing to external I/O"]
pub const GHOSTTY_IO_ERROR: Type = -5;
#[doc = " Operation failed because encoded input exceeded a configured limit"]
pub const GHOSTTY_LIMIT_EXCEEDED: Type = -6;
#[doc = " Operation was rejected by a safety check (e.g. pasted text that could\n inject commands). Nothing was done. Confirm with the user and retry\n with the operation's allow flag set."]
pub const GHOSTTY_REJECTED: Type = -7;
#[doc = " Operation was rejected by a safety check (e.g. pasted text that could\n inject commands). Nothing was done. Confirm with the user and retry\n with the operation's allow flag set."]
pub const GHOSTTY_RESULT_MAX_VALUE: Type = 2147483647;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a terminal instance.\n\n @ingroup terminal"]
pub type GhosttyTerminal = *mut GhosttyTerminalImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySnapshotDecoderImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to an incremental terminal snapshot decoder.\n\n @ingroup snapshot"]
pub type GhosttySnapshotDecoder = *mut GhosttySnapshotDecoderImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTrackedGridRefImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a tracked grid reference.\n\n A tracked grid reference is owned by the caller and must be freed with\n ghostty_tracked_grid_ref_free(). If the terminal that created it is freed\n first, the handle remains valid only for tracked-grid-ref APIs: it reports no\n value and can still be freed.\n\n @ingroup grid_ref"]
pub type GhosttyTrackedGridRef = *mut GhosttyTrackedGridRefImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyKittyGraphicsImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a Kitty graphics image storage.\n\n Obtained via ghostty_terminal_get() with\n GHOSTTY_TERMINAL_DATA_KITTY_GRAPHICS. The pointer is borrowed from\n the terminal and remains valid until the next mutating terminal call\n (e.g. ghostty_terminal_vt_write() or ghostty_terminal_reset()).\n\n @ingroup kitty_graphics"]
pub type GhosttyKittyGraphics = *mut GhosttyKittyGraphicsImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyKittyGraphicsImageImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a Kitty graphics image.\n\n Obtained via ghostty_kitty_graphics_image() with an image ID. The\n pointer is borrowed from the storage and remains valid until the next\n mutating terminal call.\n\n @ingroup kitty_graphics"]
pub type GhosttyKittyGraphicsImage = *const GhosttyKittyGraphicsImageImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyKittyGraphicsPlacementIteratorImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a Kitty graphics placement iterator.\n\n @ingroup kitty_graphics"]
pub type GhosttyKittyGraphicsPlacementIterator = *mut GhosttyKittyGraphicsPlacementIteratorImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyRenderStateImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a render state instance.\n\n @ingroup render"]
pub type GhosttyRenderState = *mut GhosttyRenderStateImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyRenderStateRowIteratorImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a render-state row iterator.\n\n @ingroup render"]
pub type GhosttyRenderStateRowIterator = *mut GhosttyRenderStateRowIteratorImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyRenderStateRowCellsImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to render-state row cells.\n\n @ingroup render"]
pub type GhosttyRenderStateRowCells = *mut GhosttyRenderStateRowCellsImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySearchImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a terminal search.\n\n A search is bound to the terminal it was created with. It borrows the\n terminal, so it never frees it, and the search must be freed with\n ghostty_search_free(). If the terminal is freed first, the search\n detects this: calls that need the terminal fail cleanly and the\n search can still be freed.\n\n @ingroup search"]
pub type GhosttySearch = *mut GhosttySearchImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySgrParserImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to an SGR parser instance.\n\n This handle represents an SGR (Select Graphic Rendition) parser that can\n be used to parse SGR sequences and extract individual text attributes.\n\n @ingroup sgr"]
pub type GhosttySgrParser = *mut GhosttySgrParserImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyFormatterImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a formatter instance.\n\n @ingroup formatter"]
pub type GhosttyFormatter = *mut GhosttyFormatterImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyOscParserImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to an OSC parser instance.\n\n This handle represents an OSC (Operating System Command) parser that can\n be used to parse the contents of OSC sequences.\n\n @ingroup osc"]
pub type GhosttyOscParser = *mut GhosttyOscParserImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyOscCommandImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a single OSC command.\n\n This handle represents a parsed OSC (Operating System Command) command.\n The command can be queried for its type and associated data.\n\n @ingroup osc"]
pub type GhosttyOscCommand = *mut GhosttyOscCommandImpl;
pub mod GhosttyFormatterFormat {
#[doc = " Terminal content output format.\n\n @ingroup formatter"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Plain text (no escape sequences)."]
pub const GHOSTTY_FORMATTER_FORMAT_PLAIN: Type = 0;
#[doc = " VT sequences preserving colors, styles, URLs, etc."]
pub const GHOSTTY_FORMATTER_FORMAT_VT: Type = 1;
#[doc = " HTML with inline styles."]
pub const GHOSTTY_FORMATTER_FORMAT_HTML: Type = 2;
#[doc = " HTML with inline styles."]
pub const GHOSTTY_FORMATTER_FORMAT_MAX_VALUE: Type = 2147483647;
}
#[doc = " A borrowed byte string (pointer + length).\n\n The memory is not owned by this struct. The pointer is only valid\n for the lifetime documented by the API that produces or consumes it.\n Empty strings produced by the library have a non-NULL pointer to valid\n storage."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyString {
#[doc = " Pointer to the string bytes."]
pub ptr: *const u8,
#[doc = " Length of the string in bytes."]
pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyString"][::std::mem::size_of::<GhosttyString>() - 16usize];
["Alignment of GhosttyString"][::std::mem::align_of::<GhosttyString>() - 8usize];
["Offset of field: GhosttyString::ptr"][::std::mem::offset_of!(GhosttyString, ptr) - 0usize];
["Offset of field: GhosttyString::len"][::std::mem::offset_of!(GhosttyString, len) - 8usize];
};
impl Default for GhosttyString {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " A caller-provided byte buffer.\n\n APIs that write to this type use `len` for the number of bytes written on\n GHOSTTY_SUCCESS and the required byte capacity on GHOSTTY_OUT_OF_SPACE."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyBuffer {
#[doc = " Destination buffer for bytes. May be NULL when cap is 0 to query required size."]
pub ptr: *mut u8,
#[doc = " Capacity of ptr in bytes."]
pub cap: usize,
#[doc = " Bytes written on success, or required byte capacity on GHOSTTY_OUT_OF_SPACE."]
pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyBuffer"][::std::mem::size_of::<GhosttyBuffer>() - 24usize];
["Alignment of GhosttyBuffer"][::std::mem::align_of::<GhosttyBuffer>() - 8usize];
["Offset of field: GhosttyBuffer::ptr"][::std::mem::offset_of!(GhosttyBuffer, ptr) - 0usize];
["Offset of field: GhosttyBuffer::cap"][::std::mem::offset_of!(GhosttyBuffer, cap) - 8usize];
["Offset of field: GhosttyBuffer::len"][::std::mem::offset_of!(GhosttyBuffer, len) - 16usize];
};
impl Default for GhosttyBuffer {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " A surface-space position in pixels.\n\n This is not a terminal grid coordinate. It represents an x/y position in the\n rendered surface coordinate space, with (0, 0) at the top-left of the\n surface."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttySurfacePosition {
#[doc = " X position in surface pixels."]
pub x: f64,
#[doc = " Y position in surface pixels."]
pub y: f64,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySurfacePosition"][::std::mem::size_of::<GhosttySurfacePosition>() - 16usize];
["Alignment of GhosttySurfacePosition"]
[::std::mem::align_of::<GhosttySurfacePosition>() - 8usize];
["Offset of field: GhosttySurfacePosition::x"]
[::std::mem::offset_of!(GhosttySurfacePosition, x) - 0usize];
["Offset of field: GhosttySurfacePosition::y"]
[::std::mem::offset_of!(GhosttySurfacePosition, y) - 8usize];
};
#[doc = " A borrowed list of Unicode scalar values.\n\n Values are encoded as uint32_t scalar values. The memory is not owned by this\n struct. The pointer is only valid for the lifetime documented by the API that\n consumes or produces it.\n\n APIs may document special handling for NULL + len 0, such as “use defaults”."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyCodepoints {
#[doc = " Pointer to Unicode scalar values."]
pub ptr: *const u32,
#[doc = " Number of entries in ptr."]
pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyCodepoints"][::std::mem::size_of::<GhosttyCodepoints>() - 16usize];
["Alignment of GhosttyCodepoints"][::std::mem::align_of::<GhosttyCodepoints>() - 8usize];
["Offset of field: GhosttyCodepoints::ptr"]
[::std::mem::offset_of!(GhosttyCodepoints, ptr) - 0usize];
["Offset of field: GhosttyCodepoints::len"]
[::std::mem::offset_of!(GhosttyCodepoints, len) - 8usize];
};
impl Default for GhosttyCodepoints {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Return the versioned libghostty-vt C type manifest for the current target.\n\n The manifest defines all the public types available in the linked\n build. The types contain their layouts, enum values, union fields, and more.\n\n Language bindings, such as WebAssembly hosts, should obtain offsets,\n sizes, alignments, array shapes, enum constants, and tagged-union arms from\n this manifest rather than hardcoding them. Consumers should reject unknown\n schema versions and verify the descriptors they require at initialization.\n\n Packed type descriptors define fields using `lsb` and `width`. `lsb` is\n relative to bit zero of the containing numerical value; for nested packed\n layouts it is relative to the immediate containing field. Tagged packed\n unions select an inline arm layout using the named tag field. These layouts\n describe the current linked build and are not a cross-version stability\n promise.\n\n The formal format is defined by the\n <a href=\"types.schema.json\">libghostty-vt ABI manifest JSON Schema</a>.\n\n Example (abbreviated):\n @code{.json}\n {\n \"schema\": 1,\n \"abi\": {\n \"target\": \"wasm32\", \"os\": \"freestanding\", \"environment\": \"none\",\n \"pointer_size\": 4, \"usize_size\": 4, \"max_alignment\": 16,\n \"endian\": \"little\"\n },\n \"types\": {\n \"GhosttyRenderStateData\": {\n \"kind\": \"enum\", \"size\": 4, \"align\": 4,\n \"underlying\": \"i32\", \"prefix\": \"GHOSTTY_RENDER_STATE_DATA_\",\n \"values\": { \"INVALID\": 0, \"DIRTY\": 3, \"MAX_VALUE\": 2147483647 }\n },\n \"GhosttyStyleColor\": {\n \"kind\": \"struct\", \"size\": 16, \"align\": 8,\n \"fields\": {\n \"tag\": { \"offset\": 0, \"size\": 4,\n \"type\": \"GhosttyStyleColorTag\" },\n \"value\": { \"offset\": 8, \"size\": 8,\n \"type\": \"GhosttyStyleColorValue\", \"tag\": \"tag\",\n \"arms\": { \"NONE\": null, \"PALETTE\": \"palette\",\n \"RGB\": \"rgb\" } }\n }\n }\n }\n }\n @endcode\n\n The returned pointer is valid for the lifetime of the process.\n\n @return Pointer to the null-terminated JSON string."]
pub fn ghostty_type_json() -> *const ::std::os::raw::c_char;
}
#[doc = " Function table for custom memory allocator operations.\n\n This vtable defines the interface for a custom memory allocator. All\n function pointers must be valid and non-NULL.\n\n @ingroup allocator\n\n If you're not going to use a custom allocator, you can ignore all of\n this. All functions that take an allocator pointer allow NULL to use a\n default allocator. Native freestanding builds must provide an allocator\n for operations that allocate memory.\n\n The interface is based on the Zig allocator interface. I'll say up front\n that it is easy to look at this interface and think \"wow, this is really\n overcomplicated\". The reason for this complexity is well thought out by\n the Zig folks, and it enables a diverse set of allocation strategies\n as shown by the Zig ecosystem. As a consolation, please note that many\n of the arguments are only needed for advanced use cases and can be\n safely ignored in simple implementations. For example, if you look at\n the Zig implementation of the libc allocator in `lib/std/heap.zig`\n (search for CAllocator), you'll see it is very simple.\n\n We chose to align with the Zig allocator interface because:\n\n 1. It is a proven interface that serves a wide variety of use cases\n in the real world via the Zig ecosystem. It's shown to work.\n\n 2. Our core implementation itself is Zig, and this lets us very\n cheaply and easily convert between C and Zig allocators.\n\n NOTE(mitchellh): In the future, we can have default implementations of\n resize/remap and allow those to be null."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyAllocatorVtable {
#[doc = " Return a pointer to `len` bytes with specified `alignment`, or return\n `NULL` indicating the allocation failed.\n\n @param ctx The allocator context\n @param len Number of bytes to allocate\n @param alignment Required alignment for the allocation, as the number\n of low bits of the returned address that must be zero. This is not\n a byte count: convert it with `1 << alignment` before passing it to\n aligned_alloc or posix_memalign. For example:\n - 1: the lowest bit must be zero (2-byte aligned)\n - 2: the lowest two bits must be zero (4-byte aligned)\n - 4: the lowest four bits must be zero (16-byte aligned)\n This matches Zig's `std.mem.Alignment`.\n @param ret_addr First return address of the allocation call stack (0 if not provided)\n @return Pointer to allocated memory, or NULL if allocation failed"]
pub alloc: ::std::option::Option<
unsafe extern "C" fn(
ctx: *mut ::std::os::raw::c_void,
len: usize,
alignment: u8,
ret_addr: usize,
) -> *mut ::std::os::raw::c_void,
>,
#[doc = " Attempt to expand or shrink memory in place.\n\n `memory_len` must equal the length requested from the most recent\n successful call to `alloc`, `resize`, or `remap`. `alignment` must\n equal the same value that was passed as the `alignment` parameter to\n the original `alloc` call.\n\n `new_len` must be greater than zero.\n\n @param ctx The allocator context\n @param memory Pointer to the memory block to resize\n @param memory_len Current size of the memory block\n @param alignment Alignment (must match original allocation)\n @param new_len New requested size\n @param ret_addr First return address of the allocation call stack (0 if not provided)\n @return true if resize was successful in-place, false if relocation would be required"]
pub resize: ::std::option::Option<
unsafe extern "C" fn(
ctx: *mut ::std::os::raw::c_void,
memory: *mut ::std::os::raw::c_void,
memory_len: usize,
alignment: u8,
new_len: usize,
ret_addr: usize,
) -> bool,
>,
#[doc = " Attempt to expand or shrink memory, allowing relocation.\n\n `memory_len` must equal the length requested from the most recent\n successful call to `alloc`, `resize`, or `remap`. `alignment` must\n equal the same value that was passed as the `alignment` parameter to\n the original `alloc` call.\n\n A non-`NULL` return value indicates the resize was successful. The\n allocation may have same address, or may have been relocated. In either\n case, the allocation now has size of `new_len`. A `NULL` return value\n indicates that the resize would be equivalent to allocating new memory,\n copying the bytes from the old memory, and then freeing the old memory.\n In such case, it is more efficient for the caller to perform the copy.\n\n `new_len` must be greater than zero.\n\n @param ctx The allocator context\n @param memory Pointer to the memory block to remap\n @param memory_len Current size of the memory block\n @param alignment Alignment (must match original allocation)\n @param new_len New requested size\n @param ret_addr First return address of the allocation call stack (0 if not provided)\n @return Pointer to resized memory (may be relocated), or NULL if manual copy is needed"]
pub remap: ::std::option::Option<
unsafe extern "C" fn(
ctx: *mut ::std::os::raw::c_void,
memory: *mut ::std::os::raw::c_void,
memory_len: usize,
alignment: u8,
new_len: usize,
ret_addr: usize,
) -> *mut ::std::os::raw::c_void,
>,
#[doc = " Free and invalidate a region of memory.\n\n `memory_len` must equal the length requested from the most recent\n successful call to `alloc`, `resize`, or `remap`. `alignment` must\n equal the same value that was passed as the `alignment` parameter to\n the original `alloc` call.\n\n @param ctx The allocator context\n @param memory Pointer to the memory block to free\n @param memory_len Size of the memory block\n @param alignment Alignment (must match original allocation)\n @param ret_addr First return address of the allocation call stack (0 if not provided)"]
pub free: ::std::option::Option<
unsafe extern "C" fn(
ctx: *mut ::std::os::raw::c_void,
memory: *mut ::std::os::raw::c_void,
memory_len: usize,
alignment: u8,
ret_addr: usize,
),
>,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyAllocatorVtable"][::std::mem::size_of::<GhosttyAllocatorVtable>() - 32usize];
["Alignment of GhosttyAllocatorVtable"]
[::std::mem::align_of::<GhosttyAllocatorVtable>() - 8usize];
["Offset of field: GhosttyAllocatorVtable::alloc"]
[::std::mem::offset_of!(GhosttyAllocatorVtable, alloc) - 0usize];
["Offset of field: GhosttyAllocatorVtable::resize"]
[::std::mem::offset_of!(GhosttyAllocatorVtable, resize) - 8usize];
["Offset of field: GhosttyAllocatorVtable::remap"]
[::std::mem::offset_of!(GhosttyAllocatorVtable, remap) - 16usize];
["Offset of field: GhosttyAllocatorVtable::free"]
[::std::mem::offset_of!(GhosttyAllocatorVtable, free) - 24usize];
};
#[doc = " Custom memory allocator.\n\n For functions that take an allocator pointer, a NULL pointer indicates\n that the default allocator should be used. The default allocator will\n be libc malloc/free if we're linking to libc. If libc isn't linked,\n a custom allocator is used (currently Zig's SMP allocator). On native\n freestanding targets, the default allocator always fails instead.\n\n @ingroup allocator\n\n Usage example:\n @code\n GhosttyAllocator allocator = {\n .vtable = &my_allocator_vtable,\n .ctx = my_allocator_state\n };\n @endcode"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyAllocator {
#[doc = " Opaque context pointer passed to all vtable functions.\n This allows the allocator implementation to maintain state\n or reference external resources needed for memory management."]
pub ctx: *mut ::std::os::raw::c_void,
#[doc = " Pointer to the allocator's vtable containing function pointers\n for memory operations (alloc, resize, remap, free)."]
pub vtable: *const GhosttyAllocatorVtable,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyAllocator"][::std::mem::size_of::<GhosttyAllocator>() - 16usize];
["Alignment of GhosttyAllocator"][::std::mem::align_of::<GhosttyAllocator>() - 8usize];
["Offset of field: GhosttyAllocator::ctx"]
[::std::mem::offset_of!(GhosttyAllocator, ctx) - 0usize];
["Offset of field: GhosttyAllocator::vtable"]
[::std::mem::offset_of!(GhosttyAllocator, vtable) - 8usize];
};
impl Default for GhosttyAllocator {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Allocate a buffer of `len` bytes.\n\n Uses the provided allocator, or the default allocator if NULL is passed.\n The returned buffer must be freed with ghostty_free() using the same\n allocator.\n\n @param allocator Pointer to the allocator to use, or NULL for the default\n @param len Number of bytes to allocate\n @return Pointer to the allocated buffer, or NULL if len is zero or\n allocation failed\n\n @ingroup allocator"]
pub fn ghostty_alloc(allocator: *const GhosttyAllocator, len: usize) -> *mut u8;
}
unsafe extern "C" {
#[doc = " Free memory that was allocated by a libghostty-vt function.\n\n Use this to free buffers returned by functions such as\n ghostty_formatter_format_alloc(). Pass the same allocator that was\n used for the allocation, or NULL if the default allocator was used.\n\n On platforms where the library's internal allocator differs from the\n consumer's C runtime (e.g. Windows, where Zig's libc and MSVC's CRT\n maintain separate heaps), calling the standard C free() on memory\n allocated by the library causes undefined behavior. This function\n guarantees the correct allocator is used regardless of platform.\n\n It is safe to pass a NULL pointer; the call is a no-op in that case.\n\n @param allocator Pointer to the allocator that was used to allocate the\n memory, or NULL if the default allocator was used\n @param ptr Pointer to the memory to free (may be NULL)\n @param len Length of the allocation in bytes (must match the original\n allocation size)\n\n @ingroup allocator"]
pub fn ghostty_free(allocator: *const GhosttyAllocator, ptr: *mut u8, len: usize);
}
pub mod GhosttyOptimizeMode {
#[doc = " Build optimization mode."]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_OPTIMIZE_DEBUG: Type = 0;
pub const GHOSTTY_OPTIMIZE_RELEASE_SAFE: Type = 1;
pub const GHOSTTY_OPTIMIZE_RELEASE_SMALL: Type = 2;
pub const GHOSTTY_OPTIMIZE_RELEASE_FAST: Type = 3;
pub const GHOSTTY_OPTIMIZE_MODE_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyBuildInfo {
#[doc = " Build info data types that can be queried.\n\n Each variant documents the expected output pointer type."]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const GHOSTTY_BUILD_INFO_INVALID: Type = 0;
#[doc = " Whether SIMD-accelerated code paths are enabled.\n\n Output type: bool *"]
pub const GHOSTTY_BUILD_INFO_SIMD: Type = 1;
#[doc = " Whether Kitty graphics protocol support is available.\n\n Output type: bool *"]
pub const GHOSTTY_BUILD_INFO_KITTY_GRAPHICS: Type = 2;
#[doc = " Whether tmux control mode support is available.\n\n Output type: bool *"]
pub const GHOSTTY_BUILD_INFO_TMUX_CONTROL_MODE: Type = 3;
#[doc = " The optimization mode the library was built with.\n\n Output type: GhosttyOptimizeMode *"]
pub const GHOSTTY_BUILD_INFO_OPTIMIZE: Type = 4;
#[doc = " The full version string (e.g. \"1.2.3\" or \"1.2.3-dev+abcdef\").\n\n Output type: GhosttyString *"]
pub const GHOSTTY_BUILD_INFO_VERSION_STRING: Type = 5;
#[doc = " The major version number.\n\n Output type: size_t *"]
pub const GHOSTTY_BUILD_INFO_VERSION_MAJOR: Type = 6;
#[doc = " The minor version number.\n\n Output type: size_t *"]
pub const GHOSTTY_BUILD_INFO_VERSION_MINOR: Type = 7;
#[doc = " The patch version number.\n\n Output type: size_t *"]
pub const GHOSTTY_BUILD_INFO_VERSION_PATCH: Type = 8;
#[doc = " The pre metadata string (e.g. \"alpha\", \"beta\", \"dev\"). Has zero length if\n no pre metadata is present.\n\n Output type: GhosttyString *"]
pub const GHOSTTY_BUILD_INFO_VERSION_PRE: Type = 9;
#[doc = " The build metadata string (e.g. commit hash). Has zero length if\n no build metadata is present.\n\n Output type: GhosttyString *"]
pub const GHOSTTY_BUILD_INFO_VERSION_BUILD: Type = 10;
#[doc = " The build metadata string (e.g. commit hash). Has zero length if\n no build metadata is present.\n\n Output type: GhosttyString *"]
pub const GHOSTTY_BUILD_INFO_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Query a compile-time build configuration value.\n\n The caller must pass a pointer to the correct output type for the\n requested data (see GhosttyBuildInfo variants for types).\n\n @param data The build info field to query\n @param out Pointer to store the result (type depends on data parameter)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the\n data type is invalid\n\n @ingroup build_info"]
pub fn ghostty_build_info(
data: GhosttyBuildInfo::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
#[doc = " RGB color value.\n\n @ingroup color"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyColorRgb {
#[doc = "< Red component (0-255)"]
pub r: u8,
#[doc = "< Green component (0-255)"]
pub g: u8,
#[doc = "< Blue component (0-255)"]
pub b: u8,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyColorRgb"][::std::mem::size_of::<GhosttyColorRgb>() - 3usize];
["Alignment of GhosttyColorRgb"][::std::mem::align_of::<GhosttyColorRgb>() - 1usize];
["Offset of field: GhosttyColorRgb::r"][::std::mem::offset_of!(GhosttyColorRgb, r) - 0usize];
["Offset of field: GhosttyColorRgb::g"][::std::mem::offset_of!(GhosttyColorRgb, g) - 1usize];
["Offset of field: GhosttyColorRgb::b"][::std::mem::offset_of!(GhosttyColorRgb, b) - 2usize];
};
#[doc = " Palette color index (0-255).\n\n @ingroup color"]
pub type GhosttyColorPaletteIndex = u8;
#[doc = " A 256-bit mask of palette indices.\n\n Index i is set iff `(bits[i >> 6] >> (i & 63)) & 1` is 1.\n The mask is typically initialized to zero and then populated with\n GHOSTTY_COLOR_PALETTE_MASK_SET().\n\n @code{.c}\n GhosttyColorPaletteMask mask = {0};\n GHOSTTY_COLOR_PALETTE_MASK_SET(&mask, 20);\n if (GHOSTTY_COLOR_PALETTE_MASK_IS_SET(&mask, 20)) {\n // Index 20 will be preserved.\n }\n @endcode\n\n @ingroup color"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyColorPaletteMask {
pub bits: [u64; 4usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyColorPaletteMask"][::std::mem::size_of::<GhosttyColorPaletteMask>() - 32usize];
["Alignment of GhosttyColorPaletteMask"]
[::std::mem::align_of::<GhosttyColorPaletteMask>() - 8usize];
["Offset of field: GhosttyColorPaletteMask::bits"]
[::std::mem::offset_of!(GhosttyColorPaletteMask, bits) - 0usize];
};
#[doc = " An entry in Ghostty's X11 color name table.\n\n @ingroup color"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyColorX11Entry {
#[doc = " Null-terminated color name. NULL marks the end of the table."]
pub name: *const ::std::os::raw::c_char,
#[doc = " The RGB value of the color."]
pub color: GhosttyColorRgb,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyColorX11Entry"][::std::mem::size_of::<GhosttyColorX11Entry>() - 16usize];
["Alignment of GhosttyColorX11Entry"][::std::mem::align_of::<GhosttyColorX11Entry>() - 8usize];
["Offset of field: GhosttyColorX11Entry::name"]
[::std::mem::offset_of!(GhosttyColorX11Entry, name) - 0usize];
["Offset of field: GhosttyColorX11Entry::color"]
[::std::mem::offset_of!(GhosttyColorX11Entry, color) - 8usize];
};
impl Default for GhosttyColorX11Entry {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Get the RGB color components.\n\n This function extracts the individual red, green, and blue components\n from a GhosttyColorRgb value. Primarily useful in WebAssembly environments\n where accessing struct fields directly is difficult.\n\n @param color Pointer to the RGB color value\n @param r Pointer to store the red component (0-255)\n @param g Pointer to store the green component (0-255)\n @param b Pointer to store the blue component (0-255)\n\n @ingroup color"]
pub fn ghostty_color_rgb_get(color: *const GhosttyColorRgb, r: *mut u8, g: *mut u8, b: *mut u8);
}
unsafe extern "C" {
#[doc = " Parse an X11 color name.\n\n The color name is resolved from Ghostty's embedded rgb.txt table.\n Leading and trailing spaces and tabs are trimmed, and matching is\n ASCII case-insensitive. Hex values are not accepted by this function.\n\n @param name The color name bytes (must not be NULL)\n @param len The length of @p name in bytes\n @param[out] out The parsed RGB color\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if no color\n matches or @p name is NULL\n\n @ingroup color"]
pub fn ghostty_color_parse_x11(
name: *const ::std::os::raw::c_char,
len: usize,
out: *mut GhosttyColorRgb,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Parse a flexible Ghostty color value.\n\n Accepts Ghostty's terminal color syntax: X11 color names, hex colors\n in 3-, 6-, 9-, or 12-digit form (the leading # is optional for 3- and\n 6-digit values), and rgb:<red>/<green>/<blue> or\n rgbi:<red>/<green>/<blue> specifications. Leading and trailing spaces\n and tabs are trimmed.\n\n @param value The color value bytes (must not be NULL)\n @param len The length of @p value in bytes\n @param[out] out The parsed RGB color\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if parsing\n fails or @p value is NULL\n\n @ingroup color"]
pub fn ghostty_color_parse(
value: *const ::std::os::raw::c_char,
len: usize,
out: *mut GhosttyColorRgb,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Parse a Ghostty palette entry.\n\n Accepts Ghostty palette config syntax: N=COLOR. N is a palette index\n from 0 to 255 in decimal or in 0x, 0o, or 0b-prefixed form. Spaces and\n tabs around N and COLOR are ignored. COLOR accepts the same syntax as\n ghostty_color_parse().\n\n @param value The palette entry bytes (must not be NULL)\n @param len The length of @p value in bytes\n @param[out] out_index The parsed palette index\n @param[out] out_rgb The parsed RGB color\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE on any\n failure, including index overflow\n\n @ingroup color"]
pub fn ghostty_color_parse_palette_entry(
value: *const ::std::os::raw::c_char,
len: usize,
out_index: *mut u8,
out_rgb: *mut GhosttyColorRgb,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get Ghostty's built-in default 256-color palette.\n\n Writes exactly 256 entries: Ghostty's base16 defaults, the xterm\n 6x6x6 color cube, and the grayscale ramp.\n\n @param[out] out The output palette, an array of exactly 256\n GhosttyColorRgb values\n\n @ingroup color"]
pub fn ghostty_color_palette_default(out: *mut GhosttyColorRgb);
}
unsafe extern "C" {
#[doc = " Generate a 256-color palette from base colors.\n\n The base palette supplies indices 0-15, which are always preserved.\n If @p base is NULL, Ghostty's default palette is used. If @p skip is\n NULL, no extra indices are skipped. Set bits in @p skip preserve those\n indices from @p base. The 216-color cube at indices 16-231 is generated\n with trilinear CIELAB interpolation, and the grayscale ramp at indices\n 232-255 is interpolated from the background to the foreground.\n\n For light themes, @p harmonious controls whether the generated palette\n keeps the background-to-foreground orientation. When false, Ghostty\n swaps the light background and dark foreground so the cube and ramp run\n dark-to-light. The output palette may be the same pointer as @p base.\n\n @param base The base palette, an array of exactly 256 GhosttyColorRgb\n values, or NULL to use Ghostty's default palette\n @param skip The palette indices to preserve from @p base, or NULL for\n an empty mask\n @param bg The terminal background color (must not be NULL)\n @param fg The terminal foreground color (must not be NULL)\n @param harmonious Whether light themes keep background-to-foreground\n orientation\n @param[out] out The output palette, an array of exactly 256\n GhosttyColorRgb values\n\n @ingroup color"]
pub fn ghostty_color_palette_generate(
base: *const GhosttyColorRgb,
skip: *const GhosttyColorPaletteMask,
bg: *const GhosttyColorRgb,
fg: *const GhosttyColorRgb,
harmonious: bool,
out: *mut GhosttyColorRgb,
);
}
unsafe extern "C" {
#[doc = " Calculate W3C relative luminance for an RGB color.\n\n Returns a normalized value from 0.0 for black to 1.0 for white.\n See https://www.w3.org/TR/WCAG20/#relativeluminancedef.\n\n @param color The RGB color (must not be NULL)\n @return Relative luminance in the range 0.0 to 1.0\n\n @ingroup color"]
pub fn ghostty_color_luminance(color: *const GhosttyColorRgb) -> f64;
}
unsafe extern "C" {
#[doc = " Calculate perceived luminance for an RGB color.\n\n Returns a normalized value from 0.0 for black to 1.0 for white.\n Ghostty treats a background color as light when this exceeds 0.5.\n This is not the metric used internally by\n ghostty_color_palette_generate(), which uses CIELAB lightness.\n\n @param color The RGB color (must not be NULL)\n @return Perceived luminance in the range 0.0 to 1.0\n\n @ingroup color"]
pub fn ghostty_color_perceived_luminance(color: *const GhosttyColorRgb) -> f64;
}
unsafe extern "C" {
#[doc = " Calculate the WCAG contrast ratio between two RGB colors.\n\n The contrast ratio is symmetric and ranges from 1.0 for identical\n colors to 21.0 for black and white.\n\n @param a The first RGB color (must not be NULL)\n @param b The second RGB color (must not be NULL)\n @return WCAG contrast ratio in the range 1.0 to 21.0\n\n @ingroup color"]
pub fn ghostty_color_contrast(a: *const GhosttyColorRgb, b: *const GhosttyColorRgb) -> f64;
}
unsafe extern "C" {
#[doc = " Get Ghostty's X11 color name table.\n\n The returned pointer references static memory valid for the program\n lifetime and is never NULL. Entries are in rgb.txt order and are\n terminated by an entry with name == NULL. Aliases are separate entries,\n such as \"medium spring green\" and \"MediumSpringGreen\". Names are the\n exact supported spellings from rgb.txt; ghostty_color_parse_x11() also\n matches them case-insensitively.\n\n @code{.c}\n for (const GhosttyColorX11Entry* e = ghostty_color_x11_names();\n e->name != NULL;\n e++) {\n // e->name and e->color are valid here.\n }\n @endcode\n\n @return Pointer to the first X11 color entry\n\n @ingroup color"]
pub fn ghostty_color_x11_names() -> *const GhosttyColorX11Entry;
}
unsafe extern "C" {
#[doc = " Get the number of X11 color name entries.\n\n The returned count excludes the NULL terminator and is provided so\n bindings can preallocate storage before reading ghostty_color_x11_names().\n\n @return Number of X11 color name entries\n\n @ingroup color"]
pub fn ghostty_color_x11_name_count() -> usize;
}
pub mod GhosttyColorScheme {
#[doc = " Color scheme reported in response to a CSI ? 996 n query.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_COLOR_SCHEME_LIGHT: Type = 0;
pub const GHOSTTY_COLOR_SCHEME_DARK: Type = 1;
pub const GHOSTTY_COLOR_SCHEME_MAX_VALUE: Type = 2147483647;
}
#[doc = " Primary device attributes (DA1) response data.\n\n Returned as part of GhosttyDeviceAttributes in response to a CSI c query.\n The conformance_level is the Pp parameter and features contains the Ps\n feature codes.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyDeviceAttributesPrimary {
#[doc = " Conformance level (Pp parameter). E.g. 62 for VT220."]
pub conformance_level: u16,
#[doc = " DA1 feature codes. Only the first num_features entries are valid."]
pub features: [u16; 64usize],
#[doc = " Number of valid entries in the features array."]
pub num_features: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyDeviceAttributesPrimary"]
[::std::mem::size_of::<GhosttyDeviceAttributesPrimary>() - 144usize];
["Alignment of GhosttyDeviceAttributesPrimary"]
[::std::mem::align_of::<GhosttyDeviceAttributesPrimary>() - 8usize];
["Offset of field: GhosttyDeviceAttributesPrimary::conformance_level"]
[::std::mem::offset_of!(GhosttyDeviceAttributesPrimary, conformance_level) - 0usize];
["Offset of field: GhosttyDeviceAttributesPrimary::features"]
[::std::mem::offset_of!(GhosttyDeviceAttributesPrimary, features) - 2usize];
["Offset of field: GhosttyDeviceAttributesPrimary::num_features"]
[::std::mem::offset_of!(GhosttyDeviceAttributesPrimary, num_features) - 136usize];
};
impl Default for GhosttyDeviceAttributesPrimary {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Secondary device attributes (DA2) response data.\n\n Returned as part of GhosttyDeviceAttributes in response to a CSI > c query.\n Response format: CSI > Pp ; Pv ; Pc c\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyDeviceAttributesSecondary {
#[doc = " Terminal type identifier (Pp). E.g. 1 for VT220."]
pub device_type: u16,
#[doc = " Firmware/patch version number (Pv)."]
pub firmware_version: u16,
#[doc = " ROM cartridge registration number (Pc). Always 0 for emulators."]
pub rom_cartridge: u16,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyDeviceAttributesSecondary"]
[::std::mem::size_of::<GhosttyDeviceAttributesSecondary>() - 6usize];
["Alignment of GhosttyDeviceAttributesSecondary"]
[::std::mem::align_of::<GhosttyDeviceAttributesSecondary>() - 2usize];
["Offset of field: GhosttyDeviceAttributesSecondary::device_type"]
[::std::mem::offset_of!(GhosttyDeviceAttributesSecondary, device_type) - 0usize];
["Offset of field: GhosttyDeviceAttributesSecondary::firmware_version"]
[::std::mem::offset_of!(GhosttyDeviceAttributesSecondary, firmware_version) - 2usize];
["Offset of field: GhosttyDeviceAttributesSecondary::rom_cartridge"]
[::std::mem::offset_of!(GhosttyDeviceAttributesSecondary, rom_cartridge) - 4usize];
};
#[doc = " Tertiary device attributes (DA3) response data.\n\n Returned as part of GhosttyDeviceAttributes in response to a CSI = c query.\n Response format: DCS ! | D...D ST (DECRPTUI).\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyDeviceAttributesTertiary {
#[doc = " Unit ID encoded as 8 uppercase hex digits in the response."]
pub unit_id: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyDeviceAttributesTertiary"]
[::std::mem::size_of::<GhosttyDeviceAttributesTertiary>() - 4usize];
["Alignment of GhosttyDeviceAttributesTertiary"]
[::std::mem::align_of::<GhosttyDeviceAttributesTertiary>() - 4usize];
["Offset of field: GhosttyDeviceAttributesTertiary::unit_id"]
[::std::mem::offset_of!(GhosttyDeviceAttributesTertiary, unit_id) - 0usize];
};
#[doc = " Device attributes response data for all three DA levels.\n\n Filled by the device_attributes callback in response to CSI c,\n CSI > c, or CSI = c queries. The terminal uses whichever sub-struct\n matches the request type.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyDeviceAttributes {
pub primary: GhosttyDeviceAttributesPrimary,
pub secondary: GhosttyDeviceAttributesSecondary,
pub tertiary: GhosttyDeviceAttributesTertiary,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyDeviceAttributes"]
[::std::mem::size_of::<GhosttyDeviceAttributes>() - 160usize];
["Alignment of GhosttyDeviceAttributes"]
[::std::mem::align_of::<GhosttyDeviceAttributes>() - 8usize];
["Offset of field: GhosttyDeviceAttributes::primary"]
[::std::mem::offset_of!(GhosttyDeviceAttributes, primary) - 0usize];
["Offset of field: GhosttyDeviceAttributes::secondary"]
[::std::mem::offset_of!(GhosttyDeviceAttributes, secondary) - 144usize];
["Offset of field: GhosttyDeviceAttributes::tertiary"]
[::std::mem::offset_of!(GhosttyDeviceAttributes, tertiary) - 152usize];
};
impl Default for GhosttyDeviceAttributes {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Encode a color scheme report into an escape sequence.\n\n Encodes a color scheme report into the provided buffer. Dark color schemes\n emit ESC [ ? 997 ; 1 n, and light color schemes emit ESC [ ? 997 ; 2 n.\n The encoded bytes are identical to the terminal's internal CSI ? 996 n\n query response.\n\n Hosts should gate unsolicited sends on GHOSTTY_MODE_COLOR_SCHEME_REPORT\n (mode 2031) being set, which can be checked via the mode getters.\n\n If the buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE\n and writes the required buffer size to @p out_written. The caller can\n then retry with a sufficiently sized buffer.\n\n @param scheme The color scheme to encode\n @param buf Output buffer to write the encoded sequence into (may be NULL)\n @param buf_len Size of the output buffer in bytes\n @param[out] out_written On success, the number of bytes written. On\n GHOSTTY_OUT_OF_SPACE, the required buffer size.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if the buffer\n is too small"]
pub fn ghostty_color_scheme_report_encode(
scheme: GhosttyColorScheme::Type,
buf: *mut ::std::os::raw::c_char,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
pub mod GhosttyFocusEvent {
#[doc = " Focus event types for focus reporting mode (mode 1004)."]
pub type Type = ::std::os::raw::c_int;
#[doc = " Terminal window gained focus"]
pub const GHOSTTY_FOCUS_GAINED: Type = 0;
#[doc = " Terminal window lost focus"]
pub const GHOSTTY_FOCUS_LOST: Type = 1;
#[doc = " Terminal window lost focus"]
pub const GHOSTTY_FOCUS_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Encode a focus event into a terminal escape sequence.\n\n Encodes a focus gained (CSI I) or focus lost (CSI O) report into the\n provided buffer.\n\n If the buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE\n and writes the required buffer size to @p out_written. The caller can\n then retry with a sufficiently sized buffer.\n\n @param event The focus event to encode\n @param buf Output buffer to write the encoded sequence into (may be NULL)\n @param buf_len Size of the output buffer in bytes\n @param[out] out_written On success, the number of bytes written. On\n GHOSTTY_OUT_OF_SPACE, the required buffer size.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if the buffer\n is too small"]
pub fn ghostty_focus_encode(
event: GhosttyFocusEvent::Type,
buf: *mut ::std::os::raw::c_char,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
#[doc = " Read bytes from a source.\n\n The callback must set @p out_read to a value no greater than @p capacity\n when returning true. A positive value reports progress; it may be less than\n capacity and does not indicate end-of-file. A zero value is definitive\n end-of-file. It must not be used to report temporary input starvation or a\n would-block condition.\n\n Returning false reports a fatal read error and the value of @p out_read is\n ignored. The library does not inspect or modify errno.\n\n All pointer arguments are borrowed and valid only for the duration of the\n callback. The callback is invoked synchronously on the calling thread.\n\n @param userdata Opaque userdata from GhosttyReader\n @param buffer Destination for read bytes; always non-NULL\n @param capacity Writable capacity of @p buffer; always greater than zero\n @param[out] out_read Number of bytes read when returning true; non-NULL\n @return true for a successful read or end-of-file, false for a fatal error"]
pub type GhosttyReaderFn = ::std::option::Option<
unsafe extern "C" fn(
userdata: *mut ::std::os::raw::c_void,
buffer: *mut u8,
capacity: usize,
out_read: *mut usize,
) -> bool,
>;
#[doc = " Write bytes to a destination.\n\n Returning true means all @p len bytes were accepted. Returning false\n reports a fatal write error. A callback wrapping an interface that permits\n partial writes must retry internally until the full slice is accepted or\n an error occurs.\n\n On failure, the destination may already contain a prefix of the bytes. The\n calling operation fails and must not be resumed from that partial output.\n The library does not inspect or modify errno.\n\n @p data is borrowed and valid only for the duration of the callback. The\n callback is invoked synchronously on the calling thread. Successful return\n means the bytes were handed to the destination; it does not imply that the\n destination was flushed or made durable.\n\n @param userdata Opaque userdata from GhosttyWriter\n @param data Source bytes; always non-NULL\n @param len Number of source bytes; always greater than zero\n @return true if the complete slice was accepted, false on fatal error"]
pub type GhosttyWriterFn = ::std::option::Option<
unsafe extern "C" fn(
userdata: *mut ::std::os::raw::c_void,
data: *const u8,
len: usize,
) -> bool,
>;
#[doc = " A byte source callback and its opaque context.\n\n The struct is passed by value. @p read must be non-NULL."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyReader {
pub read: GhosttyReaderFn,
pub userdata: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyReader"][::std::mem::size_of::<GhosttyReader>() - 16usize];
["Alignment of GhosttyReader"][::std::mem::align_of::<GhosttyReader>() - 8usize];
["Offset of field: GhosttyReader::read"][::std::mem::offset_of!(GhosttyReader, read) - 0usize];
["Offset of field: GhosttyReader::userdata"]
[::std::mem::offset_of!(GhosttyReader, userdata) - 8usize];
};
impl Default for GhosttyReader {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " A byte destination callback and its opaque context.\n\n The struct is passed by value. @p write must be non-NULL."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyWriter {
pub write: GhosttyWriterFn,
pub userdata: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyWriter"][::std::mem::size_of::<GhosttyWriter>() - 16usize];
["Alignment of GhosttyWriter"][::std::mem::align_of::<GhosttyWriter>() - 8usize];
["Offset of field: GhosttyWriter::write"]
[::std::mem::offset_of!(GhosttyWriter, write) - 0usize];
["Offset of field: GhosttyWriter::userdata"]
[::std::mem::offset_of!(GhosttyWriter, userdata) - 8usize];
};
impl Default for GhosttyWriter {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Read one MIME-typed representation of some content, streaming its\n bytes to a writer.\n\n The library calls this with the MIME type of the representation it\n needs. The callback writes all of that representation's data to\n @p writer, in as many calls to `writer.write(writer.userdata, data,\n len)` as is convenient (one call with everything or many small\n pieces both work), and returns true. Nothing written is retained\n beyond each write call, so the data may be borrowed from anywhere:\n a pasteboard item, a file being read, a stream.\n\n Returning false reports that the data could not be read. If the\n writer refuses a write (returns false), stop and return false\n without writing more.\n\n All pointer arguments, the mime, and the writer are borrowed and\n valid only for the duration of the callback. The callback is\n invoked synchronously on the calling thread. The API receiving the\n GhosttyMimeReader defines which MIME types are requested, how many\n times, and any consistency requirements across repeated reads.\n\n @param userdata Opaque userdata from GhosttyMimeReader\n @param mime The MIME type of the representation to read\n @param writer Where to write the data; valid only during this call\n @return true once all the data was written, false if it could not\n be read or the writer refused a write"]
pub type GhosttyMimeReaderFn = ::std::option::Option<
unsafe extern "C" fn(
userdata: *mut ::std::os::raw::c_void,
mime: GhosttyString,
writer: GhosttyWriter,
) -> bool,
>;
#[doc = " A MIME-typed content source callback and its opaque context.\n\n The struct is passed by value. @p read must be non-NULL."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyMimeReader {
pub read: GhosttyMimeReaderFn,
pub userdata: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyMimeReader"][::std::mem::size_of::<GhosttyMimeReader>() - 16usize];
["Alignment of GhosttyMimeReader"][::std::mem::align_of::<GhosttyMimeReader>() - 8usize];
["Offset of field: GhosttyMimeReader::read"]
[::std::mem::offset_of!(GhosttyMimeReader, read) - 0usize];
["Offset of field: GhosttyMimeReader::userdata"]
[::std::mem::offset_of!(GhosttyMimeReader, userdata) - 8usize];
};
impl Default for GhosttyMimeReader {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Packed cell value.\n\n Represents a single terminal cell. Portable callers can query fields via\n ghostty_cell_get(). Boundary-sensitive callers can decode the packed value\n using the GhosttyCell descriptor returned by ghostty_type_json(). The\n manifest is authoritative for the linked build; hardcoding bit positions\n is unsupported.\n\n @ingroup screen"]
pub type GhosttyCell = u64;
#[doc = " Opaque row value.\n\n Represents a single terminal row. The internal layout is opaque and\n must be queried via ghostty_row_get(). Obtain row values from\n terminal query APIs.\n\n @ingroup screen"]
pub type GhosttyRow = u64;
#[doc = " A borrowed view of contiguous raw cell values.\n\n The memory is not owned by this struct. The pointer is only valid\n for the lifetime documented by the API that produces it. Each value\n can be queried via ghostty_cell_get() or decoded using the GhosttyCell\n packed descriptor returned by ghostty_type_json().\n\n @ingroup screen"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyCellsView {
#[doc = " Pointer to len contiguous cell values."]
pub ptr: *const GhosttyCell,
#[doc = " Number of cells."]
pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyCellsView"][::std::mem::size_of::<GhosttyCellsView>() - 16usize];
["Alignment of GhosttyCellsView"][::std::mem::align_of::<GhosttyCellsView>() - 8usize];
["Offset of field: GhosttyCellsView::ptr"]
[::std::mem::offset_of!(GhosttyCellsView, ptr) - 0usize];
["Offset of field: GhosttyCellsView::len"]
[::std::mem::offset_of!(GhosttyCellsView, len) - 8usize];
};
impl Default for GhosttyCellsView {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub mod GhosttyCellContentTag {
#[doc = " Cell content tag.\n\n Describes what kind of content a cell holds.\n\n @ingroup screen"]
pub type Type = ::std::os::raw::c_int;
#[doc = " A single codepoint (may be zero for empty)."]
pub const GHOSTTY_CELL_CONTENT_CODEPOINT: Type = 0;
#[doc = " A codepoint that is part of a multi-codepoint grapheme cluster."]
pub const GHOSTTY_CELL_CONTENT_CODEPOINT_GRAPHEME: Type = 1;
#[doc = " No text; background color from palette."]
pub const GHOSTTY_CELL_CONTENT_BG_COLOR_PALETTE: Type = 2;
#[doc = " No text; background color as RGB."]
pub const GHOSTTY_CELL_CONTENT_BG_COLOR_RGB: Type = 3;
#[doc = " No text; background color as RGB."]
pub const GHOSTTY_CELL_CONTENT_TAG_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyCellWide {
#[doc = " Cell wide property.\n\n Describes the width behavior of a cell.\n\n @ingroup screen"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Not a wide character, cell width 1."]
pub const GHOSTTY_CELL_WIDE_NARROW: Type = 0;
#[doc = " Wide character, cell width 2."]
pub const GHOSTTY_CELL_WIDE_WIDE: Type = 1;
#[doc = " Spacer after wide character. Do not render."]
pub const GHOSTTY_CELL_WIDE_SPACER_TAIL: Type = 2;
#[doc = " Spacer at end of soft-wrapped line for a wide character."]
pub const GHOSTTY_CELL_WIDE_SPACER_HEAD: Type = 3;
#[doc = " Spacer at end of soft-wrapped line for a wide character."]
pub const GHOSTTY_CELL_WIDE_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyCellSemanticContent {
#[doc = " Semantic content type of a cell.\n\n Set by semantic prompt sequences (OSC 133) to distinguish between\n command output, user input, and shell prompt text.\n\n @ingroup screen"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Regular output content, such as command output."]
pub const GHOSTTY_CELL_SEMANTIC_OUTPUT: Type = 0;
#[doc = " Content that is part of user input."]
pub const GHOSTTY_CELL_SEMANTIC_INPUT: Type = 1;
#[doc = " Content that is part of a shell prompt."]
pub const GHOSTTY_CELL_SEMANTIC_PROMPT: Type = 2;
#[doc = " Content that is part of a shell prompt."]
pub const GHOSTTY_CELL_SEMANTIC_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyCellData {
#[doc = " Cell data types.\n\n These values specify what type of data to extract from a cell\n using `ghostty_cell_get`.\n\n @ingroup screen"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const GHOSTTY_CELL_DATA_INVALID: Type = 0;
#[doc = " The codepoint of the cell (0 if empty or bg-color-only).\n\n Output type: uint32_t *"]
pub const GHOSTTY_CELL_DATA_CODEPOINT: Type = 1;
#[doc = " The content tag describing what kind of content is in the cell.\n\n Output type: GhosttyCellContentTag *"]
pub const GHOSTTY_CELL_DATA_CONTENT_TAG: Type = 2;
#[doc = " The wide property of the cell.\n\n Output type: GhosttyCellWide *"]
pub const GHOSTTY_CELL_DATA_WIDE: Type = 3;
#[doc = " Whether the cell has text to render.\n\n Output type: bool *"]
pub const GHOSTTY_CELL_DATA_HAS_TEXT: Type = 4;
#[doc = " Whether the cell has non-default styling.\n\n Output type: bool *"]
pub const GHOSTTY_CELL_DATA_HAS_STYLING: Type = 5;
#[doc = " The style ID for the cell (for use with style lookups).\n\n Output type: uint16_t *"]
pub const GHOSTTY_CELL_DATA_STYLE_ID: Type = 6;
#[doc = " Whether the cell has a hyperlink.\n\n Output type: bool *"]
pub const GHOSTTY_CELL_DATA_HAS_HYPERLINK: Type = 7;
#[doc = " Whether the cell is protected.\n\n Output type: bool *"]
pub const GHOSTTY_CELL_DATA_PROTECTED: Type = 8;
#[doc = " The semantic content type of the cell (from OSC 133).\n\n Output type: GhosttyCellSemanticContent *"]
pub const GHOSTTY_CELL_DATA_SEMANTIC_CONTENT: Type = 9;
#[doc = " The palette index for the cell's background color.\n Only valid when content_tag is GHOSTTY_CELL_CONTENT_BG_COLOR_PALETTE.\n\n Output type: GhosttyColorPaletteIndex *"]
pub const GHOSTTY_CELL_DATA_COLOR_PALETTE: Type = 10;
#[doc = " The RGB value for the cell's background color.\n Only valid when content_tag is GHOSTTY_CELL_CONTENT_BG_COLOR_RGB.\n\n Output type: GhosttyColorRgb *"]
pub const GHOSTTY_CELL_DATA_COLOR_RGB: Type = 11;
#[doc = " The RGB value for the cell's background color.\n Only valid when content_tag is GHOSTTY_CELL_CONTENT_BG_COLOR_RGB.\n\n Output type: GhosttyColorRgb *"]
pub const GHOSTTY_CELL_DATA_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyRowSemanticPrompt {
#[doc = " Row semantic prompt state.\n\n Indicates whether any cells in a row are part of a shell prompt,\n as reported by OSC 133 sequences.\n\n @ingroup screen"]
pub type Type = ::std::os::raw::c_int;
#[doc = " No prompt cells in this row."]
pub const GHOSTTY_ROW_SEMANTIC_NONE: Type = 0;
#[doc = " Prompt cells exist and this is a primary prompt line."]
pub const GHOSTTY_ROW_SEMANTIC_PROMPT: Type = 1;
#[doc = " Prompt cells exist and this is a continuation line."]
pub const GHOSTTY_ROW_SEMANTIC_PROMPT_CONTINUATION: Type = 2;
#[doc = " Prompt cells exist and this is a continuation line."]
pub const GHOSTTY_ROW_SEMANTIC_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyRowData {
#[doc = " Row data types.\n\n These values specify what type of data to extract from a row\n using `ghostty_row_get`.\n\n @ingroup screen"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const GHOSTTY_ROW_DATA_INVALID: Type = 0;
#[doc = " Whether this row is soft-wrapped.\n\n Output type: bool *"]
pub const GHOSTTY_ROW_DATA_WRAP: Type = 1;
#[doc = " Whether this row is a continuation of a soft-wrapped row.\n\n Output type: bool *"]
pub const GHOSTTY_ROW_DATA_WRAP_CONTINUATION: Type = 2;
#[doc = " Whether any cells in this row have grapheme clusters.\n\n Output type: bool *"]
pub const GHOSTTY_ROW_DATA_GRAPHEME: Type = 3;
#[doc = " Whether any cells in this row have styling (may have false positives).\n\n Output type: bool *"]
pub const GHOSTTY_ROW_DATA_STYLED: Type = 4;
#[doc = " Whether any cells in this row have hyperlinks (may have false positives).\n\n Output type: bool *"]
pub const GHOSTTY_ROW_DATA_HYPERLINK: Type = 5;
#[doc = " The semantic prompt state of this row.\n\n Output type: GhosttyRowSemanticPrompt *"]
pub const GHOSTTY_ROW_DATA_SEMANTIC_PROMPT: Type = 6;
#[doc = " Whether this row contains a Kitty virtual placeholder.\n\n Output type: bool *"]
pub const GHOSTTY_ROW_DATA_KITTY_VIRTUAL_PLACEHOLDER: Type = 7;
#[doc = " Whether this row is dirty and requires a redraw.\n\n Output type: bool *"]
pub const GHOSTTY_ROW_DATA_DIRTY: Type = 8;
#[doc = " Whether this row is dirty and requires a redraw.\n\n Output type: bool *"]
pub const GHOSTTY_ROW_DATA_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Get data from a cell.\n\n Extracts typed data from the given cell based on the specified\n data type. The output pointer must be of the appropriate type for the\n requested data kind. Valid data types and output types are documented\n in the `GhosttyCellData` enum.\n\n @param cell The cell value\n @param data The type of data to extract\n @param out Pointer to store the extracted data (type depends on data parameter)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the\n data type is invalid\n\n @ingroup screen"]
pub fn ghostty_cell_get(
cell: GhosttyCell,
data: GhosttyCellData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple data fields from a cell in a single call.\n\n Each element in the keys array specifies a data kind, and the\n corresponding element in the values array receives the result.\n\n Processing stops at the first error; on success out_written\n is set to count, on error it is set to the index of the\n failing key (i.e. the number of values successfully written).\n\n @param cell The cell value\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers (types must match each key's\n documented output type)\n @param[out] out_written On return, receives the number of values\n successfully written (may be NULL)\n @return GHOSTTY_SUCCESS if all queries succeed\n\n @ingroup screen"]
pub fn ghostty_cell_get_multi(
cell: GhosttyCell,
count: usize,
keys: *const GhosttyCellData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get data from a row.\n\n Extracts typed data from the given row based on the specified\n data type. The output pointer must be of the appropriate type for the\n requested data kind. Valid data types and output types are documented\n in the `GhosttyRowData` enum.\n\n @param row The row value\n @param data The type of data to extract\n @param out Pointer to store the extracted data (type depends on data parameter)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the\n data type is invalid\n\n @ingroup screen"]
pub fn ghostty_row_get(
row: GhosttyRow,
data: GhosttyRowData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple data fields from a row in a single call.\n\n Each element in the keys array specifies a data kind, and the\n corresponding element in the values array receives the result.\n\n Processing stops at the first error; on success out_written\n is set to count, on error it is set to the index of the\n failing key (i.e. the number of values successfully written).\n\n @param row The row value\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers (types must match each key's\n documented output type)\n @param[out] out_written On return, receives the number of values\n successfully written (may be NULL)\n @return GHOSTTY_SUCCESS if all queries succeed\n\n @ingroup screen"]
pub fn ghostty_row_get_multi(
row: GhosttyRow,
count: usize,
keys: *const GhosttyRowData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
#[doc = " Style identifier type.\n\n Used to look up the full style from a grid reference.\n Obtain this from a cell via GHOSTTY_CELL_DATA_STYLE_ID.\n\n @ingroup style"]
pub type GhosttyStyleId = u16;
pub mod GhosttyStyleColorTag {
#[doc = " Style color tags.\n\n These values identify the type of color in a style color.\n Use the tag to determine which field in the color value union to access.\n\n @ingroup style"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_STYLE_COLOR_NONE: Type = 0;
pub const GHOSTTY_STYLE_COLOR_PALETTE: Type = 1;
pub const GHOSTTY_STYLE_COLOR_RGB: Type = 2;
pub const GHOSTTY_STYLE_COLOR_TAG_MAX_VALUE: Type = 2147483647;
}
#[doc = " Style color value union.\n\n Use the tag to determine which field is active.\n\n @ingroup style"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union GhosttyStyleColorValue {
pub palette: GhosttyColorPaletteIndex,
pub rgb: GhosttyColorRgb,
pub _padding: u64,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyStyleColorValue"][::std::mem::size_of::<GhosttyStyleColorValue>() - 8usize];
["Alignment of GhosttyStyleColorValue"]
[::std::mem::align_of::<GhosttyStyleColorValue>() - 8usize];
["Offset of field: GhosttyStyleColorValue::palette"]
[::std::mem::offset_of!(GhosttyStyleColorValue, palette) - 0usize];
["Offset of field: GhosttyStyleColorValue::rgb"]
[::std::mem::offset_of!(GhosttyStyleColorValue, rgb) - 0usize];
["Offset of field: GhosttyStyleColorValue::_padding"]
[::std::mem::offset_of!(GhosttyStyleColorValue, _padding) - 0usize];
};
impl Default for GhosttyStyleColorValue {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Style color (tagged union).\n\n A color used in a style attribute. Can be unset (none), a palette\n index, or a direct RGB value.\n\n @ingroup style"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GhosttyStyleColor {
pub tag: GhosttyStyleColorTag::Type,
pub value: GhosttyStyleColorValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyStyleColor"][::std::mem::size_of::<GhosttyStyleColor>() - 16usize];
["Alignment of GhosttyStyleColor"][::std::mem::align_of::<GhosttyStyleColor>() - 8usize];
["Offset of field: GhosttyStyleColor::tag"]
[::std::mem::offset_of!(GhosttyStyleColor, tag) - 0usize];
["Offset of field: GhosttyStyleColor::value"]
[::std::mem::offset_of!(GhosttyStyleColor, value) - 8usize];
};
impl Default for GhosttyStyleColor {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Terminal cell style.\n\n Describes the complete visual style for a terminal cell, including\n foreground, background, and underline colors, as well as text\n decoration flags. The underline field uses the same values as\n GhosttySgrUnderline.\n\n This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.\n\n @ingroup style"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GhosttyStyle {
pub size: usize,
pub fg_color: GhosttyStyleColor,
pub bg_color: GhosttyStyleColor,
pub underline_color: GhosttyStyleColor,
pub bold: bool,
pub italic: bool,
pub faint: bool,
pub blink: bool,
pub inverse: bool,
pub invisible: bool,
pub strikethrough: bool,
pub overline: bool,
#[doc = "< One of GHOSTTY_SGR_UNDERLINE_* values"]
pub underline: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyStyle"][::std::mem::size_of::<GhosttyStyle>() - 72usize];
["Alignment of GhosttyStyle"][::std::mem::align_of::<GhosttyStyle>() - 8usize];
["Offset of field: GhosttyStyle::size"][::std::mem::offset_of!(GhosttyStyle, size) - 0usize];
["Offset of field: GhosttyStyle::fg_color"]
[::std::mem::offset_of!(GhosttyStyle, fg_color) - 8usize];
["Offset of field: GhosttyStyle::bg_color"]
[::std::mem::offset_of!(GhosttyStyle, bg_color) - 24usize];
["Offset of field: GhosttyStyle::underline_color"]
[::std::mem::offset_of!(GhosttyStyle, underline_color) - 40usize];
["Offset of field: GhosttyStyle::bold"][::std::mem::offset_of!(GhosttyStyle, bold) - 56usize];
["Offset of field: GhosttyStyle::italic"]
[::std::mem::offset_of!(GhosttyStyle, italic) - 57usize];
["Offset of field: GhosttyStyle::faint"][::std::mem::offset_of!(GhosttyStyle, faint) - 58usize];
["Offset of field: GhosttyStyle::blink"][::std::mem::offset_of!(GhosttyStyle, blink) - 59usize];
["Offset of field: GhosttyStyle::inverse"]
[::std::mem::offset_of!(GhosttyStyle, inverse) - 60usize];
["Offset of field: GhosttyStyle::invisible"]
[::std::mem::offset_of!(GhosttyStyle, invisible) - 61usize];
["Offset of field: GhosttyStyle::strikethrough"]
[::std::mem::offset_of!(GhosttyStyle, strikethrough) - 62usize];
["Offset of field: GhosttyStyle::overline"]
[::std::mem::offset_of!(GhosttyStyle, overline) - 63usize];
["Offset of field: GhosttyStyle::underline"]
[::std::mem::offset_of!(GhosttyStyle, underline) - 64usize];
};
impl Default for GhosttyStyle {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Get the default style.\n\n Initializes the style to the default values (no colors, no flags).\n\n @param style Pointer to the style to initialize\n\n @ingroup style"]
pub fn ghostty_style_default(style: *mut GhosttyStyle);
}
unsafe extern "C" {
#[doc = " Check if a style is the default style.\n\n Returns true if all colors are unset and all flags are off.\n\n @param style Pointer to the style to check\n @return true if the style is the default style\n\n @ingroup style"]
pub fn ghostty_style_is_default(style: *const GhosttyStyle) -> bool;
}
#[doc = " A resolved reference to a terminal cell position.\n\n This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.\n\n @ingroup grid_ref"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyGridRef {
pub size: usize,
pub node: *mut ::std::os::raw::c_void,
pub x: u16,
pub y: u16,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyGridRef"][::std::mem::size_of::<GhosttyGridRef>() - 24usize];
["Alignment of GhosttyGridRef"][::std::mem::align_of::<GhosttyGridRef>() - 8usize];
["Offset of field: GhosttyGridRef::size"]
[::std::mem::offset_of!(GhosttyGridRef, size) - 0usize];
["Offset of field: GhosttyGridRef::node"]
[::std::mem::offset_of!(GhosttyGridRef, node) - 8usize];
["Offset of field: GhosttyGridRef::x"][::std::mem::offset_of!(GhosttyGridRef, x) - 16usize];
["Offset of field: GhosttyGridRef::y"][::std::mem::offset_of!(GhosttyGridRef, y) - 18usize];
};
impl Default for GhosttyGridRef {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Get the cell from a grid reference.\n\n @param ref Pointer to the grid reference\n @param[out] out_cell On success, set to the cell at the ref's position (may be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the ref's\n node is NULL\n\n @ingroup grid_ref"]
pub fn ghostty_grid_ref_cell(
ref_: *const GhosttyGridRef,
out_cell: *mut GhosttyCell,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the row from a grid reference.\n\n @param ref Pointer to the grid reference\n @param[out] out_row On success, set to the row at the ref's position (may be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the ref's\n node is NULL\n\n @ingroup grid_ref"]
pub fn ghostty_grid_ref_row(
ref_: *const GhosttyGridRef,
out_row: *mut GhosttyRow,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the grapheme cluster codepoints for the cell at the grid reference's\n position.\n\n Writes the full grapheme cluster (the cell's primary codepoint followed by\n any combining codepoints) into the provided buffer. If the cell has no text,\n out_len is set to 0 and GHOSTTY_SUCCESS is returned.\n\n If the buffer is too small (or NULL), the function returns\n GHOSTTY_OUT_OF_SPACE and writes the required number of codepoints to\n out_len. The caller can then retry with a sufficiently sized buffer.\n\n @param ref Pointer to the grid reference\n @param buf Output buffer of uint32_t codepoints (may be NULL)\n @param buf_len Number of uint32_t elements in the buffer\n @param[out] out_len On success, the number of codepoints written. On\n GHOSTTY_OUT_OF_SPACE, the required buffer size in codepoints.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the ref's\n node is NULL, GHOSTTY_OUT_OF_SPACE if the buffer is too small\n\n @ingroup grid_ref"]
pub fn ghostty_grid_ref_graphemes(
ref_: *const GhosttyGridRef,
buf: *mut u32,
buf_len: usize,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the hyperlink URI for the cell at the grid reference's position.\n\n Writes the URI bytes into the provided buffer. If the cell has no\n hyperlink, out_len is set to 0 and GHOSTTY_SUCCESS is returned.\n\n If the buffer is too small (or NULL), the function returns\n GHOSTTY_OUT_OF_SPACE and writes the required number of bytes to\n out_len. The caller can then retry with a sufficiently sized buffer.\n\n @param ref Pointer to the grid reference\n @param buf Output buffer for the URI bytes (may be NULL)\n @param buf_len Size of the output buffer in bytes\n @param[out] out_len On success, the number of bytes written. On\n GHOSTTY_OUT_OF_SPACE, the required buffer size in bytes.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the ref's\n node is NULL, GHOSTTY_OUT_OF_SPACE if the buffer is too small\n\n @ingroup grid_ref"]
pub fn ghostty_grid_ref_hyperlink_uri(
ref_: *const GhosttyGridRef,
buf: *mut u8,
buf_len: usize,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the hyperlink ID for the cell at the grid reference's position.\n\n This is the ID given with the `id=` parameter of the OSC 8 sequence that\n started the hyperlink. Cells that share an ID and URI belong to the same\n hyperlink even when they are not contiguous, such as a hyperlink that\n wraps across lines.\n\n Writes the ID bytes into the provided buffer. If the cell has no\n hyperlink, or its hyperlink was started without an ID, out_len is set\n to 0 and GHOSTTY_SUCCESS is returned.\n\n If the buffer is too small (or NULL), the function returns\n GHOSTTY_OUT_OF_SPACE and writes the required number of bytes to\n out_len. The caller can then retry with a sufficiently sized buffer.\n\n @param ref Pointer to the grid reference\n @param buf Output buffer for the ID bytes (may be NULL)\n @param buf_len Size of the output buffer in bytes\n @param[out] out_len On success, the number of bytes written. On\n GHOSTTY_OUT_OF_SPACE, the required buffer size in bytes.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the ref's\n node is NULL, GHOSTTY_OUT_OF_SPACE if the buffer is too small\n\n @ingroup grid_ref"]
pub fn ghostty_grid_ref_hyperlink_id(
ref_: *const GhosttyGridRef,
buf: *mut u8,
buf_len: usize,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the style of the cell at the grid reference's position.\n\n @param ref Pointer to the grid reference\n @param[out] out_style On success, set to the cell's style (may be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the ref's\n node is NULL\n\n @ingroup grid_ref"]
pub fn ghostty_grid_ref_style(
ref_: *const GhosttyGridRef,
out_style: *mut GhosttyStyle,
) -> GhosttyResult::Type;
}
#[doc = " A coordinate in the terminal grid.\n\n @ingroup point"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyPointCoordinate {
#[doc = " Column (0-indexed)."]
pub x: u16,
#[doc = " Row (0-indexed). May exceed page size for screen/history tags."]
pub y: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyPointCoordinate"][::std::mem::size_of::<GhosttyPointCoordinate>() - 8usize];
["Alignment of GhosttyPointCoordinate"]
[::std::mem::align_of::<GhosttyPointCoordinate>() - 4usize];
["Offset of field: GhosttyPointCoordinate::x"]
[::std::mem::offset_of!(GhosttyPointCoordinate, x) - 0usize];
["Offset of field: GhosttyPointCoordinate::y"]
[::std::mem::offset_of!(GhosttyPointCoordinate, y) - 4usize];
};
pub mod GhosttyPointTag {
#[doc = " Point reference tag.\n\n Determines which coordinate system a point uses.\n\n @ingroup point"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Active area where the cursor can move."]
pub const GHOSTTY_POINT_TAG_ACTIVE: Type = 0;
#[doc = " Visible viewport (changes when scrolled)."]
pub const GHOSTTY_POINT_TAG_VIEWPORT: Type = 1;
#[doc = " Full screen including scrollback."]
pub const GHOSTTY_POINT_TAG_SCREEN: Type = 2;
#[doc = " Scrollback history only (before active area)."]
pub const GHOSTTY_POINT_TAG_HISTORY: Type = 3;
#[doc = " Scrollback history only (before active area)."]
pub const GHOSTTY_POINT_TAG_MAX_VALUE: Type = 2147483647;
}
#[doc = " Point value union.\n\n @ingroup point"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union GhosttyPointValue {
#[doc = " Coordinate (used for all tag variants)."]
pub coordinate: GhosttyPointCoordinate,
#[doc = " Padding for ABI compatibility. Do not use."]
pub _padding: [u64; 2usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyPointValue"][::std::mem::size_of::<GhosttyPointValue>() - 16usize];
["Alignment of GhosttyPointValue"][::std::mem::align_of::<GhosttyPointValue>() - 8usize];
["Offset of field: GhosttyPointValue::coordinate"]
[::std::mem::offset_of!(GhosttyPointValue, coordinate) - 0usize];
["Offset of field: GhosttyPointValue::_padding"]
[::std::mem::offset_of!(GhosttyPointValue, _padding) - 0usize];
};
impl Default for GhosttyPointValue {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Tagged union for a point in the terminal grid.\n\n @ingroup point"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GhosttyPoint {
pub tag: GhosttyPointTag::Type,
pub value: GhosttyPointValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyPoint"][::std::mem::size_of::<GhosttyPoint>() - 24usize];
["Alignment of GhosttyPoint"][::std::mem::align_of::<GhosttyPoint>() - 8usize];
["Offset of field: GhosttyPoint::tag"][::std::mem::offset_of!(GhosttyPoint, tag) - 0usize];
["Offset of field: GhosttyPoint::value"][::std::mem::offset_of!(GhosttyPoint, value) - 8usize];
};
impl Default for GhosttyPoint {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySelectionGestureImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to state for interpreting terminal selection gestures.\n\n The gesture owns only the state required to interpret pointer events. Calls\n that use a gesture are not concurrency-safe and must be serialized with\n terminal mutations.\n\n @ingroup selection"]
pub type GhosttySelectionGesture = *mut GhosttySelectionGestureImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySelectionGestureEventImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to reusable input data for selection gesture operations.\n\n Event options are set with ghostty_selection_gesture_event_set(). Individual\n gesture operations document which options are required or optional.\n\n @ingroup selection"]
pub type GhosttySelectionGestureEvent = *mut GhosttySelectionGestureEventImpl;
#[doc = " A snapshot selection range defined by two grid references.\n\n Both endpoints are inclusive. The endpoints preserve selection direction\n and may be reversed; callers must not assume that start is the top-left\n endpoint or that end is the bottom-right endpoint.\n\n When rectangle is false, the endpoints describe a linear selection. When\n rectangle is true, the same endpoints are interpreted as opposite corners\n of a rectangular/block selection.\n\n The start and end values are untracked GhosttyGridRef snapshots and are\n only valid until the next mutating operation on the terminal that produced\n them unless the selection is reconstructed from tracked references.\n\n This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.\n\n @ingroup selection"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySelection {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttySelection)."]
pub size: usize,
#[doc = " Start of the selection range (inclusive).\n\n This may be after end in terminal order. It is an untracked\n GhosttyGridRef snapshot and follows untracked grid-ref lifetime rules."]
pub start: GhosttyGridRef,
#[doc = " End of the selection range (inclusive).\n\n This may be before start in terminal order. It is an untracked\n GhosttyGridRef snapshot and follows untracked grid-ref lifetime rules."]
pub end: GhosttyGridRef,
#[doc = " Whether the endpoints are interpreted as a rectangular/block selection\n rather than a linear selection."]
pub rectangle: bool,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySelection"][::std::mem::size_of::<GhosttySelection>() - 64usize];
["Alignment of GhosttySelection"][::std::mem::align_of::<GhosttySelection>() - 8usize];
["Offset of field: GhosttySelection::size"]
[::std::mem::offset_of!(GhosttySelection, size) - 0usize];
["Offset of field: GhosttySelection::start"]
[::std::mem::offset_of!(GhosttySelection, start) - 8usize];
["Offset of field: GhosttySelection::end"]
[::std::mem::offset_of!(GhosttySelection, end) - 32usize];
["Offset of field: GhosttySelection::rectangle"]
[::std::mem::offset_of!(GhosttySelection, rectangle) - 56usize];
};
impl Default for GhosttySelection {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " A caller-provided buffer of selections.\n\n This follows the same conventions as GhosttyBuffer: ptr may be NULL with\n cap 0 to query the required capacity. APIs that fill this type set len to\n the number of entries written on GHOSTTY_SUCCESS, or to the required entry\n capacity on GHOSTTY_OUT_OF_SPACE.\n\n @ingroup selection"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySelectionBuffer {
#[doc = " Destination buffer for selections. May be NULL when cap is 0 to query\n the required capacity."]
pub ptr: *mut GhosttySelection,
#[doc = " Capacity of ptr in entries."]
pub cap: usize,
#[doc = " Entries written on success, or required entry capacity on\n GHOSTTY_OUT_OF_SPACE."]
pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySelectionBuffer"][::std::mem::size_of::<GhosttySelectionBuffer>() - 24usize];
["Alignment of GhosttySelectionBuffer"]
[::std::mem::align_of::<GhosttySelectionBuffer>() - 8usize];
["Offset of field: GhosttySelectionBuffer::ptr"]
[::std::mem::offset_of!(GhosttySelectionBuffer, ptr) - 0usize];
["Offset of field: GhosttySelectionBuffer::cap"]
[::std::mem::offset_of!(GhosttySelectionBuffer, cap) - 8usize];
["Offset of field: GhosttySelectionBuffer::len"]
[::std::mem::offset_of!(GhosttySelectionBuffer, len) - 16usize];
};
impl Default for GhosttySelectionBuffer {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Options for deriving a word selection from a terminal grid reference.\n\n This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.\n If boundary_codepoints is NULL and boundary_codepoints_len is 0, Ghostty's\n default word-boundary codepoints are used. If boundary_codepoints_len is\n non-zero, boundary_codepoints must not be NULL.\n\n @ingroup selection"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalSelectWordOptions {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectWordOptions)."]
pub size: usize,
#[doc = " Grid reference under which to derive the word selection."]
pub ref_: GhosttyGridRef,
#[doc = " Optional word-boundary codepoints as uint32_t scalar values."]
pub boundary_codepoints: *const u32,
#[doc = " Number of entries in boundary_codepoints."]
pub boundary_codepoints_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalSelectWordOptions"]
[::std::mem::size_of::<GhosttyTerminalSelectWordOptions>() - 48usize];
["Alignment of GhosttyTerminalSelectWordOptions"]
[::std::mem::align_of::<GhosttyTerminalSelectWordOptions>() - 8usize];
["Offset of field: GhosttyTerminalSelectWordOptions::size"]
[::std::mem::offset_of!(GhosttyTerminalSelectWordOptions, size) - 0usize];
["Offset of field: GhosttyTerminalSelectWordOptions::ref_"]
[::std::mem::offset_of!(GhosttyTerminalSelectWordOptions, ref_) - 8usize];
["Offset of field: GhosttyTerminalSelectWordOptions::boundary_codepoints"]
[::std::mem::offset_of!(GhosttyTerminalSelectWordOptions, boundary_codepoints) - 32usize];
["Offset of field: GhosttyTerminalSelectWordOptions::boundary_codepoints_len"][::std::mem::offset_of!(
GhosttyTerminalSelectWordOptions,
boundary_codepoints_len
) - 40usize];
};
impl Default for GhosttyTerminalSelectWordOptions {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Options for deriving the nearest word selection between two grid references.\n\n This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.\n If boundary_codepoints is NULL and boundary_codepoints_len is 0, Ghostty's\n default word-boundary codepoints are used. If boundary_codepoints_len is\n non-zero, boundary_codepoints must not be NULL.\n\n @ingroup selection"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalSelectWordBetweenOptions {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectWordBetweenOptions)."]
pub size: usize,
#[doc = " Starting grid reference for the inclusive search range."]
pub start: GhosttyGridRef,
#[doc = " Ending grid reference for the inclusive search range."]
pub end: GhosttyGridRef,
#[doc = " Optional word-boundary codepoints as uint32_t scalar values."]
pub boundary_codepoints: *const u32,
#[doc = " Number of entries in boundary_codepoints."]
pub boundary_codepoints_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalSelectWordBetweenOptions"]
[::std::mem::size_of::<GhosttyTerminalSelectWordBetweenOptions>() - 72usize];
["Alignment of GhosttyTerminalSelectWordBetweenOptions"]
[::std::mem::align_of::<GhosttyTerminalSelectWordBetweenOptions>() - 8usize];
["Offset of field: GhosttyTerminalSelectWordBetweenOptions::size"]
[::std::mem::offset_of!(GhosttyTerminalSelectWordBetweenOptions, size) - 0usize];
["Offset of field: GhosttyTerminalSelectWordBetweenOptions::start"]
[::std::mem::offset_of!(GhosttyTerminalSelectWordBetweenOptions, start) - 8usize];
["Offset of field: GhosttyTerminalSelectWordBetweenOptions::end"]
[::std::mem::offset_of!(GhosttyTerminalSelectWordBetweenOptions, end) - 32usize];
["Offset of field: GhosttyTerminalSelectWordBetweenOptions::boundary_codepoints"][::std::mem::offset_of!(
GhosttyTerminalSelectWordBetweenOptions,
boundary_codepoints
) - 56usize];
["Offset of field: GhosttyTerminalSelectWordBetweenOptions::boundary_codepoints_len"][::std::mem::offset_of!(
GhosttyTerminalSelectWordBetweenOptions,
boundary_codepoints_len
)
- 64usize];
};
impl Default for GhosttyTerminalSelectWordBetweenOptions {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Options for deriving a line selection from a terminal grid reference.\n\n This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.\n If whitespace is NULL and whitespace_len is 0, Ghostty's default line-trim\n whitespace codepoints are used. If whitespace_len is non-zero, whitespace\n must not be NULL.\n\n @ingroup selection"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalSelectLineOptions {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectLineOptions)."]
pub size: usize,
#[doc = " Grid reference under which to derive the line selection."]
pub ref_: GhosttyGridRef,
#[doc = " Optional codepoints to trim from the start and end of the line."]
pub whitespace: *const u32,
#[doc = " Number of entries in whitespace."]
pub whitespace_len: usize,
#[doc = " Whether semantic prompt state changes should bound the line selection."]
pub semantic_prompt_boundary: bool,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalSelectLineOptions"]
[::std::mem::size_of::<GhosttyTerminalSelectLineOptions>() - 56usize];
["Alignment of GhosttyTerminalSelectLineOptions"]
[::std::mem::align_of::<GhosttyTerminalSelectLineOptions>() - 8usize];
["Offset of field: GhosttyTerminalSelectLineOptions::size"]
[::std::mem::offset_of!(GhosttyTerminalSelectLineOptions, size) - 0usize];
["Offset of field: GhosttyTerminalSelectLineOptions::ref_"]
[::std::mem::offset_of!(GhosttyTerminalSelectLineOptions, ref_) - 8usize];
["Offset of field: GhosttyTerminalSelectLineOptions::whitespace"]
[::std::mem::offset_of!(GhosttyTerminalSelectLineOptions, whitespace) - 32usize];
["Offset of field: GhosttyTerminalSelectLineOptions::whitespace_len"]
[::std::mem::offset_of!(GhosttyTerminalSelectLineOptions, whitespace_len) - 40usize];
["Offset of field: GhosttyTerminalSelectLineOptions::semantic_prompt_boundary"][::std::mem::offset_of!(
GhosttyTerminalSelectLineOptions,
semantic_prompt_boundary
) - 48usize];
};
impl Default for GhosttyTerminalSelectLineOptions {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Options for one-shot formatting of a terminal selection.\n\n This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.\n\n If selection is NULL, the terminal's current active selection is used.\n If selection is non-NULL, that caller-provided snapshot selection is used.\n\n The selection is formatted from the terminal's active screen using the same\n formatting semantics as GhosttyFormatter. For copy/clipboard behavior\n matching Ghostty's Screen.selectionString(), use plain output with unwrap\n and trim both set to true.\n\n @ingroup selection"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalSelectionFormatOptions {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectionFormatOptions)."]
pub size: usize,
#[doc = " Output format to emit."]
pub emit: GhosttyFormatterFormat::Type,
#[doc = " Whether to unwrap soft-wrapped lines."]
pub unwrap: bool,
#[doc = " Whether to trim trailing whitespace on non-blank lines."]
pub trim: bool,
#[doc = " Optional selection to format.\n\n If NULL, the terminal's current active selection is used. If the terminal\n has no active selection, formatting returns GHOSTTY_NO_VALUE.\n\n If non-NULL, the pointed-to selection must be a valid snapshot selection\n for this terminal and must obey GhosttySelection lifetime rules."]
pub selection: *const GhosttySelection,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalSelectionFormatOptions"]
[::std::mem::size_of::<GhosttyTerminalSelectionFormatOptions>() - 24usize];
["Alignment of GhosttyTerminalSelectionFormatOptions"]
[::std::mem::align_of::<GhosttyTerminalSelectionFormatOptions>() - 8usize];
["Offset of field: GhosttyTerminalSelectionFormatOptions::size"]
[::std::mem::offset_of!(GhosttyTerminalSelectionFormatOptions, size) - 0usize];
["Offset of field: GhosttyTerminalSelectionFormatOptions::emit"]
[::std::mem::offset_of!(GhosttyTerminalSelectionFormatOptions, emit) - 8usize];
["Offset of field: GhosttyTerminalSelectionFormatOptions::unwrap"]
[::std::mem::offset_of!(GhosttyTerminalSelectionFormatOptions, unwrap) - 12usize];
["Offset of field: GhosttyTerminalSelectionFormatOptions::trim"]
[::std::mem::offset_of!(GhosttyTerminalSelectionFormatOptions, trim) - 13usize];
["Offset of field: GhosttyTerminalSelectionFormatOptions::selection"]
[::std::mem::offset_of!(GhosttyTerminalSelectionFormatOptions, selection) - 16usize];
};
impl Default for GhosttyTerminalSelectionFormatOptions {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub mod GhosttySelectionOrder {
#[doc = " Ordering of a selection's endpoints in terminal coordinates.\n\n Mirrored orders are only produced by rectangular selections whose start\n and end endpoints are on opposite diagonal corners that are not simple\n top-left-to-bottom-right or bottom-right-to-top-left orderings.\n\n @ingroup selection"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Start is before end in top-left to bottom-right order."]
pub const GHOSTTY_SELECTION_ORDER_FORWARD: Type = 0;
#[doc = " End is before start in top-left to bottom-right order."]
pub const GHOSTTY_SELECTION_ORDER_REVERSE: Type = 1;
#[doc = " Rectangular selection from top-right to bottom-left."]
pub const GHOSTTY_SELECTION_ORDER_MIRRORED_FORWARD: Type = 2;
#[doc = " Rectangular selection from bottom-left to top-right."]
pub const GHOSTTY_SELECTION_ORDER_MIRRORED_REVERSE: Type = 3;
#[doc = " Rectangular selection from bottom-left to top-right."]
pub const GHOSTTY_SELECTION_ORDER_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySelectionAdjust {
#[doc = " Operation used to adjust a selection endpoint.\n\n Adjustment mutates the selection's logical end endpoint, not whichever\n endpoint is visually bottom/right. This preserves keyboard and drag\n behavior for both forward and reversed selections.\n\n @ingroup selection"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Move left to the previous non-empty cell, wrapping upward."]
pub const GHOSTTY_SELECTION_ADJUST_LEFT: Type = 0;
#[doc = " Move right to the next non-empty cell, wrapping downward."]
pub const GHOSTTY_SELECTION_ADJUST_RIGHT: Type = 1;
#[doc = " Move up one row at the current column, or to the beginning of the\n line if already at the top."]
pub const GHOSTTY_SELECTION_ADJUST_UP: Type = 2;
#[doc = " Move down to the next non-blank row at the current column, or to the\n end of the line if none exists."]
pub const GHOSTTY_SELECTION_ADJUST_DOWN: Type = 3;
#[doc = " Move to the top-left cell of the screen."]
pub const GHOSTTY_SELECTION_ADJUST_HOME: Type = 4;
#[doc = " Move to the right edge of the last non-blank row on the screen."]
pub const GHOSTTY_SELECTION_ADJUST_END: Type = 5;
#[doc = " Move up by one terminal page height, or to home if that would move\n past the top."]
pub const GHOSTTY_SELECTION_ADJUST_PAGE_UP: Type = 6;
#[doc = " Move down by one terminal page height, or to end if that would move\n past the bottom."]
pub const GHOSTTY_SELECTION_ADJUST_PAGE_DOWN: Type = 7;
#[doc = " Move to the left edge of the current line."]
pub const GHOSTTY_SELECTION_ADJUST_BEGINNING_OF_LINE: Type = 8;
#[doc = " Move to the right edge of the current line."]
pub const GHOSTTY_SELECTION_ADJUST_END_OF_LINE: Type = 9;
#[doc = " Move to the right edge of the current line."]
pub const GHOSTTY_SELECTION_ADJUST_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySelectionGestureBehavior {
#[doc = " Selection behavior chosen for a gesture's click sequence.\n\n @ingroup selection"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Cell-granular drag selection."]
pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_CELL: Type = 0;
#[doc = " Word selection on press and word-granular drag selection."]
pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_WORD: Type = 1;
#[doc = " Line selection on press and line-granular drag selection."]
pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_LINE: Type = 2;
#[doc = " Semantic command output selection on press and drag."]
pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_OUTPUT: Type = 3;
#[doc = " Semantic command output selection on press and drag."]
pub const GHOSTTY_SELECTION_GESTURE_BEHAVIOR_MAX_VALUE: Type = 2147483647;
}
#[doc = " Selection behaviors for single-, double-, and triple-click gestures.\n\n @ingroup selection"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySelectionGestureBehaviors {
#[doc = " Behavior for single-click selection gestures."]
pub single_click: GhosttySelectionGestureBehavior::Type,
#[doc = " Behavior for double-click selection gestures."]
pub double_click: GhosttySelectionGestureBehavior::Type,
#[doc = " Behavior for triple-click selection gestures."]
pub triple_click: GhosttySelectionGestureBehavior::Type,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySelectionGestureBehaviors"]
[::std::mem::size_of::<GhosttySelectionGestureBehaviors>() - 12usize];
["Alignment of GhosttySelectionGestureBehaviors"]
[::std::mem::align_of::<GhosttySelectionGestureBehaviors>() - 4usize];
["Offset of field: GhosttySelectionGestureBehaviors::single_click"]
[::std::mem::offset_of!(GhosttySelectionGestureBehaviors, single_click) - 0usize];
["Offset of field: GhosttySelectionGestureBehaviors::double_click"]
[::std::mem::offset_of!(GhosttySelectionGestureBehaviors, double_click) - 4usize];
["Offset of field: GhosttySelectionGestureBehaviors::triple_click"]
[::std::mem::offset_of!(GhosttySelectionGestureBehaviors, triple_click) - 8usize];
};
impl Default for GhosttySelectionGestureBehaviors {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Display geometry used to interpret selection gesture drag events.\n\n @ingroup selection"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttySelectionGestureGeometry {
#[doc = " Number of columns in the rendered terminal grid. Must be non-zero."]
pub columns: u32,
#[doc = " Width of one terminal cell in surface pixels. Must be non-zero."]
pub cell_width: u32,
#[doc = " Left padding before the terminal grid begins in surface pixels."]
pub padding_left: u32,
#[doc = " Height of the rendered terminal surface in surface pixels. Must be non-zero."]
pub screen_height: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySelectionGestureGeometry"]
[::std::mem::size_of::<GhosttySelectionGestureGeometry>() - 16usize];
["Alignment of GhosttySelectionGestureGeometry"]
[::std::mem::align_of::<GhosttySelectionGestureGeometry>() - 4usize];
["Offset of field: GhosttySelectionGestureGeometry::columns"]
[::std::mem::offset_of!(GhosttySelectionGestureGeometry, columns) - 0usize];
["Offset of field: GhosttySelectionGestureGeometry::cell_width"]
[::std::mem::offset_of!(GhosttySelectionGestureGeometry, cell_width) - 4usize];
["Offset of field: GhosttySelectionGestureGeometry::padding_left"]
[::std::mem::offset_of!(GhosttySelectionGestureGeometry, padding_left) - 8usize];
["Offset of field: GhosttySelectionGestureGeometry::screen_height"]
[::std::mem::offset_of!(GhosttySelectionGestureGeometry, screen_height) - 12usize];
};
pub mod GhosttySelectionGestureAutoscroll {
#[doc = " Current autoscroll direction for an active selection drag gesture.\n\n @ingroup selection"]
pub type Type = ::std::os::raw::c_int;
#[doc = " No selection autoscroll is requested."]
pub const GHOSTTY_SELECTION_GESTURE_AUTOSCROLL_NONE: Type = 0;
#[doc = " Selection dragging should autoscroll the viewport upward."]
pub const GHOSTTY_SELECTION_GESTURE_AUTOSCROLL_UP: Type = 1;
#[doc = " Selection dragging should autoscroll the viewport downward."]
pub const GHOSTTY_SELECTION_GESTURE_AUTOSCROLL_DOWN: Type = 2;
#[doc = " Selection dragging should autoscroll the viewport downward."]
pub const GHOSTTY_SELECTION_GESTURE_AUTOSCROLL_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySelectionGestureData {
#[doc = " Data fields readable from a selection gesture with\n ghostty_selection_gesture_get().\n\n @ingroup selection"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Current click count: uint8_t*. 0 means inactive."]
pub const GHOSTTY_SELECTION_GESTURE_DATA_CLICK_COUNT: Type = 0;
#[doc = " Whether the current/last left-click gesture has dragged: bool*."]
pub const GHOSTTY_SELECTION_GESTURE_DATA_DRAGGED: Type = 1;
#[doc = " Current autoscroll request: GhosttySelectionGestureAutoscroll*."]
pub const GHOSTTY_SELECTION_GESTURE_DATA_AUTOSCROLL: Type = 2;
#[doc = " Current gesture behavior: GhosttySelectionGestureBehavior*."]
pub const GHOSTTY_SELECTION_GESTURE_DATA_BEHAVIOR: Type = 3;
#[doc = " Current left-click anchor: GhosttyGridRef*.\n\n Returns GHOSTTY_NO_VALUE if there is no valid active anchor. On success,\n writes an untracked GhosttyGridRef snapshot with normal GhosttyGridRef\n lifetime rules."]
pub const GHOSTTY_SELECTION_GESTURE_DATA_ANCHOR: Type = 4;
#[doc = " Current left-click anchor: GhosttyGridRef*.\n\n Returns GHOSTTY_NO_VALUE if there is no valid active anchor. On success,\n writes an untracked GhosttyGridRef snapshot with normal GhosttyGridRef\n lifetime rules."]
pub const GHOSTTY_SELECTION_GESTURE_DATA_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySelectionGestureEventType {
#[doc = " Selection gesture event type.\n\n The event type is fixed when the event is created. Each event type documents\n which options are valid and which options are required by gesture operations.\n\n @ingroup selection"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Press event for ghostty_selection_gesture_event()."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_PRESS: Type = 0;
#[doc = " Release event for ghostty_selection_gesture_event()."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_RELEASE: Type = 1;
#[doc = " Drag event for ghostty_selection_gesture_event()."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_DRAG: Type = 2;
#[doc = " Autoscroll tick event for ghostty_selection_gesture_event()."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_AUTOSCROLL_TICK: Type = 3;
#[doc = " Deep press event for ghostty_selection_gesture_event()."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_DEEP_PRESS: Type = 4;
#[doc = " Deep press event for ghostty_selection_gesture_event()."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySelectionGestureEventOption {
#[doc = " Options stored on a reusable selection gesture event.\n\n Passing NULL as the value to ghostty_selection_gesture_event_set() clears the\n corresponding option.\n\n @ingroup selection"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Grid reference under the pointer: GhosttyGridRef*.\n\n Required for PRESS and DRAG events. Optional for RELEASE events; when unset\n or cleared, release records that the pointer did not map to a valid cell."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REF: Type = 0;
#[doc = " Surface-space pointer position: GhosttySurfacePosition*.\n\n Valid for PRESS, DRAG, and AUTOSCROLL_TICK."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_POSITION: Type = 1;
#[doc = " Maximum repeat-click distance in pixels: double*."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REPEAT_DISTANCE: Type = 2;
#[doc = " Optional monotonic event time in nanoseconds: uint64_t*.\n\n If unset, press treats the event as untimed and only single-click behavior\n is available."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_TIME_NS: Type = 3;
#[doc = " Maximum interval between repeat clicks in nanoseconds: uint64_t*."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REPEAT_INTERVAL_NS: Type = 4;
#[doc = " Word-boundary codepoints: GhosttyCodepoints*.\n\n The codepoints are copied into event-owned storage when set. If unset,\n operations that need word boundaries use Ghostty's defaults.\n\n Valid for PRESS, DRAG, AUTOSCROLL_TICK, and DEEP_PRESS."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_WORD_BOUNDARY_CODEPOINTS: Type = 5;
#[doc = " Selection behavior table: GhosttySelectionGestureBehaviors*.\n\n If unset, press uses the default behavior table: cell, word, line."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_BEHAVIORS: Type = 6;
#[doc = " Whether a drag or autoscroll tick should produce a rectangular selection: bool*."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_RECTANGLE: Type = 7;
#[doc = " Drag display geometry: GhosttySelectionGestureGeometry*. Required for DRAG and AUTOSCROLL_TICK."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_GEOMETRY: Type = 8;
#[doc = " Viewport coordinate for an autoscroll tick: GhosttyPointCoordinate*. Required for AUTOSCROLL_TICK."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_VIEWPORT: Type = 9;
#[doc = " Viewport coordinate for an autoscroll tick: GhosttyPointCoordinate*. Required for AUTOSCROLL_TICK."]
pub const GHOSTTY_SELECTION_GESTURE_EVENT_OPT_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a reusable selection gesture event object.\n\n @param allocator Allocator, or NULL for the default allocator\n @param out_event Receives the created event handle\n @param type Event type. This is fixed for the lifetime of the event.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if out_event is\n NULL or type is invalid, or GHOSTTY_OUT_OF_MEMORY if allocation fails\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_event_new(
allocator: *const GhosttyAllocator,
out_event: *mut GhosttySelectionGestureEvent,
type_: GhosttySelectionGestureEventType::Type,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a selection gesture event object.\n\n Passing NULL is allowed and is a no-op.\n\n @param event Selection gesture event handle to free\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_event_free(event: GhosttySelectionGestureEvent);
}
unsafe extern "C" {
#[doc = " Set or clear an option on a selection gesture event.\n\n The value type depends on option and is documented by\n GhosttySelectionGestureEventOption. Passing NULL for value clears the option.\n\n @param event Selection gesture event handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param option Event option to set or clear\n @param value Pointer to the input value for option, or NULL to clear\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_MEMORY if copying\n event-owned data fails, or GHOSTTY_INVALID_VALUE if event, option, or\n value is invalid\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_event_set(
event: GhosttySelectionGestureEvent,
option: GhosttySelectionGestureEventOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Apply a selection gesture event and return the resulting selection snapshot.\n\n This dispatches to the gesture operation matching the event's fixed type.\n For GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_PRESS, the event must have\n GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REF set before calling this function.\n All other press options use their initialized defaults when unset or cleared.\n\n For GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_RELEASE, only\n GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REF is valid. It is optional; if unset or\n cleared, release records that the pointer did not map to a valid cell. Release\n events update gesture state but do not produce a selection, so this function\n returns GHOSTTY_NO_VALUE after applying them.\n\n For GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_DRAG,\n GHOSTTY_SELECTION_GESTURE_EVENT_OPT_REF and\n GHOSTTY_SELECTION_GESTURE_EVENT_OPT_GEOMETRY are required. Position,\n rectangle, and word-boundary codepoints are optional and use initialized\n defaults when unset or cleared.\n\n For GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_AUTOSCROLL_TICK,\n GHOSTTY_SELECTION_GESTURE_EVENT_OPT_VIEWPORT and\n GHOSTTY_SELECTION_GESTURE_EVENT_OPT_GEOMETRY are required. Position,\n rectangle, and word-boundary codepoints are optional and use initialized\n defaults when unset or cleared.\n\n For GHOSTTY_SELECTION_GESTURE_EVENT_TYPE_DEEP_PRESS, only\n GHOSTTY_SELECTION_GESTURE_EVENT_OPT_WORD_BOUNDARY_CODEPOINTS is valid. It is\n optional and uses initialized defaults when unset or cleared.\n\n The returned selection is not installed as the terminal's current selection.\n It is a snapshot with the same lifetime rules as GhosttySelection.\n\n @param gesture Selection gesture handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param terminal Terminal used to interpret and update gesture state\n @param event Selection gesture event handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param[out] out_selection On success, receives the resulting selection. May\n be NULL to apply the event and discard the selection result.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if the event does not\n currently produce a selection, GHOSTTY_OUT_OF_MEMORY if tracking\n gesture state fails, or GHOSTTY_INVALID_VALUE if gesture, terminal,\n event, or required event data is invalid\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_event(
gesture: GhosttySelectionGesture,
terminal: GhosttyTerminal,
event: GhosttySelectionGestureEvent,
out_selection: *mut GhosttySelection,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Create a selection gesture object.\n\n The gesture stores mutable state for terminal text selection gestures. The\n gesture is not bound to a terminal at creation time; terminal-dependent APIs\n take the terminal explicitly.\n\n @param allocator Allocator, or NULL for the default allocator\n @param out_gesture Receives the created gesture handle\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if out_gesture is\n NULL, or GHOSTTY_OUT_OF_MEMORY if allocation fails\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_new(
allocator: *const GhosttyAllocator,
out_gesture: *mut GhosttySelectionGesture,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a selection gesture object.\n\n This releases any tracked terminal references owned by the gesture using the\n provided terminal, then frees the gesture object. Passing NULL for gesture is\n allowed and is a no-op.\n\n If the terminal is still alive, pass the terminal most recently used with the\n gesture so any tracked terminal references can be released correctly. If the\n terminal has already been freed, pass NULL for terminal; the terminal's page\n storage has already released the underlying tracked references, so the\n gesture wrapper can be safely discarded without touching the stale terminal\n state.\n\n @param gesture Selection gesture handle to free\n @param terminal Terminal used to release tracked gesture state, or NULL if\n the terminal has already been freed\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_free(
gesture: GhosttySelectionGesture,
terminal: GhosttyTerminal,
);
}
unsafe extern "C" {
#[doc = " Reset any active selection gesture state.\n\n This cancels the active click sequence and releases any tracked terminal\n references owned by the gesture without freeing the gesture object.\n Passing NULL is allowed and is a no-op.\n\n @param gesture Selection gesture handle to reset\n @param terminal Terminal used to release tracked gesture state\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_reset(
gesture: GhosttySelectionGesture,
terminal: GhosttyTerminal,
);
}
unsafe extern "C" {
#[doc = " Read data from a selection gesture.\n\n The type of value depends on data and is documented by\n GhosttySelectionGestureData. For GHOSTTY_SELECTION_GESTURE_DATA_ANCHOR,\n the returned GhosttyGridRef is an untracked snapshot with normal grid-ref\n lifetime rules.\n\n @param gesture Selection gesture handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param terminal Terminal used to validate terminal-backed gesture state\n @param data Data field to read\n @param value Output pointer whose type depends on data\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if the requested data\n has no value, or GHOSTTY_INVALID_VALUE if gesture, terminal, data, or\n value is invalid\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_get(
gesture: GhosttySelectionGesture,
terminal: GhosttyTerminal,
data: GhosttySelectionGestureData::Type,
value: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Read multiple data fields from a selection gesture in a single call.\n\n This is an optimization over calling ghostty_selection_gesture_get() multiple\n times. Each entry in values must point to storage of the type documented by\n the corresponding GhosttySelectionGestureData key.\n\n If any individual read fails, the function returns that error and writes the\n index of the failing key to out_written when out_written is non-NULL. On\n success, out_written receives count when non-NULL.\n\n @param gesture Selection gesture handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param terminal Terminal used to validate terminal-backed gesture state\n @param count Number of data fields to read\n @param keys Data fields to read (must not be NULL)\n @param values Output pointers corresponding to keys (must not be NULL)\n @param out_written Optional number of fields read, or failing index on error\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if a requested data\n field has no value, or GHOSTTY_INVALID_VALUE if gesture, terminal,\n keys, values, or a value pointer is invalid\n\n @ingroup selection"]
pub fn ghostty_selection_gesture_get_multi(
gesture: GhosttySelectionGesture,
terminal: GhosttyTerminal,
count: usize,
keys: *const GhosttySelectionGestureData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Derive a word selection snapshot from a terminal grid reference.\n\n The returned selection is not installed as the terminal's current\n selection. It is a snapshot with the same lifetime rules as GhosttySelection.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param options Word-selection options\n @param[out] out_selection On success, receives the derived selection\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if the valid ref has\n no selectable word content, or GHOSTTY_INVALID_VALUE if the\n terminal, options, ref, codepoint pointer, or output pointer are\n invalid.\n\n @ingroup selection"]
pub fn ghostty_terminal_select_word(
terminal: GhosttyTerminal,
options: *const GhosttyTerminalSelectWordOptions,
out_selection: *mut GhosttySelection,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Derive the nearest word selection snapshot between two terminal grid refs.\n\n Starting at options->start, this searches toward options->end (inclusive)\n and returns the first selectable word found using Ghostty's word-selection\n rules.\n\n This is useful for implementing double-click-and-drag selection in a UI. If\n a user double-clicks one word and drags across spaces or punctuation toward\n another word, selecting only the word directly under the current pointer can\n flicker or collapse when the pointer is between words. Instead, ask for the\n nearest word between the original click and the drag point, ask again in the\n reverse direction, and combine the two word bounds into the drag selection.\n\n @snippet c-vt-selection/src/main.c selection-word-between\n\n The returned selection is not installed as the terminal's current\n selection. It is a snapshot with the same lifetime rules as GhosttySelection.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param options Word-between-selection options\n @param[out] out_selection On success, receives the derived selection\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if there is no\n selectable word content between the valid refs, or\n GHOSTTY_INVALID_VALUE if the terminal, options, refs, codepoint\n pointer, or output pointer are invalid.\n\n @ingroup selection"]
pub fn ghostty_terminal_select_word_between(
terminal: GhosttyTerminal,
options: *const GhosttyTerminalSelectWordBetweenOptions,
out_selection: *mut GhosttySelection,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Derive a line selection snapshot from a terminal grid reference.\n\n The returned selection is not installed as the terminal's current\n selection. It is a snapshot with the same lifetime rules as GhosttySelection.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param options Line-selection options\n @param[out] out_selection On success, receives the derived selection\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if the valid ref has\n no selectable line content, or GHOSTTY_INVALID_VALUE if the\n terminal, options, ref, codepoint pointer, or output pointer are\n invalid.\n\n @ingroup selection"]
pub fn ghostty_terminal_select_line(
terminal: GhosttyTerminal,
options: *const GhosttyTerminalSelectLineOptions,
out_selection: *mut GhosttySelection,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Derive a selection snapshot covering all selectable terminal content.\n\n The returned selection is not installed as the terminal's current\n selection. It is a snapshot with the same lifetime rules as GhosttySelection.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param[out] out_selection On success, receives the derived selection\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if there is no\n selectable content, or GHOSTTY_INVALID_VALUE if the terminal or\n output pointer is invalid.\n\n @ingroup selection"]
pub fn ghostty_terminal_select_all(
terminal: GhosttyTerminal,
out_selection: *mut GhosttySelection,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Derive a command-output selection snapshot from a terminal grid reference.\n\n The returned selection is not installed as the terminal's current\n selection. It is a snapshot with the same lifetime rules as GhosttySelection.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param ref Grid reference within command output to select\n @param[out] out_selection On success, receives the derived selection\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if the valid ref is\n not selectable command output, or GHOSTTY_INVALID_VALUE if the\n terminal, ref, or output pointer is invalid.\n\n @ingroup selection"]
pub fn ghostty_terminal_select_output(
terminal: GhosttyTerminal,
ref_: GhosttyGridRef,
out_selection: *mut GhosttySelection,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Format a terminal selection into a caller-provided buffer.\n\n This is a one-shot convenience API for formatting either the terminal's\n active selection or a caller-provided GhosttySelection without explicitly\n creating a GhosttyFormatter.\n\n Pass NULL for buf to query the required output size. In that case,\n out_written receives the required size and the function returns\n GHOSTTY_OUT_OF_SPACE.\n\n If buf is too small, the function returns GHOSTTY_OUT_OF_SPACE and writes\n the required size to out_written. The caller can then retry with a larger\n buffer.\n\n If options.selection is NULL and the terminal has no active selection, the\n function returns GHOSTTY_NO_VALUE.\n\n @param terminal The terminal to read from (must not be NULL)\n @param options Selection formatting options\n @param buf Output buffer, or NULL to query required size\n @param buf_len Length of buf in bytes\n @param out_written Number of bytes written, or required size on\n GHOSTTY_OUT_OF_SPACE (must not be NULL)\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup selection"]
pub fn ghostty_terminal_selection_format_buf(
terminal: GhosttyTerminal,
options: GhosttyTerminalSelectionFormatOptions,
buf: *mut u8,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Format a terminal selection into an allocated buffer.\n\n This is a one-shot convenience API for formatting either the terminal's\n active selection or a caller-provided GhosttySelection without explicitly\n creating a GhosttyFormatter.\n\n The returned buffer is allocated using allocator, or the default allocator\n if NULL is passed. The caller owns the returned buffer and must free it with\n ghostty_free(), passing the same allocator and returned length.\n Empty output returns GHOSTTY_SUCCESS with *out_ptr set to NULL and\n *out_len set to zero. This result can be passed to ghostty_free().\n\n The returned bytes are not NUL-terminated. This supports plain text, VT, and\n HTML uniformly as byte output.\n\n If options.selection is NULL and the terminal has no active selection, the\n function returns GHOSTTY_NO_VALUE and leaves out_ptr as NULL and out_len as 0.\n\n @param terminal The terminal to read from (must not be NULL)\n @param allocator Allocator used for the returned buffer, or NULL for the default allocator\n @param options Selection formatting options\n @param out_ptr Receives the allocated output buffer (must not be NULL)\n @param out_len Receives the output length in bytes (must not be NULL)\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup selection"]
pub fn ghostty_terminal_selection_format_alloc(
terminal: GhosttyTerminal,
allocator: *const GhosttyAllocator,
options: GhosttyTerminalSelectionFormatOptions,
out_ptr: *mut *mut u8,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Adjust a selection snapshot using terminal selection semantics.\n\n This mutates the caller-provided GhosttySelection in place. The logical end\n endpoint is always moved, regardless of whether the selection is forward or\n reversed visually. The input selection remains a snapshot: after adjustment,\n call ghostty_terminal_set() with GHOSTTY_TERMINAL_OPT_SELECTION to install it\n as the terminal-owned selection if desired.\n\n The selection's start and end grid refs must both be valid untracked\n snapshots for the given terminal's currently active screen. In practice,\n they must come from that terminal and screen, and no mutating terminal call\n may have occurred since the refs were produced or reconstructed from\n tracked refs. Passing refs from another terminal, another screen, or stale\n refs violates this precondition.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param selection Selection snapshot to adjust in place\n @param adjustment The adjustment operation to apply\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal,\n selection, or adjustment are invalid. Selection reference validity\n is a precondition and is not checked.\n\n @ingroup selection"]
pub fn ghostty_terminal_selection_adjust(
terminal: GhosttyTerminal,
selection: *mut GhosttySelection,
adjustment: GhosttySelectionAdjust::Type,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the current endpoint ordering of a selection snapshot.\n\n The selection's start and end grid refs must both be valid untracked\n snapshots for the given terminal's currently active screen. In practice,\n they must come from that terminal and screen, and no mutating terminal call\n may have occurred since the refs were produced or reconstructed from\n tracked refs. Passing refs from another terminal, another screen, or stale\n refs violates this precondition.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param selection Selection snapshot to inspect\n @param[out] out_order On success, receives the selection order\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal,\n selection, or output pointer are invalid. Selection reference\n validity is a precondition and is not checked.\n\n @ingroup selection"]
pub fn ghostty_terminal_selection_order(
terminal: GhosttyTerminal,
selection: *const GhosttySelection,
out_order: *mut GhosttySelectionOrder::Type,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Return a selection snapshot with endpoints ordered as requested.\n\n Use GHOSTTY_SELECTION_ORDER_FORWARD to get top-left to bottom-right bounds,\n and GHOSTTY_SELECTION_ORDER_REVERSE to get bottom-right to top-left bounds.\n Mirrored desired orders are accepted but normalized the same as forward.\n The output selection is a fresh untracked snapshot and is not installed as\n the terminal's current selection.\n\n The selection's start and end grid refs must both be valid untracked\n snapshots for the given terminal's currently active screen. In practice,\n they must come from that terminal and screen, and no mutating terminal call\n may have occurred since the refs were produced or reconstructed from\n tracked refs. Passing refs from another terminal, another screen, or stale\n refs violates this precondition.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param selection Selection snapshot to order\n @param desired Desired endpoint order\n @param[out] out_selection On success, receives the ordered selection\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal,\n selection, desired order, or output pointer are invalid. Selection\n reference validity is a precondition and is not checked.\n\n @ingroup selection"]
pub fn ghostty_terminal_selection_ordered(
terminal: GhosttyTerminal,
selection: *const GhosttySelection,
desired: GhosttySelectionOrder::Type,
out_selection: *mut GhosttySelection,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Test whether a terminal point is inside a selection snapshot.\n\n This uses the same selection semantics as the terminal, including\n rectangular/block selections and linear selections spanning multiple rows.\n\n The selection's start and end grid refs must both be valid untracked\n snapshots for the given terminal's currently active screen. In practice,\n they must come from that terminal and screen, and no mutating terminal call\n may have occurred since the refs were produced or reconstructed from\n tracked refs. Passing refs from another terminal, another screen, or stale\n refs violates this precondition.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param selection Selection snapshot to inspect\n @param point Point to test for containment\n @param[out] out_contains On success, receives whether point is inside selection\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal,\n selection, point, or output pointer are invalid. Selection reference\n validity is a precondition and is not checked.\n\n @ingroup selection"]
pub fn ghostty_terminal_selection_contains(
terminal: GhosttyTerminal,
selection: *const GhosttySelection,
point: GhosttyPoint,
out_contains: *mut bool,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Test whether two selection snapshots are equal.\n\n Equality uses the terminal's internal selection semantics: both endpoint\n pins must match and both selections must have the same rectangular/block\n state. This avoids requiring callers to compare raw GhosttyGridRef internals.\n\n Both selections' start and end grid refs must be valid untracked snapshots\n for the given terminal's currently active screen. In practice, they must\n come from that terminal and screen, and no mutating terminal call may have\n occurred since the refs were produced or reconstructed from tracked refs.\n Passing refs from another terminal, another screen, or stale refs violates\n this precondition.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param a First selection snapshot to compare\n @param b Second selection snapshot to compare\n @param[out] out_equal On success, receives whether the selections are equal\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal,\n selections, or output pointer are invalid. Selection reference\n validity is a precondition and is not checked.\n\n @ingroup selection"]
pub fn ghostty_terminal_selection_equal(
terminal: GhosttyTerminal,
a: *const GhosttySelection,
b: *const GhosttySelection,
out_equal: *mut bool,
) -> GhosttyResult::Type;
}
#[doc = " A packed 16-bit terminal mode.\n\n Encodes a mode value (bits 0–14) and an ANSI flag (bit 15) into a\n single 16-bit integer. Use the inline helper functions to construct\n and inspect modes rather than manipulating bits directly."]
pub type GhosttyMode = u16;
pub mod GhosttyModeReportState {
#[doc = " DECRPM report state values.\n\n These correspond to the Ps2 parameter in a DECRPM response\n sequence (CSI ? Ps1 ; Ps2 $ y)."]
pub type Type = ::std::os::raw::c_int;
#[doc = " Mode is not recognized"]
pub const GHOSTTY_MODE_REPORT_NOT_RECOGNIZED: Type = 0;
#[doc = " Mode is set (enabled)"]
pub const GHOSTTY_MODE_REPORT_SET: Type = 1;
#[doc = " Mode is reset (disabled)"]
pub const GHOSTTY_MODE_REPORT_RESET: Type = 2;
#[doc = " Mode is permanently set"]
pub const GHOSTTY_MODE_REPORT_PERMANENTLY_SET: Type = 3;
#[doc = " Mode is permanently reset"]
pub const GHOSTTY_MODE_REPORT_PERMANENTLY_RESET: Type = 4;
#[doc = " Mode is permanently reset"]
pub const GHOSTTY_MODE_REPORT_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Encode a DECRPM (DEC Private Mode Report) response sequence.\n\n Writes a mode report escape sequence into the provided buffer.\n The generated sequence has the form:\n - DEC private mode: CSI ? Ps1 ; Ps2 $ y\n - ANSI mode: CSI Ps1 ; Ps2 $ y\n\n If the buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE\n and writes the required buffer size to @p out_written. The caller can\n then retry with a sufficiently sized buffer.\n\n @param mode The mode identifying the mode to report on\n @param state The report state for this mode\n @param buf Output buffer to write the encoded sequence into (may be NULL)\n @param buf_len Size of the output buffer in bytes\n @param[out] out_written On success, the number of bytes written. On\n GHOSTTY_OUT_OF_SPACE, the required buffer size.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if the buffer\n is too small"]
pub fn ghostty_mode_report_encode(
mode: GhosttyMode,
state: GhosttyModeReportState::Type,
buf: *mut ::std::os::raw::c_char,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
pub mod GhosttyOscCommandType {
#[doc = " OSC command types.\n\n @ingroup osc"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_OSC_COMMAND_INVALID: Type = 0;
pub const GHOSTTY_OSC_COMMAND_CHANGE_WINDOW_TITLE: Type = 1;
pub const GHOSTTY_OSC_COMMAND_CHANGE_WINDOW_ICON: Type = 2;
pub const GHOSTTY_OSC_COMMAND_SEMANTIC_PROMPT: Type = 3;
pub const GHOSTTY_OSC_COMMAND_CLIPBOARD_CONTENTS: Type = 4;
pub const GHOSTTY_OSC_COMMAND_REPORT_PWD: Type = 5;
pub const GHOSTTY_OSC_COMMAND_MOUSE_SHAPE: Type = 6;
pub const GHOSTTY_OSC_COMMAND_COLOR_OPERATION: Type = 7;
pub const GHOSTTY_OSC_COMMAND_KITTY_COLOR_PROTOCOL: Type = 8;
pub const GHOSTTY_OSC_COMMAND_SHOW_DESKTOP_NOTIFICATION: Type = 9;
pub const GHOSTTY_OSC_COMMAND_HYPERLINK_START: Type = 10;
pub const GHOSTTY_OSC_COMMAND_HYPERLINK_END: Type = 11;
pub const GHOSTTY_OSC_COMMAND_CONEMU_SLEEP: Type = 12;
pub const GHOSTTY_OSC_COMMAND_CONEMU_SHOW_MESSAGE_BOX: Type = 13;
pub const GHOSTTY_OSC_COMMAND_CONEMU_CHANGE_TAB_TITLE: Type = 14;
pub const GHOSTTY_OSC_COMMAND_CONEMU_PROGRESS_REPORT: Type = 15;
pub const GHOSTTY_OSC_COMMAND_CONEMU_WAIT_INPUT: Type = 16;
pub const GHOSTTY_OSC_COMMAND_CONEMU_GUIMACRO: Type = 17;
pub const GHOSTTY_OSC_COMMAND_CONEMU_RUN_PROCESS: Type = 18;
pub const GHOSTTY_OSC_COMMAND_CONEMU_OUTPUT_ENVIRONMENT_VARIABLE: Type = 19;
pub const GHOSTTY_OSC_COMMAND_CONEMU_XTERM_EMULATION: Type = 20;
pub const GHOSTTY_OSC_COMMAND_CONEMU_COMMENT: Type = 21;
pub const GHOSTTY_OSC_COMMAND_KITTY_TEXT_SIZING: Type = 22;
pub const GHOSTTY_OSC_COMMAND_KITTY_CLIPBOARD_PROTOCOL: Type = 23;
pub const GHOSTTY_OSC_COMMAND_KITTY_DND_PROTOCOL: Type = 24;
pub const GHOSTTY_OSC_COMMAND_CONTEXT_SIGNAL: Type = 25;
pub const GHOSTTY_OSC_COMMAND_KITTY_DESKTOP_NOTIFICATION: Type = 26;
#[doc = " An OSC sequence whose number the parser does not implement. Read it\n with the GHOSTTY_OSC_DATA_UNKNOWN_* data types.\n\n Only produced when GHOSTTY_OSC_OPT_UNKNOWN_MAX_BYTES is nonzero.\n Otherwise these sequences are GHOSTTY_OSC_COMMAND_INVALID."]
pub const GHOSTTY_OSC_COMMAND_UNKNOWN: Type = 27;
#[doc = " A program status report or support query (OSC 7501), which a program\n sends to say what it is doing, such as working or waiting on the user.\n\n The OSC parser only identifies this command. To receive the report's\n contents, use a terminal with GHOSTTY_TERMINAL_OPT_PROGRAM_STATUS\n instead (see GhosttyTerminalProgramStatus)."]
pub const GHOSTTY_OSC_COMMAND_PROGRAM_STATUS: Type = 28;
#[doc = " A program status report or support query (OSC 7501), which a program\n sends to say what it is doing, such as working or waiting on the user.\n\n The OSC parser only identifies this command. To receive the report's\n contents, use a terminal with GHOSTTY_TERMINAL_OPT_PROGRAM_STATUS\n instead (see GhosttyTerminalProgramStatus)."]
pub const GHOSTTY_OSC_COMMAND_TYPE_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyOscTerminator {
#[doc = " How an OSC sequence was ended.\n\n Programs can end an OSC sequence in two ways. When you reply to a\n sequence, end the reply the same way the program ended its request.\n Some programs only recognize replies that match.\n\n @ingroup osc"]
pub type Type = ::std::os::raw::c_int;
#[doc = " The string terminator (ST): ESC followed by a backslash (0x1B 0x5C)."]
pub const GHOSTTY_OSC_TERMINATOR_ST: Type = 0;
#[doc = " The bell character, BEL (byte 0x07)."]
pub const GHOSTTY_OSC_TERMINATOR_BEL: Type = 1;
#[doc = " The bell character, BEL (byte 0x07)."]
pub const GHOSTTY_OSC_TERMINATOR_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyOscOption {
#[doc = " OSC parser options, set with ghostty_osc_set().\n\n @ingroup osc"]
pub type Type = ::std::os::raw::c_int;
#[doc = " The most bytes to keep from each OSC sequence whose number the parser\n does not implement.\n\n Zero, the default, discards these sequences and they produce\n GHOSTTY_OSC_COMMAND_INVALID. Any other value makes them produce\n GHOSTTY_OSC_COMMAND_UNKNOWN. A NULL value pointer sets the limit back\n to zero.\n\n A sequence longer than the limit is still reported. Its content holds\n the first bytes up to the limit, and GHOSTTY_OSC_DATA_UNKNOWN_TRUNCATED\n is true.\n\n Limits up to 2048 bytes use a buffer the parser already owns and never\n allocate memory. Larger limits allocate memory from the parser's\n allocator for each unknown sequence.\n\n Input type: size_t*"]
pub const GHOSTTY_OSC_OPT_UNKNOWN_MAX_BYTES: Type = 0;
#[doc = " The most bytes to keep from each OSC sequence whose number the parser\n does not implement.\n\n Zero, the default, discards these sequences and they produce\n GHOSTTY_OSC_COMMAND_INVALID. Any other value makes them produce\n GHOSTTY_OSC_COMMAND_UNKNOWN. A NULL value pointer sets the limit back\n to zero.\n\n A sequence longer than the limit is still reported. Its content holds\n the first bytes up to the limit, and GHOSTTY_OSC_DATA_UNKNOWN_TRUNCATED\n is true.\n\n Limits up to 2048 bytes use a buffer the parser already owns and never\n allocate memory. Larger limits allocate memory from the parser's\n allocator for each unknown sequence.\n\n Input type: size_t*"]
pub const GHOSTTY_OSC_OPT_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyOscCommandData {
#[doc = " OSC command data types.\n\n These values specify what type of data to extract from an OSC command\n using `ghostty_osc_command_data`.\n\n @ingroup osc"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const GHOSTTY_OSC_DATA_INVALID: Type = 0;
#[doc = " Window title string data.\n\n Valid for: GHOSTTY_OSC_COMMAND_CHANGE_WINDOW_TITLE\n\n Output type: const char ** (pointer to null-terminated string)\n\n Lifetime: Valid until the next call to any ghostty_osc_* function with\n the same parser instance. Memory is owned by the parser."]
pub const GHOSTTY_OSC_DATA_CHANGE_WINDOW_TITLE_STR: Type = 1;
#[doc = " The raw bytes of an unknown sequence: everything that was passed to\n ghostty_osc_next(), including the number at the start. For example,\n the sequence `ESC ] 7400;status=busy BEL` gives\n `7400;status=busy`. The bytes are not null-terminated.\n\n Valid for: GHOSTTY_OSC_COMMAND_UNKNOWN\n\n Output type: GhosttyString *\n\n Lifetime: Valid until the next call to any ghostty_osc_* function with\n the same parser instance. Memory is owned by the parser."]
pub const GHOSTTY_OSC_DATA_UNKNOWN_CONTENT: Type = 2;
#[doc = " True if the unknown sequence was longer than\n GHOSTTY_OSC_OPT_UNKNOWN_MAX_BYTES, or memory ran out while reading it.\n In that case the content holds only the beginning of the sequence.\n\n Valid for: GHOSTTY_OSC_COMMAND_UNKNOWN\n\n Output type: bool *"]
pub const GHOSTTY_OSC_DATA_UNKNOWN_TRUNCATED: Type = 3;
#[doc = " How the unknown sequence was ended, based on the terminator passed to\n ghostty_osc_end(). If you reply to the sequence, end the reply the same\n way.\n\n Valid for: GHOSTTY_OSC_COMMAND_UNKNOWN\n\n Output type: GhosttyOscTerminator *"]
pub const GHOSTTY_OSC_DATA_UNKNOWN_TERMINATOR: Type = 4;
#[doc = " How the unknown sequence was ended, based on the terminator passed to\n ghostty_osc_end(). If you reply to the sequence, end the reply the same\n way.\n\n Valid for: GHOSTTY_OSC_COMMAND_UNKNOWN\n\n Output type: GhosttyOscTerminator *"]
pub const GHOSTTY_OSC_DATA_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a new OSC parser instance.\n\n Creates a new OSC (Operating System Command) parser using the provided\n allocator. The parser must be freed using ghostty_vt_osc_free() when\n no longer needed.\n\n @param allocator Pointer to the allocator to use for memory management, or NULL to use the default allocator\n @param parser Pointer to store the created parser handle\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup osc"]
pub fn ghostty_osc_new(
allocator: *const GhosttyAllocator,
parser: *mut GhosttyOscParser,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free an OSC parser instance.\n\n Releases all resources associated with the OSC parser. After this call,\n the parser handle becomes invalid and must not be used.\n\n @param parser The parser handle to free (may be NULL)\n\n @ingroup osc"]
pub fn ghostty_osc_free(parser: GhosttyOscParser);
}
unsafe extern "C" {
#[doc = " Reset an OSC parser instance to its initial state.\n\n Resets the parser state, clearing any partially parsed OSC sequences\n and returning the parser to its initial state. This is useful for\n reusing a parser instance or recovering from parse errors.\n\n @param parser The parser handle to reset, must not be null.\n\n @ingroup osc"]
pub fn ghostty_osc_reset(parser: GhosttyOscParser);
}
unsafe extern "C" {
#[doc = " Set an option on an OSC parser.\n\n `value` points to the option's input type, which is listed in the\n documentation for each GhosttyOscOption value. Pass NULL to restore the\n option's default.\n\n Options stay set across ghostty_osc_reset(). You can change an option\n at any time, but a sequence that is already being parsed may keep the\n old setting. It is simplest to set options before the first sequence.\n\n @param parser The parser handle\n @param option The option to set\n @param value Pointer to the new value, or NULL to restore the default\n @return GHOSTTY_SUCCESS on success, or GHOSTTY_INVALID_VALUE if the parser\n is NULL\n\n @ingroup osc"]
pub fn ghostty_osc_set(
parser: GhosttyOscParser,
option: GhosttyOscOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Parse the next byte in an OSC sequence.\n\n Processes a single byte as part of an OSC sequence. The parser maintains\n internal state to track the progress through the sequence. Call this\n function for each byte in the sequence data.\n\n When finished pumping the parser with bytes, call ghostty_osc_end\n to get the final result.\n\n @param parser The parser handle, must not be null.\n @param byte The next byte to parse\n\n @ingroup osc"]
pub fn ghostty_osc_next(parser: GhosttyOscParser, byte: u8);
}
unsafe extern "C" {
#[doc = " Finalize OSC parsing and retrieve the parsed command.\n\n Call this after feeding every byte of the sequence to ghostty_osc_next(),\n except the byte that ended it. Pass that byte here as the terminator.\n\n If the sequence is not a valid command, this returns NULL. You don't need\n to check for NULL before calling ghostty_osc_command_type(), which\n returns GHOSTTY_OSC_COMMAND_INVALID for it.\n\n Commands that reply to the program, such as color queries, end their\n reply the same way the request ended. A terminator of 0x07 (BEL) gets a\n BEL reply, and any other byte gets an ST reply. Commands that don't\n reply ignore the terminator.\n\n If the program cancelled the sequence with CAN (0x18) or SUB (0x1A),\n pass that byte as the terminator. The sequence is then discarded and\n this returns NULL, whatever command it contained. This matches xterm.\n The \"Ending a Sequence\" section of the overview has an example.\n\n The returned command handle is valid until the next call to any\n `ghostty_osc_*` function with the same parser instance with the exception\n of command introspection functions such as `ghostty_osc_command_type`.\n\n @param parser The parser handle, must not be null.\n @param terminator The byte that ended the OSC sequence: 0x07 for BEL,\n 0x5C for ST, or 0x18 (CAN) or 0x1A (SUB) if it was cancelled\n @return Handle to the parsed OSC command, or NULL if the sequence is not\n a valid command or was cancelled\n\n @ingroup osc"]
pub fn ghostty_osc_end(parser: GhosttyOscParser, terminator: u8) -> GhosttyOscCommand;
}
unsafe extern "C" {
#[doc = " Get the type of an OSC command.\n\n Returns the type identifier for the given OSC command. This can be used\n to determine what kind of command was parsed and what data might be\n available from it.\n\n @param command The OSC command handle to query (may be NULL)\n @return The command type, or GHOSTTY_OSC_COMMAND_INVALID if command is NULL\n\n @ingroup osc"]
pub fn ghostty_osc_command_type(command: GhosttyOscCommand) -> GhosttyOscCommandType::Type;
}
unsafe extern "C" {
#[doc = " Extract data from an OSC command.\n\n Extracts typed data from the given OSC command based on the specified\n data type. The output pointer must be of the appropriate type for the\n requested data kind. Valid command types, output types, and memory\n safety information are documented in the `GhosttyOscCommandData` enum.\n\n @param command The OSC command handle to query (may be NULL)\n @param data The type of data to extract\n @param out Pointer to store the extracted data (type depends on data parameter)\n @return true if data extraction was successful, false otherwise\n\n @ingroup osc"]
pub fn ghostty_osc_command_data(
command: GhosttyOscCommand,
data: GhosttyOscCommandData::Type,
out: *mut ::std::os::raw::c_void,
) -> bool;
}
pub mod GhosttySizeReportStyle {
#[doc = " Size report style.\n\n Determines the output format for the terminal size report."]
pub type Type = ::std::os::raw::c_int;
#[doc = " In-band size report (mode 2048): ESC [ 48 ; rows ; cols ; height ; width t"]
pub const GHOSTTY_SIZE_REPORT_MODE_2048: Type = 0;
#[doc = " XTWINOPS text area size in pixels: ESC [ 4 ; height ; width t"]
pub const GHOSTTY_SIZE_REPORT_CSI_14_T: Type = 1;
#[doc = " XTWINOPS cell size in pixels: ESC [ 6 ; height ; width t"]
pub const GHOSTTY_SIZE_REPORT_CSI_16_T: Type = 2;
#[doc = " XTWINOPS text area size in characters: ESC [ 8 ; rows ; cols t"]
pub const GHOSTTY_SIZE_REPORT_CSI_18_T: Type = 3;
#[doc = " XTWINOPS screen size in characters: ESC [ 9 ; rows ; cols t\n\n The physical screen size is not known, so this reports the text\n area size in characters, the same as CSI 18 t."]
pub const GHOSTTY_SIZE_REPORT_CSI_19_T: Type = 4;
#[doc = " XTWINOPS screen size in characters: ESC [ 9 ; rows ; cols t\n\n The physical screen size is not known, so this reports the text\n area size in characters, the same as CSI 18 t."]
pub const GHOSTTY_SIZE_REPORT_STYLE_MAX_VALUE: Type = 2147483647;
}
#[doc = " Terminal size information for encoding size reports."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttySizeReportSize {
#[doc = " Terminal row count in cells."]
pub rows: u16,
#[doc = " Terminal column count in cells."]
pub columns: u16,
#[doc = " Width of a single terminal cell in pixels."]
pub cell_width: u32,
#[doc = " Height of a single terminal cell in pixels."]
pub cell_height: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySizeReportSize"][::std::mem::size_of::<GhosttySizeReportSize>() - 12usize];
["Alignment of GhosttySizeReportSize"]
[::std::mem::align_of::<GhosttySizeReportSize>() - 4usize];
["Offset of field: GhosttySizeReportSize::rows"]
[::std::mem::offset_of!(GhosttySizeReportSize, rows) - 0usize];
["Offset of field: GhosttySizeReportSize::columns"]
[::std::mem::offset_of!(GhosttySizeReportSize, columns) - 2usize];
["Offset of field: GhosttySizeReportSize::cell_width"]
[::std::mem::offset_of!(GhosttySizeReportSize, cell_width) - 4usize];
["Offset of field: GhosttySizeReportSize::cell_height"]
[::std::mem::offset_of!(GhosttySizeReportSize, cell_height) - 8usize];
};
unsafe extern "C" {
#[doc = " Encode a terminal size report into an escape sequence.\n\n Encodes a size report in the format specified by @p style into the\n provided buffer.\n\n If the buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE\n and writes the required buffer size to @p out_written. The caller can\n then retry with a sufficiently sized buffer.\n\n @param style The size report format to encode\n @param size Terminal size information\n @param buf Output buffer to write the encoded sequence into (may be NULL)\n @param buf_len Size of the output buffer in bytes\n @param[out] out_written On success, the number of bytes written. On\n GHOSTTY_OUT_OF_SPACE, the required buffer size.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if the buffer\n is too small"]
pub fn ghostty_size_report_encode(
style: GhosttySizeReportStyle::Type,
size: GhosttySizeReportSize,
buf: *mut ::std::os::raw::c_char,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
pub mod GhosttyKittyGraphicsData {
#[doc = " Queryable data kinds for ghostty_kitty_graphics_get().\n\n @ingroup kitty_graphics"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid / sentinel value."]
pub const GHOSTTY_KITTY_GRAPHICS_DATA_INVALID: Type = 0;
#[doc = " Populate a pre-allocated placement iterator with placement data from\n the storage. Iterator data is only valid as long as the underlying\n terminal is not mutated.\n\n Output type: GhosttyKittyGraphicsPlacementIterator *"]
pub const GHOSTTY_KITTY_GRAPHICS_DATA_PLACEMENT_ITERATOR: Type = 1;
#[doc = " Generation stamp of the last content mutation to this storage:\n any image transmit/replace, placement add, or delete. Zero means\n the storage has never been mutated (and is therefore empty).\n\n If the generation is unchanged since a previous query, the set of\n placements and all image data are identical, so placement iteration\n and image staleness checks can be skipped entirely. Note that\n placement *geometry* may still have changed (scrolling and resizing\n move placements without changing the storage contents), so rendering\n geometry such as ghostty_kitty_graphics_placement_render_info()\n must still be recomputed for frames marked dirty.\n\n Stamps are unique and monotonically increasing process-wide: a\n value observed from any storage never recurs for different content,\n even across screen switches (main vs. alternate screen have\n independent storages) or terminal resets. It is therefore safe to\n key caches on this value alone.\n\n Output type: uint64_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_DATA_GENERATION: Type = 2;
#[doc = " Generation stamp of the last content mutation to this storage:\n any image transmit/replace, placement add, or delete. Zero means\n the storage has never been mutated (and is therefore empty).\n\n If the generation is unchanged since a previous query, the set of\n placements and all image data are identical, so placement iteration\n and image staleness checks can be skipped entirely. Note that\n placement *geometry* may still have changed (scrolling and resizing\n move placements without changing the storage contents), so rendering\n geometry such as ghostty_kitty_graphics_placement_render_info()\n must still be recomputed for frames marked dirty.\n\n Stamps are unique and monotonically increasing process-wide: a\n value observed from any storage never recurs for different content,\n even across screen switches (main vs. alternate screen have\n independent storages) or terminal resets. It is therefore safe to\n key caches on this value alone.\n\n Output type: uint64_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_DATA_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyKittyGraphicsPlacementData {
#[doc = " Queryable data kinds for ghostty_kitty_graphics_placement_get().\n\n @ingroup kitty_graphics"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid / sentinel value."]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_INVALID: Type = 0;
#[doc = " The image ID this placement belongs to.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_IMAGE_ID: Type = 1;
#[doc = " The placement ID.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_PLACEMENT_ID: Type = 2;
#[doc = " Whether this is a virtual placement (unicode placeholder).\n\n Output type: bool *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_IS_VIRTUAL: Type = 3;
#[doc = " Pixel offset from the left edge of the cell.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_X_OFFSET: Type = 4;
#[doc = " Pixel offset from the top edge of the cell.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_Y_OFFSET: Type = 5;
#[doc = " Source rectangle x origin in pixels.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_X: Type = 6;
#[doc = " Source rectangle y origin in pixels.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_Y: Type = 7;
#[doc = " Source rectangle width in pixels (0 = full image width).\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_WIDTH: Type = 8;
#[doc = " Source rectangle height in pixels (0 = full image height).\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_SOURCE_HEIGHT: Type = 9;
#[doc = " Number of columns this placement occupies.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_COLUMNS: Type = 10;
#[doc = " Number of rows this placement occupies.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_ROWS: Type = 11;
#[doc = " Z-index for this placement.\n\n Output type: int32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_Z: Type = 12;
#[doc = " Z-index for this placement.\n\n Output type: int32_t *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyKittyPlacementLayer {
#[doc = " Z-layer classification for kitty graphics placements.\n\n Based on the kitty protocol z-index conventions:\n - BELOW_BG: z < INT32_MIN/2 (drawn below cell background)\n - BELOW_TEXT: INT32_MIN/2 <= z < 0 (above background, below text)\n - ABOVE_TEXT: z >= 0 (above text)\n - ALL: no filtering (current behavior)\n\n @ingroup kitty_graphics"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_KITTY_PLACEMENT_LAYER_ALL: Type = 0;
pub const GHOSTTY_KITTY_PLACEMENT_LAYER_BELOW_BG: Type = 1;
pub const GHOSTTY_KITTY_PLACEMENT_LAYER_BELOW_TEXT: Type = 2;
pub const GHOSTTY_KITTY_PLACEMENT_LAYER_ABOVE_TEXT: Type = 3;
pub const GHOSTTY_KITTY_PLACEMENT_LAYER_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyKittyGraphicsPlacementIteratorOption {
#[doc = " Settable options for ghostty_kitty_graphics_placement_iterator_set().\n\n @ingroup kitty_graphics"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Set the z-layer filter for the iterator.\n\n Input type: GhosttyKittyPlacementLayer *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPTION_LAYER: Type = 0;
#[doc = " Set the z-layer filter for the iterator.\n\n Input type: GhosttyKittyPlacementLayer *"]
pub const GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPTION_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyKittyImageFormat {
#[doc = " Pixel format of a Kitty graphics image.\n\n Note that stored images are always fully decoded:\n GHOSTTY_KITTY_IMAGE_FORMAT_PNG is never returned by\n ghostty_kitty_graphics_image_get() because PNG payloads are decoded\n to GHOSTTY_KITTY_IMAGE_FORMAT_RGBA before storage. The PNG value\n exists only for protocol-level completeness.\n\n @ingroup kitty_graphics"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_KITTY_IMAGE_FORMAT_RGB: Type = 0;
pub const GHOSTTY_KITTY_IMAGE_FORMAT_RGBA: Type = 1;
pub const GHOSTTY_KITTY_IMAGE_FORMAT_PNG: Type = 2;
pub const GHOSTTY_KITTY_IMAGE_FORMAT_GRAY_ALPHA: Type = 3;
pub const GHOSTTY_KITTY_IMAGE_FORMAT_GRAY: Type = 4;
pub const GHOSTTY_KITTY_IMAGE_FORMAT_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyKittyImageCompression {
#[doc = " Compression of a Kitty graphics image.\n\n Note that stored images are always decompressed:\n GHOSTTY_KITTY_IMAGE_COMPRESSION_ZLIB_DEFLATE payloads are inflated\n before storage, so ghostty_kitty_graphics_image_get() always reports\n GHOSTTY_KITTY_IMAGE_COMPRESSION_NONE. Consumers never need to\n inflate image data themselves.\n\n @ingroup kitty_graphics"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_KITTY_IMAGE_COMPRESSION_NONE: Type = 0;
pub const GHOSTTY_KITTY_IMAGE_COMPRESSION_ZLIB_DEFLATE: Type = 1;
pub const GHOSTTY_KITTY_IMAGE_COMPRESSION_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyKittyGraphicsImageData {
#[doc = " Queryable data kinds for ghostty_kitty_graphics_image_get().\n\n @ingroup kitty_graphics"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid / sentinel value."]
pub const GHOSTTY_KITTY_IMAGE_DATA_INVALID: Type = 0;
#[doc = " The image ID.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_ID: Type = 1;
#[doc = " The image number.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_NUMBER: Type = 2;
#[doc = " Image width in pixels.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_WIDTH: Type = 3;
#[doc = " Image height in pixels.\n\n Output type: uint32_t *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_HEIGHT: Type = 4;
#[doc = " Pixel format of the image. Never GHOSTTY_KITTY_IMAGE_FORMAT_PNG;\n PNG payloads are decoded to RGBA before storage.\n\n Output type: GhosttyKittyImageFormat *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_FORMAT: Type = 5;
#[doc = " Compression of the image. Always\n GHOSTTY_KITTY_IMAGE_COMPRESSION_NONE; compressed payloads are\n inflated before storage.\n\n Output type: GhosttyKittyImageCompression *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_COMPRESSION: Type = 6;
#[doc = " Borrowed pointer to the raw pixel data. Valid as long as the\n underlying terminal is not mutated. Returns GHOSTTY_NO_VALUE when\n the image metadata is resident but its pixel payload is pending.\n\n The data is always fully decoded, uncompressed pixels in the\n format reported by GHOSTTY_KITTY_IMAGE_DATA_FORMAT: zlib payloads\n are inflated and PNG payloads are decoded to RGBA at transmission\n time, before the image is stored. Consumers can upload this\n directly to the GPU without any decode step.\n\n For an animated image (Kitty graphics animation, actions a=f/a=a)\n this is the pixel data of the current animation frame. The\n image's GHOSTTY_KITTY_IMAGE_DATA_GENERATION changes whenever the\n current frame changes, so generation-keyed caches remain\n coherent.\n\n Output type: const uint8_t **"]
pub const GHOSTTY_KITTY_IMAGE_DATA_DATA_PTR: Type = 7;
#[doc = " Length of the raw pixel data in bytes. Always equal to\n width * height * bytes-per-pixel for the reported format. For a\n pending image, this is the expected length reserved against the\n storage limit even though DATA_PTR is not available yet.\n\n Output type: size_t *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_DATA_LEN: Type = 8;
#[doc = " Generation stamp assigned when this image was added to (or\n replaced in) the storage. A changed generation for a given image\n ID means the pixel contents may have changed even when the\n dimensions, format, and data length are identical (e.g. a\n retransmission of the same image ID), so texture caches must key\n staleness on this value rather than on size heuristics.\n\n Stamps are unique and monotonically increasing process-wide and\n are drawn from the same sequence as\n GHOSTTY_KITTY_GRAPHICS_DATA_GENERATION. Never zero for a stored\n image, so zero can be used as an \"empty\" sentinel by callers. Pending\n payload completion preserves this value to retain image age; consumers\n detect that completion through GHOSTTY_KITTY_GRAPHICS_DATA_GENERATION\n and retry DATA_PTR.\n\n Output type: uint64_t *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_GENERATION: Type = 9;
#[doc = " Generation stamp assigned when this image was added to (or\n replaced in) the storage. A changed generation for a given image\n ID means the pixel contents may have changed even when the\n dimensions, format, and data length are identical (e.g. a\n retransmission of the same image ID), so texture caches must key\n staleness on this value rather than on size heuristics.\n\n Stamps are unique and monotonically increasing process-wide and\n are drawn from the same sequence as\n GHOSTTY_KITTY_GRAPHICS_DATA_GENERATION. Never zero for a stored\n image, so zero can be used as an \"empty\" sentinel by callers. Pending\n payload completion preserves this value to retain image age; consumers\n detect that completion through GHOSTTY_KITTY_GRAPHICS_DATA_GENERATION\n and retry DATA_PTR.\n\n Output type: uint64_t *"]
pub const GHOSTTY_KITTY_IMAGE_DATA_MAX_VALUE: Type = 2147483647;
}
#[doc = " Combined rendering geometry for a placement in a single sized struct.\n\n Combines the results of ghostty_kitty_graphics_placement_pixel_size(),\n ghostty_kitty_graphics_placement_grid_size(),\n ghostty_kitty_graphics_placement_viewport_pos(), and\n ghostty_kitty_graphics_placement_source_rect() into one call. This is\n an optimization over calling those four functions individually,\n particularly useful in environments with high per-call overhead such\n as FFI or Cgo.\n\n This struct uses the sized-struct ABI pattern. Initialize with\n GHOSTTY_INIT_SIZED(GhosttyKittyGraphicsPlacementRenderInfo) before calling\n ghostty_kitty_graphics_placement_render_info().\n\n @ingroup kitty_graphics"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyKittyGraphicsPlacementRenderInfo {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyKittyGraphicsPlacementRenderInfo)."]
pub size: usize,
#[doc = " Rendered width in pixels."]
pub pixel_width: u32,
#[doc = " Rendered height in pixels."]
pub pixel_height: u32,
#[doc = " Number of grid columns the placement occupies."]
pub grid_cols: u32,
#[doc = " Number of grid rows the placement occupies."]
pub grid_rows: u32,
#[doc = " Viewport-relative column (may be negative for partially visible placements)."]
pub viewport_col: i32,
#[doc = " Viewport-relative row (may be negative for partially visible placements)."]
pub viewport_row: i32,
#[doc = " False when the placement is fully off-screen or virtual."]
pub viewport_visible: bool,
#[doc = " Resolved source rectangle x origin in pixels."]
pub source_x: u32,
#[doc = " Resolved source rectangle y origin in pixels."]
pub source_y: u32,
#[doc = " Resolved source rectangle width in pixels."]
pub source_width: u32,
#[doc = " Resolved source rectangle height in pixels."]
pub source_height: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyKittyGraphicsPlacementRenderInfo"]
[::std::mem::size_of::<GhosttyKittyGraphicsPlacementRenderInfo>() - 56usize];
["Alignment of GhosttyKittyGraphicsPlacementRenderInfo"]
[::std::mem::align_of::<GhosttyKittyGraphicsPlacementRenderInfo>() - 8usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::size"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, size) - 0usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::pixel_width"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, pixel_width) - 8usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::pixel_height"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, pixel_height) - 12usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::grid_cols"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, grid_cols) - 16usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::grid_rows"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, grid_rows) - 20usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::viewport_col"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, viewport_col) - 24usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::viewport_row"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, viewport_row) - 28usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::viewport_visible"][::std::mem::offset_of!(
GhosttyKittyGraphicsPlacementRenderInfo,
viewport_visible
) - 32usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::source_x"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, source_x) - 36usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::source_y"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, source_y) - 40usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::source_width"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, source_width) - 44usize];
["Offset of field: GhosttyKittyGraphicsPlacementRenderInfo::source_height"]
[::std::mem::offset_of!(GhosttyKittyGraphicsPlacementRenderInfo, source_height) - 48usize];
};
unsafe extern "C" {
#[doc = " Get data from a kitty graphics storage instance.\n\n The output pointer must be of the appropriate type for the requested\n data kind.\n\n Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.\n\n @param graphics The kitty graphics handle\n @param data The type of data to extract\n @param[out] out Pointer to store the extracted data\n @return GHOSTTY_SUCCESS on success\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_get(
graphics: GhosttyKittyGraphics,
data: GhosttyKittyGraphicsData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Look up a Kitty graphics image by its image ID.\n\n Returns NULL if no image with the given ID exists or if Kitty graphics\n are disabled at build time.\n\n @param graphics The kitty graphics handle\n @param image_id The image ID to look up\n @return An opaque image handle, or NULL if not found\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_image(
graphics: GhosttyKittyGraphics,
image_id: u32,
) -> GhosttyKittyGraphicsImage;
}
unsafe extern "C" {
#[doc = " Get data from a Kitty graphics image.\n\n The output pointer must be of the appropriate type for the requested\n data kind.\n\n @param image The image handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param data The data kind to query\n @param[out] out Pointer to receive the queried value\n @return GHOSTTY_SUCCESS on success\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_image_get(
image: GhosttyKittyGraphicsImage,
data: GhosttyKittyGraphicsImageData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple data fields from a Kitty graphics image in a single call.\n\n This is an optimization over calling ghostty_kitty_graphics_image_get()\n repeatedly, particularly useful in environments with high per-call\n overhead such as FFI or Cgo.\n\n Each element in the keys array specifies a data kind, and the\n corresponding element in the values array receives the result.\n The type of each values[i] pointer must match the output type\n documented for keys[i].\n\n Processing stops at the first error; on success out_written\n is set to count, on error it is set to the index of the\n failing key (i.e. the number of values successfully written).\n\n @param image The image handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers (types must match each key's\n documented output type)\n @param[out] out_written On return, receives the number of values\n successfully written (may be NULL)\n @return GHOSTTY_SUCCESS if all queries succeed\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_image_get_multi(
image: GhosttyKittyGraphicsImage,
count: usize,
keys: *const GhosttyKittyGraphicsImageData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Create a new placement iterator instance.\n\n All fields except the allocator are left undefined until populated\n via ghostty_kitty_graphics_get() with\n GHOSTTY_KITTY_GRAPHICS_DATA_PLACEMENT_ITERATOR.\n\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param[out] out_iterator On success, receives the created iterator handle\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_MEMORY on allocation\n failure\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_iterator_new(
allocator: *const GhosttyAllocator,
out_iterator: *mut GhosttyKittyGraphicsPlacementIterator,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a placement iterator.\n\n @param iterator The iterator handle to free (may be NULL)\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_iterator_free(
iterator: GhosttyKittyGraphicsPlacementIterator,
);
}
unsafe extern "C" {
#[doc = " Set an option on a placement iterator.\n\n Use GHOSTTY_KITTY_GRAPHICS_PLACEMENT_ITERATOR_OPTION_LAYER with a\n GhosttyKittyPlacementLayer value to filter placements by z-layer.\n The filter is applied during iteration: ghostty_kitty_graphics_placement_next()\n will skip placements that do not match the configured layer.\n\n The default layer is GHOSTTY_KITTY_PLACEMENT_LAYER_ALL (no filtering).\n\n @param iterator The iterator handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param option The option to set\n @param value Pointer to the value (type depends on option; NULL returns\n GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_iterator_set(
iterator: GhosttyKittyGraphicsPlacementIterator,
option: GhosttyKittyGraphicsPlacementIteratorOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Advance the placement iterator to the next placement.\n\n If a layer filter has been set via\n ghostty_kitty_graphics_placement_iterator_set(), only placements\n matching that layer are returned.\n\n @param iterator The iterator handle (may be NULL)\n @return true if advanced to the next placement, false if at the end\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_next(
iterator: GhosttyKittyGraphicsPlacementIterator,
) -> bool;
}
unsafe extern "C" {
#[doc = " Get data from the current placement in a placement iterator.\n\n Call ghostty_kitty_graphics_placement_next() at least once before\n calling this function.\n\n @param iterator The iterator handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param data The data kind to query\n @param[out] out Pointer to receive the queried value\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the\n iterator is NULL or not positioned on a placement\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_get(
iterator: GhosttyKittyGraphicsPlacementIterator,
data: GhosttyKittyGraphicsPlacementData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple data fields from the current placement in a single call.\n\n This is an optimization over calling ghostty_kitty_graphics_placement_get()\n repeatedly, particularly useful in environments with high per-call\n overhead such as FFI or Cgo.\n\n Each element in the keys array specifies a data kind, and the\n corresponding element in the values array receives the result.\n The type of each values[i] pointer must match the output type\n documented for keys[i].\n\n Processing stops at the first error; on success out_written\n is set to count, on error it is set to the index of the\n failing key (i.e. the number of values successfully written).\n\n @param iterator The iterator handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers (types must match each key's\n documented output type)\n @param[out] out_written On return, receives the number of values\n successfully written (may be NULL)\n @return GHOSTTY_SUCCESS if all queries succeed\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_get_multi(
iterator: GhosttyKittyGraphicsPlacementIterator,
count: usize,
keys: *const GhosttyKittyGraphicsPlacementData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Compute the grid rectangle occupied by the current placement.\n\n Uses the placement's pin, the image dimensions, and the terminal's\n cell/pixel geometry to calculate the bounding rectangle. Virtual\n placements (unicode placeholders) return GHOSTTY_NO_VALUE.\n\n @param terminal The terminal handle\n @param image The image handle for this placement's image\n @param iterator The placement iterator positioned on a placement\n @param[out] out_selection On success, receives the bounding rectangle\n as a selection with rectangle=true\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if any handle\n is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE for\n virtual placements or when Kitty graphics are disabled\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_rect(
iterator: GhosttyKittyGraphicsPlacementIterator,
image: GhosttyKittyGraphicsImage,
terminal: GhosttyTerminal,
out_selection: *mut GhosttySelection,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Compute the rendered pixel size of the current placement.\n\n Takes into account the placement's source rectangle, specified\n columns/rows, and aspect ratio to calculate the final rendered\n pixel dimensions.\n\n @param iterator The placement iterator positioned on a placement\n @param image The image handle for this placement's image\n @param terminal The terminal handle\n @param[out] out_width On success, receives the width in pixels\n @param[out] out_height On success, receives the height in pixels\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if any handle\n is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE when\n Kitty graphics are disabled\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_pixel_size(
iterator: GhosttyKittyGraphicsPlacementIterator,
image: GhosttyKittyGraphicsImage,
terminal: GhosttyTerminal,
out_width: *mut u32,
out_height: *mut u32,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Compute the grid cell size of the current placement.\n\n Returns the number of columns and rows that the placement occupies\n in the terminal grid. If the placement specifies explicit columns\n and rows, those are returned directly; otherwise they are calculated\n from the pixel size and cell dimensions.\n\n @param iterator The placement iterator positioned on a placement\n @param image The image handle for this placement's image\n @param terminal The terminal handle\n @param[out] out_cols On success, receives the number of columns\n @param[out] out_rows On success, receives the number of rows\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if any handle\n is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE when\n Kitty graphics are disabled\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_grid_size(
iterator: GhosttyKittyGraphicsPlacementIterator,
image: GhosttyKittyGraphicsImage,
terminal: GhosttyTerminal,
out_cols: *mut u32,
out_rows: *mut u32,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the viewport-relative grid position of the current placement.\n\n Converts the placement's internal pin to viewport-relative column and\n row coordinates. The returned coordinates represent the top-left\n corner of the placement in the viewport's grid coordinate space.\n\n The row value can be negative when the placement's origin has\n scrolled above the top of the viewport. For example, a 4-row\n image that has scrolled up by 2 rows returns row=-2, meaning\n its top 2 rows are above the visible area but its bottom 2 rows\n are still on screen. Embedders should use these coordinates\n directly when computing the destination rectangle for rendering;\n the embedder is responsible for clipping the portion of the image\n that falls outside the viewport.\n\n Returns GHOSTTY_SUCCESS for any placement that is at least\n partially visible in the viewport. Returns GHOSTTY_NO_VALUE when\n the placement is completely outside the viewport (its bottom edge\n is above the viewport or its top edge is at or below the last\n viewport row), or when the placement is a virtual (unicode\n placeholder) placement.\n\n @param iterator The placement iterator positioned on a placement\n @param image The image handle for this placement's image\n @param terminal The terminal handle\n @param[out] out_col On success, receives the viewport-relative column\n @param[out] out_row On success, receives the viewport-relative row\n (may be negative for partially visible placements)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if fully\n off-screen or virtual, GHOSTTY_INVALID_VALUE if any handle\n is NULL or the iterator is not positioned\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_viewport_pos(
iterator: GhosttyKittyGraphicsPlacementIterator,
image: GhosttyKittyGraphicsImage,
terminal: GhosttyTerminal,
out_col: *mut i32,
out_row: *mut i32,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the resolved source rectangle for the current placement.\n\n Applies kitty protocol semantics: a width or height of 0 in the\n placement means \"use the full image dimension\", and the resulting\n rectangle is clamped to the actual image bounds. The returned\n values are in pixels and are ready to use for texture sampling.\n\n @param iterator The placement iterator positioned on a placement\n @param image The image handle for this placement's image\n @param[out] out_x Source rect x origin in pixels\n @param[out] out_y Source rect y origin in pixels\n @param[out] out_width Source rect width in pixels\n @param[out] out_height Source rect height in pixels\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if any\n handle is NULL or the iterator is not positioned\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_source_rect(
iterator: GhosttyKittyGraphicsPlacementIterator,
image: GhosttyKittyGraphicsImage,
out_x: *mut u32,
out_y: *mut u32,
out_width: *mut u32,
out_height: *mut u32,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get all rendering geometry for a placement in a single call.\n\n Combines pixel size, grid size, viewport position, and source\n rectangle into one struct. Initialize with\n GHOSTTY_INIT_SIZED(GhosttyKittyGraphicsPlacementRenderInfo).\n\n When viewport_visible is false, the placement is fully off-screen\n or is a virtual placement; viewport_col and viewport_row may\n contain meaningless values in that case.\n\n @param iterator The iterator positioned on a placement\n @param image The image handle for this placement's image\n @param terminal The terminal handle\n @param[out] out_info Pointer to receive the rendering geometry\n @return GHOSTTY_SUCCESS on success\n\n @ingroup kitty_graphics"]
pub fn ghostty_kitty_graphics_placement_render_info(
iterator: GhosttyKittyGraphicsPlacementIterator,
image: GhosttyKittyGraphicsImage,
terminal: GhosttyTerminal,
out_info: *mut GhosttyKittyGraphicsPlacementRenderInfo,
) -> GhosttyResult::Type;
}
pub mod GhosttyTerminalCompressionMode {
#[doc = " Amount of compression work to perform before returning.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Perform one bounded compression step suitable for idle scheduling."]
pub const GHOSTTY_TERMINAL_COMPRESSION_MODE_INCREMENTAL: Type = 0;
#[doc = " Synchronously inspect every currently eligible page."]
pub const GHOSTTY_TERMINAL_COMPRESSION_MODE_FULL: Type = 1;
#[doc = " Synchronously inspect every currently eligible page."]
pub const GHOSTTY_TERMINAL_COMPRESSION_MODE_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyTerminalCompressionResult {
#[doc = " Scheduling result from terminal compression.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Retained-mapping reclamation is unavailable on this target."]
pub const GHOSTTY_TERMINAL_COMPRESSION_RESULT_UNSUPPORTED: Type = 0;
#[doc = " More incremental compression work remains."]
pub const GHOSTTY_TERMINAL_COMPRESSION_RESULT_PENDING: Type = 1;
#[doc = " The pass has no continuation to schedule."]
pub const GHOSTTY_TERMINAL_COMPRESSION_RESULT_COMPLETE: Type = 2;
#[doc = " The pass has no continuation to schedule."]
pub const GHOSTTY_TERMINAL_COMPRESSION_RESULT_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyTerminalScrollViewportTag {
#[doc = " Scroll viewport behavior tag.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Scroll to the top of the scrollback."]
pub const GHOSTTY_SCROLL_VIEWPORT_TOP: Type = 0;
#[doc = " Scroll to the bottom (active area)."]
pub const GHOSTTY_SCROLL_VIEWPORT_BOTTOM: Type = 1;
#[doc = " Scroll by a delta amount (up is negative)."]
pub const GHOSTTY_SCROLL_VIEWPORT_DELTA: Type = 2;
#[doc = " Scroll to an absolute row offset from the top of the scrollable\n area. Row 0 is the top of the scrollback and the requested row\n becomes the first visible row of the viewport. The value is\n clamped so the viewport never scrolls beyond the top of the\n active area. If the terminal has no scrollback (e.g. the\n alternate screen is active), the viewport always remains on the\n active area.\n\n This is the same row space as the offset field of\n GhosttyTerminalScrollbar, so a scrollbar position obtained from\n GHOSTTY_TERMINAL_DATA_SCROLLBAR round-trips cleanly."]
pub const GHOSTTY_SCROLL_VIEWPORT_ROW: Type = 3;
#[doc = " Scroll by a number of prompts relative to the viewport top. Negative\n values move backward and positive values move forward. Requires semantic\n prompt markers from the shell. Zero or no matching prompt is a no-op.\n If fewer prompts remain than requested, move to the last matching prompt,\n clamped to the active area.\n\n Moving forward through a final prompt continuation can snap to the active\n area even when there is no newer prompt."]
pub const GHOSTTY_SCROLL_VIEWPORT_DELTA_PROMPT: Type = 4;
#[doc = " Scroll by a number of prompts relative to the viewport top. Negative\n values move backward and positive values move forward. Requires semantic\n prompt markers from the shell. Zero or no matching prompt is a no-op.\n If fewer prompts remain than requested, move to the last matching prompt,\n clamped to the active area.\n\n Moving forward through a final prompt continuation can snap to the active\n area even when there is no newer prompt."]
pub const GHOSTTY_SCROLL_VIEWPORT_MAX_VALUE: Type = 2147483647;
}
#[doc = " Scroll viewport value.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union GhosttyTerminalScrollViewportValue {
#[doc = " Scroll delta (only used with GHOSTTY_SCROLL_VIEWPORT_DELTA). Up is negative."]
pub delta: isize,
#[doc = " Absolute row offset (only used with GHOSTTY_SCROLL_VIEWPORT_ROW)."]
pub row: usize,
#[doc = " Prompt delta (only used with GHOSTTY_SCROLL_VIEWPORT_DELTA_PROMPT)."]
pub delta_prompt: isize,
#[doc = " Padding for ABI compatibility. Do not use."]
pub _padding: [u64; 2usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalScrollViewportValue"]
[::std::mem::size_of::<GhosttyTerminalScrollViewportValue>() - 16usize];
["Alignment of GhosttyTerminalScrollViewportValue"]
[::std::mem::align_of::<GhosttyTerminalScrollViewportValue>() - 8usize];
["Offset of field: GhosttyTerminalScrollViewportValue::delta"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewportValue, delta) - 0usize];
["Offset of field: GhosttyTerminalScrollViewportValue::row"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewportValue, row) - 0usize];
["Offset of field: GhosttyTerminalScrollViewportValue::delta_prompt"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewportValue, delta_prompt) - 0usize];
["Offset of field: GhosttyTerminalScrollViewportValue::_padding"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewportValue, _padding) - 0usize];
};
impl Default for GhosttyTerminalScrollViewportValue {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Tagged union for scroll viewport behavior.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GhosttyTerminalScrollViewport {
pub tag: GhosttyTerminalScrollViewportTag::Type,
pub value: GhosttyTerminalScrollViewportValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalScrollViewport"]
[::std::mem::size_of::<GhosttyTerminalScrollViewport>() - 24usize];
["Alignment of GhosttyTerminalScrollViewport"]
[::std::mem::align_of::<GhosttyTerminalScrollViewport>() - 8usize];
["Offset of field: GhosttyTerminalScrollViewport::tag"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewport, tag) - 0usize];
["Offset of field: GhosttyTerminalScrollViewport::value"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewport, value) - 8usize];
};
impl Default for GhosttyTerminalScrollViewport {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub mod GhosttyTerminalScreen {
#[doc = " Terminal screen identifier.\n\n Identifies which screen buffer is active in the terminal.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " The primary (normal) screen."]
pub const GHOSTTY_TERMINAL_SCREEN_PRIMARY: Type = 0;
#[doc = " The alternate screen."]
pub const GHOSTTY_TERMINAL_SCREEN_ALTERNATE: Type = 1;
#[doc = " The alternate screen."]
pub const GHOSTTY_TERMINAL_SCREEN_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyTerminalCursorStyle {
#[doc = " Visual style of the terminal cursor.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Bar cursor (DECSCUSR 5, 6)."]
pub const GHOSTTY_TERMINAL_CURSOR_STYLE_BAR: Type = 0;
#[doc = " Block cursor (DECSCUSR 1, 2)."]
pub const GHOSTTY_TERMINAL_CURSOR_STYLE_BLOCK: Type = 1;
#[doc = " Underline cursor (DECSCUSR 3, 4)."]
pub const GHOSTTY_TERMINAL_CURSOR_STYLE_UNDERLINE: Type = 2;
#[doc = " Hollow block cursor."]
pub const GHOSTTY_TERMINAL_CURSOR_STYLE_BLOCK_HOLLOW: Type = 3;
#[doc = " Hollow block cursor."]
pub const GHOSTTY_TERMINAL_CURSOR_STYLE_MAX_VALUE: Type = 2147483647;
}
#[doc = " Scrollbar state for the terminal viewport.\n\n Represents the scrollable area dimensions needed to render a scrollbar.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyTerminalScrollbar {
#[doc = " Total size of the scrollable area in rows."]
pub total: u64,
#[doc = " Offset into the total area that the viewport is at."]
pub offset: u64,
#[doc = " Length of the visible area in rows."]
pub len: u64,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalScrollbar"]
[::std::mem::size_of::<GhosttyTerminalScrollbar>() - 24usize];
["Alignment of GhosttyTerminalScrollbar"]
[::std::mem::align_of::<GhosttyTerminalScrollbar>() - 8usize];
["Offset of field: GhosttyTerminalScrollbar::total"]
[::std::mem::offset_of!(GhosttyTerminalScrollbar, total) - 0usize];
["Offset of field: GhosttyTerminalScrollbar::offset"]
[::std::mem::offset_of!(GhosttyTerminalScrollbar, offset) - 8usize];
["Offset of field: GhosttyTerminalScrollbar::len"]
[::std::mem::offset_of!(GhosttyTerminalScrollbar, len) - 16usize];
};
#[doc = " Memory held by a terminal.\n\n Read with ghostty_terminal_get() and\n `GHOSTTY_TERMINAL_DATA_MEMORY_USAGE`. This helps applications that host\n many terminals stay within a memory budget, for example by compressing\n or closing the terminals that hold the most memory first.\n\n Most of a terminal's memory goes to its screen contents and scrollback,\n which are stored in fixed-size blocks called pages. Resident bytes are\n the physical memory pages use right now, and are the figure to budget\n against. Virtual bytes are the address space reserved for pages.\n Compressing scrollback lowers the resident figure but not the virtual\n one, because each page's space stays reserved for decompression.\n\n This is a sized struct. Set `size` before the call, most easily with\n GHOSTTY_INIT_SIZED(). Later versions of libghostty-vt may add fields to\n the end of this struct, and the size tells the library which version\n your program was compiled against. This lets older programs keep working\n with newer versions of the library.\n\n Each screen has its own set of fields, named with a `primary_` or\n `alternate_` prefix. The primary screen holds shell output and all of\n the scrollback. The alternate screen is used by full-screen programs\n such as text editors, and its fields are all zero until a program first\n switches to it. Add the two sets together for the terminal's total.\n\n Everything the terminal displays is stored inside pages, including\n colors, styles and hyperlinks, so those are already part of the page\n figures. Images are stored separately and have their own fields. Small\n structures outside of pages, such as the window title and internal\n bookkeeping, are not counted. They are small next to the pages once a\n terminal has any scrollback.\n\n On macOS, the operating system takes back memory freed by compression\n lazily, when something else needs it. Until then, the memory use the\n system reports for your process (its RSS) can be higher than the\n resident figures here.\n\n @snippet c-vt-compression/src/main.c memory-usage\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyTerminalMemoryUsage {
#[doc = " Size of this struct in bytes. Set by the caller."]
pub size: usize,
#[doc = " Whether compressing scrollback can free memory on this platform. When\n false, ghostty_terminal_compress() reports\n `GHOSTTY_TERMINAL_COMPRESSION_RESULT_UNSUPPORTED` and the compressed\n fields are always zero. To reduce a terminal's memory on such a\n platform, you have to do something else, such as closing it."]
pub compression_supported: bool,
#[doc = " Number of pages in the primary screen, including compressed pages."]
pub primary_pages: u64,
#[doc = " Bytes of address space reserved for the primary screen's pages. This\n includes compressed pages and spare pages kept ready for reuse.\n Always at least `primary_resident_bytes`."]
pub primary_virtual_bytes: u64,
#[doc = " Bytes of physical memory used by the primary screen's pages. A\n compressed page counts only its compressed size. Use this figure for\n memory budgets."]
pub primary_resident_bytes: u64,
#[doc = " Number of the primary screen's pages that are compressed."]
pub primary_compressed_pages: u64,
#[doc = " Bytes of compressed data held for the primary screen's compressed\n pages. This is already included in `primary_resident_bytes`."]
pub primary_compressed_bytes: u64,
#[doc = " Bytes of image data stored for the primary screen through the Kitty\n graphics protocol. This is not included in `primary_resident_bytes`.\n Always zero when libghostty-vt is built without Kitty graphics."]
pub primary_image_bytes: u64,
#[doc = " The same as `primary_pages`, for the alternate screen."]
pub alternate_pages: u64,
#[doc = " The same as `primary_virtual_bytes`, for the alternate screen."]
pub alternate_virtual_bytes: u64,
#[doc = " The same as `primary_resident_bytes`, for the alternate screen."]
pub alternate_resident_bytes: u64,
#[doc = " The same as `primary_compressed_pages`, for the alternate screen."]
pub alternate_compressed_pages: u64,
#[doc = " The same as `primary_compressed_bytes`, for the alternate screen."]
pub alternate_compressed_bytes: u64,
#[doc = " The same as `primary_image_bytes`, for the alternate screen."]
pub alternate_image_bytes: u64,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalMemoryUsage"]
[::std::mem::size_of::<GhosttyTerminalMemoryUsage>() - 112usize];
["Alignment of GhosttyTerminalMemoryUsage"]
[::std::mem::align_of::<GhosttyTerminalMemoryUsage>() - 8usize];
["Offset of field: GhosttyTerminalMemoryUsage::size"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, size) - 0usize];
["Offset of field: GhosttyTerminalMemoryUsage::compression_supported"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, compression_supported) - 8usize];
["Offset of field: GhosttyTerminalMemoryUsage::primary_pages"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, primary_pages) - 16usize];
["Offset of field: GhosttyTerminalMemoryUsage::primary_virtual_bytes"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, primary_virtual_bytes) - 24usize];
["Offset of field: GhosttyTerminalMemoryUsage::primary_resident_bytes"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, primary_resident_bytes) - 32usize];
["Offset of field: GhosttyTerminalMemoryUsage::primary_compressed_pages"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, primary_compressed_pages) - 40usize];
["Offset of field: GhosttyTerminalMemoryUsage::primary_compressed_bytes"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, primary_compressed_bytes) - 48usize];
["Offset of field: GhosttyTerminalMemoryUsage::primary_image_bytes"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, primary_image_bytes) - 56usize];
["Offset of field: GhosttyTerminalMemoryUsage::alternate_pages"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, alternate_pages) - 64usize];
["Offset of field: GhosttyTerminalMemoryUsage::alternate_virtual_bytes"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, alternate_virtual_bytes) - 72usize];
["Offset of field: GhosttyTerminalMemoryUsage::alternate_resident_bytes"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, alternate_resident_bytes) - 80usize];
["Offset of field: GhosttyTerminalMemoryUsage::alternate_compressed_pages"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, alternate_compressed_pages) - 88usize];
["Offset of field: GhosttyTerminalMemoryUsage::alternate_compressed_bytes"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, alternate_compressed_bytes) - 96usize];
["Offset of field: GhosttyTerminalMemoryUsage::alternate_image_bytes"]
[::std::mem::offset_of!(GhosttyTerminalMemoryUsage, alternate_image_bytes) - 104usize];
};
#[doc = " Callback function type for bell.\n\n Called when the terminal receives a BEL character (0x07).\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n\n @ingroup terminal"]
pub type GhosttyTerminalBellFn = ::std::option::Option<
unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::std::os::raw::c_void),
>;
pub mod GhosttyTerminalUnknownSequenceTag {
#[doc = " The kind of unsupported sequence passed to a\n GhosttyTerminalUnknownSequenceFn callback.\n\n New kinds may be added in later versions. Callbacks should ignore any\n tag they don't handle.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Application Program Command (APC)."]
pub const GHOSTTY_TERMINAL_UNKNOWN_SEQUENCE_APC: Type = 0;
#[doc = " Operating System Command (OSC). The value is in `value.osc`."]
pub const GHOSTTY_TERMINAL_UNKNOWN_SEQUENCE_OSC: Type = 1;
#[doc = " Operating System Command (OSC). The value is in `value.osc`."]
pub const GHOSTTY_TERMINAL_UNKNOWN_SEQUENCE_MAX_VALUE: Type = 2147483647;
}
#[doc = " An unsupported string terminal sequence.\n\n The content is borrowed and valid only for the callback duration. It\n contains the bytes between the sequence introducer and terminator, may\n contain arbitrary binary data, and is not null-terminated.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalUnknownStringSequence {
#[doc = " Whether content was shortened by the byte limit or allocation failure."]
pub truncated: bool,
#[doc = " Retained sequence content."]
pub content: GhosttyString,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalUnknownStringSequence"]
[::std::mem::size_of::<GhosttyTerminalUnknownStringSequence>() - 24usize];
["Alignment of GhosttyTerminalUnknownStringSequence"]
[::std::mem::align_of::<GhosttyTerminalUnknownStringSequence>() - 8usize];
["Offset of field: GhosttyTerminalUnknownStringSequence::truncated"]
[::std::mem::offset_of!(GhosttyTerminalUnknownStringSequence, truncated) - 0usize];
["Offset of field: GhosttyTerminalUnknownStringSequence::content"]
[::std::mem::offset_of!(GhosttyTerminalUnknownStringSequence, content) - 8usize];
};
impl Default for GhosttyTerminalUnknownStringSequence {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " An OSC sequence whose number libghostty-vt does not implement.\n\n OSC sequences start with `ESC ]`, followed by a number that identifies\n the command, usually a `;`, and then the command's data. The sequence\n ends with either BEL or ESC followed by a backslash. For example, a\n program might write:\n\n @code\n ESC ] 7400;status=busy BEL\n @endcode\n\n For that sequence, `content` is `7400;status=busy` and `terminator`\n is GHOSTTY_OSC_TERMINATOR_BEL. See the Unsupported Sequences section of\n the terminal documentation for a complete example.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalUnknownOscSequence {
#[doc = " True if the sequence was longer than\n GHOSTTY_TERMINAL_OPT_UNKNOWN_MAX_BYTES, or memory ran out while\n reading it. In that case `content` holds only the beginning of the\n sequence."]
pub truncated: bool,
#[doc = " Everything between `ESC ]` and the terminator, including the number\n at the start. The bytes are not null-terminated and are only valid\n until the callback returns. Copy them if you need them later."]
pub content: GhosttyString,
#[doc = " How the program ended the sequence. If you send a reply, end it the\n same way."]
pub terminator: GhosttyOscTerminator::Type,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalUnknownOscSequence"]
[::std::mem::size_of::<GhosttyTerminalUnknownOscSequence>() - 32usize];
["Alignment of GhosttyTerminalUnknownOscSequence"]
[::std::mem::align_of::<GhosttyTerminalUnknownOscSequence>() - 8usize];
["Offset of field: GhosttyTerminalUnknownOscSequence::truncated"]
[::std::mem::offset_of!(GhosttyTerminalUnknownOscSequence, truncated) - 0usize];
["Offset of field: GhosttyTerminalUnknownOscSequence::content"]
[::std::mem::offset_of!(GhosttyTerminalUnknownOscSequence, content) - 8usize];
["Offset of field: GhosttyTerminalUnknownOscSequence::terminator"]
[::std::mem::offset_of!(GhosttyTerminalUnknownOscSequence, terminator) - 24usize];
};
impl Default for GhosttyTerminalUnknownOscSequence {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Unsupported terminal sequence value.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union GhosttyTerminalUnknownSequenceValue {
#[doc = " Application Program Command (APC)."]
pub apc: GhosttyTerminalUnknownStringSequence,
#[doc = " Operating System Command (OSC)."]
pub osc: GhosttyTerminalUnknownOscSequence,
#[doc = " Padding for ABI compatibility. Do not use.\n\n 128 bytes leaves room for future structured sequence payloads, such as\n CSI with borrowed parameter, separator, and intermediate arrays, without\n changing the tagged union's ABI."]
pub _padding: [u64; 16usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalUnknownSequenceValue"]
[::std::mem::size_of::<GhosttyTerminalUnknownSequenceValue>() - 128usize];
["Alignment of GhosttyTerminalUnknownSequenceValue"]
[::std::mem::align_of::<GhosttyTerminalUnknownSequenceValue>() - 8usize];
["Offset of field: GhosttyTerminalUnknownSequenceValue::apc"]
[::std::mem::offset_of!(GhosttyTerminalUnknownSequenceValue, apc) - 0usize];
["Offset of field: GhosttyTerminalUnknownSequenceValue::osc"]
[::std::mem::offset_of!(GhosttyTerminalUnknownSequenceValue, osc) - 0usize];
["Offset of field: GhosttyTerminalUnknownSequenceValue::_padding"]
[::std::mem::offset_of!(GhosttyTerminalUnknownSequenceValue, _padding) - 0usize];
};
impl Default for GhosttyTerminalUnknownSequenceValue {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " An unsupported terminal sequence.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GhosttyTerminalUnknownSequence {
pub tag: GhosttyTerminalUnknownSequenceTag::Type,
pub value: GhosttyTerminalUnknownSequenceValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalUnknownSequence"]
[::std::mem::size_of::<GhosttyTerminalUnknownSequence>() - 136usize];
["Alignment of GhosttyTerminalUnknownSequence"]
[::std::mem::align_of::<GhosttyTerminalUnknownSequence>() - 8usize];
["Offset of field: GhosttyTerminalUnknownSequence::tag"]
[::std::mem::offset_of!(GhosttyTerminalUnknownSequence, tag) - 0usize];
["Offset of field: GhosttyTerminalUnknownSequence::value"]
[::std::mem::offset_of!(GhosttyTerminalUnknownSequence, value) - 8usize];
};
impl Default for GhosttyTerminalUnknownSequence {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Callback function type for unsupported terminal sequences.\n\n Called once for each complete sequence that libghostty-vt does not\n implement. Check `sequence->tag` first, because more kinds of sequences\n may be reported in later versions.\n\n These are not reported:\n\n - Sequences the program cancelled partway through with CAN or SUB.\n - Sequences libghostty-vt implements, even when their contents are\n malformed.\n - Supported protocols that the embedder turned off.\n\n The callback runs during ghostty_terminal_vt_write(). It may write a reply\n to the pty, and that reply stays in order with the terminal's own\n replies. It must not call ghostty_terminal_vt_write() on the same\n terminal.\n\n Nothing is reported until GHOSTTY_TERMINAL_OPT_UNKNOWN_MAX_BYTES is also\n set to a nonzero value. Installing the callback by itself keeps no data\n and allocates no memory.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param sequence Borrowed unsupported sequence\n\n @ingroup terminal"]
pub type GhosttyTerminalUnknownSequenceFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
sequence: *const GhosttyTerminalUnknownSequence,
),
>;
pub mod GhosttyClipboardLocation {
#[doc = " Clipboard destination for a clipboard write.\n\n Protocol-specific destination identifiers are normalized to these values\n before the clipboard write callback is invoked.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " The standard system clipboard."]
pub const GHOSTTY_CLIPBOARD_LOCATION_STANDARD: Type = 0;
#[doc = " The selection clipboard."]
pub const GHOSTTY_CLIPBOARD_LOCATION_SELECTION: Type = 1;
#[doc = " The primary selection clipboard."]
pub const GHOSTTY_CLIPBOARD_LOCATION_PRIMARY: Type = 2;
#[doc = " The primary selection clipboard."]
pub const GHOSTTY_CLIPBOARD_LOCATION_MAX_VALUE: Type = 2147483647;
}
#[doc = " One MIME representation in a clipboard write.\n\n Both strings are borrowed and valid only for the duration of the callback.\n The data is binary-safe and has already been decoded from any protocol-level\n encoding. A zero-length data string is an explicit empty representation; it\n does not clear the clipboard.\n\n This struct has a frozen layout and will not gain fields in future versions.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyClipboardContent {
#[doc = " MIME type of the representation."]
pub mime: GhosttyString,
#[doc = " Decoded, binary-safe representation data."]
pub data: GhosttyString,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyClipboardContent"][::std::mem::size_of::<GhosttyClipboardContent>() - 32usize];
["Alignment of GhosttyClipboardContent"]
[::std::mem::align_of::<GhosttyClipboardContent>() - 8usize];
["Offset of field: GhosttyClipboardContent::mime"]
[::std::mem::offset_of!(GhosttyClipboardContent, mime) - 0usize];
["Offset of field: GhosttyClipboardContent::data"]
[::std::mem::offset_of!(GhosttyClipboardContent, data) - 16usize];
};
impl Default for GhosttyClipboardContent {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub mod GhosttyClipboardWriteResult {
#[doc = " Result of a clipboard write reply.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " The clipboard write completed successfully."]
pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_SUCCESS: Type = 0;
#[doc = " The clipboard write was denied by policy or the user."]
pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_DENIED: Type = 1;
#[doc = " The destination or one or more representations are unsupported."]
pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_UNSUPPORTED: Type = 2;
#[doc = " The clipboard is temporarily unavailable."]
pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_BUSY: Type = 3;
#[doc = " One or more representations contain invalid data."]
pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_INVALID_DATA: Type = 4;
#[doc = " The clipboard write failed due to an I/O error."]
pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_IO_ERROR: Type = 5;
#[doc = " The clipboard write failed due to an I/O error."]
pub const GHOSTTY_CLIPBOARD_WRITE_RESULT_MAX_VALUE: Type = 2147483647;
}
#[doc = " The reply to a clipboard write request.\n\n This is a sized struct; set `size` to `sizeof(GhosttyClipboardWriteReply)`.\n The reply is borrowed only for the duration of the reply call and may be\n freed as soon as it returns.\n\n The result answers the program with the matching protocol status for\n protocols with a write acknowledgement (OSC 5522: DONE, EPERM, ENOSYS,\n EBUSY, EINVAL, EIO); protocols without one (OSC 52, OSC 1337 Copy)\n discard the reply. `remember` is ignored on any result other than\n GHOSTTY_CLIPBOARD_WRITE_RESULT_SUCCESS.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyClipboardWriteReply {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " Outcome of the write."]
pub result: GhosttyClipboardWriteResult::Type,
#[doc = " Record a session grant so future requests from the same program skip\n the permission prompt. Only honored on success when\n GhosttyClipboardWrite::can_remember is set."]
pub remember: bool,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyClipboardWriteReply"]
[::std::mem::size_of::<GhosttyClipboardWriteReply>() - 16usize];
["Alignment of GhosttyClipboardWriteReply"]
[::std::mem::align_of::<GhosttyClipboardWriteReply>() - 8usize];
["Offset of field: GhosttyClipboardWriteReply::size"]
[::std::mem::offset_of!(GhosttyClipboardWriteReply, size) - 0usize];
["Offset of field: GhosttyClipboardWriteReply::result"]
[::std::mem::offset_of!(GhosttyClipboardWriteReply, result) - 8usize];
["Offset of field: GhosttyClipboardWriteReply::remember"]
[::std::mem::offset_of!(GhosttyClipboardWriteReply, remember) - 12usize];
};
impl Default for GhosttyClipboardWriteReply {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Function type used to answer a clipboard write request. Obtained from\n GhosttyClipboardWrite::reply; see that struct for the contract.\n\n @param write The request being answered\n @param reply The reply, borrowed only for the duration of this call\n\n @ingroup terminal"]
pub type GhosttyClipboardWriteReplyFn = ::std::option::Option<
unsafe extern "C" fn(
write: *const GhosttyClipboardWrite,
reply: *const GhosttyClipboardWriteReply,
),
>;
#[doc = " A synchronous request to write clipboard contents.\n\n This is a sized struct. The callback must only access fields present in the\n size reported by `size`. The request, contents array, MIME strings, and\n data strings are all borrowed and valid only for the callback duration.\n\n All entries in `contents` are representations of the same logical value\n and must be committed atomically. A `contents_len` of zero requests that\n the destination be cleared. This is distinct from a content entry whose data\n has zero length.\n\n The write is answered by calling `reply` with this request and a\n GhosttyClipboardWriteReply. This must happen within the clipboard write\n request callback. This struct is only valid during that time. Calling\n `reply` more than once is safely ignored. Returning without replying\n denies the write.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyClipboardWrite {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " Clipboard destination."]
pub location: GhosttyClipboardLocation::Type,
#[doc = " Borrowed array of MIME representations."]
pub contents: *const GhosttyClipboardContent,
#[doc = " Number of entries in contents; zero means clear the destination."]
pub contents_len: usize,
#[doc = " Name of the writing program for permission prompts, if the protocol\n carries one. Empty otherwise."]
pub name: GhosttyString,
#[doc = " True if the terminal already holds a session grant for this request\n The embedder should skip any permission prompt and perform the write."]
pub granted: bool,
#[doc = " True if the program supplied a session password, so the embedder may\n offer to remember the user's decision through\n GhosttyClipboardWriteReply::remember. When false, remember is ignored."]
pub can_remember: bool,
#[doc = " Terminal-owned reply state. Do not access."]
pub ctx: *const ::std::os::raw::c_void,
#[doc = " Answer the write; see the struct documentation."]
pub reply: GhosttyClipboardWriteReplyFn,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyClipboardWrite"][::std::mem::size_of::<GhosttyClipboardWrite>() - 72usize];
["Alignment of GhosttyClipboardWrite"]
[::std::mem::align_of::<GhosttyClipboardWrite>() - 8usize];
["Offset of field: GhosttyClipboardWrite::size"]
[::std::mem::offset_of!(GhosttyClipboardWrite, size) - 0usize];
["Offset of field: GhosttyClipboardWrite::location"]
[::std::mem::offset_of!(GhosttyClipboardWrite, location) - 8usize];
["Offset of field: GhosttyClipboardWrite::contents"]
[::std::mem::offset_of!(GhosttyClipboardWrite, contents) - 16usize];
["Offset of field: GhosttyClipboardWrite::contents_len"]
[::std::mem::offset_of!(GhosttyClipboardWrite, contents_len) - 24usize];
["Offset of field: GhosttyClipboardWrite::name"]
[::std::mem::offset_of!(GhosttyClipboardWrite, name) - 32usize];
["Offset of field: GhosttyClipboardWrite::granted"]
[::std::mem::offset_of!(GhosttyClipboardWrite, granted) - 48usize];
["Offset of field: GhosttyClipboardWrite::can_remember"]
[::std::mem::offset_of!(GhosttyClipboardWrite, can_remember) - 49usize];
["Offset of field: GhosttyClipboardWrite::ctx"]
[::std::mem::offset_of!(GhosttyClipboardWrite, ctx) - 56usize];
["Offset of field: GhosttyClipboardWrite::reply"]
[::std::mem::offset_of!(GhosttyClipboardWrite, reply) - 64usize];
};
impl Default for GhosttyClipboardWrite {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Callback function type for clipboard_write.\n\n The embedder may ask for permission to write or perform the write\n async, but the callback itself is synchronous and the reply function\n must be called during the lifetime of this function. While this callback\n is active the VT stream is paused.\n\n Answer by calling `write->reply(write, &reply)` before returning. See\n GhosttyClipboardWrite for the full contract.\n\n The request may carry an optional program name requesting the write\n and the state of prior permission granted. If `can_remember` is set\n the response may set the `remember` flag and future requests from this\n same program will be \"granted\" and the embedder can skip permission\n requests.\n\n Clipboard read requests (OSC 52 \"?\" and OSC 5522 reads) are delivered\n to GhosttyTerminalClipboardReadFn instead.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param write Borrowed atomic clipboard write request\n\n @ingroup terminal"]
pub type GhosttyTerminalClipboardWriteFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
write: *const GhosttyClipboardWrite,
),
>;
pub mod GhosttyClipboardReadResult {
#[doc = " Result of a clipboard read reply.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " The clipboard was read; the reply carries its contents."]
pub const GHOSTTY_CLIPBOARD_READ_RESULT_SUCCESS: Type = 0;
#[doc = " The clipboard read was denied by policy or the user."]
pub const GHOSTTY_CLIPBOARD_READ_RESULT_DENIED: Type = 1;
#[doc = " The embedder cannot read this clipboard."]
pub const GHOSTTY_CLIPBOARD_READ_RESULT_UNSUPPORTED: Type = 2;
#[doc = " The clipboard is temporarily unavailable."]
pub const GHOSTTY_CLIPBOARD_READ_RESULT_BUSY: Type = 3;
#[doc = " Reading the clipboard failed due to an I/O error."]
pub const GHOSTTY_CLIPBOARD_READ_RESULT_IO_ERROR: Type = 4;
#[doc = " Reading the clipboard failed due to an I/O error."]
pub const GHOSTTY_CLIPBOARD_READ_RESULT_MAX_VALUE: Type = 2147483647;
}
#[doc = " The reply to a clipboard read request.\n\n This is a sized struct; set `size` to `sizeof(GhosttyClipboardReadReply)`.\n All arrays and the strings they point to are borrowed only for the\n duration of the reply call and may be freed as soon as it returns.\n\n Any result other than GHOSTTY_CLIPBOARD_READ_RESULT_SUCCESS answers the\n program with an empty clipboard (OSC 52) or the matching protocol status\n (OSC 5522: EPERM, ENOSYS, EBUSY, EIO); the other fields are ignored in\n that case. On success, `contents` should carry one representation per\n requested MIME type (GhosttyClipboardRead::mimes) that the clipboard\n has; unrequested representations are ignored. Protocols that carry a\n single text value (OSC 52) use the first entry with a text MIME type\n such as \"text/plain\".\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyClipboardReadReply {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " Outcome of the read."]
pub result: GhosttyClipboardReadResult::Type,
#[doc = " Borrowed array of MIME representations of the clipboard contents."]
pub contents: *const GhosttyClipboardContent,
#[doc = " Number of entries in contents."]
pub contents_len: usize,
#[doc = " Borrowed array of all MIME types available on the clipboard. Only\n used when GhosttyClipboardRead::list is set; may be NULL otherwise."]
pub available: *const GhosttyString,
#[doc = " Number of entries in available."]
pub available_len: usize,
#[doc = " Record a session grant so future requests from the same program skip\n the permission prompt. Only honored on success when\n GhosttyClipboardRead::can_remember is set."]
pub remember: bool,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyClipboardReadReply"]
[::std::mem::size_of::<GhosttyClipboardReadReply>() - 56usize];
["Alignment of GhosttyClipboardReadReply"]
[::std::mem::align_of::<GhosttyClipboardReadReply>() - 8usize];
["Offset of field: GhosttyClipboardReadReply::size"]
[::std::mem::offset_of!(GhosttyClipboardReadReply, size) - 0usize];
["Offset of field: GhosttyClipboardReadReply::result"]
[::std::mem::offset_of!(GhosttyClipboardReadReply, result) - 8usize];
["Offset of field: GhosttyClipboardReadReply::contents"]
[::std::mem::offset_of!(GhosttyClipboardReadReply, contents) - 16usize];
["Offset of field: GhosttyClipboardReadReply::contents_len"]
[::std::mem::offset_of!(GhosttyClipboardReadReply, contents_len) - 24usize];
["Offset of field: GhosttyClipboardReadReply::available"]
[::std::mem::offset_of!(GhosttyClipboardReadReply, available) - 32usize];
["Offset of field: GhosttyClipboardReadReply::available_len"]
[::std::mem::offset_of!(GhosttyClipboardReadReply, available_len) - 40usize];
["Offset of field: GhosttyClipboardReadReply::remember"]
[::std::mem::offset_of!(GhosttyClipboardReadReply, remember) - 48usize];
};
impl Default for GhosttyClipboardReadReply {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Function type used to answer a clipboard read request. Obtained from\n GhosttyClipboardRead::reply; see that struct for the contract.\n\n @param read The request being answered\n @param reply The reply, borrowed only for the duration of this call\n\n @ingroup terminal"]
pub type GhosttyClipboardReadReplyFn = ::std::option::Option<
unsafe extern "C" fn(
read: *const GhosttyClipboardRead,
reply: *const GhosttyClipboardReadReply,
),
>;
#[doc = " A synchronous request to read clipboard contents.\n\n This is a sized struct. The callback must only access fields present in the\n size reported by `size`. The request is borrowed and valid only for the\n callback duration.\n\n The read is answered by calling `reply` with this request and a\n GhosttyClipboardReadReply. This must happen before the callback returns;\n the request is invalid afterwards. Calling `reply` more than once is\n ignored. Returning without replying answers the program with an empty\n clipboard (OSC 52) or EPERM (OSC 5522).\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyClipboardRead {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " Clipboard to read."]
pub location: GhosttyClipboardLocation::Type,
#[doc = " Borrowed array of the MIME types the program wants, in order of\n preference. Protocols that only carry text (OSC 52) request\n \"text/plain\". NULL when mimes_len is zero."]
pub mimes: *const GhosttyString,
#[doc = " Number of entries in mimes."]
pub mimes_len: usize,
#[doc = " True if the program also wants the list of MIME types available on the\n clipboard, delivered through GhosttyClipboardReadReply::available."]
pub list: bool,
#[doc = " Name of the requesting program for permission prompts, if the protocol\n carries one. Empty otherwise."]
pub name: GhosttyString,
#[doc = " True if the terminal already holds a session grant for this request\n (kitty clipboard protocol passwords). The embedder should skip any\n permission prompt and serve the read.\n\n Always false when mimes_len is zero: such a request is served\n without a prompt (see the callback docs), so the terminal never\n consults grants for it and a one-time password is preserved for\n the follow-up data read."]
pub granted: bool,
#[doc = " True if the program supplied a session password, so the embedder may\n offer to remember the user's decision through\n GhosttyClipboardReadReply::remember. When false, remember is ignored."]
pub can_remember: bool,
#[doc = " Terminal-owned reply state. Do not access."]
pub ctx: *const ::std::os::raw::c_void,
#[doc = " Answer the read; see the struct documentation."]
pub reply: GhosttyClipboardReadReplyFn,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyClipboardRead"][::std::mem::size_of::<GhosttyClipboardRead>() - 80usize];
["Alignment of GhosttyClipboardRead"][::std::mem::align_of::<GhosttyClipboardRead>() - 8usize];
["Offset of field: GhosttyClipboardRead::size"]
[::std::mem::offset_of!(GhosttyClipboardRead, size) - 0usize];
["Offset of field: GhosttyClipboardRead::location"]
[::std::mem::offset_of!(GhosttyClipboardRead, location) - 8usize];
["Offset of field: GhosttyClipboardRead::mimes"]
[::std::mem::offset_of!(GhosttyClipboardRead, mimes) - 16usize];
["Offset of field: GhosttyClipboardRead::mimes_len"]
[::std::mem::offset_of!(GhosttyClipboardRead, mimes_len) - 24usize];
["Offset of field: GhosttyClipboardRead::list"]
[::std::mem::offset_of!(GhosttyClipboardRead, list) - 32usize];
["Offset of field: GhosttyClipboardRead::name"]
[::std::mem::offset_of!(GhosttyClipboardRead, name) - 40usize];
["Offset of field: GhosttyClipboardRead::granted"]
[::std::mem::offset_of!(GhosttyClipboardRead, granted) - 56usize];
["Offset of field: GhosttyClipboardRead::can_remember"]
[::std::mem::offset_of!(GhosttyClipboardRead, can_remember) - 57usize];
["Offset of field: GhosttyClipboardRead::ctx"]
[::std::mem::offset_of!(GhosttyClipboardRead, ctx) - 64usize];
["Offset of field: GhosttyClipboardRead::reply"]
[::std::mem::offset_of!(GhosttyClipboardRead, reply) - 72usize];
};
impl Default for GhosttyClipboardRead {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Callback function type for clipboard_read.\n\n Called synchronously when the running program requests clipboard contents\n via OSC 52 with a \"?\" payload or a Kitty clipboard (OSC 5522) read.\n Answering lets the program read the user's clipboard, so the embedder is\n expected to mediate consent. Because the read is synchronous, an embedder\n that needs to ask the user must block (for example by running a modal\n prompt) until it has an answer; the VT stream waits until the callback\n returns.\n\n Answer by calling `read->reply(read, &reply)` before returning. See\n GhosttyClipboardRead for the full contract.\n\n OSC 5522 requests carry the program's MIME list, name, and password grant\n state; a reply that sets `remember` records a session grant so later\n requests with the same password arrive with `granted` set. Kitty itself\n serves a request for only the targets listing (`list` with no `mimes`)\n without prompting, and embedders are expected to do the same; the\n terminal never consults grants for such requests (`granted` is false\n and one-time passwords are not consumed).\n\n Installing this callback also enables Kitty paste events (mode 5522):\n ghostty_terminal_paste() sends the program an event instead of the text,\n and the program's follow-up read arrives here with `granted` set since\n the user already pasted. See ghostty_terminal_paste().\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param read Borrowed clipboard read request\n\n @ingroup terminal"]
pub type GhosttyTerminalClipboardReadFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
read: *const GhosttyClipboardRead,
),
>;
#[doc = " A request to show a desktop notification.\n\n This is a sized struct. The callback must only access fields present in the\n size reported by `size`. Both strings are borrowed and valid only for the\n duration of the callback.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalDesktopNotification {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " Notification title, or an empty string when the protocol omits it."]
pub title: GhosttyString,
#[doc = " Notification body."]
pub body: GhosttyString,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalDesktopNotification"]
[::std::mem::size_of::<GhosttyTerminalDesktopNotification>() - 40usize];
["Alignment of GhosttyTerminalDesktopNotification"]
[::std::mem::align_of::<GhosttyTerminalDesktopNotification>() - 8usize];
["Offset of field: GhosttyTerminalDesktopNotification::size"]
[::std::mem::offset_of!(GhosttyTerminalDesktopNotification, size) - 0usize];
["Offset of field: GhosttyTerminalDesktopNotification::title"]
[::std::mem::offset_of!(GhosttyTerminalDesktopNotification, title) - 8usize];
["Offset of field: GhosttyTerminalDesktopNotification::body"]
[::std::mem::offset_of!(GhosttyTerminalDesktopNotification, body) - 24usize];
};
impl Default for GhosttyTerminalDesktopNotification {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Callback function type for desktop notifications.\n\n Called synchronously when the terminal receives OSC 9 or OSC 777.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param notification Borrowed desktop notification request\n\n @ingroup terminal"]
pub type GhosttyTerminalDesktopNotificationFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
notification: *const GhosttyTerminalDesktopNotification,
),
>;
pub mod GhosttyTerminalProgressState {
#[doc = " State of a terminal progress report.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Remove any visible progress indication."]
pub const GHOSTTY_TERMINAL_PROGRESS_STATE_REMOVE: Type = 0;
#[doc = " Show determinate progress."]
pub const GHOSTTY_TERMINAL_PROGRESS_STATE_SET: Type = 1;
#[doc = " Show a failed progress state."]
pub const GHOSTTY_TERMINAL_PROGRESS_STATE_ERROR: Type = 2;
#[doc = " Show indeterminate progress."]
pub const GHOSTTY_TERMINAL_PROGRESS_STATE_INDETERMINATE: Type = 3;
#[doc = " Show paused progress."]
pub const GHOSTTY_TERMINAL_PROGRESS_STATE_PAUSE: Type = 4;
#[doc = " Show paused progress."]
pub const GHOSTTY_TERMINAL_PROGRESS_STATE_MAX_VALUE: Type = 2147483647;
}
#[doc = " A progress report emitted by the running program.\n\n This is a sized struct. The callback must only access fields present in the\n size reported by `size`.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalProgressReport {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " Literal progress state reported by the running program."]
pub state: GhosttyTerminalProgressState::Type,
#[doc = " Progress percentage from 0 through 100, or -1 when omitted."]
pub progress: i8,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalProgressReport"]
[::std::mem::size_of::<GhosttyTerminalProgressReport>() - 16usize];
["Alignment of GhosttyTerminalProgressReport"]
[::std::mem::align_of::<GhosttyTerminalProgressReport>() - 8usize];
["Offset of field: GhosttyTerminalProgressReport::size"]
[::std::mem::offset_of!(GhosttyTerminalProgressReport, size) - 0usize];
["Offset of field: GhosttyTerminalProgressReport::state"]
[::std::mem::offset_of!(GhosttyTerminalProgressReport, state) - 8usize];
["Offset of field: GhosttyTerminalProgressReport::progress"]
[::std::mem::offset_of!(GhosttyTerminalProgressReport, progress) - 12usize];
};
impl Default for GhosttyTerminalProgressReport {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Callback function type for progress reports.\n\n Called synchronously when the terminal receives OSC 9;4.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param report Borrowed progress report\n\n @ingroup terminal"]
pub type GhosttyTerminalProgressReportFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
report: *const GhosttyTerminalProgressReport,
),
>;
pub mod GhosttyProgramStatusState {
#[doc = " What a program says it is doing, in a program status report (OSC 7501).\n\n See GhosttyTerminalProgramStatus for an overview of the protocol.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " At rest, waiting for the user's next instruction. For example, an\n interactive tool sitting at its own prompt."]
pub const GHOSTTY_PROGRAM_STATUS_STATE_IDLE: Type = 0;
#[doc = " Running on its own. The report may include a progress percentage."]
pub const GHOSTTY_PROGRAM_STATUS_STATE_WORKING: Type = 1;
#[doc = " Finished a piece of work, and the result is ready for the user to\n look at."]
pub const GHOSTTY_PROGRAM_STATUS_STATE_DONE: Type = 2;
#[doc = " Can't continue until the user does something. `kind` says what the\n program needs and `message` says why. The report may include a\n progress percentage."]
pub const GHOSTTY_PROGRAM_STATUS_STATE_BLOCKED: Type = 3;
#[doc = " Failed and stopped."]
pub const GHOSTTY_PROGRAM_STATUS_STATE_ERROR: Type = 4;
#[doc = " Not a real state. Remove the record with this report's id and every\n record beneath it. If the id is empty, remove every record."]
pub const GHOSTTY_PROGRAM_STATUS_STATE_CLEAR: Type = 5;
#[doc = " Not a real state. Remove the record with this report's id and every\n record beneath it. If the id is empty, remove every record."]
pub const GHOSTTY_PROGRAM_STATUS_STATE_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyProgramStatusKind {
#[doc = " What a blocked program needs from the user, in a program status report\n (OSC 7501).\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " The program didn't say, or the state isn't\n GHOSTTY_PROGRAM_STATUS_STATE_BLOCKED."]
pub const GHOSTTY_PROGRAM_STATUS_KIND_NONE: Type = 0;
#[doc = " Approval to do something, such as \"Apply these changes?\"."]
pub const GHOSTTY_PROGRAM_STATUS_KIND_PERMISSION: Type = 1;
#[doc = " An answer the user has to type."]
pub const GHOSTTY_PROGRAM_STATUS_KIND_QUESTION: Type = 2;
#[doc = " A login, password, token, or other credential."]
pub const GHOSTTY_PROGRAM_STATUS_KIND_AUTH: Type = 3;
#[doc = " A login, password, token, or other credential."]
pub const GHOSTTY_PROGRAM_STATUS_KIND_MAX_VALUE: Type = 2147483647;
}
#[doc = " A program status report (OSC 7501).\n\n The program status protocol lets a program tell the terminal what it is\n doing: idle, working, done, waiting on the user, or failed, and why. It\n is meant for long-running work like builds, deploys, and coding agents,\n where the user is often looking at something else and wants to know when\n the work finishes or needs them. The protocol only describes state. How\n to show it, if at all, is up to your application.\n\n The full specification is at\n https://www.superlogical.com/rex/docs/build/program-status\n\n For example, a program waiting for the user to approve a change sends\n this, where ST is the string terminator (ESC \\ or BEL):\n\n @code\n ESC ] 7501 ; state=blocked:kind=permission:app=terraform:msg=QXBwbHk/ ST\n @endcode\n\n The callback then receives a report with:\n\n - `state`: GHOSTTY_PROGRAM_STATUS_STATE_BLOCKED\n - `kind`: GHOSTTY_PROGRAM_STATUS_KIND_PERMISSION\n - `progress`: -1, because the program didn't send one, so the work is\n indeterminate\n - `id`: empty, because this is the root record\n - `app`: \"terraform\"\n - `title`: empty\n - `message`: \"Apply?\", decoded from the base64 in `msg`\n\n Only reports that pass every check in the specification reach the\n callback. Text that the program didn't send is an empty string (len=0),\n never NULL. All strings are only valid during the callback, so copy any\n you want to keep.\n\n This is a sized struct. Later versions may add fields at the end, and\n `size` tells you which fields are present. Every field below has been\n present since this struct was introduced.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalProgramStatus {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " What the program is doing."]
pub state: GhosttyProgramStatusState::Type,
#[doc = " What the program needs from the user. Only set for\n GHOSTTY_PROGRAM_STATUS_STATE_BLOCKED. It is\n GHOSTTY_PROGRAM_STATUS_KIND_NONE for other states, when the program\n didn't say, or when it sent a kind this version doesn't know."]
pub kind: GhosttyProgramStatusKind::Type,
#[doc = " How far along the work is, from 0 through 100, or -1 when there is\n no percentage. Only set for GHOSTTY_PROGRAM_STATUS_STATE_WORKING and\n GHOSTTY_PROGRAM_STATUS_STATE_BLOCKED. For those states, -1 means the\n work is indeterminate: the program is busy but has no percentage to\n report. It is also -1 for other states and when the program sent a\n value outside that range."]
pub progress: i8,
#[doc = " Which record this report is about. Empty for the root record.\n\n A program that only reports on itself leaves this empty. A program\n that reports on several things at once gives each its own id, such as\n \"us-east\" and \"eu-west\" for a deploy to two regions. A \"/\" makes one\n record the child of another, so \"build/test\" is a child of \"build\".\n The parent record doesn't have to exist."]
pub id: GhosttyString,
#[doc = " A stable name for the program that a machine can match on, such as\n \"cargo\", \"terraform\", or \"claude-code\". Use it as a key for grouping,\n filtering, or choosing an icon. It is not a label. The label is\n `title`. Empty when the report didn't include one. See\n GhosttyTerminalProgramStatusFn for how an empty app is filled in from\n a parent record."]
pub app: GhosttyString,
#[doc = " A short label for the record, meant for people. Programs that report\n several records use this to tell them apart."]
pub title: GhosttyString,
#[doc = " One line of text for people, saying what the record is doing,\n waiting for, or has finished. You may shorten it to fit, but don't\n try to read meaning into it."]
pub message: GhosttyString,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalProgramStatus"]
[::std::mem::size_of::<GhosttyTerminalProgramStatus>() - 88usize];
["Alignment of GhosttyTerminalProgramStatus"]
[::std::mem::align_of::<GhosttyTerminalProgramStatus>() - 8usize];
["Offset of field: GhosttyTerminalProgramStatus::size"]
[::std::mem::offset_of!(GhosttyTerminalProgramStatus, size) - 0usize];
["Offset of field: GhosttyTerminalProgramStatus::state"]
[::std::mem::offset_of!(GhosttyTerminalProgramStatus, state) - 8usize];
["Offset of field: GhosttyTerminalProgramStatus::kind"]
[::std::mem::offset_of!(GhosttyTerminalProgramStatus, kind) - 12usize];
["Offset of field: GhosttyTerminalProgramStatus::progress"]
[::std::mem::offset_of!(GhosttyTerminalProgramStatus, progress) - 16usize];
["Offset of field: GhosttyTerminalProgramStatus::id"]
[::std::mem::offset_of!(GhosttyTerminalProgramStatus, id) - 24usize];
["Offset of field: GhosttyTerminalProgramStatus::app"]
[::std::mem::offset_of!(GhosttyTerminalProgramStatus, app) - 40usize];
["Offset of field: GhosttyTerminalProgramStatus::title"]
[::std::mem::offset_of!(GhosttyTerminalProgramStatus, title) - 56usize];
["Offset of field: GhosttyTerminalProgramStatus::message"]
[::std::mem::offset_of!(GhosttyTerminalProgramStatus, message) - 72usize];
};
impl Default for GhosttyTerminalProgramStatus {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Callback function type for program status reports (OSC 7501).\n\n Called synchronously each time the running program sends a valid\n report. See GhosttyTerminalProgramStatus for what a report contains.\n\n The terminal doesn't store reports, so your application keeps them. To\n follow the specification, keep one record per id. A report with an empty\n id is about the root record, the program itself. The records follow\n these rules:\n\n - A report replaces its record completely. A value the report leaves\n out is gone from the record afterwards. It doesn't keep its old value.\n - A GHOSTTY_PROGRAM_STATUS_STATE_CLEAR report removes the record with\n its id and every record beneath it, so clearing \"build\" also removes\n \"build/test\". A clear report with an empty id removes every record.\n - A record without an app takes it from its nearest ancestor that has\n one. If the root record has app \"deploy\" and the record \"us-east\"\n has none, show \"us-east\" with app \"deploy\" too.\n - When a new shell prompt starts (GHOSTTY_SEMANTIC_PROMPT_PROMPT_START\n from the GHOSTTY_TERMINAL_OPT_SEMANTIC_PROMPT callback) or the program\n running in the terminal exits, remove `working` and `blocked` records.\n You may remove `idle` records too. Keep `done` and `error` records\n until the user has seen them, for example until they next focus the\n terminal.\n - Keep at most 256 records, and allow at least 64. When a new record\n would go over your limit, remove the one that was updated longest ago.\n\n A full reset (RIS, `ESC c`) removes every record. When that happens,\n the terminal calls this with a GHOSTTY_PROGRAM_STATUS_STATE_CLEAR report\n and an empty id, and then calls the GHOSTTY_TERMINAL_OPT_RESET callback.\n\n `title` and `message` are already decoded and contain no control\n characters, but they are still untrusted text from the program. Don't\n treat them as markup. If you show them outside the terminal, such as in\n a tab or a notification, remove invisible formatting characters like\n text direction overrides, and say which terminal the text came from so\n a program can't pretend to be one running elsewhere.\n\n Example, where `Records`, `records_clear`, and `records_put` stand in for\n your application's own storage:\n\n @code\n void on_program_status(GhosttyTerminal terminal,\n void* userdata,\n const GhosttyTerminalProgramStatus* report) {\n (void)terminal;\n Records* records = userdata;\n\n if (report->state == GHOSTTY_PROGRAM_STATUS_STATE_CLEAR) {\n // Remove this record and every record beneath it. An empty id\n // removes every record.\n records_clear(records, report->id);\n return;\n }\n\n // Replace the whole record. The strings are only valid during this\n // call, so records_put must copy them.\n records_put(records, report->id, report->state, report->message);\n }\n\n // Set write_pty too, so programs that check for support get a reply.\n ghostty_terminal_set(terminal, GHOSTTY_TERMINAL_OPT_USERDATA, records);\n ghostty_terminal_set(terminal, GHOSTTY_TERMINAL_OPT_WRITE_PTY,\n (const void*)on_write_pty);\n ghostty_terminal_set(terminal, GHOSTTY_TERMINAL_OPT_PROGRAM_STATUS,\n (const void*)on_program_status);\n @endcode\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param report The report. It and its strings are only valid during the\n call.\n\n @ingroup terminal"]
pub type GhosttyTerminalProgramStatusFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
report: *const GhosttyTerminalProgramStatus,
),
>;
pub mod GhosttySemanticPromptKind {
#[doc = " The step of a command that a shell integration event reports.\n\n More kinds may be added in later versions, so ignore any kind you don't\n handle.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Never reported. This exists so that a zeroed value is not mistaken\n for a real event."]
pub const GHOSTTY_SEMANTIC_PROMPT_INVALID: Type = 0;
#[doc = " The shell started drawing a prompt. `prompt_kind` says which one."]
pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_START: Type = 1;
#[doc = " The prompt is drawn and the user can start typing a command."]
pub const GHOSTTY_SEMANTIC_PROMPT_INPUT_START: Type = 2;
#[doc = " The user submitted the command and it started running. Anything the\n terminal receives after this is the command's output."]
pub const GHOSTTY_SEMANTIC_PROMPT_OUTPUT_START: Type = 3;
#[doc = " The command finished running."]
pub const GHOSTTY_SEMANTIC_PROMPT_COMMAND_END: Type = 4;
#[doc = " The command finished running."]
pub const GHOSTTY_SEMANTIC_PROMPT_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySemanticPromptPromptKind {
#[doc = " Which prompt a `GHOSTTY_SEMANTIC_PROMPT_PROMPT_START` event starts.\n\n Most shells only draw a primary prompt. Some also draw a prompt on the\n right side of the line, or a prompt at the start of each extra line\n when a command spans several lines.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " The main prompt shown before each command. This is used when the\n shell doesn't say which prompt it is drawing."]
pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_PRIMARY: Type = 0;
#[doc = " A prompt drawn at the right edge of the line, such as zsh's\n RPROMPT."]
pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_RIGHT: Type = 1;
#[doc = " A prompt at the start of an extra line of a command that spans\n several lines."]
pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_CONTINUATION: Type = 2;
#[doc = " Another prompt for an extra line of input, such as bash's PS2.\n Shells differ in whether they report extra lines as continuation or\n secondary prompts, so most applications should treat the two the\n same."]
pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_SECONDARY: Type = 3;
#[doc = " Another prompt for an extra line of input, such as bash's PS2.\n Shells differ in whether they report extra lines as continuation or\n secondary prompts, so most applications should treat the two the\n same."]
pub const GHOSTTY_SEMANTIC_PROMPT_PROMPT_MAX_VALUE: Type = 2147483647;
}
#[doc = " A shell integration event, passed to the\n `GHOSTTY_TERMINAL_OPT_SEMANTIC_PROMPT` callback.\n\n `kind` says which step of the command this is. The other fields only\n carry information for the kinds listed on each field, and are zero or\n empty otherwise.\n\n Strings are only valid during the callback. Copy them if you need them\n later.\n\n This is a sized struct. Later versions may add fields at the end, and\n `size` tells you which fields are present. Every field below has been\n present since this struct was introduced, so you only need to check\n `size` before reading fields added later. Two fields are likely to be\n added in the future:\n\n - An identifier the shell assigns to each command.\n - A flag on `GHOSTTY_SEMANTIC_PROMPT_PROMPT_START` that says the shell\n redrew a prompt it had already drawn, instead of starting a new one.\n\n Neither exists yet.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyTerminalSemanticPrompt {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " Which step of the command this event reports."]
pub kind: GhosttySemanticPromptKind::Type,
#[doc = " Which prompt is starting. Set for\n `GHOSTTY_SEMANTIC_PROMPT_PROMPT_START`. Always\n `GHOSTTY_SEMANTIC_PROMPT_PROMPT_PRIMARY` for other kinds."]
pub prompt_kind: GhosttySemanticPromptPromptKind::Type,
#[doc = " True if the shell reported the command's exit code. Only ever true\n for `GHOSTTY_SEMANTIC_PROMPT_COMMAND_END`."]
pub has_exit_code: bool,
#[doc = " The command's exit code. Only meaningful when `has_exit_code` is\n true. Exit codes can be negative, for example on Windows, so use\n `has_exit_code` rather than a special value to tell whether one was\n reported."]
pub exit_code: i32,
#[doc = " The command line that is about to run, for\n `GHOSTTY_SEMANTIC_PROMPT_OUTPUT_START`. The shell sends it encoded,\n and this is the decoded text. Empty (len=0) if the shell didn't send\n one or it couldn't be decoded."]
pub command: GhosttyString,
#[doc = " A description of what went wrong, for\n `GHOSTTY_SEMANTIC_PROMPT_COMMAND_END` when the shell sent one. Empty\n (len=0) otherwise. Few shells send this. The exit code is the usual\n way to tell whether a command failed."]
pub error: GhosttyString,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalSemanticPrompt"]
[::std::mem::size_of::<GhosttyTerminalSemanticPrompt>() - 56usize];
["Alignment of GhosttyTerminalSemanticPrompt"]
[::std::mem::align_of::<GhosttyTerminalSemanticPrompt>() - 8usize];
["Offset of field: GhosttyTerminalSemanticPrompt::size"]
[::std::mem::offset_of!(GhosttyTerminalSemanticPrompt, size) - 0usize];
["Offset of field: GhosttyTerminalSemanticPrompt::kind"]
[::std::mem::offset_of!(GhosttyTerminalSemanticPrompt, kind) - 8usize];
["Offset of field: GhosttyTerminalSemanticPrompt::prompt_kind"]
[::std::mem::offset_of!(GhosttyTerminalSemanticPrompt, prompt_kind) - 12usize];
["Offset of field: GhosttyTerminalSemanticPrompt::has_exit_code"]
[::std::mem::offset_of!(GhosttyTerminalSemanticPrompt, has_exit_code) - 16usize];
["Offset of field: GhosttyTerminalSemanticPrompt::exit_code"]
[::std::mem::offset_of!(GhosttyTerminalSemanticPrompt, exit_code) - 20usize];
["Offset of field: GhosttyTerminalSemanticPrompt::command"]
[::std::mem::offset_of!(GhosttyTerminalSemanticPrompt, command) - 24usize];
["Offset of field: GhosttyTerminalSemanticPrompt::error"]
[::std::mem::offset_of!(GhosttyTerminalSemanticPrompt, error) - 40usize];
};
impl Default for GhosttyTerminalSemanticPrompt {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Callback function type for semantic_prompt.\n\n Called when the shell reports a step of a command. Each command goes\n through four steps, in this order: the prompt starts, input starts,\n output starts, and the command ends. Then the next prompt starts.\n\n Shells differ in what they report. Many don't send the command line or\n the exit code, and some skip steps, so handle each event on its own\n instead of expecting a strict order. A shell may also start the same\n prompt more than once, for example when it redraws the prompt after a\n resize, so treat a repeated `GHOSTTY_SEMANTIC_PROMPT_PROMPT_START` as\n harmless.\n\n The terminal has already updated its screen when this is called. A\n sequence the terminal rejects as malformed is never reported.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param event The event. It and its strings are only valid during the\n call.\n\n @ingroup terminal"]
pub type GhosttyTerminalSemanticPromptFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
event: *const GhosttyTerminalSemanticPrompt,
),
>;
#[doc = " Callback function type for reset.\n\n Called when the running program performs a full reset (RIS, `ESC c`).\n A full reset clears the screen and scrollback, returns modes to their\n defaults, and clears the title and working directory. Use this callback\n to reset any state your application keeps about what's running in the\n terminal, such as the current command.\n\n The terminal has already reset itself when this is called. The\n GHOSTTY_TERMINAL_OPT_TITLE_CHANGED and GHOSTTY_TERMINAL_OPT_PWD_CHANGED\n callbacks are not called for the cleared title and working directory,\n so update anything you show for them here. A full reset also removes\n any progress report and program status records. If you set\n GHOSTTY_TERMINAL_OPT_PROGRESS_REPORT or\n GHOSTTY_TERMINAL_OPT_PROGRAM_STATUS, those callbacks are called before\n this one.\n\n A soft reset (DECSTR, `CSI ! p`) keeps the screen, title and working\n directory, and doesn't call this.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n\n @ingroup terminal"]
pub type GhosttyTerminalResetFn = ::std::option::Option<
unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::std::os::raw::c_void),
>;
pub mod GhosttyTerminalResizeWindowTag {
#[doc = " The kind of window resize request passed to a\n GhosttyTerminalResizeWindowFn callback.\n\n New kinds may be added in later versions. Callbacks should ignore any\n tag they don't handle.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Resize the window's text area to a size in rows and columns\n (CSI 8 ; rows ; columns t). The value is in `value.grid`."]
pub const GHOSTTY_TERMINAL_RESIZE_WINDOW_GRID: Type = 0;
#[doc = " Resize the window's text area to a size in rows and columns\n (CSI 8 ; rows ; columns t). The value is in `value.grid`."]
pub const GHOSTTY_TERMINAL_RESIZE_WINDOW_MAX_VALUE: Type = 2147483647;
}
#[doc = " A request to resize the window's text area to a size in rows and columns.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyTerminalResizeWindowGrid {
#[doc = " Requested height in rows, or 0 to keep the current height."]
pub rows: u16,
#[doc = " Requested width in columns, or 0 to keep the current width."]
pub columns: u16,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalResizeWindowGrid"]
[::std::mem::size_of::<GhosttyTerminalResizeWindowGrid>() - 4usize];
["Alignment of GhosttyTerminalResizeWindowGrid"]
[::std::mem::align_of::<GhosttyTerminalResizeWindowGrid>() - 2usize];
["Offset of field: GhosttyTerminalResizeWindowGrid::rows"]
[::std::mem::offset_of!(GhosttyTerminalResizeWindowGrid, rows) - 0usize];
["Offset of field: GhosttyTerminalResizeWindowGrid::columns"]
[::std::mem::offset_of!(GhosttyTerminalResizeWindowGrid, columns) - 2usize];
};
#[doc = " Window resize request value.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union GhosttyTerminalResizeWindowValue {
#[doc = " Size in rows and columns (GHOSTTY_TERMINAL_RESIZE_WINDOW_GRID)."]
pub grid: GhosttyTerminalResizeWindowGrid,
#[doc = " Padding for ABI compatibility. Do not use."]
pub _padding: [u64; 2usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalResizeWindowValue"]
[::std::mem::size_of::<GhosttyTerminalResizeWindowValue>() - 16usize];
["Alignment of GhosttyTerminalResizeWindowValue"]
[::std::mem::align_of::<GhosttyTerminalResizeWindowValue>() - 8usize];
["Offset of field: GhosttyTerminalResizeWindowValue::grid"]
[::std::mem::offset_of!(GhosttyTerminalResizeWindowValue, grid) - 0usize];
["Offset of field: GhosttyTerminalResizeWindowValue::_padding"]
[::std::mem::offset_of!(GhosttyTerminalResizeWindowValue, _padding) - 0usize];
};
impl Default for GhosttyTerminalResizeWindowValue {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " A request from the running program to resize the window.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GhosttyTerminalResizeWindow {
pub tag: GhosttyTerminalResizeWindowTag::Type,
pub value: GhosttyTerminalResizeWindowValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalResizeWindow"]
[::std::mem::size_of::<GhosttyTerminalResizeWindow>() - 24usize];
["Alignment of GhosttyTerminalResizeWindow"]
[::std::mem::align_of::<GhosttyTerminalResizeWindow>() - 8usize];
["Offset of field: GhosttyTerminalResizeWindow::tag"]
[::std::mem::offset_of!(GhosttyTerminalResizeWindow, tag) - 0usize];
["Offset of field: GhosttyTerminalResizeWindow::value"]
[::std::mem::offset_of!(GhosttyTerminalResizeWindow, value) - 8usize];
};
impl Default for GhosttyTerminalResizeWindow {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Callback function type for window resize requests.\n\n Called synchronously when the running program asks to resize the window,\n such as with CSI 8 ; rows ; columns t. Check `request->tag` first, because\n more kinds of requests may be reported in later versions. The terminal is\n not resized by this: the embedder decides whether to allow the request,\n and if so resizes its window and the terminal. Letting any\n program resize the window is a nuisance at best, so consider making this\n opt-in for users.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param request Borrowed resize request\n\n @ingroup terminal"]
pub type GhosttyTerminalResizeWindowFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
request: *const GhosttyTerminalResizeWindow,
),
>;
#[doc = " Callback function type for color scheme queries (CSI ? 996 n).\n\n Called when the terminal receives a color scheme device status report\n query. Return true and fill *out_scheme with the current color scheme,\n or return false to silently ignore the query.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param[out] out_scheme Pointer to store the current color scheme\n @return true if the color scheme was filled, false to ignore the query\n\n @ingroup terminal"]
pub type GhosttyTerminalColorSchemeFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
out_scheme: *mut GhosttyColorScheme::Type,
) -> bool,
>;
#[doc = " Callback function type for device attributes queries (DA1/DA2/DA3).\n\n Called when the terminal receives a device attributes query (CSI c,\n CSI > c, or CSI = c). Return true and fill *out_attrs with the\n response data, or return false to silently ignore the query.\n\n The terminal uses whichever sub-struct (primary, secondary, tertiary)\n matches the request type, but all three should be filled for simplicity.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param[out] out_attrs Pointer to store the device attributes response\n @return true if attributes were filled, false to ignore the query\n\n @ingroup terminal"]
pub type GhosttyTerminalDeviceAttributesFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
out_attrs: *mut GhosttyDeviceAttributes,
) -> bool,
>;
#[doc = " Callback function type for enquiry (ENQ, 0x05).\n\n Called when the terminal receives an ENQ character. Return the\n response bytes as a GhosttyString. The memory must remain valid\n until the callback returns. Return a zero-length string to send\n no response.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @return The response bytes to write back to the pty\n\n @ingroup terminal"]
pub type GhosttyTerminalEnquiryFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
) -> GhosttyString,
>;
#[doc = " Callback function type for terminal size reports.\n\n Called in response to XTWINOPS size queries (CSI 14/16/18/19 t) and when VT\n input enables in-band size reports (mode 2048).\n Return true and fill *out_size with the current terminal geometry,\n or return false to suppress the report.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param[out] out_size Pointer to store the terminal size information\n @return true if size was filled, false to suppress the XTWINOPS response or\n mode 2048 report\n\n @ingroup terminal"]
pub type GhosttyTerminalSizeFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
out_size: *mut GhosttySizeReportSize,
) -> bool,
>;
#[doc = " Callback function type for title_changed.\n\n Called when the terminal title changes via escape sequences\n (e.g. OSC 0 or OSC 2). The new title can be queried from the\n terminal after the callback returns.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n\n @ingroup terminal"]
pub type GhosttyTerminalTitleChangedFn = ::std::option::Option<
unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::std::os::raw::c_void),
>;
#[doc = " Callback function type for render_hold.\n\n Called when the running program asks the terminal to stop updating\n the screen, and again when it lets the screen update again. We call\n the time in between a \"render hold\".\n\n Programs use a hold to avoid flicker. A full-screen program usually\n redraws in several steps: clear, draw the text, move the cursor. If\n the screen is drawn halfway through, the user sees a broken frame. To\n prevent that, the program starts a hold, draws everything, and then\n releases the hold. The screen should keep showing the last finished\n frame the whole time and then switch to the new one all at once.\n\n Today the only way a program can start a hold is synchronized output\n (DEC private mode 2026, GHOSTTY_MODE_SYNC_OUTPUT). The callback is\n named for what the embedder should do rather than for that mode so\n that other sources of holds can be added later.\n\n ### When it is called\n\n With `held` set to true when the program sets mode 2026.\n\n With `held` set to false when the hold ends, which happens when:\n\n - the program resets mode 2026\n - the terminal is fully reset, by the program (RIS) or by\n ghostty_terminal_reset()\n - the terminal is resized with ghostty_terminal_resize()\n\n The two calls always come in pairs. Setting the mode while a hold is\n already active does nothing, and neither does resetting it when there\n is no hold. Changing the mode yourself with GHOSTTY_TERMINAL_OPT_MODE\n never invokes the callback.\n\n ### What to do\n\n When a hold begins, the terminal contains exactly the frame the\n program wants left on screen. Nothing after the start of the hold has\n been processed yet, even if more bytes follow in the same\n ghostty_terminal_vt_write() call. Capture that frame by calling\n ghostty_render_state_update() from within the callback, then stop\n updating the render state until the hold ends. You can keep drawing\n the render state in the meantime. It won't change.\n\n @code{.c}\n typedef struct {\n GhosttyRenderState render_state;\n bool held;\n uint64_t hold_started_ms;\n } Renderer;\n\n void on_render_hold(GhosttyTerminal terminal, void* userdata, bool held) {\n Renderer* r = userdata;\n if (held) {\n // Capture the frame the program wants left on screen.\n ghostty_render_state_update(r->render_state, terminal);\n r->hold_started_ms = now_ms();\n }\n r->held = held;\n }\n\n void draw(Renderer* r, GhosttyTerminal terminal) {\n // Give up on a program that holds the screen for too long.\n if (r->held && now_ms() - r->hold_started_ms >= 1000) {\n GhosttyTerminalModeConfig mode = {\n .mode = GHOSTTY_MODE_SYNC_OUTPUT,\n .value = false,\n };\n ghostty_terminal_set(terminal, GHOSTTY_TERMINAL_OPT_MODE, &mode);\n r->held = false;\n }\n\n // During a hold, skip the update and draw the captured frame.\n if (!r->held) ghostty_render_state_update(r->render_state, terminal);\n draw_render_state(r->render_state);\n }\n @endcode\n\n ### Timeouts\n\n The terminal has no clock, so it never ends a hold on its own. A\n program that crashes or forgets to release its hold would freeze the\n screen forever, so you need a timeout like the one above. One second\n is a common choice. When it expires, reset the mode yourself and go\n back to updating normally. Because setting the mode again during a\n hold does nothing, a program can't keep pushing your deadline back.\n\n ### Why a callback\n\n You could instead check GHOSTTY_MODE_SYNC_OUTPUT before each draw\n and skip the update when it is set. That is simpler, but it has two\n problems. First, the frame left on screen is whatever you happened to\n draw last, which can be older than what the program intended or even\n a half-drawn frame. Second, if the program releases a hold and starts\n the next one between two of your draws, you never see the mode turn\n off and the finished frame in between is lost. A program that draws\n continuously can then appear frozen. Capturing the frame when each\n hold begins avoids both.\n\n ### Other notes\n\n You are free to ignore a hold whenever showing live content matters\n more, such as when the user scrolls or starts a selection.\n\n Like every callback, this runs on the thread that called\n ghostty_terminal_vt_write(). If another thread draws the render\n state, protect the update in the callback the same way you protect\n any other access to the render state.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param held True when a hold begins, false when it ends\n\n @ingroup terminal"]
pub type GhosttyTerminalRenderHoldFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
held: bool,
),
>;
#[doc = " Callback function type for pwd_changed.\n\n Called when the terminal pwd (current working directory) changes via\n escape sequences: OSC 7 (file:// URI), OSC 9 (ConEmu CurrentDir), or\n OSC 1337 CurrentDir (iTerm2). Use ghostty_terminal_get() with\n GHOSTTY_TERMINAL_DATA_PWD inside the callback to read the new value.\n\n The terminal stores whatever bytes the shell emitted, without parsing.\n That means for OSC 7 the value is the raw URI (typically file://...);\n for OSC 9/OSC 1337 it is typically a bare path. The embedder is\n responsible for decoding any URI scheme or host if it cares about them.\n\n The callback also fires when the shell clears the pwd (e.g. an empty\n OSC 7). In that case GHOSTTY_TERMINAL_DATA_PWD returns a zero-length\n string.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n\n @ingroup terminal"]
pub type GhosttyTerminalPwdChangedFn = ::std::option::Option<
unsafe extern "C" fn(terminal: GhosttyTerminal, userdata: *mut ::std::os::raw::c_void),
>;
#[doc = " Callback function type for write_pty.\n\n Called when the terminal needs to write data back to the pty, for\n example in response to a device status report, mode query, or VT-driven\n mode 2048 enable. The data is only valid for the duration of the call;\n callers must copy it if it needs to persist.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @param data Pointer to the response bytes\n @param len Length of the response in bytes\n\n @ingroup terminal"]
pub type GhosttyTerminalWritePtyFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
data: *const u8,
len: usize,
),
>;
#[doc = " Callback function type for XTVERSION.\n\n Called when the terminal receives an XTVERSION query (CSI > q).\n Return the version string (e.g. \"myterm 1.0\") as a GhosttyString.\n The memory must remain valid until the callback returns. Return a\n zero-length string to report the default \"libghostty\" version.\n\n @param terminal The terminal handle\n @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA\n @return The version string to report\n\n @ingroup terminal"]
pub type GhosttyTerminalXtversionFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: GhosttyTerminal,
userdata: *mut ::std::os::raw::c_void,
) -> GhosttyString,
>;
#[doc = " A terminal mode and boolean value used for mode configuration and queries.\n\n For GHOSTTY_TERMINAL_DATA_MODE, initialize `mode` before calling\n ghostty_terminal_get(). On success, `value` contains the current mode value.\n\n This struct has a frozen layout and will not gain fields in future versions.\n\n @ingroup terminal"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyTerminalModeConfig {
#[doc = " Mode to configure or query."]
pub mode: GhosttyMode,
#[doc = " Value to set, or the current value returned by a query."]
pub value: bool,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalModeConfig"]
[::std::mem::size_of::<GhosttyTerminalModeConfig>() - 4usize];
["Alignment of GhosttyTerminalModeConfig"]
[::std::mem::align_of::<GhosttyTerminalModeConfig>() - 2usize];
["Offset of field: GhosttyTerminalModeConfig::mode"]
[::std::mem::offset_of!(GhosttyTerminalModeConfig, mode) - 0usize];
["Offset of field: GhosttyTerminalModeConfig::value"]
[::std::mem::offset_of!(GhosttyTerminalModeConfig, value) - 2usize];
};
pub mod GhosttyTerminalOption {
#[doc = " Terminal option identifiers.\n\n These values are used with ghostty_terminal_set() to configure\n terminal callbacks and associated state.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Opaque userdata pointer passed to all callbacks.\n\n Input type: void*"]
pub const GHOSTTY_TERMINAL_OPT_USERDATA: Type = 0;
#[doc = " Callback invoked when the terminal needs to write data back\n to the pty (e.g. in response to a DECRQM query, device status\n report, or VT-driven mode 2048 enable). Set to NULL to ignore such\n sequences.\n\n Input type: GhosttyTerminalWritePtyFn"]
pub const GHOSTTY_TERMINAL_OPT_WRITE_PTY: Type = 1;
#[doc = " Callback invoked when the terminal receives a BEL character\n (0x07). Set to NULL to ignore bell events.\n\n Input type: GhosttyTerminalBellFn"]
pub const GHOSTTY_TERMINAL_OPT_BELL: Type = 2;
#[doc = " Callback invoked when the terminal receives an ENQ character\n (0x05). Set to NULL to send no response.\n\n Input type: GhosttyTerminalEnquiryFn"]
pub const GHOSTTY_TERMINAL_OPT_ENQUIRY: Type = 3;
#[doc = " Callback invoked when the terminal receives an XTVERSION query\n (CSI > q). Set to NULL to report the default \"libghostty\" string.\n\n Input type: GhosttyTerminalXtversionFn"]
pub const GHOSTTY_TERMINAL_OPT_XTVERSION: Type = 4;
#[doc = " Callback invoked when the terminal title changes via escape\n sequences (e.g. OSC 0 or OSC 2). Set to NULL to ignore title\n change events.\n\n Input type: GhosttyTerminalTitleChangedFn"]
pub const GHOSTTY_TERMINAL_OPT_TITLE_CHANGED: Type = 5;
#[doc = " Callback invoked in response to XTWINOPS size queries\n (CSI 14/16/18/19 t). Set to NULL to silently ignore size queries.\n\n Input type: GhosttyTerminalSizeFn"]
pub const GHOSTTY_TERMINAL_OPT_SIZE: Type = 6;
#[doc = " Callback invoked in response to a color scheme device status\n report query (CSI ? 996 n). Return true and fill the out pointer\n to report the current scheme, or return false to silently ignore.\n Set to NULL to ignore color scheme queries.\n\n Input type: GhosttyTerminalColorSchemeFn"]
pub const GHOSTTY_TERMINAL_OPT_COLOR_SCHEME: Type = 7;
#[doc = " Callback invoked in response to a device attributes query\n (CSI c, CSI > c, or CSI = c). Return true and fill the out\n pointer with response data, or return false to silently ignore.\n Set to NULL to ignore device attributes queries.\n\n Input type: GhosttyTerminalDeviceAttributesFn"]
pub const GHOSTTY_TERMINAL_OPT_DEVICE_ATTRIBUTES: Type = 8;
#[doc = " Set the terminal title manually.\n\n The string data is copied into the terminal. A NULL value pointer\n clears the title (equivalent to setting an empty string).\n\n Input type: GhosttyString*"]
pub const GHOSTTY_TERMINAL_OPT_TITLE: Type = 9;
#[doc = " Set the terminal working directory manually.\n\n The string data is copied into the terminal. A NULL value pointer\n clears the pwd (equivalent to setting an empty string).\n\n Input type: GhosttyString*"]
pub const GHOSTTY_TERMINAL_OPT_PWD: Type = 10;
#[doc = " Set the default foreground color.\n\n A NULL value pointer clears the default (unset).\n\n Input type: GhosttyColorRgb*"]
pub const GHOSTTY_TERMINAL_OPT_COLOR_FOREGROUND: Type = 11;
#[doc = " Set the default background color.\n\n A NULL value pointer clears the default (unset).\n\n Input type: GhosttyColorRgb*"]
pub const GHOSTTY_TERMINAL_OPT_COLOR_BACKGROUND: Type = 12;
#[doc = " Set the default cursor color.\n\n A NULL value pointer clears the default (unset).\n\n Input type: GhosttyColorRgb*"]
pub const GHOSTTY_TERMINAL_OPT_COLOR_CURSOR: Type = 13;
#[doc = " Set the default 256-color palette.\n\n The value must point to an array of exactly 256 GhosttyColorRgb values.\n A NULL value pointer resets to the built-in default palette.\n\n Input type: GhosttyColorRgb[256]*"]
pub const GHOSTTY_TERMINAL_OPT_COLOR_PALETTE: Type = 14;
#[doc = " Set the Kitty image storage limit in bytes.\n\n Applied to all initialized screens (primary and alternate).\n A value of zero disables the Kitty graphics protocol entirely,\n deleting all stored images and placements. A NULL value pointer\n is equivalent to zero (disables). Has no effect when Kitty graphics\n are disabled at build time.\n\n Input type: uint64_t*"]
pub const GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_STORAGE_LIMIT: Type = 15;
#[doc = " Enable or disable Kitty image loading via the file medium.\n\n A NULL value pointer is a no-op. Has no effect when Kitty graphics\n are disabled at build time.\n\n Input type: bool*"]
pub const GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_FILE: Type = 16;
#[doc = " Enable Kitty image loading via the temporary file medium, restricted to\n the provided directory. The string data is copied into the terminal.\n\n A NULL value pointer disables the temporary file medium. Has no effect\n when Kitty graphics are disabled at build time.\n\n Input type: GhosttyString*"]
pub const GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_TEMP_FILE: Type = 17;
#[doc = " Enable or disable Kitty image loading via the shared memory medium.\n\n A NULL value pointer is a no-op. Has no effect when Kitty graphics\n are disabled at build time.\n\n Input type: bool*"]
pub const GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_SHARED_MEM: Type = 18;
#[doc = " Set the maximum bytes the APC handler will buffer for all protocols.\n This prevents malicious input from causing unbounded memory allocation.\n A NULL value pointer removes all overrides, reverting to the built-in\n defaults.\n\n Input type: size_t*"]
pub const GHOSTTY_TERMINAL_OPT_APC_MAX_BYTES: Type = 19;
#[doc = " Set the maximum bytes the APC handler will buffer for Kitty graphics\n protocol data. A NULL value pointer removes the override, reverting\n to the built-in default.\n\n Input type: size_t*"]
pub const GHOSTTY_TERMINAL_OPT_APC_MAX_BYTES_KITTY: Type = 20;
#[doc = " Set the active screen selection.\n\n The value must point to a GhosttySelection whose grid references are\n valid for this terminal's active screen at the time of the call. The\n terminal copies the selection immediately and converts it to\n terminal-owned tracked state, so the GhosttySelection struct and its\n untracked grid references do not need to outlive this call.\n\n Passing NULL clears the active screen selection.\n\n Input type: GhosttySelection*"]
pub const GHOSTTY_TERMINAL_OPT_SELECTION: Type = 21;
#[doc = " Set the default cursor style used by DECSCUSR reset (CSI 0 q).\n\n A NULL value pointer resets to the built-in default block cursor.\n\n Input type: GhosttyTerminalCursorStyle*"]
pub const GHOSTTY_TERMINAL_OPT_DEFAULT_CURSOR_STYLE: Type = 22;
#[doc = " Set whether the default cursor should blink when reset by DECSCUSR\n (CSI 0 q).\n\n A NULL value pointer resets to the built-in default of not blinking.\n\n Input type: bool*"]
pub const GHOSTTY_TERMINAL_OPT_DEFAULT_CURSOR_BLINK: Type = 23;
#[doc = " Enable or disable Glyph Protocol APC handling.\n\n When disabled, Glyph Protocol APC sequences are ignored and no\n support/query/register/clear responses are emitted. Disabling also clears\n the terminal session's glyph glossary. A NULL value pointer is a no-op.\n\n Input type: bool*"]
pub const GHOSTTY_TERMINAL_OPT_GLYPH_PROTOCOL: Type = 24;
#[doc = " Callback invoked when the terminal pwd changes via escape\n sequences (OSC 7, OSC 9, or OSC 1337 CurrentDir). Set to NULL\n to ignore pwd change events.\n\n Input type: GhosttyTerminalPwdChangedFn"]
pub const GHOSTTY_TERMINAL_OPT_PWD_CHANGED: Type = 25;
#[doc = " Callback invoked when the running program performs a clipboard write.\n OSC 52, iTerm2 OSC 1337 Copy, and Kitty clipboard (OSC 5522) writes\n are normalized to an atomic set of decoded MIME representations. Set\n to NULL to ignore clipboard writes (Kitty clipboard writes are then\n refused with ENOSYS). Clipboard read requests are delivered to\n GHOSTTY_TERMINAL_OPT_CLIPBOARD_READ instead.\n\n Input type: GhosttyTerminalClipboardWriteFn"]
pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE: Type = 26;
#[doc = " Set the maximum scrollback allocation in bytes.\n\n This is an estimate. Internally, libghostty only prunes bytes up\n to a \"page\"-granularity. A page is the minimum allocated unit of\n grid space within Ghostty. A page at the time of writing these docs\n is about 400KB, so the byte limit will be within this delta.\n\n This works alongside the line limit configuration. If both are set,\n the first-reached limit is used first. Both limits are dependent\n on external state (byte limit can be reached with less lines if\n more styles are used for example, line limit can be reached with\n a narrower terminal viewport). So, they are useful together.\n\n Lowering the limit immediately removes eligible complete historical\n pages. A value of zero disables scrollback and erases retained history.\n A NULL value pointer removes the byte limit.\n\n Input type: size_t*"]
pub const GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES: Type = 27;
#[doc = " Set the maximum number of physical lines retained in scrollback.\n\n This is an estimate. Internally, libghostty only prunes lines up\n to a \"page\"-granularity. A page is the minimum allocated unit of\n grid space within Ghostty. As a result, the actual available scrollback\n lines will almost always be higher than configured. The magnitude\n of the difference depends on the number of used styles, graphemes, etc.\n since the row-count in a page is dynamic based on that. In general,\n it ranges from dozens to a hundred or so lines.\n\n This works alongside the line limit configuration. If both are set,\n the first-reached limit is used first. Both limits are dependent\n on external state (byte limit can be reached with less lines if\n more styles are used for example, line limit can be reached with\n a narrower terminal viewport). So, they are useful together.\n\n Lowering the limit immediately removes eligible complete historical\n pages. A NULL value pointer removes the line limit.\n\n Input type: size_t*"]
pub const GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_LINES: Type = 28;
#[doc = " Callback invoked when the running program requests a desktop\n notification via OSC 9 or OSC 777. Set to NULL to ignore desktop\n notification requests.\n\n Input type: GhosttyTerminalDesktopNotificationFn"]
pub const GHOSTTY_TERMINAL_OPT_DESKTOP_NOTIFICATION: Type = 29;
#[doc = " Callback invoked when the running program reports progress via OSC 9;4.\n Set to NULL to ignore progress reports.\n\n Input type: GhosttyTerminalProgressReportFn"]
pub const GHOSTTY_TERMINAL_OPT_PROGRESS_REPORT: Type = 30;
#[doc = " Set the maximum number of replay-safe VT continuation bytes retained.\n\n Continuation bytes reconstruct an escape sequence or UTF-8 codepoint\n which was unfinished at the end of the most recent\n VT write call. They are used automatically by terminal snapshots and may\n also be exported directly with the continuation APIs.\n\n Tracking is disabled by default. A nonzero value enables tracking and\n sets its byte limit. Passing NULL or a pointer to zero disables tracking.\n Lowering the limit below an already-retained\n continuation, or enabling tracking while the parser is already\n unfinished, makes the current continuation unavailable because earlier\n bytes cannot be reconstructed. Tracking recovers automatically after a\n later write reaches the ground state or contains a fresh replay start.\n\n Input type: size_t*"]
pub const GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES: Type = 31;
#[doc = " Enable window title reports in response to CSI 21 t.\n\n This is disabled by default because a running program can set a title and\n query it back into the pty input stream, potentially injecting commands\n that execute after user interaction. Passing NULL or a pointer to false\n disables title reporting.\n\n Input type: bool*"]
pub const GHOSTTY_TERMINAL_OPT_TITLE_REPORT: Type = 32;
#[doc = " Set the reset default for a terminal mode.\n\n This unconditionally updates both the current value and the value restored\n by a terminal reset. RIS restores every mode, and DECSTR only a subset.\n\n Some recognized modes represent transitions or mirror additional terminal\n state and cannot safely be configured as reset defaults. Those modes return\n GHOSTTY_INVALID_VALUE. A NULL value pointer also returns\n GHOSTTY_INVALID_VALUE.\n\n Input type: GhosttyTerminalModeConfig*"]
pub const GHOSTTY_TERMINAL_OPT_MODE_DEFAULT: Type = 33;
#[doc = " Set the current value of a terminal mode.\n\n This does not change the value restored by a reset (RIS or DECSTR).\n A NULL value pointer or unknown mode returns GHOSTTY_INVALID_VALUE.\n\n Input type: GhosttyTerminalModeConfig*"]
pub const GHOSTTY_TERMINAL_OPT_MODE: Type = 34;
#[doc = " Callback for escape sequences that libghostty-vt does not implement.\n Set to NULL to stop receiving them.\n\n GHOSTTY_TERMINAL_OPT_UNKNOWN_MAX_BYTES must also be set, or the\n callback is never called. See the Unsupported Sequences section of the\n terminal documentation for an example.\n\n Input type: GhosttyTerminalUnknownSequenceFn"]
pub const GHOSTTY_TERMINAL_OPT_UNKNOWN_SEQUENCE: Type = 35;
#[doc = " The most bytes of each unsupported sequence to keep and pass to the\n GHOSTTY_TERMINAL_OPT_UNKNOWN_SEQUENCE callback. The same limit applies\n to APC and OSC sequences.\n\n Zero, the default, turns unsupported sequence reporting off. A NULL\n value pointer also sets it to zero.\n\n A sequence longer than the limit is still reported. Its content holds\n the first bytes up to the limit, and `truncated` is true.\n\n Choose a limit that fits the largest sequence you expect. Unknown OSC\n sequences up to 2048 bytes are kept in a buffer the terminal already\n owns, so limits up to 2048 add no memory allocations for OSC. Larger\n limits allocate memory for each unknown OSC sequence. Unknown APC\n sequences are always kept in allocated memory.\n\n Input type: size_t*"]
pub const GHOSTTY_TERMINAL_OPT_UNKNOWN_MAX_BYTES: Type = 36;
#[doc = " Set the name of the terminfo entry this terminal runs as, reported\n in response to an XTGETTCAP query for \"TN\" (e.g. \"xterm-256color\").\n\n The string data is copied into the terminal. A NULL value pointer\n clears the name (equivalent to setting an empty string). A name\n longer than 128 bytes returns GHOSTTY_INVALID_VALUE.\n\n If this is unset then we don't report anything for an XTGETTCAP\n TN query, because we don't know what the embedding terminal around\n libghostty is advertising itself as.\n\n Input type: GhosttyString*"]
pub const GHOSTTY_TERMINAL_OPT_TERMINFO_NAME: Type = 37;
#[doc = " Callback invoked when the running program requests clipboard contents\n via OSC 52 with a \"?\" payload or a Kitty clipboard (OSC 5522) read. The\n read is synchronous and must be answered before the callback returns.\n Set to NULL (the default) to ignore OSC 52 read requests and refuse\n OSC 5522 reads with EPERM.\n\n Input type: GhosttyTerminalClipboardReadFn"]
pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_READ: Type = 38;
#[doc = " Set the maximum total decoded bytes a single Kitty clipboard protocol\n (OSC 5522) write transaction may accumulate. The limit is captured\n when a transaction begins; an in-flight transaction keeps the limit\n it started with.\n\n Data beyond the limit fails the whole transaction with EFBIG. The\n transaction is discarded, later write-related packets are ignored\n until a new write begins, and nothing reaches the clipboard write\n callback.\n\n Transactions are buffered in memory, so this limit bounds how much\n memory a single write can make the terminal allocate. Pass SIZE_MAX\n to remove the limit. A NULL value pointer reverts to the built-in\n default of 64MiB, the minimum required by the protocol.\n\n This limit doesn't apply to OSC 52 writes, which are bounded by the\n maximum length of an escape sequence instead.\n\n Input type: size_t*"]
pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE_MAX_BYTES: Type = 39;
#[doc = " Set whether a resize may pull rows out of scrollback back into the\n active area.\n\n When true, growing rows reveals scrollback if the cursor is on the\n bottom row, and a column reflow that needs fewer rows reveals\n scrollback as well. When false, growing rows always appends blank rows\n at the bottom and a column reflow keeps the top of the active area on\n the same content, so a line that is fully in scrollback stays there. A\n soft-wrapped line with at least one row still in the active area may\n still unwrap back into view.\n\n Set this to false when the pty keeps its own screen buffer without\n scrollback, since it cannot pull rows back and will otherwise disagree\n with the terminal about the screen contents after a resize. Windows\n ConPTY is the motivating case.\n\n This is preserved across a full reset (RIS).\n\n A NULL value pointer resets to the built-in default of true.\n\n Input type: bool*"]
pub const GHOSTTY_TERMINAL_OPT_RESIZE_PULL_SCROLLBACK: Type = 40;
#[doc = " Callback invoked when the running program asks the terminal to\n stop updating the screen and when it allows updates again. Today\n this is driven by synchronized output (mode 2026). Set to NULL to\n ignore these events.\n\n See GhosttyTerminalRenderHoldFn for how to use this in a renderer.\n\n Input type: GhosttyTerminalRenderHoldFn"]
pub const GHOSTTY_TERMINAL_OPT_RENDER_HOLD: Type = 41;
#[doc = " Callback invoked when the shell reports a step of a command: a prompt\n starts, input starts, output starts, or the command ends. Set to NULL\n to ignore these events.\n\n Input type: GhosttyTerminalSemanticPromptFn"]
pub const GHOSTTY_TERMINAL_OPT_SEMANTIC_PROMPT: Type = 42;
#[doc = " Callback invoked after the running program performs a full reset\n (RIS, ESC c). Set to NULL to ignore resets.\n\n Input type: GhosttyTerminalResetFn"]
pub const GHOSTTY_TERMINAL_OPT_RESET: Type = 43;
#[doc = " Enable checksum reports in response to DECRQCRA (CSI Pi ; Pg ; Pt ; Pl ;\n Pb ; Pr * y).\n\n This is disabled by default because a running program can checksum the\n screen one cell at a time and so read back everything on it, including\n output from other programs. Passing NULL or a pointer to false disables\n checksum reporting.\n\n While this is disabled, XTCHECKSUM (CSI Ps # y), which changes how the\n checksum is calculated, is ignored as well.\n\n Input type: bool*"]
pub const GHOSTTY_TERMINAL_OPT_XT_CHECKSUM_REPORT: Type = 44;
#[doc = " Set how the DECRQCRA checksum is calculated after a reset (RIS or DECSTR).\n This also changes the current calculation.\n\n The value holds the same bits as XTCHECKSUM (CSI Ps # y) and xterm's\n checksumExtension resource, which a running program can still use to\n change the calculation until the next reset:\n\n - 1: don't negate the result\n - 2: don't add the video attributes of each cell\n - 4: don't omit blanks\n - 8: count cells that were never written to as spaces\n - 16: use full codepoints instead of the DEC 8-bit values\n\n Zero, or passing NULL, is the calculation of a real DEC terminal.\n Values above 31 return GHOSTTY_INVALID_VALUE.\n\n Input type: uint8_t*"]
pub const GHOSTTY_TERMINAL_OPT_XT_CHECKSUM_EXTENSION: Type = 45;
#[doc = " Callback invoked when the running program sends a program status\n report via OSC 7501. Set to NULL to ignore these reports.\n\n Programs may ask whether the terminal supports the protocol by\n sending `OSC 7501 ; ?`. While this callback is set, the terminal\n answers through GHOSTTY_TERMINAL_OPT_WRITE_PTY with `?` followed by\n the states and kinds it accepts:\n\n @code\n program: ESC ] 7501 ; ? ST\n terminal: ESC ] 7501 ; ?:states=idle,working,done,blocked,error:kinds=permission,question,auth ST\n @endcode\n\n While this callback is NULL, the query gets no reply, so a program\n that asks sees the protocol as unsupported. Asking is optional, so\n programs may send reports anyway. Those are dropped. Set a write_pty\n callback too, or programs never see the reply.\n\n Input type: GhosttyTerminalProgramStatusFn"]
pub const GHOSTTY_TERMINAL_OPT_PROGRAM_STATUS: Type = 46;
#[doc = " Callback invoked when the running program asks to resize the window,\n such as with CSI 8 ; rows ; columns t. Set to NULL to ignore resize\n requests.\n\n Input type: GhosttyTerminalResizeWindowFn"]
pub const GHOSTTY_TERMINAL_OPT_RESIZE_WINDOW: Type = 47;
#[doc = " Callback invoked when the running program asks to resize the window,\n such as with CSI 8 ; rows ; columns t. Set to NULL to ignore resize\n requests.\n\n Input type: GhosttyTerminalResizeWindowFn"]
pub const GHOSTTY_TERMINAL_OPT_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyTerminalData {
#[doc = " Terminal data types.\n\n These values specify what type of data to extract from a terminal\n using `ghostty_terminal_get`.\n\n @ingroup terminal"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const GHOSTTY_TERMINAL_DATA_INVALID: Type = 0;
#[doc = " Terminal width in cells.\n\n Output type: uint16_t *"]
pub const GHOSTTY_TERMINAL_DATA_COLS: Type = 1;
#[doc = " Terminal height in cells.\n\n Output type: uint16_t *"]
pub const GHOSTTY_TERMINAL_DATA_ROWS: Type = 2;
#[doc = " Cursor column position (0-indexed).\n\n Output type: uint16_t *"]
pub const GHOSTTY_TERMINAL_DATA_CURSOR_X: Type = 3;
#[doc = " Cursor row position within the active area (0-indexed).\n\n Output type: uint16_t *"]
pub const GHOSTTY_TERMINAL_DATA_CURSOR_Y: Type = 4;
#[doc = " Whether the cursor has a pending wrap (next print will soft-wrap).\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_CURSOR_PENDING_WRAP: Type = 5;
#[doc = " The currently active screen.\n\n Output type: GhosttyTerminalScreen *"]
pub const GHOSTTY_TERMINAL_DATA_ACTIVE_SCREEN: Type = 6;
#[doc = " Whether the cursor is visible (DEC mode 25).\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_CURSOR_VISIBLE: Type = 7;
#[doc = " Current Kitty keyboard protocol flags.\n\n Output type: GhosttyKittyKeyFlags * (uint8_t *)"]
pub const GHOSTTY_TERMINAL_DATA_KITTY_KEYBOARD_FLAGS: Type = 8;
#[doc = " Scrollbar state for the terminal viewport.\n\n This is amortized O(1): the total is maintained incrementally as\n the terminal is modified and the viewport offset is cached. The\n first read after the viewport moves to an arbitrary position that\n isn't an absolute row (e.g. scrolling to a selection) may cost\n O(pages) to compute the offset, after which it is cached again.\n\n There is intentionally no change notification for scroll state.\n Callers building scrollbars should poll this once per frame or\n per write batch and diff the result to detect changes; this is\n what Ghostty's own renderer does.\n\n Output type: GhosttyTerminalScrollbar *"]
pub const GHOSTTY_TERMINAL_DATA_SCROLLBAR: Type = 9;
#[doc = " The current SGR style of the cursor.\n\n This is the style that will be applied to newly printed characters.\n\n Output type: GhosttyStyle *"]
pub const GHOSTTY_TERMINAL_DATA_CURSOR_STYLE: Type = 10;
#[doc = " Whether any mouse tracking mode is active.\n\n Returns true if any of the mouse tracking modes (X10, normal, button,\n or any-event) are enabled.\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_MOUSE_TRACKING: Type = 11;
#[doc = " The terminal title as set by escape sequences (e.g. OSC 0/2).\n\n Returns a borrowed string. The pointer is valid until the next mutating\n terminal call. An empty string (len=0) is returned when no title has been\n set.\n\n Output type: GhosttyString *"]
pub const GHOSTTY_TERMINAL_DATA_TITLE: Type = 12;
#[doc = " The terminal's current working directory as set by escape sequences\n (e.g. OSC 7).\n\n Returns a borrowed string. The pointer is valid until the next mutating\n terminal call. An empty string (len=0) is returned when no pwd has been\n set.\n\n Output type: GhosttyString *"]
pub const GHOSTTY_TERMINAL_DATA_PWD: Type = 13;
#[doc = " The total number of rows in the active screen including scrollback.\n\n Output type: size_t *"]
pub const GHOSTTY_TERMINAL_DATA_TOTAL_ROWS: Type = 14;
#[doc = " The number of scrollback rows (total rows minus viewport rows).\n\n Output type: size_t *"]
pub const GHOSTTY_TERMINAL_DATA_SCROLLBACK_ROWS: Type = 15;
#[doc = " The total width of the terminal in pixels.\n\n This is cols * cell_width_px as set by ghostty_terminal_resize().\n\n Output type: uint32_t *"]
pub const GHOSTTY_TERMINAL_DATA_WIDTH_PX: Type = 16;
#[doc = " The total height of the terminal in pixels.\n\n This is rows * cell_height_px as set by ghostty_terminal_resize().\n\n Output type: uint32_t *"]
pub const GHOSTTY_TERMINAL_DATA_HEIGHT_PX: Type = 17;
#[doc = " The effective foreground color (override or default).\n\n Returns GHOSTTY_NO_VALUE if no foreground color is set.\n\n Output type: GhosttyColorRgb *"]
pub const GHOSTTY_TERMINAL_DATA_COLOR_FOREGROUND: Type = 18;
#[doc = " The effective background color (override or default).\n\n Returns GHOSTTY_NO_VALUE if no background color is set.\n\n Output type: GhosttyColorRgb *"]
pub const GHOSTTY_TERMINAL_DATA_COLOR_BACKGROUND: Type = 19;
#[doc = " The effective cursor color (override or default).\n\n Returns GHOSTTY_NO_VALUE if no cursor color is set.\n\n Output type: GhosttyColorRgb *"]
pub const GHOSTTY_TERMINAL_DATA_COLOR_CURSOR: Type = 20;
#[doc = " The current 256-color palette.\n\n Output type: GhosttyColorRgb[256] *"]
pub const GHOSTTY_TERMINAL_DATA_COLOR_PALETTE: Type = 21;
#[doc = " The default foreground color (ignoring any OSC override).\n\n Returns GHOSTTY_NO_VALUE if no default foreground color is set.\n\n Output type: GhosttyColorRgb *"]
pub const GHOSTTY_TERMINAL_DATA_COLOR_FOREGROUND_DEFAULT: Type = 22;
#[doc = " The default background color (ignoring any OSC override).\n\n Returns GHOSTTY_NO_VALUE if no default background color is set.\n\n Output type: GhosttyColorRgb *"]
pub const GHOSTTY_TERMINAL_DATA_COLOR_BACKGROUND_DEFAULT: Type = 23;
#[doc = " The default cursor color (ignoring any OSC override).\n\n Returns GHOSTTY_NO_VALUE if no default cursor color is set.\n\n Output type: GhosttyColorRgb *"]
pub const GHOSTTY_TERMINAL_DATA_COLOR_CURSOR_DEFAULT: Type = 24;
#[doc = " The default 256-color palette (ignoring any OSC overrides).\n\n Output type: GhosttyColorRgb[256] *"]
pub const GHOSTTY_TERMINAL_DATA_COLOR_PALETTE_DEFAULT: Type = 25;
#[doc = " The Kitty image storage limit in bytes for the active screen.\n\n A value of zero means the Kitty graphics protocol is disabled.\n Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.\n\n Output type: uint64_t *"]
pub const GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_STORAGE_LIMIT: Type = 26;
#[doc = " Whether the file medium is enabled for Kitty image loading on the\n active screen.\n\n Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_FILE: Type = 27;
#[doc = " The directory allowed for Kitty image loading via the temporary file\n medium on the active screen. The string is empty when the medium is\n disabled.\n\n Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.\n\n Output type: GhosttyString *"]
pub const GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_TEMP_FILE: Type = 28;
#[doc = " Whether the shared memory medium is enabled for Kitty image loading\n on the active screen.\n\n Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_KITTY_IMAGE_MEDIUM_SHARED_MEM: Type = 29;
#[doc = " The Kitty graphics image storage for the active screen.\n\n Returns a borrowed pointer to the image storage. The pointer is valid\n until the next mutating terminal call (e.g. ghostty_terminal_vt_write()\n or ghostty_terminal_reset()).\n\n Returns GHOSTTY_NO_VALUE when Kitty graphics are disabled at build time.\n\n Output type: GhosttyKittyGraphics *"]
pub const GHOSTTY_TERMINAL_DATA_KITTY_GRAPHICS: Type = 30;
#[doc = " The active screen's current selection.\n\n On success, writes an untracked snapshot of the terminal-owned selection\n to the caller-provided GhosttySelection. The GhosttySelection struct is\n caller-owned and may be kept, but the grid references inside it are\n untracked borrowed references into the active screen. They are only valid\n until the next mutating terminal call, such as ghostty_terminal_set(),\n ghostty_terminal_vt_write(), ghostty_terminal_resize(), or\n ghostty_terminal_reset().\n\n Returns GHOSTTY_NO_VALUE when there is no active selection.\n\n Output type: GhosttySelection *"]
pub const GHOSTTY_TERMINAL_DATA_SELECTION: Type = 31;
#[doc = " Whether the viewport is currently pinned to the active area.\n\n This is true when the viewport is following the active terminal area,\n and false when the user has scrolled into history.\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_VIEWPORT_ACTIVE: Type = 32;
#[doc = " Whether VT processing encountered a non-gracefully handled error that may\n have prevented a terminal-owned semantic update.\n\n Processing remains best-effort, and ghostty_terminal_reset() does not\n clear it. Gracefully handled protocol failures, configured limits,\n malformed or unsupported input, and failures limited to external effects\n or query responses do not set it.\n\n This can't currently be unset. This is purely informational to consumers\n if there was some error that happened at some point during VT processing.\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_VT_PROCESSING_ERROR: Type = 33;
#[doc = " The configured maximum scrollback allocation in bytes.\n\n This always reports the primary screen's configured value, including\n while an alternate screen is active. Returns GHOSTTY_NO_VALUE when the\n configured byte limit is unlimited.\n\n Output type: size_t *"]
pub const GHOSTTY_TERMINAL_DATA_SCROLLBACK_MAX_BYTES: Type = 34;
#[doc = " The configured maximum number of physical scrollback lines.\n\n This always reports the primary screen's configured value, including\n while an alternate screen is active. Returns GHOSTTY_NO_VALUE when the\n configured line limit is unlimited.\n\n Output type: size_t *"]
pub const GHOSTTY_TERMINAL_DATA_SCROLLBACK_MAX_LINES: Type = 35;
#[doc = " The configured maximum retained VT continuation size in bytes.\n\n A value of zero means continuation tracking is disabled. This reports the\n configured limit even when a current unfinished continuation is\n temporarily unavailable.\n\n Output type: size_t *"]
pub const GHOSTTY_TERMINAL_DATA_CONTINUATION_MAX_BYTES: Type = 36;
#[doc = " Get the current value of a terminal mode.\n\n The caller must initialize the `mode` field. On success, the `value` field\n is updated with the current value. A NULL pointer or unknown mode returns\n GHOSTTY_INVALID_VALUE.\n\n Input/output type: GhosttyTerminalModeConfig *"]
pub const GHOSTTY_TERMINAL_DATA_MODE: Type = 37;
#[doc = " Whether VT processing is at ground.\n\n Ground is when the stream isn't in the middle of any type of sequence:\n UTF-8, ESC, CSI, OSC, etc. It is the stateless point of the stream.\n\n This is useful to know because it is a point at which you can\n safely insert out-of-band VT sequences. For example, while reading\n from a pty if you want to make your own changes, you can wait until\n the pty input reaches ground, then write yours.\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_VT_GROUND: Type = 38;
#[doc = " Whether the cursor is currently at a semantic shell prompt or input area.\n\n This depends on semantic prompt markers such as OSC 133. Returns false\n when semantic prompt information is unavailable or the alternate screen\n is active.\n\n Output type: bool *"]
pub const GHOSTTY_TERMINAL_DATA_CURSOR_AT_PROMPT: Type = 39;
#[doc = " The configured maximum decoded bytes per Kitty clipboard protocol\n (OSC 5522) write transaction. See\n GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE_MAX_BYTES.\n\n Output type: size_t *"]
pub const GHOSTTY_TERMINAL_DATA_CLIPBOARD_WRITE_MAX_BYTES: Type = 40;
#[doc = " The mouse pointer shape requested by the application through OSC 22.\n\n Initially GHOSTTY_MOUSE_SHAPE_TEXT. Excludes host hover overrides.\n\n Output type: GhosttyMouseShape *"]
pub const GHOSTTY_TERMINAL_DATA_MOUSE_SHAPE: Type = 41;
#[doc = " How much memory the terminal holds. See GhosttyTerminalMemoryUsage\n for what each field means.\n\n Set the struct's `size` field before the call, for example with\n GHOSTTY_INIT_SIZED(). If `size` is too small, this returns\n GHOSTTY_INVALID_VALUE and leaves the struct unchanged.\n\n This never decompresses scrollback, but it does look at every page, so\n avoid reading it after every write.\n\n Output type: GhosttyTerminalMemoryUsage *"]
pub const GHOSTTY_TERMINAL_DATA_MEMORY_USAGE: Type = 42;
#[doc = " How much memory the terminal holds. See GhosttyTerminalMemoryUsage\n for what each field means.\n\n Set the struct's `size` field before the call, for example with\n GHOSTTY_INIT_SIZED(). If `size` is too small, this returns\n GHOSTTY_INVALID_VALUE and leaves the struct unchanged.\n\n This never decompresses scrollback, but it does look at every page, so\n avoid reading it after every write.\n\n Output type: GhosttyTerminalMemoryUsage *"]
pub const GHOSTTY_TERMINAL_DATA_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a new terminal instance.\n\n The terminal starts with various reasonable defaults e.g. around\n scrollback limits. Use ghostty_terminal_set() to change any options\n prior to using the terminal.\n\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param terminal Pointer to store the created terminal handle\n @param cols Terminal width in cells (must be greater than zero)\n @param rows Terminal height in cells (must be greater than zero)\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup terminal"]
pub fn ghostty_terminal_new(
allocator: *const GhosttyAllocator,
terminal: *mut GhosttyTerminal,
cols: u16,
rows: u16,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a terminal instance.\n\n Releases all resources associated with the terminal. After this call,\n the terminal handle becomes invalid and must not be used.\n\n @param terminal The terminal handle to free (may be NULL)\n\n @ingroup terminal"]
pub fn ghostty_terminal_free(terminal: GhosttyTerminal);
}
unsafe extern "C" {
#[doc = " Perform a full reset of the terminal (RIS).\n\n Resets all terminal state back to its initial configuration, including\n modes, scrollback, scrolling region, and screen contents. The terminal\n dimensions are preserved.\n\n If synchronized output was enabled, the GHOSTTY_TERMINAL_OPT_RENDER_HOLD\n callback is invoked to report that the hold ended.\n\n @param terminal The terminal handle (may be NULL, in which case this is a no-op)\n\n @ingroup terminal"]
pub fn ghostty_terminal_reset(terminal: GhosttyTerminal);
}
unsafe extern "C" {
#[doc = " Resize the terminal to the given dimensions.\n\n Changes the number of columns and rows in the terminal. The primary\n screen will reflow content if wraparound mode is enabled; the alternate\n screen does not reflow. If the dimensions are unchanged, the grid is\n left as is, but everything below still applies.\n\n This also updates the terminal's pixel dimensions (used for image\n protocols and size reports), disables synchronized output mode (allowed\n by the spec so that resize results are shown immediately), and sends an\n in-band size report if mode 2048 is enabled.\n\n If synchronized output was enabled, the GHOSTTY_TERMINAL_OPT_RENDER_HOLD\n callback is invoked to report that the hold ended.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param cols New width in cells (must be greater than zero)\n @param rows New height in cells (must be greater than zero)\n @param cell_width_px Width of a single cell in pixels\n @param cell_height_px Height of a single cell in pixels\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup terminal"]
pub fn ghostty_terminal_resize(
terminal: GhosttyTerminal,
cols: u16,
rows: u16,
cell_width_px: u32,
cell_height_px: u32,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Set an option on the terminal.\n\n Configures terminal callbacks and associated state such as the\n write_pty callback and userdata pointer. The value is passed\n directly for pointer types (callbacks, userdata) or as a pointer\n to the value for non-pointer types (e.g. GhosttyString*).\n The behavior of a NULL value is specific to each option and is\n documented by the corresponding GhosttyTerminalOption value.\n\n Callbacks are invoked synchronously during VT writes. Callbacks must not\n call ghostty_terminal_vt_write() or\n ghostty_terminal_vt_write_until_ground() on the same terminal\n (no reentrancy).\n\n @param terminal The terminal handle (may be NULL, in which case this is a no-op)\n @param option The option to set\n @param value Pointer to the value to set (type depends on the option),\n or NULL to clear the option\n\n @ingroup terminal"]
pub fn ghostty_terminal_set(
terminal: GhosttyTerminal,
option: GhosttyTerminalOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Write VT-encoded data to the terminal for processing.\n\n Feeds raw bytes through the terminal's VT stream parser, updating\n terminal state accordingly. By default, sequences that require output\n (queries, device status reports) are silently ignored. Use\n ghostty_terminal_set() with GHOSTTY_TERMINAL_OPT_WRITE_PTY to install\n a callback that receives response data.\n\n This never fails. Any erroneous input or errors in processing the\n input are logged internally but do not cause this function to fail\n because this input is assumed to be untrusted and from an external\n source; so the primary goal is to keep the terminal state consistent and\n not allow malformed input to corrupt or crash.\n\n @param terminal The terminal handle\n @param data Pointer to the data to write\n @param len Length of the data in bytes\n\n @ingroup terminal"]
pub fn ghostty_terminal_vt_write(terminal: GhosttyTerminal, data: *const u8, len: usize);
}
unsafe extern "C" {
#[doc = " Write VT-encoded data, but only the shortest prefix needed to reach ground.\n\n Ground is when the stream isn't in the middle of any type of sequence:\n UTF-8, ESC, CSI, OSC, etc. It is the stateless point of the stream.\n\n This is useful to know because it is a point at which you can\n safely insert out-of-band VT sequences. For example, while reading\n from a pty if you want to make your own changes, you can wait until\n the pty input reaches ground, then write yours.\n\n If the stream is already at ground then this consumes nothing and returns\n GHOSTTY_SUCCESS. On success, out_consumed is the number of bytes consumed\n before reaching ground, including the byte that reaches it.\n GHOSTTY_NO_VALUE means the full slice was consumed without reaching ground.\n\n @param terminal The terminal handle (must not be NULL)\n @param data Pointer to the data to write, or NULL when len is zero\n @param len Length of the data in bytes\n @param[out] out_consumed Number of bytes consumed (must not be NULL)\n @return GHOSTTY_SUCCESS if ground was reached, GHOSTTY_NO_VALUE if all input\n was consumed without reaching ground, or GHOSTTY_INVALID_VALUE if\n an argument is invalid\n\n @ingroup terminal"]
pub fn ghostty_terminal_vt_write_until_ground(
terminal: GhosttyTerminal,
data: *const u8,
len: usize,
out_consumed: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Write the terminal's replay-safe VT continuation to a callback writer.\n\n The continuation is the exact byte suffix needed to reconstruct unfinished\n VT parser or UTF-8 decoder state in an equivalent terminal. It is empty\n when the stream is at ground. The callback is invoked synchronously and\n may be called more than once. It must not call terminal APIs with the same\n terminal handle.\n\n Continuation tracking must have been enabled by setting\n GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES to a nonzero value before the\n input that produced the continuation was written.\n\n The caller must serialize this operation with both VT write functions and\n all other access to the same terminal.\n\n @param terminal Terminal to read from (must not be NULL)\n @param writer Destination writer whose write callback must not be NULL\n @return GHOSTTY_SUCCESS on success, GHOSTTY_IO_ERROR if the callback rejects\n a write, GHOSTTY_LIMIT_EXCEEDED if output accounting overflows, or\n GHOSTTY_INVALID_VALUE if an argument is invalid, tracking is\n disabled, or the current continuation is unavailable\n\n @ingroup terminal"]
pub fn ghostty_terminal_continuation_write(
terminal: GhosttyTerminal,
writer: GhosttyWriter,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Copy the terminal's replay-safe VT continuation into a caller buffer.\n\n Pass NULL for buf with buf_len zero to query the required size. A size query\n returns GHOSTTY_OUT_OF_SPACE and stores the required size in out_written,\n including zero when the stream is at ground. If a non-NULL buffer is too\n small, the function has the same result and reports the full required size.\n Continuation tracking must have been enabled by setting\n GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES to a nonzero value before the\n input that produced the continuation was written.\n\n The caller must serialize this operation with all other access to the same\n terminal.\n\n @param terminal Terminal to read from (must not be NULL)\n @param buf Destination buffer, or NULL when buf_len is zero\n @param buf_len Destination buffer capacity in bytes\n @param[out] out_written Bytes written, or required size on\n GHOSTTY_OUT_OF_SPACE (must not be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE for a size query or\n insufficient buffer, or GHOSTTY_INVALID_VALUE if an argument is\n invalid, tracking is disabled, or the current continuation is\n unavailable\n\n @ingroup terminal"]
pub fn ghostty_terminal_continuation_buf(
terminal: GhosttyTerminal,
buf: *mut u8,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Return an allocated copy of the terminal's replay-safe VT continuation.\n\n The returned bytes are allocated with allocator, or the default allocator\n when allocator is NULL. The caller must release them with ghostty_free(),\n passing the same allocator and returned length. An empty continuation is a\n successful result with *out_ptr set to NULL and *out_len set to zero,\n which can also be passed to ghostty_free().\n Continuation tracking must have been enabled by setting\n GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES to a nonzero value before the\n input that produced the continuation was written.\n\n The caller must serialize this operation with all other access to the same\n terminal.\n\n @param terminal Terminal to read from (must not be NULL)\n @param allocator Allocator for the output, or NULL for the default allocator\n @param[out] out_ptr Allocated continuation bytes (must not be NULL)\n @param[out] out_len Number of continuation bytes (must not be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_MEMORY on allocation\n failure, or GHOSTTY_INVALID_VALUE if an argument is invalid,\n tracking is disabled, or the current continuation is unavailable\n\n @ingroup terminal"]
pub fn ghostty_terminal_continuation_alloc(
terminal: GhosttyTerminal,
allocator: *const GhosttyAllocator,
out_ptr: *mut *mut u8,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Scroll the terminal viewport.\n\n Scrolls the terminal's viewport according to the given behavior.\n When using GHOSTTY_SCROLL_VIEWPORT_DELTA, set the delta field in\n the value union to specify the number of rows to scroll (negative\n for up, positive for down). When using GHOSTTY_SCROLL_VIEWPORT_ROW,\n set the row field to the absolute row offset from the top of the\n scrollable area (the same row space as the offset field of\n GhosttyTerminalScrollbar). When using\n GHOSTTY_SCROLL_VIEWPORT_DELTA_PROMPT, set delta_prompt to the signed\n number of prompts to move. See GHOSTTY_SCROLL_VIEWPORT_DELTA_PROMPT for\n the navigation behavior. For other behaviors, the value is ignored.\n\n @param terminal The terminal handle (may be NULL, in which case this is a no-op)\n @param behavior The scroll behavior as a tagged union\n\n @ingroup terminal"]
pub fn ghostty_terminal_scroll_viewport(
terminal: GhosttyTerminal,
behavior: GhosttyTerminalScrollViewport,
);
}
unsafe extern "C" {
#[doc = " Return the current compression activity token.\n\n The token is opaque and only equality comparisons are meaningful. An\n embedding application should cache it and restart its compression idle\n delay whenever the value changes. The value may wrap and changes in either\n direction have the same meaning.\n\n This function only observes terminal state. It does not perform or schedule\n compression.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param[out] out_activity Receives the current activity token\n @return GHOSTTY_SUCCESS on success, or GHOSTTY_INVALID_VALUE if an argument\n is NULL\n\n @ingroup terminal"]
pub fn ghostty_terminal_compression_activity(
terminal: GhosttyTerminal,
out_activity: *mut u64,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Compress eligible terminal scrollback.\n\n Incremental mode performs bounded work suitable for an idle callback. A\n pending result means the application should invoke another step while the\n terminal remains idle. A complete result means no continuation is needed\n until ghostty_terminal_compression_activity() changes. Full mode performs\n one synchronous scan and can stall on large scrollback buffers.\n\n Compression is opportunistic. Complete means the pass has finished, not\n that every page was compressed: pages may be unprofitable or encounter an\n allocation or reclamation failure. Compression changes only the terminal's\n storage representation and never its logical contents or scrollback limit.\n Accessing compressed history restores it transparently.\n\n This function is not thread-safe with other operations on the same\n terminal. The caller must serialize it with writes, rendering, searches,\n and other terminal access.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param mode The amount of compression work to perform\n @param[out] out_result Receives the compression scheduling result\n @return GHOSTTY_SUCCESS on success, or GHOSTTY_INVALID_VALUE if an argument\n or mode is invalid\n\n @ingroup terminal"]
pub fn ghostty_terminal_compress(
terminal: GhosttyTerminal,
mode: GhosttyTerminalCompressionMode::Type,
out_result: *mut GhosttyTerminalCompressionResult::Type,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get data from a terminal instance.\n\n Extracts typed data from the given terminal based on the specified\n data type. The output pointer must be of the appropriate type for the\n requested data kind. Valid data types and output types are documented\n in the `GhosttyTerminalData` enum.\n\n @param terminal The terminal handle (may be NULL)\n @param data The type of data to extract\n @param out Pointer to store the extracted data (type depends on data parameter)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal\n is NULL or the data type is invalid\n\n @ingroup terminal"]
pub fn ghostty_terminal_get(
terminal: GhosttyTerminal,
data: GhosttyTerminalData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple data fields from a terminal in a single call.\n\n This is an optimization over calling ghostty_terminal_get()\n repeatedly, particularly useful in environments with high per-call\n overhead such as FFI or Cgo.\n\n Each element in the keys array specifies a data kind, and the\n corresponding element in the values array receives the result.\n The type of each values[i] pointer must match the output type\n documented for keys[i].\n\n Processing stops at the first error; on success out_written\n is set to count, on error it is set to the index of the\n failing key (i.e. the number of values successfully written).\n\n @param terminal The terminal handle (may be NULL)\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers (types must match each key's\n documented output type)\n @param[out] out_written On return, receives the number of values\n successfully written (may be NULL)\n @return GHOSTTY_SUCCESS if all queries succeed\n\n @ingroup terminal"]
pub fn ghostty_terminal_get_multi(
terminal: GhosttyTerminal,
count: usize,
keys: *const GhosttyTerminalData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Resolve a point in the terminal grid to a grid reference.\n\n Resolves the given point (which can be in active, viewport, screen,\n or history coordinates) to a grid reference for that location. Use\n ghostty_grid_ref_cell() and ghostty_grid_ref_row() to extract the cell\n and row.\n\n Lookups using the `active` and `viewport` tags are fast. The `screen`\n and `history` tags may require traversing the full scrollback page list\n to resolve the y coordinate, so they can be expensive for large\n scrollback buffers.\n\n This function isn't meant to be used as the core of render loop. It\n isn't built to sustain the framerates needed for rendering large screens.\n Use the render state API for that. This API is instead meant for less\n strictly performance-sensitive use cases.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param point The point specifying which cell to look up\n @param[out] out_ref On success, set to the grid reference at the given point (may be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal\n is NULL or the point is out of bounds\n\n @ingroup terminal"]
pub fn ghostty_terminal_grid_ref(
terminal: GhosttyTerminal,
point: GhosttyPoint,
out_ref: *mut GhosttyGridRef,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Create an owned tracked grid reference for a terminal point.\n\n This is the tracked variant of ghostty_terminal_grid_ref(). The returned\n handle follows the referenced cell as the terminal's page list is modified:\n scrolling, pruning, resize/reflow, and other page-list operations update the\n tracked reference automatically.\n\n The reference is attached to the terminal screen/page-list that is active at\n creation time.\n\n If the point is outside the requested coordinate space, this returns\n GHOSTTY_INVALID_VALUE and writes NULL to out_ref.\n\n The returned handle must be freed with ghostty_tracked_grid_ref_free(). If\n the terminal is freed first, the handle remains valid only for\n tracked-grid-ref APIs: it reports no value and can still be freed.\n\n @param terminal Terminal instance.\n @param point Point to track.\n @param[out] out_ref On success, receives the tracked reference handle.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if terminal,\n point, or out_ref is invalid, or GHOSTTY_OUT_OF_MEMORY if allocation\n fails.\n\n @ingroup terminal"]
pub fn ghostty_terminal_grid_ref_track(
terminal: GhosttyTerminal,
point: GhosttyPoint,
out_ref: *mut GhosttyTrackedGridRef,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Convert a grid reference back to a point in the given coordinate system.\n\n This is the inverse of ghostty_terminal_grid_ref(): given a grid reference,\n it returns the x/y coordinates in the requested coordinate system (active,\n viewport, screen, or history).\n\n The grid reference must have been obtained from the same terminal instance.\n Like all grid references, it is only valid until the next mutating terminal\n call.\n\n Not every grid reference is representable in every coordinate system. For\n example, a cell in scrollback history cannot be expressed in active\n coordinates, and a cell that has scrolled off the visible area cannot be\n expressed in viewport coordinates. In these cases, the function returns\n GHOSTTY_NO_VALUE.\n\n @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param ref Pointer to the grid reference to convert\n @param tag The target coordinate system\n @param[out] out On success, set to the coordinate in the requested system (may be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal\n or ref is NULL/invalid, GHOSTTY_NO_VALUE if the ref falls outside\n the requested coordinate system\n\n @ingroup terminal"]
pub fn ghostty_terminal_point_from_grid_ref(
terminal: GhosttyTerminal,
ref_: *const GhosttyGridRef,
tag: GhosttyPointTag::Type,
out: *mut GhosttyPointCoordinate,
) -> GhosttyResult::Type;
}
#[doc = " Extra screen state to include in styled output.\n\n @ingroup formatter"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyFormatterScreenExtra {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyFormatterScreenExtra)."]
pub size: usize,
#[doc = " Emit cursor position using CUP (CSI H)."]
pub cursor: bool,
#[doc = " Emit current SGR style state based on the cursor's active style_id."]
pub style: bool,
#[doc = " Emit current hyperlink state using OSC 8 sequences."]
pub hyperlink: bool,
#[doc = " Emit character protection mode using DECSCA."]
pub protection: bool,
#[doc = " Emit Kitty keyboard protocol state using CSI > u and CSI = sequences."]
pub kitty_keyboard: bool,
#[doc = " Emit character set designations and invocations."]
pub charsets: bool,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyFormatterScreenExtra"]
[::std::mem::size_of::<GhosttyFormatterScreenExtra>() - 16usize];
["Alignment of GhosttyFormatterScreenExtra"]
[::std::mem::align_of::<GhosttyFormatterScreenExtra>() - 8usize];
["Offset of field: GhosttyFormatterScreenExtra::size"]
[::std::mem::offset_of!(GhosttyFormatterScreenExtra, size) - 0usize];
["Offset of field: GhosttyFormatterScreenExtra::cursor"]
[::std::mem::offset_of!(GhosttyFormatterScreenExtra, cursor) - 8usize];
["Offset of field: GhosttyFormatterScreenExtra::style"]
[::std::mem::offset_of!(GhosttyFormatterScreenExtra, style) - 9usize];
["Offset of field: GhosttyFormatterScreenExtra::hyperlink"]
[::std::mem::offset_of!(GhosttyFormatterScreenExtra, hyperlink) - 10usize];
["Offset of field: GhosttyFormatterScreenExtra::protection"]
[::std::mem::offset_of!(GhosttyFormatterScreenExtra, protection) - 11usize];
["Offset of field: GhosttyFormatterScreenExtra::kitty_keyboard"]
[::std::mem::offset_of!(GhosttyFormatterScreenExtra, kitty_keyboard) - 12usize];
["Offset of field: GhosttyFormatterScreenExtra::charsets"]
[::std::mem::offset_of!(GhosttyFormatterScreenExtra, charsets) - 13usize];
};
#[doc = " Extra terminal state to include in styled output.\n\n @ingroup formatter"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyFormatterTerminalExtra {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyFormatterTerminalExtra)."]
pub size: usize,
#[doc = " Emit the palette using OSC 4 sequences."]
pub palette: bool,
#[doc = " Emit terminal modes that differ from their defaults using CSI h/l."]
pub modes: bool,
#[doc = " Emit scrolling region state using DECSTBM and DECSLRM sequences."]
pub scrolling_region: bool,
#[doc = " Emit tabstop positions by clearing all tabs and setting each one."]
pub tabstops: bool,
#[doc = " Emit the present working directory using OSC 7."]
pub pwd: bool,
#[doc = " Emit keyboard modes such as ModifyOtherKeys."]
pub keyboard: bool,
#[doc = " Screen-level extras."]
pub screen: GhosttyFormatterScreenExtra,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyFormatterTerminalExtra"]
[::std::mem::size_of::<GhosttyFormatterTerminalExtra>() - 32usize];
["Alignment of GhosttyFormatterTerminalExtra"]
[::std::mem::align_of::<GhosttyFormatterTerminalExtra>() - 8usize];
["Offset of field: GhosttyFormatterTerminalExtra::size"]
[::std::mem::offset_of!(GhosttyFormatterTerminalExtra, size) - 0usize];
["Offset of field: GhosttyFormatterTerminalExtra::palette"]
[::std::mem::offset_of!(GhosttyFormatterTerminalExtra, palette) - 8usize];
["Offset of field: GhosttyFormatterTerminalExtra::modes"]
[::std::mem::offset_of!(GhosttyFormatterTerminalExtra, modes) - 9usize];
["Offset of field: GhosttyFormatterTerminalExtra::scrolling_region"]
[::std::mem::offset_of!(GhosttyFormatterTerminalExtra, scrolling_region) - 10usize];
["Offset of field: GhosttyFormatterTerminalExtra::tabstops"]
[::std::mem::offset_of!(GhosttyFormatterTerminalExtra, tabstops) - 11usize];
["Offset of field: GhosttyFormatterTerminalExtra::pwd"]
[::std::mem::offset_of!(GhosttyFormatterTerminalExtra, pwd) - 12usize];
["Offset of field: GhosttyFormatterTerminalExtra::keyboard"]
[::std::mem::offset_of!(GhosttyFormatterTerminalExtra, keyboard) - 13usize];
["Offset of field: GhosttyFormatterTerminalExtra::screen"]
[::std::mem::offset_of!(GhosttyFormatterTerminalExtra, screen) - 16usize];
};
#[doc = " Options for creating a terminal formatter.\n\n @ingroup formatter"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyFormatterTerminalOptions {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyFormatterTerminalOptions)."]
pub size: usize,
#[doc = " Output format to emit."]
pub emit: GhosttyFormatterFormat::Type,
#[doc = " Whether to unwrap soft-wrapped lines."]
pub unwrap: bool,
#[doc = " Whether to trim trailing whitespace on non-blank lines."]
pub trim: bool,
#[doc = " Extra terminal state to include in styled output."]
pub extra: GhosttyFormatterTerminalExtra,
#[doc = " Optional selection to restrict output to a range.\n If NULL, the entire screen is formatted."]
pub selection: *const GhosttySelection,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyFormatterTerminalOptions"]
[::std::mem::size_of::<GhosttyFormatterTerminalOptions>() - 56usize];
["Alignment of GhosttyFormatterTerminalOptions"]
[::std::mem::align_of::<GhosttyFormatterTerminalOptions>() - 8usize];
["Offset of field: GhosttyFormatterTerminalOptions::size"]
[::std::mem::offset_of!(GhosttyFormatterTerminalOptions, size) - 0usize];
["Offset of field: GhosttyFormatterTerminalOptions::emit"]
[::std::mem::offset_of!(GhosttyFormatterTerminalOptions, emit) - 8usize];
["Offset of field: GhosttyFormatterTerminalOptions::unwrap"]
[::std::mem::offset_of!(GhosttyFormatterTerminalOptions, unwrap) - 12usize];
["Offset of field: GhosttyFormatterTerminalOptions::trim"]
[::std::mem::offset_of!(GhosttyFormatterTerminalOptions, trim) - 13usize];
["Offset of field: GhosttyFormatterTerminalOptions::extra"]
[::std::mem::offset_of!(GhosttyFormatterTerminalOptions, extra) - 16usize];
["Offset of field: GhosttyFormatterTerminalOptions::selection"]
[::std::mem::offset_of!(GhosttyFormatterTerminalOptions, selection) - 48usize];
};
impl Default for GhosttyFormatterTerminalOptions {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Create a formatter for a terminal's active screen.\n\n The terminal must outlive the formatter. The formatter stores a borrowed\n reference to the terminal and reads its current state on each format call.\n\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param formatter Pointer to store the created formatter handle\n @param terminal The terminal to format (must not be NULL)\n @param options Formatting options\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup formatter"]
pub fn ghostty_formatter_terminal_new(
allocator: *const GhosttyAllocator,
formatter: *mut GhosttyFormatter,
terminal: GhosttyTerminal,
options: GhosttyFormatterTerminalOptions,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Run the formatter and stream output to a writer.\n\n Each call formats the current terminal state and invokes the writer\n synchronously as output becomes available. The callback may be called more\n than once and must not call formatter or terminal APIs using the same\n formatter or its terminal.\n\n If an error occurs, the writer may already contain a partial formatted\n output. The operation cannot be resumed from that partial output. This\n function does not flush or make the caller's destination durable.\n\n @param formatter The formatter handle (must not be NULL)\n @param writer Destination writer whose write callback must not be NULL\n @return GHOSTTY_SUCCESS on success, GHOSTTY_IO_ERROR if the writer rejects\n output, GHOSTTY_LIMIT_EXCEEDED if output accounting overflows, or\n GHOSTTY_INVALID_VALUE if an argument is invalid\n\n @ingroup formatter"]
pub fn ghostty_formatter_format(
formatter: GhosttyFormatter,
writer: GhosttyWriter,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Run the formatter and produce output into the caller-provided buffer.\n\n Each call formats the current terminal state. Pass NULL for buf to\n query the required buffer size without writing any output; in that case\n out_written receives the required size and the return value is\n GHOSTTY_OUT_OF_SPACE.\n\n If the buffer is too small, returns GHOSTTY_OUT_OF_SPACE and sets\n out_written to the required size. The caller can then retry with a\n larger buffer.\n\n @param formatter The formatter handle (must not be NULL)\n @param buf Pointer to the output buffer, or NULL to query size\n @param buf_len Length of the output buffer in bytes\n @param out_written Pointer to receive the number of bytes written,\n or the required size on failure\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup formatter"]
pub fn ghostty_formatter_format_buf(
formatter: GhosttyFormatter,
buf: *mut u8,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Run the formatter and return an allocated buffer with the output.\n\n Each call formats the current terminal state. The buffer is allocated\n using the provided allocator (or the default allocator if NULL).\n The caller is responsible for freeing the returned buffer with\n ghostty_free(), passing the same allocator (or NULL for the default)\n that was used for the allocation.\n Empty output returns GHOSTTY_SUCCESS with *out_ptr set to NULL and\n *out_len set to zero. This result can be passed to ghostty_free().\n\n @param formatter The formatter handle (must not be NULL)\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param out_ptr Pointer to receive the allocated buffer\n @param out_len Pointer to receive the length of the output in bytes\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_MEMORY on allocation\n failure\n\n @ingroup formatter"]
pub fn ghostty_formatter_format_alloc(
formatter: GhosttyFormatter,
allocator: *const GhosttyAllocator,
out_ptr: *mut *mut u8,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a formatter instance.\n\n Releases all resources associated with the formatter. After this call,\n the formatter handle becomes invalid.\n\n @param formatter The formatter handle to free (may be NULL)\n\n @ingroup formatter"]
pub fn ghostty_formatter_free(formatter: GhosttyFormatter);
}
pub mod GhosttyRenderStateDirty {
#[doc = " Dirty state of a render state after update.\n\n @ingroup render"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Not dirty at all; rendering can be skipped."]
pub const GHOSTTY_RENDER_STATE_DIRTY_FALSE: Type = 0;
#[doc = " Some rows changed; renderer can redraw incrementally."]
pub const GHOSTTY_RENDER_STATE_DIRTY_PARTIAL: Type = 1;
#[doc = " Global state changed; renderer should redraw everything."]
pub const GHOSTTY_RENDER_STATE_DIRTY_FULL: Type = 2;
#[doc = " Global state changed; renderer should redraw everything."]
pub const GHOSTTY_RENDER_STATE_DIRTY_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyRenderStateCursorVisualStyle {
#[doc = " Visual style of the cursor.\n\n @ingroup render"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Bar cursor (DECSCUSR 5, 6)."]
pub const GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BAR: Type = 0;
#[doc = " Block cursor (DECSCUSR 1, 2)."]
pub const GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BLOCK: Type = 1;
#[doc = " Underline cursor (DECSCUSR 3, 4)."]
pub const GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_UNDERLINE: Type = 2;
#[doc = " Hollow block cursor."]
pub const GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BLOCK_HOLLOW: Type = 3;
#[doc = " Hollow block cursor."]
pub const GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_MAX_VALUE: Type = 2147483647;
}
#[doc = " A number of rows above and below the viewport.\n\n This is used both to request overscan with\n GHOSTTY_RENDER_STATE_OPTION_OVERSCAN and to report how many rows an\n update captured with GHOSTTY_RENDER_STATE_DATA_OVERSCAN. See \"Overscan\"\n in the render state overview for how the extra rows are used.\n\n @ingroup render"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyRenderStateOverscan {
#[doc = " Rows above the top of the viewport."]
pub above: u16,
#[doc = " Rows below the bottom of the viewport."]
pub below: u16,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyRenderStateOverscan"]
[::std::mem::size_of::<GhosttyRenderStateOverscan>() - 4usize];
["Alignment of GhosttyRenderStateOverscan"]
[::std::mem::align_of::<GhosttyRenderStateOverscan>() - 2usize];
["Offset of field: GhosttyRenderStateOverscan::above"]
[::std::mem::offset_of!(GhosttyRenderStateOverscan, above) - 0usize];
["Offset of field: GhosttyRenderStateOverscan::below"]
[::std::mem::offset_of!(GhosttyRenderStateOverscan, below) - 2usize];
};
#[doc = " The identity of a row across render state updates.\n\n Treat this value as opaque. Two ids are the same when both words are\n equal. No other comparison or interpretation is meaningful, and the\n contents may change between library versions. A zero-initialized id is\n never valid, so it can be used to mean \"no row\".\n\n @code{.c}\n bool same = a.bits[0] == b.bits[0] && a.bits[1] == b.bits[1];\n @endcode\n\n See \"Row Identity\" in the render state overview for how to use ids.\n\n @ingroup render"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyRenderStateRowId {
#[doc = " Opaque id data. Compare both words for equality."]
pub bits: [u64; 2usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyRenderStateRowId"][::std::mem::size_of::<GhosttyRenderStateRowId>() - 16usize];
["Alignment of GhosttyRenderStateRowId"]
[::std::mem::align_of::<GhosttyRenderStateRowId>() - 8usize];
["Offset of field: GhosttyRenderStateRowId::bits"]
[::std::mem::offset_of!(GhosttyRenderStateRowId, bits) - 0usize];
};
pub mod GhosttyRenderStateData {
#[doc = " Queryable data kinds for ghostty_render_state_get().\n\n @ingroup render"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid / sentinel value."]
pub const GHOSTTY_RENDER_STATE_DATA_INVALID: Type = 0;
#[doc = " Viewport width in cells (uint16_t)."]
pub const GHOSTTY_RENDER_STATE_DATA_COLS: Type = 1;
#[doc = " Viewport height in cells (uint16_t). This does not include\n overscan rows."]
pub const GHOSTTY_RENDER_STATE_DATA_ROWS: Type = 2;
#[doc = " Current dirty state (GhosttyRenderStateDirty)."]
pub const GHOSTTY_RENDER_STATE_DATA_DIRTY: Type = 3;
#[doc = " Populate a pre-allocated GhosttyRenderStateRowIterator with row data\n from the render state (GhosttyRenderStateRowIterator). Row data is\n only valid as long as the underlying render state is not updated.\n It is unsafe to use row data after updating the render state.\n\n The iterator visits every row the last update captured, from top\n to bottom. This is exactly the viewport unless overscan was\n requested with GHOSTTY_RENDER_STATE_OPTION_OVERSCAN."]
pub const GHOSTTY_RENDER_STATE_DATA_ROW_ITERATOR: Type = 4;
#[doc = " Default/current background color (GhosttyColorRgb)."]
pub const GHOSTTY_RENDER_STATE_DATA_COLOR_BACKGROUND: Type = 5;
#[doc = " Default/current foreground color (GhosttyColorRgb)."]
pub const GHOSTTY_RENDER_STATE_DATA_COLOR_FOREGROUND: Type = 6;
#[doc = " Cursor color when explicitly set by terminal state (GhosttyColorRgb).\n Returns GHOSTTY_INVALID_VALUE if no explicit cursor color is set;\n use COLOR_CURSOR_HAS_VALUE to check first."]
pub const GHOSTTY_RENDER_STATE_DATA_COLOR_CURSOR: Type = 7;
#[doc = " Whether an explicit cursor color is set (bool)."]
pub const GHOSTTY_RENDER_STATE_DATA_COLOR_CURSOR_HAS_VALUE: Type = 8;
#[doc = " The active 256-color palette (GhosttyColorRgb[256])."]
pub const GHOSTTY_RENDER_STATE_DATA_COLOR_PALETTE: Type = 9;
#[doc = " The visual style of the cursor (GhosttyRenderStateCursorVisualStyle)."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VISUAL_STYLE: Type = 10;
#[doc = " Whether the cursor is visible based on terminal modes (bool)."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VISIBLE: Type = 11;
#[doc = " Whether the cursor should blink based on terminal modes (bool)."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_BLINKING: Type = 12;
#[doc = " Whether the cursor is at a password input field (bool)."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_PASSWORD_INPUT: Type = 13;
#[doc = " Whether the cursor is visible within the viewport (bool).\n If false, the cursor viewport position values are undefined."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_HAS_VALUE: Type = 14;
#[doc = " Cursor viewport x position in cells (uint16_t).\n Only valid when CURSOR_VIEWPORT_HAS_VALUE is true."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_X: Type = 15;
#[doc = " Cursor viewport y position in cells (uint16_t).\n Only valid when CURSOR_VIEWPORT_HAS_VALUE is true."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_Y: Type = 16;
#[doc = " Whether the cursor is on the tail of a wide character (bool).\n Only valid when CURSOR_VIEWPORT_HAS_VALUE is true."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_WIDE_TAIL: Type = 17;
#[doc = " All cursor state in one sized struct (GhosttyRenderStateCursor).\n Initialize the output with GHOSTTY_INIT_SIZED before querying."]
pub const GHOSTTY_RENDER_STATE_DATA_CURSOR: Type = 18;
#[doc = " All render-state colors in one sized struct (GhosttyRenderStateColors).\n Initialize the output with GHOSTTY_INIT_SIZED before querying."]
pub const GHOSTTY_RENDER_STATE_DATA_COLORS: Type = 19;
#[doc = " How many overscan rows the last update captured on each side\n (GhosttyRenderStateOverscan). This is never more than the request.\n It is less when those rows don't exist: `above` is smaller near the\n top of the scrollback, and `below` is zero while the viewport is\n scrolled to the bottom."]
pub const GHOSTTY_RENDER_STATE_DATA_OVERSCAN: Type = 20;
#[doc = " The overscan request most recently set with\n GHOSTTY_RENDER_STATE_OPTION_OVERSCAN (GhosttyRenderStateOverscan).\n The next update uses this request. Both sides are zero if it was\n never set."]
pub const GHOSTTY_RENDER_STATE_DATA_OVERSCAN_REQUEST: Type = 21;
#[doc = " The overscan request most recently set with\n GHOSTTY_RENDER_STATE_OPTION_OVERSCAN (GhosttyRenderStateOverscan).\n The next update uses this request. Both sides are zero if it was\n never set."]
pub const GHOSTTY_RENDER_STATE_DATA_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyRenderStateOption {
#[doc = " Settable options for ghostty_render_state_set().\n\n @ingroup render"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Set dirty state (GhosttyRenderStateDirty)."]
pub const GHOSTTY_RENDER_STATE_OPTION_DIRTY: Type = 0;
#[doc = " Request overscan rows above and below the viewport\n (GhosttyRenderStateOverscan). The request takes effect on the next\n update and stays in effect until it is changed. Both sides are zero\n by default, which captures only the viewport. The rows of the last\n update can still be read after changing the request. Expect a full\n redraw on the update after a change. See \"Overscan\" in the render\n state overview."]
pub const GHOSTTY_RENDER_STATE_OPTION_OVERSCAN: Type = 1;
#[doc = " Request overscan rows above and below the viewport\n (GhosttyRenderStateOverscan). The request takes effect on the next\n update and stays in effect until it is changed. Both sides are zero\n by default, which captures only the viewport. The rows of the last\n update can still be read after changing the request. Expect a full\n redraw on the update after a change. See \"Overscan\" in the render\n state overview."]
pub const GHOSTTY_RENDER_STATE_OPTION_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyRenderStateRowData {
#[doc = " Queryable data kinds for ghostty_render_state_row_get().\n\n @ingroup render"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid / sentinel value."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_INVALID: Type = 0;
#[doc = " Whether the current row is dirty (bool)."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_DIRTY: Type = 1;
#[doc = " The raw row value (GhosttyRow)."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_RAW: Type = 2;
#[doc = " Populate a pre-allocated GhosttyRenderStateRowCells with cell data for\n the current row (GhosttyRenderStateRowCells). Cell data is only\n valid as long as the underlying render state is not updated.\n It is unsafe to use cell data after updating the render state."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_CELLS: Type = 3;
#[doc = " Row-local selected cell range (GhosttyRenderStateRowSelection)."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_SELECTION: Type = 4;
#[doc = " A borrowed view of the raw cell values for the current row\n (GhosttyCellsView). One value per column, identical to querying\n GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_RAW for each cell. The view\n is only valid as long as the underlying render state is not\n updated; it is unsafe to use after updating the render state.\n\n This is the bulk alternative to iterating cells one at a time.\n It lets callers with expensive call boundaries (e.g. WebAssembly\n embedders) read an entire row with a single call.\n\n Bit positions aren't protected by ABI, so callers should parse them\n out of the manifest from `ghostty_type_json`. Callers with access\n to the C header or without high FFI costs should use `ghostty_cell_get`."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_CELLS_RAW: Type = 5;
#[doc = " The row's position relative to the top of the viewport (int32_t).\n Viewport rows are 0 through rows - 1. Overscan rows above the\n viewport are negative, and overscan rows below it start at rows.\n Without overscan, this equals the y reported by\n ghostty_render_state_row_iterator_next_dirty()."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_VIEWPORT_Y: Type = 6;
#[doc = " The row's identity across updates (GhosttyRenderStateRowId). This\n works with or without overscan. See \"Row Identity\" in the render\n state overview."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_ID: Type = 7;
#[doc = " The row's identity across updates (GhosttyRenderStateRowId). This\n works with or without overscan. See \"Row Identity\" in the render\n state overview."]
pub const GHOSTTY_RENDER_STATE_ROW_DATA_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyRenderStateRowOption {
#[doc = " Settable options for ghostty_render_state_row_set().\n\n @ingroup render"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Set dirty state for the current row (bool)."]
pub const GHOSTTY_RENDER_STATE_ROW_OPTION_DIRTY: Type = 0;
#[doc = " Set dirty state for the current row (bool)."]
pub const GHOSTTY_RENDER_STATE_ROW_OPTION_MAX_VALUE: Type = 2147483647;
}
#[doc = " Row-local selection range.\n\n This struct uses the sized-struct ABI pattern. Initialize with\n GHOSTTY_INIT_SIZED(GhosttyRenderStateRowSelection) before querying\n GHOSTTY_RENDER_STATE_ROW_DATA_SELECTION.\n\n Querying GHOSTTY_RENDER_STATE_ROW_DATA_SELECTION returns GHOSTTY_NO_VALUE\n if the current row does not intersect the current selection.\n\n @ingroup render"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyRenderStateRowSelection {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyRenderStateRowSelection)."]
pub size: usize,
#[doc = " Start column of the row-local selection range, inclusive."]
pub start_x: u16,
#[doc = " End column of the row-local selection range, inclusive."]
pub end_x: u16,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyRenderStateRowSelection"]
[::std::mem::size_of::<GhosttyRenderStateRowSelection>() - 16usize];
["Alignment of GhosttyRenderStateRowSelection"]
[::std::mem::align_of::<GhosttyRenderStateRowSelection>() - 8usize];
["Offset of field: GhosttyRenderStateRowSelection::size"]
[::std::mem::offset_of!(GhosttyRenderStateRowSelection, size) - 0usize];
["Offset of field: GhosttyRenderStateRowSelection::start_x"]
[::std::mem::offset_of!(GhosttyRenderStateRowSelection, start_x) - 8usize];
["Offset of field: GhosttyRenderStateRowSelection::end_x"]
[::std::mem::offset_of!(GhosttyRenderStateRowSelection, end_x) - 10usize];
};
#[doc = " Render-state cursor information.\n\n This struct uses the sized-struct ABI pattern. Initialize with\n GHOSTTY_INIT_SIZED(GhosttyRenderStateCursor) before querying\n GHOSTTY_RENDER_STATE_DATA_CURSOR.\n\n When viewport_has_value is false, viewport_x, viewport_y, and wide_tail\n contain undefined data and must not be read.\n\n @ingroup render"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyRenderStateCursor {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyRenderStateCursor)."]
pub size: usize,
#[doc = " Whether the cursor is visible within the viewport."]
pub viewport_has_value: bool,
#[doc = " Cursor viewport x position in cells."]
pub viewport_x: u16,
#[doc = " Cursor viewport y position in cells."]
pub viewport_y: u16,
#[doc = " Whether the cursor is on the tail of a wide character."]
pub wide_tail: bool,
#[doc = " Whether the cursor is visible based on terminal modes."]
pub visible: bool,
#[doc = " Whether the cursor should blink based on terminal modes."]
pub blinking: bool,
#[doc = " Whether the cursor is at a password input field."]
pub password_input: bool,
#[doc = " The visual style of the cursor."]
pub visual_style: GhosttyRenderStateCursorVisualStyle::Type,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyRenderStateCursor"]
[::std::mem::size_of::<GhosttyRenderStateCursor>() - 24usize];
["Alignment of GhosttyRenderStateCursor"]
[::std::mem::align_of::<GhosttyRenderStateCursor>() - 8usize];
["Offset of field: GhosttyRenderStateCursor::size"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, size) - 0usize];
["Offset of field: GhosttyRenderStateCursor::viewport_has_value"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, viewport_has_value) - 8usize];
["Offset of field: GhosttyRenderStateCursor::viewport_x"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, viewport_x) - 10usize];
["Offset of field: GhosttyRenderStateCursor::viewport_y"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, viewport_y) - 12usize];
["Offset of field: GhosttyRenderStateCursor::wide_tail"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, wide_tail) - 14usize];
["Offset of field: GhosttyRenderStateCursor::visible"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, visible) - 15usize];
["Offset of field: GhosttyRenderStateCursor::blinking"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, blinking) - 16usize];
["Offset of field: GhosttyRenderStateCursor::password_input"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, password_input) - 17usize];
["Offset of field: GhosttyRenderStateCursor::visual_style"]
[::std::mem::offset_of!(GhosttyRenderStateCursor, visual_style) - 20usize];
};
impl Default for GhosttyRenderStateCursor {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " Render-state color information.\n\n This struct uses the sized-struct ABI pattern. Initialize with\n GHOSTTY_INIT_SIZED(GhosttyRenderStateColors) before querying\n GHOSTTY_RENDER_STATE_DATA_COLORS.\n\n Example:\n @code\n GhosttyRenderStateColors colors = GHOSTTY_INIT_SIZED(GhosttyRenderStateColors);\n GhosttyResult result = ghostty_render_state_get(\n state, GHOSTTY_RENDER_STATE_DATA_COLORS, &colors);\n @endcode\n\n @ingroup render"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyRenderStateColors {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyRenderStateColors)."]
pub size: usize,
#[doc = " The default/current background color for the render state."]
pub background: GhosttyColorRgb,
#[doc = " The default/current foreground color for the render state."]
pub foreground: GhosttyColorRgb,
#[doc = " The cursor color when explicitly set by terminal state."]
pub cursor: GhosttyColorRgb,
#[doc = " True when cursor contains a valid explicit cursor color value.\n If this is false, the cursor color should be ignored; it will\n contain undefined data."]
pub cursor_has_value: bool,
#[doc = " The active 256-color palette for this render state."]
pub palette: [GhosttyColorRgb; 256usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyRenderStateColors"]
[::std::mem::size_of::<GhosttyRenderStateColors>() - 792usize];
["Alignment of GhosttyRenderStateColors"]
[::std::mem::align_of::<GhosttyRenderStateColors>() - 8usize];
["Offset of field: GhosttyRenderStateColors::size"]
[::std::mem::offset_of!(GhosttyRenderStateColors, size) - 0usize];
["Offset of field: GhosttyRenderStateColors::background"]
[::std::mem::offset_of!(GhosttyRenderStateColors, background) - 8usize];
["Offset of field: GhosttyRenderStateColors::foreground"]
[::std::mem::offset_of!(GhosttyRenderStateColors, foreground) - 11usize];
["Offset of field: GhosttyRenderStateColors::cursor"]
[::std::mem::offset_of!(GhosttyRenderStateColors, cursor) - 14usize];
["Offset of field: GhosttyRenderStateColors::cursor_has_value"]
[::std::mem::offset_of!(GhosttyRenderStateColors, cursor_has_value) - 17usize];
["Offset of field: GhosttyRenderStateColors::palette"]
[::std::mem::offset_of!(GhosttyRenderStateColors, palette) - 18usize];
};
impl Default for GhosttyRenderStateColors {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Create a new render state instance.\n\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param state Pointer to store the created render state handle\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_MEMORY on allocation\n failure\n\n @ingroup render"]
pub fn ghostty_render_state_new(
allocator: *const GhosttyAllocator,
state: *mut GhosttyRenderState,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a render state instance.\n\n Releases all resources associated with the render state. After this call,\n the render state handle becomes invalid.\n\n @param state The render state handle to free (may be NULL)\n\n @ingroup render"]
pub fn ghostty_render_state_free(state: GhosttyRenderState);
}
unsafe extern "C" {
#[doc = " Update a render state instance from a terminal.\n\n This consumes terminal/screen dirty state in the same way as the internal\n render state update path.\n\n This is a convenience function that performs a full update in one call,\n equivalent to ghostty_render_state_begin_update immediately followed by\n ghostty_render_state_end_update. Callers that hold a lock over the\n terminal state should prefer calling the two phases directly so that the\n lock is only held for the begin phase.\n\n @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param terminal The terminal handle to read from (NULL returns GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state` or\n `terminal` is NULL, GHOSTTY_OUT_OF_MEMORY if updating the state requires\n allocation and that allocation fails\n\n @ingroup render"]
pub fn ghostty_render_state_update(
state: GhosttyRenderState,
terminal: GhosttyTerminal,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Begin an update of a render state instance from a terminal.\n\n Every begin must be completed with a ghostty_render_state_end_update call\n before the render state is read.\n\n This two-phase structure exists for callers that synchronize access to the\n terminal state (e.g. with a lock shared with an IO thread): only this\n function requires terminal access, so a caller can hold its lock for this\n call only and then call ghostty_render_state_end_update after releasing\n it. The end phase exclusively reads and writes memory owned by the render\n state, so it is safe to call while the terminal is being modified.\n\n Work that doesn't require terminal access may be deferred to the end phase\n to keep this call (and therefore lock hold time) as short as possible.\n Callers must treat the render state as incomplete until\n ghostty_render_state_end_update is called.\n\n This consumes terminal/screen dirty state in the same way as the internal\n render state update path.\n\n @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param terminal The terminal handle to read from (NULL returns GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state` or\n `terminal` is NULL, GHOSTTY_OUT_OF_MEMORY if updating the state requires\n allocation and that allocation fails\n\n @ingroup render"]
pub fn ghostty_render_state_begin_update(
state: GhosttyRenderState,
terminal: GhosttyTerminal,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Complete a prior ghostty_render_state_begin_update call by performing any\n deferred work.\n\n This only reads and writes memory owned by the render state, so it is safe\n to call while the terminal is being modified (no terminal synchronization\n is required). Calling this without a prior begin is a safe no-op.\n\n @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state` is\n NULL\n\n @ingroup render"]
pub fn ghostty_render_state_end_update(state: GhosttyRenderState) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Mark all dirty render-state data as consumed.\n\n This sets the global dirty state to GHOSTTY_RENDER_STATE_DIRTY_FALSE and\n clears every per-row dirty flag. It is idempotent and does not modify cell\n contents or dirty state owned by the terminal. Call this only after a\n complete frame has been rendered successfully; partial consumers should\n use ghostty_render_state_set() and ghostty_render_state_row_set() instead.\n\n @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state` is\n NULL\n\n @ingroup render"]
pub fn ghostty_render_state_clean(state: GhosttyRenderState) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get a value from a render state.\n\n The `out` pointer must point to a value of the type corresponding to the\n requested data kind (see GhosttyRenderStateData).\n\n @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param data The data kind to query\n @param[out] out Pointer to receive the queried value\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state` or\n `out` is NULL, `data` is not a recognized enum value, or a sized\n output struct is smaller than `sizeof(size_t)`\n\n @ingroup render"]
pub fn ghostty_render_state_get(
state: GhosttyRenderState,
data: GhosttyRenderStateData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple data fields from a render state in a single call.\n\n Each element in the keys array specifies a data kind, and the\n corresponding element in the values array receives the result.\n\n Processing stops at the first error; on success out_written\n is set to count, on error it is set to the index of the\n failing key (i.e. the number of values successfully written).\n\n @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers (types must match each key's\n documented output type)\n @param[out] out_written On return, receives the number of values\n successfully written (may be NULL)\n @return GHOSTTY_SUCCESS if all queries succeed\n\n @ingroup render"]
pub fn ghostty_render_state_get_multi(
state: GhosttyRenderState,
count: usize,
keys: *const GhosttyRenderStateData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Set an option on a render state.\n\n The `value` pointer must point to a value of the type corresponding to the\n requested option kind (see GhosttyRenderStateOption).\n\n @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param option The option to set\n @param[in] value Pointer to the value to set (NULL returns\n GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state` or\n `value` is NULL\n\n @ingroup render"]
pub fn ghostty_render_state_set(
state: GhosttyRenderState,
option: GhosttyRenderStateOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Create a new row iterator instance.\n\n All fields except the allocator are left undefined until populated\n via ghostty_render_state_get() with\n GHOSTTY_RENDER_STATE_DATA_ROW_ITERATOR.\n\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param[out] out_iterator On success, receives the created iterator handle\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_MEMORY on allocation\n failure\n\n @ingroup render"]
pub fn ghostty_render_state_row_iterator_new(
allocator: *const GhosttyAllocator,
out_iterator: *mut GhosttyRenderStateRowIterator,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a render-state row iterator.\n\n @param iterator The iterator handle to free (may be NULL)\n\n @ingroup render"]
pub fn ghostty_render_state_row_iterator_free(iterator: GhosttyRenderStateRowIterator);
}
unsafe extern "C" {
#[doc = " Move a render-state row iterator to the next row.\n\n Rows are visited in order from top to bottom with no gaps. Without\n overscan, the first row is the top row of the viewport. With overscan,\n the first row is the highest captured row above the viewport (see\n GHOSTTY_RENDER_STATE_OPTION_OVERSCAN). Returns true if the iterator\n moved successfully and row data is available to read at the new\n position.\n\n @param iterator The iterator handle to advance (may be NULL)\n @return true if advanced to the next row, false if `iterator` is\n NULL or if the iterator has reached the end\n\n @ingroup render"]
pub fn ghostty_render_state_row_iterator_next(iterator: GhosttyRenderStateRowIterator) -> bool;
}
unsafe extern "C" {
#[doc = " Move a render-state row iterator to the next row requiring a redraw.\n\n If the global dirty state is GHOSTTY_RENDER_STATE_DIRTY_FALSE, this returns\n false. If it is GHOSTTY_RENDER_STATE_DIRTY_PARTIAL, clean rows are skipped.\n If it is GHOSTTY_RENDER_STATE_DIRTY_FULL, every remaining row is returned\n regardless of its per-row dirty flag. Rows are returned in ascending\n viewport order. This function does not clear any dirty state.\n\n @param iterator The iterator handle to advance (NULL returns false)\n @param[out] out_y Receives the row's position in the iterator when true\n is returned (NULL returns false). It is not modified\n when false is returned. Without overscan, this is the\n viewport y. With overscan, it counts from the highest\n captured row, so use\n GHOSTTY_RENDER_STATE_ROW_DATA_VIEWPORT_Y to place\n the row.\n @return true if advanced to a row requiring a redraw, false if an argument\n is NULL or the iterator has reached the end of the effective dirty\n rows\n\n @ingroup render"]
pub fn ghostty_render_state_row_iterator_next_dirty(
iterator: GhosttyRenderStateRowIterator,
out_y: *mut u16,
) -> bool;
}
unsafe extern "C" {
#[doc = " Get a value from the current row in a render-state row iterator.\n\n The `out` pointer must point to a value of the type corresponding to the\n requested data kind (see GhosttyRenderStateRowData).\n Call ghostty_render_state_row_iterator_next() or\n ghostty_render_state_row_iterator_next_dirty() at least once before\n calling this function.\n\n @param iterator The iterator handle to query (NULL returns GHOSTTY_INVALID_VALUE)\n @param data The data kind to query\n @param[out] out Pointer to receive the queried value\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if\n `iterator` is NULL or the iterator is not positioned on a row\n\n @ingroup render"]
pub fn ghostty_render_state_row_get(
iterator: GhosttyRenderStateRowIterator,
data: GhosttyRenderStateRowData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple data fields from the current row in a single call.\n\n Each element in the keys array specifies a data kind, and the\n corresponding element in the values array receives the result.\n\n Processing stops at the first error; on success out_written\n is set to count, on error it is set to the index of the\n failing key (i.e. the number of values successfully written).\n\n @param iterator The iterator handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers (types must match each key's\n documented output type)\n @param[out] out_written On return, receives the number of values\n successfully written (may be NULL)\n @return GHOSTTY_SUCCESS if all queries succeed\n\n @ingroup render"]
pub fn ghostty_render_state_row_get_multi(
iterator: GhosttyRenderStateRowIterator,
count: usize,
keys: *const GhosttyRenderStateRowData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Set an option on the current row in a render-state row iterator.\n\n The `value` pointer must point to a value of the type corresponding to the\n requested option kind (see GhosttyRenderStateRowOption).\n Call ghostty_render_state_row_iterator_next() or\n ghostty_render_state_row_iterator_next_dirty() at least once before\n calling this function.\n\n @param iterator The iterator handle to update (NULL returns GHOSTTY_INVALID_VALUE)\n @param option The option to set\n @param[in] value Pointer to the value to set (NULL returns\n GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if\n `iterator` is NULL or the iterator is not positioned on a row\n\n @ingroup render"]
pub fn ghostty_render_state_row_set(
iterator: GhosttyRenderStateRowIterator,
option: GhosttyRenderStateRowOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Create a new row cells instance.\n\n All fields except the allocator are left undefined until populated\n via ghostty_render_state_row_get() with\n GHOSTTY_RENDER_STATE_ROW_DATA_CELLS.\n\n You can reuse this value repeatedly with ghostty_render_state_row_get() to\n avoid allocating a new cells container for every row.\n\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param[out] out_cells On success, receives the created row cells handle\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_MEMORY on allocation\n failure\n\n @ingroup render"]
pub fn ghostty_render_state_row_cells_new(
allocator: *const GhosttyAllocator,
out_cells: *mut GhosttyRenderStateRowCells,
) -> GhosttyResult::Type;
}
pub mod GhosttyRenderStateRowCellsData {
#[doc = " Queryable data kinds for ghostty_render_state_row_cells_get().\n\n @ingroup render"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid / sentinel value."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_INVALID: Type = 0;
#[doc = " The raw cell value (GhosttyCell)."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_RAW: Type = 1;
#[doc = " The style for the current cell (GhosttyStyle)."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_STYLE: Type = 2;
#[doc = " The total number of grapheme codepoints including the base codepoint\n (uint32_t). Returns 0 if the cell has no text."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_GRAPHEMES_LEN: Type = 3;
#[doc = " Write grapheme codepoints into a caller-provided buffer (uint32_t*).\n The buffer must be at least graphemes_len elements. The base codepoint\n is written first, followed by any extra codepoints."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_GRAPHEMES_BUF: Type = 4;
#[doc = " The resolved background color of the cell (GhosttyColorRgb).\n Flattens the three possible sources: content-tag bg_color_rgb,\n content-tag bg_color_palette (looked up in the palette), or the\n style's bg_color. Returns GHOSTTY_INVALID_VALUE if the cell has\n no background color, in which case the caller should use whatever\n default background color it wants (e.g. the terminal background)."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_BG_COLOR: Type = 5;
#[doc = " The resolved foreground color of the cell (GhosttyColorRgb).\n Resolves palette indices through the palette. Bold color handling\n is not applied; the caller should handle bold styling separately.\n Returns GHOSTTY_INVALID_VALUE if the cell has no explicit foreground\n color, in which case the caller should use whatever default foreground\n color it wants (e.g. the terminal foreground)."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_FG_COLOR: Type = 6;
#[doc = " Whether the cell is contained within the current selection (bool).\n This returns true when the cell's column is within the current row's\n row-local selection range, and false otherwise. Rendering policy for\n selected cells (colors, inversion, etc.) is left to the caller.\n\n Renderers that can draw cells in spans may be more efficient querying\n GHOSTTY_RENDER_STATE_ROW_DATA_SELECTION once per row and applying that\n range directly, avoiding one C API call per cell for selection state."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_SELECTED: Type = 7;
#[doc = " Whether the cell has any explicit styling (bool).\n This is equivalent to querying the raw cell's\n GHOSTTY_CELL_DATA_HAS_STYLING value, but avoids materializing the raw\n GhosttyCell for renderers that only need to know whether fetching the\n full style is necessary."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_HAS_STYLING: Type = 8;
#[doc = " Encode the current cell's full grapheme cluster as UTF-8 into a\n caller-provided buffer (GhosttyBuffer).\n\n The base codepoint is encoded first, followed by any extra grapheme\n codepoints. Returns GHOSTTY_SUCCESS with len=0 when the cell has no text.\n\n If ptr is NULL or cap is too small for a non-empty cell, returns\n GHOSTTY_OUT_OF_SPACE without writing any bytes and sets len to the required\n buffer size in bytes."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_GRAPHEMES_UTF8: Type = 9;
#[doc = " Encode the current cell's full grapheme cluster as UTF-8 into a\n caller-provided buffer (GhosttyBuffer).\n\n The base codepoint is encoded first, followed by any extra grapheme\n codepoints. Returns GHOSTTY_SUCCESS with len=0 when the cell has no text.\n\n If ptr is NULL or cap is too small for a non-empty cell, returns\n GHOSTTY_OUT_OF_SPACE without writing any bytes and sets len to the required\n buffer size in bytes."]
pub const GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Move a render-state row cells iterator to the next cell.\n\n Returns true if the iterator moved successfully and cell data is\n available to read at the new position.\n\n @param cells The row cells handle to advance (may be NULL)\n @return true if advanced to the next cell, false if `cells` is\n NULL or if the iterator has reached the end\n\n @ingroup render"]
pub fn ghostty_render_state_row_cells_next(cells: GhosttyRenderStateRowCells) -> bool;
}
unsafe extern "C" {
#[doc = " Move a render-state row cells iterator to a specific column.\n\n Positions the iterator at the given x (column) index so that\n subsequent reads return data for that cell.\n\n @param cells The row cells handle to reposition (NULL returns\n GHOSTTY_INVALID_VALUE)\n @param x The zero-based column index to select\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `cells`\n is NULL or `x` is out of range\n\n @ingroup render"]
pub fn ghostty_render_state_row_cells_select(
cells: GhosttyRenderStateRowCells,
x: u16,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get a value from the current cell in a render-state row cells iterator.\n\n The `out` pointer must point to a value of the type corresponding to the\n requested data kind (see GhosttyRenderStateRowCellsData).\n Call ghostty_render_state_row_cells_next() or\n ghostty_render_state_row_cells_select() at least once before\n calling this function.\n\n @param cells The row cells handle to query (NULL returns GHOSTTY_INVALID_VALUE)\n @param data The data kind to query\n @param[out] out Pointer to receive the queried value\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if\n `cells` is NULL or the iterator is not positioned on a cell\n\n @ingroup render"]
pub fn ghostty_render_state_row_cells_get(
cells: GhosttyRenderStateRowCells,
data: GhosttyRenderStateRowCellsData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple data fields from the current cell in a single call.\n\n Each element in the keys array specifies a data kind, and the\n corresponding element in the values array receives the result.\n\n Processing stops at the first error; on success out_written\n is set to count, on error it is set to the index of the\n failing key (i.e. the number of values successfully written).\n\n @param cells The row cells handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers (types must match each key's\n documented output type)\n @param[out] out_written On return, receives the number of values\n successfully written (may be NULL)\n @return GHOSTTY_SUCCESS if all queries succeed\n\n @ingroup render"]
pub fn ghostty_render_state_row_cells_get_multi(
cells: GhosttyRenderStateRowCells,
count: usize,
keys: *const GhosttyRenderStateRowCellsData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a row cells instance.\n\n @param cells The row cells handle to free (may be NULL)\n\n @ingroup render"]
pub fn ghostty_render_state_row_cells_free(cells: GhosttyRenderStateRowCells);
}
unsafe extern "C" {
#[doc = " Free a tracked grid reference.\n\n Passing NULL is allowed and has no effect. A tracked reference may be freed\n after the terminal that created it is freed.\n\n @param ref Tracked grid reference to free.\n\n @ingroup grid_ref"]
pub fn ghostty_tracked_grid_ref_free(ref_: GhosttyTrackedGridRef);
}
unsafe extern "C" {
#[doc = " Return whether a tracked grid reference currently has a meaningful value.\n\n If the terminal that created the tracked reference has been freed, this\n returns false.\n\n @param ref Tracked grid reference.\n @return true if the reference currently has a meaningful value.\n\n @ingroup grid_ref"]
pub fn ghostty_tracked_grid_ref_has_value(ref_: GhosttyTrackedGridRef) -> bool;
}
unsafe extern "C" {
#[doc = " Convert a tracked grid reference to a point in the requested coordinate\n space.\n\n This is the tracked equivalent of ghostty_terminal_point_from_grid_ref().\n Unlike snapshotting, this does not expose an intermediate untracked\n GhosttyGridRef.\n\n A tracked reference is resolved against the terminal screen/page-list that\n currently owns the reference. If the terminal has switched between primary\n and alternate screens since the reference was created or last set, this may\n be different from the terminal's currently active screen.\n\n If the tracked reference no longer has a meaningful value, this returns\n GHOSTTY_NO_VALUE. GHOSTTY_NO_VALUE is also returned when the reference cannot\n be represented in the requested coordinate space, including after the\n terminal that created the tracked reference has been freed.\n\n @param ref Tracked grid reference.\n @param tag Coordinate space to convert into.\n @param[out] out_point On success, receives the coordinate. May be NULL.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if ref is invalid,\n or GHOSTTY_NO_VALUE if there is no representable value.\n\n @ingroup grid_ref"]
pub fn ghostty_tracked_grid_ref_point(
ref_: GhosttyTrackedGridRef,
tag: GhosttyPointTag::Type,
out_point: *mut GhosttyPointCoordinate,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Move an existing tracked grid reference to a new terminal point.\n\n On success, the tracked reference begins tracking the new point and any prior\n \"no value\" state is cleared. On GHOSTTY_OUT_OF_MEMORY, the original tracked\n reference is left unchanged.\n\n The terminal must be the same terminal that created the tracked reference.\n The point is resolved against the terminal screen/page-list that is active at\n the time this function is called. If the terminal has switched between\n primary and alternate screens, this may move the tracked reference from one\n screen/page-list to the other.\n\n @param ref Tracked grid reference.\n @param terminal Terminal instance that owns the reference.\n @param point New point to track.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if ref, terminal,\n or point is invalid, or GHOSTTY_OUT_OF_MEMORY if allocation fails.\n\n @ingroup grid_ref"]
pub fn ghostty_tracked_grid_ref_set(
ref_: GhosttyTrackedGridRef,
terminal: GhosttyTerminal,
point: GhosttyPoint,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Snapshot a tracked grid reference into a regular GhosttyGridRef.\n\n The returned GhosttyGridRef is an untracked snapshot and has the same\n lifetime rules as ghostty_terminal_grid_ref(): it is only valid until the\n next terminal update. Snapshot immediately before calling\n ghostty_grid_ref_cell(), ghostty_grid_ref_row(),\n ghostty_grid_ref_graphemes(), ghostty_grid_ref_hyperlink_uri(),\n ghostty_grid_ref_hyperlink_id(), or ghostty_grid_ref_style().\n\n If the tracked reference no longer has a meaningful value, this returns\n GHOSTTY_NO_VALUE. This includes references whose owning terminal has been\n freed.\n\n @param ref Tracked grid reference.\n @param[out] out_ref On success, receives an untracked snapshot. May be NULL.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if ref is invalid,\n or GHOSTTY_NO_VALUE if the tracked location was discarded.\n\n @ingroup grid_ref"]
pub fn ghostty_tracked_grid_ref_snapshot(
ref_: GhosttyTrackedGridRef,
out_ref: *mut GhosttyGridRef,
) -> GhosttyResult::Type;
}
pub mod GhosttySgrAttributeTag {
#[doc = " SGR attribute tags.\n\n These values identify the type of an SGR attribute in a tagged union.\n Use the tag to determine which field in the attribute value union to access.\n\n @ingroup sgr"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_SGR_ATTR_UNSET: Type = 0;
pub const GHOSTTY_SGR_ATTR_UNKNOWN: Type = 1;
pub const GHOSTTY_SGR_ATTR_BOLD: Type = 2;
pub const GHOSTTY_SGR_ATTR_RESET_BOLD: Type = 3;
pub const GHOSTTY_SGR_ATTR_ITALIC: Type = 4;
pub const GHOSTTY_SGR_ATTR_RESET_ITALIC: Type = 5;
pub const GHOSTTY_SGR_ATTR_FAINT: Type = 6;
pub const GHOSTTY_SGR_ATTR_UNDERLINE: Type = 7;
pub const GHOSTTY_SGR_ATTR_UNDERLINE_COLOR: Type = 8;
pub const GHOSTTY_SGR_ATTR_UNDERLINE_COLOR_256: Type = 9;
pub const GHOSTTY_SGR_ATTR_RESET_UNDERLINE_COLOR: Type = 10;
pub const GHOSTTY_SGR_ATTR_OVERLINE: Type = 11;
pub const GHOSTTY_SGR_ATTR_RESET_OVERLINE: Type = 12;
pub const GHOSTTY_SGR_ATTR_BLINK: Type = 13;
pub const GHOSTTY_SGR_ATTR_RESET_BLINK: Type = 14;
pub const GHOSTTY_SGR_ATTR_INVERSE: Type = 15;
pub const GHOSTTY_SGR_ATTR_RESET_INVERSE: Type = 16;
pub const GHOSTTY_SGR_ATTR_INVISIBLE: Type = 17;
pub const GHOSTTY_SGR_ATTR_RESET_INVISIBLE: Type = 18;
pub const GHOSTTY_SGR_ATTR_STRIKETHROUGH: Type = 19;
pub const GHOSTTY_SGR_ATTR_RESET_STRIKETHROUGH: Type = 20;
pub const GHOSTTY_SGR_ATTR_DIRECT_COLOR_FG: Type = 21;
pub const GHOSTTY_SGR_ATTR_DIRECT_COLOR_BG: Type = 22;
pub const GHOSTTY_SGR_ATTR_BG_8: Type = 23;
pub const GHOSTTY_SGR_ATTR_FG_8: Type = 24;
pub const GHOSTTY_SGR_ATTR_RESET_FG: Type = 25;
pub const GHOSTTY_SGR_ATTR_RESET_BG: Type = 26;
pub const GHOSTTY_SGR_ATTR_BRIGHT_BG_8: Type = 27;
pub const GHOSTTY_SGR_ATTR_BRIGHT_FG_8: Type = 28;
pub const GHOSTTY_SGR_ATTR_BG_256: Type = 29;
pub const GHOSTTY_SGR_ATTR_FG_256: Type = 30;
pub const GHOSTTY_SGR_ATTR_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySgrUnderline {
#[doc = " Underline style types.\n\n @ingroup sgr"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_SGR_UNDERLINE_NONE: Type = 0;
pub const GHOSTTY_SGR_UNDERLINE_SINGLE: Type = 1;
pub const GHOSTTY_SGR_UNDERLINE_DOUBLE: Type = 2;
pub const GHOSTTY_SGR_UNDERLINE_CURLY: Type = 3;
pub const GHOSTTY_SGR_UNDERLINE_DOTTED: Type = 4;
pub const GHOSTTY_SGR_UNDERLINE_DASHED: Type = 5;
pub const GHOSTTY_SGR_UNDERLINE_MAX_VALUE: Type = 2147483647;
}
#[doc = " Unknown SGR attribute data.\n\n Contains the full parameter list and the partial list where parsing\n encountered an unknown or invalid sequence.\n\n @ingroup sgr"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySgrUnknown {
pub full_ptr: *const u16,
pub full_len: usize,
pub partial_ptr: *const u16,
pub partial_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySgrUnknown"][::std::mem::size_of::<GhosttySgrUnknown>() - 32usize];
["Alignment of GhosttySgrUnknown"][::std::mem::align_of::<GhosttySgrUnknown>() - 8usize];
["Offset of field: GhosttySgrUnknown::full_ptr"]
[::std::mem::offset_of!(GhosttySgrUnknown, full_ptr) - 0usize];
["Offset of field: GhosttySgrUnknown::full_len"]
[::std::mem::offset_of!(GhosttySgrUnknown, full_len) - 8usize];
["Offset of field: GhosttySgrUnknown::partial_ptr"]
[::std::mem::offset_of!(GhosttySgrUnknown, partial_ptr) - 16usize];
["Offset of field: GhosttySgrUnknown::partial_len"]
[::std::mem::offset_of!(GhosttySgrUnknown, partial_len) - 24usize];
};
impl Default for GhosttySgrUnknown {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " SGR attribute value union.\n\n This union contains all possible attribute values. Use the tag field\n to determine which union member is active. Attributes without associated\n data (like bold, italic) don't use the union value.\n\n @ingroup sgr"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union GhosttySgrAttributeValue {
pub unknown: GhosttySgrUnknown,
pub underline: GhosttySgrUnderline::Type,
pub underline_color: GhosttyColorRgb,
pub underline_color_256: GhosttyColorPaletteIndex,
pub direct_color_fg: GhosttyColorRgb,
pub direct_color_bg: GhosttyColorRgb,
pub bg_8: GhosttyColorPaletteIndex,
pub fg_8: GhosttyColorPaletteIndex,
pub bright_bg_8: GhosttyColorPaletteIndex,
pub bright_fg_8: GhosttyColorPaletteIndex,
pub bg_256: GhosttyColorPaletteIndex,
pub fg_256: GhosttyColorPaletteIndex,
pub _padding: [u64; 8usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySgrAttributeValue"]
[::std::mem::size_of::<GhosttySgrAttributeValue>() - 64usize];
["Alignment of GhosttySgrAttributeValue"]
[::std::mem::align_of::<GhosttySgrAttributeValue>() - 8usize];
["Offset of field: GhosttySgrAttributeValue::unknown"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, unknown) - 0usize];
["Offset of field: GhosttySgrAttributeValue::underline"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, underline) - 0usize];
["Offset of field: GhosttySgrAttributeValue::underline_color"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, underline_color) - 0usize];
["Offset of field: GhosttySgrAttributeValue::underline_color_256"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, underline_color_256) - 0usize];
["Offset of field: GhosttySgrAttributeValue::direct_color_fg"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, direct_color_fg) - 0usize];
["Offset of field: GhosttySgrAttributeValue::direct_color_bg"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, direct_color_bg) - 0usize];
["Offset of field: GhosttySgrAttributeValue::bg_8"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, bg_8) - 0usize];
["Offset of field: GhosttySgrAttributeValue::fg_8"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, fg_8) - 0usize];
["Offset of field: GhosttySgrAttributeValue::bright_bg_8"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, bright_bg_8) - 0usize];
["Offset of field: GhosttySgrAttributeValue::bright_fg_8"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, bright_fg_8) - 0usize];
["Offset of field: GhosttySgrAttributeValue::bg_256"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, bg_256) - 0usize];
["Offset of field: GhosttySgrAttributeValue::fg_256"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, fg_256) - 0usize];
["Offset of field: GhosttySgrAttributeValue::_padding"]
[::std::mem::offset_of!(GhosttySgrAttributeValue, _padding) - 0usize];
};
impl Default for GhosttySgrAttributeValue {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " SGR attribute (tagged union).\n\n A complete SGR attribute with both its type tag and associated value.\n Always check the tag field to determine which value union member is valid.\n\n Attributes without associated data (e.g., GHOSTTY_SGR_ATTR_BOLD) can be\n identified by tag alone; the value union is not used for these and\n the memory in the value field is undefined.\n\n @ingroup sgr"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GhosttySgrAttribute {
pub tag: GhosttySgrAttributeTag::Type,
pub value: GhosttySgrAttributeValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySgrAttribute"][::std::mem::size_of::<GhosttySgrAttribute>() - 72usize];
["Alignment of GhosttySgrAttribute"][::std::mem::align_of::<GhosttySgrAttribute>() - 8usize];
["Offset of field: GhosttySgrAttribute::tag"]
[::std::mem::offset_of!(GhosttySgrAttribute, tag) - 0usize];
["Offset of field: GhosttySgrAttribute::value"]
[::std::mem::offset_of!(GhosttySgrAttribute, value) - 8usize];
};
impl Default for GhosttySgrAttribute {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Create a new SGR parser instance.\n\n Creates a new SGR (Select Graphic Rendition) parser using the provided\n allocator. The parser must be freed using ghostty_sgr_free() when\n no longer needed.\n\n @param allocator Pointer to the allocator to use for memory management, or\n NULL to use the default allocator\n @param parser Pointer to store the created parser handle\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup sgr"]
pub fn ghostty_sgr_new(
allocator: *const GhosttyAllocator,
parser: *mut GhosttySgrParser,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free an SGR parser instance.\n\n Releases all resources associated with the SGR parser. After this call,\n the parser handle becomes invalid and must not be used. This includes\n any attributes previously returned by ghostty_sgr_next().\n\n @param parser The parser handle to free (may be NULL)\n\n @ingroup sgr"]
pub fn ghostty_sgr_free(parser: GhosttySgrParser);
}
unsafe extern "C" {
#[doc = " Reset an SGR parser instance to the beginning of the parameter list.\n\n Resets the parser's iteration state without clearing the parameters.\n After calling this, ghostty_sgr_next() will start from the beginning\n of the parameter list again.\n\n @param parser The parser handle to reset, must not be NULL\n\n @ingroup sgr"]
pub fn ghostty_sgr_reset(parser: GhosttySgrParser);
}
unsafe extern "C" {
#[doc = " Set SGR parameters for parsing.\n\n Sets the SGR parameter list to parse. Parameters are the numeric values\n from a CSI SGR sequence (e.g., for `ESC[1;31m`, params would be {1, 31}).\n\n The separators array optionally specifies the separator type for each\n parameter position. Each byte should be either ';' for semicolon or ':'\n for colon. This is needed for certain color formats that use colon\n separators (e.g., `ESC[4:3m` for curly underline). Any invalid separator\n values are treated as semicolons. The separators array must have the same\n length as the params array, if it is not NULL.\n\n If separators is NULL, all parameters are assumed to be semicolon-separated.\n\n This function makes an internal copy of the parameter and separator data,\n so the caller can safely free or modify the input arrays after this call.\n\n After calling this function, the parser is automatically reset and ready\n to iterate from the beginning.\n\n @param parser The parser handle, must not be NULL\n @param params Array of SGR parameter values\n @param separators Optional array of separator characters (';' or ':'), or\n NULL\n @param len Number of parameters (and separators if provided)\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup sgr"]
pub fn ghostty_sgr_set_params(
parser: GhosttySgrParser,
params: *const u16,
separators: *const ::std::os::raw::c_char,
len: usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get the next SGR attribute.\n\n Parses and returns the next attribute from the parameter list.\n Call this function repeatedly until it returns false to process\n all attributes in the sequence.\n\n @param parser The parser handle, must not be NULL\n @param attr Pointer to store the next attribute\n @return true if an attribute was returned, false if no more attributes\n\n @ingroup sgr"]
pub fn ghostty_sgr_next(parser: GhosttySgrParser, attr: *mut GhosttySgrAttribute) -> bool;
}
unsafe extern "C" {
#[doc = " Get the full parameter list from an unknown SGR attribute.\n\n This function retrieves the full parameter list that was provided to the\n parser when an unknown attribute was encountered. Primarily useful in\n WebAssembly environments where accessing struct fields directly is difficult.\n\n @param unknown The unknown attribute data\n @param ptr Pointer to store the pointer to the parameter array (may be NULL)\n @return The length of the full parameter array\n\n @ingroup sgr"]
pub fn ghostty_sgr_unknown_full(unknown: GhosttySgrUnknown, ptr: *mut *const u16) -> usize;
}
unsafe extern "C" {
#[doc = " Get the partial parameter list from an unknown SGR attribute.\n\n This function retrieves the partial parameter list where parsing stopped\n when an unknown attribute was encountered. Primarily useful in WebAssembly\n environments where accessing struct fields directly is difficult.\n\n @param unknown The unknown attribute data\n @param ptr Pointer to store the pointer to the parameter array (may be NULL)\n @return The length of the partial parameter array\n\n @ingroup sgr"]
pub fn ghostty_sgr_unknown_partial(unknown: GhosttySgrUnknown, ptr: *mut *const u16) -> usize;
}
unsafe extern "C" {
#[doc = " Get the tag from an SGR attribute.\n\n This function extracts the tag that identifies which type of attribute\n this is. Primarily useful in WebAssembly environments where accessing\n struct fields directly is difficult.\n\n @param attr The SGR attribute\n @return The attribute tag\n\n @ingroup sgr"]
pub fn ghostty_sgr_attribute_tag(attr: GhosttySgrAttribute) -> GhosttySgrAttributeTag::Type;
}
unsafe extern "C" {
#[doc = " Get the value from an SGR attribute.\n\n This function returns a pointer to the value union from an SGR attribute. Use\n the tag to determine which field of the union is valid. Primarily useful in\n WebAssembly environments where accessing struct fields directly is difficult.\n\n @param attr Pointer to the SGR attribute\n @return Pointer to the attribute value union\n\n @ingroup sgr"]
pub fn ghostty_sgr_attribute_value(
attr: *mut GhosttySgrAttribute,
) -> *mut GhosttySgrAttributeValue;
}
#[doc = " A decoded image, filled in by a decode callback such as\n GhosttySysDecodePngFn.\n\n Pixels are 8-bit RGBA: four bytes per pixel, stored row by row starting\n at the top-left corner, with no padding between rows. A complete image\n is therefore `width * height * 4` bytes long.\n\n The pixel buffer must be allocated with the allocator passed to the\n decode callback. When the callback returns true, the library takes\n ownership of the buffer and frees it with that same allocator."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttySysImage {
#[doc = " Image width in pixels."]
pub width: u32,
#[doc = " Image height in pixels."]
pub height: u32,
#[doc = " The decoded RGBA pixels, allocated with the allocator passed to\n the decode callback."]
pub data: *mut u8,
#[doc = " Length of `data` in bytes. This must be the exact size that was\n requested from the allocator, because the library uses it to free\n the buffer."]
pub data_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttySysImage"][::std::mem::size_of::<GhosttySysImage>() - 24usize];
["Alignment of GhosttySysImage"][::std::mem::align_of::<GhosttySysImage>() - 8usize];
["Offset of field: GhosttySysImage::width"]
[::std::mem::offset_of!(GhosttySysImage, width) - 0usize];
["Offset of field: GhosttySysImage::height"]
[::std::mem::offset_of!(GhosttySysImage, height) - 4usize];
["Offset of field: GhosttySysImage::data"]
[::std::mem::offset_of!(GhosttySysImage, data) - 8usize];
["Offset of field: GhosttySysImage::data_len"]
[::std::mem::offset_of!(GhosttySysImage, data_len) - 16usize];
};
impl Default for GhosttySysImage {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub mod GhosttySysLogLevel {
#[doc = " Log severity levels for the log callback."]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_SYS_LOG_LEVEL_ERROR: Type = 0;
pub const GHOSTTY_SYS_LOG_LEVEL_WARNING: Type = 1;
pub const GHOSTTY_SYS_LOG_LEVEL_INFO: Type = 2;
pub const GHOSTTY_SYS_LOG_LEVEL_DEBUG: Type = 3;
pub const GHOSTTY_SYS_LOG_LEVEL_MAX_VALUE: Type = 2147483647;
}
#[doc = " Callback type for logging.\n\n When installed, internal library log messages are delivered through\n this callback instead of being discarded. The embedder is responsible\n for formatting and routing log output.\n\n @p scope is the log scope name as UTF-8 bytes (e.g. \"osc\", \"kitty\").\n When the log is unscoped (default scope), @p scope_len is 0.\n\n All pointer arguments are only valid for the duration of the callback.\n The callback must be safe to call from any thread.\n\n @param userdata The userdata pointer set via GHOSTTY_SYS_OPT_USERDATA\n @param level The severity level of the log message\n @param scope Pointer to the scope name bytes\n @param scope_len Length of the scope name in bytes\n @param message Pointer to the log message bytes\n @param message_len Length of the log message in bytes"]
pub type GhosttySysLogFn = ::std::option::Option<
unsafe extern "C" fn(
userdata: *mut ::std::os::raw::c_void,
level: GhosttySysLogLevel::Type,
scope: *const u8,
scope_len: usize,
message: *const u8,
message_len: usize,
),
>;
#[doc = " Callback type for PNG decoding.\n\n The library calls this when it receives a PNG image and needs the raw\n pixels. The callback decodes the PNG bytes in @p data and describes\n the result in @p out. See the example in the @ref sys overview for a\n complete callback.\n\n ### On success\n\n Allocate the pixel buffer with ghostty_alloc() and @p allocator, write\n the decoded pixels into it, set all four fields of @p out, and return\n true. The library then owns the buffer and frees it with the same\n allocator. See GhosttySysImage for the expected pixel layout.\n\n The allocator limits how much memory a single image may use, so\n ghostty_alloc() can return NULL for very large images. Treat that as\n a failure.\n\n ### On failure\n\n Free anything that was allocated and return false. The library does\n not read @p out in this case, and the image is rejected.\n\n ### The output struct starts zeroed\n\n The library sets every field of @p out to zero before it calls the\n callback. This has two practical effects:\n\n - If the callback returns true but `data` is still NULL, the library\n treats the call as a failure.\n - Language bindings can store a pointer into @p out directly. Some\n runtimes, such as Go, require memory to be initialized before a\n pointer is written into it, and this guarantee satisfies that\n requirement.\n\n Only @p out is zeroed. Memory returned by ghostty_alloc() is not.\n\n @p data and @p allocator are only valid for the duration of the\n callback.\n\n @param userdata The userdata pointer set via GHOSTTY_SYS_OPT_USERDATA\n @param allocator The allocator to use for the output pixel buffer\n @param data Pointer to the raw PNG data\n @param data_len Length of the raw PNG data in bytes\n @param[out] out The decoded image. Zeroed by the library before the\n call, and filled in by the callback on success.\n @return true if the image was decoded and @p out was filled in,\n false on failure"]
pub type GhosttySysDecodePngFn = ::std::option::Option<
unsafe extern "C" fn(
userdata: *mut ::std::os::raw::c_void,
allocator: *const GhosttyAllocator,
data: *const u8,
data_len: usize,
out: *mut GhosttySysImage,
) -> bool,
>;
#[doc = " Callback type for secure random bytes.\n\n Fills @p buf with @p len cryptographically secure random bytes. The\n library uses this for secrets, so it must be a real CSPRNG (getrandom,\n arc4random_buf, BCryptGenRandom, crypto.getRandomValues, ...); a\n predictable source is a security hole.\n\n @param userdata The userdata pointer set via GHOSTTY_SYS_OPT_USERDATA\n @param buf Buffer to fill\n @param len Number of bytes to fill\n @return true if the buffer was filled, false if no entropy is available"]
pub type GhosttySysRandomSecureFn = ::std::option::Option<
unsafe extern "C" fn(userdata: *mut ::std::os::raw::c_void, buf: *mut u8, len: usize) -> bool,
>;
pub mod GhosttySysOption {
#[doc = " System option identifiers for ghostty_sys_set()."]
pub type Type = ::std::os::raw::c_int;
#[doc = " Set the userdata pointer passed to all sys callbacks.\n\n Input type: void* (or NULL)"]
pub const GHOSTTY_SYS_OPT_USERDATA: Type = 0;
#[doc = " Set the PNG decode function.\n\n When set, the terminal can accept PNG images via the Kitty\n Graphics Protocol. When cleared (NULL value), PNG decoding is\n unsupported and PNG image data will be rejected.\n\n Input type: GhosttySysDecodePngFn (function pointer, or NULL)"]
pub const GHOSTTY_SYS_OPT_DECODE_PNG: Type = 1;
#[doc = " Set the log callback.\n\n When set, internal library log messages are delivered to this\n callback. When cleared (NULL value), log messages are silently\n discarded.\n\n Use ghostty_sys_log_stderr as a convenience callback that\n writes formatted messages to stderr.\n\n Which log levels are emitted depends on the build mode of the\n library and is not configurable at runtime. Debug builds emit\n all levels (debug and above). Release builds emit info and\n above; debug-level messages are compiled out entirely and will\n never reach the callback.\n\n Input type: GhosttySysLogFn (function pointer, or NULL)"]
pub const GHOSTTY_SYS_OPT_LOG: Type = 2;
#[doc = " Override the secure random source.\n\n By default the library draws secure random bytes from the\n platform (getrandom or arc4random_buf on POSIX, CNG on Windows).\n Targets without one, such as wasm32-freestanding, have no default\n and operations that need entropy fail with GHOSTTY_IO_ERROR until\n this is set. When set,\n it is used instead of the platform source on every target. When\n cleared (NULL value), the platform default is restored.\n\n Input type: GhosttySysRandomSecureFn (function pointer, or NULL)"]
pub const GHOSTTY_SYS_OPT_RANDOM_SECURE: Type = 3;
#[doc = " Override the secure random source.\n\n By default the library draws secure random bytes from the\n platform (getrandom or arc4random_buf on POSIX, CNG on Windows).\n Targets without one, such as wasm32-freestanding, have no default\n and operations that need entropy fail with GHOSTTY_IO_ERROR until\n this is set. When set,\n it is used instead of the platform source on every target. When\n cleared (NULL value), the platform default is restored.\n\n Input type: GhosttySysRandomSecureFn (function pointer, or NULL)"]
pub const GHOSTTY_SYS_OPT_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Set a system-level option.\n\n Configures a process-global implementation function. These should be\n set once at startup before using any terminal functionality that\n depends on them.\n\n @param option The option to set\n @param value Pointer to the value (type depends on the option),\n or NULL to clear it\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the\n option is not recognized"]
pub fn ghostty_sys_set(
option: GhosttySysOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Built-in log callback that writes to stderr.\n\n Formats each message as \"[level](scope): message\\n\".\n Can be passed directly to ghostty_sys_set():\n\n @code\n ghostty_sys_set(GHOSTTY_SYS_OPT_LOG, &ghostty_sys_log_stderr);\n @endcode"]
pub fn ghostty_sys_log_stderr(
userdata: *mut ::std::os::raw::c_void,
level: GhosttySysLogLevel::Type,
scope: *const u8,
scope_len: usize,
message: *const u8,
message_len: usize,
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyKeyEventImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a key event.\n\n This handle represents a keyboard input event containing information about\n the physical key pressed, modifiers, and generated text.\n\n @ingroup key"]
pub type GhosttyKeyEvent = *mut GhosttyKeyEventImpl;
pub mod GhosttyKeyAction {
#[doc = " Keyboard input event types.\n\n @ingroup key"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Key was released"]
pub const GHOSTTY_KEY_ACTION_RELEASE: Type = 0;
#[doc = " Key was pressed"]
pub const GHOSTTY_KEY_ACTION_PRESS: Type = 1;
#[doc = " Key is being repeated (held down)"]
pub const GHOSTTY_KEY_ACTION_REPEAT: Type = 2;
#[doc = " Key is being repeated (held down)"]
pub const GHOSTTY_KEY_ACTION_MAX_VALUE: Type = 2147483647;
}
#[doc = " Keyboard modifier keys bitmask.\n\n A bitmask representing all keyboard modifiers. This tracks which modifier keys\n are pressed and, where supported by the platform, which side (left or right)\n of each modifier is active.\n\n Use the GHOSTTY_MODS_* constants to test and set individual modifiers.\n\n Modifier side bits are only meaningful when the corresponding modifier bit is set.\n Not all platforms support distinguishing between left and right modifier\n keys and Ghostty is built to expect that some platforms may not provide this\n information.\n\n @ingroup key"]
pub type GhosttyMods = u16;
pub mod GhosttyKey {
#[doc = " Physical key codes.\n\n The set of key codes that Ghostty is aware of. These represent physical keys\n on the keyboard and are layout-independent. For example, the \"a\" key on a US\n keyboard is the same as the \"ф\" key on a Russian keyboard, but both will\n report the same key_a value.\n\n Layout-dependent strings are provided separately as UTF-8 text and are produced\n by the platform. These values are based on the W3C UI Events KeyboardEvent code\n standard. See: https://www.w3.org/TR/uievents-code\n\n @ingroup key"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_KEY_UNIDENTIFIED: Type = 0;
pub const GHOSTTY_KEY_BACKQUOTE: Type = 1;
pub const GHOSTTY_KEY_BACKSLASH: Type = 2;
pub const GHOSTTY_KEY_BRACKET_LEFT: Type = 3;
pub const GHOSTTY_KEY_BRACKET_RIGHT: Type = 4;
pub const GHOSTTY_KEY_COMMA: Type = 5;
pub const GHOSTTY_KEY_DIGIT_0: Type = 6;
pub const GHOSTTY_KEY_DIGIT_1: Type = 7;
pub const GHOSTTY_KEY_DIGIT_2: Type = 8;
pub const GHOSTTY_KEY_DIGIT_3: Type = 9;
pub const GHOSTTY_KEY_DIGIT_4: Type = 10;
pub const GHOSTTY_KEY_DIGIT_5: Type = 11;
pub const GHOSTTY_KEY_DIGIT_6: Type = 12;
pub const GHOSTTY_KEY_DIGIT_7: Type = 13;
pub const GHOSTTY_KEY_DIGIT_8: Type = 14;
pub const GHOSTTY_KEY_DIGIT_9: Type = 15;
pub const GHOSTTY_KEY_EQUAL: Type = 16;
pub const GHOSTTY_KEY_INTL_BACKSLASH: Type = 17;
pub const GHOSTTY_KEY_INTL_RO: Type = 18;
pub const GHOSTTY_KEY_INTL_YEN: Type = 19;
pub const GHOSTTY_KEY_A: Type = 20;
pub const GHOSTTY_KEY_B: Type = 21;
pub const GHOSTTY_KEY_C: Type = 22;
pub const GHOSTTY_KEY_D: Type = 23;
pub const GHOSTTY_KEY_E: Type = 24;
pub const GHOSTTY_KEY_F: Type = 25;
pub const GHOSTTY_KEY_G: Type = 26;
pub const GHOSTTY_KEY_H: Type = 27;
pub const GHOSTTY_KEY_I: Type = 28;
pub const GHOSTTY_KEY_J: Type = 29;
pub const GHOSTTY_KEY_K: Type = 30;
pub const GHOSTTY_KEY_L: Type = 31;
pub const GHOSTTY_KEY_M: Type = 32;
pub const GHOSTTY_KEY_N: Type = 33;
pub const GHOSTTY_KEY_O: Type = 34;
pub const GHOSTTY_KEY_P: Type = 35;
pub const GHOSTTY_KEY_Q: Type = 36;
pub const GHOSTTY_KEY_R: Type = 37;
pub const GHOSTTY_KEY_S: Type = 38;
pub const GHOSTTY_KEY_T: Type = 39;
pub const GHOSTTY_KEY_U: Type = 40;
pub const GHOSTTY_KEY_V: Type = 41;
pub const GHOSTTY_KEY_W: Type = 42;
pub const GHOSTTY_KEY_X: Type = 43;
pub const GHOSTTY_KEY_Y: Type = 44;
pub const GHOSTTY_KEY_Z: Type = 45;
pub const GHOSTTY_KEY_MINUS: Type = 46;
pub const GHOSTTY_KEY_PERIOD: Type = 47;
pub const GHOSTTY_KEY_QUOTE: Type = 48;
pub const GHOSTTY_KEY_SEMICOLON: Type = 49;
pub const GHOSTTY_KEY_SLASH: Type = 50;
pub const GHOSTTY_KEY_ALT_LEFT: Type = 51;
pub const GHOSTTY_KEY_ALT_RIGHT: Type = 52;
pub const GHOSTTY_KEY_BACKSPACE: Type = 53;
pub const GHOSTTY_KEY_CAPS_LOCK: Type = 54;
pub const GHOSTTY_KEY_CONTEXT_MENU: Type = 55;
pub const GHOSTTY_KEY_CONTROL_LEFT: Type = 56;
pub const GHOSTTY_KEY_CONTROL_RIGHT: Type = 57;
pub const GHOSTTY_KEY_ENTER: Type = 58;
pub const GHOSTTY_KEY_META_LEFT: Type = 59;
pub const GHOSTTY_KEY_META_RIGHT: Type = 60;
pub const GHOSTTY_KEY_SHIFT_LEFT: Type = 61;
pub const GHOSTTY_KEY_SHIFT_RIGHT: Type = 62;
pub const GHOSTTY_KEY_SPACE: Type = 63;
pub const GHOSTTY_KEY_TAB: Type = 64;
pub const GHOSTTY_KEY_CONVERT: Type = 65;
pub const GHOSTTY_KEY_KANA_MODE: Type = 66;
pub const GHOSTTY_KEY_NON_CONVERT: Type = 67;
pub const GHOSTTY_KEY_DELETE: Type = 68;
pub const GHOSTTY_KEY_END: Type = 69;
pub const GHOSTTY_KEY_HELP: Type = 70;
pub const GHOSTTY_KEY_HOME: Type = 71;
pub const GHOSTTY_KEY_INSERT: Type = 72;
pub const GHOSTTY_KEY_PAGE_DOWN: Type = 73;
pub const GHOSTTY_KEY_PAGE_UP: Type = 74;
pub const GHOSTTY_KEY_ARROW_DOWN: Type = 75;
pub const GHOSTTY_KEY_ARROW_LEFT: Type = 76;
pub const GHOSTTY_KEY_ARROW_RIGHT: Type = 77;
pub const GHOSTTY_KEY_ARROW_UP: Type = 78;
pub const GHOSTTY_KEY_NUM_LOCK: Type = 79;
pub const GHOSTTY_KEY_NUMPAD_0: Type = 80;
pub const GHOSTTY_KEY_NUMPAD_1: Type = 81;
pub const GHOSTTY_KEY_NUMPAD_2: Type = 82;
pub const GHOSTTY_KEY_NUMPAD_3: Type = 83;
pub const GHOSTTY_KEY_NUMPAD_4: Type = 84;
pub const GHOSTTY_KEY_NUMPAD_5: Type = 85;
pub const GHOSTTY_KEY_NUMPAD_6: Type = 86;
pub const GHOSTTY_KEY_NUMPAD_7: Type = 87;
pub const GHOSTTY_KEY_NUMPAD_8: Type = 88;
pub const GHOSTTY_KEY_NUMPAD_9: Type = 89;
pub const GHOSTTY_KEY_NUMPAD_ADD: Type = 90;
pub const GHOSTTY_KEY_NUMPAD_BACKSPACE: Type = 91;
pub const GHOSTTY_KEY_NUMPAD_CLEAR: Type = 92;
pub const GHOSTTY_KEY_NUMPAD_CLEAR_ENTRY: Type = 93;
pub const GHOSTTY_KEY_NUMPAD_COMMA: Type = 94;
pub const GHOSTTY_KEY_NUMPAD_DECIMAL: Type = 95;
pub const GHOSTTY_KEY_NUMPAD_DIVIDE: Type = 96;
pub const GHOSTTY_KEY_NUMPAD_ENTER: Type = 97;
pub const GHOSTTY_KEY_NUMPAD_EQUAL: Type = 98;
pub const GHOSTTY_KEY_NUMPAD_MEMORY_ADD: Type = 99;
pub const GHOSTTY_KEY_NUMPAD_MEMORY_CLEAR: Type = 100;
pub const GHOSTTY_KEY_NUMPAD_MEMORY_RECALL: Type = 101;
pub const GHOSTTY_KEY_NUMPAD_MEMORY_STORE: Type = 102;
pub const GHOSTTY_KEY_NUMPAD_MEMORY_SUBTRACT: Type = 103;
pub const GHOSTTY_KEY_NUMPAD_MULTIPLY: Type = 104;
pub const GHOSTTY_KEY_NUMPAD_PAREN_LEFT: Type = 105;
pub const GHOSTTY_KEY_NUMPAD_PAREN_RIGHT: Type = 106;
pub const GHOSTTY_KEY_NUMPAD_SUBTRACT: Type = 107;
pub const GHOSTTY_KEY_NUMPAD_SEPARATOR: Type = 108;
pub const GHOSTTY_KEY_NUMPAD_UP: Type = 109;
pub const GHOSTTY_KEY_NUMPAD_DOWN: Type = 110;
pub const GHOSTTY_KEY_NUMPAD_RIGHT: Type = 111;
pub const GHOSTTY_KEY_NUMPAD_LEFT: Type = 112;
pub const GHOSTTY_KEY_NUMPAD_BEGIN: Type = 113;
pub const GHOSTTY_KEY_NUMPAD_HOME: Type = 114;
pub const GHOSTTY_KEY_NUMPAD_END: Type = 115;
pub const GHOSTTY_KEY_NUMPAD_INSERT: Type = 116;
pub const GHOSTTY_KEY_NUMPAD_DELETE: Type = 117;
pub const GHOSTTY_KEY_NUMPAD_PAGE_UP: Type = 118;
pub const GHOSTTY_KEY_NUMPAD_PAGE_DOWN: Type = 119;
pub const GHOSTTY_KEY_ESCAPE: Type = 120;
pub const GHOSTTY_KEY_F1: Type = 121;
pub const GHOSTTY_KEY_F2: Type = 122;
pub const GHOSTTY_KEY_F3: Type = 123;
pub const GHOSTTY_KEY_F4: Type = 124;
pub const GHOSTTY_KEY_F5: Type = 125;
pub const GHOSTTY_KEY_F6: Type = 126;
pub const GHOSTTY_KEY_F7: Type = 127;
pub const GHOSTTY_KEY_F8: Type = 128;
pub const GHOSTTY_KEY_F9: Type = 129;
pub const GHOSTTY_KEY_F10: Type = 130;
pub const GHOSTTY_KEY_F11: Type = 131;
pub const GHOSTTY_KEY_F12: Type = 132;
pub const GHOSTTY_KEY_F13: Type = 133;
pub const GHOSTTY_KEY_F14: Type = 134;
pub const GHOSTTY_KEY_F15: Type = 135;
pub const GHOSTTY_KEY_F16: Type = 136;
pub const GHOSTTY_KEY_F17: Type = 137;
pub const GHOSTTY_KEY_F18: Type = 138;
pub const GHOSTTY_KEY_F19: Type = 139;
pub const GHOSTTY_KEY_F20: Type = 140;
pub const GHOSTTY_KEY_F21: Type = 141;
pub const GHOSTTY_KEY_F22: Type = 142;
pub const GHOSTTY_KEY_F23: Type = 143;
pub const GHOSTTY_KEY_F24: Type = 144;
pub const GHOSTTY_KEY_F25: Type = 145;
pub const GHOSTTY_KEY_FN: Type = 146;
pub const GHOSTTY_KEY_FN_LOCK: Type = 147;
pub const GHOSTTY_KEY_PRINT_SCREEN: Type = 148;
pub const GHOSTTY_KEY_SCROLL_LOCK: Type = 149;
pub const GHOSTTY_KEY_PAUSE: Type = 150;
pub const GHOSTTY_KEY_BROWSER_BACK: Type = 151;
pub const GHOSTTY_KEY_BROWSER_FAVORITES: Type = 152;
pub const GHOSTTY_KEY_BROWSER_FORWARD: Type = 153;
pub const GHOSTTY_KEY_BROWSER_HOME: Type = 154;
pub const GHOSTTY_KEY_BROWSER_REFRESH: Type = 155;
pub const GHOSTTY_KEY_BROWSER_SEARCH: Type = 156;
pub const GHOSTTY_KEY_BROWSER_STOP: Type = 157;
pub const GHOSTTY_KEY_EJECT: Type = 158;
pub const GHOSTTY_KEY_LAUNCH_APP_1: Type = 159;
pub const GHOSTTY_KEY_LAUNCH_APP_2: Type = 160;
pub const GHOSTTY_KEY_LAUNCH_MAIL: Type = 161;
pub const GHOSTTY_KEY_MEDIA_PLAY_PAUSE: Type = 162;
pub const GHOSTTY_KEY_MEDIA_SELECT: Type = 163;
pub const GHOSTTY_KEY_MEDIA_STOP: Type = 164;
pub const GHOSTTY_KEY_MEDIA_TRACK_NEXT: Type = 165;
pub const GHOSTTY_KEY_MEDIA_TRACK_PREVIOUS: Type = 166;
pub const GHOSTTY_KEY_POWER: Type = 167;
pub const GHOSTTY_KEY_SLEEP: Type = 168;
pub const GHOSTTY_KEY_AUDIO_VOLUME_DOWN: Type = 169;
pub const GHOSTTY_KEY_AUDIO_VOLUME_MUTE: Type = 170;
pub const GHOSTTY_KEY_AUDIO_VOLUME_UP: Type = 171;
pub const GHOSTTY_KEY_WAKE_UP: Type = 172;
pub const GHOSTTY_KEY_COPY: Type = 173;
pub const GHOSTTY_KEY_CUT: Type = 174;
pub const GHOSTTY_KEY_PASTE: Type = 175;
pub const GHOSTTY_KEY_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a new key event instance.\n\n Creates a new key event with default values. The event must be freed using\n ghostty_key_event_free() when no longer needed.\n\n @param allocator Pointer to the allocator to use for memory management, or NULL to use the default allocator\n @param event Pointer to store the created key event handle\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup key"]
pub fn ghostty_key_event_new(
allocator: *const GhosttyAllocator,
event: *mut GhosttyKeyEvent,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a key event instance.\n\n Releases all resources associated with the key event. After this call,\n the event handle becomes invalid and must not be used.\n\n @param event The key event handle to free (may be NULL)\n\n @ingroup key"]
pub fn ghostty_key_event_free(event: GhosttyKeyEvent);
}
unsafe extern "C" {
#[doc = " Set the key action (press, release, repeat).\n\n @param event The key event handle, must not be NULL\n @param action The action to set\n\n @ingroup key"]
pub fn ghostty_key_event_set_action(event: GhosttyKeyEvent, action: GhosttyKeyAction::Type);
}
unsafe extern "C" {
#[doc = " Get the key action (press, release, repeat).\n\n @param event The key event handle, must not be NULL\n @return The key action\n\n @ingroup key"]
pub fn ghostty_key_event_get_action(event: GhosttyKeyEvent) -> GhosttyKeyAction::Type;
}
unsafe extern "C" {
#[doc = " Set the physical key code.\n\n @param event The key event handle, must not be NULL\n @param key The physical key code to set\n\n @ingroup key"]
pub fn ghostty_key_event_set_key(event: GhosttyKeyEvent, key: GhosttyKey::Type);
}
unsafe extern "C" {
#[doc = " Get the physical key code.\n\n @param event The key event handle, must not be NULL\n @return The physical key code\n\n @ingroup key"]
pub fn ghostty_key_event_get_key(event: GhosttyKeyEvent) -> GhosttyKey::Type;
}
unsafe extern "C" {
#[doc = " Set the modifier keys bitmask.\n\n @param event The key event handle, must not be NULL\n @param mods The modifier keys bitmask to set\n\n @ingroup key"]
pub fn ghostty_key_event_set_mods(event: GhosttyKeyEvent, mods: GhosttyMods);
}
unsafe extern "C" {
#[doc = " Get the modifier keys bitmask.\n\n @param event The key event handle, must not be NULL\n @return The modifier keys bitmask\n\n @ingroup key"]
pub fn ghostty_key_event_get_mods(event: GhosttyKeyEvent) -> GhosttyMods;
}
unsafe extern "C" {
#[doc = " Set the consumed modifiers bitmask.\n\n @param event The key event handle, must not be NULL\n @param consumed_mods The consumed modifiers bitmask to set\n\n @ingroup key"]
pub fn ghostty_key_event_set_consumed_mods(event: GhosttyKeyEvent, consumed_mods: GhosttyMods);
}
unsafe extern "C" {
#[doc = " Get the consumed modifiers bitmask.\n\n @param event The key event handle, must not be NULL\n @return The consumed modifiers bitmask\n\n @ingroup key"]
pub fn ghostty_key_event_get_consumed_mods(event: GhosttyKeyEvent) -> GhosttyMods;
}
unsafe extern "C" {
#[doc = " Set whether the key event is part of a composition sequence.\n\n @param event The key event handle, must not be NULL\n @param composing Whether the key event is part of a composition sequence\n\n @ingroup key"]
pub fn ghostty_key_event_set_composing(event: GhosttyKeyEvent, composing: bool);
}
unsafe extern "C" {
#[doc = " Get whether the key event is part of a composition sequence.\n\n @param event The key event handle, must not be NULL\n @return Whether the key event is part of a composition sequence\n\n @ingroup key"]
pub fn ghostty_key_event_get_composing(event: GhosttyKeyEvent) -> bool;
}
unsafe extern "C" {
#[doc = " Set the UTF-8 text generated by the key for the current keyboard layout.\n\n Must contain the unmodified character before any Ctrl/Meta transformations.\n The encoder derives modifier sequences from the logical key and mods\n bitmask, not from this text. Do not pass C0 control characters\n (U+0000-U+001F, U+007F) or platform function key codes (e.g. macOS PUA\n U+F700-U+F8FF); pass NULL instead and let the encoder use the logical key.\n\n The key event does NOT take ownership of the text pointer. The caller\n must ensure the string remains valid for the lifetime needed by the event.\n\n @param event The key event handle, must not be NULL\n @param utf8 The UTF-8 text to set (or NULL for empty)\n @param len Length of the UTF-8 text in bytes\n\n @ingroup key"]
pub fn ghostty_key_event_set_utf8(
event: GhosttyKeyEvent,
utf8: *const ::std::os::raw::c_char,
len: usize,
);
}
unsafe extern "C" {
#[doc = " Get the UTF-8 text generated by the key event.\n\n The returned pointer is valid until the event is freed or the UTF-8 text is modified.\n\n @param event The key event handle, must not be NULL\n @param len Pointer to store the length of the UTF-8 text in bytes (may be NULL)\n @return The UTF-8 text (or NULL for empty)\n\n @ingroup key"]
pub fn ghostty_key_event_get_utf8(
event: GhosttyKeyEvent,
len: *mut usize,
) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
#[doc = " Set the unshifted Unicode codepoint.\n\n @param event The key event handle, must not be NULL\n @param codepoint The unshifted Unicode codepoint to set\n\n @ingroup key"]
pub fn ghostty_key_event_set_unshifted_codepoint(event: GhosttyKeyEvent, codepoint: u32);
}
unsafe extern "C" {
#[doc = " Get the unshifted Unicode codepoint.\n\n @param event The key event handle, must not be NULL\n @return The unshifted Unicode codepoint\n\n @ingroup key"]
pub fn ghostty_key_event_get_unshifted_codepoint(event: GhosttyKeyEvent) -> u32;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyKeyEncoderImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a key encoder instance.\n\n This handle represents a key encoder that converts key events into terminal\n escape sequences.\n\n @ingroup key"]
pub type GhosttyKeyEncoder = *mut GhosttyKeyEncoderImpl;
#[doc = " Kitty keyboard protocol flags.\n\n Bitflags representing the various modes of the Kitty keyboard protocol.\n These can be combined using bitwise OR operations. Valid values all\n start with `GHOSTTY_KITTY_KEY_`.\n\n @ingroup key"]
pub type GhosttyKittyKeyFlags = u8;
pub mod GhosttyOptionAsAlt {
#[doc = " macOS option key behavior.\n\n Determines whether the \"option\" key on macOS is treated as \"alt\" or not.\n See the Ghostty `macos-option-as-alt` configuration option for more details.\n\n @ingroup key"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Option key is not treated as alt"]
pub const GHOSTTY_OPTION_AS_ALT_FALSE: Type = 0;
#[doc = " Option key is treated as alt"]
pub const GHOSTTY_OPTION_AS_ALT_TRUE: Type = 1;
#[doc = " Only left option key is treated as alt"]
pub const GHOSTTY_OPTION_AS_ALT_LEFT: Type = 2;
#[doc = " Only right option key is treated as alt"]
pub const GHOSTTY_OPTION_AS_ALT_RIGHT: Type = 3;
#[doc = " Only right option key is treated as alt"]
pub const GHOSTTY_OPTION_AS_ALT_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyKeyEncoderOption {
#[doc = " Key encoder option identifiers.\n\n These values are used with ghostty_key_encoder_setopt() to configure\n the behavior of the key encoder.\n\n @ingroup key"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Terminal DEC mode 1: cursor key application mode (value: bool)"]
pub const GHOSTTY_KEY_ENCODER_OPT_CURSOR_KEY_APPLICATION: Type = 0;
#[doc = " Terminal DEC mode 66: keypad key application mode (value: bool)"]
pub const GHOSTTY_KEY_ENCODER_OPT_KEYPAD_KEY_APPLICATION: Type = 1;
#[doc = " Terminal DEC mode 1035: ignore keypad with numlock (value: bool)"]
pub const GHOSTTY_KEY_ENCODER_OPT_IGNORE_KEYPAD_WITH_NUMLOCK: Type = 2;
#[doc = " Terminal DEC mode 1036: alt sends escape prefix (value: bool)"]
pub const GHOSTTY_KEY_ENCODER_OPT_ALT_ESC_PREFIX: Type = 3;
#[doc = " xterm modifyOtherKeys mode 2 (value: bool)"]
pub const GHOSTTY_KEY_ENCODER_OPT_MODIFY_OTHER_KEYS_STATE_2: Type = 4;
#[doc = " Kitty keyboard protocol flags (value: GhosttyKittyKeyFlags bitmask)"]
pub const GHOSTTY_KEY_ENCODER_OPT_KITTY_FLAGS: Type = 5;
#[doc = " macOS option-as-alt setting (value: GhosttyOptionAsAlt)"]
pub const GHOSTTY_KEY_ENCODER_OPT_MACOS_OPTION_AS_ALT: Type = 6;
#[doc = " Backarrow key mode (value: bool)\n See https://vt100.net/dec/ek-vt3xx-tp-002.pdf page 170\n If `false` (the default), `backspace` emits 0x7f\n If `true`, `backspace` emits 0x08"]
pub const GHOSTTY_KEY_ENCODER_OPT_BACKARROW_KEY_MODE: Type = 7;
#[doc = " Backarrow key mode (value: bool)\n See https://vt100.net/dec/ek-vt3xx-tp-002.pdf page 170\n If `false` (the default), `backspace` emits 0x7f\n If `true`, `backspace` emits 0x08"]
pub const GHOSTTY_KEY_ENCODER_OPT_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a new key encoder instance.\n\n Creates a new key encoder with default options. The encoder can be configured\n using ghostty_key_encoder_setopt() and must be freed using\n ghostty_key_encoder_free() when no longer needed.\n\n @param allocator Pointer to the allocator to use for memory management, or NULL to use the default allocator\n @param encoder Pointer to store the created encoder handle\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup key"]
pub fn ghostty_key_encoder_new(
allocator: *const GhosttyAllocator,
encoder: *mut GhosttyKeyEncoder,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a key encoder instance.\n\n Releases all resources associated with the key encoder. After this call,\n the encoder handle becomes invalid and must not be used.\n\n @param encoder The encoder handle to free (may be NULL)\n\n @ingroup key"]
pub fn ghostty_key_encoder_free(encoder: GhosttyKeyEncoder);
}
unsafe extern "C" {
#[doc = " Set an option on the key encoder.\n\n Configures the behavior of the key encoder. Options control various aspects\n of encoding such as terminal modes (cursor key application mode, keypad mode),\n protocol selection (Kitty keyboard protocol flags), and platform-specific\n behaviors (macOS option-as-alt).\n\n If you are using a terminal instance, you can set the key encoding\n options based on the active terminal state (e.g. legacy vs Kitty mode\n and associated flags) with ghostty_key_encoder_setopt_from_terminal().\n\n A null pointer value does nothing. It does not reset the value to the\n default. The setopt call will do nothing.\n\n @param encoder The encoder handle, must not be NULL\n @param option The option to set\n @param value Pointer to the value to set (type depends on the option)\n\n @ingroup key"]
pub fn ghostty_key_encoder_setopt(
encoder: GhosttyKeyEncoder,
option: GhosttyKeyEncoderOption::Type,
value: *const ::std::os::raw::c_void,
);
}
unsafe extern "C" {
#[doc = " Set encoder options from a terminal's current state.\n\n Reads the terminal's current modes and flags and applies them to the\n encoder's options. This sets cursor key application mode, keypad mode,\n alt escape prefix, modifyOtherKeys state, and Kitty keyboard protocol\n flags from the terminal state.\n\n Note that the `macos_option_as_alt` option cannot be determined from\n terminal state and is reset to `GHOSTTY_OPTION_AS_ALT_FALSE` by this\n call. Use ghostty_key_encoder_setopt() to set it afterward if needed.\n\n @param encoder The encoder handle, must not be NULL\n @param terminal The terminal handle, must not be NULL\n\n @ingroup key"]
pub fn ghostty_key_encoder_setopt_from_terminal(
encoder: GhosttyKeyEncoder,
terminal: GhosttyTerminal,
);
}
unsafe extern "C" {
#[doc = " Encode a key event into a terminal escape sequence.\n\n Converts a key event into the appropriate terminal escape sequence based on\n the encoder's current options. The sequence is written to the provided buffer.\n\n Not all key events produce output. For example, unmodified modifier keys\n typically don't generate escape sequences. Check the out_len parameter to\n determine if any data was written.\n\n If the output buffer is too small, this function returns GHOSTTY_OUT_OF_SPACE\n and out_len will contain the required buffer size. The caller can then\n allocate a larger buffer and call the function again.\n\n @param encoder The encoder handle, must not be NULL\n @param event The key event to encode, must not be NULL\n @param out_buf Buffer to write the encoded sequence to\n @param out_buf_size Size of the output buffer in bytes\n @param out_len Pointer to store the number of bytes written (may be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if buffer too small, or other error code\n\n ## Example: Calculate required buffer size\n\n @code{.c}\n // Query the required size with a NULL buffer (always returns OUT_OF_SPACE)\n size_t required = 0;\n GhosttyResult result = ghostty_key_encoder_encode(encoder, event, NULL, 0, &required);\n assert(result == GHOSTTY_OUT_OF_SPACE);\n\n // Allocate buffer of required size\n char *buf = malloc(required);\n\n // Encode with properly sized buffer\n size_t written = 0;\n result = ghostty_key_encoder_encode(encoder, event, buf, required, &written);\n assert(result == GHOSTTY_SUCCESS);\n\n // Use the encoded sequence...\n\n free(buf);\n @endcode\n\n ## Example: Direct encoding with static buffer\n\n @code{.c}\n // Most escape sequences are short, so a static buffer often suffices\n char buf[128];\n size_t written = 0;\n GhosttyResult result = ghostty_key_encoder_encode(encoder, event, buf, sizeof(buf), &written);\n\n if (result == GHOSTTY_SUCCESS) {\n // Write the encoded sequence to the terminal\n write(pty_fd, buf, written);\n } else if (result == GHOSTTY_OUT_OF_SPACE) {\n // Buffer too small, written contains required size\n char *dynamic_buf = malloc(written);\n result = ghostty_key_encoder_encode(encoder, event, dynamic_buf, written, &written);\n assert(result == GHOSTTY_SUCCESS);\n write(pty_fd, dynamic_buf, written);\n free(dynamic_buf);\n }\n @endcode\n\n @ingroup key"]
pub fn ghostty_key_encoder_encode(
encoder: GhosttyKeyEncoder,
event: GhosttyKeyEvent,
out_buf: *mut ::std::os::raw::c_char,
out_buf_size: usize,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyMouseEventImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a mouse event.\n\n This handle represents a normalized mouse input event containing\n action, button, modifiers, and surface-space position.\n\n @ingroup mouse"]
pub type GhosttyMouseEvent = *mut GhosttyMouseEventImpl;
pub mod GhosttyMouseAction {
#[doc = " Mouse event action type.\n\n @ingroup mouse"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Mouse button was pressed."]
pub const GHOSTTY_MOUSE_ACTION_PRESS: Type = 0;
#[doc = " Mouse button was released."]
pub const GHOSTTY_MOUSE_ACTION_RELEASE: Type = 1;
#[doc = " Mouse moved."]
pub const GHOSTTY_MOUSE_ACTION_MOTION: Type = 2;
#[doc = " Mouse moved."]
pub const GHOSTTY_MOUSE_ACTION_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyMouseButton {
#[doc = " Mouse button identity.\n\n @ingroup mouse"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_MOUSE_BUTTON_UNKNOWN: Type = 0;
pub const GHOSTTY_MOUSE_BUTTON_LEFT: Type = 1;
pub const GHOSTTY_MOUSE_BUTTON_RIGHT: Type = 2;
pub const GHOSTTY_MOUSE_BUTTON_MIDDLE: Type = 3;
pub const GHOSTTY_MOUSE_BUTTON_FOUR: Type = 4;
pub const GHOSTTY_MOUSE_BUTTON_FIVE: Type = 5;
pub const GHOSTTY_MOUSE_BUTTON_SIX: Type = 6;
pub const GHOSTTY_MOUSE_BUTTON_SEVEN: Type = 7;
pub const GHOSTTY_MOUSE_BUTTON_EIGHT: Type = 8;
pub const GHOSTTY_MOUSE_BUTTON_NINE: Type = 9;
pub const GHOSTTY_MOUSE_BUTTON_TEN: Type = 10;
pub const GHOSTTY_MOUSE_BUTTON_ELEVEN: Type = 11;
pub const GHOSTTY_MOUSE_BUTTON_MAX_VALUE: Type = 2147483647;
}
#[doc = " Mouse position in surface-space pixels.\n\n @ingroup mouse"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyMousePosition {
pub x: f32,
pub y: f32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyMousePosition"][::std::mem::size_of::<GhosttyMousePosition>() - 8usize];
["Alignment of GhosttyMousePosition"][::std::mem::align_of::<GhosttyMousePosition>() - 4usize];
["Offset of field: GhosttyMousePosition::x"]
[::std::mem::offset_of!(GhosttyMousePosition, x) - 0usize];
["Offset of field: GhosttyMousePosition::y"]
[::std::mem::offset_of!(GhosttyMousePosition, y) - 4usize];
};
unsafe extern "C" {
#[doc = " Create a new mouse event instance.\n\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param event Pointer to store the created event handle\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_new(
allocator: *const GhosttyAllocator,
event: *mut GhosttyMouseEvent,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a mouse event instance.\n\n @param event The mouse event handle to free (may be NULL)\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_free(event: GhosttyMouseEvent);
}
unsafe extern "C" {
#[doc = " Set the event action.\n\n @param event The event handle, must not be NULL\n @param action The action to set\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_set_action(
event: GhosttyMouseEvent,
action: GhosttyMouseAction::Type,
);
}
unsafe extern "C" {
#[doc = " Get the event action.\n\n @param event The event handle, must not be NULL\n @return The event action\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_get_action(event: GhosttyMouseEvent) -> GhosttyMouseAction::Type;
}
unsafe extern "C" {
#[doc = " Set the event button.\n\n This sets a concrete button identity for the event.\n To represent \"no button\" (for motion events), use\n ghostty_mouse_event_clear_button().\n\n @param event The event handle, must not be NULL\n @param button The button to set\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_set_button(
event: GhosttyMouseEvent,
button: GhosttyMouseButton::Type,
);
}
unsafe extern "C" {
#[doc = " Clear the event button.\n\n This sets the event button to \"none\".\n\n @param event The event handle, must not be NULL\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_clear_button(event: GhosttyMouseEvent);
}
unsafe extern "C" {
#[doc = " Get the event button.\n\n @param event The event handle, must not be NULL\n @param out_button Output pointer for the button value (may be NULL)\n @return true if a button is set, false if no button is set\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_get_button(
event: GhosttyMouseEvent,
out_button: *mut GhosttyMouseButton::Type,
) -> bool;
}
unsafe extern "C" {
#[doc = " Set keyboard modifiers held during the event.\n\n @param event The event handle, must not be NULL\n @param mods Modifier bitmask\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_set_mods(event: GhosttyMouseEvent, mods: GhosttyMods);
}
unsafe extern "C" {
#[doc = " Get keyboard modifiers held during the event.\n\n @param event The event handle, must not be NULL\n @return Modifier bitmask\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_get_mods(event: GhosttyMouseEvent) -> GhosttyMods;
}
unsafe extern "C" {
#[doc = " Set the event position in surface-space pixels.\n\n @param event The event handle, must not be NULL\n @param position The position to set\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_set_position(
event: GhosttyMouseEvent,
position: GhosttyMousePosition,
);
}
unsafe extern "C" {
#[doc = " Get the event position in surface-space pixels.\n\n @param event The event handle, must not be NULL\n @return The current event position\n\n @ingroup mouse"]
pub fn ghostty_mouse_event_get_position(event: GhosttyMouseEvent) -> GhosttyMousePosition;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyMouseEncoderImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a mouse encoder instance.\n\n This handle represents a mouse encoder that converts normalized\n mouse events into terminal escape sequences.\n\n @ingroup mouse"]
pub type GhosttyMouseEncoder = *mut GhosttyMouseEncoderImpl;
pub mod GhosttyMouseTrackingMode {
#[doc = " Mouse tracking mode.\n\n @ingroup mouse"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Mouse reporting disabled."]
pub const GHOSTTY_MOUSE_TRACKING_NONE: Type = 0;
#[doc = " X10 mouse mode."]
pub const GHOSTTY_MOUSE_TRACKING_X10: Type = 1;
#[doc = " Normal mouse mode (button press/release only)."]
pub const GHOSTTY_MOUSE_TRACKING_NORMAL: Type = 2;
#[doc = " Button-event tracking mode."]
pub const GHOSTTY_MOUSE_TRACKING_BUTTON: Type = 3;
#[doc = " Any-event tracking mode."]
pub const GHOSTTY_MOUSE_TRACKING_ANY: Type = 4;
#[doc = " Any-event tracking mode."]
pub const GHOSTTY_MOUSE_TRACKING_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyMouseFormat {
#[doc = " Mouse output format.\n\n @ingroup mouse"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_MOUSE_FORMAT_X10: Type = 0;
pub const GHOSTTY_MOUSE_FORMAT_UTF8: Type = 1;
pub const GHOSTTY_MOUSE_FORMAT_SGR: Type = 2;
pub const GHOSTTY_MOUSE_FORMAT_URXVT: Type = 3;
pub const GHOSTTY_MOUSE_FORMAT_SGR_PIXELS: Type = 4;
pub const GHOSTTY_MOUSE_FORMAT_MAX_VALUE: Type = 2147483647;
}
#[doc = " Mouse encoder size and geometry context.\n\n This describes the rendered terminal geometry used to convert\n surface-space positions into encoded coordinates.\n\n @ingroup mouse"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyMouseEncoderSize {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyMouseEncoderSize)."]
pub size: usize,
#[doc = " Full screen width in pixels."]
pub screen_width: u32,
#[doc = " Full screen height in pixels."]
pub screen_height: u32,
#[doc = " Cell width in pixels. Must be non-zero."]
pub cell_width: u32,
#[doc = " Cell height in pixels. Must be non-zero."]
pub cell_height: u32,
#[doc = " Top padding in pixels."]
pub padding_top: u32,
#[doc = " Bottom padding in pixels."]
pub padding_bottom: u32,
#[doc = " Right padding in pixels."]
pub padding_right: u32,
#[doc = " Left padding in pixels."]
pub padding_left: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyMouseEncoderSize"][::std::mem::size_of::<GhosttyMouseEncoderSize>() - 40usize];
["Alignment of GhosttyMouseEncoderSize"]
[::std::mem::align_of::<GhosttyMouseEncoderSize>() - 8usize];
["Offset of field: GhosttyMouseEncoderSize::size"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, size) - 0usize];
["Offset of field: GhosttyMouseEncoderSize::screen_width"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, screen_width) - 8usize];
["Offset of field: GhosttyMouseEncoderSize::screen_height"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, screen_height) - 12usize];
["Offset of field: GhosttyMouseEncoderSize::cell_width"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, cell_width) - 16usize];
["Offset of field: GhosttyMouseEncoderSize::cell_height"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, cell_height) - 20usize];
["Offset of field: GhosttyMouseEncoderSize::padding_top"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, padding_top) - 24usize];
["Offset of field: GhosttyMouseEncoderSize::padding_bottom"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, padding_bottom) - 28usize];
["Offset of field: GhosttyMouseEncoderSize::padding_right"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, padding_right) - 32usize];
["Offset of field: GhosttyMouseEncoderSize::padding_left"]
[::std::mem::offset_of!(GhosttyMouseEncoderSize, padding_left) - 36usize];
};
pub mod GhosttyMouseEncoderOption {
#[doc = " Mouse encoder option identifiers.\n\n These values are used with ghostty_mouse_encoder_setopt() to configure\n the behavior of the mouse encoder.\n\n @ingroup mouse"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Mouse tracking mode (value: GhosttyMouseTrackingMode)."]
pub const GHOSTTY_MOUSE_ENCODER_OPT_EVENT: Type = 0;
#[doc = " Mouse output format (value: GhosttyMouseFormat)."]
pub const GHOSTTY_MOUSE_ENCODER_OPT_FORMAT: Type = 1;
#[doc = " Renderer size context (value: GhosttyMouseEncoderSize)."]
pub const GHOSTTY_MOUSE_ENCODER_OPT_SIZE: Type = 2;
#[doc = " Whether any mouse button is currently pressed (value: bool)."]
pub const GHOSTTY_MOUSE_ENCODER_OPT_ANY_BUTTON_PRESSED: Type = 3;
#[doc = " Whether to enable motion deduplication by last cell (value: bool)."]
pub const GHOSTTY_MOUSE_ENCODER_OPT_TRACK_LAST_CELL: Type = 4;
#[doc = " Whether to enable motion deduplication by last cell (value: bool)."]
pub const GHOSTTY_MOUSE_ENCODER_OPT_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a new mouse encoder instance.\n\n @param allocator Pointer to allocator, or NULL to use the default allocator\n @param encoder Pointer to store the created encoder handle\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup mouse"]
pub fn ghostty_mouse_encoder_new(
allocator: *const GhosttyAllocator,
encoder: *mut GhosttyMouseEncoder,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a mouse encoder instance.\n\n @param encoder The encoder handle to free (may be NULL)\n\n @ingroup mouse"]
pub fn ghostty_mouse_encoder_free(encoder: GhosttyMouseEncoder);
}
unsafe extern "C" {
#[doc = " Set an option on the mouse encoder.\n\n A null pointer value does nothing. It does not reset to defaults.\n\n @param encoder The encoder handle, must not be NULL\n @param option The option to set\n @param value Pointer to option value (type depends on option)\n\n @ingroup mouse"]
pub fn ghostty_mouse_encoder_setopt(
encoder: GhosttyMouseEncoder,
option: GhosttyMouseEncoderOption::Type,
value: *const ::std::os::raw::c_void,
);
}
unsafe extern "C" {
#[doc = " Set encoder options from a terminal's current state.\n\n This sets tracking mode and output format from terminal state.\n It does not modify size or any-button state.\n\n @param encoder The encoder handle, must not be NULL\n @param terminal The terminal handle, must not be NULL\n\n @ingroup mouse"]
pub fn ghostty_mouse_encoder_setopt_from_terminal(
encoder: GhosttyMouseEncoder,
terminal: GhosttyTerminal,
);
}
unsafe extern "C" {
#[doc = " Reset internal encoder state.\n\n This clears motion deduplication state (last tracked cell).\n\n @param encoder The encoder handle (may be NULL)\n\n @ingroup mouse"]
pub fn ghostty_mouse_encoder_reset(encoder: GhosttyMouseEncoder);
}
unsafe extern "C" {
#[doc = " Encode a mouse event into a terminal escape sequence.\n\n Not all mouse events produce output. In such cases this returns\n GHOSTTY_SUCCESS with out_len set to 0.\n\n If the output buffer is too small, this returns GHOSTTY_OUT_OF_SPACE\n and out_len contains the required size.\n\n @param encoder The encoder handle, must not be NULL\n @param event The mouse event to encode, must not be NULL\n @param out_buf Buffer to write encoded bytes to, or NULL to query required size\n @param out_buf_size Size of out_buf in bytes\n @param out_len Pointer to store bytes written (or required bytes on failure)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if buffer is too small,\n or another error code\n\n @ingroup mouse"]
pub fn ghostty_mouse_encoder_encode(
encoder: GhosttyMouseEncoder,
event: GhosttyMouseEvent,
out_buf: *mut ::std::os::raw::c_char,
out_buf_size: usize,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
pub mod GhosttyMouseShape {
#[doc = " Mouse pointer shapes based on the W3C cursor names.\n\n Hosts map these values to their native pointer shapes; not every platform\n supports every shape. These are pointer shapes, not terminal text cursors.\n\n @ingroup mouse"]
pub type Type = ::std::os::raw::c_int;
pub const GHOSTTY_MOUSE_SHAPE_DEFAULT: Type = 0;
pub const GHOSTTY_MOUSE_SHAPE_CONTEXT_MENU: Type = 1;
pub const GHOSTTY_MOUSE_SHAPE_HELP: Type = 2;
pub const GHOSTTY_MOUSE_SHAPE_POINTER: Type = 3;
pub const GHOSTTY_MOUSE_SHAPE_PROGRESS: Type = 4;
pub const GHOSTTY_MOUSE_SHAPE_WAIT: Type = 5;
pub const GHOSTTY_MOUSE_SHAPE_CELL: Type = 6;
pub const GHOSTTY_MOUSE_SHAPE_CROSSHAIR: Type = 7;
pub const GHOSTTY_MOUSE_SHAPE_TEXT: Type = 8;
pub const GHOSTTY_MOUSE_SHAPE_VERTICAL_TEXT: Type = 9;
pub const GHOSTTY_MOUSE_SHAPE_ALIAS: Type = 10;
pub const GHOSTTY_MOUSE_SHAPE_COPY: Type = 11;
pub const GHOSTTY_MOUSE_SHAPE_MOVE: Type = 12;
pub const GHOSTTY_MOUSE_SHAPE_NO_DROP: Type = 13;
pub const GHOSTTY_MOUSE_SHAPE_NOT_ALLOWED: Type = 14;
pub const GHOSTTY_MOUSE_SHAPE_GRAB: Type = 15;
pub const GHOSTTY_MOUSE_SHAPE_GRABBING: Type = 16;
pub const GHOSTTY_MOUSE_SHAPE_ALL_SCROLL: Type = 17;
pub const GHOSTTY_MOUSE_SHAPE_COL_RESIZE: Type = 18;
pub const GHOSTTY_MOUSE_SHAPE_ROW_RESIZE: Type = 19;
pub const GHOSTTY_MOUSE_SHAPE_N_RESIZE: Type = 20;
pub const GHOSTTY_MOUSE_SHAPE_E_RESIZE: Type = 21;
pub const GHOSTTY_MOUSE_SHAPE_S_RESIZE: Type = 22;
pub const GHOSTTY_MOUSE_SHAPE_W_RESIZE: Type = 23;
pub const GHOSTTY_MOUSE_SHAPE_NE_RESIZE: Type = 24;
pub const GHOSTTY_MOUSE_SHAPE_NW_RESIZE: Type = 25;
pub const GHOSTTY_MOUSE_SHAPE_SE_RESIZE: Type = 26;
pub const GHOSTTY_MOUSE_SHAPE_SW_RESIZE: Type = 27;
pub const GHOSTTY_MOUSE_SHAPE_EW_RESIZE: Type = 28;
pub const GHOSTTY_MOUSE_SHAPE_NS_RESIZE: Type = 29;
pub const GHOSTTY_MOUSE_SHAPE_NESW_RESIZE: Type = 30;
pub const GHOSTTY_MOUSE_SHAPE_NWSE_RESIZE: Type = 31;
pub const GHOSTTY_MOUSE_SHAPE_ZOOM_IN: Type = 32;
pub const GHOSTTY_MOUSE_SHAPE_ZOOM_OUT: Type = 33;
pub const GHOSTTY_MOUSE_SHAPE_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttyPasteSource {
#[doc = " Why a paste happened."]
pub type Type = ::std::os::raw::c_int;
#[doc = " The user pasted from a clipboard: keybind, menu, middle click."]
pub const GHOSTTY_PASTE_SOURCE_CLIPBOARD: Type = 0;
#[doc = " Text inserted some other way: IME commit, drag and drop, scripted\n input. Always written as text, never as a paste event, matching\n kitty. This is not a way to opt out of paste events; an embedder\n that doesn't want them doesn't install a clipboard_read callback."]
pub const GHOSTTY_PASTE_SOURCE_TEXT: Type = 1;
#[doc = " Text inserted some other way: IME commit, drag and drop, scripted\n input. Always written as text, never as a paste event, matching\n kitty. This is not a way to opt out of paste events; an embedder\n that doesn't want them doesn't install a clipboard_read callback."]
pub const GHOSTTY_PASTE_SOURCE_MAX_VALUE: Type = 2147483647;
}
#[doc = " A paste of clipboard contents into the terminal.\n\n This is a sized struct; set `size` to `sizeof(GhosttyPaste)`. The\n MIME type array and the strings it points to are borrowed only for\n the duration of the ghostty_terminal_paste() call, as is everything\n the reader produces."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyPaste {
#[doc = " Size of this struct in bytes."]
pub size: usize,
#[doc = " The clipboard the contents came from. Reported to the program on a\n paste event (the selection and primary locations are both reported\n as the primary selection, the protocol knows only two); no effect\n on a text paste."]
pub location: GhosttyClipboardLocation::Type,
#[doc = " Why this paste happened."]
pub source: GhosttyPasteSource::Type,
#[doc = " Borrowed array of the MIME types of the representations available,\n in preferred order. A text paste reads and writes the first entry\n with a text MIME type such as \"text/plain\" and ignores the rest. A\n paste event lists every entry and reads none. May be NULL when\n mimes_len is zero, which is nothing to paste."]
pub mimes: *const GhosttyString,
#[doc = " Number of entries in mimes."]
pub mimes_len: usize,
#[doc = " Produces the data of a representation on demand. Required when\n mimes_len is nonzero.\n\n Called at most once per ghostty_terminal_paste() call: for the\n text representation being pasted, never for anything else and\n never for a paste event. The MIME type requested is always an\n entry of `mimes`, passed through exactly as given there (the same\n pointer and length), so the callback may identify the\n representation by pointer or by content. A false return fails the\n paste with GHOSTTY_IO_ERROR."]
pub reader: GhosttyMimeReader,
#[doc = " Write text that could inject commands. Call with false, confirm\n with the user on GHOSTTY_REJECTED, and call again with true."]
pub allow_unsafe: bool,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyPaste"][::std::mem::size_of::<GhosttyPaste>() - 56usize];
["Alignment of GhosttyPaste"][::std::mem::align_of::<GhosttyPaste>() - 8usize];
["Offset of field: GhosttyPaste::size"][::std::mem::offset_of!(GhosttyPaste, size) - 0usize];
["Offset of field: GhosttyPaste::location"]
[::std::mem::offset_of!(GhosttyPaste, location) - 8usize];
["Offset of field: GhosttyPaste::source"]
[::std::mem::offset_of!(GhosttyPaste, source) - 12usize];
["Offset of field: GhosttyPaste::mimes"][::std::mem::offset_of!(GhosttyPaste, mimes) - 16usize];
["Offset of field: GhosttyPaste::mimes_len"]
[::std::mem::offset_of!(GhosttyPaste, mimes_len) - 24usize];
["Offset of field: GhosttyPaste::reader"]
[::std::mem::offset_of!(GhosttyPaste, reader) - 32usize];
["Offset of field: GhosttyPaste::allow_unsafe"]
[::std::mem::offset_of!(GhosttyPaste, allow_unsafe) - 48usize];
};
impl Default for GhosttyPaste {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
unsafe extern "C" {
#[doc = " Paste into the terminal according to its current state: a Kitty\n clipboard protocol paste event if mode 5522 is enabled and a\n clipboard_read callback is installed, otherwise the text framed per\n mode 2004. See the group documentation for the full behavior. Output\n streams through the write_pty callback in chunks. The viewport is not\n scrolled; that is up to the embedder, as for key input.\n\n A paste event records a session grant for its one-time password only\n once the event is written; a failed call never leaves a grant for an\n event that was never sent.\n\n @param terminal The terminal handle\n @param paste The paste request, borrowed for the duration of the call\n @param[out] out_written On success, whether anything was written to\n the pty (the encoded text or a paste event). False means\n there was nothing to paste: no non-empty text\n representation. May be NULL.\n @return GHOSTTY_SUCCESS on success (see @p out_written);\n GHOSTTY_REJECTED if the text could inject commands and\n GhosttyPaste::allow_unsafe is false (nothing was written);\n GHOSTTY_INVALID_VALUE for a NULL terminal or paste, MIME\n types without a reader, or when no write_pty callback is\n installed; GHOSTTY_OUT_OF_MEMORY; GHOSTTY_IO_ERROR if the\n reader failed or there is no secure entropy source to mint a\n paste event password (wasm32-freestanding without\n GHOSTTY_SYS_OPT_RANDOM_SECURE set). Errors write nothing."]
pub fn ghostty_terminal_paste(
terminal: GhosttyTerminal,
paste: *const GhosttyPaste,
out_written: *mut bool,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Check if paste data is safe to paste into the terminal.\n\n Data is considered unsafe if it contains:\n - Line terminators (`\\n` or `\\r`) which can inject commands. A\n carriage return is what the Enter key sends, so it is as dangerous\n as a newline on an unbracketed paste.\n - The bracketed paste end sequence (`\\x1b[201~`) which can be used\n to exit bracketed paste mode and inject commands\n\n This check is conservative and considers data unsafe regardless of\n current terminal state. ghostty_terminal_paste() applies the\n terminal-state-aware rule itself (line terminators are safe inside a\n bracketed paste); use this to apply the stricter rule on top.\n\n @param data The paste data to check (must not be NULL)\n @param len The length of the data in bytes\n @return true if the data is safe to paste, false otherwise"]
pub fn ghostty_paste_is_safe(data: *const ::std::os::raw::c_char, len: usize) -> bool;
}
unsafe extern "C" {
#[doc = " Encode paste data for writing to the terminal pty.\n\n This function prepares paste data for terminal input by:\n - Stripping unsafe control bytes (NUL, ESC, DEL, etc.) by replacing\n them with spaces\n - Wrapping the data in bracketed paste sequences if @p bracketed is true\n - Replacing newlines with carriage returns if @p bracketed is false\n\n The input @p data buffer is modified in place during encoding. The\n encoded result (potentially with bracketed paste prefix/suffix) is\n written to the output buffer.\n\n If the output buffer is too small, the function returns\n GHOSTTY_OUT_OF_SPACE and sets the required size in @p out_written.\n The caller can then retry with a sufficiently sized buffer.\n\n This is the encoder ghostty_terminal_paste() uses for a text paste;\n use it directly when there is no terminal to paste into.\n\n @param data The paste data to encode (modified in place, may be NULL)\n @param data_len The length of the input data in bytes\n @param bracketed Whether bracketed paste mode is active\n @param buf Output buffer to write the encoded result into (may be NULL)\n @param buf_len Size of the output buffer in bytes\n @param[out] out_written On success, the number of bytes written. On\n GHOSTTY_OUT_OF_SPACE, the required buffer size.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if the buffer\n is too small"]
pub fn ghostty_paste_encode(
data: *mut ::std::os::raw::c_char,
data_len: usize,
bracketed: bool,
buf: *mut ::std::os::raw::c_char,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
pub mod GhosttySearchStatus {
#[doc = " Progress state of a search.\n\n @ingroup search"]
pub type Type = ::std::os::raw::c_int;
#[doc = " ghostty_search_tick() can make progress without terminal access."]
pub const GHOSTTY_SEARCH_STATUS_RUNNING: Type = 0;
#[doc = " Blocked until ghostty_search_feed(). This is also the state right\n after a needle is set, since the search has not yet seen the\n terminal."]
pub const GHOSTTY_SEARCH_STATUS_FEED_REQUIRED: Type = 1;
#[doc = " Caught up with the terminal state as of the last feed. This never\n means finished forever, since later terminal writes require\n another feed to be seen. A search with no needle set also reports\n complete, since there is nothing to look for."]
pub const GHOSTTY_SEARCH_STATUS_COMPLETE: Type = 2;
#[doc = " Caught up with the terminal state as of the last feed. This never\n means finished forever, since later terminal writes require\n another feed to be seen. A search with no needle set also reports\n complete, since there is nothing to look for."]
pub const GHOSTTY_SEARCH_STATUS_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySearchScroll {
#[doc = " Scroll policy applied when a match becomes selected via\n GHOSTTY_SEARCH_OPT_SELECT_NEXT or GHOSTTY_SEARCH_OPT_SELECT_PREV.\n\n @ingroup search"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Scroll the viewport so the match is visible, only if it is not\n already visible. This is the default."]
pub const GHOSTTY_SEARCH_SCROLL_IF_NEEDED: Type = 0;
#[doc = " Never scroll the viewport."]
pub const GHOSTTY_SEARCH_SCROLL_NONE: Type = 1;
#[doc = " Never scroll the viewport."]
pub const GHOSTTY_SEARCH_SCROLL_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySearchData {
#[doc = " Data fields readable with ghostty_search_get(). The output value\n type is documented per field.\n\n All reads reflect the terminal's active screen as of the last feed.\n When the running application switches to the alternate screen, the\n next feed switches counts, matches, and selection to that screen's\n results. Primary screen results, including completed scrollback\n searches, are retained and restored on the way back.\n\n @ingroup search"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Current search status: GhosttySearchStatus*."]
pub const GHOSTTY_SEARCH_DATA_STATUS: Type = 0;
#[doc = " The needle this search is looking for: GhosttyString*. The bytes\n are borrowed from the search and remain valid until the needle is\n changed or the search is freed. Returns GHOSTTY_NO_VALUE when no\n needle is set."]
pub const GHOSTTY_SEARCH_DATA_NEEDLE: Type = 1;
#[doc = " Total matches found so far on the active screen: size_t*. Zero\n until the first feed."]
pub const GHOSTTY_SEARCH_DATA_TOTAL_MATCHES: Type = 2;
#[doc = " Index of the selected match: size_t*. This indexes the newest to\n oldest ordering of GHOSTTY_SEARCH_DATA_MATCHES, where 0 is the\n newest match, so a \"k of n\" find bar renders index + 1 of\n GHOSTTY_SEARCH_DATA_TOTAL_MATCHES. Returns GHOSTTY_NO_VALUE when\n nothing is selected."]
pub const GHOSTTY_SEARCH_DATA_SELECTED_INDEX: Type = 3;
#[doc = " The selected match: GhosttySelection*. This is an untracked\n snapshot with standard GhosttySelection lifetime rules. Returns\n GHOSTTY_NO_VALUE when nothing is selected."]
pub const GHOSTTY_SEARCH_DATA_SELECTED_MATCH: Type = 4;
#[doc = " All matches on the active screen, ordered newest to oldest, from\n the bottom of the active area up through scrollback:\n GhosttySelectionBuffer*. Set ptr to NULL with cap 0 to query the\n required capacity. An undersized buffer returns\n GHOSTTY_OUT_OF_SPACE with the required capacity in len."]
pub const GHOSTTY_SEARCH_DATA_MATCHES: Type = 5;
#[doc = " Matches on the pages covering the viewport, for drawing highlight\n rectangles: GhosttySelectionBuffer*. The list is computed during\n feeds and cached, so it reflects the viewport as of the last\n feed.\n\n Matches are found a page at a time, so the list can include\n matches slightly outside the visible viewport when they share a\n page with it. Ghostty's own renderer behaves the same way.\n Converting each match to viewport coordinates with\n ghostty_terminal_point_from_grid_ref() clips this naturally: skip\n matches that fail the conversion or whose row is beyond the\n visible row count."]
pub const GHOSTTY_SEARCH_DATA_VIEWPORT_MATCHES: Type = 6;
#[doc = " Current scroll policy: GhosttySearchScroll*."]
pub const GHOSTTY_SEARCH_DATA_SELECT_SCROLL: Type = 7;
#[doc = " Current scroll policy: GhosttySearchScroll*."]
pub const GHOSTTY_SEARCH_DATA_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySearchOption {
#[doc = " Options writable with ghostty_search_set(). The value type, and\n what a NULL value means, is documented per option.\n\n @ingroup search"]
pub type Type = ::std::os::raw::c_int;
#[doc = " Set the needle to search for: const GhosttyString*. The bytes are\n copied, so the caller's memory does not need to outlive the call.\n Matching is byte-exact except ASCII letters, which compare\n case-insensitively.\n\n Changing the needle restarts the search from scratch and drops\n all results. As an exception, setting a needle equal to the current\n one (compared the same way as matching) keeps existing results,\n so find bars can resubmit freely. A NULL or empty value clears\n the needle and returns the search to idle.\n\n Replacing or clearing a needle releases tracked state held\n within the terminal, so the caller must serialize this with all\n other access to the same terminal. Returns GHOSTTY_INVALID_VALUE\n after the terminal was freed."]
pub const GHOSTTY_SEARCH_OPT_NEEDLE: Type = 0;
#[doc = " Select the next match, moving toward older content: from the\n bottom of the screen upward into history, the direction a search\n from the prompt usually wants. Wraps around past the oldest\n match.\n\n The value must be NULL. It is reserved for future use.\n\n This catches up with the terminal first, so it is safe to call at\n any time relative to feeds. The viewport scrolls to the newly\n selected match according to GHOSTTY_SEARCH_OPT_SELECT_SCROLL.\n This reads the terminal, so the caller must serialize it with all\n other access to the same terminal. Returns GHOSTTY_NO_VALUE when\n there are no matches."]
pub const GHOSTTY_SEARCH_OPT_SELECT_NEXT: Type = 1;
#[doc = " Select the previous match, moving toward newer content, wrapping\n around past the newest match. Otherwise identical to\n GHOSTTY_SEARCH_OPT_SELECT_NEXT."]
pub const GHOSTTY_SEARCH_OPT_SELECT_PREV: Type = 2;
#[doc = " Set the scroll policy applied by the select options: const\n GhosttySearchScroll*. The policy persists until changed. A NULL\n value resets it to GHOSTTY_SEARCH_SCROLL_IF_NEEDED. This only\n modifies search-owned state and never reads the terminal."]
pub const GHOSTTY_SEARCH_OPT_SELECT_SCROLL: Type = 3;
#[doc = " Set the scroll policy applied by the select options: const\n GhosttySearchScroll*. The policy persists until changed. A NULL\n value resets it to GHOSTTY_SEARCH_SCROLL_IF_NEEDED. This only\n modifies search-owned state and never reads the terminal."]
pub const GHOSTTY_SEARCH_OPT_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a search bound to a terminal.\n\n The search borrows the terminal and never frees it. The search and\n the terminal can be freed in either order; see ghostty_search_free().\n\n The search starts idle with no needle: it reports\n GHOSTTY_SEARCH_STATUS_COMPLETE and finds nothing. Set\n GHOSTTY_SEARCH_OPT_NEEDLE to start searching.\n\n Creation is cheap and does not read terminal contents, but it\n registers the search with the terminal so the two can be freed in\n any order. The caller must serialize this call with all other\n access to the same terminal.\n\n @param allocator Allocator, or NULL for the default allocator\n @param out_search Receives the created search handle\n @param terminal Terminal to bind the search to\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if\n out_search or terminal is invalid, or GHOSTTY_OUT_OF_MEMORY\n if allocation fails\n\n @ingroup search"]
pub fn ghostty_search_new(
allocator: *const GhosttyAllocator,
out_search: *mut GhosttySearch,
terminal: GhosttyTerminal,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a search.\n\n If the bound terminal is still alive, this releases tracked state\n the search holds within it, so the caller must serialize this call\n with all other access to the same terminal. If the terminal was\n already freed, the search has been detached and this releases only\n search-owned memory. Passing NULL is allowed and is a no-op.\n\n @param search Search handle to free\n\n @ingroup search"]
pub fn ghostty_search_free(search: GhosttySearch);
}
unsafe extern "C" {
#[doc = " Make a bounded amount of search progress.\n\n This only works on data the search has already copied and never\n reads the terminal, so it is safe to call while another thread\n modifies the terminal. Call it in a loop while the status is\n GHOSTTY_SEARCH_STATUS_RUNNING. When the status becomes\n GHOSTTY_SEARCH_STATUS_FEED_REQUIRED, call ghostty_search_feed() to\n unblock it.\n\n @param search Search handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param[out] out_status Receives the status after the tick (may be NULL)\n @return GHOSTTY_SUCCESS on success, or GHOSTTY_INVALID_VALUE if\n search is NULL or the terminal was freed\n\n @ingroup search"]
pub fn ghostty_search_tick(
search: GhosttySearch,
out_status: *mut GhosttySearchStatus::Type,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Read the terminal to update the search.\n\n Each feed catches the search up with the terminal: it reconciles\n the tracked screens against the live ones, re-scans the active\n area, refreshes the viewport match list, gives the scrollback\n searcher its next chunk of data, and prunes results that scrollback\n eviction invalidated. Feeding is also the only way the search\n learns about terminal changes, so keep feeding periodically while\n the search is in use, even after it reports complete.\n\n This reads the terminal, so the caller must serialize it with all\n other access to the same terminal. Each call does a bounded amount\n of work so that any caller-held terminal lock is held only briefly.\n\n @param search Search handle (NULL returns GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success, or GHOSTTY_INVALID_VALUE if\n search is NULL or the terminal was freed\n\n @ingroup search"]
pub fn ghostty_search_feed(search: GhosttySearch) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Feed and tick until the search is caught up with the terminal.\n\n This is a blocking convenience for one-shot and single-threaded\n embedders. It always performs at least one feed, so it also picks\n up any terminal changes since the last feed, then loops until the\n status is GHOSTTY_SEARCH_STATUS_COMPLETE. Searching a large\n scrollback can take a while, so interactive embedders should drive\n ghostty_search_tick() and ghostty_search_feed() themselves.\n\n This reads the terminal for the entire call, so the caller must\n serialize it with all other access to the same terminal.\n\n @param search Search handle (NULL returns GHOSTTY_INVALID_VALUE)\n @return GHOSTTY_SUCCESS on success, or GHOSTTY_INVALID_VALUE if\n search is NULL or the terminal was freed\n\n @ingroup search"]
pub fn ghostty_search_run(search: GhosttySearch) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Write an option to a search.\n\n The value type, and what a NULL value means, depends on the option\n and is documented by GhosttySearchOption. The needle and select\n options touch the terminal, so the caller must serialize those\n calls with all other access to the same terminal.\n GHOSTTY_SEARCH_OPT_SELECT_SCROLL only modifies search-owned state.\n\n @param search Search handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param option Option to write\n @param value Pointer to the input value for the option. The meaning\n of NULL is documented per option.\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if a select\n option found no matches, GHOSTTY_OUT_OF_MEMORY if\n allocation fails, or GHOSTTY_INVALID_VALUE if search,\n option, or value is invalid or the option needs a terminal\n that was already freed\n\n @ingroup search"]
pub fn ghostty_search_set(
search: GhosttySearch,
option: GhosttySearchOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Read a data field from a search.\n\n The output value type depends on data and is documented by\n GhosttySearchData. This never reads the terminal, so it is safe to\n call while another thread modifies the terminal. Returned\n selections are untracked snapshots with standard GhosttySelection\n lifetime rules.\n\n @param search Search handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param data Data field to read\n @param value Output pointer whose type depends on data\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if the\n requested data has no value, GHOSTTY_OUT_OF_SPACE if a\n provided GhosttySelectionBuffer is too small (required\n capacity in its len), GHOSTTY_OUT_OF_MEMORY if collecting\n viewport matches fails, or GHOSTTY_INVALID_VALUE if search,\n data, or value is invalid\n\n @ingroup search"]
pub fn ghostty_search_get(
search: GhosttySearch,
data: GhosttySearchData::Type,
value: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Read multiple data fields from a search in a single call.\n\n This is an optimization over calling ghostty_search_get() multiple\n times. Each entry in values must point to storage of the type\n documented by the corresponding GhosttySearchData key.\n\n If any individual read fails, the function returns that error and\n writes the index of the failing key to out_written when out_written\n is non-NULL. Earlier keys have already been written. On success,\n out_written receives count when non-NULL. A too-small\n GhosttySelectionBuffer stops the batch with GHOSTTY_OUT_OF_SPACE at\n that key's index with the required capacity in its len, so order\n buffer-valued keys after scalar keys.\n\n @param search Search handle (NULL returns GHOSTTY_INVALID_VALUE)\n @param count Number of data fields to read\n @param keys Data fields to read (must not be NULL)\n @param values Output pointers corresponding to keys (must not be NULL)\n @param out_written Optional number of fields read, or failing index\n on error\n @return GHOSTTY_SUCCESS on success, or the first failing read's\n result\n\n @ingroup search"]
pub fn ghostty_search_get_multi(
search: GhosttySearch,
count: usize,
keys: *const GhosttySearchData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
pub mod GhosttySnapshotDecoderOption {
#[doc = " Configurable snapshot decoder options.\n\n Options may only be changed before decoding starts. Calling\n ghostty_snapshot_decoder_set() after ghostty_snapshot_decoder_ready() or\n ghostty_snapshot_decoder_decode() returns GHOSTTY_INVALID_VALUE."]
pub type Type = ::std::os::raw::c_int;
#[doc = " Largest non-ground continuation the decoder will accept.\n\n A value of zero accepts only snapshots whose VT parser is in the ground\n state. The decoder default matches the largest built-in APC protocol\n buffer limit, currently 65 MiB.\n\n This is primarily an input validation limit. When\n GHOSTTY_SNAPSHOT_DECODER_OPT_RETAIN_CONTINUATION is true, the same value\n also becomes the continuation tracking limit on the returned terminal.\n\n Input type: size_t *"]
pub const GHOSTTY_SNAPSHOT_DECODER_OPT_MAX_CONTINUATION_BYTES: Type = 0;
#[doc = " Retain the decoded continuation on the returned terminal.\n\n When true, terminals returned by ghostty_snapshot_decoder_ready() and\n ghostty_snapshot_decoder_decode() use\n GHOSTTY_SNAPSHOT_DECODER_OPT_MAX_CONTINUATION_BYTES as their continuation\n tracking limit. The existing ghostty_terminal_continuation_* APIs can then\n export the exact unfinished VT or UTF-8 input restored from the snapshot.\n\n This is false by default. A maximum continuation size of zero leaves\n tracking disabled. With a nonzero maximum, tracking remains enabled even\n when the decoded continuation is empty. Exporting an empty continuation\n does not disable it. Callers that do not need ongoing tracking must still\n set GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES to zero after export and\n before writing post-snapshot input.\n\n Input type: bool *"]
pub const GHOSTTY_SNAPSHOT_DECODER_OPT_RETAIN_CONTINUATION: Type = 1;
#[doc = " Compress scrollback history while it is restored.\n\n By default, restoring a snapshot leaves all of its scrollback history\n uncompressed, even if the terminal that produced the snapshot had\n compressed it. The history stays that size until the application calls\n ghostty_terminal_compress(). For a terminal with a lot of scrollback,\n that can be many times more memory than the terminal needed before.\n\n When this option is true, the decoder compresses each history page right\n after restoring it. The restored terminal starts out compressed, and the\n decode never holds more than one uncompressed history page at a time.\n The result is the same as decoding normally and then calling\n ghostty_terminal_compress() with GHOSTTY_TERMINAL_COMPRESSION_MODE_FULL,\n without the memory spike in between.\n\n A history page that is on screen when it is restored stays uncompressed.\n This only happens if the viewport is scrolled to the top of the\n scrollback during an incremental decode. Compressed history is\n uncompressed automatically when it is accessed later, for example by\n scrolling or searching.\n\n This only changes how the restored terminal stores its history in\n memory. The snapshot format is unchanged, so it works with any snapshot.\n On platforms that do not support scrollback compression, this option is\n accepted and has no effect.\n\n This is false by default.\n\n Input type: bool *"]
pub const GHOSTTY_SNAPSHOT_DECODER_OPT_COMPRESS_HISTORY: Type = 2;
#[doc = " Compress scrollback history while it is restored.\n\n By default, restoring a snapshot leaves all of its scrollback history\n uncompressed, even if the terminal that produced the snapshot had\n compressed it. The history stays that size until the application calls\n ghostty_terminal_compress(). For a terminal with a lot of scrollback,\n that can be many times more memory than the terminal needed before.\n\n When this option is true, the decoder compresses each history page right\n after restoring it. The restored terminal starts out compressed, and the\n decode never holds more than one uncompressed history page at a time.\n The result is the same as decoding normally and then calling\n ghostty_terminal_compress() with GHOSTTY_TERMINAL_COMPRESSION_MODE_FULL,\n without the memory spike in between.\n\n A history page that is on screen when it is restored stays uncompressed.\n This only happens if the viewport is scrolled to the top of the\n scrollback during an incremental decode. Compressed history is\n uncompressed automatically when it is accessed later, for example by\n scrolling or searching.\n\n This only changes how the restored terminal stores its history in\n memory. The snapshot format is unchanged, so it works with any snapshot.\n On platforms that do not support scrollback compression, this option is\n accepted and has no effect.\n\n This is false by default.\n\n Input type: bool *"]
pub const GHOSTTY_SNAPSHOT_DECODER_OPT_MAX_VALUE: Type = 2147483647;
}
pub mod GhosttySnapshotDecoderData {
#[doc = " Queryable snapshot decoder data.\n\n Each variant documents the output pointer type expected by\n ghostty_snapshot_decoder_get()."]
pub type Type = ::std::os::raw::c_int;
#[doc = " Invalid data type. Never results in data extraction."]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_INVALID: Type = 0;
#[doc = " Current maximum accepted continuation size.\n\n This value is available in every non-failed decoder state.\n\n Output type: size_t *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_MAX_CONTINUATION_BYTES: Type = 1;
#[doc = " Number of snapshot source bytes consumed so far.\n\n At FINISH this identifies the first byte after the snapshot. Trailing\n bytes are not consumed. This value is unavailable after a decoding error,\n because the decoder can no longer guarantee its source position.\n\n Output type: size_t *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_SOURCE_OFFSET: Type = 2;
#[doc = " Advisory complete logical history extent for the primary screen.\n\n The value counts rows before the active area, including any resident\n overlap carried before READY. It becomes available after READY validates.\n\n Output type: uint64_t *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_HISTORY_ROWS_PRIMARY: Type = 3;
#[doc = " Advisory complete logical history extent for the alternate screen.\n\n The value has the same semantics and lifetime as\n GHOSTTY_SNAPSHOT_DECODER_DATA_HISTORY_ROWS_PRIMARY. Querying it returns\n GHOSTTY_NO_VALUE when the snapshot does not declare an alternate screen.\n\n Output type: uint64_t *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_HISTORY_ROWS_ALTERNATE: Type = 4;
#[doc = " Screen associated with the most recently decoded history page.\n\n This value is available only after ghostty_snapshot_decoder_next()\n returns GHOSTTY_SUCCESS. A later call to next replaces it or clears it\n when FINISH is reached or an error occurs.\n\n Output type: GhosttyTerminalScreen *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_SCREEN: Type = 5;
#[doc = " Rows prepended by the most recently decoded history page.\n\n Zero means the page was consumed and validated but could not be\n applied to the live terminal.\n\n Output type: size_t *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_ROWS: Type = 6;
#[doc = " Page records remaining in the same screen's HISTORY sequence.\n\n This is not a count of all pages remaining in the snapshot.\n\n Output type: uint32_t *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_REMAINING: Type = 7;
#[doc = " Whether decoded continuation tracking is retained on returned terminals.\n\n This value is available in every non-failed decoder state.\n\n Output type: bool *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_RETAIN_CONTINUATION: Type = 8;
#[doc = " Whether history is compressed while it is restored.\n\n See GHOSTTY_SNAPSHOT_DECODER_OPT_COMPRESS_HISTORY. This value is\n available in every non-failed decoder state.\n\n Output type: bool *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_COMPRESS_HISTORY: Type = 9;
#[doc = " Whether history is compressed while it is restored.\n\n See GHOSTTY_SNAPSHOT_DECODER_OPT_COMPRESS_HISTORY. This value is\n available in every non-failed decoder state.\n\n Output type: bool *"]
pub const GHOSTTY_SNAPSHOT_DECODER_DATA_MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Encode a complete terminal snapshot to a writer.\n\n The terminal's persistent VT stream supplies the continuation bytes needed\n to reconstruct unfinished parser state. The caller must prevent concurrent\n writes or other terminal mutation for the duration of this call. The writer\n callback must not call terminal APIs with the same terminal handle.\n A terminal can be encoded with tracking disabled when its VT parser and\n UTF-8 decoder are both at ground. If either is unfinished, tracking must\n have been enabled before the input that produced that state was written;\n otherwise this returns GHOSTTY_INVALID_VALUE.\n\n Encoding begins at the writer's current position. If an error occurs, the\n writer may contain a partial snapshot without a valid FINISH marker.\n Calls to the writer are synchronous; this function does not flush or make\n the caller's destination durable.\n\n @param terminal Terminal to encode (must not be NULL)\n @param writer Destination writer whose write callback must not be NULL\n @return GHOSTTY_SUCCESS on success, GHOSTTY_IO_ERROR if the writer rejects\n output, GHOSTTY_LIMIT_EXCEEDED if output accounting overflows, or\n another error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_encode(
terminal: GhosttyTerminal,
writer: GhosttyWriter,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Encode a complete terminal snapshot to a caller-provided buffer.\n\n Pass NULL for buf with buf_len zero to query the required size. If the\n buffer is too small, this returns GHOSTTY_OUT_OF_SPACE and stores the\n required capacity in out_written. A non-NULL undersized buffer may contain\n a partial snapshot prefix. On success, out_written receives the number of\n bytes encoded.\n\n A terminal can be encoded with tracking disabled when its VT parser and\n UTF-8 decoder are both at ground. If either is unfinished, tracking must\n have been enabled before the input that produced that state was written;\n otherwise this returns GHOSTTY_INVALID_VALUE.\n\n @param terminal Terminal to encode (must not be NULL)\n @param buf Destination buffer, or NULL when buf_len is zero\n @param buf_len Destination buffer capacity in bytes\n @param[out] out_written Bytes written, or required capacity on\n GHOSTTY_OUT_OF_SPACE (must not be NULL)\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_encode_buf(
terminal: GhosttyTerminal,
buf: *mut u8,
buf_len: usize,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Encode a complete terminal snapshot to an allocated buffer.\n\n The returned buffer is allocated with allocator, or the default allocator\n when allocator is NULL. The caller must release it with ghostty_free(),\n passing the same allocator used here.\n\n A terminal can be encoded with tracking disabled when its VT parser and\n UTF-8 decoder are both at ground. If either is unfinished, tracking must\n have been enabled before the input that produced that state was written;\n otherwise this returns GHOSTTY_INVALID_VALUE.\n\n @param terminal Terminal to encode (must not be NULL)\n @param allocator Allocator for the output, or NULL for the default allocator\n @param[out] out_ptr Allocated snapshot bytes (must not be NULL)\n @param[out] out_len Number of allocated snapshot bytes (must not be NULL)\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_encode_alloc(
terminal: GhosttyTerminal,
allocator: *const GhosttyAllocator,
out_ptr: *mut *mut u8,
out_len: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Create a snapshot decoder that reads from a caller-provided reader.\n\n The decoder stores a copy of reader. Its read callback must not be NULL, and\n both the callback and its caller-owned context must remain valid until\n FINISH is reached or the decoder is freed. Reads are synchronous and occur\n only during ready, next, or decode calls. A zero-byte successful read is\n permanent end-of-file, not temporary starvation; nonblocking sources must\n wait outside the decoder or block in their callback. The read callback must\n not call APIs, including ghostty_snapshot_decoder_free(), on the decoder\n that owns it. Returning false reports GHOSTTY_IO_ERROR; returning true with\n zero bytes before a required marker reports truncated snapshot data as\n GHOSTTY_INVALID_VALUE.\n\n @param allocator Allocator for decoder and decoded terminal state, or NULL\n for the default allocator\n @param decoder Pointer to receive the decoder handle (must not be NULL)\n @param reader Snapshot source reader\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_new(
allocator: *const GhosttyAllocator,
decoder: *mut GhosttySnapshotDecoder,
reader: GhosttyReader,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Create a snapshot decoder over a borrowed byte buffer.\n\n The bytes are not copied. ptr must remain valid and immutable until FINISH\n is reached or the decoder is freed. Bytes after FINISH are not consumed;\n query GHOSTTY_SNAPSHOT_DECODER_DATA_SOURCE_OFFSET to locate them.\n\n @param allocator Allocator for decoder and decoded terminal state, or NULL\n for the default allocator\n @param decoder Pointer to receive the decoder handle (must not be NULL)\n @param ptr Snapshot source bytes\n @param len Number of source bytes\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_new_buf(
allocator: *const GhosttyAllocator,
decoder: *mut GhosttySnapshotDecoder,
ptr: *const u8,
len: usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Free a snapshot decoder.\n\n This does not release the caller's ownership of a terminal returned by\n ready or decode. Abandoning an incremental decode leaves that terminal\n usable with whatever history had already been restored.\n\n @param decoder Decoder to free (may be NULL)\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_free(decoder: GhosttySnapshotDecoder);
}
unsafe extern "C" {
#[doc = " Set a snapshot decoder option.\n\n The value pointer must have the type documented by option. Options may only\n be changed before decoding starts.\n\n @param decoder Decoder handle (must not be NULL)\n @param option Option to change\n @param value Pointer to the option value (must not be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if decoding has\n started or an argument is invalid, or another error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_set(
decoder: GhosttySnapshotDecoder,
option: GhosttySnapshotDecoderOption::Type,
value: *const ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Decode and validate the renderable snapshot prefix through READY.\n\n On success, terminal receives a caller-owned terminal with its persistent\n VT stream already restored from the snapshot continuation. The terminal is\n immediately usable for rendering and live input. Older scrollback remains\n to be restored with ghostty_snapshot_decoder_next().\n\n The restored parser state may be unfinished. By default, terminal\n continuation tracking is disabled and\n GHOSTTY_TERMINAL_DATA_CONTINUATION_MAX_BYTES returns zero. When\n GHOSTTY_SNAPSHOT_DECODER_OPT_RETAIN_CONTINUATION is true, the decoder's\n maximum continuation size is applied to the terminal, and the terminal\n continuation APIs export the exact current continuation when that limit is\n nonzero. Tracking remains enabled even if the exported continuation is\n empty. Callers that do not need ongoing tracking must set\n GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES to zero after export and before\n writing any post-snapshot bytes, because later input may change it.\n\n The caller must keep the returned terminal alive until FINISH validates or\n the decoder is freed. The decoder borrows this terminal handle while it\n restores history; ghostty_snapshot_decoder_next() uses it automatically.\n\n This operation may only be called once and only before decoding starts.\n terminal is set to NULL on every error. A decoding, I/O, or allocation\n error after input consumption begins poisons the decoder, after which it\n must be freed. An invalid argument or lifecycle error detected before the\n operation consumes input does not poison it.\n\n @param decoder Decoder handle (must not be NULL)\n @param[out] terminal Pointer to receive the terminal (must not be NULL)\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_ready(
decoder: GhosttySnapshotDecoder,
terminal: *mut GhosttyTerminal,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Decode one history page into the terminal returned by READY.\n\n Each GHOSTTY_SUCCESS consumes and validates one PAGE record. Query the\n GHOSTTY_SNAPSHOT_DECODER_DATA_PROGRESS_* values before calling next again.\n GHOSTTY_NO_VALUE means FINISH was validated; repeated calls after FINISH\n also return GHOSTTY_NO_VALUE.\n\n The terminal may be rendered, resized, and fed live PTY input between calls.\n If a history page can no longer be applied safely, it is still consumed and\n validated and progress reports zero rows. The decoder applies history\n to the caller-owned terminal produced by its READY operation.\n\n If GHOSTTY_SNAPSHOT_DECODER_OPT_COMPRESS_HISTORY is true, the page is\n compressed before this function returns, unless it is visible in the\n terminal's viewport.\n\n A decoding error invalidates the decoder's source position. The terminal\n remains caller-owned and usable with its already-restored history, but only\n ghostty_snapshot_decoder_free() may subsequently be called on the decoder.\n\n @param decoder Decoder handle (must not be NULL)\n @return GHOSTTY_SUCCESS for one page, GHOSTTY_NO_VALUE after FINISH, or an\n error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_next(decoder: GhosttySnapshotDecoder) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Decode and validate one complete snapshot.\n\n This is the one-shot form of READY followed by all history pages through\n FINISH. It may only be called before decoding starts. Bytes following FINISH\n are left unread. On success terminal receives a caller-owned terminal with\n its persistent VT stream restored. Continuation tracking on the returned\n terminal is disabled by default. When\n GHOSTTY_SNAPSHOT_DECODER_OPT_RETAIN_CONTINUATION is true, the decoder's\n maximum continuation size is applied to the terminal, and the terminal\n continuation APIs export the exact current continuation when that limit is\n nonzero. Tracking remains enabled even if the exported continuation is\n empty. Callers that do not need ongoing tracking must set\n GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES to zero after export and before\n writing any post-snapshot bytes, because later input may change it.\n terminal is set to NULL on every error.\n A decoding, I/O, or allocation error after input consumption begins poisons\n the decoder, after which it must be freed. An invalid argument or\n lifecycle error detected before the operation consumes input does not\n poison it.\n\n @param decoder Decoder handle (must not be NULL)\n @param[out] terminal Pointer to receive the terminal (must not be NULL)\n @return GHOSTTY_SUCCESS on success, or an error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_decode(
decoder: GhosttySnapshotDecoder,
terminal: *mut GhosttyTerminal,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get typed data from a snapshot decoder.\n\n The output pointer must have the type documented by data. A phase-dependent\n value that is not currently available returns GHOSTTY_NO_VALUE.\n\n @param decoder Decoder handle (must not be NULL)\n @param data Data kind to query\n @param[out] out Pointer to receive the value (must not be NULL)\n @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if the requested data\n is unavailable, or another error code on failure\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_get(
decoder: GhosttySnapshotDecoder,
data: GhosttySnapshotDecoderData::Type,
out: *mut ::std::os::raw::c_void,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Get multiple snapshot decoder data fields in a single call.\n\n Each keys element selects a data kind and the corresponding values element\n points to storage of the documented output type. Processing stops at the\n first error. On success out_written is set to count; on error it is set to\n the number of values written before the failing key. Invalid array arguments\n report zero values written.\n\n @param decoder Decoder handle (must not be NULL)\n @param count Number of key/value pairs\n @param keys Array of data kinds to query\n @param values Array of output pointers corresponding to keys\n @param[out] out_written Number of successfully written values (may be NULL)\n @return GHOSTTY_SUCCESS if every query succeeds, or the first error\n\n @ingroup snapshot"]
pub fn ghostty_snapshot_decoder_get_multi(
decoder: GhosttySnapshotDecoder,
count: usize,
keys: *const GhosttySnapshotDecoderData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> GhosttyResult::Type;
}
unsafe extern "C" {
#[doc = " Returns the terminal display width of a Unicode codepoint in\n terminal grid cells: 0, 1, or 2.\n\n This is the same width table the terminal itself uses when laying\n out printed text, so callers can predict column layout (e.g. IME\n preedit overlays) that exactly matches what the terminal will do\n when the text is actually written to it.\n\n Semantics:\n - Returns 0 for zero-width codepoints: C0/C1 control characters,\n nonspacing and enclosing combining marks, default-ignorable\n codepoints (ZWJ, ZWNJ, variation selectors, etc.), and\n surrogate codepoints.\n - Returns 2 for wide codepoints: East Asian Wide/Fullwidth\n (including emoji with default emoji presentation) and regional\n indicators. Width is clamped to 2 (e.g. the three-em dash).\n - Returns 1 for everything else, including invalid codepoints\n beyond U+10FFFF (this function is total; it never fails).\n\n This operates on a single codepoint only and therefore cannot account\n for grapheme-cluster-level width rules (VS16 emoji presentation,\n combining sequences, etc.). For cluster-accurate widths, use\n ghostty_unicode_grapheme_width(). Summing per-codepoint widths is only\n correct when mode 2027 (grapheme clustering) is disabled.\n\n This function is pure, allocates nothing, and is thread-safe.\n\n @param cp The Unicode codepoint to measure\n @return Display width in cells: 0, 1, or 2"]
pub fn ghostty_unicode_codepoint_width(cp: u32) -> u8;
}
unsafe extern "C" {
#[doc = " Measures the terminal display width of the first grapheme cluster in a\n sequence of Unicode codepoints.\n\n This uses the exact same grapheme segmentation and cluster width rules\n the terminal itself uses when printing text with grapheme clustering\n enabled (mode 2027), so callers can predict column layout (e.g. IME\n preedit overlays) that exactly matches what the terminal will do when\n the text is actually written to it. Unlike\n ghostty_unicode_codepoint_width(), this accounts for cluster-level\n rules: emoji variation selectors, ZWJ sequences, combining marks, and\n skin tone modifiers.\n\n Reads codepoints from cps until the terminal would consider the\n grapheme cluster complete, stores the cluster's total width in cells\n (0, 1, or 2) into width (which may be NULL if only segmentation is\n desired), and returns the number of codepoints consumed. Returns 0 if\n and only if len is 0; otherwise consumes at least one codepoint. Measure\n a whole string by calling in a loop:\n\n @code\n size_t total = 0;\n for (size_t i = 0; i < len;) {\n uint8_t width;\n i += ghostty_unicode_grapheme_width(cps + i, len - i, &width);\n total += width;\n }\n @endcode\n\n This is not a streaming API. The provided sequence must contain a\n complete first grapheme cluster, or the logical end of the string. If\n input arrives in chunks, keep buffering while this function consumes all\n available codepoints (return value == len) and the stream may still\n continue; a later codepoint could still extend the cluster and change\n its width.\n\n Width semantics, matching the terminal with mode 2027 enabled:\n - The cluster starts at the width of its first codepoint, as returned by\n ghostty_unicode_codepoint_width().\n - VS16 (U+FE0F) forces the cluster wide (2) and VS15 (U+FE0E) forces it\n narrow (1), but only when the immediately preceding codepoint in the\n cluster is a valid emoji variation sequence base (per Unicode\n emoji-variation-sequences.txt). Invalid variation selectors are\n ignored entirely.\n - Any other continuation codepoint that contributes to grapheme width\n forces the cluster wide (2). Note this means cluster width is NOT the\n maximum of per-codepoint widths: some continuation marks have narrow\n codepoint width yet still widen the cluster.\n\n Mode dependence: this models mode 2027 (grapheme clustering) enabled,\n which is Ghostty's recommended configuration. When mode 2027 is\n disabled, clusters never combine and variation selectors never change\n width; predict layout in that case by summing\n ghostty_unicode_codepoint_width() over each codepoint instead.\n\n Edge cases:\n - Codepoints beyond U+10FFFF consume one codepoint, have width 1, and\n are always cluster boundaries. This function is total; it never fails.\n - Control characters (C0/C1, CR, LF) are never printed through the\n terminal's text path; passing them here returns an unspecified (but\n stable and bounded) result.\n - A cluster whose first codepoint is zero-width (e.g. a lone combining\n mark) is malformed at a cell start; the terminal may attach it to\n earlier screen content. This function reports the fold result for the\n sequence in isolation (typically 0).\n\n This function is pure, allocates nothing, and is thread-safe.\n\n @param cps Pointer to codepoints (may be NULL only when len is 0)\n @param len Number of codepoints available\n @param width Out: cluster display width in cells (0-2); may be NULL\n @return Number of codepoints in the first grapheme cluster"]
pub fn ghostty_unicode_grapheme_width(cps: *const u32, len: usize, width: *mut u8) -> usize;
}