/* automatically generated by rust-bindgen 0.72.1 */
pub const ENUM_MAX_VALUE: u32 = 2147483647;
pub const COLOR_NAMED_BLACK: u8 = 0;
pub const COLOR_NAMED_RED: u8 = 1;
pub const COLOR_NAMED_GREEN: u8 = 2;
pub const COLOR_NAMED_YELLOW: u8 = 3;
pub const COLOR_NAMED_BLUE: u8 = 4;
pub const COLOR_NAMED_MAGENTA: u8 = 5;
pub const COLOR_NAMED_CYAN: u8 = 6;
pub const COLOR_NAMED_WHITE: u8 = 7;
pub const COLOR_NAMED_BRIGHT_BLACK: u8 = 8;
pub const COLOR_NAMED_BRIGHT_RED: u8 = 9;
pub const COLOR_NAMED_BRIGHT_GREEN: u8 = 10;
pub const COLOR_NAMED_BRIGHT_YELLOW: u8 = 11;
pub const COLOR_NAMED_BRIGHT_BLUE: u8 = 12;
pub const COLOR_NAMED_BRIGHT_MAGENTA: u8 = 13;
pub const COLOR_NAMED_BRIGHT_CYAN: u8 = 14;
pub const COLOR_NAMED_BRIGHT_WHITE: u8 = 15;
pub const DA_CONFORMANCE_VT100: u16 = 1;
pub const DA_CONFORMANCE_VT101: u16 = 1;
pub const DA_CONFORMANCE_VT102: u16 = 6;
pub const DA_CONFORMANCE_VT125: u16 = 12;
pub const DA_CONFORMANCE_VT131: u16 = 7;
pub const DA_CONFORMANCE_VT132: u16 = 4;
pub const DA_CONFORMANCE_VT220: u16 = 62;
pub const DA_CONFORMANCE_VT240: u16 = 62;
pub const DA_CONFORMANCE_VT320: u16 = 63;
pub const DA_CONFORMANCE_VT340: u16 = 63;
pub const DA_CONFORMANCE_VT420: u16 = 64;
pub const DA_CONFORMANCE_VT510: u16 = 65;
pub const DA_CONFORMANCE_VT520: u16 = 65;
pub const DA_CONFORMANCE_VT525: u16 = 65;
pub const DA_CONFORMANCE_LEVEL_2: u16 = 62;
pub const DA_CONFORMANCE_LEVEL_3: u16 = 63;
pub const DA_CONFORMANCE_LEVEL_4: u16 = 64;
pub const DA_CONFORMANCE_LEVEL_5: u16 = 65;
pub const DA_FEATURE_COLUMNS_132: u16 = 1;
pub const DA_FEATURE_PRINTER: u16 = 2;
pub const DA_FEATURE_REGIS: u16 = 3;
pub const DA_FEATURE_SIXEL: u16 = 4;
pub const DA_FEATURE_SELECTIVE_ERASE: u16 = 6;
pub const DA_FEATURE_USER_DEFINED_KEYS: u16 = 8;
pub const DA_FEATURE_NATIONAL_REPLACEMENT: u16 = 9;
pub const DA_FEATURE_TECHNICAL_CHARACTERS: u16 = 15;
pub const DA_FEATURE_LOCATOR: u16 = 16;
pub const DA_FEATURE_TERMINAL_STATE: u16 = 17;
pub const DA_FEATURE_WINDOWING: u16 = 18;
pub const DA_FEATURE_HORIZONTAL_SCROLLING: u16 = 21;
pub const DA_FEATURE_ANSI_COLOR: u16 = 22;
pub const DA_FEATURE_RECTANGULAR_EDITING: u16 = 28;
pub const DA_FEATURE_ANSI_TEXT_LOCATOR: u16 = 29;
pub const DA_FEATURE_CLIPBOARD: u16 = 52;
pub const DA_DEVICE_TYPE_VT100: u16 = 0;
pub const DA_DEVICE_TYPE_VT220: u16 = 1;
pub const DA_DEVICE_TYPE_VT240: u16 = 2;
pub const DA_DEVICE_TYPE_VT330: u16 = 18;
pub const DA_DEVICE_TYPE_VT340: u16 = 19;
pub const DA_DEVICE_TYPE_VT320: u16 = 24;
pub const DA_DEVICE_TYPE_VT382: u16 = 32;
pub const DA_DEVICE_TYPE_VT420: u16 = 41;
pub const DA_DEVICE_TYPE_VT510: u16 = 61;
pub const DA_DEVICE_TYPE_VT520: u16 = 64;
pub const DA_DEVICE_TYPE_VT525: u16 = 65;
pub const MODS_SHIFT: u16 = 1;
pub const MODS_CTRL: u16 = 2;
pub const MODS_ALT: u16 = 4;
pub const MODS_SUPER: u16 = 8;
pub const MODS_CAPS_LOCK: u16 = 16;
pub const MODS_NUM_LOCK: u16 = 32;
pub const MODS_SHIFT_SIDE: u16 = 64;
pub const MODS_CTRL_SIDE: u16 = 128;
pub const MODS_ALT_SIDE: u16 = 256;
pub const MODS_SUPER_SIDE: u16 = 512;
pub const KITTY_KEY_DISABLED: u8 = 0;
pub const KITTY_KEY_DISAMBIGUATE: u8 = 1;
pub const KITTY_KEY_REPORT_EVENTS: u8 = 2;
pub const KITTY_KEY_REPORT_ALTERNATES: u8 = 4;
pub const KITTY_KEY_REPORT_ALL: u8 = 8;
pub const KITTY_KEY_REPORT_ASSOCIATED: u8 = 16;
pub const KITTY_KEY_ALL: u8 = 31;
pub mod Result {
#[doc = " Result codes for libghostty-vt operations."]
pub type Type = ::std::os::raw::c_int;
#[doc = " Operation completed successfully"]
pub const SUCCESS: Type = 0;
#[doc = " Operation failed due to failed allocation"]
pub const OUT_OF_MEMORY: Type = -1;
#[doc = " Operation failed due to invalid value"]
pub const INVALID_VALUE: Type = -2;
#[doc = " Operation failed because the provided buffer was too small"]
pub const OUT_OF_SPACE: Type = -3;
#[doc = " The requested value has no value"]
pub const NO_VALUE: Type = -4;
#[doc = " The requested value has no value"]
pub const RESULT_MAX_VALUE: Type = 2147483647;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TerminalImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a terminal instance.\n"]
pub type Terminal = *mut TerminalImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TrackedGridRefImpl {
_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"]
pub type TrackedGridRef = *mut TrackedGridRefImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct KittyGraphicsImpl {
_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"]
pub type KittyGraphics = *mut KittyGraphicsImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct KittyGraphicsImageImpl {
_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"]
pub type KittyGraphicsImage = *const KittyGraphicsImageImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct KittyGraphicsPlacementIteratorImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a Kitty graphics placement iterator.\n"]
pub type KittyGraphicsPlacementIterator = *mut KittyGraphicsPlacementIteratorImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct RenderStateImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a render state instance.\n"]
pub type RenderState = *mut RenderStateImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct RenderStateRowIteratorImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a render-state row iterator.\n"]
pub type RenderStateRowIterator = *mut RenderStateRowIteratorImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct RenderStateRowCellsImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to render-state row cells.\n"]
pub type RenderStateRowCells = *mut RenderStateRowCellsImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SgrParserImpl {
_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"]
pub type SgrParser = *mut SgrParserImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FormatterImpl {
_unused: [u8; 0],
}
#[doc = " Opaque handle to a formatter instance.\n"]
pub type Formatter = *mut FormatterImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct OscParserImpl {
_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"]
pub type OscParser = *mut OscParserImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct OscCommandImpl {
_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"]
pub type OscCommand = *mut OscCommandImpl;
pub mod FormatterFormat {
#[doc = " Terminal content output format.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Plain text (no escape sequences)."]
pub const PLAIN: Type = 0;
#[doc = " VT sequences preserving colors, styles, URLs, etc."]
pub const VT: Type = 1;
#[doc = " HTML with inline styles."]
pub const HTML: Type = 2;
#[doc = " HTML with inline styles."]
pub const 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."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct String {
#[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 String"][::std::mem::size_of::<String>() - 16usize];
["Alignment of String"][::std::mem::align_of::<String>() - 8usize];
["Offset of field: String::ptr"][::std::mem::offset_of!(String, ptr) - 0usize];
["Offset of field: String::len"][::std::mem::offset_of!(String, len) - 8usize];
};
impl Default for String {
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 Buffer {
#[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 Buffer"][::std::mem::size_of::<Buffer>() - 24usize];
["Alignment of Buffer"][::std::mem::align_of::<Buffer>() - 8usize];
["Offset of field: Buffer::ptr"][::std::mem::offset_of!(Buffer, ptr) - 0usize];
["Offset of field: Buffer::cap"][::std::mem::offset_of!(Buffer, cap) - 8usize];
["Offset of field: Buffer::len"][::std::mem::offset_of!(Buffer, len) - 16usize];
};
impl Default for Buffer {
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 SurfacePosition {
#[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 SurfacePosition"][::std::mem::size_of::<SurfacePosition>() - 16usize];
["Alignment of SurfacePosition"][::std::mem::align_of::<SurfacePosition>() - 8usize];
["Offset of field: SurfacePosition::x"][::std::mem::offset_of!(SurfacePosition, x) - 0usize];
["Offset of field: SurfacePosition::y"][::std::mem::offset_of!(SurfacePosition, 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 Codepoints {
#[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 Codepoints"][::std::mem::size_of::<Codepoints>() - 16usize];
["Alignment of Codepoints"][::std::mem::align_of::<Codepoints>() - 8usize];
["Offset of field: Codepoints::ptr"][::std::mem::offset_of!(Codepoints, ptr) - 0usize];
["Offset of field: Codepoints::len"][::std::mem::offset_of!(Codepoints, len) - 8usize];
};
impl Default for Codepoints {
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 a pointer to a null-terminated JSON string describing the\n layout of every C API struct for the current target.\n\n This is primarily useful for language bindings that can't easily\n set C struct fields and need to do so via byte offsets. For example,\n WebAssembly modules can't share struct definitions with the host.\n\n Example (abbreviated):\n {\n \"GhosttyMouseEncoderSize\": {\n \"size\": 40,\n \"align\": 8,\n \"fields\": {\n \"size\": { \"offset\": 0, \"size\": 8, \"type\": \"u64\" },\n \"screen_width\": { \"offset\": 8, \"size\": 4, \"type\": \"u32\" },\n \"screen_height\": { \"offset\": 12, \"size\": 4, \"type\": \"u32\" },\n \"cell_width\": { \"offset\": 16, \"size\": 4, \"type\": \"u32\" },\n \"cell_height\": { \"offset\": 20, \"size\": 4, \"type\": \"u32\" },\n \"padding_top\": { \"offset\": 24, \"size\": 4, \"type\": \"u32\" },\n \"padding_bottom\": { \"offset\": 28, \"size\": 4, \"type\": \"u32\" },\n \"padding_right\": { \"offset\": 32, \"size\": 4, \"type\": \"u32\" },\n \"padding_left\": { \"offset\": 36, \"size\": 4, \"type\": \"u32\" }\n }\n }\n }\n\n The returned pointer is valid for the lifetime of the process.\n"]
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\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.\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 AllocatorVtable {
#[doc = " Return a pointer to `len` bytes with specified `alignment`, or return\n `NULL` indicating the allocation failed.\n\n be a power of two between 1 and 16 inclusive."]
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"]
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"]
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"]
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 AllocatorVtable"][::std::mem::size_of::<AllocatorVtable>() - 32usize];
["Alignment of AllocatorVtable"][::std::mem::align_of::<AllocatorVtable>() - 8usize];
["Offset of field: AllocatorVtable::alloc"]
[::std::mem::offset_of!(AllocatorVtable, alloc) - 0usize];
["Offset of field: AllocatorVtable::resize"]
[::std::mem::offset_of!(AllocatorVtable, resize) - 8usize];
["Offset of field: AllocatorVtable::remap"]
[::std::mem::offset_of!(AllocatorVtable, remap) - 16usize];
["Offset of field: AllocatorVtable::free"]
[::std::mem::offset_of!(AllocatorVtable, 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).\n\n\n Usage example:\n GhosttyAllocator allocator = {\n .vtable = &my_allocator_vtable,\n .ctx = my_allocator_state\n };"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Allocator {
#[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 AllocatorVtable,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of Allocator"][::std::mem::size_of::<Allocator>() - 16usize];
["Alignment of Allocator"][::std::mem::align_of::<Allocator>() - 8usize];
["Offset of field: Allocator::ctx"][::std::mem::offset_of!(Allocator, ctx) - 0usize];
["Offset of field: Allocator::vtable"][::std::mem::offset_of!(Allocator, vtable) - 8usize];
};
impl Default for Allocator {
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"]
pub fn ghostty_alloc(allocator: *const Allocator, 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 memory, or NULL if the default allocator was used\n allocation size)\n"]
pub fn ghostty_free(allocator: *const Allocator, ptr: *mut u8, len: usize);
}
pub mod OptimizeMode {
#[doc = " Build optimization mode."]
pub type Type = ::std::os::raw::c_uint;
pub const DEBUG: Type = 0;
pub const RELEASE_SAFE: Type = 1;
pub const RELEASE_SMALL: Type = 2;
pub const RELEASE_FAST: Type = 3;
pub const MODE_MAX_VALUE: Type = 2147483647;
}
pub mod BuildInfo {
#[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_uint;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const INVALID: Type = 0;
#[doc = " Whether SIMD-accelerated code paths are enabled.\n\n Output type: bool *"]
pub const SIMD: Type = 1;
#[doc = " Whether Kitty graphics protocol support is available.\n\n Output type: bool *"]
pub const KITTY_GRAPHICS: Type = 2;
#[doc = " Whether tmux control mode support is available.\n\n Output type: bool *"]
pub const TMUX_CONTROL_MODE: Type = 3;
#[doc = " The optimization mode the library was built with.\n\n Output type: GhosttyOptimizeMode *"]
pub const 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 VERSION_STRING: Type = 5;
#[doc = " The major version number.\n\n Output type: size_t *"]
pub const VERSION_MAJOR: Type = 6;
#[doc = " The minor version number.\n\n Output type: size_t *"]
pub const VERSION_MINOR: Type = 7;
#[doc = " The patch version number.\n\n Output type: size_t *"]
pub const 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 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 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 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 data type is invalid\n"]
pub fn ghostty_build_info(
data: BuildInfo::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::Type;
}
#[doc = " RGB color value.\n"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ColorRgb {
#[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 ColorRgb"][::std::mem::size_of::<ColorRgb>() - 3usize];
["Alignment of ColorRgb"][::std::mem::align_of::<ColorRgb>() - 1usize];
["Offset of field: ColorRgb::r"][::std::mem::offset_of!(ColorRgb, r) - 0usize];
["Offset of field: ColorRgb::g"][::std::mem::offset_of!(ColorRgb, g) - 1usize];
["Offset of field: ColorRgb::b"][::std::mem::offset_of!(ColorRgb, b) - 2usize];
};
#[doc = " Palette color index (0-255).\n"]
pub type ColorPaletteIndex = u8;
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"]
pub fn ghostty_color_rgb_get(color: ColorRgb, r: *mut u8, g: *mut u8, b: *mut u8);
}
pub mod ColorScheme {
#[doc = " Color scheme reported in response to a CSI ? 996 n query.\n"]
pub type Type = ::std::os::raw::c_uint;
pub const LIGHT: Type = 0;
pub const DARK: Type = 1;
pub const 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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct DeviceAttributesPrimary {
#[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 DeviceAttributesPrimary"]
[::std::mem::size_of::<DeviceAttributesPrimary>() - 144usize];
["Alignment of DeviceAttributesPrimary"]
[::std::mem::align_of::<DeviceAttributesPrimary>() - 8usize];
["Offset of field: DeviceAttributesPrimary::conformance_level"]
[::std::mem::offset_of!(DeviceAttributesPrimary, conformance_level) - 0usize];
["Offset of field: DeviceAttributesPrimary::features"]
[::std::mem::offset_of!(DeviceAttributesPrimary, features) - 2usize];
["Offset of field: DeviceAttributesPrimary::num_features"]
[::std::mem::offset_of!(DeviceAttributesPrimary, num_features) - 136usize];
};
impl Default for DeviceAttributesPrimary {
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"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct DeviceAttributesSecondary {
#[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 DeviceAttributesSecondary"]
[::std::mem::size_of::<DeviceAttributesSecondary>() - 6usize];
["Alignment of DeviceAttributesSecondary"]
[::std::mem::align_of::<DeviceAttributesSecondary>() - 2usize];
["Offset of field: DeviceAttributesSecondary::device_type"]
[::std::mem::offset_of!(DeviceAttributesSecondary, device_type) - 0usize];
["Offset of field: DeviceAttributesSecondary::firmware_version"]
[::std::mem::offset_of!(DeviceAttributesSecondary, firmware_version) - 2usize];
["Offset of field: DeviceAttributesSecondary::rom_cartridge"]
[::std::mem::offset_of!(DeviceAttributesSecondary, 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"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct DeviceAttributesTertiary {
#[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 DeviceAttributesTertiary"]
[::std::mem::size_of::<DeviceAttributesTertiary>() - 4usize];
["Alignment of DeviceAttributesTertiary"]
[::std::mem::align_of::<DeviceAttributesTertiary>() - 4usize];
["Offset of field: DeviceAttributesTertiary::unit_id"]
[::std::mem::offset_of!(DeviceAttributesTertiary, 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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct DeviceAttributes {
pub primary: DeviceAttributesPrimary,
pub secondary: DeviceAttributesSecondary,
pub tertiary: DeviceAttributesTertiary,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of DeviceAttributes"][::std::mem::size_of::<DeviceAttributes>() - 160usize];
["Alignment of DeviceAttributes"][::std::mem::align_of::<DeviceAttributes>() - 8usize];
["Offset of field: DeviceAttributes::primary"]
[::std::mem::offset_of!(DeviceAttributes, primary) - 0usize];
["Offset of field: DeviceAttributes::secondary"]
[::std::mem::offset_of!(DeviceAttributes, secondary) - 144usize];
["Offset of field: DeviceAttributes::tertiary"]
[::std::mem::offset_of!(DeviceAttributes, tertiary) - 152usize];
};
impl Default for DeviceAttributes {
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 FocusEvent {
#[doc = " Focus event types for focus reporting mode (mode 1004)."]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Terminal window gained focus"]
pub const GAINED: Type = 0;
#[doc = " Terminal window lost focus"]
pub const LOST: Type = 1;
#[doc = " Terminal window lost focus"]
pub const 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 GHOSTTY_OUT_OF_SPACE, the required buffer size.\n is too small"]
pub fn ghostty_focus_encode(
event: FocusEvent::Type,
buf: *mut ::std::os::raw::c_char,
buf_len: usize,
out_written: *mut usize,
) -> Result::Type;
}
#[doc = " Opaque cell value.\n\n Represents a single terminal cell. The internal layout is opaque and\n must be queried via ghostty_cell_get(). Obtain cell values from\n terminal query APIs.\n"]
pub type Cell = 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"]
pub type Row = u64;
pub mod CellContentTag {
#[doc = " Cell content tag.\n\n Describes what kind of content a cell holds.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " A single codepoint (may be zero for empty)."]
pub const CODEPOINT: Type = 0;
#[doc = " A codepoint that is part of a multi-codepoint grapheme cluster."]
pub const CODEPOINT_GRAPHEME: Type = 1;
#[doc = " No text; background color from palette."]
pub const BG_COLOR_PALETTE: Type = 2;
#[doc = " No text; background color as RGB."]
pub const BG_COLOR_RGB: Type = 3;
#[doc = " No text; background color as RGB."]
pub const TAG_MAX_VALUE: Type = 2147483647;
}
pub mod CellWide {
#[doc = " Cell wide property.\n\n Describes the width behavior of a cell.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Not a wide character, cell width 1."]
pub const NARROW: Type = 0;
#[doc = " Wide character, cell width 2."]
pub const WIDE: Type = 1;
#[doc = " Spacer after wide character. Do not render."]
pub const SPACER_TAIL: Type = 2;
#[doc = " Spacer at end of soft-wrapped line for a wide character."]
pub const SPACER_HEAD: Type = 3;
#[doc = " Spacer at end of soft-wrapped line for a wide character."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod CellSemanticContent {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Regular output content, such as command output."]
pub const OUTPUT: Type = 0;
#[doc = " Content that is part of user input."]
pub const INPUT: Type = 1;
#[doc = " Content that is part of a shell prompt."]
pub const PROMPT: Type = 2;
#[doc = " Content that is part of a shell prompt."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod CellData {
#[doc = " Cell data types.\n\n These values specify what type of data to extract from a cell\n using `ghostty_cell_get`.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const INVALID: Type = 0;
#[doc = " The codepoint of the cell (0 if empty or bg-color-only).\n\n Output type: uint32_t *"]
pub const CODEPOINT: Type = 1;
#[doc = " The content tag describing what kind of content is in the cell.\n\n Output type: GhosttyCellContentTag *"]
pub const CONTENT_TAG: Type = 2;
#[doc = " The wide property of the cell.\n\n Output type: GhosttyCellWide *"]
pub const WIDE: Type = 3;
#[doc = " Whether the cell has text to render.\n\n Output type: bool *"]
pub const HAS_TEXT: Type = 4;
#[doc = " Whether the cell has non-default styling.\n\n Output type: bool *"]
pub const HAS_STYLING: Type = 5;
#[doc = " The style ID for the cell (for use with style lookups).\n\n Output type: uint16_t *"]
pub const STYLE_ID: Type = 6;
#[doc = " Whether the cell has a hyperlink.\n\n Output type: bool *"]
pub const HAS_HYPERLINK: Type = 7;
#[doc = " Whether the cell is protected.\n\n Output type: bool *"]
pub const PROTECTED: Type = 8;
#[doc = " The semantic content type of the cell (from OSC 133).\n\n Output type: GhosttyCellSemanticContent *"]
pub const 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 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 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 MAX_VALUE: Type = 2147483647;
}
pub mod RowSemanticPrompt {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " No prompt cells in this row."]
pub const NONE: Type = 0;
#[doc = " Prompt cells exist and this is a primary prompt line."]
pub const PROMPT: Type = 1;
#[doc = " Prompt cells exist and this is a continuation line."]
pub const PROMPT_CONTINUATION: Type = 2;
#[doc = " Prompt cells exist and this is a continuation line."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod RowData {
#[doc = " Row data types.\n\n These values specify what type of data to extract from a row\n using `ghostty_row_get`.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const INVALID: Type = 0;
#[doc = " Whether this row is soft-wrapped.\n\n Output type: bool *"]
pub const WRAP: Type = 1;
#[doc = " Whether this row is a continuation of a soft-wrapped row.\n\n Output type: bool *"]
pub const WRAP_CONTINUATION: Type = 2;
#[doc = " Whether any cells in this row have grapheme clusters.\n\n Output type: bool *"]
pub const GRAPHEME: Type = 3;
#[doc = " Whether any cells in this row have styling (may have false positives).\n\n Output type: bool *"]
pub const STYLED: Type = 4;
#[doc = " Whether any cells in this row have hyperlinks (may have false positives).\n\n Output type: bool *"]
pub const HYPERLINK: Type = 5;
#[doc = " The semantic prompt state of this row.\n\n Output type: GhosttyRowSemanticPrompt *"]
pub const SEMANTIC_PROMPT: Type = 6;
#[doc = " Whether this row contains a Kitty virtual placeholder.\n\n Output type: bool *"]
pub const KITTY_VIRTUAL_PLACEHOLDER: Type = 7;
#[doc = " Whether this row is dirty and requires a redraw.\n\n Output type: bool *"]
pub const DIRTY: Type = 8;
#[doc = " Whether this row is dirty and requires a redraw.\n\n Output type: bool *"]
pub const 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 data type is invalid\n"]
pub fn ghostty_cell_get(
cell: Cell,
data: CellData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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 documented output type)\n successfully written (may be NULL)\n"]
pub fn ghostty_cell_get_multi(
cell: Cell,
count: usize,
keys: *const CellData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::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 data type is invalid\n"]
pub fn ghostty_row_get(
row: Row,
data: RowData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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 documented output type)\n successfully written (may be NULL)\n"]
pub fn ghostty_row_get_multi(
row: Row,
count: usize,
keys: *const RowData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::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"]
pub type StyleId = u16;
pub mod StyleColorTag {
#[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"]
pub type Type = ::std::os::raw::c_uint;
pub const NONE: Type = 0;
pub const PALETTE: Type = 1;
pub const RGB: Type = 2;
pub const TAG_MAX_VALUE: Type = 2147483647;
}
#[doc = " Style color value union.\n\n Use the tag to determine which field is active.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union StyleColorValue {
pub palette: ColorPaletteIndex,
pub rgb: ColorRgb,
pub _padding: u64,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of StyleColorValue"][::std::mem::size_of::<StyleColorValue>() - 8usize];
["Alignment of StyleColorValue"][::std::mem::align_of::<StyleColorValue>() - 8usize];
["Offset of field: StyleColorValue::palette"]
[::std::mem::offset_of!(StyleColorValue, palette) - 0usize];
["Offset of field: StyleColorValue::rgb"]
[::std::mem::offset_of!(StyleColorValue, rgb) - 0usize];
["Offset of field: StyleColorValue::_padding"]
[::std::mem::offset_of!(StyleColorValue, _padding) - 0usize];
};
impl Default for StyleColorValue {
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"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct StyleColor {
pub tag: StyleColorTag::Type,
pub value: StyleColorValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of StyleColor"][::std::mem::size_of::<StyleColor>() - 16usize];
["Alignment of StyleColor"][::std::mem::align_of::<StyleColor>() - 8usize];
["Offset of field: StyleColor::tag"][::std::mem::offset_of!(StyleColor, tag) - 0usize];
["Offset of field: StyleColor::value"][::std::mem::offset_of!(StyleColor, value) - 8usize];
};
impl Default for StyleColor {
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"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Style {
pub size: usize,
pub fg_color: StyleColor,
pub bg_color: StyleColor,
pub underline_color: StyleColor,
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 Style"][::std::mem::size_of::<Style>() - 72usize];
["Alignment of Style"][::std::mem::align_of::<Style>() - 8usize];
["Offset of field: Style::size"][::std::mem::offset_of!(Style, size) - 0usize];
["Offset of field: Style::fg_color"][::std::mem::offset_of!(Style, fg_color) - 8usize];
["Offset of field: Style::bg_color"][::std::mem::offset_of!(Style, bg_color) - 24usize];
["Offset of field: Style::underline_color"]
[::std::mem::offset_of!(Style, underline_color) - 40usize];
["Offset of field: Style::bold"][::std::mem::offset_of!(Style, bold) - 56usize];
["Offset of field: Style::italic"][::std::mem::offset_of!(Style, italic) - 57usize];
["Offset of field: Style::faint"][::std::mem::offset_of!(Style, faint) - 58usize];
["Offset of field: Style::blink"][::std::mem::offset_of!(Style, blink) - 59usize];
["Offset of field: Style::inverse"][::std::mem::offset_of!(Style, inverse) - 60usize];
["Offset of field: Style::invisible"][::std::mem::offset_of!(Style, invisible) - 61usize];
["Offset of field: Style::strikethrough"]
[::std::mem::offset_of!(Style, strikethrough) - 62usize];
["Offset of field: Style::overline"][::std::mem::offset_of!(Style, overline) - 63usize];
["Offset of field: Style::underline"][::std::mem::offset_of!(Style, underline) - 64usize];
};
impl Default for Style {
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"]
pub fn ghostty_style_default(style: *mut Style);
}
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"]
pub fn ghostty_style_is_default(style: *const Style) -> 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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GridRef {
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 GridRef"][::std::mem::size_of::<GridRef>() - 24usize];
["Alignment of GridRef"][::std::mem::align_of::<GridRef>() - 8usize];
["Offset of field: GridRef::size"][::std::mem::offset_of!(GridRef, size) - 0usize];
["Offset of field: GridRef::node"][::std::mem::offset_of!(GridRef, node) - 8usize];
["Offset of field: GridRef::x"][::std::mem::offset_of!(GridRef, x) - 16usize];
["Offset of field: GridRef::y"][::std::mem::offset_of!(GridRef, y) - 18usize];
};
impl Default for GridRef {
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 node is NULL\n"]
pub fn ghostty_grid_ref_cell(ref_: *const GridRef, out_cell: *mut Cell) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Get the row from a grid reference.\n\n node is NULL\n"]
pub fn ghostty_grid_ref_row(ref_: *const GridRef, out_row: *mut Row) -> Result::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 GHOSTTY_OUT_OF_SPACE, the required buffer size in codepoints.\n node is NULL, GHOSTTY_OUT_OF_SPACE if the buffer is too small\n"]
pub fn ghostty_grid_ref_graphemes(
ref_: *const GridRef,
buf: *mut u32,
buf_len: usize,
out_len: *mut usize,
) -> Result::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 GHOSTTY_OUT_OF_SPACE, the required buffer size in bytes.\n node is NULL, GHOSTTY_OUT_OF_SPACE if the buffer is too small\n"]
pub fn ghostty_grid_ref_hyperlink_uri(
ref_: *const GridRef,
buf: *mut u8,
buf_len: usize,
out_len: *mut usize,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Get the style of the cell at the grid reference's position.\n\n node is NULL\n"]
pub fn ghostty_grid_ref_style(ref_: *const GridRef, out_style: *mut Style) -> Result::Type;
}
#[doc = " A coordinate in the terminal grid.\n"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct PointCoordinate {
#[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 PointCoordinate"][::std::mem::size_of::<PointCoordinate>() - 8usize];
["Alignment of PointCoordinate"][::std::mem::align_of::<PointCoordinate>() - 4usize];
["Offset of field: PointCoordinate::x"][::std::mem::offset_of!(PointCoordinate, x) - 0usize];
["Offset of field: PointCoordinate::y"][::std::mem::offset_of!(PointCoordinate, y) - 4usize];
};
pub mod PointTag {
#[doc = " Point reference tag.\n\n Determines which coordinate system a point uses.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Active area where the cursor can move."]
pub const ACTIVE: Type = 0;
#[doc = " Visible viewport (changes when scrolled)."]
pub const VIEWPORT: Type = 1;
#[doc = " Full screen including scrollback."]
pub const SCREEN: Type = 2;
#[doc = " Scrollback history only (before active area)."]
pub const HISTORY: Type = 3;
#[doc = " Scrollback history only (before active area)."]
pub const MAX_VALUE: Type = 2147483647;
}
#[doc = " Point value union.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union PointValue {
#[doc = " Coordinate (used for all tag variants)."]
pub coordinate: PointCoordinate,
#[doc = " Padding for ABI compatibility. Do not use."]
pub _padding: [u64; 2usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of PointValue"][::std::mem::size_of::<PointValue>() - 16usize];
["Alignment of PointValue"][::std::mem::align_of::<PointValue>() - 8usize];
["Offset of field: PointValue::coordinate"]
[::std::mem::offset_of!(PointValue, coordinate) - 0usize];
["Offset of field: PointValue::_padding"]
[::std::mem::offset_of!(PointValue, _padding) - 0usize];
};
impl Default for PointValue {
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"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Point {
pub tag: PointTag::Type,
pub value: PointValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of Point"][::std::mem::size_of::<Point>() - 24usize];
["Alignment of Point"][::std::mem::align_of::<Point>() - 8usize];
["Offset of field: Point::tag"][::std::mem::offset_of!(Point, tag) - 0usize];
["Offset of field: Point::value"][::std::mem::offset_of!(Point, value) - 8usize];
};
impl Default for Point {
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 SelectionGestureImpl {
_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"]
pub type SelectionGesture = *mut SelectionGestureImpl;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SelectionGestureEventImpl {
_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"]
pub type SelectionGestureEvent = *mut SelectionGestureEventImpl;
#[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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Selection {
#[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: GridRef,
#[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: GridRef,
#[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 Selection"][::std::mem::size_of::<Selection>() - 64usize];
["Alignment of Selection"][::std::mem::align_of::<Selection>() - 8usize];
["Offset of field: Selection::size"][::std::mem::offset_of!(Selection, size) - 0usize];
["Offset of field: Selection::start"][::std::mem::offset_of!(Selection, start) - 8usize];
["Offset of field: Selection::end"][::std::mem::offset_of!(Selection, end) - 32usize];
["Offset of field: Selection::rectangle"]
[::std::mem::offset_of!(Selection, rectangle) - 56usize];
};
impl Default for Selection {
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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TerminalSelectWordOptions {
#[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_: GridRef,
#[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 TerminalSelectWordOptions"]
[::std::mem::size_of::<TerminalSelectWordOptions>() - 48usize];
["Alignment of TerminalSelectWordOptions"]
[::std::mem::align_of::<TerminalSelectWordOptions>() - 8usize];
["Offset of field: TerminalSelectWordOptions::size"]
[::std::mem::offset_of!(TerminalSelectWordOptions, size) - 0usize];
["Offset of field: TerminalSelectWordOptions::ref_"]
[::std::mem::offset_of!(TerminalSelectWordOptions, ref_) - 8usize];
["Offset of field: TerminalSelectWordOptions::boundary_codepoints"]
[::std::mem::offset_of!(TerminalSelectWordOptions, boundary_codepoints) - 32usize];
["Offset of field: TerminalSelectWordOptions::boundary_codepoints_len"]
[::std::mem::offset_of!(TerminalSelectWordOptions, boundary_codepoints_len) - 40usize];
};
impl Default for TerminalSelectWordOptions {
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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TerminalSelectWordBetweenOptions {
#[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: GridRef,
#[doc = " Ending grid reference for the inclusive search range."]
pub end: GridRef,
#[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 TerminalSelectWordBetweenOptions"]
[::std::mem::size_of::<TerminalSelectWordBetweenOptions>() - 72usize];
["Alignment of TerminalSelectWordBetweenOptions"]
[::std::mem::align_of::<TerminalSelectWordBetweenOptions>() - 8usize];
["Offset of field: TerminalSelectWordBetweenOptions::size"]
[::std::mem::offset_of!(TerminalSelectWordBetweenOptions, size) - 0usize];
["Offset of field: TerminalSelectWordBetweenOptions::start"]
[::std::mem::offset_of!(TerminalSelectWordBetweenOptions, start) - 8usize];
["Offset of field: TerminalSelectWordBetweenOptions::end"]
[::std::mem::offset_of!(TerminalSelectWordBetweenOptions, end) - 32usize];
["Offset of field: TerminalSelectWordBetweenOptions::boundary_codepoints"]
[::std::mem::offset_of!(TerminalSelectWordBetweenOptions, boundary_codepoints) - 56usize];
["Offset of field: TerminalSelectWordBetweenOptions::boundary_codepoints_len"][::std::mem::offset_of!(
TerminalSelectWordBetweenOptions,
boundary_codepoints_len
) - 64usize];
};
impl Default for TerminalSelectWordBetweenOptions {
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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TerminalSelectLineOptions {
#[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_: GridRef,
#[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 TerminalSelectLineOptions"]
[::std::mem::size_of::<TerminalSelectLineOptions>() - 56usize];
["Alignment of TerminalSelectLineOptions"]
[::std::mem::align_of::<TerminalSelectLineOptions>() - 8usize];
["Offset of field: TerminalSelectLineOptions::size"]
[::std::mem::offset_of!(TerminalSelectLineOptions, size) - 0usize];
["Offset of field: TerminalSelectLineOptions::ref_"]
[::std::mem::offset_of!(TerminalSelectLineOptions, ref_) - 8usize];
["Offset of field: TerminalSelectLineOptions::whitespace"]
[::std::mem::offset_of!(TerminalSelectLineOptions, whitespace) - 32usize];
["Offset of field: TerminalSelectLineOptions::whitespace_len"]
[::std::mem::offset_of!(TerminalSelectLineOptions, whitespace_len) - 40usize];
["Offset of field: TerminalSelectLineOptions::semantic_prompt_boundary"]
[::std::mem::offset_of!(TerminalSelectLineOptions, semantic_prompt_boundary) - 48usize];
};
impl Default for TerminalSelectLineOptions {
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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TerminalSelectionFormatOptions {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectionFormatOptions)."]
pub size: usize,
#[doc = " Output format to emit."]
pub emit: FormatterFormat::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 Selection,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of TerminalSelectionFormatOptions"]
[::std::mem::size_of::<TerminalSelectionFormatOptions>() - 24usize];
["Alignment of TerminalSelectionFormatOptions"]
[::std::mem::align_of::<TerminalSelectionFormatOptions>() - 8usize];
["Offset of field: TerminalSelectionFormatOptions::size"]
[::std::mem::offset_of!(TerminalSelectionFormatOptions, size) - 0usize];
["Offset of field: TerminalSelectionFormatOptions::emit"]
[::std::mem::offset_of!(TerminalSelectionFormatOptions, emit) - 8usize];
["Offset of field: TerminalSelectionFormatOptions::unwrap"]
[::std::mem::offset_of!(TerminalSelectionFormatOptions, unwrap) - 12usize];
["Offset of field: TerminalSelectionFormatOptions::trim"]
[::std::mem::offset_of!(TerminalSelectionFormatOptions, trim) - 13usize];
["Offset of field: TerminalSelectionFormatOptions::selection"]
[::std::mem::offset_of!(TerminalSelectionFormatOptions, selection) - 16usize];
};
impl Default for TerminalSelectionFormatOptions {
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 SelectionOrder {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Start is before end in top-left to bottom-right order."]
pub const FORWARD: Type = 0;
#[doc = " End is before start in top-left to bottom-right order."]
pub const REVERSE: Type = 1;
#[doc = " Rectangular selection from top-right to bottom-left."]
pub const MIRRORED_FORWARD: Type = 2;
#[doc = " Rectangular selection from bottom-left to top-right."]
pub const MIRRORED_REVERSE: Type = 3;
#[doc = " Rectangular selection from bottom-left to top-right."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod SelectionAdjust {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Move left to the previous non-empty cell, wrapping upward."]
pub const LEFT: Type = 0;
#[doc = " Move right to the next non-empty cell, wrapping downward."]
pub const 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 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 DOWN: Type = 3;
#[doc = " Move to the top-left cell of the screen."]
pub const HOME: Type = 4;
#[doc = " Move to the right edge of the last non-blank row on the screen."]
pub const END: Type = 5;
#[doc = " Move up by one terminal page height, or to home if that would move\n past the top."]
pub const 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 PAGE_DOWN: Type = 7;
#[doc = " Move to the left edge of the current line."]
pub const BEGINNING_OF_LINE: Type = 8;
#[doc = " Move to the right edge of the current line."]
pub const END_OF_LINE: Type = 9;
#[doc = " Move to the right edge of the current line."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod SelectionGestureBehavior {
#[doc = " Selection behavior chosen for a gesture's click sequence.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Cell-granular drag selection."]
pub const CELL: Type = 0;
#[doc = " Word selection on press and word-granular drag selection."]
pub const WORD: Type = 1;
#[doc = " Line selection on press and line-granular drag selection."]
pub const LINE: Type = 2;
#[doc = " Semantic command output selection on press and drag."]
pub const OUTPUT: Type = 3;
#[doc = " Semantic command output selection on press and drag."]
pub const MAX_VALUE: Type = 2147483647;
}
#[doc = " Selection behaviors for single-, double-, and triple-click gestures.\n"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SelectionGestureBehaviors {
#[doc = " Behavior for single-click selection gestures."]
pub single_click: SelectionGestureBehavior::Type,
#[doc = " Behavior for double-click selection gestures."]
pub double_click: SelectionGestureBehavior::Type,
#[doc = " Behavior for triple-click selection gestures."]
pub triple_click: SelectionGestureBehavior::Type,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of SelectionGestureBehaviors"]
[::std::mem::size_of::<SelectionGestureBehaviors>() - 12usize];
["Alignment of SelectionGestureBehaviors"]
[::std::mem::align_of::<SelectionGestureBehaviors>() - 4usize];
["Offset of field: SelectionGestureBehaviors::single_click"]
[::std::mem::offset_of!(SelectionGestureBehaviors, single_click) - 0usize];
["Offset of field: SelectionGestureBehaviors::double_click"]
[::std::mem::offset_of!(SelectionGestureBehaviors, double_click) - 4usize];
["Offset of field: SelectionGestureBehaviors::triple_click"]
[::std::mem::offset_of!(SelectionGestureBehaviors, triple_click) - 8usize];
};
impl Default for SelectionGestureBehaviors {
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"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct SelectionGestureGeometry {
#[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 SelectionGestureGeometry"]
[::std::mem::size_of::<SelectionGestureGeometry>() - 16usize];
["Alignment of SelectionGestureGeometry"]
[::std::mem::align_of::<SelectionGestureGeometry>() - 4usize];
["Offset of field: SelectionGestureGeometry::columns"]
[::std::mem::offset_of!(SelectionGestureGeometry, columns) - 0usize];
["Offset of field: SelectionGestureGeometry::cell_width"]
[::std::mem::offset_of!(SelectionGestureGeometry, cell_width) - 4usize];
["Offset of field: SelectionGestureGeometry::padding_left"]
[::std::mem::offset_of!(SelectionGestureGeometry, padding_left) - 8usize];
["Offset of field: SelectionGestureGeometry::screen_height"]
[::std::mem::offset_of!(SelectionGestureGeometry, screen_height) - 12usize];
};
pub mod SelectionGestureAutoscroll {
#[doc = " Current autoscroll direction for an active selection drag gesture.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " No selection autoscroll is requested."]
pub const NONE: Type = 0;
#[doc = " Selection dragging should autoscroll the viewport upward."]
pub const UP: Type = 1;
#[doc = " Selection dragging should autoscroll the viewport downward."]
pub const DOWN: Type = 2;
#[doc = " Selection dragging should autoscroll the viewport downward."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod SelectionGestureData {
#[doc = " Data fields readable from a selection gesture with\n ghostty_selection_gesture_get().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Current click count: uint8_t*. 0 means inactive."]
pub const CLICK_COUNT: Type = 0;
#[doc = " Whether the current/last left-click gesture has dragged: bool*."]
pub const DRAGGED: Type = 1;
#[doc = " Current autoscroll request: GhosttySelectionGestureAutoscroll*."]
pub const AUTOSCROLL: Type = 2;
#[doc = " Current gesture behavior: GhosttySelectionGestureBehavior*."]
pub const 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 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 MAX_VALUE: Type = 2147483647;
}
pub mod SelectionGestureEventType {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Press event for ghostty_selection_gesture_event()."]
pub const PRESS: Type = 0;
#[doc = " Release event for ghostty_selection_gesture_event()."]
pub const RELEASE: Type = 1;
#[doc = " Drag event for ghostty_selection_gesture_event()."]
pub const DRAG: Type = 2;
#[doc = " Autoscroll tick event for ghostty_selection_gesture_event()."]
pub const AUTOSCROLL_TICK: Type = 3;
#[doc = " Deep press event for ghostty_selection_gesture_event()."]
pub const DEEP_PRESS: Type = 4;
#[doc = " Deep press event for ghostty_selection_gesture_event()."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod SelectionGestureEventOption {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[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 REF: Type = 0;
#[doc = " Surface-space pointer position: GhosttySurfacePosition*.\n\n Valid for PRESS, DRAG, and AUTOSCROLL_TICK."]
pub const POSITION: Type = 1;
#[doc = " Maximum repeat-click distance in pixels: double*."]
pub const 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 TIME_NS: Type = 3;
#[doc = " Maximum interval between repeat clicks in nanoseconds: uint64_t*."]
pub const 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 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 BEHAVIORS: Type = 6;
#[doc = " Whether a drag or autoscroll tick should produce a rectangular selection: bool*."]
pub const RECTANGLE: Type = 7;
#[doc = " Drag display geometry: GhosttySelectionGestureGeometry*. Required for DRAG and AUTOSCROLL_TICK."]
pub const GEOMETRY: Type = 8;
#[doc = " Viewport coordinate for an autoscroll tick: GhosttyPointCoordinate*. Required for AUTOSCROLL_TICK."]
pub const VIEWPORT: Type = 9;
#[doc = " Viewport coordinate for an autoscroll tick: GhosttyPointCoordinate*. Required for AUTOSCROLL_TICK."]
pub const MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a reusable selection gesture event object.\n\n NULL or type is invalid, or GHOSTTY_OUT_OF_MEMORY if allocation fails\n"]
pub fn ghostty_selection_gesture_event_new(
allocator: *const Allocator,
out_event: *mut SelectionGestureEvent,
type_: SelectionGestureEventType::Type,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Free a selection gesture event object.\n\n Passing NULL is allowed and is a no-op.\n\n"]
pub fn ghostty_selection_gesture_event_free(event: SelectionGestureEvent);
}
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 event-owned data fails, or GHOSTTY_INVALID_VALUE if event, option, or\n value is invalid\n"]
pub fn ghostty_selection_gesture_event_set(
event: SelectionGestureEvent,
option: SelectionGestureEventOption::Type,
value: *const ::std::os::raw::c_void,
) -> Result::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 be NULL to apply the event and discard the selection result.\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"]
pub fn ghostty_selection_gesture_event(
gesture: SelectionGesture,
terminal: Terminal,
event: SelectionGestureEvent,
out_selection: *mut Selection,
) -> Result::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 NULL, or GHOSTTY_OUT_OF_MEMORY if allocation fails\n"]
pub fn ghostty_selection_gesture_new(
allocator: *const Allocator,
out_gesture: *mut SelectionGesture,
) -> Result::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 the terminal has already been freed\n"]
pub fn ghostty_selection_gesture_free(gesture: SelectionGesture, terminal: Terminal);
}
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"]
pub fn ghostty_selection_gesture_reset(gesture: SelectionGesture, terminal: Terminal);
}
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 has no value, or GHOSTTY_INVALID_VALUE if gesture, terminal, data, or\n value is invalid\n"]
pub fn ghostty_selection_gesture_get(
gesture: SelectionGesture,
terminal: Terminal,
data: SelectionGestureData::Type,
value: *mut ::std::os::raw::c_void,
) -> Result::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 field has no value, or GHOSTTY_INVALID_VALUE if gesture, terminal,\n keys, values, or a value pointer is invalid\n"]
pub fn ghostty_selection_gesture_get_multi(
gesture: SelectionGesture,
terminal: Terminal,
count: usize,
keys: *const SelectionGestureData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::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 no selectable word content, or GHOSTTY_INVALID_VALUE if the\n terminal, options, ref, codepoint pointer, or output pointer are\n invalid.\n"]
pub fn ghostty_terminal_select_word(
terminal: Terminal,
options: *const TerminalSelectWordOptions,
out_selection: *mut Selection,
) -> Result::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\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 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"]
pub fn ghostty_terminal_select_word_between(
terminal: Terminal,
options: *const TerminalSelectWordBetweenOptions,
out_selection: *mut Selection,
) -> Result::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 no selectable line content, or GHOSTTY_INVALID_VALUE if the\n terminal, options, ref, codepoint pointer, or output pointer are\n invalid.\n"]
pub fn ghostty_terminal_select_line(
terminal: Terminal,
options: *const TerminalSelectLineOptions,
out_selection: *mut Selection,
) -> Result::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 selectable content, or GHOSTTY_INVALID_VALUE if the terminal or\n output pointer is invalid.\n"]
pub fn ghostty_terminal_select_all(
terminal: Terminal,
out_selection: *mut Selection,
) -> Result::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 not selectable command output, or GHOSTTY_INVALID_VALUE if the\n terminal, ref, or output pointer is invalid.\n"]
pub fn ghostty_terminal_select_output(
terminal: Terminal,
ref_: GridRef,
out_selection: *mut Selection,
) -> Result::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 GHOSTTY_OUT_OF_SPACE (must not be NULL)\n"]
pub fn ghostty_terminal_selection_format_buf(
terminal: Terminal,
options: TerminalSelectionFormatOptions,
buf: *mut u8,
buf_len: usize,
out_written: *mut usize,
) -> Result::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\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"]
pub fn ghostty_terminal_selection_format_alloc(
terminal: Terminal,
allocator: *const Allocator,
options: TerminalSelectionFormatOptions,
out_ptr: *mut *mut u8,
out_len: *mut usize,
) -> Result::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 selection, or adjustment are invalid. Selection reference validity\n is a precondition and is not checked.\n"]
pub fn ghostty_terminal_selection_adjust(
terminal: Terminal,
selection: *mut Selection,
adjustment: SelectionAdjust::Type,
) -> Result::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 selection, or output pointer are invalid. Selection reference\n validity is a precondition and is not checked.\n"]
pub fn ghostty_terminal_selection_order(
terminal: Terminal,
selection: *const Selection,
out_order: *mut SelectionOrder::Type,
) -> Result::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 selection, desired order, or output pointer are invalid. Selection\n reference validity is a precondition and is not checked.\n"]
pub fn ghostty_terminal_selection_ordered(
terminal: Terminal,
selection: *const Selection,
desired: SelectionOrder::Type,
out_selection: *mut Selection,
) -> Result::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 selection, point, or output pointer are invalid. Selection reference\n validity is a precondition and is not checked.\n"]
pub fn ghostty_terminal_selection_contains(
terminal: Terminal,
selection: *const Selection,
point: Point,
out_contains: *mut bool,
) -> Result::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 selections, or output pointer are invalid. Selection reference\n validity is a precondition and is not checked.\n"]
pub fn ghostty_terminal_selection_equal(
terminal: Terminal,
a: *const Selection,
b: *const Selection,
out_equal: *mut bool,
) -> Result::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 Mode = u16;
pub mod ModeReportState {
#[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_uint;
#[doc = " Mode is not recognized"]
pub const NOT_RECOGNIZED: Type = 0;
#[doc = " Mode is set (enabled)"]
pub const SET: Type = 1;
#[doc = " Mode is reset (disabled)"]
pub const RESET: Type = 2;
#[doc = " Mode is permanently set"]
pub const PERMANENTLY_SET: Type = 3;
#[doc = " Mode is permanently reset"]
pub const PERMANENTLY_RESET: Type = 4;
#[doc = " Mode is permanently reset"]
pub const 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 GHOSTTY_OUT_OF_SPACE, the required buffer size.\n is too small"]
pub fn ghostty_mode_report_encode(
mode: Mode,
state: ModeReportState::Type,
buf: *mut ::std::os::raw::c_char,
buf_len: usize,
out_written: *mut usize,
) -> Result::Type;
}
pub mod SizeReportStyle {
#[doc = " Size report style.\n\n Determines the output format for the terminal size report."]
pub type Type = ::std::os::raw::c_uint;
#[doc = " In-band size report (mode 2048): ESC [ 48 ; rows ; cols ; height ; width t"]
pub const MODE_2048: Type = 0;
#[doc = " XTWINOPS text area size in pixels: ESC [ 4 ; height ; width t"]
pub const CSI_14_T: Type = 1;
#[doc = " XTWINOPS cell size in pixels: ESC [ 6 ; height ; width t"]
pub const CSI_16_T: Type = 2;
#[doc = " XTWINOPS text area size in characters: ESC [ 8 ; rows ; cols t"]
pub const CSI_18_T: Type = 3;
#[doc = " XTWINOPS text area size in characters: ESC [ 8 ; rows ; cols t"]
pub const STYLE_MAX_VALUE: Type = 2147483647;
}
#[doc = " Terminal size information for encoding size reports."]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct SizeReportSize {
#[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 SizeReportSize"][::std::mem::size_of::<SizeReportSize>() - 12usize];
["Alignment of SizeReportSize"][::std::mem::align_of::<SizeReportSize>() - 4usize];
["Offset of field: SizeReportSize::rows"]
[::std::mem::offset_of!(SizeReportSize, rows) - 0usize];
["Offset of field: SizeReportSize::columns"]
[::std::mem::offset_of!(SizeReportSize, columns) - 2usize];
["Offset of field: SizeReportSize::cell_width"]
[::std::mem::offset_of!(SizeReportSize, cell_width) - 4usize];
["Offset of field: SizeReportSize::cell_height"]
[::std::mem::offset_of!(SizeReportSize, 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 GHOSTTY_OUT_OF_SPACE, the required buffer size.\n is too small"]
pub fn ghostty_size_report_encode(
style: SizeReportStyle::Type,
size: SizeReportSize,
buf: *mut ::std::os::raw::c_char,
buf_len: usize,
out_written: *mut usize,
) -> Result::Type;
}
pub mod KittyGraphicsData {
#[doc = " Queryable data kinds for ghostty_kitty_graphics_get().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid / sentinel value."]
pub const 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 PLACEMENT_ITERATOR: Type = 1;
#[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 MAX_VALUE: Type = 2147483647;
}
pub mod KittyGraphicsPlacementData {
#[doc = " Queryable data kinds for ghostty_kitty_graphics_placement_get().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid / sentinel value."]
pub const INVALID: Type = 0;
#[doc = " The image ID this placement belongs to.\n\n Output type: uint32_t *"]
pub const IMAGE_ID: Type = 1;
#[doc = " The placement ID.\n\n Output type: uint32_t *"]
pub const PLACEMENT_ID: Type = 2;
#[doc = " Whether this is a virtual placement (unicode placeholder).\n\n Output type: bool *"]
pub const IS_VIRTUAL: Type = 3;
#[doc = " Pixel offset from the left edge of the cell.\n\n Output type: uint32_t *"]
pub const X_OFFSET: Type = 4;
#[doc = " Pixel offset from the top edge of the cell.\n\n Output type: uint32_t *"]
pub const Y_OFFSET: Type = 5;
#[doc = " Source rectangle x origin in pixels.\n\n Output type: uint32_t *"]
pub const SOURCE_X: Type = 6;
#[doc = " Source rectangle y origin in pixels.\n\n Output type: uint32_t *"]
pub const SOURCE_Y: Type = 7;
#[doc = " Source rectangle width in pixels (0 = full image width).\n\n Output type: uint32_t *"]
pub const SOURCE_WIDTH: Type = 8;
#[doc = " Source rectangle height in pixels (0 = full image height).\n\n Output type: uint32_t *"]
pub const SOURCE_HEIGHT: Type = 9;
#[doc = " Number of columns this placement occupies.\n\n Output type: uint32_t *"]
pub const COLUMNS: Type = 10;
#[doc = " Number of rows this placement occupies.\n\n Output type: uint32_t *"]
pub const ROWS: Type = 11;
#[doc = " Z-index for this placement.\n\n Output type: int32_t *"]
pub const Z: Type = 12;
#[doc = " Z-index for this placement.\n\n Output type: int32_t *"]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod KittyPlacementLayer {
#[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"]
pub type Type = ::std::os::raw::c_uint;
pub const ALL: Type = 0;
pub const BELOW_BG: Type = 1;
pub const BELOW_TEXT: Type = 2;
pub const ABOVE_TEXT: Type = 3;
pub const MAX_VALUE: Type = 2147483647;
}
pub mod KittyGraphicsPlacementIteratorOption {
#[doc = " Settable options for ghostty_kitty_graphics_placement_iterator_set().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Set the z-layer filter for the iterator.\n\n Input type: GhosttyKittyPlacementLayer *"]
pub const LAYER: Type = 0;
#[doc = " Set the z-layer filter for the iterator.\n\n Input type: GhosttyKittyPlacementLayer *"]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod KittyImageFormat {
#[doc = " Pixel format of a Kitty graphics image.\n"]
pub type Type = ::std::os::raw::c_uint;
pub const RGB: Type = 0;
pub const RGBA: Type = 1;
pub const PNG: Type = 2;
pub const GRAY_ALPHA: Type = 3;
pub const GRAY: Type = 4;
pub const MAX_VALUE: Type = 2147483647;
}
pub mod KittyImageCompression {
#[doc = " Compression of a Kitty graphics image.\n"]
pub type Type = ::std::os::raw::c_uint;
pub const NONE: Type = 0;
pub const ZLIB_DEFLATE: Type = 1;
pub const MAX_VALUE: Type = 2147483647;
}
pub mod KittyGraphicsImageData {
#[doc = " Queryable data kinds for ghostty_kitty_graphics_image_get().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid / sentinel value."]
pub const INVALID: Type = 0;
#[doc = " The image ID.\n\n Output type: uint32_t *"]
pub const ID: Type = 1;
#[doc = " The image number.\n\n Output type: uint32_t *"]
pub const NUMBER: Type = 2;
#[doc = " Image width in pixels.\n\n Output type: uint32_t *"]
pub const WIDTH: Type = 3;
#[doc = " Image height in pixels.\n\n Output type: uint32_t *"]
pub const HEIGHT: Type = 4;
#[doc = " Pixel format of the image.\n\n Output type: GhosttyKittyImageFormat *"]
pub const FORMAT: Type = 5;
#[doc = " Compression of the image.\n\n Output type: GhosttyKittyImageCompression *"]
pub const COMPRESSION: Type = 6;
#[doc = " Borrowed pointer to the raw pixel data. Valid as long as the\n underlying terminal is not mutated.\n\n Output type: const uint8_t **"]
pub const DATA_PTR: Type = 7;
#[doc = " Length of the raw pixel data in bytes.\n\n Output type: size_t *"]
pub const DATA_LEN: Type = 8;
#[doc = " Length of the raw pixel data in bytes.\n\n Output type: size_t *"]
pub const 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"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct KittyGraphicsPlacementRenderInfo {
#[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 KittyGraphicsPlacementRenderInfo"]
[::std::mem::size_of::<KittyGraphicsPlacementRenderInfo>() - 56usize];
["Alignment of KittyGraphicsPlacementRenderInfo"]
[::std::mem::align_of::<KittyGraphicsPlacementRenderInfo>() - 8usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::size"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, size) - 0usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::pixel_width"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, pixel_width) - 8usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::pixel_height"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, pixel_height) - 12usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::grid_cols"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, grid_cols) - 16usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::grid_rows"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, grid_rows) - 20usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::viewport_col"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, viewport_col) - 24usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::viewport_row"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, viewport_row) - 28usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::viewport_visible"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, viewport_visible) - 32usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::source_x"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, source_x) - 36usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::source_y"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, source_y) - 40usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::source_width"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, source_width) - 44usize];
["Offset of field: KittyGraphicsPlacementRenderInfo::source_height"]
[::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, 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"]
pub fn ghostty_kitty_graphics_get(
graphics: KittyGraphics,
data: KittyGraphicsData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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"]
pub fn ghostty_kitty_graphics_image(
graphics: KittyGraphics,
image_id: u32,
) -> KittyGraphicsImage;
}
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"]
pub fn ghostty_kitty_graphics_image_get(
image: KittyGraphicsImage,
data: KittyGraphicsImageData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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 documented output type)\n successfully written (may be NULL)\n"]
pub fn ghostty_kitty_graphics_image_get_multi(
image: KittyGraphicsImage,
count: usize,
keys: *const KittyGraphicsImageData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::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 failure\n"]
pub fn ghostty_kitty_graphics_placement_iterator_new(
allocator: *const Allocator,
out_iterator: *mut KittyGraphicsPlacementIterator,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Free a placement iterator.\n\n"]
pub fn ghostty_kitty_graphics_placement_iterator_free(iterator: KittyGraphicsPlacementIterator);
}
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 GHOSTTY_INVALID_VALUE)\n"]
pub fn ghostty_kitty_graphics_placement_iterator_set(
iterator: KittyGraphicsPlacementIterator,
option: KittyGraphicsPlacementIteratorOption::Type,
value: *const ::std::os::raw::c_void,
) -> Result::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"]
pub fn ghostty_kitty_graphics_placement_next(iterator: KittyGraphicsPlacementIterator) -> 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 iterator is NULL or not positioned on a placement\n"]
pub fn ghostty_kitty_graphics_placement_get(
iterator: KittyGraphicsPlacementIterator,
data: KittyGraphicsPlacementData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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 documented output type)\n successfully written (may be NULL)\n"]
pub fn ghostty_kitty_graphics_placement_get_multi(
iterator: KittyGraphicsPlacementIterator,
count: usize,
keys: *const KittyGraphicsPlacementData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::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 as a selection with rectangle=true\n is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE for\n virtual placements or when Kitty graphics are disabled\n"]
pub fn ghostty_kitty_graphics_placement_rect(
iterator: KittyGraphicsPlacementIterator,
image: KittyGraphicsImage,
terminal: Terminal,
out_selection: *mut Selection,
) -> Result::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 is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE when\n Kitty graphics are disabled\n"]
pub fn ghostty_kitty_graphics_placement_pixel_size(
iterator: KittyGraphicsPlacementIterator,
image: KittyGraphicsImage,
terminal: Terminal,
out_width: *mut u32,
out_height: *mut u32,
) -> Result::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 is NULL or the iterator is not positioned, GHOSTTY_NO_VALUE when\n Kitty graphics are disabled\n"]
pub fn ghostty_kitty_graphics_placement_grid_size(
iterator: KittyGraphicsPlacementIterator,
image: KittyGraphicsImage,
terminal: Terminal,
out_cols: *mut u32,
out_rows: *mut u32,
) -> Result::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 (may be negative for partially visible placements)\n off-screen or virtual, GHOSTTY_INVALID_VALUE if any handle\n is NULL or the iterator is not positioned\n"]
pub fn ghostty_kitty_graphics_placement_viewport_pos(
iterator: KittyGraphicsPlacementIterator,
image: KittyGraphicsImage,
terminal: Terminal,
out_col: *mut i32,
out_row: *mut i32,
) -> Result::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 handle is NULL or the iterator is not positioned\n"]
pub fn ghostty_kitty_graphics_placement_source_rect(
iterator: KittyGraphicsPlacementIterator,
image: KittyGraphicsImage,
out_x: *mut u32,
out_y: *mut u32,
out_width: *mut u32,
out_height: *mut u32,
) -> Result::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"]
pub fn ghostty_kitty_graphics_placement_render_info(
iterator: KittyGraphicsPlacementIterator,
image: KittyGraphicsImage,
terminal: Terminal,
out_info: *mut KittyGraphicsPlacementRenderInfo,
) -> Result::Type;
}
#[doc = " Terminal initialization options.\n"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct TerminalOptions {
#[doc = " Terminal width in cells. Must be greater than zero."]
pub cols: u16,
#[doc = " Terminal height in cells. Must be greater than zero."]
pub rows: u16,
#[doc = " Maximum number of lines to keep in scrollback history."]
pub max_scrollback: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of TerminalOptions"][::std::mem::size_of::<TerminalOptions>() - 16usize];
["Alignment of TerminalOptions"][::std::mem::align_of::<TerminalOptions>() - 8usize];
["Offset of field: TerminalOptions::cols"]
[::std::mem::offset_of!(TerminalOptions, cols) - 0usize];
["Offset of field: TerminalOptions::rows"]
[::std::mem::offset_of!(TerminalOptions, rows) - 2usize];
["Offset of field: TerminalOptions::max_scrollback"]
[::std::mem::offset_of!(TerminalOptions, max_scrollback) - 8usize];
};
pub mod TerminalScrollViewportTag {
#[doc = " Scroll viewport behavior tag.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Scroll to the top of the scrollback."]
pub const TOP: Type = 0;
#[doc = " Scroll to the bottom (active area)."]
pub const BOTTOM: Type = 1;
#[doc = " Scroll by a delta amount (up is negative)."]
pub const DELTA: Type = 2;
#[doc = " Scroll by a delta amount (up is negative)."]
pub const MAX_VALUE: Type = 2147483647;
}
#[doc = " Scroll viewport value.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union TerminalScrollViewportValue {
#[doc = " Scroll delta (only used with GHOSTTY_SCROLL_VIEWPORT_DELTA). Up is negative."]
pub delta: isize,
#[doc = " Padding for ABI compatibility. Do not use."]
pub _padding: [u64; 2usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of TerminalScrollViewportValue"]
[::std::mem::size_of::<TerminalScrollViewportValue>() - 16usize];
["Alignment of TerminalScrollViewportValue"]
[::std::mem::align_of::<TerminalScrollViewportValue>() - 8usize];
["Offset of field: TerminalScrollViewportValue::delta"]
[::std::mem::offset_of!(TerminalScrollViewportValue, delta) - 0usize];
["Offset of field: TerminalScrollViewportValue::_padding"]
[::std::mem::offset_of!(TerminalScrollViewportValue, _padding) - 0usize];
};
impl Default for TerminalScrollViewportValue {
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"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct TerminalScrollViewport {
pub tag: TerminalScrollViewportTag::Type,
pub value: TerminalScrollViewportValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of TerminalScrollViewport"][::std::mem::size_of::<TerminalScrollViewport>() - 24usize];
["Alignment of TerminalScrollViewport"]
[::std::mem::align_of::<TerminalScrollViewport>() - 8usize];
["Offset of field: TerminalScrollViewport::tag"]
[::std::mem::offset_of!(TerminalScrollViewport, tag) - 0usize];
["Offset of field: TerminalScrollViewport::value"]
[::std::mem::offset_of!(TerminalScrollViewport, value) - 8usize];
};
impl Default for TerminalScrollViewport {
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 TerminalScreen {
#[doc = " Terminal screen identifier.\n\n Identifies which screen buffer is active in the terminal.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " The primary (normal) screen."]
pub const PRIMARY: Type = 0;
#[doc = " The alternate screen."]
pub const ALTERNATE: Type = 1;
#[doc = " The alternate screen."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod TerminalCursorStyle {
#[doc = " Visual style of the terminal cursor.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Bar cursor (DECSCUSR 5, 6)."]
pub const BAR: Type = 0;
#[doc = " Block cursor (DECSCUSR 1, 2)."]
pub const BLOCK: Type = 1;
#[doc = " Underline cursor (DECSCUSR 3, 4)."]
pub const UNDERLINE: Type = 2;
#[doc = " Hollow block cursor."]
pub const BLOCK_HOLLOW: Type = 3;
#[doc = " Hollow block cursor."]
pub const MAX_VALUE: Type = 2147483647;
}
#[doc = " Scrollbar state for the terminal viewport.\n\n Represents the scrollable area dimensions needed to render a scrollbar.\n"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct TerminalScrollbar {
#[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 TerminalScrollbar"][::std::mem::size_of::<TerminalScrollbar>() - 24usize];
["Alignment of TerminalScrollbar"][::std::mem::align_of::<TerminalScrollbar>() - 8usize];
["Offset of field: TerminalScrollbar::total"]
[::std::mem::offset_of!(TerminalScrollbar, total) - 0usize];
["Offset of field: TerminalScrollbar::offset"]
[::std::mem::offset_of!(TerminalScrollbar, offset) - 8usize];
["Offset of field: TerminalScrollbar::len"]
[::std::mem::offset_of!(TerminalScrollbar, len) - 16usize];
};
#[doc = " Callback function type for bell.\n\n Called when the terminal receives a BEL character (0x07).\n\n"]
pub type TerminalBellFn = ::std::option::Option<
unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void),
>;
#[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"]
pub type TerminalColorSchemeFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: Terminal,
userdata: *mut ::std::os::raw::c_void,
out_scheme: *mut ColorScheme::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"]
pub type TerminalDeviceAttributesFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: Terminal,
userdata: *mut ::std::os::raw::c_void,
out_attrs: *mut DeviceAttributes,
) -> 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"]
pub type TerminalEnquiryFn = ::std::option::Option<
unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void) -> String,
>;
#[doc = " Callback function type for size queries (XTWINOPS).\n\n Called in response to XTWINOPS size queries (CSI 14/16/18 t).\n Return true and fill *out_size with the current terminal geometry,\n or return false to silently ignore the query.\n\n"]
pub type TerminalSizeFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: Terminal,
userdata: *mut ::std::os::raw::c_void,
out_size: *mut SizeReportSize,
) -> 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"]
pub type TerminalTitleChangedFn = ::std::option::Option<
unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void),
>;
#[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"]
pub type TerminalPwdChangedFn = ::std::option::Option<
unsafe extern "C" fn(terminal: Terminal, 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 or mode query. The\n data is only valid for the duration of the call; callers must copy\n it if it needs to persist.\n\n"]
pub type TerminalWritePtyFn = ::std::option::Option<
unsafe extern "C" fn(
terminal: Terminal,
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"]
pub type TerminalXtversionFn = ::std::option::Option<
unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void) -> String,
>;
pub mod TerminalOption {
#[doc = " Terminal option identifiers.\n\n These values are used with ghostty_terminal_set() to configure\n terminal callbacks and associated state.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Opaque userdata pointer passed to all callbacks.\n\n Input type: void*"]
pub const 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 or device\n status report). Set to NULL to ignore such sequences.\n\n Input type: GhosttyTerminalWritePtyFn"]
pub const 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 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 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 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 TITLE_CHANGED: Type = 5;
#[doc = " Callback invoked in response to XTWINOPS size queries\n (CSI 14/16/18 t). Set to NULL to silently ignore size queries.\n\n Input type: GhosttyTerminalSizeFn"]
pub const 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 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 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 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 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 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 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 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 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 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 KITTY_IMAGE_MEDIUM_FILE: Type = 16;
#[doc = " Enable or disable Kitty image loading via the temporary 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 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 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 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 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 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 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 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 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 PWD_CHANGED: Type = 25;
#[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 MAX_VALUE: Type = 2147483647;
}
pub mod TerminalData {
#[doc = " Terminal data types.\n\n These values specify what type of data to extract from a terminal\n using `ghostty_terminal_get`.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const INVALID: Type = 0;
#[doc = " Terminal width in cells.\n\n Output type: uint16_t *"]
pub const COLS: Type = 1;
#[doc = " Terminal height in cells.\n\n Output type: uint16_t *"]
pub const ROWS: Type = 2;
#[doc = " Cursor column position (0-indexed).\n\n Output type: uint16_t *"]
pub const CURSOR_X: Type = 3;
#[doc = " Cursor row position within the active area (0-indexed).\n\n Output type: uint16_t *"]
pub const CURSOR_Y: Type = 4;
#[doc = " Whether the cursor has a pending wrap (next print will soft-wrap).\n\n Output type: bool *"]
pub const CURSOR_PENDING_WRAP: Type = 5;
#[doc = " The currently active screen.\n\n Output type: GhosttyTerminalScreen *"]
pub const ACTIVE_SCREEN: Type = 6;
#[doc = " Whether the cursor is visible (DEC mode 25).\n\n Output type: bool *"]
pub const CURSOR_VISIBLE: Type = 7;
#[doc = " Current Kitty keyboard protocol flags.\n\n Output type: GhosttyKittyKeyFlags * (uint8_t *)"]
pub const KITTY_KEYBOARD_FLAGS: Type = 8;
#[doc = " Scrollbar state for the terminal viewport.\n\n This may be expensive to calculate depending on where the viewport\n is (arbitrary pins are expensive). The caller should take care to only\n call this as needed and not too frequently.\n\n Output type: GhosttyTerminalScrollbar *"]
pub const 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 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 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 call\n to ghostty_terminal_vt_write() or ghostty_terminal_reset(). An empty\n string (len=0) is returned when no title has been set.\n\n Output type: GhosttyString *"]
pub const 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 call\n to ghostty_terminal_vt_write() or ghostty_terminal_reset(). An empty\n string (len=0) is returned when no pwd has been set.\n\n Output type: GhosttyString *"]
pub const PWD: Type = 13;
#[doc = " The total number of rows in the active screen including scrollback.\n\n Output type: size_t *"]
pub const TOTAL_ROWS: Type = 14;
#[doc = " The number of scrollback rows (total rows minus viewport rows).\n\n Output type: size_t *"]
pub const 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 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 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 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 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 COLOR_CURSOR: Type = 20;
#[doc = " The current 256-color palette.\n\n Output type: GhosttyColorRgb[256] *"]
pub const 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 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 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 COLOR_CURSOR_DEFAULT: Type = 24;
#[doc = " The default 256-color palette (ignoring any OSC overrides).\n\n Output type: GhosttyColorRgb[256] *"]
pub const 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 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 KITTY_IMAGE_MEDIUM_FILE: Type = 27;
#[doc = " Whether the temporary file 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 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 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 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 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 VIEWPORT_ACTIVE: Type = 32;
#[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 MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a new terminal instance.\n\n"]
pub fn ghostty_terminal_new(
allocator: *const Allocator,
terminal: *mut Terminal,
options: TerminalOptions,
) -> Result::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"]
pub fn ghostty_terminal_free(terminal: Terminal);
}
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"]
pub fn ghostty_terminal_reset(terminal: Terminal);
}
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, this is a no-op.\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"]
pub fn ghostty_terminal_resize(
terminal: Terminal,
cols: u16,
rows: u16,
cell_width_px: u32,
cell_height_px: u32,
) -> Result::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 NULL clears the option to its default.\n\n Callbacks are invoked synchronously during ghostty_terminal_vt_write().\n Callbacks must not call ghostty_terminal_vt_write() on the same\n terminal (no reentrancy).\n\n or NULL to clear the option\n"]
pub fn ghostty_terminal_set(
terminal: Terminal,
option: TerminalOption::Type,
value: *const ::std::os::raw::c_void,
) -> Result::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"]
pub fn ghostty_terminal_vt_write(terminal: Terminal, data: *const u8, len: usize);
}
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). For other behaviors, the value is ignored.\n\n"]
pub fn ghostty_terminal_scroll_viewport(terminal: Terminal, behavior: TerminalScrollViewport);
}
unsafe extern "C" {
#[doc = " Get the current value of a terminal mode.\n\n Returns the value of the mode identified by the given mode.\n\n if it is reset\n is NULL or the mode does not correspond to a known mode\n"]
pub fn ghostty_terminal_mode_get(
terminal: Terminal,
mode: Mode,
out_value: *mut bool,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Set the value of a terminal mode.\n\n Sets the mode identified by the given mode to the specified value.\n\n is NULL or the mode does not correspond to a known mode\n"]
pub fn ghostty_terminal_mode_set(terminal: Terminal, mode: Mode, value: bool) -> Result::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 is NULL or the data type is invalid\n"]
pub fn ghostty_terminal_get(
terminal: Terminal,
data: TerminalData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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 documented output type)\n successfully written (may be NULL)\n"]
pub fn ghostty_terminal_get_multi(
terminal: Terminal,
count: usize,
keys: *const TerminalData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::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 is NULL or the point is out of bounds\n"]
pub fn ghostty_terminal_grid_ref(
terminal: Terminal,
point: Point,
out_ref: *mut GridRef,
) -> Result::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 point, or out_ref is invalid, or GHOSTTY_OUT_OF_MEMORY if allocation\n fails.\n"]
pub fn ghostty_terminal_grid_ref_track(
terminal: Terminal,
point: Point,
out_ref: *mut TrackedGridRef,
) -> Result::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 or ref is NULL/invalid, GHOSTTY_NO_VALUE if the ref falls outside\n the requested coordinate system\n"]
pub fn ghostty_terminal_point_from_grid_ref(
terminal: Terminal,
ref_: *const GridRef,
tag: PointTag::Type,
out: *mut PointCoordinate,
) -> Result::Type;
}
#[doc = " Extra screen state to include in styled output.\n"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct FormatterScreenExtra {
#[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 FormatterScreenExtra"][::std::mem::size_of::<FormatterScreenExtra>() - 16usize];
["Alignment of FormatterScreenExtra"][::std::mem::align_of::<FormatterScreenExtra>() - 8usize];
["Offset of field: FormatterScreenExtra::size"]
[::std::mem::offset_of!(FormatterScreenExtra, size) - 0usize];
["Offset of field: FormatterScreenExtra::cursor"]
[::std::mem::offset_of!(FormatterScreenExtra, cursor) - 8usize];
["Offset of field: FormatterScreenExtra::style"]
[::std::mem::offset_of!(FormatterScreenExtra, style) - 9usize];
["Offset of field: FormatterScreenExtra::hyperlink"]
[::std::mem::offset_of!(FormatterScreenExtra, hyperlink) - 10usize];
["Offset of field: FormatterScreenExtra::protection"]
[::std::mem::offset_of!(FormatterScreenExtra, protection) - 11usize];
["Offset of field: FormatterScreenExtra::kitty_keyboard"]
[::std::mem::offset_of!(FormatterScreenExtra, kitty_keyboard) - 12usize];
["Offset of field: FormatterScreenExtra::charsets"]
[::std::mem::offset_of!(FormatterScreenExtra, charsets) - 13usize];
};
#[doc = " Extra terminal state to include in styled output.\n"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct FormatterTerminalExtra {
#[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: FormatterScreenExtra,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of FormatterTerminalExtra"][::std::mem::size_of::<FormatterTerminalExtra>() - 32usize];
["Alignment of FormatterTerminalExtra"]
[::std::mem::align_of::<FormatterTerminalExtra>() - 8usize];
["Offset of field: FormatterTerminalExtra::size"]
[::std::mem::offset_of!(FormatterTerminalExtra, size) - 0usize];
["Offset of field: FormatterTerminalExtra::palette"]
[::std::mem::offset_of!(FormatterTerminalExtra, palette) - 8usize];
["Offset of field: FormatterTerminalExtra::modes"]
[::std::mem::offset_of!(FormatterTerminalExtra, modes) - 9usize];
["Offset of field: FormatterTerminalExtra::scrolling_region"]
[::std::mem::offset_of!(FormatterTerminalExtra, scrolling_region) - 10usize];
["Offset of field: FormatterTerminalExtra::tabstops"]
[::std::mem::offset_of!(FormatterTerminalExtra, tabstops) - 11usize];
["Offset of field: FormatterTerminalExtra::pwd"]
[::std::mem::offset_of!(FormatterTerminalExtra, pwd) - 12usize];
["Offset of field: FormatterTerminalExtra::keyboard"]
[::std::mem::offset_of!(FormatterTerminalExtra, keyboard) - 13usize];
["Offset of field: FormatterTerminalExtra::screen"]
[::std::mem::offset_of!(FormatterTerminalExtra, screen) - 16usize];
};
#[doc = " Options for creating a terminal formatter.\n"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FormatterTerminalOptions {
#[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyFormatterTerminalOptions)."]
pub size: usize,
#[doc = " Output format to emit."]
pub emit: FormatterFormat::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: FormatterTerminalExtra,
#[doc = " Optional selection to restrict output to a range.\n If NULL, the entire screen is formatted."]
pub selection: *const Selection,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of FormatterTerminalOptions"]
[::std::mem::size_of::<FormatterTerminalOptions>() - 56usize];
["Alignment of FormatterTerminalOptions"]
[::std::mem::align_of::<FormatterTerminalOptions>() - 8usize];
["Offset of field: FormatterTerminalOptions::size"]
[::std::mem::offset_of!(FormatterTerminalOptions, size) - 0usize];
["Offset of field: FormatterTerminalOptions::emit"]
[::std::mem::offset_of!(FormatterTerminalOptions, emit) - 8usize];
["Offset of field: FormatterTerminalOptions::unwrap"]
[::std::mem::offset_of!(FormatterTerminalOptions, unwrap) - 12usize];
["Offset of field: FormatterTerminalOptions::trim"]
[::std::mem::offset_of!(FormatterTerminalOptions, trim) - 13usize];
["Offset of field: FormatterTerminalOptions::extra"]
[::std::mem::offset_of!(FormatterTerminalOptions, extra) - 16usize];
["Offset of field: FormatterTerminalOptions::selection"]
[::std::mem::offset_of!(FormatterTerminalOptions, selection) - 48usize];
};
impl Default for FormatterTerminalOptions {
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"]
pub fn ghostty_formatter_terminal_new(
allocator: *const Allocator,
formatter: *mut Formatter,
terminal: Terminal,
options: FormatterTerminalOptions,
) -> Result::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 or the required size on failure\n"]
pub fn ghostty_formatter_format_buf(
formatter: Formatter,
buf: *mut u8,
buf_len: usize,
out_written: *mut usize,
) -> Result::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\n failure\n"]
pub fn ghostty_formatter_format_alloc(
formatter: Formatter,
allocator: *const Allocator,
out_ptr: *mut *mut u8,
out_len: *mut usize,
) -> Result::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"]
pub fn ghostty_formatter_free(formatter: Formatter);
}
pub mod RenderStateDirty {
#[doc = " Dirty state of a render state after update.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Not dirty at all; rendering can be skipped."]
pub const FALSE: Type = 0;
#[doc = " Some rows changed; renderer can redraw incrementally."]
pub const PARTIAL: Type = 1;
#[doc = " Global state changed; renderer should redraw everything."]
pub const FULL: Type = 2;
#[doc = " Global state changed; renderer should redraw everything."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod RenderStateCursorVisualStyle {
#[doc = " Visual style of the cursor.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Bar cursor (DECSCUSR 5, 6)."]
pub const BAR: Type = 0;
#[doc = " Block cursor (DECSCUSR 1, 2)."]
pub const BLOCK: Type = 1;
#[doc = " Underline cursor (DECSCUSR 3, 4)."]
pub const UNDERLINE: Type = 2;
#[doc = " Hollow block cursor."]
pub const BLOCK_HOLLOW: Type = 3;
#[doc = " Hollow block cursor."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod RenderStateData {
#[doc = " Queryable data kinds for ghostty_render_state_get().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid / sentinel value."]
pub const INVALID: Type = 0;
#[doc = " Viewport width in cells (uint16_t)."]
pub const COLS: Type = 1;
#[doc = " Viewport height in cells (uint16_t)."]
pub const ROWS: Type = 2;
#[doc = " Current dirty state (GhosttyRenderStateDirty)."]
pub const 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."]
pub const ROW_ITERATOR: Type = 4;
#[doc = " Default/current background color (GhosttyColorRgb)."]
pub const COLOR_BACKGROUND: Type = 5;
#[doc = " Default/current foreground color (GhosttyColorRgb)."]
pub const 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 COLOR_CURSOR: Type = 7;
#[doc = " Whether an explicit cursor color is set (bool)."]
pub const COLOR_CURSOR_HAS_VALUE: Type = 8;
#[doc = " The active 256-color palette (GhosttyColorRgb[256])."]
pub const COLOR_PALETTE: Type = 9;
#[doc = " The visual style of the cursor (GhosttyRenderStateCursorVisualStyle)."]
pub const CURSOR_VISUAL_STYLE: Type = 10;
#[doc = " Whether the cursor is visible based on terminal modes (bool)."]
pub const CURSOR_VISIBLE: Type = 11;
#[doc = " Whether the cursor should blink based on terminal modes (bool)."]
pub const CURSOR_BLINKING: Type = 12;
#[doc = " Whether the cursor is at a password input field (bool)."]
pub const 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 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 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 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 CURSOR_VIEWPORT_WIDE_TAIL: Type = 17;
#[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 MAX_VALUE: Type = 2147483647;
}
pub mod RenderStateOption {
#[doc = " Settable options for ghostty_render_state_set().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Set dirty state (GhosttyRenderStateDirty)."]
pub const DIRTY: Type = 0;
#[doc = " Set dirty state (GhosttyRenderStateDirty)."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod RenderStateRowData {
#[doc = " Queryable data kinds for ghostty_render_state_row_get().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid / sentinel value."]
pub const INVALID: Type = 0;
#[doc = " Whether the current row is dirty (bool)."]
pub const DIRTY: Type = 1;
#[doc = " The raw row value (GhosttyRow)."]
pub const 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 CELLS: Type = 3;
#[doc = " Row-local selected cell range (GhosttyRenderStateRowSelection)."]
pub const SELECTION: Type = 4;
#[doc = " Row-local selected cell range (GhosttyRenderStateRowSelection)."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod RenderStateRowOption {
#[doc = " Settable options for ghostty_render_state_row_set().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Set dirty state for the current row (bool)."]
pub const DIRTY: Type = 0;
#[doc = " Set dirty state for the current row (bool)."]
pub const 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"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct RenderStateRowSelection {
#[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 RenderStateRowSelection"][::std::mem::size_of::<RenderStateRowSelection>() - 16usize];
["Alignment of RenderStateRowSelection"]
[::std::mem::align_of::<RenderStateRowSelection>() - 8usize];
["Offset of field: RenderStateRowSelection::size"]
[::std::mem::offset_of!(RenderStateRowSelection, size) - 0usize];
["Offset of field: RenderStateRowSelection::start_x"]
[::std::mem::offset_of!(RenderStateRowSelection, start_x) - 8usize];
["Offset of field: RenderStateRowSelection::end_x"]
[::std::mem::offset_of!(RenderStateRowSelection, end_x) - 10usize];
};
#[doc = " Render-state color information.\n\n This struct uses the sized-struct ABI pattern. Initialize with\n GHOSTTY_INIT_SIZED(GhosttyRenderStateColors) before calling\n ghostty_render_state_colors_get().\n\n Example:\n GhosttyRenderStateColors colors = GHOSTTY_INIT_SIZED(GhosttyRenderStateColors);\n GhosttyResult result = ghostty_render_state_colors_get(state, &colors);\n"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct RenderStateColors {
#[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: ColorRgb,
#[doc = " The default/current foreground color for the render state."]
pub foreground: ColorRgb,
#[doc = " The cursor color when explicitly set by terminal state."]
pub cursor: ColorRgb,
#[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: [ColorRgb; 256usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of RenderStateColors"][::std::mem::size_of::<RenderStateColors>() - 792usize];
["Alignment of RenderStateColors"][::std::mem::align_of::<RenderStateColors>() - 8usize];
["Offset of field: RenderStateColors::size"]
[::std::mem::offset_of!(RenderStateColors, size) - 0usize];
["Offset of field: RenderStateColors::background"]
[::std::mem::offset_of!(RenderStateColors, background) - 8usize];
["Offset of field: RenderStateColors::foreground"]
[::std::mem::offset_of!(RenderStateColors, foreground) - 11usize];
["Offset of field: RenderStateColors::cursor"]
[::std::mem::offset_of!(RenderStateColors, cursor) - 14usize];
["Offset of field: RenderStateColors::cursor_has_value"]
[::std::mem::offset_of!(RenderStateColors, cursor_has_value) - 17usize];
["Offset of field: RenderStateColors::palette"]
[::std::mem::offset_of!(RenderStateColors, palette) - 18usize];
};
impl Default for RenderStateColors {
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 failure\n"]
pub fn ghostty_render_state_new(
allocator: *const Allocator,
state: *mut RenderState,
) -> Result::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"]
pub fn ghostty_render_state_free(state: RenderState);
}
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 `terminal` is NULL, GHOSTTY_OUT_OF_MEMORY if updating the state requires\n allocation and that allocation fails\n"]
pub fn ghostty_render_state_update(state: RenderState, terminal: Terminal) -> Result::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 NULL or `data` is not a recognized enum value\n"]
pub fn ghostty_render_state_get(
state: RenderState,
data: RenderStateData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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 documented output type)\n successfully written (may be NULL)\n"]
pub fn ghostty_render_state_get_multi(
state: RenderState,
count: usize,
keys: *const RenderStateData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::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 GHOSTTY_INVALID_VALUE)\n `value` is NULL\n"]
pub fn ghostty_render_state_set(
state: RenderState,
option: RenderStateOption::Type,
value: *const ::std::os::raw::c_void,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Get the current color information from a render state.\n\n This writes as many fields as fit in the caller-provided sized struct.\n `out_colors->size` must be set by the caller (typically via\n GHOSTTY_INIT_SIZED(GhosttyRenderStateColors)).\n\n `out_colors` is NULL, or if `out_colors->size` is smaller than\n `sizeof(size_t)`\n"]
pub fn ghostty_render_state_colors_get(
state: RenderState,
out_colors: *mut RenderStateColors,
) -> Result::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 failure\n"]
pub fn ghostty_render_state_row_iterator_new(
allocator: *const Allocator,
out_iterator: *mut RenderStateRowIterator,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Free a render-state row iterator.\n\n"]
pub fn ghostty_render_state_row_iterator_free(iterator: RenderStateRowIterator);
}
unsafe extern "C" {
#[doc = " Move a render-state row iterator to the next row.\n\n Returns true if the iterator moved successfully and row data is\n available to read at the new position.\n\n NULL or if the iterator has reached the end\n"]
pub fn ghostty_render_state_row_iterator_next(iterator: RenderStateRowIterator) -> 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() at least once before\n calling this function.\n\n `iterator` is NULL or the iterator is not positioned on a row\n"]
pub fn ghostty_render_state_row_get(
iterator: RenderStateRowIterator,
data: RenderStateRowData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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 documented output type)\n successfully written (may be NULL)\n"]
pub fn ghostty_render_state_row_get_multi(
iterator: RenderStateRowIterator,
count: usize,
keys: *const RenderStateRowData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::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() at least once before\n calling this function.\n\n GHOSTTY_INVALID_VALUE)\n `iterator` is NULL or the iterator is not positioned on a row\n"]
pub fn ghostty_render_state_row_set(
iterator: RenderStateRowIterator,
option: RenderStateRowOption::Type,
value: *const ::std::os::raw::c_void,
) -> Result::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 failure\n"]
pub fn ghostty_render_state_row_cells_new(
allocator: *const Allocator,
out_cells: *mut RenderStateRowCells,
) -> Result::Type;
}
pub mod RenderStateRowCellsData {
#[doc = " Queryable data kinds for ghostty_render_state_row_cells_get().\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid / sentinel value."]
pub const INVALID: Type = 0;
#[doc = " The raw cell value (GhosttyCell)."]
pub const RAW: Type = 1;
#[doc = " The style for the current cell (GhosttyStyle)."]
pub const 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 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 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 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 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 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 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 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 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 NULL or if the iterator has reached the end\n"]
pub fn ghostty_render_state_row_cells_next(cells: RenderStateRowCells) -> 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 GHOSTTY_INVALID_VALUE)\n is NULL or `x` is out of range\n"]
pub fn ghostty_render_state_row_cells_select(
cells: RenderStateRowCells,
x: u16,
) -> Result::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 `cells` is NULL or the iterator is not positioned on a cell\n"]
pub fn ghostty_render_state_row_cells_get(
cells: RenderStateRowCells,
data: RenderStateRowCellsData::Type,
out: *mut ::std::os::raw::c_void,
) -> Result::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 documented output type)\n successfully written (may be NULL)\n"]
pub fn ghostty_render_state_row_cells_get_multi(
cells: RenderStateRowCells,
count: usize,
keys: *const RenderStateRowCellsData::Type,
values: *mut *mut ::std::os::raw::c_void,
out_written: *mut usize,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Free a row cells instance.\n\n"]
pub fn ghostty_render_state_row_cells_free(cells: RenderStateRowCells);
}
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"]
pub fn ghostty_tracked_grid_ref_free(ref_: TrackedGridRef);
}
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"]
pub fn ghostty_tracked_grid_ref_has_value(ref_: TrackedGridRef) -> 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 or GHOSTTY_NO_VALUE if there is no representable value.\n"]
pub fn ghostty_tracked_grid_ref_point(
ref_: TrackedGridRef,
tag: PointTag::Type,
out_point: *mut PointCoordinate,
) -> Result::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 or point is invalid, or GHOSTTY_OUT_OF_MEMORY if allocation fails.\n"]
pub fn ghostty_tracked_grid_ref_set(
ref_: TrackedGridRef,
terminal: Terminal,
point: Point,
) -> Result::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(), or\n 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 or GHOSTTY_NO_VALUE if the tracked location was discarded.\n"]
pub fn ghostty_tracked_grid_ref_snapshot(
ref_: TrackedGridRef,
out_ref: *mut GridRef,
) -> Result::Type;
}
pub mod OscCommandType {
#[doc = " OSC command types.\n"]
pub type Type = ::std::os::raw::c_uint;
pub const INVALID: Type = 0;
pub const CHANGE_WINDOW_TITLE: Type = 1;
pub const CHANGE_WINDOW_ICON: Type = 2;
pub const SEMANTIC_PROMPT: Type = 3;
pub const CLIPBOARD_CONTENTS: Type = 4;
pub const REPORT_PWD: Type = 5;
pub const MOUSE_SHAPE: Type = 6;
pub const COLOR_OPERATION: Type = 7;
pub const KITTY_COLOR_PROTOCOL: Type = 8;
pub const SHOW_DESKTOP_NOTIFICATION: Type = 9;
pub const HYPERLINK_START: Type = 10;
pub const HYPERLINK_END: Type = 11;
pub const CONEMU_SLEEP: Type = 12;
pub const CONEMU_SHOW_MESSAGE_BOX: Type = 13;
pub const CONEMU_CHANGE_TAB_TITLE: Type = 14;
pub const CONEMU_PROGRESS_REPORT: Type = 15;
pub const CONEMU_WAIT_INPUT: Type = 16;
pub const CONEMU_GUIMACRO: Type = 17;
pub const CONEMU_RUN_PROCESS: Type = 18;
pub const CONEMU_OUTPUT_ENVIRONMENT_VARIABLE: Type = 19;
pub const CONEMU_XTERM_EMULATION: Type = 20;
pub const CONEMU_COMMENT: Type = 21;
pub const KITTY_TEXT_SIZING: Type = 22;
pub const TYPE_MAX_VALUE: Type = 2147483647;
}
pub mod OscCommandData {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Invalid data type. Never results in any data extraction."]
pub const 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 CHANGE_WINDOW_TITLE_STR: Type = 1;
#[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 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"]
pub fn ghostty_osc_new(allocator: *const Allocator, parser: *mut OscParser) -> Result::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"]
pub fn ghostty_osc_free(parser: OscParser);
}
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"]
pub fn ghostty_osc_reset(parser: OscParser);
}
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"]
pub fn ghostty_osc_next(parser: OscParser, byte: u8);
}
unsafe extern "C" {
#[doc = " Finalize OSC parsing and retrieve the parsed command.\n\n Call this function after feeding all bytes of an OSC sequence to the parser\n using ghostty_osc_next() with the exception of the terminating character\n (ESC or ST). This function finalizes the parsing process and returns the\n parsed OSC command.\n\n The return value is never NULL. Invalid commands will return a command\n with type GHOSTTY_OSC_COMMAND_INVALID.\n\n The terminator parameter specifies the byte that terminated the OSC sequence\n (typically 0x07 for BEL or 0x5C for ST after ESC). This information is\n preserved in the parsed command so that responses can use the same terminator\n format for better compatibility with the calling program. For commands that\n do not require a response, this parameter is ignored and the resulting\n command will not retain the terminator information.\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"]
pub fn ghostty_osc_end(parser: OscParser, terminator: u8) -> OscCommand;
}
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"]
pub fn ghostty_osc_command_type(command: OscCommand) -> OscCommandType::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"]
pub fn ghostty_osc_command_data(
command: OscCommand,
data: OscCommandData::Type,
out: *mut ::std::os::raw::c_void,
) -> bool;
}
pub mod SgrAttributeTag {
#[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"]
pub type Type = ::std::os::raw::c_uint;
pub const UNSET: Type = 0;
pub const UNKNOWN: Type = 1;
pub const BOLD: Type = 2;
pub const RESET_BOLD: Type = 3;
pub const ITALIC: Type = 4;
pub const RESET_ITALIC: Type = 5;
pub const FAINT: Type = 6;
pub const UNDERLINE: Type = 7;
pub const UNDERLINE_COLOR: Type = 8;
pub const UNDERLINE_COLOR_256: Type = 9;
pub const RESET_UNDERLINE_COLOR: Type = 10;
pub const OVERLINE: Type = 11;
pub const RESET_OVERLINE: Type = 12;
pub const BLINK: Type = 13;
pub const RESET_BLINK: Type = 14;
pub const INVERSE: Type = 15;
pub const RESET_INVERSE: Type = 16;
pub const INVISIBLE: Type = 17;
pub const RESET_INVISIBLE: Type = 18;
pub const STRIKETHROUGH: Type = 19;
pub const RESET_STRIKETHROUGH: Type = 20;
pub const DIRECT_COLOR_FG: Type = 21;
pub const DIRECT_COLOR_BG: Type = 22;
pub const BG_8: Type = 23;
pub const FG_8: Type = 24;
pub const RESET_FG: Type = 25;
pub const RESET_BG: Type = 26;
pub const BRIGHT_BG_8: Type = 27;
pub const BRIGHT_FG_8: Type = 28;
pub const BG_256: Type = 29;
pub const FG_256: Type = 30;
pub const MAX_VALUE: Type = 2147483647;
}
pub mod SgrUnderline {
#[doc = " Underline style types.\n"]
pub type Type = ::std::os::raw::c_uint;
pub const NONE: Type = 0;
pub const SINGLE: Type = 1;
pub const DOUBLE: Type = 2;
pub const CURLY: Type = 3;
pub const DOTTED: Type = 4;
pub const DASHED: Type = 5;
pub const 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"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SgrUnknown {
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 SgrUnknown"][::std::mem::size_of::<SgrUnknown>() - 32usize];
["Alignment of SgrUnknown"][::std::mem::align_of::<SgrUnknown>() - 8usize];
["Offset of field: SgrUnknown::full_ptr"]
[::std::mem::offset_of!(SgrUnknown, full_ptr) - 0usize];
["Offset of field: SgrUnknown::full_len"]
[::std::mem::offset_of!(SgrUnknown, full_len) - 8usize];
["Offset of field: SgrUnknown::partial_ptr"]
[::std::mem::offset_of!(SgrUnknown, partial_ptr) - 16usize];
["Offset of field: SgrUnknown::partial_len"]
[::std::mem::offset_of!(SgrUnknown, partial_len) - 24usize];
};
impl Default for SgrUnknown {
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"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union SgrAttributeValue {
pub unknown: SgrUnknown,
pub underline: SgrUnderline::Type,
pub underline_color: ColorRgb,
pub underline_color_256: ColorPaletteIndex,
pub direct_color_fg: ColorRgb,
pub direct_color_bg: ColorRgb,
pub bg_8: ColorPaletteIndex,
pub fg_8: ColorPaletteIndex,
pub bright_bg_8: ColorPaletteIndex,
pub bright_fg_8: ColorPaletteIndex,
pub bg_256: ColorPaletteIndex,
pub fg_256: ColorPaletteIndex,
pub _padding: [u64; 8usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of SgrAttributeValue"][::std::mem::size_of::<SgrAttributeValue>() - 64usize];
["Alignment of SgrAttributeValue"][::std::mem::align_of::<SgrAttributeValue>() - 8usize];
["Offset of field: SgrAttributeValue::unknown"]
[::std::mem::offset_of!(SgrAttributeValue, unknown) - 0usize];
["Offset of field: SgrAttributeValue::underline"]
[::std::mem::offset_of!(SgrAttributeValue, underline) - 0usize];
["Offset of field: SgrAttributeValue::underline_color"]
[::std::mem::offset_of!(SgrAttributeValue, underline_color) - 0usize];
["Offset of field: SgrAttributeValue::underline_color_256"]
[::std::mem::offset_of!(SgrAttributeValue, underline_color_256) - 0usize];
["Offset of field: SgrAttributeValue::direct_color_fg"]
[::std::mem::offset_of!(SgrAttributeValue, direct_color_fg) - 0usize];
["Offset of field: SgrAttributeValue::direct_color_bg"]
[::std::mem::offset_of!(SgrAttributeValue, direct_color_bg) - 0usize];
["Offset of field: SgrAttributeValue::bg_8"]
[::std::mem::offset_of!(SgrAttributeValue, bg_8) - 0usize];
["Offset of field: SgrAttributeValue::fg_8"]
[::std::mem::offset_of!(SgrAttributeValue, fg_8) - 0usize];
["Offset of field: SgrAttributeValue::bright_bg_8"]
[::std::mem::offset_of!(SgrAttributeValue, bright_bg_8) - 0usize];
["Offset of field: SgrAttributeValue::bright_fg_8"]
[::std::mem::offset_of!(SgrAttributeValue, bright_fg_8) - 0usize];
["Offset of field: SgrAttributeValue::bg_256"]
[::std::mem::offset_of!(SgrAttributeValue, bg_256) - 0usize];
["Offset of field: SgrAttributeValue::fg_256"]
[::std::mem::offset_of!(SgrAttributeValue, fg_256) - 0usize];
["Offset of field: SgrAttributeValue::_padding"]
[::std::mem::offset_of!(SgrAttributeValue, _padding) - 0usize];
};
impl Default for SgrAttributeValue {
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"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SgrAttribute {
pub tag: SgrAttributeTag::Type,
pub value: SgrAttributeValue,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of SgrAttribute"][::std::mem::size_of::<SgrAttribute>() - 72usize];
["Alignment of SgrAttribute"][::std::mem::align_of::<SgrAttribute>() - 8usize];
["Offset of field: SgrAttribute::tag"][::std::mem::offset_of!(SgrAttribute, tag) - 0usize];
["Offset of field: SgrAttribute::value"][::std::mem::offset_of!(SgrAttribute, value) - 8usize];
};
impl Default for SgrAttribute {
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 NULL to use the default allocator\n"]
pub fn ghostty_sgr_new(allocator: *const Allocator, parser: *mut SgrParser) -> Result::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"]
pub fn ghostty_sgr_free(parser: SgrParser);
}
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"]
pub fn ghostty_sgr_reset(parser: SgrParser);
}
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 NULL\n"]
pub fn ghostty_sgr_set_params(
parser: SgrParser,
params: *const u16,
separators: *const ::std::os::raw::c_char,
len: usize,
) -> Result::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"]
pub fn ghostty_sgr_next(parser: SgrParser, attr: *mut SgrAttribute) -> 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"]
pub fn ghostty_sgr_unknown_full(unknown: SgrUnknown, 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"]
pub fn ghostty_sgr_unknown_partial(unknown: SgrUnknown, 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"]
pub fn ghostty_sgr_attribute_tag(attr: SgrAttribute) -> SgrAttributeTag::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"]
pub fn ghostty_sgr_attribute_value(attr: *mut SgrAttribute) -> *mut SgrAttributeValue;
}
#[doc = " Result of decoding an image.\n\n The `data` buffer must be allocated through the allocator provided to\n the decode callback. The library takes ownership and will free it\n with the same allocator."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SysImage {
#[doc = " Image width in pixels."]
pub width: u32,
#[doc = " Image height in pixels."]
pub height: u32,
#[doc = " Pointer to the decoded RGBA pixel data."]
pub data: *mut u8,
#[doc = " Length of the pixel data in bytes."]
pub data_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of SysImage"][::std::mem::size_of::<SysImage>() - 24usize];
["Alignment of SysImage"][::std::mem::align_of::<SysImage>() - 8usize];
["Offset of field: SysImage::width"][::std::mem::offset_of!(SysImage, width) - 0usize];
["Offset of field: SysImage::height"][::std::mem::offset_of!(SysImage, height) - 4usize];
["Offset of field: SysImage::data"][::std::mem::offset_of!(SysImage, data) - 8usize];
["Offset of field: SysImage::data_len"][::std::mem::offset_of!(SysImage, data_len) - 16usize];
};
impl Default for SysImage {
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 SysLogLevel {
#[doc = " Log severity levels for the log callback."]
pub type Type = ::std::os::raw::c_uint;
pub const ERROR: Type = 0;
pub const WARNING: Type = 1;
pub const INFO: Type = 2;
pub const DEBUG: Type = 3;
pub const 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 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"]
pub type SysLogFn = ::std::option::Option<
unsafe extern "C" fn(
userdata: *mut ::std::os::raw::c_void,
level: SysLogLevel::Type,
scope: *const u8,
scope_len: usize,
message: *const u8,
message_len: usize,
),
>;
#[doc = " Callback type for PNG decoding.\n\n Decodes raw PNG data into RGBA pixels. The output pixel data must be\n allocated through the provided allocator. The library takes ownership\n of the buffer and will free it with the same allocator.\n"]
pub type SysDecodePngFn = ::std::option::Option<
unsafe extern "C" fn(
userdata: *mut ::std::os::raw::c_void,
allocator: *const Allocator,
data: *const u8,
data_len: usize,
out: *mut SysImage,
) -> bool,
>;
pub mod SysOption {
#[doc = " System option identifiers for ghostty_sys_set()."]
pub type Type = ::std::os::raw::c_uint;
#[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 = " 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_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 or NULL to clear it\n option is not recognized"]
pub fn ghostty_sys_set(
option: SysOption::Type,
value: *const ::std::os::raw::c_void,
) -> Result::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 ghostty_sys_set(GHOSTTY_SYS_OPT_LOG, &ghostty_sys_log_stderr);"]
pub fn ghostty_sys_log_stderr(
userdata: *mut ::std::os::raw::c_void,
level: SysLogLevel::Type,
scope: *const u8,
scope_len: usize,
message: *const u8,
message_len: usize,
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct KeyEventImpl {
_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"]
pub type KeyEvent = *mut KeyEventImpl;
pub mod KeyAction {
#[doc = " Keyboard input event types.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Key was released"]
pub const RELEASE: Type = 0;
#[doc = " Key was pressed"]
pub const PRESS: Type = 1;
#[doc = " Key is being repeated (held down)"]
pub const REPEAT: Type = 2;
#[doc = " Key is being repeated (held down)"]
pub const 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"]
pub type Mods = u16;
pub mod Key {
#[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"]
pub type Type = ::std::os::raw::c_uint;
pub const UNIDENTIFIED: Type = 0;
pub const BACKQUOTE: Type = 1;
pub const BACKSLASH: Type = 2;
pub const BRACKET_LEFT: Type = 3;
pub const BRACKET_RIGHT: Type = 4;
pub const COMMA: Type = 5;
pub const DIGIT_0: Type = 6;
pub const DIGIT_1: Type = 7;
pub const DIGIT_2: Type = 8;
pub const DIGIT_3: Type = 9;
pub const DIGIT_4: Type = 10;
pub const DIGIT_5: Type = 11;
pub const DIGIT_6: Type = 12;
pub const DIGIT_7: Type = 13;
pub const DIGIT_8: Type = 14;
pub const DIGIT_9: Type = 15;
pub const EQUAL: Type = 16;
pub const INTL_BACKSLASH: Type = 17;
pub const INTL_RO: Type = 18;
pub const INTL_YEN: Type = 19;
pub const A: Type = 20;
pub const B: Type = 21;
pub const C: Type = 22;
pub const D: Type = 23;
pub const E: Type = 24;
pub const F: Type = 25;
pub const G: Type = 26;
pub const H: Type = 27;
pub const I: Type = 28;
pub const J: Type = 29;
pub const K: Type = 30;
pub const L: Type = 31;
pub const M: Type = 32;
pub const N: Type = 33;
pub const O: Type = 34;
pub const P: Type = 35;
pub const Q: Type = 36;
pub const R: Type = 37;
pub const S: Type = 38;
pub const T: Type = 39;
pub const U: Type = 40;
pub const V: Type = 41;
pub const W: Type = 42;
pub const X: Type = 43;
pub const Y: Type = 44;
pub const Z: Type = 45;
pub const MINUS: Type = 46;
pub const PERIOD: Type = 47;
pub const QUOTE: Type = 48;
pub const SEMICOLON: Type = 49;
pub const SLASH: Type = 50;
pub const ALT_LEFT: Type = 51;
pub const ALT_RIGHT: Type = 52;
pub const BACKSPACE: Type = 53;
pub const CAPS_LOCK: Type = 54;
pub const CONTEXT_MENU: Type = 55;
pub const CONTROL_LEFT: Type = 56;
pub const CONTROL_RIGHT: Type = 57;
pub const ENTER: Type = 58;
pub const META_LEFT: Type = 59;
pub const META_RIGHT: Type = 60;
pub const SHIFT_LEFT: Type = 61;
pub const SHIFT_RIGHT: Type = 62;
pub const SPACE: Type = 63;
pub const TAB: Type = 64;
pub const CONVERT: Type = 65;
pub const KANA_MODE: Type = 66;
pub const NON_CONVERT: Type = 67;
pub const DELETE: Type = 68;
pub const END: Type = 69;
pub const HELP: Type = 70;
pub const HOME: Type = 71;
pub const INSERT: Type = 72;
pub const PAGE_DOWN: Type = 73;
pub const PAGE_UP: Type = 74;
pub const ARROW_DOWN: Type = 75;
pub const ARROW_LEFT: Type = 76;
pub const ARROW_RIGHT: Type = 77;
pub const ARROW_UP: Type = 78;
pub const NUM_LOCK: Type = 79;
pub const NUMPAD_0: Type = 80;
pub const NUMPAD_1: Type = 81;
pub const NUMPAD_2: Type = 82;
pub const NUMPAD_3: Type = 83;
pub const NUMPAD_4: Type = 84;
pub const NUMPAD_5: Type = 85;
pub const NUMPAD_6: Type = 86;
pub const NUMPAD_7: Type = 87;
pub const NUMPAD_8: Type = 88;
pub const NUMPAD_9: Type = 89;
pub const NUMPAD_ADD: Type = 90;
pub const NUMPAD_BACKSPACE: Type = 91;
pub const NUMPAD_CLEAR: Type = 92;
pub const NUMPAD_CLEAR_ENTRY: Type = 93;
pub const NUMPAD_COMMA: Type = 94;
pub const NUMPAD_DECIMAL: Type = 95;
pub const NUMPAD_DIVIDE: Type = 96;
pub const NUMPAD_ENTER: Type = 97;
pub const NUMPAD_EQUAL: Type = 98;
pub const NUMPAD_MEMORY_ADD: Type = 99;
pub const NUMPAD_MEMORY_CLEAR: Type = 100;
pub const NUMPAD_MEMORY_RECALL: Type = 101;
pub const NUMPAD_MEMORY_STORE: Type = 102;
pub const NUMPAD_MEMORY_SUBTRACT: Type = 103;
pub const NUMPAD_MULTIPLY: Type = 104;
pub const NUMPAD_PAREN_LEFT: Type = 105;
pub const NUMPAD_PAREN_RIGHT: Type = 106;
pub const NUMPAD_SUBTRACT: Type = 107;
pub const NUMPAD_SEPARATOR: Type = 108;
pub const NUMPAD_UP: Type = 109;
pub const NUMPAD_DOWN: Type = 110;
pub const NUMPAD_RIGHT: Type = 111;
pub const NUMPAD_LEFT: Type = 112;
pub const NUMPAD_BEGIN: Type = 113;
pub const NUMPAD_HOME: Type = 114;
pub const NUMPAD_END: Type = 115;
pub const NUMPAD_INSERT: Type = 116;
pub const NUMPAD_DELETE: Type = 117;
pub const NUMPAD_PAGE_UP: Type = 118;
pub const NUMPAD_PAGE_DOWN: Type = 119;
pub const ESCAPE: Type = 120;
pub const F1: Type = 121;
pub const F2: Type = 122;
pub const F3: Type = 123;
pub const F4: Type = 124;
pub const F5: Type = 125;
pub const F6: Type = 126;
pub const F7: Type = 127;
pub const F8: Type = 128;
pub const F9: Type = 129;
pub const F10: Type = 130;
pub const F11: Type = 131;
pub const F12: Type = 132;
pub const F13: Type = 133;
pub const F14: Type = 134;
pub const F15: Type = 135;
pub const F16: Type = 136;
pub const F17: Type = 137;
pub const F18: Type = 138;
pub const F19: Type = 139;
pub const F20: Type = 140;
pub const F21: Type = 141;
pub const F22: Type = 142;
pub const F23: Type = 143;
pub const F24: Type = 144;
pub const F25: Type = 145;
pub const FN: Type = 146;
pub const FN_LOCK: Type = 147;
pub const PRINT_SCREEN: Type = 148;
pub const SCROLL_LOCK: Type = 149;
pub const PAUSE: Type = 150;
pub const BROWSER_BACK: Type = 151;
pub const BROWSER_FAVORITES: Type = 152;
pub const BROWSER_FORWARD: Type = 153;
pub const BROWSER_HOME: Type = 154;
pub const BROWSER_REFRESH: Type = 155;
pub const BROWSER_SEARCH: Type = 156;
pub const BROWSER_STOP: Type = 157;
pub const EJECT: Type = 158;
pub const LAUNCH_APP_1: Type = 159;
pub const LAUNCH_APP_2: Type = 160;
pub const LAUNCH_MAIL: Type = 161;
pub const MEDIA_PLAY_PAUSE: Type = 162;
pub const MEDIA_SELECT: Type = 163;
pub const MEDIA_STOP: Type = 164;
pub const MEDIA_TRACK_NEXT: Type = 165;
pub const MEDIA_TRACK_PREVIOUS: Type = 166;
pub const POWER: Type = 167;
pub const SLEEP: Type = 168;
pub const AUDIO_VOLUME_DOWN: Type = 169;
pub const AUDIO_VOLUME_MUTE: Type = 170;
pub const AUDIO_VOLUME_UP: Type = 171;
pub const WAKE_UP: Type = 172;
pub const COPY: Type = 173;
pub const CUT: Type = 174;
pub const PASTE: Type = 175;
pub const 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"]
pub fn ghostty_key_event_new(allocator: *const Allocator, event: *mut KeyEvent)
-> Result::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"]
pub fn ghostty_key_event_free(event: KeyEvent);
}
unsafe extern "C" {
#[doc = " Set the key action (press, release, repeat).\n\n"]
pub fn ghostty_key_event_set_action(event: KeyEvent, action: KeyAction::Type);
}
unsafe extern "C" {
#[doc = " Get the key action (press, release, repeat).\n\n"]
pub fn ghostty_key_event_get_action(event: KeyEvent) -> KeyAction::Type;
}
unsafe extern "C" {
#[doc = " Set the physical key code.\n\n"]
pub fn ghostty_key_event_set_key(event: KeyEvent, key: Key::Type);
}
unsafe extern "C" {
#[doc = " Get the physical key code.\n\n"]
pub fn ghostty_key_event_get_key(event: KeyEvent) -> Key::Type;
}
unsafe extern "C" {
#[doc = " Set the modifier keys bitmask.\n\n"]
pub fn ghostty_key_event_set_mods(event: KeyEvent, mods: Mods);
}
unsafe extern "C" {
#[doc = " Get the modifier keys bitmask.\n\n"]
pub fn ghostty_key_event_get_mods(event: KeyEvent) -> Mods;
}
unsafe extern "C" {
#[doc = " Set the consumed modifiers bitmask.\n\n"]
pub fn ghostty_key_event_set_consumed_mods(event: KeyEvent, consumed_mods: Mods);
}
unsafe extern "C" {
#[doc = " Get the consumed modifiers bitmask.\n\n"]
pub fn ghostty_key_event_get_consumed_mods(event: KeyEvent) -> Mods;
}
unsafe extern "C" {
#[doc = " Set whether the key event is part of a composition sequence.\n\n"]
pub fn ghostty_key_event_set_composing(event: KeyEvent, composing: bool);
}
unsafe extern "C" {
#[doc = " Get whether the key event is part of a composition sequence.\n\n"]
pub fn ghostty_key_event_get_composing(event: KeyEvent) -> 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"]
pub fn ghostty_key_event_set_utf8(
event: KeyEvent,
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"]
pub fn ghostty_key_event_get_utf8(
event: KeyEvent,
len: *mut usize,
) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
#[doc = " Set the unshifted Unicode codepoint.\n\n"]
pub fn ghostty_key_event_set_unshifted_codepoint(event: KeyEvent, codepoint: u32);
}
unsafe extern "C" {
#[doc = " Get the unshifted Unicode codepoint.\n\n"]
pub fn ghostty_key_event_get_unshifted_codepoint(event: KeyEvent) -> u32;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct KeyEncoderImpl {
_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"]
pub type KeyEncoder = *mut KeyEncoderImpl;
#[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"]
pub type KittyKeyFlags = u8;
pub mod OptionAsAlt {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Option key is not treated as alt"]
pub const FALSE: Type = 0;
#[doc = " Option key is treated as alt"]
pub const TRUE: Type = 1;
#[doc = " Only left option key is treated as alt"]
pub const LEFT: Type = 2;
#[doc = " Only right option key is treated as alt"]
pub const RIGHT: Type = 3;
#[doc = " Only right option key is treated as alt"]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod KeyEncoderOption {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Terminal DEC mode 1: cursor key application mode (value: bool)"]
pub const CURSOR_KEY_APPLICATION: Type = 0;
#[doc = " Terminal DEC mode 66: keypad key application mode (value: bool)"]
pub const KEYPAD_KEY_APPLICATION: Type = 1;
#[doc = " Terminal DEC mode 1035: ignore keypad with numlock (value: bool)"]
pub const IGNORE_KEYPAD_WITH_NUMLOCK: Type = 2;
#[doc = " Terminal DEC mode 1036: alt sends escape prefix (value: bool)"]
pub const ALT_ESC_PREFIX: Type = 3;
#[doc = " xterm modifyOtherKeys mode 2 (value: bool)"]
pub const MODIFY_OTHER_KEYS_STATE_2: Type = 4;
#[doc = " Kitty keyboard protocol flags (value: GhosttyKittyKeyFlags bitmask)"]
pub const KITTY_FLAGS: Type = 5;
#[doc = " macOS option-as-alt setting (value: GhosttyOptionAsAlt)"]
pub const 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 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 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"]
pub fn ghostty_key_encoder_new(
allocator: *const Allocator,
encoder: *mut KeyEncoder,
) -> Result::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"]
pub fn ghostty_key_encoder_free(encoder: KeyEncoder);
}
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"]
pub fn ghostty_key_encoder_setopt(
encoder: KeyEncoder,
option: KeyEncoderOption::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"]
pub fn ghostty_key_encoder_setopt_from_terminal(encoder: KeyEncoder, terminal: Terminal);
}
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\n ## Example: Calculate required buffer size\n\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\n ## Example: Direct encoding with static buffer\n\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"]
pub fn ghostty_key_encoder_encode(
encoder: KeyEncoder,
event: KeyEvent,
out_buf: *mut ::std::os::raw::c_char,
out_buf_size: usize,
out_len: *mut usize,
) -> Result::Type;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MouseEventImpl {
_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"]
pub type MouseEvent = *mut MouseEventImpl;
pub mod MouseAction {
#[doc = " Mouse event action type.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Mouse button was pressed."]
pub const PRESS: Type = 0;
#[doc = " Mouse button was released."]
pub const RELEASE: Type = 1;
#[doc = " Mouse moved."]
pub const MOTION: Type = 2;
#[doc = " Mouse moved."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod MouseButton {
#[doc = " Mouse button identity.\n"]
pub type Type = ::std::os::raw::c_uint;
pub const UNKNOWN: Type = 0;
pub const LEFT: Type = 1;
pub const RIGHT: Type = 2;
pub const MIDDLE: Type = 3;
pub const FOUR: Type = 4;
pub const FIVE: Type = 5;
pub const SIX: Type = 6;
pub const SEVEN: Type = 7;
pub const EIGHT: Type = 8;
pub const NINE: Type = 9;
pub const TEN: Type = 10;
pub const ELEVEN: Type = 11;
pub const MAX_VALUE: Type = 2147483647;
}
#[doc = " Mouse position in surface-space pixels.\n"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct MousePosition {
pub x: f32,
pub y: f32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of MousePosition"][::std::mem::size_of::<MousePosition>() - 8usize];
["Alignment of MousePosition"][::std::mem::align_of::<MousePosition>() - 4usize];
["Offset of field: MousePosition::x"][::std::mem::offset_of!(MousePosition, x) - 0usize];
["Offset of field: MousePosition::y"][::std::mem::offset_of!(MousePosition, y) - 4usize];
};
unsafe extern "C" {
#[doc = " Create a new mouse event instance.\n\n"]
pub fn ghostty_mouse_event_new(
allocator: *const Allocator,
event: *mut MouseEvent,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Free a mouse event instance.\n\n"]
pub fn ghostty_mouse_event_free(event: MouseEvent);
}
unsafe extern "C" {
#[doc = " Set the event action.\n\n"]
pub fn ghostty_mouse_event_set_action(event: MouseEvent, action: MouseAction::Type);
}
unsafe extern "C" {
#[doc = " Get the event action.\n\n"]
pub fn ghostty_mouse_event_get_action(event: MouseEvent) -> MouseAction::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"]
pub fn ghostty_mouse_event_set_button(event: MouseEvent, button: MouseButton::Type);
}
unsafe extern "C" {
#[doc = " Clear the event button.\n\n This sets the event button to \"none\".\n\n"]
pub fn ghostty_mouse_event_clear_button(event: MouseEvent);
}
unsafe extern "C" {
#[doc = " Get the event button.\n\n"]
pub fn ghostty_mouse_event_get_button(
event: MouseEvent,
out_button: *mut MouseButton::Type,
) -> bool;
}
unsafe extern "C" {
#[doc = " Set keyboard modifiers held during the event.\n\n"]
pub fn ghostty_mouse_event_set_mods(event: MouseEvent, mods: Mods);
}
unsafe extern "C" {
#[doc = " Get keyboard modifiers held during the event.\n\n"]
pub fn ghostty_mouse_event_get_mods(event: MouseEvent) -> Mods;
}
unsafe extern "C" {
#[doc = " Set the event position in surface-space pixels.\n\n"]
pub fn ghostty_mouse_event_set_position(event: MouseEvent, position: MousePosition);
}
unsafe extern "C" {
#[doc = " Get the event position in surface-space pixels.\n\n"]
pub fn ghostty_mouse_event_get_position(event: MouseEvent) -> MousePosition;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MouseEncoderImpl {
_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"]
pub type MouseEncoder = *mut MouseEncoderImpl;
pub mod MouseTrackingMode {
#[doc = " Mouse tracking mode.\n"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Mouse reporting disabled."]
pub const NONE: Type = 0;
#[doc = " X10 mouse mode."]
pub const X10: Type = 1;
#[doc = " Normal mouse mode (button press/release only)."]
pub const NORMAL: Type = 2;
#[doc = " Button-event tracking mode."]
pub const BUTTON: Type = 3;
#[doc = " Any-event tracking mode."]
pub const ANY: Type = 4;
#[doc = " Any-event tracking mode."]
pub const MAX_VALUE: Type = 2147483647;
}
pub mod MouseFormat {
#[doc = " Mouse output format.\n"]
pub type Type = ::std::os::raw::c_uint;
pub const X10: Type = 0;
pub const UTF8: Type = 1;
pub const SGR: Type = 2;
pub const URXVT: Type = 3;
pub const SGR_PIXELS: Type = 4;
pub const 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"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct MouseEncoderSize {
#[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 MouseEncoderSize"][::std::mem::size_of::<MouseEncoderSize>() - 40usize];
["Alignment of MouseEncoderSize"][::std::mem::align_of::<MouseEncoderSize>() - 8usize];
["Offset of field: MouseEncoderSize::size"]
[::std::mem::offset_of!(MouseEncoderSize, size) - 0usize];
["Offset of field: MouseEncoderSize::screen_width"]
[::std::mem::offset_of!(MouseEncoderSize, screen_width) - 8usize];
["Offset of field: MouseEncoderSize::screen_height"]
[::std::mem::offset_of!(MouseEncoderSize, screen_height) - 12usize];
["Offset of field: MouseEncoderSize::cell_width"]
[::std::mem::offset_of!(MouseEncoderSize, cell_width) - 16usize];
["Offset of field: MouseEncoderSize::cell_height"]
[::std::mem::offset_of!(MouseEncoderSize, cell_height) - 20usize];
["Offset of field: MouseEncoderSize::padding_top"]
[::std::mem::offset_of!(MouseEncoderSize, padding_top) - 24usize];
["Offset of field: MouseEncoderSize::padding_bottom"]
[::std::mem::offset_of!(MouseEncoderSize, padding_bottom) - 28usize];
["Offset of field: MouseEncoderSize::padding_right"]
[::std::mem::offset_of!(MouseEncoderSize, padding_right) - 32usize];
["Offset of field: MouseEncoderSize::padding_left"]
[::std::mem::offset_of!(MouseEncoderSize, padding_left) - 36usize];
};
pub mod MouseEncoderOption {
#[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"]
pub type Type = ::std::os::raw::c_uint;
#[doc = " Mouse tracking mode (value: GhosttyMouseTrackingMode)."]
pub const EVENT: Type = 0;
#[doc = " Mouse output format (value: GhosttyMouseFormat)."]
pub const FORMAT: Type = 1;
#[doc = " Renderer size context (value: GhosttyMouseEncoderSize)."]
pub const SIZE: Type = 2;
#[doc = " Whether any mouse button is currently pressed (value: bool)."]
pub const ANY_BUTTON_PRESSED: Type = 3;
#[doc = " Whether to enable motion deduplication by last cell (value: bool)."]
pub const TRACK_LAST_CELL: Type = 4;
#[doc = " Whether to enable motion deduplication by last cell (value: bool)."]
pub const MAX_VALUE: Type = 2147483647;
}
unsafe extern "C" {
#[doc = " Create a new mouse encoder instance.\n\n"]
pub fn ghostty_mouse_encoder_new(
allocator: *const Allocator,
encoder: *mut MouseEncoder,
) -> Result::Type;
}
unsafe extern "C" {
#[doc = " Free a mouse encoder instance.\n\n"]
pub fn ghostty_mouse_encoder_free(encoder: MouseEncoder);
}
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"]
pub fn ghostty_mouse_encoder_setopt(
encoder: MouseEncoder,
option: MouseEncoderOption::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"]
pub fn ghostty_mouse_encoder_setopt_from_terminal(encoder: MouseEncoder, terminal: Terminal);
}
unsafe extern "C" {
#[doc = " Reset internal encoder state.\n\n This clears motion deduplication state (last tracked cell).\n\n"]
pub fn ghostty_mouse_encoder_reset(encoder: MouseEncoder);
}
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 or another error code\n"]
pub fn ghostty_mouse_encoder_encode(
encoder: MouseEncoder,
event: MouseEvent,
out_buf: *mut ::std::os::raw::c_char,
out_buf_size: usize,
out_len: *mut usize,
) -> Result::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 - Newlines (`\\n`) which can inject commands\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.\n"]
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 GHOSTTY_OUT_OF_SPACE, the required buffer size.\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,
) -> Result::Type;
}