1pub const ENUM_MAX_VALUE: u32 = 2147483647;
4pub const COLOR_NAMED_BLACK: u8 = 0;
5pub const COLOR_NAMED_RED: u8 = 1;
6pub const COLOR_NAMED_GREEN: u8 = 2;
7pub const COLOR_NAMED_YELLOW: u8 = 3;
8pub const COLOR_NAMED_BLUE: u8 = 4;
9pub const COLOR_NAMED_MAGENTA: u8 = 5;
10pub const COLOR_NAMED_CYAN: u8 = 6;
11pub const COLOR_NAMED_WHITE: u8 = 7;
12pub const COLOR_NAMED_BRIGHT_BLACK: u8 = 8;
13pub const COLOR_NAMED_BRIGHT_RED: u8 = 9;
14pub const COLOR_NAMED_BRIGHT_GREEN: u8 = 10;
15pub const COLOR_NAMED_BRIGHT_YELLOW: u8 = 11;
16pub const COLOR_NAMED_BRIGHT_BLUE: u8 = 12;
17pub const COLOR_NAMED_BRIGHT_MAGENTA: u8 = 13;
18pub const COLOR_NAMED_BRIGHT_CYAN: u8 = 14;
19pub const COLOR_NAMED_BRIGHT_WHITE: u8 = 15;
20pub const DA_CONFORMANCE_VT100: u16 = 1;
21pub const DA_CONFORMANCE_VT101: u16 = 1;
22pub const DA_CONFORMANCE_VT102: u16 = 6;
23pub const DA_CONFORMANCE_VT125: u16 = 12;
24pub const DA_CONFORMANCE_VT131: u16 = 7;
25pub const DA_CONFORMANCE_VT132: u16 = 4;
26pub const DA_CONFORMANCE_VT220: u16 = 62;
27pub const DA_CONFORMANCE_VT240: u16 = 62;
28pub const DA_CONFORMANCE_VT320: u16 = 63;
29pub const DA_CONFORMANCE_VT340: u16 = 63;
30pub const DA_CONFORMANCE_VT420: u16 = 64;
31pub const DA_CONFORMANCE_VT510: u16 = 65;
32pub const DA_CONFORMANCE_VT520: u16 = 65;
33pub const DA_CONFORMANCE_VT525: u16 = 65;
34pub const DA_CONFORMANCE_LEVEL_2: u16 = 62;
35pub const DA_CONFORMANCE_LEVEL_3: u16 = 63;
36pub const DA_CONFORMANCE_LEVEL_4: u16 = 64;
37pub const DA_CONFORMANCE_LEVEL_5: u16 = 65;
38pub const DA_FEATURE_COLUMNS_132: u16 = 1;
39pub const DA_FEATURE_PRINTER: u16 = 2;
40pub const DA_FEATURE_REGIS: u16 = 3;
41pub const DA_FEATURE_SIXEL: u16 = 4;
42pub const DA_FEATURE_SELECTIVE_ERASE: u16 = 6;
43pub const DA_FEATURE_USER_DEFINED_KEYS: u16 = 8;
44pub const DA_FEATURE_NATIONAL_REPLACEMENT: u16 = 9;
45pub const DA_FEATURE_TECHNICAL_CHARACTERS: u16 = 15;
46pub const DA_FEATURE_LOCATOR: u16 = 16;
47pub const DA_FEATURE_TERMINAL_STATE: u16 = 17;
48pub const DA_FEATURE_WINDOWING: u16 = 18;
49pub const DA_FEATURE_HORIZONTAL_SCROLLING: u16 = 21;
50pub const DA_FEATURE_ANSI_COLOR: u16 = 22;
51pub const DA_FEATURE_RECTANGULAR_EDITING: u16 = 28;
52pub const DA_FEATURE_ANSI_TEXT_LOCATOR: u16 = 29;
53pub const DA_FEATURE_CLIPBOARD: u16 = 52;
54pub const DA_DEVICE_TYPE_VT100: u16 = 0;
55pub const DA_DEVICE_TYPE_VT220: u16 = 1;
56pub const DA_DEVICE_TYPE_VT240: u16 = 2;
57pub const DA_DEVICE_TYPE_VT330: u16 = 18;
58pub const DA_DEVICE_TYPE_VT340: u16 = 19;
59pub const DA_DEVICE_TYPE_VT320: u16 = 24;
60pub const DA_DEVICE_TYPE_VT382: u16 = 32;
61pub const DA_DEVICE_TYPE_VT420: u16 = 41;
62pub const DA_DEVICE_TYPE_VT510: u16 = 61;
63pub const DA_DEVICE_TYPE_VT520: u16 = 64;
64pub const DA_DEVICE_TYPE_VT525: u16 = 65;
65pub const MODS_SHIFT: u16 = 1;
66pub const MODS_CTRL: u16 = 2;
67pub const MODS_ALT: u16 = 4;
68pub const MODS_SUPER: u16 = 8;
69pub const MODS_CAPS_LOCK: u16 = 16;
70pub const MODS_NUM_LOCK: u16 = 32;
71pub const MODS_SHIFT_SIDE: u16 = 64;
72pub const MODS_CTRL_SIDE: u16 = 128;
73pub const MODS_ALT_SIDE: u16 = 256;
74pub const MODS_SUPER_SIDE: u16 = 512;
75pub const KITTY_KEY_DISABLED: u8 = 0;
76pub const KITTY_KEY_DISAMBIGUATE: u8 = 1;
77pub const KITTY_KEY_REPORT_EVENTS: u8 = 2;
78pub const KITTY_KEY_REPORT_ALTERNATES: u8 = 4;
79pub const KITTY_KEY_REPORT_ALL: u8 = 8;
80pub const KITTY_KEY_REPORT_ASSOCIATED: u8 = 16;
81pub const KITTY_KEY_ALL: u8 = 31;
82pub mod Result {
83 #[doc = " Result codes for libghostty-vt operations."]
84 pub type Type = ::std::os::raw::c_int;
85 #[doc = " Operation completed successfully"]
86 pub const SUCCESS: Type = 0;
87 #[doc = " Operation failed due to failed allocation"]
88 pub const OUT_OF_MEMORY: Type = -1;
89 #[doc = " Operation failed due to invalid value"]
90 pub const INVALID_VALUE: Type = -2;
91 #[doc = " Operation failed because the provided buffer was too small"]
92 pub const OUT_OF_SPACE: Type = -3;
93 #[doc = " The requested value has no value"]
94 pub const NO_VALUE: Type = -4;
95 #[doc = " The requested value has no value"]
96 pub const RESULT_MAX_VALUE: Type = 2147483647;
97}
98#[repr(C)]
99#[derive(Debug, Copy, Clone)]
100pub struct TerminalImpl {
101 _unused: [u8; 0],
102}
103#[doc = " Opaque handle to a terminal instance.\n"]
104pub type Terminal = *mut TerminalImpl;
105#[repr(C)]
106#[derive(Debug, Copy, Clone)]
107pub struct TrackedGridRefImpl {
108 _unused: [u8; 0],
109}
110#[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"]
111pub type TrackedGridRef = *mut TrackedGridRefImpl;
112#[repr(C)]
113#[derive(Debug, Copy, Clone)]
114pub struct KittyGraphicsImpl {
115 _unused: [u8; 0],
116}
117#[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"]
118pub type KittyGraphics = *mut KittyGraphicsImpl;
119#[repr(C)]
120#[derive(Debug, Copy, Clone)]
121pub struct KittyGraphicsImageImpl {
122 _unused: [u8; 0],
123}
124#[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"]
125pub type KittyGraphicsImage = *const KittyGraphicsImageImpl;
126#[repr(C)]
127#[derive(Debug, Copy, Clone)]
128pub struct KittyGraphicsPlacementIteratorImpl {
129 _unused: [u8; 0],
130}
131#[doc = " Opaque handle to a Kitty graphics placement iterator.\n"]
132pub type KittyGraphicsPlacementIterator = *mut KittyGraphicsPlacementIteratorImpl;
133#[repr(C)]
134#[derive(Debug, Copy, Clone)]
135pub struct RenderStateImpl {
136 _unused: [u8; 0],
137}
138#[doc = " Opaque handle to a render state instance.\n"]
139pub type RenderState = *mut RenderStateImpl;
140#[repr(C)]
141#[derive(Debug, Copy, Clone)]
142pub struct RenderStateRowIteratorImpl {
143 _unused: [u8; 0],
144}
145#[doc = " Opaque handle to a render-state row iterator.\n"]
146pub type RenderStateRowIterator = *mut RenderStateRowIteratorImpl;
147#[repr(C)]
148#[derive(Debug, Copy, Clone)]
149pub struct RenderStateRowCellsImpl {
150 _unused: [u8; 0],
151}
152#[doc = " Opaque handle to render-state row cells.\n"]
153pub type RenderStateRowCells = *mut RenderStateRowCellsImpl;
154#[repr(C)]
155#[derive(Debug, Copy, Clone)]
156pub struct SgrParserImpl {
157 _unused: [u8; 0],
158}
159#[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"]
160pub type SgrParser = *mut SgrParserImpl;
161#[repr(C)]
162#[derive(Debug, Copy, Clone)]
163pub struct FormatterImpl {
164 _unused: [u8; 0],
165}
166#[doc = " Opaque handle to a formatter instance.\n"]
167pub type Formatter = *mut FormatterImpl;
168#[repr(C)]
169#[derive(Debug, Copy, Clone)]
170pub struct OscParserImpl {
171 _unused: [u8; 0],
172}
173#[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"]
174pub type OscParser = *mut OscParserImpl;
175#[repr(C)]
176#[derive(Debug, Copy, Clone)]
177pub struct OscCommandImpl {
178 _unused: [u8; 0],
179}
180#[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"]
181pub type OscCommand = *mut OscCommandImpl;
182pub mod FormatterFormat {
183 #[doc = " Terminal content output format.\n"]
184 pub type Type = ::std::os::raw::c_uint;
185 #[doc = " Plain text (no escape sequences)."]
186 pub const PLAIN: Type = 0;
187 #[doc = " VT sequences preserving colors, styles, URLs, etc."]
188 pub const VT: Type = 1;
189 #[doc = " HTML with inline styles."]
190 pub const HTML: Type = 2;
191 #[doc = " HTML with inline styles."]
192 pub const MAX_VALUE: Type = 2147483647;
193}
194#[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."]
195#[repr(C)]
196#[derive(Debug, Copy, Clone)]
197pub struct String {
198 #[doc = " Pointer to the string bytes."]
199 pub ptr: *const u8,
200 #[doc = " Length of the string in bytes."]
201 pub len: usize,
202}
203#[allow(clippy::unnecessary_operation, clippy::identity_op)]
204const _: () = {
205 ["Size of String"][::std::mem::size_of::<String>() - 16usize];
206 ["Alignment of String"][::std::mem::align_of::<String>() - 8usize];
207 ["Offset of field: String::ptr"][::std::mem::offset_of!(String, ptr) - 0usize];
208 ["Offset of field: String::len"][::std::mem::offset_of!(String, len) - 8usize];
209};
210impl Default for String {
211 fn default() -> Self {
212 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
213 unsafe {
214 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
215 s.assume_init()
216 }
217 }
218}
219#[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."]
220#[repr(C)]
221#[derive(Debug, Copy, Clone)]
222pub struct Buffer {
223 #[doc = " Destination buffer for bytes. May be NULL when cap is 0 to query required size."]
224 pub ptr: *mut u8,
225 #[doc = " Capacity of ptr in bytes."]
226 pub cap: usize,
227 #[doc = " Bytes written on success, or required byte capacity on GHOSTTY_OUT_OF_SPACE."]
228 pub len: usize,
229}
230#[allow(clippy::unnecessary_operation, clippy::identity_op)]
231const _: () = {
232 ["Size of Buffer"][::std::mem::size_of::<Buffer>() - 24usize];
233 ["Alignment of Buffer"][::std::mem::align_of::<Buffer>() - 8usize];
234 ["Offset of field: Buffer::ptr"][::std::mem::offset_of!(Buffer, ptr) - 0usize];
235 ["Offset of field: Buffer::cap"][::std::mem::offset_of!(Buffer, cap) - 8usize];
236 ["Offset of field: Buffer::len"][::std::mem::offset_of!(Buffer, len) - 16usize];
237};
238impl Default for Buffer {
239 fn default() -> Self {
240 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
241 unsafe {
242 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
243 s.assume_init()
244 }
245 }
246}
247#[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."]
248#[repr(C)]
249#[derive(Debug, Default, Copy, Clone)]
250pub struct SurfacePosition {
251 #[doc = " X position in surface pixels."]
252 pub x: f64,
253 #[doc = " Y position in surface pixels."]
254 pub y: f64,
255}
256#[allow(clippy::unnecessary_operation, clippy::identity_op)]
257const _: () = {
258 ["Size of SurfacePosition"][::std::mem::size_of::<SurfacePosition>() - 16usize];
259 ["Alignment of SurfacePosition"][::std::mem::align_of::<SurfacePosition>() - 8usize];
260 ["Offset of field: SurfacePosition::x"][::std::mem::offset_of!(SurfacePosition, x) - 0usize];
261 ["Offset of field: SurfacePosition::y"][::std::mem::offset_of!(SurfacePosition, y) - 8usize];
262};
263#[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”."]
264#[repr(C)]
265#[derive(Debug, Copy, Clone)]
266pub struct Codepoints {
267 #[doc = " Pointer to Unicode scalar values."]
268 pub ptr: *const u32,
269 #[doc = " Number of entries in ptr."]
270 pub len: usize,
271}
272#[allow(clippy::unnecessary_operation, clippy::identity_op)]
273const _: () = {
274 ["Size of Codepoints"][::std::mem::size_of::<Codepoints>() - 16usize];
275 ["Alignment of Codepoints"][::std::mem::align_of::<Codepoints>() - 8usize];
276 ["Offset of field: Codepoints::ptr"][::std::mem::offset_of!(Codepoints, ptr) - 0usize];
277 ["Offset of field: Codepoints::len"][::std::mem::offset_of!(Codepoints, len) - 8usize];
278};
279impl Default for Codepoints {
280 fn default() -> Self {
281 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
282 unsafe {
283 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
284 s.assume_init()
285 }
286 }
287}
288unsafe extern "C" {
289 #[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"]
290 pub fn ghostty_type_json() -> *const ::std::os::raw::c_char;
291}
292#[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."]
293#[repr(C)]
294#[derive(Debug, Default, Copy, Clone)]
295pub struct AllocatorVtable {
296 #[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."]
297 pub alloc: ::std::option::Option<
298 unsafe extern "C" fn(
299 ctx: *mut ::std::os::raw::c_void,
300 len: usize,
301 alignment: u8,
302 ret_addr: usize,
303 ) -> *mut ::std::os::raw::c_void,
304 >,
305 #[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"]
306 pub resize: ::std::option::Option<
307 unsafe extern "C" fn(
308 ctx: *mut ::std::os::raw::c_void,
309 memory: *mut ::std::os::raw::c_void,
310 memory_len: usize,
311 alignment: u8,
312 new_len: usize,
313 ret_addr: usize,
314 ) -> bool,
315 >,
316 #[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"]
317 pub remap: ::std::option::Option<
318 unsafe extern "C" fn(
319 ctx: *mut ::std::os::raw::c_void,
320 memory: *mut ::std::os::raw::c_void,
321 memory_len: usize,
322 alignment: u8,
323 new_len: usize,
324 ret_addr: usize,
325 ) -> *mut ::std::os::raw::c_void,
326 >,
327 #[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"]
328 pub free: ::std::option::Option<
329 unsafe extern "C" fn(
330 ctx: *mut ::std::os::raw::c_void,
331 memory: *mut ::std::os::raw::c_void,
332 memory_len: usize,
333 alignment: u8,
334 ret_addr: usize,
335 ),
336 >,
337}
338#[allow(clippy::unnecessary_operation, clippy::identity_op)]
339const _: () = {
340 ["Size of AllocatorVtable"][::std::mem::size_of::<AllocatorVtable>() - 32usize];
341 ["Alignment of AllocatorVtable"][::std::mem::align_of::<AllocatorVtable>() - 8usize];
342 ["Offset of field: AllocatorVtable::alloc"]
343 [::std::mem::offset_of!(AllocatorVtable, alloc) - 0usize];
344 ["Offset of field: AllocatorVtable::resize"]
345 [::std::mem::offset_of!(AllocatorVtable, resize) - 8usize];
346 ["Offset of field: AllocatorVtable::remap"]
347 [::std::mem::offset_of!(AllocatorVtable, remap) - 16usize];
348 ["Offset of field: AllocatorVtable::free"]
349 [::std::mem::offset_of!(AllocatorVtable, free) - 24usize];
350};
351#[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 };"]
352#[repr(C)]
353#[derive(Debug, Copy, Clone)]
354pub struct Allocator {
355 #[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."]
356 pub ctx: *mut ::std::os::raw::c_void,
357 #[doc = " Pointer to the allocator's vtable containing function pointers\n for memory operations (alloc, resize, remap, free)."]
358 pub vtable: *const AllocatorVtable,
359}
360#[allow(clippy::unnecessary_operation, clippy::identity_op)]
361const _: () = {
362 ["Size of Allocator"][::std::mem::size_of::<Allocator>() - 16usize];
363 ["Alignment of Allocator"][::std::mem::align_of::<Allocator>() - 8usize];
364 ["Offset of field: Allocator::ctx"][::std::mem::offset_of!(Allocator, ctx) - 0usize];
365 ["Offset of field: Allocator::vtable"][::std::mem::offset_of!(Allocator, vtable) - 8usize];
366};
367impl Default for Allocator {
368 fn default() -> Self {
369 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
370 unsafe {
371 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
372 s.assume_init()
373 }
374 }
375}
376unsafe extern "C" {
377 #[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"]
378 pub fn ghostty_alloc(allocator: *const Allocator, len: usize) -> *mut u8;
379}
380unsafe extern "C" {
381 #[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"]
382 pub fn ghostty_free(allocator: *const Allocator, ptr: *mut u8, len: usize);
383}
384pub mod OptimizeMode {
385 #[doc = " Build optimization mode."]
386 pub type Type = ::std::os::raw::c_uint;
387 pub const DEBUG: Type = 0;
388 pub const RELEASE_SAFE: Type = 1;
389 pub const RELEASE_SMALL: Type = 2;
390 pub const RELEASE_FAST: Type = 3;
391 pub const MODE_MAX_VALUE: Type = 2147483647;
392}
393pub mod BuildInfo {
394 #[doc = " Build info data types that can be queried.\n\n Each variant documents the expected output pointer type."]
395 pub type Type = ::std::os::raw::c_uint;
396 #[doc = " Invalid data type. Never results in any data extraction."]
397 pub const INVALID: Type = 0;
398 #[doc = " Whether SIMD-accelerated code paths are enabled.\n\n Output type: bool *"]
399 pub const SIMD: Type = 1;
400 #[doc = " Whether Kitty graphics protocol support is available.\n\n Output type: bool *"]
401 pub const KITTY_GRAPHICS: Type = 2;
402 #[doc = " Whether tmux control mode support is available.\n\n Output type: bool *"]
403 pub const TMUX_CONTROL_MODE: Type = 3;
404 #[doc = " The optimization mode the library was built with.\n\n Output type: GhosttyOptimizeMode *"]
405 pub const OPTIMIZE: Type = 4;
406 #[doc = " The full version string (e.g. \"1.2.3\" or \"1.2.3-dev+abcdef\").\n\n Output type: GhosttyString *"]
407 pub const VERSION_STRING: Type = 5;
408 #[doc = " The major version number.\n\n Output type: size_t *"]
409 pub const VERSION_MAJOR: Type = 6;
410 #[doc = " The minor version number.\n\n Output type: size_t *"]
411 pub const VERSION_MINOR: Type = 7;
412 #[doc = " The patch version number.\n\n Output type: size_t *"]
413 pub const VERSION_PATCH: Type = 8;
414 #[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 *"]
415 pub const VERSION_PRE: Type = 9;
416 #[doc = " The build metadata string (e.g. commit hash). Has zero length if\n no build metadata is present.\n\n Output type: GhosttyString *"]
417 pub const VERSION_BUILD: Type = 10;
418 #[doc = " The build metadata string (e.g. commit hash). Has zero length if\n no build metadata is present.\n\n Output type: GhosttyString *"]
419 pub const MAX_VALUE: Type = 2147483647;
420}
421unsafe extern "C" {
422 #[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"]
423 pub fn ghostty_build_info(
424 data: BuildInfo::Type,
425 out: *mut ::std::os::raw::c_void,
426 ) -> Result::Type;
427}
428#[doc = " RGB color value.\n"]
429#[repr(C)]
430#[derive(Debug, Default, Copy, Clone)]
431pub struct ColorRgb {
432 #[doc = "< Red component (0-255)"]
433 pub r: u8,
434 #[doc = "< Green component (0-255)"]
435 pub g: u8,
436 #[doc = "< Blue component (0-255)"]
437 pub b: u8,
438}
439#[allow(clippy::unnecessary_operation, clippy::identity_op)]
440const _: () = {
441 ["Size of ColorRgb"][::std::mem::size_of::<ColorRgb>() - 3usize];
442 ["Alignment of ColorRgb"][::std::mem::align_of::<ColorRgb>() - 1usize];
443 ["Offset of field: ColorRgb::r"][::std::mem::offset_of!(ColorRgb, r) - 0usize];
444 ["Offset of field: ColorRgb::g"][::std::mem::offset_of!(ColorRgb, g) - 1usize];
445 ["Offset of field: ColorRgb::b"][::std::mem::offset_of!(ColorRgb, b) - 2usize];
446};
447#[doc = " Palette color index (0-255).\n"]
448pub type ColorPaletteIndex = u8;
449unsafe extern "C" {
450 #[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"]
451 pub fn ghostty_color_rgb_get(color: ColorRgb, r: *mut u8, g: *mut u8, b: *mut u8);
452}
453pub mod ColorScheme {
454 #[doc = " Color scheme reported in response to a CSI ? 996 n query.\n"]
455 pub type Type = ::std::os::raw::c_uint;
456 pub const LIGHT: Type = 0;
457 pub const DARK: Type = 1;
458 pub const MAX_VALUE: Type = 2147483647;
459}
460#[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"]
461#[repr(C)]
462#[derive(Debug, Copy, Clone)]
463pub struct DeviceAttributesPrimary {
464 #[doc = " Conformance level (Pp parameter). E.g. 62 for VT220."]
465 pub conformance_level: u16,
466 #[doc = " DA1 feature codes. Only the first num_features entries are valid."]
467 pub features: [u16; 64usize],
468 #[doc = " Number of valid entries in the features array."]
469 pub num_features: usize,
470}
471#[allow(clippy::unnecessary_operation, clippy::identity_op)]
472const _: () = {
473 ["Size of DeviceAttributesPrimary"]
474 [::std::mem::size_of::<DeviceAttributesPrimary>() - 144usize];
475 ["Alignment of DeviceAttributesPrimary"]
476 [::std::mem::align_of::<DeviceAttributesPrimary>() - 8usize];
477 ["Offset of field: DeviceAttributesPrimary::conformance_level"]
478 [::std::mem::offset_of!(DeviceAttributesPrimary, conformance_level) - 0usize];
479 ["Offset of field: DeviceAttributesPrimary::features"]
480 [::std::mem::offset_of!(DeviceAttributesPrimary, features) - 2usize];
481 ["Offset of field: DeviceAttributesPrimary::num_features"]
482 [::std::mem::offset_of!(DeviceAttributesPrimary, num_features) - 136usize];
483};
484impl Default for DeviceAttributesPrimary {
485 fn default() -> Self {
486 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
487 unsafe {
488 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
489 s.assume_init()
490 }
491 }
492}
493#[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"]
494#[repr(C)]
495#[derive(Debug, Default, Copy, Clone)]
496pub struct DeviceAttributesSecondary {
497 #[doc = " Terminal type identifier (Pp). E.g. 1 for VT220."]
498 pub device_type: u16,
499 #[doc = " Firmware/patch version number (Pv)."]
500 pub firmware_version: u16,
501 #[doc = " ROM cartridge registration number (Pc). Always 0 for emulators."]
502 pub rom_cartridge: u16,
503}
504#[allow(clippy::unnecessary_operation, clippy::identity_op)]
505const _: () = {
506 ["Size of DeviceAttributesSecondary"]
507 [::std::mem::size_of::<DeviceAttributesSecondary>() - 6usize];
508 ["Alignment of DeviceAttributesSecondary"]
509 [::std::mem::align_of::<DeviceAttributesSecondary>() - 2usize];
510 ["Offset of field: DeviceAttributesSecondary::device_type"]
511 [::std::mem::offset_of!(DeviceAttributesSecondary, device_type) - 0usize];
512 ["Offset of field: DeviceAttributesSecondary::firmware_version"]
513 [::std::mem::offset_of!(DeviceAttributesSecondary, firmware_version) - 2usize];
514 ["Offset of field: DeviceAttributesSecondary::rom_cartridge"]
515 [::std::mem::offset_of!(DeviceAttributesSecondary, rom_cartridge) - 4usize];
516};
517#[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"]
518#[repr(C)]
519#[derive(Debug, Default, Copy, Clone)]
520pub struct DeviceAttributesTertiary {
521 #[doc = " Unit ID encoded as 8 uppercase hex digits in the response."]
522 pub unit_id: u32,
523}
524#[allow(clippy::unnecessary_operation, clippy::identity_op)]
525const _: () = {
526 ["Size of DeviceAttributesTertiary"]
527 [::std::mem::size_of::<DeviceAttributesTertiary>() - 4usize];
528 ["Alignment of DeviceAttributesTertiary"]
529 [::std::mem::align_of::<DeviceAttributesTertiary>() - 4usize];
530 ["Offset of field: DeviceAttributesTertiary::unit_id"]
531 [::std::mem::offset_of!(DeviceAttributesTertiary, unit_id) - 0usize];
532};
533#[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"]
534#[repr(C)]
535#[derive(Debug, Copy, Clone)]
536pub struct DeviceAttributes {
537 pub primary: DeviceAttributesPrimary,
538 pub secondary: DeviceAttributesSecondary,
539 pub tertiary: DeviceAttributesTertiary,
540}
541#[allow(clippy::unnecessary_operation, clippy::identity_op)]
542const _: () = {
543 ["Size of DeviceAttributes"][::std::mem::size_of::<DeviceAttributes>() - 160usize];
544 ["Alignment of DeviceAttributes"][::std::mem::align_of::<DeviceAttributes>() - 8usize];
545 ["Offset of field: DeviceAttributes::primary"]
546 [::std::mem::offset_of!(DeviceAttributes, primary) - 0usize];
547 ["Offset of field: DeviceAttributes::secondary"]
548 [::std::mem::offset_of!(DeviceAttributes, secondary) - 144usize];
549 ["Offset of field: DeviceAttributes::tertiary"]
550 [::std::mem::offset_of!(DeviceAttributes, tertiary) - 152usize];
551};
552impl Default for DeviceAttributes {
553 fn default() -> Self {
554 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
555 unsafe {
556 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
557 s.assume_init()
558 }
559 }
560}
561pub mod FocusEvent {
562 #[doc = " Focus event types for focus reporting mode (mode 1004)."]
563 pub type Type = ::std::os::raw::c_uint;
564 #[doc = " Terminal window gained focus"]
565 pub const GAINED: Type = 0;
566 #[doc = " Terminal window lost focus"]
567 pub const LOST: Type = 1;
568 #[doc = " Terminal window lost focus"]
569 pub const MAX_VALUE: Type = 2147483647;
570}
571unsafe extern "C" {
572 #[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"]
573 pub fn ghostty_focus_encode(
574 event: FocusEvent::Type,
575 buf: *mut ::std::os::raw::c_char,
576 buf_len: usize,
577 out_written: *mut usize,
578 ) -> Result::Type;
579}
580#[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"]
581pub type Cell = u64;
582#[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"]
583pub type Row = u64;
584pub mod CellContentTag {
585 #[doc = " Cell content tag.\n\n Describes what kind of content a cell holds.\n"]
586 pub type Type = ::std::os::raw::c_uint;
587 #[doc = " A single codepoint (may be zero for empty)."]
588 pub const CODEPOINT: Type = 0;
589 #[doc = " A codepoint that is part of a multi-codepoint grapheme cluster."]
590 pub const CODEPOINT_GRAPHEME: Type = 1;
591 #[doc = " No text; background color from palette."]
592 pub const BG_COLOR_PALETTE: Type = 2;
593 #[doc = " No text; background color as RGB."]
594 pub const BG_COLOR_RGB: Type = 3;
595 #[doc = " No text; background color as RGB."]
596 pub const TAG_MAX_VALUE: Type = 2147483647;
597}
598pub mod CellWide {
599 #[doc = " Cell wide property.\n\n Describes the width behavior of a cell.\n"]
600 pub type Type = ::std::os::raw::c_uint;
601 #[doc = " Not a wide character, cell width 1."]
602 pub const NARROW: Type = 0;
603 #[doc = " Wide character, cell width 2."]
604 pub const WIDE: Type = 1;
605 #[doc = " Spacer after wide character. Do not render."]
606 pub const SPACER_TAIL: Type = 2;
607 #[doc = " Spacer at end of soft-wrapped line for a wide character."]
608 pub const SPACER_HEAD: Type = 3;
609 #[doc = " Spacer at end of soft-wrapped line for a wide character."]
610 pub const MAX_VALUE: Type = 2147483647;
611}
612pub mod CellSemanticContent {
613 #[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"]
614 pub type Type = ::std::os::raw::c_uint;
615 #[doc = " Regular output content, such as command output."]
616 pub const OUTPUT: Type = 0;
617 #[doc = " Content that is part of user input."]
618 pub const INPUT: Type = 1;
619 #[doc = " Content that is part of a shell prompt."]
620 pub const PROMPT: Type = 2;
621 #[doc = " Content that is part of a shell prompt."]
622 pub const MAX_VALUE: Type = 2147483647;
623}
624pub mod CellData {
625 #[doc = " Cell data types.\n\n These values specify what type of data to extract from a cell\n using `ghostty_cell_get`.\n"]
626 pub type Type = ::std::os::raw::c_uint;
627 #[doc = " Invalid data type. Never results in any data extraction."]
628 pub const INVALID: Type = 0;
629 #[doc = " The codepoint of the cell (0 if empty or bg-color-only).\n\n Output type: uint32_t *"]
630 pub const CODEPOINT: Type = 1;
631 #[doc = " The content tag describing what kind of content is in the cell.\n\n Output type: GhosttyCellContentTag *"]
632 pub const CONTENT_TAG: Type = 2;
633 #[doc = " The wide property of the cell.\n\n Output type: GhosttyCellWide *"]
634 pub const WIDE: Type = 3;
635 #[doc = " Whether the cell has text to render.\n\n Output type: bool *"]
636 pub const HAS_TEXT: Type = 4;
637 #[doc = " Whether the cell has non-default styling.\n\n Output type: bool *"]
638 pub const HAS_STYLING: Type = 5;
639 #[doc = " The style ID for the cell (for use with style lookups).\n\n Output type: uint16_t *"]
640 pub const STYLE_ID: Type = 6;
641 #[doc = " Whether the cell has a hyperlink.\n\n Output type: bool *"]
642 pub const HAS_HYPERLINK: Type = 7;
643 #[doc = " Whether the cell is protected.\n\n Output type: bool *"]
644 pub const PROTECTED: Type = 8;
645 #[doc = " The semantic content type of the cell (from OSC 133).\n\n Output type: GhosttyCellSemanticContent *"]
646 pub const SEMANTIC_CONTENT: Type = 9;
647 #[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 *"]
648 pub const COLOR_PALETTE: Type = 10;
649 #[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 *"]
650 pub const COLOR_RGB: Type = 11;
651 #[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 *"]
652 pub const MAX_VALUE: Type = 2147483647;
653}
654pub mod RowSemanticPrompt {
655 #[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"]
656 pub type Type = ::std::os::raw::c_uint;
657 #[doc = " No prompt cells in this row."]
658 pub const NONE: Type = 0;
659 #[doc = " Prompt cells exist and this is a primary prompt line."]
660 pub const PROMPT: Type = 1;
661 #[doc = " Prompt cells exist and this is a continuation line."]
662 pub const PROMPT_CONTINUATION: Type = 2;
663 #[doc = " Prompt cells exist and this is a continuation line."]
664 pub const MAX_VALUE: Type = 2147483647;
665}
666pub mod RowData {
667 #[doc = " Row data types.\n\n These values specify what type of data to extract from a row\n using `ghostty_row_get`.\n"]
668 pub type Type = ::std::os::raw::c_uint;
669 #[doc = " Invalid data type. Never results in any data extraction."]
670 pub const INVALID: Type = 0;
671 #[doc = " Whether this row is soft-wrapped.\n\n Output type: bool *"]
672 pub const WRAP: Type = 1;
673 #[doc = " Whether this row is a continuation of a soft-wrapped row.\n\n Output type: bool *"]
674 pub const WRAP_CONTINUATION: Type = 2;
675 #[doc = " Whether any cells in this row have grapheme clusters.\n\n Output type: bool *"]
676 pub const GRAPHEME: Type = 3;
677 #[doc = " Whether any cells in this row have styling (may have false positives).\n\n Output type: bool *"]
678 pub const STYLED: Type = 4;
679 #[doc = " Whether any cells in this row have hyperlinks (may have false positives).\n\n Output type: bool *"]
680 pub const HYPERLINK: Type = 5;
681 #[doc = " The semantic prompt state of this row.\n\n Output type: GhosttyRowSemanticPrompt *"]
682 pub const SEMANTIC_PROMPT: Type = 6;
683 #[doc = " Whether this row contains a Kitty virtual placeholder.\n\n Output type: bool *"]
684 pub const KITTY_VIRTUAL_PLACEHOLDER: Type = 7;
685 #[doc = " Whether this row is dirty and requires a redraw.\n\n Output type: bool *"]
686 pub const DIRTY: Type = 8;
687 #[doc = " Whether this row is dirty and requires a redraw.\n\n Output type: bool *"]
688 pub const MAX_VALUE: Type = 2147483647;
689}
690unsafe extern "C" {
691 #[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"]
692 pub fn ghostty_cell_get(
693 cell: Cell,
694 data: CellData::Type,
695 out: *mut ::std::os::raw::c_void,
696 ) -> Result::Type;
697}
698unsafe extern "C" {
699 #[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"]
700 pub fn ghostty_cell_get_multi(
701 cell: Cell,
702 count: usize,
703 keys: *const CellData::Type,
704 values: *mut *mut ::std::os::raw::c_void,
705 out_written: *mut usize,
706 ) -> Result::Type;
707}
708unsafe extern "C" {
709 #[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"]
710 pub fn ghostty_row_get(
711 row: Row,
712 data: RowData::Type,
713 out: *mut ::std::os::raw::c_void,
714 ) -> Result::Type;
715}
716unsafe extern "C" {
717 #[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"]
718 pub fn ghostty_row_get_multi(
719 row: Row,
720 count: usize,
721 keys: *const RowData::Type,
722 values: *mut *mut ::std::os::raw::c_void,
723 out_written: *mut usize,
724 ) -> Result::Type;
725}
726#[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"]
727pub type StyleId = u16;
728pub mod StyleColorTag {
729 #[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"]
730 pub type Type = ::std::os::raw::c_uint;
731 pub const NONE: Type = 0;
732 pub const PALETTE: Type = 1;
733 pub const RGB: Type = 2;
734 pub const TAG_MAX_VALUE: Type = 2147483647;
735}
736#[doc = " Style color value union.\n\n Use the tag to determine which field is active.\n"]
737#[repr(C)]
738#[derive(Copy, Clone)]
739pub union StyleColorValue {
740 pub palette: ColorPaletteIndex,
741 pub rgb: ColorRgb,
742 pub _padding: u64,
743}
744#[allow(clippy::unnecessary_operation, clippy::identity_op)]
745const _: () = {
746 ["Size of StyleColorValue"][::std::mem::size_of::<StyleColorValue>() - 8usize];
747 ["Alignment of StyleColorValue"][::std::mem::align_of::<StyleColorValue>() - 8usize];
748 ["Offset of field: StyleColorValue::palette"]
749 [::std::mem::offset_of!(StyleColorValue, palette) - 0usize];
750 ["Offset of field: StyleColorValue::rgb"]
751 [::std::mem::offset_of!(StyleColorValue, rgb) - 0usize];
752 ["Offset of field: StyleColorValue::_padding"]
753 [::std::mem::offset_of!(StyleColorValue, _padding) - 0usize];
754};
755impl Default for StyleColorValue {
756 fn default() -> Self {
757 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
758 unsafe {
759 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
760 s.assume_init()
761 }
762 }
763}
764#[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"]
765#[repr(C)]
766#[derive(Copy, Clone)]
767pub struct StyleColor {
768 pub tag: StyleColorTag::Type,
769 pub value: StyleColorValue,
770}
771#[allow(clippy::unnecessary_operation, clippy::identity_op)]
772const _: () = {
773 ["Size of StyleColor"][::std::mem::size_of::<StyleColor>() - 16usize];
774 ["Alignment of StyleColor"][::std::mem::align_of::<StyleColor>() - 8usize];
775 ["Offset of field: StyleColor::tag"][::std::mem::offset_of!(StyleColor, tag) - 0usize];
776 ["Offset of field: StyleColor::value"][::std::mem::offset_of!(StyleColor, value) - 8usize];
777};
778impl Default for StyleColor {
779 fn default() -> Self {
780 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
781 unsafe {
782 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
783 s.assume_init()
784 }
785 }
786}
787#[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"]
788#[repr(C)]
789#[derive(Copy, Clone)]
790pub struct Style {
791 pub size: usize,
792 pub fg_color: StyleColor,
793 pub bg_color: StyleColor,
794 pub underline_color: StyleColor,
795 pub bold: bool,
796 pub italic: bool,
797 pub faint: bool,
798 pub blink: bool,
799 pub inverse: bool,
800 pub invisible: bool,
801 pub strikethrough: bool,
802 pub overline: bool,
803 #[doc = "< One of GHOSTTY_SGR_UNDERLINE_* values"]
804 pub underline: ::std::os::raw::c_int,
805}
806#[allow(clippy::unnecessary_operation, clippy::identity_op)]
807const _: () = {
808 ["Size of Style"][::std::mem::size_of::<Style>() - 72usize];
809 ["Alignment of Style"][::std::mem::align_of::<Style>() - 8usize];
810 ["Offset of field: Style::size"][::std::mem::offset_of!(Style, size) - 0usize];
811 ["Offset of field: Style::fg_color"][::std::mem::offset_of!(Style, fg_color) - 8usize];
812 ["Offset of field: Style::bg_color"][::std::mem::offset_of!(Style, bg_color) - 24usize];
813 ["Offset of field: Style::underline_color"]
814 [::std::mem::offset_of!(Style, underline_color) - 40usize];
815 ["Offset of field: Style::bold"][::std::mem::offset_of!(Style, bold) - 56usize];
816 ["Offset of field: Style::italic"][::std::mem::offset_of!(Style, italic) - 57usize];
817 ["Offset of field: Style::faint"][::std::mem::offset_of!(Style, faint) - 58usize];
818 ["Offset of field: Style::blink"][::std::mem::offset_of!(Style, blink) - 59usize];
819 ["Offset of field: Style::inverse"][::std::mem::offset_of!(Style, inverse) - 60usize];
820 ["Offset of field: Style::invisible"][::std::mem::offset_of!(Style, invisible) - 61usize];
821 ["Offset of field: Style::strikethrough"]
822 [::std::mem::offset_of!(Style, strikethrough) - 62usize];
823 ["Offset of field: Style::overline"][::std::mem::offset_of!(Style, overline) - 63usize];
824 ["Offset of field: Style::underline"][::std::mem::offset_of!(Style, underline) - 64usize];
825};
826impl Default for Style {
827 fn default() -> Self {
828 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
829 unsafe {
830 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
831 s.assume_init()
832 }
833 }
834}
835unsafe extern "C" {
836 #[doc = " Get the default style.\n\n Initializes the style to the default values (no colors, no flags).\n\n"]
837 pub fn ghostty_style_default(style: *mut Style);
838}
839unsafe extern "C" {
840 #[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"]
841 pub fn ghostty_style_is_default(style: *const Style) -> bool;
842}
843#[doc = " A resolved reference to a terminal cell position.\n\n This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.\n"]
844#[repr(C)]
845#[derive(Debug, Copy, Clone)]
846pub struct GridRef {
847 pub size: usize,
848 pub node: *mut ::std::os::raw::c_void,
849 pub x: u16,
850 pub y: u16,
851}
852#[allow(clippy::unnecessary_operation, clippy::identity_op)]
853const _: () = {
854 ["Size of GridRef"][::std::mem::size_of::<GridRef>() - 24usize];
855 ["Alignment of GridRef"][::std::mem::align_of::<GridRef>() - 8usize];
856 ["Offset of field: GridRef::size"][::std::mem::offset_of!(GridRef, size) - 0usize];
857 ["Offset of field: GridRef::node"][::std::mem::offset_of!(GridRef, node) - 8usize];
858 ["Offset of field: GridRef::x"][::std::mem::offset_of!(GridRef, x) - 16usize];
859 ["Offset of field: GridRef::y"][::std::mem::offset_of!(GridRef, y) - 18usize];
860};
861impl Default for GridRef {
862 fn default() -> Self {
863 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
864 unsafe {
865 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
866 s.assume_init()
867 }
868 }
869}
870unsafe extern "C" {
871 #[doc = " Get the cell from a grid reference.\n\n node is NULL\n"]
872 pub fn ghostty_grid_ref_cell(ref_: *const GridRef, out_cell: *mut Cell) -> Result::Type;
873}
874unsafe extern "C" {
875 #[doc = " Get the row from a grid reference.\n\n node is NULL\n"]
876 pub fn ghostty_grid_ref_row(ref_: *const GridRef, out_row: *mut Row) -> Result::Type;
877}
878unsafe extern "C" {
879 #[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"]
880 pub fn ghostty_grid_ref_graphemes(
881 ref_: *const GridRef,
882 buf: *mut u32,
883 buf_len: usize,
884 out_len: *mut usize,
885 ) -> Result::Type;
886}
887unsafe extern "C" {
888 #[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"]
889 pub fn ghostty_grid_ref_hyperlink_uri(
890 ref_: *const GridRef,
891 buf: *mut u8,
892 buf_len: usize,
893 out_len: *mut usize,
894 ) -> Result::Type;
895}
896unsafe extern "C" {
897 #[doc = " Get the style of the cell at the grid reference's position.\n\n node is NULL\n"]
898 pub fn ghostty_grid_ref_style(ref_: *const GridRef, out_style: *mut Style) -> Result::Type;
899}
900#[doc = " A coordinate in the terminal grid.\n"]
901#[repr(C)]
902#[derive(Debug, Default, Copy, Clone)]
903pub struct PointCoordinate {
904 #[doc = " Column (0-indexed)."]
905 pub x: u16,
906 #[doc = " Row (0-indexed). May exceed page size for screen/history tags."]
907 pub y: u32,
908}
909#[allow(clippy::unnecessary_operation, clippy::identity_op)]
910const _: () = {
911 ["Size of PointCoordinate"][::std::mem::size_of::<PointCoordinate>() - 8usize];
912 ["Alignment of PointCoordinate"][::std::mem::align_of::<PointCoordinate>() - 4usize];
913 ["Offset of field: PointCoordinate::x"][::std::mem::offset_of!(PointCoordinate, x) - 0usize];
914 ["Offset of field: PointCoordinate::y"][::std::mem::offset_of!(PointCoordinate, y) - 4usize];
915};
916pub mod PointTag {
917 #[doc = " Point reference tag.\n\n Determines which coordinate system a point uses.\n"]
918 pub type Type = ::std::os::raw::c_uint;
919 #[doc = " Active area where the cursor can move."]
920 pub const ACTIVE: Type = 0;
921 #[doc = " Visible viewport (changes when scrolled)."]
922 pub const VIEWPORT: Type = 1;
923 #[doc = " Full screen including scrollback."]
924 pub const SCREEN: Type = 2;
925 #[doc = " Scrollback history only (before active area)."]
926 pub const HISTORY: Type = 3;
927 #[doc = " Scrollback history only (before active area)."]
928 pub const MAX_VALUE: Type = 2147483647;
929}
930#[doc = " Point value union.\n"]
931#[repr(C)]
932#[derive(Copy, Clone)]
933pub union PointValue {
934 #[doc = " Coordinate (used for all tag variants)."]
935 pub coordinate: PointCoordinate,
936 #[doc = " Padding for ABI compatibility. Do not use."]
937 pub _padding: [u64; 2usize],
938}
939#[allow(clippy::unnecessary_operation, clippy::identity_op)]
940const _: () = {
941 ["Size of PointValue"][::std::mem::size_of::<PointValue>() - 16usize];
942 ["Alignment of PointValue"][::std::mem::align_of::<PointValue>() - 8usize];
943 ["Offset of field: PointValue::coordinate"]
944 [::std::mem::offset_of!(PointValue, coordinate) - 0usize];
945 ["Offset of field: PointValue::_padding"]
946 [::std::mem::offset_of!(PointValue, _padding) - 0usize];
947};
948impl Default for PointValue {
949 fn default() -> Self {
950 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
951 unsafe {
952 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
953 s.assume_init()
954 }
955 }
956}
957#[doc = " Tagged union for a point in the terminal grid.\n"]
958#[repr(C)]
959#[derive(Copy, Clone)]
960pub struct Point {
961 pub tag: PointTag::Type,
962 pub value: PointValue,
963}
964#[allow(clippy::unnecessary_operation, clippy::identity_op)]
965const _: () = {
966 ["Size of Point"][::std::mem::size_of::<Point>() - 24usize];
967 ["Alignment of Point"][::std::mem::align_of::<Point>() - 8usize];
968 ["Offset of field: Point::tag"][::std::mem::offset_of!(Point, tag) - 0usize];
969 ["Offset of field: Point::value"][::std::mem::offset_of!(Point, value) - 8usize];
970};
971impl Default for Point {
972 fn default() -> Self {
973 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
974 unsafe {
975 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
976 s.assume_init()
977 }
978 }
979}
980#[repr(C)]
981#[derive(Debug, Copy, Clone)]
982pub struct SelectionGestureImpl {
983 _unused: [u8; 0],
984}
985#[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"]
986pub type SelectionGesture = *mut SelectionGestureImpl;
987#[repr(C)]
988#[derive(Debug, Copy, Clone)]
989pub struct SelectionGestureEventImpl {
990 _unused: [u8; 0],
991}
992#[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"]
993pub type SelectionGestureEvent = *mut SelectionGestureEventImpl;
994#[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"]
995#[repr(C)]
996#[derive(Debug, Copy, Clone)]
997pub struct Selection {
998 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttySelection)."]
999 pub size: usize,
1000 #[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."]
1001 pub start: GridRef,
1002 #[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."]
1003 pub end: GridRef,
1004 #[doc = " Whether the endpoints are interpreted as a rectangular/block selection\n rather than a linear selection."]
1005 pub rectangle: bool,
1006}
1007#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1008const _: () = {
1009 ["Size of Selection"][::std::mem::size_of::<Selection>() - 64usize];
1010 ["Alignment of Selection"][::std::mem::align_of::<Selection>() - 8usize];
1011 ["Offset of field: Selection::size"][::std::mem::offset_of!(Selection, size) - 0usize];
1012 ["Offset of field: Selection::start"][::std::mem::offset_of!(Selection, start) - 8usize];
1013 ["Offset of field: Selection::end"][::std::mem::offset_of!(Selection, end) - 32usize];
1014 ["Offset of field: Selection::rectangle"]
1015 [::std::mem::offset_of!(Selection, rectangle) - 56usize];
1016};
1017impl Default for Selection {
1018 fn default() -> Self {
1019 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
1020 unsafe {
1021 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1022 s.assume_init()
1023 }
1024 }
1025}
1026#[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"]
1027#[repr(C)]
1028#[derive(Debug, Copy, Clone)]
1029pub struct TerminalSelectWordOptions {
1030 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectWordOptions)."]
1031 pub size: usize,
1032 #[doc = " Grid reference under which to derive the word selection."]
1033 pub ref_: GridRef,
1034 #[doc = " Optional word-boundary codepoints as uint32_t scalar values."]
1035 pub boundary_codepoints: *const u32,
1036 #[doc = " Number of entries in boundary_codepoints."]
1037 pub boundary_codepoints_len: usize,
1038}
1039#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1040const _: () = {
1041 ["Size of TerminalSelectWordOptions"]
1042 [::std::mem::size_of::<TerminalSelectWordOptions>() - 48usize];
1043 ["Alignment of TerminalSelectWordOptions"]
1044 [::std::mem::align_of::<TerminalSelectWordOptions>() - 8usize];
1045 ["Offset of field: TerminalSelectWordOptions::size"]
1046 [::std::mem::offset_of!(TerminalSelectWordOptions, size) - 0usize];
1047 ["Offset of field: TerminalSelectWordOptions::ref_"]
1048 [::std::mem::offset_of!(TerminalSelectWordOptions, ref_) - 8usize];
1049 ["Offset of field: TerminalSelectWordOptions::boundary_codepoints"]
1050 [::std::mem::offset_of!(TerminalSelectWordOptions, boundary_codepoints) - 32usize];
1051 ["Offset of field: TerminalSelectWordOptions::boundary_codepoints_len"]
1052 [::std::mem::offset_of!(TerminalSelectWordOptions, boundary_codepoints_len) - 40usize];
1053};
1054impl Default for TerminalSelectWordOptions {
1055 fn default() -> Self {
1056 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
1057 unsafe {
1058 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1059 s.assume_init()
1060 }
1061 }
1062}
1063#[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"]
1064#[repr(C)]
1065#[derive(Debug, Copy, Clone)]
1066pub struct TerminalSelectWordBetweenOptions {
1067 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectWordBetweenOptions)."]
1068 pub size: usize,
1069 #[doc = " Starting grid reference for the inclusive search range."]
1070 pub start: GridRef,
1071 #[doc = " Ending grid reference for the inclusive search range."]
1072 pub end: GridRef,
1073 #[doc = " Optional word-boundary codepoints as uint32_t scalar values."]
1074 pub boundary_codepoints: *const u32,
1075 #[doc = " Number of entries in boundary_codepoints."]
1076 pub boundary_codepoints_len: usize,
1077}
1078#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1079const _: () = {
1080 ["Size of TerminalSelectWordBetweenOptions"]
1081 [::std::mem::size_of::<TerminalSelectWordBetweenOptions>() - 72usize];
1082 ["Alignment of TerminalSelectWordBetweenOptions"]
1083 [::std::mem::align_of::<TerminalSelectWordBetweenOptions>() - 8usize];
1084 ["Offset of field: TerminalSelectWordBetweenOptions::size"]
1085 [::std::mem::offset_of!(TerminalSelectWordBetweenOptions, size) - 0usize];
1086 ["Offset of field: TerminalSelectWordBetweenOptions::start"]
1087 [::std::mem::offset_of!(TerminalSelectWordBetweenOptions, start) - 8usize];
1088 ["Offset of field: TerminalSelectWordBetweenOptions::end"]
1089 [::std::mem::offset_of!(TerminalSelectWordBetweenOptions, end) - 32usize];
1090 ["Offset of field: TerminalSelectWordBetweenOptions::boundary_codepoints"]
1091 [::std::mem::offset_of!(TerminalSelectWordBetweenOptions, boundary_codepoints) - 56usize];
1092 ["Offset of field: TerminalSelectWordBetweenOptions::boundary_codepoints_len"][::std::mem::offset_of!(
1093 TerminalSelectWordBetweenOptions,
1094 boundary_codepoints_len
1095 ) - 64usize];
1096};
1097impl Default for TerminalSelectWordBetweenOptions {
1098 fn default() -> Self {
1099 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
1100 unsafe {
1101 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1102 s.assume_init()
1103 }
1104 }
1105}
1106#[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"]
1107#[repr(C)]
1108#[derive(Debug, Copy, Clone)]
1109pub struct TerminalSelectLineOptions {
1110 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectLineOptions)."]
1111 pub size: usize,
1112 #[doc = " Grid reference under which to derive the line selection."]
1113 pub ref_: GridRef,
1114 #[doc = " Optional codepoints to trim from the start and end of the line."]
1115 pub whitespace: *const u32,
1116 #[doc = " Number of entries in whitespace."]
1117 pub whitespace_len: usize,
1118 #[doc = " Whether semantic prompt state changes should bound the line selection."]
1119 pub semantic_prompt_boundary: bool,
1120}
1121#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1122const _: () = {
1123 ["Size of TerminalSelectLineOptions"]
1124 [::std::mem::size_of::<TerminalSelectLineOptions>() - 56usize];
1125 ["Alignment of TerminalSelectLineOptions"]
1126 [::std::mem::align_of::<TerminalSelectLineOptions>() - 8usize];
1127 ["Offset of field: TerminalSelectLineOptions::size"]
1128 [::std::mem::offset_of!(TerminalSelectLineOptions, size) - 0usize];
1129 ["Offset of field: TerminalSelectLineOptions::ref_"]
1130 [::std::mem::offset_of!(TerminalSelectLineOptions, ref_) - 8usize];
1131 ["Offset of field: TerminalSelectLineOptions::whitespace"]
1132 [::std::mem::offset_of!(TerminalSelectLineOptions, whitespace) - 32usize];
1133 ["Offset of field: TerminalSelectLineOptions::whitespace_len"]
1134 [::std::mem::offset_of!(TerminalSelectLineOptions, whitespace_len) - 40usize];
1135 ["Offset of field: TerminalSelectLineOptions::semantic_prompt_boundary"]
1136 [::std::mem::offset_of!(TerminalSelectLineOptions, semantic_prompt_boundary) - 48usize];
1137};
1138impl Default for TerminalSelectLineOptions {
1139 fn default() -> Self {
1140 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
1141 unsafe {
1142 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1143 s.assume_init()
1144 }
1145 }
1146}
1147#[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"]
1148#[repr(C)]
1149#[derive(Debug, Copy, Clone)]
1150pub struct TerminalSelectionFormatOptions {
1151 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectionFormatOptions)."]
1152 pub size: usize,
1153 #[doc = " Output format to emit."]
1154 pub emit: FormatterFormat::Type,
1155 #[doc = " Whether to unwrap soft-wrapped lines."]
1156 pub unwrap: bool,
1157 #[doc = " Whether to trim trailing whitespace on non-blank lines."]
1158 pub trim: bool,
1159 #[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."]
1160 pub selection: *const Selection,
1161}
1162#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1163const _: () = {
1164 ["Size of TerminalSelectionFormatOptions"]
1165 [::std::mem::size_of::<TerminalSelectionFormatOptions>() - 24usize];
1166 ["Alignment of TerminalSelectionFormatOptions"]
1167 [::std::mem::align_of::<TerminalSelectionFormatOptions>() - 8usize];
1168 ["Offset of field: TerminalSelectionFormatOptions::size"]
1169 [::std::mem::offset_of!(TerminalSelectionFormatOptions, size) - 0usize];
1170 ["Offset of field: TerminalSelectionFormatOptions::emit"]
1171 [::std::mem::offset_of!(TerminalSelectionFormatOptions, emit) - 8usize];
1172 ["Offset of field: TerminalSelectionFormatOptions::unwrap"]
1173 [::std::mem::offset_of!(TerminalSelectionFormatOptions, unwrap) - 12usize];
1174 ["Offset of field: TerminalSelectionFormatOptions::trim"]
1175 [::std::mem::offset_of!(TerminalSelectionFormatOptions, trim) - 13usize];
1176 ["Offset of field: TerminalSelectionFormatOptions::selection"]
1177 [::std::mem::offset_of!(TerminalSelectionFormatOptions, selection) - 16usize];
1178};
1179impl Default for TerminalSelectionFormatOptions {
1180 fn default() -> Self {
1181 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
1182 unsafe {
1183 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1184 s.assume_init()
1185 }
1186 }
1187}
1188pub mod SelectionOrder {
1189 #[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"]
1190 pub type Type = ::std::os::raw::c_uint;
1191 #[doc = " Start is before end in top-left to bottom-right order."]
1192 pub const FORWARD: Type = 0;
1193 #[doc = " End is before start in top-left to bottom-right order."]
1194 pub const REVERSE: Type = 1;
1195 #[doc = " Rectangular selection from top-right to bottom-left."]
1196 pub const MIRRORED_FORWARD: Type = 2;
1197 #[doc = " Rectangular selection from bottom-left to top-right."]
1198 pub const MIRRORED_REVERSE: Type = 3;
1199 #[doc = " Rectangular selection from bottom-left to top-right."]
1200 pub const MAX_VALUE: Type = 2147483647;
1201}
1202pub mod SelectionAdjust {
1203 #[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"]
1204 pub type Type = ::std::os::raw::c_uint;
1205 #[doc = " Move left to the previous non-empty cell, wrapping upward."]
1206 pub const LEFT: Type = 0;
1207 #[doc = " Move right to the next non-empty cell, wrapping downward."]
1208 pub const RIGHT: Type = 1;
1209 #[doc = " Move up one row at the current column, or to the beginning of the\n line if already at the top."]
1210 pub const UP: Type = 2;
1211 #[doc = " Move down to the next non-blank row at the current column, or to the\n end of the line if none exists."]
1212 pub const DOWN: Type = 3;
1213 #[doc = " Move to the top-left cell of the screen."]
1214 pub const HOME: Type = 4;
1215 #[doc = " Move to the right edge of the last non-blank row on the screen."]
1216 pub const END: Type = 5;
1217 #[doc = " Move up by one terminal page height, or to home if that would move\n past the top."]
1218 pub const PAGE_UP: Type = 6;
1219 #[doc = " Move down by one terminal page height, or to end if that would move\n past the bottom."]
1220 pub const PAGE_DOWN: Type = 7;
1221 #[doc = " Move to the left edge of the current line."]
1222 pub const BEGINNING_OF_LINE: Type = 8;
1223 #[doc = " Move to the right edge of the current line."]
1224 pub const END_OF_LINE: Type = 9;
1225 #[doc = " Move to the right edge of the current line."]
1226 pub const MAX_VALUE: Type = 2147483647;
1227}
1228pub mod SelectionGestureBehavior {
1229 #[doc = " Selection behavior chosen for a gesture's click sequence.\n"]
1230 pub type Type = ::std::os::raw::c_uint;
1231 #[doc = " Cell-granular drag selection."]
1232 pub const CELL: Type = 0;
1233 #[doc = " Word selection on press and word-granular drag selection."]
1234 pub const WORD: Type = 1;
1235 #[doc = " Line selection on press and line-granular drag selection."]
1236 pub const LINE: Type = 2;
1237 #[doc = " Semantic command output selection on press and drag."]
1238 pub const OUTPUT: Type = 3;
1239 #[doc = " Semantic command output selection on press and drag."]
1240 pub const MAX_VALUE: Type = 2147483647;
1241}
1242#[doc = " Selection behaviors for single-, double-, and triple-click gestures.\n"]
1243#[repr(C)]
1244#[derive(Debug, Copy, Clone)]
1245pub struct SelectionGestureBehaviors {
1246 #[doc = " Behavior for single-click selection gestures."]
1247 pub single_click: SelectionGestureBehavior::Type,
1248 #[doc = " Behavior for double-click selection gestures."]
1249 pub double_click: SelectionGestureBehavior::Type,
1250 #[doc = " Behavior for triple-click selection gestures."]
1251 pub triple_click: SelectionGestureBehavior::Type,
1252}
1253#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1254const _: () = {
1255 ["Size of SelectionGestureBehaviors"]
1256 [::std::mem::size_of::<SelectionGestureBehaviors>() - 12usize];
1257 ["Alignment of SelectionGestureBehaviors"]
1258 [::std::mem::align_of::<SelectionGestureBehaviors>() - 4usize];
1259 ["Offset of field: SelectionGestureBehaviors::single_click"]
1260 [::std::mem::offset_of!(SelectionGestureBehaviors, single_click) - 0usize];
1261 ["Offset of field: SelectionGestureBehaviors::double_click"]
1262 [::std::mem::offset_of!(SelectionGestureBehaviors, double_click) - 4usize];
1263 ["Offset of field: SelectionGestureBehaviors::triple_click"]
1264 [::std::mem::offset_of!(SelectionGestureBehaviors, triple_click) - 8usize];
1265};
1266impl Default for SelectionGestureBehaviors {
1267 fn default() -> Self {
1268 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
1269 unsafe {
1270 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1271 s.assume_init()
1272 }
1273 }
1274}
1275#[doc = " Display geometry used to interpret selection gesture drag events.\n"]
1276#[repr(C)]
1277#[derive(Debug, Default, Copy, Clone)]
1278pub struct SelectionGestureGeometry {
1279 #[doc = " Number of columns in the rendered terminal grid. Must be non-zero."]
1280 pub columns: u32,
1281 #[doc = " Width of one terminal cell in surface pixels. Must be non-zero."]
1282 pub cell_width: u32,
1283 #[doc = " Left padding before the terminal grid begins in surface pixels."]
1284 pub padding_left: u32,
1285 #[doc = " Height of the rendered terminal surface in surface pixels. Must be non-zero."]
1286 pub screen_height: u32,
1287}
1288#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1289const _: () = {
1290 ["Size of SelectionGestureGeometry"]
1291 [::std::mem::size_of::<SelectionGestureGeometry>() - 16usize];
1292 ["Alignment of SelectionGestureGeometry"]
1293 [::std::mem::align_of::<SelectionGestureGeometry>() - 4usize];
1294 ["Offset of field: SelectionGestureGeometry::columns"]
1295 [::std::mem::offset_of!(SelectionGestureGeometry, columns) - 0usize];
1296 ["Offset of field: SelectionGestureGeometry::cell_width"]
1297 [::std::mem::offset_of!(SelectionGestureGeometry, cell_width) - 4usize];
1298 ["Offset of field: SelectionGestureGeometry::padding_left"]
1299 [::std::mem::offset_of!(SelectionGestureGeometry, padding_left) - 8usize];
1300 ["Offset of field: SelectionGestureGeometry::screen_height"]
1301 [::std::mem::offset_of!(SelectionGestureGeometry, screen_height) - 12usize];
1302};
1303pub mod SelectionGestureAutoscroll {
1304 #[doc = " Current autoscroll direction for an active selection drag gesture.\n"]
1305 pub type Type = ::std::os::raw::c_uint;
1306 #[doc = " No selection autoscroll is requested."]
1307 pub const NONE: Type = 0;
1308 #[doc = " Selection dragging should autoscroll the viewport upward."]
1309 pub const UP: Type = 1;
1310 #[doc = " Selection dragging should autoscroll the viewport downward."]
1311 pub const DOWN: Type = 2;
1312 #[doc = " Selection dragging should autoscroll the viewport downward."]
1313 pub const MAX_VALUE: Type = 2147483647;
1314}
1315pub mod SelectionGestureData {
1316 #[doc = " Data fields readable from a selection gesture with\n ghostty_selection_gesture_get().\n"]
1317 pub type Type = ::std::os::raw::c_uint;
1318 #[doc = " Current click count: uint8_t*. 0 means inactive."]
1319 pub const CLICK_COUNT: Type = 0;
1320 #[doc = " Whether the current/last left-click gesture has dragged: bool*."]
1321 pub const DRAGGED: Type = 1;
1322 #[doc = " Current autoscroll request: GhosttySelectionGestureAutoscroll*."]
1323 pub const AUTOSCROLL: Type = 2;
1324 #[doc = " Current gesture behavior: GhosttySelectionGestureBehavior*."]
1325 pub const BEHAVIOR: Type = 3;
1326 #[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."]
1327 pub const ANCHOR: Type = 4;
1328 #[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."]
1329 pub const MAX_VALUE: Type = 2147483647;
1330}
1331pub mod SelectionGestureEventType {
1332 #[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"]
1333 pub type Type = ::std::os::raw::c_uint;
1334 #[doc = " Press event for ghostty_selection_gesture_event()."]
1335 pub const PRESS: Type = 0;
1336 #[doc = " Release event for ghostty_selection_gesture_event()."]
1337 pub const RELEASE: Type = 1;
1338 #[doc = " Drag event for ghostty_selection_gesture_event()."]
1339 pub const DRAG: Type = 2;
1340 #[doc = " Autoscroll tick event for ghostty_selection_gesture_event()."]
1341 pub const AUTOSCROLL_TICK: Type = 3;
1342 #[doc = " Deep press event for ghostty_selection_gesture_event()."]
1343 pub const DEEP_PRESS: Type = 4;
1344 #[doc = " Deep press event for ghostty_selection_gesture_event()."]
1345 pub const MAX_VALUE: Type = 2147483647;
1346}
1347pub mod SelectionGestureEventOption {
1348 #[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"]
1349 pub type Type = ::std::os::raw::c_uint;
1350 #[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."]
1351 pub const REF: Type = 0;
1352 #[doc = " Surface-space pointer position: GhosttySurfacePosition*.\n\n Valid for PRESS, DRAG, and AUTOSCROLL_TICK."]
1353 pub const POSITION: Type = 1;
1354 #[doc = " Maximum repeat-click distance in pixels: double*."]
1355 pub const REPEAT_DISTANCE: Type = 2;
1356 #[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."]
1357 pub const TIME_NS: Type = 3;
1358 #[doc = " Maximum interval between repeat clicks in nanoseconds: uint64_t*."]
1359 pub const REPEAT_INTERVAL_NS: Type = 4;
1360 #[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."]
1361 pub const WORD_BOUNDARY_CODEPOINTS: Type = 5;
1362 #[doc = " Selection behavior table: GhosttySelectionGestureBehaviors*.\n\n If unset, press uses the default behavior table: cell, word, line."]
1363 pub const BEHAVIORS: Type = 6;
1364 #[doc = " Whether a drag or autoscroll tick should produce a rectangular selection: bool*."]
1365 pub const RECTANGLE: Type = 7;
1366 #[doc = " Drag display geometry: GhosttySelectionGestureGeometry*. Required for DRAG and AUTOSCROLL_TICK."]
1367 pub const GEOMETRY: Type = 8;
1368 #[doc = " Viewport coordinate for an autoscroll tick: GhosttyPointCoordinate*. Required for AUTOSCROLL_TICK."]
1369 pub const VIEWPORT: Type = 9;
1370 #[doc = " Viewport coordinate for an autoscroll tick: GhosttyPointCoordinate*. Required for AUTOSCROLL_TICK."]
1371 pub const MAX_VALUE: Type = 2147483647;
1372}
1373unsafe extern "C" {
1374 #[doc = " Create a reusable selection gesture event object.\n\n NULL or type is invalid, or GHOSTTY_OUT_OF_MEMORY if allocation fails\n"]
1375 pub fn ghostty_selection_gesture_event_new(
1376 allocator: *const Allocator,
1377 out_event: *mut SelectionGestureEvent,
1378 type_: SelectionGestureEventType::Type,
1379 ) -> Result::Type;
1380}
1381unsafe extern "C" {
1382 #[doc = " Free a selection gesture event object.\n\n Passing NULL is allowed and is a no-op.\n\n"]
1383 pub fn ghostty_selection_gesture_event_free(event: SelectionGestureEvent);
1384}
1385unsafe extern "C" {
1386 #[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"]
1387 pub fn ghostty_selection_gesture_event_set(
1388 event: SelectionGestureEvent,
1389 option: SelectionGestureEventOption::Type,
1390 value: *const ::std::os::raw::c_void,
1391 ) -> Result::Type;
1392}
1393unsafe extern "C" {
1394 #[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"]
1395 pub fn ghostty_selection_gesture_event(
1396 gesture: SelectionGesture,
1397 terminal: Terminal,
1398 event: SelectionGestureEvent,
1399 out_selection: *mut Selection,
1400 ) -> Result::Type;
1401}
1402unsafe extern "C" {
1403 #[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"]
1404 pub fn ghostty_selection_gesture_new(
1405 allocator: *const Allocator,
1406 out_gesture: *mut SelectionGesture,
1407 ) -> Result::Type;
1408}
1409unsafe extern "C" {
1410 #[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"]
1411 pub fn ghostty_selection_gesture_free(gesture: SelectionGesture, terminal: Terminal);
1412}
1413unsafe extern "C" {
1414 #[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"]
1415 pub fn ghostty_selection_gesture_reset(gesture: SelectionGesture, terminal: Terminal);
1416}
1417unsafe extern "C" {
1418 #[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"]
1419 pub fn ghostty_selection_gesture_get(
1420 gesture: SelectionGesture,
1421 terminal: Terminal,
1422 data: SelectionGestureData::Type,
1423 value: *mut ::std::os::raw::c_void,
1424 ) -> Result::Type;
1425}
1426unsafe extern "C" {
1427 #[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"]
1428 pub fn ghostty_selection_gesture_get_multi(
1429 gesture: SelectionGesture,
1430 terminal: Terminal,
1431 count: usize,
1432 keys: *const SelectionGestureData::Type,
1433 values: *mut *mut ::std::os::raw::c_void,
1434 out_written: *mut usize,
1435 ) -> Result::Type;
1436}
1437unsafe extern "C" {
1438 #[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"]
1439 pub fn ghostty_terminal_select_word(
1440 terminal: Terminal,
1441 options: *const TerminalSelectWordOptions,
1442 out_selection: *mut Selection,
1443 ) -> Result::Type;
1444}
1445unsafe extern "C" {
1446 #[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"]
1447 pub fn ghostty_terminal_select_word_between(
1448 terminal: Terminal,
1449 options: *const TerminalSelectWordBetweenOptions,
1450 out_selection: *mut Selection,
1451 ) -> Result::Type;
1452}
1453unsafe extern "C" {
1454 #[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"]
1455 pub fn ghostty_terminal_select_line(
1456 terminal: Terminal,
1457 options: *const TerminalSelectLineOptions,
1458 out_selection: *mut Selection,
1459 ) -> Result::Type;
1460}
1461unsafe extern "C" {
1462 #[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"]
1463 pub fn ghostty_terminal_select_all(
1464 terminal: Terminal,
1465 out_selection: *mut Selection,
1466 ) -> Result::Type;
1467}
1468unsafe extern "C" {
1469 #[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"]
1470 pub fn ghostty_terminal_select_output(
1471 terminal: Terminal,
1472 ref_: GridRef,
1473 out_selection: *mut Selection,
1474 ) -> Result::Type;
1475}
1476unsafe extern "C" {
1477 #[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"]
1478 pub fn ghostty_terminal_selection_format_buf(
1479 terminal: Terminal,
1480 options: TerminalSelectionFormatOptions,
1481 buf: *mut u8,
1482 buf_len: usize,
1483 out_written: *mut usize,
1484 ) -> Result::Type;
1485}
1486unsafe extern "C" {
1487 #[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"]
1488 pub fn ghostty_terminal_selection_format_alloc(
1489 terminal: Terminal,
1490 allocator: *const Allocator,
1491 options: TerminalSelectionFormatOptions,
1492 out_ptr: *mut *mut u8,
1493 out_len: *mut usize,
1494 ) -> Result::Type;
1495}
1496unsafe extern "C" {
1497 #[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"]
1498 pub fn ghostty_terminal_selection_adjust(
1499 terminal: Terminal,
1500 selection: *mut Selection,
1501 adjustment: SelectionAdjust::Type,
1502 ) -> Result::Type;
1503}
1504unsafe extern "C" {
1505 #[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"]
1506 pub fn ghostty_terminal_selection_order(
1507 terminal: Terminal,
1508 selection: *const Selection,
1509 out_order: *mut SelectionOrder::Type,
1510 ) -> Result::Type;
1511}
1512unsafe extern "C" {
1513 #[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"]
1514 pub fn ghostty_terminal_selection_ordered(
1515 terminal: Terminal,
1516 selection: *const Selection,
1517 desired: SelectionOrder::Type,
1518 out_selection: *mut Selection,
1519 ) -> Result::Type;
1520}
1521unsafe extern "C" {
1522 #[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"]
1523 pub fn ghostty_terminal_selection_contains(
1524 terminal: Terminal,
1525 selection: *const Selection,
1526 point: Point,
1527 out_contains: *mut bool,
1528 ) -> Result::Type;
1529}
1530unsafe extern "C" {
1531 #[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"]
1532 pub fn ghostty_terminal_selection_equal(
1533 terminal: Terminal,
1534 a: *const Selection,
1535 b: *const Selection,
1536 out_equal: *mut bool,
1537 ) -> Result::Type;
1538}
1539#[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."]
1540pub type Mode = u16;
1541pub mod ModeReportState {
1542 #[doc = " DECRPM report state values.\n\n These correspond to the Ps2 parameter in a DECRPM response\n sequence (CSI ? Ps1 ; Ps2 $ y)."]
1543 pub type Type = ::std::os::raw::c_uint;
1544 #[doc = " Mode is not recognized"]
1545 pub const NOT_RECOGNIZED: Type = 0;
1546 #[doc = " Mode is set (enabled)"]
1547 pub const SET: Type = 1;
1548 #[doc = " Mode is reset (disabled)"]
1549 pub const RESET: Type = 2;
1550 #[doc = " Mode is permanently set"]
1551 pub const PERMANENTLY_SET: Type = 3;
1552 #[doc = " Mode is permanently reset"]
1553 pub const PERMANENTLY_RESET: Type = 4;
1554 #[doc = " Mode is permanently reset"]
1555 pub const MAX_VALUE: Type = 2147483647;
1556}
1557unsafe extern "C" {
1558 #[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"]
1559 pub fn ghostty_mode_report_encode(
1560 mode: Mode,
1561 state: ModeReportState::Type,
1562 buf: *mut ::std::os::raw::c_char,
1563 buf_len: usize,
1564 out_written: *mut usize,
1565 ) -> Result::Type;
1566}
1567pub mod SizeReportStyle {
1568 #[doc = " Size report style.\n\n Determines the output format for the terminal size report."]
1569 pub type Type = ::std::os::raw::c_uint;
1570 #[doc = " In-band size report (mode 2048): ESC [ 48 ; rows ; cols ; height ; width t"]
1571 pub const MODE_2048: Type = 0;
1572 #[doc = " XTWINOPS text area size in pixels: ESC [ 4 ; height ; width t"]
1573 pub const CSI_14_T: Type = 1;
1574 #[doc = " XTWINOPS cell size in pixels: ESC [ 6 ; height ; width t"]
1575 pub const CSI_16_T: Type = 2;
1576 #[doc = " XTWINOPS text area size in characters: ESC [ 8 ; rows ; cols t"]
1577 pub const CSI_18_T: Type = 3;
1578 #[doc = " XTWINOPS text area size in characters: ESC [ 8 ; rows ; cols t"]
1579 pub const STYLE_MAX_VALUE: Type = 2147483647;
1580}
1581#[doc = " Terminal size information for encoding size reports."]
1582#[repr(C)]
1583#[derive(Debug, Default, Copy, Clone)]
1584pub struct SizeReportSize {
1585 #[doc = " Terminal row count in cells."]
1586 pub rows: u16,
1587 #[doc = " Terminal column count in cells."]
1588 pub columns: u16,
1589 #[doc = " Width of a single terminal cell in pixels."]
1590 pub cell_width: u32,
1591 #[doc = " Height of a single terminal cell in pixels."]
1592 pub cell_height: u32,
1593}
1594#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1595const _: () = {
1596 ["Size of SizeReportSize"][::std::mem::size_of::<SizeReportSize>() - 12usize];
1597 ["Alignment of SizeReportSize"][::std::mem::align_of::<SizeReportSize>() - 4usize];
1598 ["Offset of field: SizeReportSize::rows"]
1599 [::std::mem::offset_of!(SizeReportSize, rows) - 0usize];
1600 ["Offset of field: SizeReportSize::columns"]
1601 [::std::mem::offset_of!(SizeReportSize, columns) - 2usize];
1602 ["Offset of field: SizeReportSize::cell_width"]
1603 [::std::mem::offset_of!(SizeReportSize, cell_width) - 4usize];
1604 ["Offset of field: SizeReportSize::cell_height"]
1605 [::std::mem::offset_of!(SizeReportSize, cell_height) - 8usize];
1606};
1607unsafe extern "C" {
1608 #[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"]
1609 pub fn ghostty_size_report_encode(
1610 style: SizeReportStyle::Type,
1611 size: SizeReportSize,
1612 buf: *mut ::std::os::raw::c_char,
1613 buf_len: usize,
1614 out_written: *mut usize,
1615 ) -> Result::Type;
1616}
1617pub mod KittyGraphicsData {
1618 #[doc = " Queryable data kinds for ghostty_kitty_graphics_get().\n"]
1619 pub type Type = ::std::os::raw::c_uint;
1620 #[doc = " Invalid / sentinel value."]
1621 pub const INVALID: Type = 0;
1622 #[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 *"]
1623 pub const PLACEMENT_ITERATOR: Type = 1;
1624 #[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 *"]
1625 pub const MAX_VALUE: Type = 2147483647;
1626}
1627pub mod KittyGraphicsPlacementData {
1628 #[doc = " Queryable data kinds for ghostty_kitty_graphics_placement_get().\n"]
1629 pub type Type = ::std::os::raw::c_uint;
1630 #[doc = " Invalid / sentinel value."]
1631 pub const INVALID: Type = 0;
1632 #[doc = " The image ID this placement belongs to.\n\n Output type: uint32_t *"]
1633 pub const IMAGE_ID: Type = 1;
1634 #[doc = " The placement ID.\n\n Output type: uint32_t *"]
1635 pub const PLACEMENT_ID: Type = 2;
1636 #[doc = " Whether this is a virtual placement (unicode placeholder).\n\n Output type: bool *"]
1637 pub const IS_VIRTUAL: Type = 3;
1638 #[doc = " Pixel offset from the left edge of the cell.\n\n Output type: uint32_t *"]
1639 pub const X_OFFSET: Type = 4;
1640 #[doc = " Pixel offset from the top edge of the cell.\n\n Output type: uint32_t *"]
1641 pub const Y_OFFSET: Type = 5;
1642 #[doc = " Source rectangle x origin in pixels.\n\n Output type: uint32_t *"]
1643 pub const SOURCE_X: Type = 6;
1644 #[doc = " Source rectangle y origin in pixels.\n\n Output type: uint32_t *"]
1645 pub const SOURCE_Y: Type = 7;
1646 #[doc = " Source rectangle width in pixels (0 = full image width).\n\n Output type: uint32_t *"]
1647 pub const SOURCE_WIDTH: Type = 8;
1648 #[doc = " Source rectangle height in pixels (0 = full image height).\n\n Output type: uint32_t *"]
1649 pub const SOURCE_HEIGHT: Type = 9;
1650 #[doc = " Number of columns this placement occupies.\n\n Output type: uint32_t *"]
1651 pub const COLUMNS: Type = 10;
1652 #[doc = " Number of rows this placement occupies.\n\n Output type: uint32_t *"]
1653 pub const ROWS: Type = 11;
1654 #[doc = " Z-index for this placement.\n\n Output type: int32_t *"]
1655 pub const Z: Type = 12;
1656 #[doc = " Z-index for this placement.\n\n Output type: int32_t *"]
1657 pub const MAX_VALUE: Type = 2147483647;
1658}
1659pub mod KittyPlacementLayer {
1660 #[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"]
1661 pub type Type = ::std::os::raw::c_uint;
1662 pub const ALL: Type = 0;
1663 pub const BELOW_BG: Type = 1;
1664 pub const BELOW_TEXT: Type = 2;
1665 pub const ABOVE_TEXT: Type = 3;
1666 pub const MAX_VALUE: Type = 2147483647;
1667}
1668pub mod KittyGraphicsPlacementIteratorOption {
1669 #[doc = " Settable options for ghostty_kitty_graphics_placement_iterator_set().\n"]
1670 pub type Type = ::std::os::raw::c_uint;
1671 #[doc = " Set the z-layer filter for the iterator.\n\n Input type: GhosttyKittyPlacementLayer *"]
1672 pub const LAYER: Type = 0;
1673 #[doc = " Set the z-layer filter for the iterator.\n\n Input type: GhosttyKittyPlacementLayer *"]
1674 pub const MAX_VALUE: Type = 2147483647;
1675}
1676pub mod KittyImageFormat {
1677 #[doc = " Pixel format of a Kitty graphics image.\n"]
1678 pub type Type = ::std::os::raw::c_uint;
1679 pub const RGB: Type = 0;
1680 pub const RGBA: Type = 1;
1681 pub const PNG: Type = 2;
1682 pub const GRAY_ALPHA: Type = 3;
1683 pub const GRAY: Type = 4;
1684 pub const MAX_VALUE: Type = 2147483647;
1685}
1686pub mod KittyImageCompression {
1687 #[doc = " Compression of a Kitty graphics image.\n"]
1688 pub type Type = ::std::os::raw::c_uint;
1689 pub const NONE: Type = 0;
1690 pub const ZLIB_DEFLATE: Type = 1;
1691 pub const MAX_VALUE: Type = 2147483647;
1692}
1693pub mod KittyGraphicsImageData {
1694 #[doc = " Queryable data kinds for ghostty_kitty_graphics_image_get().\n"]
1695 pub type Type = ::std::os::raw::c_uint;
1696 #[doc = " Invalid / sentinel value."]
1697 pub const INVALID: Type = 0;
1698 #[doc = " The image ID.\n\n Output type: uint32_t *"]
1699 pub const ID: Type = 1;
1700 #[doc = " The image number.\n\n Output type: uint32_t *"]
1701 pub const NUMBER: Type = 2;
1702 #[doc = " Image width in pixels.\n\n Output type: uint32_t *"]
1703 pub const WIDTH: Type = 3;
1704 #[doc = " Image height in pixels.\n\n Output type: uint32_t *"]
1705 pub const HEIGHT: Type = 4;
1706 #[doc = " Pixel format of the image.\n\n Output type: GhosttyKittyImageFormat *"]
1707 pub const FORMAT: Type = 5;
1708 #[doc = " Compression of the image.\n\n Output type: GhosttyKittyImageCompression *"]
1709 pub const COMPRESSION: Type = 6;
1710 #[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 **"]
1711 pub const DATA_PTR: Type = 7;
1712 #[doc = " Length of the raw pixel data in bytes.\n\n Output type: size_t *"]
1713 pub const DATA_LEN: Type = 8;
1714 #[doc = " Length of the raw pixel data in bytes.\n\n Output type: size_t *"]
1715 pub const MAX_VALUE: Type = 2147483647;
1716}
1717#[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"]
1718#[repr(C)]
1719#[derive(Debug, Default, Copy, Clone)]
1720pub struct KittyGraphicsPlacementRenderInfo {
1721 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyKittyGraphicsPlacementRenderInfo)."]
1722 pub size: usize,
1723 #[doc = " Rendered width in pixels."]
1724 pub pixel_width: u32,
1725 #[doc = " Rendered height in pixels."]
1726 pub pixel_height: u32,
1727 #[doc = " Number of grid columns the placement occupies."]
1728 pub grid_cols: u32,
1729 #[doc = " Number of grid rows the placement occupies."]
1730 pub grid_rows: u32,
1731 #[doc = " Viewport-relative column (may be negative for partially visible placements)."]
1732 pub viewport_col: i32,
1733 #[doc = " Viewport-relative row (may be negative for partially visible placements)."]
1734 pub viewport_row: i32,
1735 #[doc = " False when the placement is fully off-screen or virtual."]
1736 pub viewport_visible: bool,
1737 #[doc = " Resolved source rectangle x origin in pixels."]
1738 pub source_x: u32,
1739 #[doc = " Resolved source rectangle y origin in pixels."]
1740 pub source_y: u32,
1741 #[doc = " Resolved source rectangle width in pixels."]
1742 pub source_width: u32,
1743 #[doc = " Resolved source rectangle height in pixels."]
1744 pub source_height: u32,
1745}
1746#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1747const _: () = {
1748 ["Size of KittyGraphicsPlacementRenderInfo"]
1749 [::std::mem::size_of::<KittyGraphicsPlacementRenderInfo>() - 56usize];
1750 ["Alignment of KittyGraphicsPlacementRenderInfo"]
1751 [::std::mem::align_of::<KittyGraphicsPlacementRenderInfo>() - 8usize];
1752 ["Offset of field: KittyGraphicsPlacementRenderInfo::size"]
1753 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, size) - 0usize];
1754 ["Offset of field: KittyGraphicsPlacementRenderInfo::pixel_width"]
1755 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, pixel_width) - 8usize];
1756 ["Offset of field: KittyGraphicsPlacementRenderInfo::pixel_height"]
1757 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, pixel_height) - 12usize];
1758 ["Offset of field: KittyGraphicsPlacementRenderInfo::grid_cols"]
1759 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, grid_cols) - 16usize];
1760 ["Offset of field: KittyGraphicsPlacementRenderInfo::grid_rows"]
1761 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, grid_rows) - 20usize];
1762 ["Offset of field: KittyGraphicsPlacementRenderInfo::viewport_col"]
1763 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, viewport_col) - 24usize];
1764 ["Offset of field: KittyGraphicsPlacementRenderInfo::viewport_row"]
1765 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, viewport_row) - 28usize];
1766 ["Offset of field: KittyGraphicsPlacementRenderInfo::viewport_visible"]
1767 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, viewport_visible) - 32usize];
1768 ["Offset of field: KittyGraphicsPlacementRenderInfo::source_x"]
1769 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, source_x) - 36usize];
1770 ["Offset of field: KittyGraphicsPlacementRenderInfo::source_y"]
1771 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, source_y) - 40usize];
1772 ["Offset of field: KittyGraphicsPlacementRenderInfo::source_width"]
1773 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, source_width) - 44usize];
1774 ["Offset of field: KittyGraphicsPlacementRenderInfo::source_height"]
1775 [::std::mem::offset_of!(KittyGraphicsPlacementRenderInfo, source_height) - 48usize];
1776};
1777unsafe extern "C" {
1778 #[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"]
1779 pub fn ghostty_kitty_graphics_get(
1780 graphics: KittyGraphics,
1781 data: KittyGraphicsData::Type,
1782 out: *mut ::std::os::raw::c_void,
1783 ) -> Result::Type;
1784}
1785unsafe extern "C" {
1786 #[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"]
1787 pub fn ghostty_kitty_graphics_image(
1788 graphics: KittyGraphics,
1789 image_id: u32,
1790 ) -> KittyGraphicsImage;
1791}
1792unsafe extern "C" {
1793 #[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"]
1794 pub fn ghostty_kitty_graphics_image_get(
1795 image: KittyGraphicsImage,
1796 data: KittyGraphicsImageData::Type,
1797 out: *mut ::std::os::raw::c_void,
1798 ) -> Result::Type;
1799}
1800unsafe extern "C" {
1801 #[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"]
1802 pub fn ghostty_kitty_graphics_image_get_multi(
1803 image: KittyGraphicsImage,
1804 count: usize,
1805 keys: *const KittyGraphicsImageData::Type,
1806 values: *mut *mut ::std::os::raw::c_void,
1807 out_written: *mut usize,
1808 ) -> Result::Type;
1809}
1810unsafe extern "C" {
1811 #[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"]
1812 pub fn ghostty_kitty_graphics_placement_iterator_new(
1813 allocator: *const Allocator,
1814 out_iterator: *mut KittyGraphicsPlacementIterator,
1815 ) -> Result::Type;
1816}
1817unsafe extern "C" {
1818 #[doc = " Free a placement iterator.\n\n"]
1819 pub fn ghostty_kitty_graphics_placement_iterator_free(iterator: KittyGraphicsPlacementIterator);
1820}
1821unsafe extern "C" {
1822 #[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"]
1823 pub fn ghostty_kitty_graphics_placement_iterator_set(
1824 iterator: KittyGraphicsPlacementIterator,
1825 option: KittyGraphicsPlacementIteratorOption::Type,
1826 value: *const ::std::os::raw::c_void,
1827 ) -> Result::Type;
1828}
1829unsafe extern "C" {
1830 #[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"]
1831 pub fn ghostty_kitty_graphics_placement_next(iterator: KittyGraphicsPlacementIterator) -> bool;
1832}
1833unsafe extern "C" {
1834 #[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"]
1835 pub fn ghostty_kitty_graphics_placement_get(
1836 iterator: KittyGraphicsPlacementIterator,
1837 data: KittyGraphicsPlacementData::Type,
1838 out: *mut ::std::os::raw::c_void,
1839 ) -> Result::Type;
1840}
1841unsafe extern "C" {
1842 #[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"]
1843 pub fn ghostty_kitty_graphics_placement_get_multi(
1844 iterator: KittyGraphicsPlacementIterator,
1845 count: usize,
1846 keys: *const KittyGraphicsPlacementData::Type,
1847 values: *mut *mut ::std::os::raw::c_void,
1848 out_written: *mut usize,
1849 ) -> Result::Type;
1850}
1851unsafe extern "C" {
1852 #[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"]
1853 pub fn ghostty_kitty_graphics_placement_rect(
1854 iterator: KittyGraphicsPlacementIterator,
1855 image: KittyGraphicsImage,
1856 terminal: Terminal,
1857 out_selection: *mut Selection,
1858 ) -> Result::Type;
1859}
1860unsafe extern "C" {
1861 #[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"]
1862 pub fn ghostty_kitty_graphics_placement_pixel_size(
1863 iterator: KittyGraphicsPlacementIterator,
1864 image: KittyGraphicsImage,
1865 terminal: Terminal,
1866 out_width: *mut u32,
1867 out_height: *mut u32,
1868 ) -> Result::Type;
1869}
1870unsafe extern "C" {
1871 #[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"]
1872 pub fn ghostty_kitty_graphics_placement_grid_size(
1873 iterator: KittyGraphicsPlacementIterator,
1874 image: KittyGraphicsImage,
1875 terminal: Terminal,
1876 out_cols: *mut u32,
1877 out_rows: *mut u32,
1878 ) -> Result::Type;
1879}
1880unsafe extern "C" {
1881 #[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"]
1882 pub fn ghostty_kitty_graphics_placement_viewport_pos(
1883 iterator: KittyGraphicsPlacementIterator,
1884 image: KittyGraphicsImage,
1885 terminal: Terminal,
1886 out_col: *mut i32,
1887 out_row: *mut i32,
1888 ) -> Result::Type;
1889}
1890unsafe extern "C" {
1891 #[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"]
1892 pub fn ghostty_kitty_graphics_placement_source_rect(
1893 iterator: KittyGraphicsPlacementIterator,
1894 image: KittyGraphicsImage,
1895 out_x: *mut u32,
1896 out_y: *mut u32,
1897 out_width: *mut u32,
1898 out_height: *mut u32,
1899 ) -> Result::Type;
1900}
1901unsafe extern "C" {
1902 #[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"]
1903 pub fn ghostty_kitty_graphics_placement_render_info(
1904 iterator: KittyGraphicsPlacementIterator,
1905 image: KittyGraphicsImage,
1906 terminal: Terminal,
1907 out_info: *mut KittyGraphicsPlacementRenderInfo,
1908 ) -> Result::Type;
1909}
1910#[doc = " Terminal initialization options.\n"]
1911#[repr(C)]
1912#[derive(Debug, Default, Copy, Clone)]
1913pub struct TerminalOptions {
1914 #[doc = " Terminal width in cells. Must be greater than zero."]
1915 pub cols: u16,
1916 #[doc = " Terminal height in cells. Must be greater than zero."]
1917 pub rows: u16,
1918 #[doc = " Maximum number of lines to keep in scrollback history."]
1919 pub max_scrollback: usize,
1920}
1921#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1922const _: () = {
1923 ["Size of TerminalOptions"][::std::mem::size_of::<TerminalOptions>() - 16usize];
1924 ["Alignment of TerminalOptions"][::std::mem::align_of::<TerminalOptions>() - 8usize];
1925 ["Offset of field: TerminalOptions::cols"]
1926 [::std::mem::offset_of!(TerminalOptions, cols) - 0usize];
1927 ["Offset of field: TerminalOptions::rows"]
1928 [::std::mem::offset_of!(TerminalOptions, rows) - 2usize];
1929 ["Offset of field: TerminalOptions::max_scrollback"]
1930 [::std::mem::offset_of!(TerminalOptions, max_scrollback) - 8usize];
1931};
1932pub mod TerminalScrollViewportTag {
1933 #[doc = " Scroll viewport behavior tag.\n"]
1934 pub type Type = ::std::os::raw::c_uint;
1935 #[doc = " Scroll to the top of the scrollback."]
1936 pub const TOP: Type = 0;
1937 #[doc = " Scroll to the bottom (active area)."]
1938 pub const BOTTOM: Type = 1;
1939 #[doc = " Scroll by a delta amount (up is negative)."]
1940 pub const DELTA: Type = 2;
1941 #[doc = " Scroll by a delta amount (up is negative)."]
1942 pub const MAX_VALUE: Type = 2147483647;
1943}
1944#[doc = " Scroll viewport value.\n"]
1945#[repr(C)]
1946#[derive(Copy, Clone)]
1947pub union TerminalScrollViewportValue {
1948 #[doc = " Scroll delta (only used with GHOSTTY_SCROLL_VIEWPORT_DELTA). Up is negative."]
1949 pub delta: isize,
1950 #[doc = " Padding for ABI compatibility. Do not use."]
1951 pub _padding: [u64; 2usize],
1952}
1953#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1954const _: () = {
1955 ["Size of TerminalScrollViewportValue"]
1956 [::std::mem::size_of::<TerminalScrollViewportValue>() - 16usize];
1957 ["Alignment of TerminalScrollViewportValue"]
1958 [::std::mem::align_of::<TerminalScrollViewportValue>() - 8usize];
1959 ["Offset of field: TerminalScrollViewportValue::delta"]
1960 [::std::mem::offset_of!(TerminalScrollViewportValue, delta) - 0usize];
1961 ["Offset of field: TerminalScrollViewportValue::_padding"]
1962 [::std::mem::offset_of!(TerminalScrollViewportValue, _padding) - 0usize];
1963};
1964impl Default for TerminalScrollViewportValue {
1965 fn default() -> Self {
1966 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
1967 unsafe {
1968 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1969 s.assume_init()
1970 }
1971 }
1972}
1973#[doc = " Tagged union for scroll viewport behavior.\n"]
1974#[repr(C)]
1975#[derive(Copy, Clone)]
1976pub struct TerminalScrollViewport {
1977 pub tag: TerminalScrollViewportTag::Type,
1978 pub value: TerminalScrollViewportValue,
1979}
1980#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1981const _: () = {
1982 ["Size of TerminalScrollViewport"][::std::mem::size_of::<TerminalScrollViewport>() - 24usize];
1983 ["Alignment of TerminalScrollViewport"]
1984 [::std::mem::align_of::<TerminalScrollViewport>() - 8usize];
1985 ["Offset of field: TerminalScrollViewport::tag"]
1986 [::std::mem::offset_of!(TerminalScrollViewport, tag) - 0usize];
1987 ["Offset of field: TerminalScrollViewport::value"]
1988 [::std::mem::offset_of!(TerminalScrollViewport, value) - 8usize];
1989};
1990impl Default for TerminalScrollViewport {
1991 fn default() -> Self {
1992 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
1993 unsafe {
1994 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1995 s.assume_init()
1996 }
1997 }
1998}
1999pub mod TerminalScreen {
2000 #[doc = " Terminal screen identifier.\n\n Identifies which screen buffer is active in the terminal.\n"]
2001 pub type Type = ::std::os::raw::c_uint;
2002 #[doc = " The primary (normal) screen."]
2003 pub const PRIMARY: Type = 0;
2004 #[doc = " The alternate screen."]
2005 pub const ALTERNATE: Type = 1;
2006 #[doc = " The alternate screen."]
2007 pub const MAX_VALUE: Type = 2147483647;
2008}
2009pub mod TerminalCursorStyle {
2010 #[doc = " Visual style of the terminal cursor.\n"]
2011 pub type Type = ::std::os::raw::c_uint;
2012 #[doc = " Bar cursor (DECSCUSR 5, 6)."]
2013 pub const BAR: Type = 0;
2014 #[doc = " Block cursor (DECSCUSR 1, 2)."]
2015 pub const BLOCK: Type = 1;
2016 #[doc = " Underline cursor (DECSCUSR 3, 4)."]
2017 pub const UNDERLINE: Type = 2;
2018 #[doc = " Hollow block cursor."]
2019 pub const BLOCK_HOLLOW: Type = 3;
2020 #[doc = " Hollow block cursor."]
2021 pub const MAX_VALUE: Type = 2147483647;
2022}
2023#[doc = " Scrollbar state for the terminal viewport.\n\n Represents the scrollable area dimensions needed to render a scrollbar.\n"]
2024#[repr(C)]
2025#[derive(Debug, Default, Copy, Clone)]
2026pub struct TerminalScrollbar {
2027 #[doc = " Total size of the scrollable area in rows."]
2028 pub total: u64,
2029 #[doc = " Offset into the total area that the viewport is at."]
2030 pub offset: u64,
2031 #[doc = " Length of the visible area in rows."]
2032 pub len: u64,
2033}
2034#[allow(clippy::unnecessary_operation, clippy::identity_op)]
2035const _: () = {
2036 ["Size of TerminalScrollbar"][::std::mem::size_of::<TerminalScrollbar>() - 24usize];
2037 ["Alignment of TerminalScrollbar"][::std::mem::align_of::<TerminalScrollbar>() - 8usize];
2038 ["Offset of field: TerminalScrollbar::total"]
2039 [::std::mem::offset_of!(TerminalScrollbar, total) - 0usize];
2040 ["Offset of field: TerminalScrollbar::offset"]
2041 [::std::mem::offset_of!(TerminalScrollbar, offset) - 8usize];
2042 ["Offset of field: TerminalScrollbar::len"]
2043 [::std::mem::offset_of!(TerminalScrollbar, len) - 16usize];
2044};
2045#[doc = " Callback function type for bell.\n\n Called when the terminal receives a BEL character (0x07).\n\n"]
2046pub type TerminalBellFn = ::std::option::Option<
2047 unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void),
2048>;
2049#[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"]
2050pub type TerminalColorSchemeFn = ::std::option::Option<
2051 unsafe extern "C" fn(
2052 terminal: Terminal,
2053 userdata: *mut ::std::os::raw::c_void,
2054 out_scheme: *mut ColorScheme::Type,
2055 ) -> bool,
2056>;
2057#[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"]
2058pub type TerminalDeviceAttributesFn = ::std::option::Option<
2059 unsafe extern "C" fn(
2060 terminal: Terminal,
2061 userdata: *mut ::std::os::raw::c_void,
2062 out_attrs: *mut DeviceAttributes,
2063 ) -> bool,
2064>;
2065#[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"]
2066pub type TerminalEnquiryFn = ::std::option::Option<
2067 unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void) -> String,
2068>;
2069#[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"]
2070pub type TerminalSizeFn = ::std::option::Option<
2071 unsafe extern "C" fn(
2072 terminal: Terminal,
2073 userdata: *mut ::std::os::raw::c_void,
2074 out_size: *mut SizeReportSize,
2075 ) -> bool,
2076>;
2077#[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"]
2078pub type TerminalTitleChangedFn = ::std::option::Option<
2079 unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void),
2080>;
2081#[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"]
2082pub type TerminalPwdChangedFn = ::std::option::Option<
2083 unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void),
2084>;
2085#[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"]
2086pub type TerminalWritePtyFn = ::std::option::Option<
2087 unsafe extern "C" fn(
2088 terminal: Terminal,
2089 userdata: *mut ::std::os::raw::c_void,
2090 data: *const u8,
2091 len: usize,
2092 ),
2093>;
2094#[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"]
2095pub type TerminalXtversionFn = ::std::option::Option<
2096 unsafe extern "C" fn(terminal: Terminal, userdata: *mut ::std::os::raw::c_void) -> String,
2097>;
2098pub mod TerminalOption {
2099 #[doc = " Terminal option identifiers.\n\n These values are used with ghostty_terminal_set() to configure\n terminal callbacks and associated state.\n"]
2100 pub type Type = ::std::os::raw::c_uint;
2101 #[doc = " Opaque userdata pointer passed to all callbacks.\n\n Input type: void*"]
2102 pub const USERDATA: Type = 0;
2103 #[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"]
2104 pub const WRITE_PTY: Type = 1;
2105 #[doc = " Callback invoked when the terminal receives a BEL character\n (0x07). Set to NULL to ignore bell events.\n\n Input type: GhosttyTerminalBellFn"]
2106 pub const BELL: Type = 2;
2107 #[doc = " Callback invoked when the terminal receives an ENQ character\n (0x05). Set to NULL to send no response.\n\n Input type: GhosttyTerminalEnquiryFn"]
2108 pub const ENQUIRY: Type = 3;
2109 #[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"]
2110 pub const XTVERSION: Type = 4;
2111 #[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"]
2112 pub const TITLE_CHANGED: Type = 5;
2113 #[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"]
2114 pub const SIZE: Type = 6;
2115 #[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"]
2116 pub const COLOR_SCHEME: Type = 7;
2117 #[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"]
2118 pub const DEVICE_ATTRIBUTES: Type = 8;
2119 #[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*"]
2120 pub const TITLE: Type = 9;
2121 #[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*"]
2122 pub const PWD: Type = 10;
2123 #[doc = " Set the default foreground color.\n\n A NULL value pointer clears the default (unset).\n\n Input type: GhosttyColorRgb*"]
2124 pub const COLOR_FOREGROUND: Type = 11;
2125 #[doc = " Set the default background color.\n\n A NULL value pointer clears the default (unset).\n\n Input type: GhosttyColorRgb*"]
2126 pub const COLOR_BACKGROUND: Type = 12;
2127 #[doc = " Set the default cursor color.\n\n A NULL value pointer clears the default (unset).\n\n Input type: GhosttyColorRgb*"]
2128 pub const COLOR_CURSOR: Type = 13;
2129 #[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]*"]
2130 pub const COLOR_PALETTE: Type = 14;
2131 #[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*"]
2132 pub const KITTY_IMAGE_STORAGE_LIMIT: Type = 15;
2133 #[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*"]
2134 pub const KITTY_IMAGE_MEDIUM_FILE: Type = 16;
2135 #[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*"]
2136 pub const KITTY_IMAGE_MEDIUM_TEMP_FILE: Type = 17;
2137 #[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*"]
2138 pub const KITTY_IMAGE_MEDIUM_SHARED_MEM: Type = 18;
2139 #[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*"]
2140 pub const APC_MAX_BYTES: Type = 19;
2141 #[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*"]
2142 pub const APC_MAX_BYTES_KITTY: Type = 20;
2143 #[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*"]
2144 pub const SELECTION: Type = 21;
2145 #[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*"]
2146 pub const DEFAULT_CURSOR_STYLE: Type = 22;
2147 #[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*"]
2148 pub const DEFAULT_CURSOR_BLINK: Type = 23;
2149 #[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*"]
2150 pub const GLYPH_PROTOCOL: Type = 24;
2151 #[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"]
2152 pub const PWD_CHANGED: Type = 25;
2153 #[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"]
2154 pub const MAX_VALUE: Type = 2147483647;
2155}
2156pub mod TerminalData {
2157 #[doc = " Terminal data types.\n\n These values specify what type of data to extract from a terminal\n using `ghostty_terminal_get`.\n"]
2158 pub type Type = ::std::os::raw::c_uint;
2159 #[doc = " Invalid data type. Never results in any data extraction."]
2160 pub const INVALID: Type = 0;
2161 #[doc = " Terminal width in cells.\n\n Output type: uint16_t *"]
2162 pub const COLS: Type = 1;
2163 #[doc = " Terminal height in cells.\n\n Output type: uint16_t *"]
2164 pub const ROWS: Type = 2;
2165 #[doc = " Cursor column position (0-indexed).\n\n Output type: uint16_t *"]
2166 pub const CURSOR_X: Type = 3;
2167 #[doc = " Cursor row position within the active area (0-indexed).\n\n Output type: uint16_t *"]
2168 pub const CURSOR_Y: Type = 4;
2169 #[doc = " Whether the cursor has a pending wrap (next print will soft-wrap).\n\n Output type: bool *"]
2170 pub const CURSOR_PENDING_WRAP: Type = 5;
2171 #[doc = " The currently active screen.\n\n Output type: GhosttyTerminalScreen *"]
2172 pub const ACTIVE_SCREEN: Type = 6;
2173 #[doc = " Whether the cursor is visible (DEC mode 25).\n\n Output type: bool *"]
2174 pub const CURSOR_VISIBLE: Type = 7;
2175 #[doc = " Current Kitty keyboard protocol flags.\n\n Output type: GhosttyKittyKeyFlags * (uint8_t *)"]
2176 pub const KITTY_KEYBOARD_FLAGS: Type = 8;
2177 #[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 *"]
2178 pub const SCROLLBAR: Type = 9;
2179 #[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 *"]
2180 pub const CURSOR_STYLE: Type = 10;
2181 #[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 *"]
2182 pub const MOUSE_TRACKING: Type = 11;
2183 #[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 *"]
2184 pub const TITLE: Type = 12;
2185 #[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 *"]
2186 pub const PWD: Type = 13;
2187 #[doc = " The total number of rows in the active screen including scrollback.\n\n Output type: size_t *"]
2188 pub const TOTAL_ROWS: Type = 14;
2189 #[doc = " The number of scrollback rows (total rows minus viewport rows).\n\n Output type: size_t *"]
2190 pub const SCROLLBACK_ROWS: Type = 15;
2191 #[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 *"]
2192 pub const WIDTH_PX: Type = 16;
2193 #[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 *"]
2194 pub const HEIGHT_PX: Type = 17;
2195 #[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 *"]
2196 pub const COLOR_FOREGROUND: Type = 18;
2197 #[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 *"]
2198 pub const COLOR_BACKGROUND: Type = 19;
2199 #[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 *"]
2200 pub const COLOR_CURSOR: Type = 20;
2201 #[doc = " The current 256-color palette.\n\n Output type: GhosttyColorRgb[256] *"]
2202 pub const COLOR_PALETTE: Type = 21;
2203 #[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 *"]
2204 pub const COLOR_FOREGROUND_DEFAULT: Type = 22;
2205 #[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 *"]
2206 pub const COLOR_BACKGROUND_DEFAULT: Type = 23;
2207 #[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 *"]
2208 pub const COLOR_CURSOR_DEFAULT: Type = 24;
2209 #[doc = " The default 256-color palette (ignoring any OSC overrides).\n\n Output type: GhosttyColorRgb[256] *"]
2210 pub const COLOR_PALETTE_DEFAULT: Type = 25;
2211 #[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 *"]
2212 pub const KITTY_IMAGE_STORAGE_LIMIT: Type = 26;
2213 #[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 *"]
2214 pub const KITTY_IMAGE_MEDIUM_FILE: Type = 27;
2215 #[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 *"]
2216 pub const KITTY_IMAGE_MEDIUM_TEMP_FILE: Type = 28;
2217 #[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 *"]
2218 pub const KITTY_IMAGE_MEDIUM_SHARED_MEM: Type = 29;
2219 #[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 *"]
2220 pub const KITTY_GRAPHICS: Type = 30;
2221 #[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 *"]
2222 pub const SELECTION: Type = 31;
2223 #[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 *"]
2224 pub const VIEWPORT_ACTIVE: Type = 32;
2225 #[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 *"]
2226 pub const MAX_VALUE: Type = 2147483647;
2227}
2228unsafe extern "C" {
2229 #[doc = " Create a new terminal instance.\n\n"]
2230 pub fn ghostty_terminal_new(
2231 allocator: *const Allocator,
2232 terminal: *mut Terminal,
2233 options: TerminalOptions,
2234 ) -> Result::Type;
2235}
2236unsafe extern "C" {
2237 #[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"]
2238 pub fn ghostty_terminal_free(terminal: Terminal);
2239}
2240unsafe extern "C" {
2241 #[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"]
2242 pub fn ghostty_terminal_reset(terminal: Terminal);
2243}
2244unsafe extern "C" {
2245 #[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"]
2246 pub fn ghostty_terminal_resize(
2247 terminal: Terminal,
2248 cols: u16,
2249 rows: u16,
2250 cell_width_px: u32,
2251 cell_height_px: u32,
2252 ) -> Result::Type;
2253}
2254unsafe extern "C" {
2255 #[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"]
2256 pub fn ghostty_terminal_set(
2257 terminal: Terminal,
2258 option: TerminalOption::Type,
2259 value: *const ::std::os::raw::c_void,
2260 ) -> Result::Type;
2261}
2262unsafe extern "C" {
2263 #[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"]
2264 pub fn ghostty_terminal_vt_write(terminal: Terminal, data: *const u8, len: usize);
2265}
2266unsafe extern "C" {
2267 #[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"]
2268 pub fn ghostty_terminal_scroll_viewport(terminal: Terminal, behavior: TerminalScrollViewport);
2269}
2270unsafe extern "C" {
2271 #[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"]
2272 pub fn ghostty_terminal_mode_get(
2273 terminal: Terminal,
2274 mode: Mode,
2275 out_value: *mut bool,
2276 ) -> Result::Type;
2277}
2278unsafe extern "C" {
2279 #[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"]
2280 pub fn ghostty_terminal_mode_set(terminal: Terminal, mode: Mode, value: bool) -> Result::Type;
2281}
2282unsafe extern "C" {
2283 #[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"]
2284 pub fn ghostty_terminal_get(
2285 terminal: Terminal,
2286 data: TerminalData::Type,
2287 out: *mut ::std::os::raw::c_void,
2288 ) -> Result::Type;
2289}
2290unsafe extern "C" {
2291 #[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"]
2292 pub fn ghostty_terminal_get_multi(
2293 terminal: Terminal,
2294 count: usize,
2295 keys: *const TerminalData::Type,
2296 values: *mut *mut ::std::os::raw::c_void,
2297 out_written: *mut usize,
2298 ) -> Result::Type;
2299}
2300unsafe extern "C" {
2301 #[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"]
2302 pub fn ghostty_terminal_grid_ref(
2303 terminal: Terminal,
2304 point: Point,
2305 out_ref: *mut GridRef,
2306 ) -> Result::Type;
2307}
2308unsafe extern "C" {
2309 #[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"]
2310 pub fn ghostty_terminal_grid_ref_track(
2311 terminal: Terminal,
2312 point: Point,
2313 out_ref: *mut TrackedGridRef,
2314 ) -> Result::Type;
2315}
2316unsafe extern "C" {
2317 #[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"]
2318 pub fn ghostty_terminal_point_from_grid_ref(
2319 terminal: Terminal,
2320 ref_: *const GridRef,
2321 tag: PointTag::Type,
2322 out: *mut PointCoordinate,
2323 ) -> Result::Type;
2324}
2325#[doc = " Extra screen state to include in styled output.\n"]
2326#[repr(C)]
2327#[derive(Debug, Default, Copy, Clone)]
2328pub struct FormatterScreenExtra {
2329 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyFormatterScreenExtra)."]
2330 pub size: usize,
2331 #[doc = " Emit cursor position using CUP (CSI H)."]
2332 pub cursor: bool,
2333 #[doc = " Emit current SGR style state based on the cursor's active style_id."]
2334 pub style: bool,
2335 #[doc = " Emit current hyperlink state using OSC 8 sequences."]
2336 pub hyperlink: bool,
2337 #[doc = " Emit character protection mode using DECSCA."]
2338 pub protection: bool,
2339 #[doc = " Emit Kitty keyboard protocol state using CSI > u and CSI = sequences."]
2340 pub kitty_keyboard: bool,
2341 #[doc = " Emit character set designations and invocations."]
2342 pub charsets: bool,
2343}
2344#[allow(clippy::unnecessary_operation, clippy::identity_op)]
2345const _: () = {
2346 ["Size of FormatterScreenExtra"][::std::mem::size_of::<FormatterScreenExtra>() - 16usize];
2347 ["Alignment of FormatterScreenExtra"][::std::mem::align_of::<FormatterScreenExtra>() - 8usize];
2348 ["Offset of field: FormatterScreenExtra::size"]
2349 [::std::mem::offset_of!(FormatterScreenExtra, size) - 0usize];
2350 ["Offset of field: FormatterScreenExtra::cursor"]
2351 [::std::mem::offset_of!(FormatterScreenExtra, cursor) - 8usize];
2352 ["Offset of field: FormatterScreenExtra::style"]
2353 [::std::mem::offset_of!(FormatterScreenExtra, style) - 9usize];
2354 ["Offset of field: FormatterScreenExtra::hyperlink"]
2355 [::std::mem::offset_of!(FormatterScreenExtra, hyperlink) - 10usize];
2356 ["Offset of field: FormatterScreenExtra::protection"]
2357 [::std::mem::offset_of!(FormatterScreenExtra, protection) - 11usize];
2358 ["Offset of field: FormatterScreenExtra::kitty_keyboard"]
2359 [::std::mem::offset_of!(FormatterScreenExtra, kitty_keyboard) - 12usize];
2360 ["Offset of field: FormatterScreenExtra::charsets"]
2361 [::std::mem::offset_of!(FormatterScreenExtra, charsets) - 13usize];
2362};
2363#[doc = " Extra terminal state to include in styled output.\n"]
2364#[repr(C)]
2365#[derive(Debug, Default, Copy, Clone)]
2366pub struct FormatterTerminalExtra {
2367 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyFormatterTerminalExtra)."]
2368 pub size: usize,
2369 #[doc = " Emit the palette using OSC 4 sequences."]
2370 pub palette: bool,
2371 #[doc = " Emit terminal modes that differ from their defaults using CSI h/l."]
2372 pub modes: bool,
2373 #[doc = " Emit scrolling region state using DECSTBM and DECSLRM sequences."]
2374 pub scrolling_region: bool,
2375 #[doc = " Emit tabstop positions by clearing all tabs and setting each one."]
2376 pub tabstops: bool,
2377 #[doc = " Emit the present working directory using OSC 7."]
2378 pub pwd: bool,
2379 #[doc = " Emit keyboard modes such as ModifyOtherKeys."]
2380 pub keyboard: bool,
2381 #[doc = " Screen-level extras."]
2382 pub screen: FormatterScreenExtra,
2383}
2384#[allow(clippy::unnecessary_operation, clippy::identity_op)]
2385const _: () = {
2386 ["Size of FormatterTerminalExtra"][::std::mem::size_of::<FormatterTerminalExtra>() - 32usize];
2387 ["Alignment of FormatterTerminalExtra"]
2388 [::std::mem::align_of::<FormatterTerminalExtra>() - 8usize];
2389 ["Offset of field: FormatterTerminalExtra::size"]
2390 [::std::mem::offset_of!(FormatterTerminalExtra, size) - 0usize];
2391 ["Offset of field: FormatterTerminalExtra::palette"]
2392 [::std::mem::offset_of!(FormatterTerminalExtra, palette) - 8usize];
2393 ["Offset of field: FormatterTerminalExtra::modes"]
2394 [::std::mem::offset_of!(FormatterTerminalExtra, modes) - 9usize];
2395 ["Offset of field: FormatterTerminalExtra::scrolling_region"]
2396 [::std::mem::offset_of!(FormatterTerminalExtra, scrolling_region) - 10usize];
2397 ["Offset of field: FormatterTerminalExtra::tabstops"]
2398 [::std::mem::offset_of!(FormatterTerminalExtra, tabstops) - 11usize];
2399 ["Offset of field: FormatterTerminalExtra::pwd"]
2400 [::std::mem::offset_of!(FormatterTerminalExtra, pwd) - 12usize];
2401 ["Offset of field: FormatterTerminalExtra::keyboard"]
2402 [::std::mem::offset_of!(FormatterTerminalExtra, keyboard) - 13usize];
2403 ["Offset of field: FormatterTerminalExtra::screen"]
2404 [::std::mem::offset_of!(FormatterTerminalExtra, screen) - 16usize];
2405};
2406#[doc = " Options for creating a terminal formatter.\n"]
2407#[repr(C)]
2408#[derive(Debug, Copy, Clone)]
2409pub struct FormatterTerminalOptions {
2410 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyFormatterTerminalOptions)."]
2411 pub size: usize,
2412 #[doc = " Output format to emit."]
2413 pub emit: FormatterFormat::Type,
2414 #[doc = " Whether to unwrap soft-wrapped lines."]
2415 pub unwrap: bool,
2416 #[doc = " Whether to trim trailing whitespace on non-blank lines."]
2417 pub trim: bool,
2418 #[doc = " Extra terminal state to include in styled output."]
2419 pub extra: FormatterTerminalExtra,
2420 #[doc = " Optional selection to restrict output to a range.\n If NULL, the entire screen is formatted."]
2421 pub selection: *const Selection,
2422}
2423#[allow(clippy::unnecessary_operation, clippy::identity_op)]
2424const _: () = {
2425 ["Size of FormatterTerminalOptions"]
2426 [::std::mem::size_of::<FormatterTerminalOptions>() - 56usize];
2427 ["Alignment of FormatterTerminalOptions"]
2428 [::std::mem::align_of::<FormatterTerminalOptions>() - 8usize];
2429 ["Offset of field: FormatterTerminalOptions::size"]
2430 [::std::mem::offset_of!(FormatterTerminalOptions, size) - 0usize];
2431 ["Offset of field: FormatterTerminalOptions::emit"]
2432 [::std::mem::offset_of!(FormatterTerminalOptions, emit) - 8usize];
2433 ["Offset of field: FormatterTerminalOptions::unwrap"]
2434 [::std::mem::offset_of!(FormatterTerminalOptions, unwrap) - 12usize];
2435 ["Offset of field: FormatterTerminalOptions::trim"]
2436 [::std::mem::offset_of!(FormatterTerminalOptions, trim) - 13usize];
2437 ["Offset of field: FormatterTerminalOptions::extra"]
2438 [::std::mem::offset_of!(FormatterTerminalOptions, extra) - 16usize];
2439 ["Offset of field: FormatterTerminalOptions::selection"]
2440 [::std::mem::offset_of!(FormatterTerminalOptions, selection) - 48usize];
2441};
2442impl Default for FormatterTerminalOptions {
2443 fn default() -> Self {
2444 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
2445 unsafe {
2446 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
2447 s.assume_init()
2448 }
2449 }
2450}
2451unsafe extern "C" {
2452 #[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"]
2453 pub fn ghostty_formatter_terminal_new(
2454 allocator: *const Allocator,
2455 formatter: *mut Formatter,
2456 terminal: Terminal,
2457 options: FormatterTerminalOptions,
2458 ) -> Result::Type;
2459}
2460unsafe extern "C" {
2461 #[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"]
2462 pub fn ghostty_formatter_format_buf(
2463 formatter: Formatter,
2464 buf: *mut u8,
2465 buf_len: usize,
2466 out_written: *mut usize,
2467 ) -> Result::Type;
2468}
2469unsafe extern "C" {
2470 #[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"]
2471 pub fn ghostty_formatter_format_alloc(
2472 formatter: Formatter,
2473 allocator: *const Allocator,
2474 out_ptr: *mut *mut u8,
2475 out_len: *mut usize,
2476 ) -> Result::Type;
2477}
2478unsafe extern "C" {
2479 #[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"]
2480 pub fn ghostty_formatter_free(formatter: Formatter);
2481}
2482pub mod RenderStateDirty {
2483 #[doc = " Dirty state of a render state after update.\n"]
2484 pub type Type = ::std::os::raw::c_uint;
2485 #[doc = " Not dirty at all; rendering can be skipped."]
2486 pub const FALSE: Type = 0;
2487 #[doc = " Some rows changed; renderer can redraw incrementally."]
2488 pub const PARTIAL: Type = 1;
2489 #[doc = " Global state changed; renderer should redraw everything."]
2490 pub const FULL: Type = 2;
2491 #[doc = " Global state changed; renderer should redraw everything."]
2492 pub const MAX_VALUE: Type = 2147483647;
2493}
2494pub mod RenderStateCursorVisualStyle {
2495 #[doc = " Visual style of the cursor.\n"]
2496 pub type Type = ::std::os::raw::c_uint;
2497 #[doc = " Bar cursor (DECSCUSR 5, 6)."]
2498 pub const BAR: Type = 0;
2499 #[doc = " Block cursor (DECSCUSR 1, 2)."]
2500 pub const BLOCK: Type = 1;
2501 #[doc = " Underline cursor (DECSCUSR 3, 4)."]
2502 pub const UNDERLINE: Type = 2;
2503 #[doc = " Hollow block cursor."]
2504 pub const BLOCK_HOLLOW: Type = 3;
2505 #[doc = " Hollow block cursor."]
2506 pub const MAX_VALUE: Type = 2147483647;
2507}
2508pub mod RenderStateData {
2509 #[doc = " Queryable data kinds for ghostty_render_state_get().\n"]
2510 pub type Type = ::std::os::raw::c_uint;
2511 #[doc = " Invalid / sentinel value."]
2512 pub const INVALID: Type = 0;
2513 #[doc = " Viewport width in cells (uint16_t)."]
2514 pub const COLS: Type = 1;
2515 #[doc = " Viewport height in cells (uint16_t)."]
2516 pub const ROWS: Type = 2;
2517 #[doc = " Current dirty state (GhosttyRenderStateDirty)."]
2518 pub const DIRTY: Type = 3;
2519 #[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."]
2520 pub const ROW_ITERATOR: Type = 4;
2521 #[doc = " Default/current background color (GhosttyColorRgb)."]
2522 pub const COLOR_BACKGROUND: Type = 5;
2523 #[doc = " Default/current foreground color (GhosttyColorRgb)."]
2524 pub const COLOR_FOREGROUND: Type = 6;
2525 #[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."]
2526 pub const COLOR_CURSOR: Type = 7;
2527 #[doc = " Whether an explicit cursor color is set (bool)."]
2528 pub const COLOR_CURSOR_HAS_VALUE: Type = 8;
2529 #[doc = " The active 256-color palette (GhosttyColorRgb[256])."]
2530 pub const COLOR_PALETTE: Type = 9;
2531 #[doc = " The visual style of the cursor (GhosttyRenderStateCursorVisualStyle)."]
2532 pub const CURSOR_VISUAL_STYLE: Type = 10;
2533 #[doc = " Whether the cursor is visible based on terminal modes (bool)."]
2534 pub const CURSOR_VISIBLE: Type = 11;
2535 #[doc = " Whether the cursor should blink based on terminal modes (bool)."]
2536 pub const CURSOR_BLINKING: Type = 12;
2537 #[doc = " Whether the cursor is at a password input field (bool)."]
2538 pub const CURSOR_PASSWORD_INPUT: Type = 13;
2539 #[doc = " Whether the cursor is visible within the viewport (bool).\n If false, the cursor viewport position values are undefined."]
2540 pub const CURSOR_VIEWPORT_HAS_VALUE: Type = 14;
2541 #[doc = " Cursor viewport x position in cells (uint16_t).\n Only valid when CURSOR_VIEWPORT_HAS_VALUE is true."]
2542 pub const CURSOR_VIEWPORT_X: Type = 15;
2543 #[doc = " Cursor viewport y position in cells (uint16_t).\n Only valid when CURSOR_VIEWPORT_HAS_VALUE is true."]
2544 pub const CURSOR_VIEWPORT_Y: Type = 16;
2545 #[doc = " Whether the cursor is on the tail of a wide character (bool).\n Only valid when CURSOR_VIEWPORT_HAS_VALUE is true."]
2546 pub const CURSOR_VIEWPORT_WIDE_TAIL: Type = 17;
2547 #[doc = " Whether the cursor is on the tail of a wide character (bool).\n Only valid when CURSOR_VIEWPORT_HAS_VALUE is true."]
2548 pub const MAX_VALUE: Type = 2147483647;
2549}
2550pub mod RenderStateOption {
2551 #[doc = " Settable options for ghostty_render_state_set().\n"]
2552 pub type Type = ::std::os::raw::c_uint;
2553 #[doc = " Set dirty state (GhosttyRenderStateDirty)."]
2554 pub const DIRTY: Type = 0;
2555 #[doc = " Set dirty state (GhosttyRenderStateDirty)."]
2556 pub const MAX_VALUE: Type = 2147483647;
2557}
2558pub mod RenderStateRowData {
2559 #[doc = " Queryable data kinds for ghostty_render_state_row_get().\n"]
2560 pub type Type = ::std::os::raw::c_uint;
2561 #[doc = " Invalid / sentinel value."]
2562 pub const INVALID: Type = 0;
2563 #[doc = " Whether the current row is dirty (bool)."]
2564 pub const DIRTY: Type = 1;
2565 #[doc = " The raw row value (GhosttyRow)."]
2566 pub const RAW: Type = 2;
2567 #[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."]
2568 pub const CELLS: Type = 3;
2569 #[doc = " Row-local selected cell range (GhosttyRenderStateRowSelection)."]
2570 pub const SELECTION: Type = 4;
2571 #[doc = " Row-local selected cell range (GhosttyRenderStateRowSelection)."]
2572 pub const MAX_VALUE: Type = 2147483647;
2573}
2574pub mod RenderStateRowOption {
2575 #[doc = " Settable options for ghostty_render_state_row_set().\n"]
2576 pub type Type = ::std::os::raw::c_uint;
2577 #[doc = " Set dirty state for the current row (bool)."]
2578 pub const DIRTY: Type = 0;
2579 #[doc = " Set dirty state for the current row (bool)."]
2580 pub const MAX_VALUE: Type = 2147483647;
2581}
2582#[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"]
2583#[repr(C)]
2584#[derive(Debug, Default, Copy, Clone)]
2585pub struct RenderStateRowSelection {
2586 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyRenderStateRowSelection)."]
2587 pub size: usize,
2588 #[doc = " Start column of the row-local selection range, inclusive."]
2589 pub start_x: u16,
2590 #[doc = " End column of the row-local selection range, inclusive."]
2591 pub end_x: u16,
2592}
2593#[allow(clippy::unnecessary_operation, clippy::identity_op)]
2594const _: () = {
2595 ["Size of RenderStateRowSelection"][::std::mem::size_of::<RenderStateRowSelection>() - 16usize];
2596 ["Alignment of RenderStateRowSelection"]
2597 [::std::mem::align_of::<RenderStateRowSelection>() - 8usize];
2598 ["Offset of field: RenderStateRowSelection::size"]
2599 [::std::mem::offset_of!(RenderStateRowSelection, size) - 0usize];
2600 ["Offset of field: RenderStateRowSelection::start_x"]
2601 [::std::mem::offset_of!(RenderStateRowSelection, start_x) - 8usize];
2602 ["Offset of field: RenderStateRowSelection::end_x"]
2603 [::std::mem::offset_of!(RenderStateRowSelection, end_x) - 10usize];
2604};
2605#[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"]
2606#[repr(C)]
2607#[derive(Debug, Copy, Clone)]
2608pub struct RenderStateColors {
2609 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyRenderStateColors)."]
2610 pub size: usize,
2611 #[doc = " The default/current background color for the render state."]
2612 pub background: ColorRgb,
2613 #[doc = " The default/current foreground color for the render state."]
2614 pub foreground: ColorRgb,
2615 #[doc = " The cursor color when explicitly set by terminal state."]
2616 pub cursor: ColorRgb,
2617 #[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."]
2618 pub cursor_has_value: bool,
2619 #[doc = " The active 256-color palette for this render state."]
2620 pub palette: [ColorRgb; 256usize],
2621}
2622#[allow(clippy::unnecessary_operation, clippy::identity_op)]
2623const _: () = {
2624 ["Size of RenderStateColors"][::std::mem::size_of::<RenderStateColors>() - 792usize];
2625 ["Alignment of RenderStateColors"][::std::mem::align_of::<RenderStateColors>() - 8usize];
2626 ["Offset of field: RenderStateColors::size"]
2627 [::std::mem::offset_of!(RenderStateColors, size) - 0usize];
2628 ["Offset of field: RenderStateColors::background"]
2629 [::std::mem::offset_of!(RenderStateColors, background) - 8usize];
2630 ["Offset of field: RenderStateColors::foreground"]
2631 [::std::mem::offset_of!(RenderStateColors, foreground) - 11usize];
2632 ["Offset of field: RenderStateColors::cursor"]
2633 [::std::mem::offset_of!(RenderStateColors, cursor) - 14usize];
2634 ["Offset of field: RenderStateColors::cursor_has_value"]
2635 [::std::mem::offset_of!(RenderStateColors, cursor_has_value) - 17usize];
2636 ["Offset of field: RenderStateColors::palette"]
2637 [::std::mem::offset_of!(RenderStateColors, palette) - 18usize];
2638};
2639impl Default for RenderStateColors {
2640 fn default() -> Self {
2641 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
2642 unsafe {
2643 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
2644 s.assume_init()
2645 }
2646 }
2647}
2648unsafe extern "C" {
2649 #[doc = " Create a new render state instance.\n\n failure\n"]
2650 pub fn ghostty_render_state_new(
2651 allocator: *const Allocator,
2652 state: *mut RenderState,
2653 ) -> Result::Type;
2654}
2655unsafe extern "C" {
2656 #[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"]
2657 pub fn ghostty_render_state_free(state: RenderState);
2658}
2659unsafe extern "C" {
2660 #[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"]
2661 pub fn ghostty_render_state_update(state: RenderState, terminal: Terminal) -> Result::Type;
2662}
2663unsafe extern "C" {
2664 #[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"]
2665 pub fn ghostty_render_state_get(
2666 state: RenderState,
2667 data: RenderStateData::Type,
2668 out: *mut ::std::os::raw::c_void,
2669 ) -> Result::Type;
2670}
2671unsafe extern "C" {
2672 #[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"]
2673 pub fn ghostty_render_state_get_multi(
2674 state: RenderState,
2675 count: usize,
2676 keys: *const RenderStateData::Type,
2677 values: *mut *mut ::std::os::raw::c_void,
2678 out_written: *mut usize,
2679 ) -> Result::Type;
2680}
2681unsafe extern "C" {
2682 #[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"]
2683 pub fn ghostty_render_state_set(
2684 state: RenderState,
2685 option: RenderStateOption::Type,
2686 value: *const ::std::os::raw::c_void,
2687 ) -> Result::Type;
2688}
2689unsafe extern "C" {
2690 #[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"]
2691 pub fn ghostty_render_state_colors_get(
2692 state: RenderState,
2693 out_colors: *mut RenderStateColors,
2694 ) -> Result::Type;
2695}
2696unsafe extern "C" {
2697 #[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"]
2698 pub fn ghostty_render_state_row_iterator_new(
2699 allocator: *const Allocator,
2700 out_iterator: *mut RenderStateRowIterator,
2701 ) -> Result::Type;
2702}
2703unsafe extern "C" {
2704 #[doc = " Free a render-state row iterator.\n\n"]
2705 pub fn ghostty_render_state_row_iterator_free(iterator: RenderStateRowIterator);
2706}
2707unsafe extern "C" {
2708 #[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"]
2709 pub fn ghostty_render_state_row_iterator_next(iterator: RenderStateRowIterator) -> bool;
2710}
2711unsafe extern "C" {
2712 #[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"]
2713 pub fn ghostty_render_state_row_get(
2714 iterator: RenderStateRowIterator,
2715 data: RenderStateRowData::Type,
2716 out: *mut ::std::os::raw::c_void,
2717 ) -> Result::Type;
2718}
2719unsafe extern "C" {
2720 #[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"]
2721 pub fn ghostty_render_state_row_get_multi(
2722 iterator: RenderStateRowIterator,
2723 count: usize,
2724 keys: *const RenderStateRowData::Type,
2725 values: *mut *mut ::std::os::raw::c_void,
2726 out_written: *mut usize,
2727 ) -> Result::Type;
2728}
2729unsafe extern "C" {
2730 #[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"]
2731 pub fn ghostty_render_state_row_set(
2732 iterator: RenderStateRowIterator,
2733 option: RenderStateRowOption::Type,
2734 value: *const ::std::os::raw::c_void,
2735 ) -> Result::Type;
2736}
2737unsafe extern "C" {
2738 #[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"]
2739 pub fn ghostty_render_state_row_cells_new(
2740 allocator: *const Allocator,
2741 out_cells: *mut RenderStateRowCells,
2742 ) -> Result::Type;
2743}
2744pub mod RenderStateRowCellsData {
2745 #[doc = " Queryable data kinds for ghostty_render_state_row_cells_get().\n"]
2746 pub type Type = ::std::os::raw::c_uint;
2747 #[doc = " Invalid / sentinel value."]
2748 pub const INVALID: Type = 0;
2749 #[doc = " The raw cell value (GhosttyCell)."]
2750 pub const RAW: Type = 1;
2751 #[doc = " The style for the current cell (GhosttyStyle)."]
2752 pub const STYLE: Type = 2;
2753 #[doc = " The total number of grapheme codepoints including the base codepoint\n (uint32_t). Returns 0 if the cell has no text."]
2754 pub const GRAPHEMES_LEN: Type = 3;
2755 #[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."]
2756 pub const GRAPHEMES_BUF: Type = 4;
2757 #[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)."]
2758 pub const BG_COLOR: Type = 5;
2759 #[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)."]
2760 pub const FG_COLOR: Type = 6;
2761 #[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."]
2762 pub const SELECTED: Type = 7;
2763 #[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."]
2764 pub const HAS_STYLING: Type = 8;
2765 #[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."]
2766 pub const GRAPHEMES_UTF8: Type = 9;
2767 #[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."]
2768 pub const MAX_VALUE: Type = 2147483647;
2769}
2770unsafe extern "C" {
2771 #[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"]
2772 pub fn ghostty_render_state_row_cells_next(cells: RenderStateRowCells) -> bool;
2773}
2774unsafe extern "C" {
2775 #[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"]
2776 pub fn ghostty_render_state_row_cells_select(
2777 cells: RenderStateRowCells,
2778 x: u16,
2779 ) -> Result::Type;
2780}
2781unsafe extern "C" {
2782 #[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"]
2783 pub fn ghostty_render_state_row_cells_get(
2784 cells: RenderStateRowCells,
2785 data: RenderStateRowCellsData::Type,
2786 out: *mut ::std::os::raw::c_void,
2787 ) -> Result::Type;
2788}
2789unsafe extern "C" {
2790 #[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"]
2791 pub fn ghostty_render_state_row_cells_get_multi(
2792 cells: RenderStateRowCells,
2793 count: usize,
2794 keys: *const RenderStateRowCellsData::Type,
2795 values: *mut *mut ::std::os::raw::c_void,
2796 out_written: *mut usize,
2797 ) -> Result::Type;
2798}
2799unsafe extern "C" {
2800 #[doc = " Free a row cells instance.\n\n"]
2801 pub fn ghostty_render_state_row_cells_free(cells: RenderStateRowCells);
2802}
2803unsafe extern "C" {
2804 #[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"]
2805 pub fn ghostty_tracked_grid_ref_free(ref_: TrackedGridRef);
2806}
2807unsafe extern "C" {
2808 #[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"]
2809 pub fn ghostty_tracked_grid_ref_has_value(ref_: TrackedGridRef) -> bool;
2810}
2811unsafe extern "C" {
2812 #[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"]
2813 pub fn ghostty_tracked_grid_ref_point(
2814 ref_: TrackedGridRef,
2815 tag: PointTag::Type,
2816 out_point: *mut PointCoordinate,
2817 ) -> Result::Type;
2818}
2819unsafe extern "C" {
2820 #[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"]
2821 pub fn ghostty_tracked_grid_ref_set(
2822 ref_: TrackedGridRef,
2823 terminal: Terminal,
2824 point: Point,
2825 ) -> Result::Type;
2826}
2827unsafe extern "C" {
2828 #[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"]
2829 pub fn ghostty_tracked_grid_ref_snapshot(
2830 ref_: TrackedGridRef,
2831 out_ref: *mut GridRef,
2832 ) -> Result::Type;
2833}
2834pub mod OscCommandType {
2835 #[doc = " OSC command types.\n"]
2836 pub type Type = ::std::os::raw::c_uint;
2837 pub const INVALID: Type = 0;
2838 pub const CHANGE_WINDOW_TITLE: Type = 1;
2839 pub const CHANGE_WINDOW_ICON: Type = 2;
2840 pub const SEMANTIC_PROMPT: Type = 3;
2841 pub const CLIPBOARD_CONTENTS: Type = 4;
2842 pub const REPORT_PWD: Type = 5;
2843 pub const MOUSE_SHAPE: Type = 6;
2844 pub const COLOR_OPERATION: Type = 7;
2845 pub const KITTY_COLOR_PROTOCOL: Type = 8;
2846 pub const SHOW_DESKTOP_NOTIFICATION: Type = 9;
2847 pub const HYPERLINK_START: Type = 10;
2848 pub const HYPERLINK_END: Type = 11;
2849 pub const CONEMU_SLEEP: Type = 12;
2850 pub const CONEMU_SHOW_MESSAGE_BOX: Type = 13;
2851 pub const CONEMU_CHANGE_TAB_TITLE: Type = 14;
2852 pub const CONEMU_PROGRESS_REPORT: Type = 15;
2853 pub const CONEMU_WAIT_INPUT: Type = 16;
2854 pub const CONEMU_GUIMACRO: Type = 17;
2855 pub const CONEMU_RUN_PROCESS: Type = 18;
2856 pub const CONEMU_OUTPUT_ENVIRONMENT_VARIABLE: Type = 19;
2857 pub const CONEMU_XTERM_EMULATION: Type = 20;
2858 pub const CONEMU_COMMENT: Type = 21;
2859 pub const KITTY_TEXT_SIZING: Type = 22;
2860 pub const TYPE_MAX_VALUE: Type = 2147483647;
2861}
2862pub mod OscCommandData {
2863 #[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"]
2864 pub type Type = ::std::os::raw::c_uint;
2865 #[doc = " Invalid data type. Never results in any data extraction."]
2866 pub const INVALID: Type = 0;
2867 #[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."]
2868 pub const CHANGE_WINDOW_TITLE_STR: Type = 1;
2869 #[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."]
2870 pub const MAX_VALUE: Type = 2147483647;
2871}
2872unsafe extern "C" {
2873 #[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"]
2874 pub fn ghostty_osc_new(allocator: *const Allocator, parser: *mut OscParser) -> Result::Type;
2875}
2876unsafe extern "C" {
2877 #[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"]
2878 pub fn ghostty_osc_free(parser: OscParser);
2879}
2880unsafe extern "C" {
2881 #[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"]
2882 pub fn ghostty_osc_reset(parser: OscParser);
2883}
2884unsafe extern "C" {
2885 #[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"]
2886 pub fn ghostty_osc_next(parser: OscParser, byte: u8);
2887}
2888unsafe extern "C" {
2889 #[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"]
2890 pub fn ghostty_osc_end(parser: OscParser, terminator: u8) -> OscCommand;
2891}
2892unsafe extern "C" {
2893 #[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"]
2894 pub fn ghostty_osc_command_type(command: OscCommand) -> OscCommandType::Type;
2895}
2896unsafe extern "C" {
2897 #[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"]
2898 pub fn ghostty_osc_command_data(
2899 command: OscCommand,
2900 data: OscCommandData::Type,
2901 out: *mut ::std::os::raw::c_void,
2902 ) -> bool;
2903}
2904pub mod SgrAttributeTag {
2905 #[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"]
2906 pub type Type = ::std::os::raw::c_uint;
2907 pub const UNSET: Type = 0;
2908 pub const UNKNOWN: Type = 1;
2909 pub const BOLD: Type = 2;
2910 pub const RESET_BOLD: Type = 3;
2911 pub const ITALIC: Type = 4;
2912 pub const RESET_ITALIC: Type = 5;
2913 pub const FAINT: Type = 6;
2914 pub const UNDERLINE: Type = 7;
2915 pub const UNDERLINE_COLOR: Type = 8;
2916 pub const UNDERLINE_COLOR_256: Type = 9;
2917 pub const RESET_UNDERLINE_COLOR: Type = 10;
2918 pub const OVERLINE: Type = 11;
2919 pub const RESET_OVERLINE: Type = 12;
2920 pub const BLINK: Type = 13;
2921 pub const RESET_BLINK: Type = 14;
2922 pub const INVERSE: Type = 15;
2923 pub const RESET_INVERSE: Type = 16;
2924 pub const INVISIBLE: Type = 17;
2925 pub const RESET_INVISIBLE: Type = 18;
2926 pub const STRIKETHROUGH: Type = 19;
2927 pub const RESET_STRIKETHROUGH: Type = 20;
2928 pub const DIRECT_COLOR_FG: Type = 21;
2929 pub const DIRECT_COLOR_BG: Type = 22;
2930 pub const BG_8: Type = 23;
2931 pub const FG_8: Type = 24;
2932 pub const RESET_FG: Type = 25;
2933 pub const RESET_BG: Type = 26;
2934 pub const BRIGHT_BG_8: Type = 27;
2935 pub const BRIGHT_FG_8: Type = 28;
2936 pub const BG_256: Type = 29;
2937 pub const FG_256: Type = 30;
2938 pub const MAX_VALUE: Type = 2147483647;
2939}
2940pub mod SgrUnderline {
2941 #[doc = " Underline style types.\n"]
2942 pub type Type = ::std::os::raw::c_uint;
2943 pub const NONE: Type = 0;
2944 pub const SINGLE: Type = 1;
2945 pub const DOUBLE: Type = 2;
2946 pub const CURLY: Type = 3;
2947 pub const DOTTED: Type = 4;
2948 pub const DASHED: Type = 5;
2949 pub const MAX_VALUE: Type = 2147483647;
2950}
2951#[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"]
2952#[repr(C)]
2953#[derive(Debug, Copy, Clone)]
2954pub struct SgrUnknown {
2955 pub full_ptr: *const u16,
2956 pub full_len: usize,
2957 pub partial_ptr: *const u16,
2958 pub partial_len: usize,
2959}
2960#[allow(clippy::unnecessary_operation, clippy::identity_op)]
2961const _: () = {
2962 ["Size of SgrUnknown"][::std::mem::size_of::<SgrUnknown>() - 32usize];
2963 ["Alignment of SgrUnknown"][::std::mem::align_of::<SgrUnknown>() - 8usize];
2964 ["Offset of field: SgrUnknown::full_ptr"]
2965 [::std::mem::offset_of!(SgrUnknown, full_ptr) - 0usize];
2966 ["Offset of field: SgrUnknown::full_len"]
2967 [::std::mem::offset_of!(SgrUnknown, full_len) - 8usize];
2968 ["Offset of field: SgrUnknown::partial_ptr"]
2969 [::std::mem::offset_of!(SgrUnknown, partial_ptr) - 16usize];
2970 ["Offset of field: SgrUnknown::partial_len"]
2971 [::std::mem::offset_of!(SgrUnknown, partial_len) - 24usize];
2972};
2973impl Default for SgrUnknown {
2974 fn default() -> Self {
2975 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
2976 unsafe {
2977 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
2978 s.assume_init()
2979 }
2980 }
2981}
2982#[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"]
2983#[repr(C)]
2984#[derive(Copy, Clone)]
2985pub union SgrAttributeValue {
2986 pub unknown: SgrUnknown,
2987 pub underline: SgrUnderline::Type,
2988 pub underline_color: ColorRgb,
2989 pub underline_color_256: ColorPaletteIndex,
2990 pub direct_color_fg: ColorRgb,
2991 pub direct_color_bg: ColorRgb,
2992 pub bg_8: ColorPaletteIndex,
2993 pub fg_8: ColorPaletteIndex,
2994 pub bright_bg_8: ColorPaletteIndex,
2995 pub bright_fg_8: ColorPaletteIndex,
2996 pub bg_256: ColorPaletteIndex,
2997 pub fg_256: ColorPaletteIndex,
2998 pub _padding: [u64; 8usize],
2999}
3000#[allow(clippy::unnecessary_operation, clippy::identity_op)]
3001const _: () = {
3002 ["Size of SgrAttributeValue"][::std::mem::size_of::<SgrAttributeValue>() - 64usize];
3003 ["Alignment of SgrAttributeValue"][::std::mem::align_of::<SgrAttributeValue>() - 8usize];
3004 ["Offset of field: SgrAttributeValue::unknown"]
3005 [::std::mem::offset_of!(SgrAttributeValue, unknown) - 0usize];
3006 ["Offset of field: SgrAttributeValue::underline"]
3007 [::std::mem::offset_of!(SgrAttributeValue, underline) - 0usize];
3008 ["Offset of field: SgrAttributeValue::underline_color"]
3009 [::std::mem::offset_of!(SgrAttributeValue, underline_color) - 0usize];
3010 ["Offset of field: SgrAttributeValue::underline_color_256"]
3011 [::std::mem::offset_of!(SgrAttributeValue, underline_color_256) - 0usize];
3012 ["Offset of field: SgrAttributeValue::direct_color_fg"]
3013 [::std::mem::offset_of!(SgrAttributeValue, direct_color_fg) - 0usize];
3014 ["Offset of field: SgrAttributeValue::direct_color_bg"]
3015 [::std::mem::offset_of!(SgrAttributeValue, direct_color_bg) - 0usize];
3016 ["Offset of field: SgrAttributeValue::bg_8"]
3017 [::std::mem::offset_of!(SgrAttributeValue, bg_8) - 0usize];
3018 ["Offset of field: SgrAttributeValue::fg_8"]
3019 [::std::mem::offset_of!(SgrAttributeValue, fg_8) - 0usize];
3020 ["Offset of field: SgrAttributeValue::bright_bg_8"]
3021 [::std::mem::offset_of!(SgrAttributeValue, bright_bg_8) - 0usize];
3022 ["Offset of field: SgrAttributeValue::bright_fg_8"]
3023 [::std::mem::offset_of!(SgrAttributeValue, bright_fg_8) - 0usize];
3024 ["Offset of field: SgrAttributeValue::bg_256"]
3025 [::std::mem::offset_of!(SgrAttributeValue, bg_256) - 0usize];
3026 ["Offset of field: SgrAttributeValue::fg_256"]
3027 [::std::mem::offset_of!(SgrAttributeValue, fg_256) - 0usize];
3028 ["Offset of field: SgrAttributeValue::_padding"]
3029 [::std::mem::offset_of!(SgrAttributeValue, _padding) - 0usize];
3030};
3031impl Default for SgrAttributeValue {
3032 fn default() -> Self {
3033 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
3034 unsafe {
3035 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
3036 s.assume_init()
3037 }
3038 }
3039}
3040#[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"]
3041#[repr(C)]
3042#[derive(Copy, Clone)]
3043pub struct SgrAttribute {
3044 pub tag: SgrAttributeTag::Type,
3045 pub value: SgrAttributeValue,
3046}
3047#[allow(clippy::unnecessary_operation, clippy::identity_op)]
3048const _: () = {
3049 ["Size of SgrAttribute"][::std::mem::size_of::<SgrAttribute>() - 72usize];
3050 ["Alignment of SgrAttribute"][::std::mem::align_of::<SgrAttribute>() - 8usize];
3051 ["Offset of field: SgrAttribute::tag"][::std::mem::offset_of!(SgrAttribute, tag) - 0usize];
3052 ["Offset of field: SgrAttribute::value"][::std::mem::offset_of!(SgrAttribute, value) - 8usize];
3053};
3054impl Default for SgrAttribute {
3055 fn default() -> Self {
3056 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
3057 unsafe {
3058 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
3059 s.assume_init()
3060 }
3061 }
3062}
3063unsafe extern "C" {
3064 #[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"]
3065 pub fn ghostty_sgr_new(allocator: *const Allocator, parser: *mut SgrParser) -> Result::Type;
3066}
3067unsafe extern "C" {
3068 #[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"]
3069 pub fn ghostty_sgr_free(parser: SgrParser);
3070}
3071unsafe extern "C" {
3072 #[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"]
3073 pub fn ghostty_sgr_reset(parser: SgrParser);
3074}
3075unsafe extern "C" {
3076 #[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"]
3077 pub fn ghostty_sgr_set_params(
3078 parser: SgrParser,
3079 params: *const u16,
3080 separators: *const ::std::os::raw::c_char,
3081 len: usize,
3082 ) -> Result::Type;
3083}
3084unsafe extern "C" {
3085 #[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"]
3086 pub fn ghostty_sgr_next(parser: SgrParser, attr: *mut SgrAttribute) -> bool;
3087}
3088unsafe extern "C" {
3089 #[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"]
3090 pub fn ghostty_sgr_unknown_full(unknown: SgrUnknown, ptr: *mut *const u16) -> usize;
3091}
3092unsafe extern "C" {
3093 #[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"]
3094 pub fn ghostty_sgr_unknown_partial(unknown: SgrUnknown, ptr: *mut *const u16) -> usize;
3095}
3096unsafe extern "C" {
3097 #[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"]
3098 pub fn ghostty_sgr_attribute_tag(attr: SgrAttribute) -> SgrAttributeTag::Type;
3099}
3100unsafe extern "C" {
3101 #[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"]
3102 pub fn ghostty_sgr_attribute_value(attr: *mut SgrAttribute) -> *mut SgrAttributeValue;
3103}
3104#[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."]
3105#[repr(C)]
3106#[derive(Debug, Copy, Clone)]
3107pub struct SysImage {
3108 #[doc = " Image width in pixels."]
3109 pub width: u32,
3110 #[doc = " Image height in pixels."]
3111 pub height: u32,
3112 #[doc = " Pointer to the decoded RGBA pixel data."]
3113 pub data: *mut u8,
3114 #[doc = " Length of the pixel data in bytes."]
3115 pub data_len: usize,
3116}
3117#[allow(clippy::unnecessary_operation, clippy::identity_op)]
3118const _: () = {
3119 ["Size of SysImage"][::std::mem::size_of::<SysImage>() - 24usize];
3120 ["Alignment of SysImage"][::std::mem::align_of::<SysImage>() - 8usize];
3121 ["Offset of field: SysImage::width"][::std::mem::offset_of!(SysImage, width) - 0usize];
3122 ["Offset of field: SysImage::height"][::std::mem::offset_of!(SysImage, height) - 4usize];
3123 ["Offset of field: SysImage::data"][::std::mem::offset_of!(SysImage, data) - 8usize];
3124 ["Offset of field: SysImage::data_len"][::std::mem::offset_of!(SysImage, data_len) - 16usize];
3125};
3126impl Default for SysImage {
3127 fn default() -> Self {
3128 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
3129 unsafe {
3130 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
3131 s.assume_init()
3132 }
3133 }
3134}
3135pub mod SysLogLevel {
3136 #[doc = " Log severity levels for the log callback."]
3137 pub type Type = ::std::os::raw::c_uint;
3138 pub const ERROR: Type = 0;
3139 pub const WARNING: Type = 1;
3140 pub const INFO: Type = 2;
3141 pub const DEBUG: Type = 3;
3142 pub const MAX_VALUE: Type = 2147483647;
3143}
3144#[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"]
3145pub type SysLogFn = ::std::option::Option<
3146 unsafe extern "C" fn(
3147 userdata: *mut ::std::os::raw::c_void,
3148 level: SysLogLevel::Type,
3149 scope: *const u8,
3150 scope_len: usize,
3151 message: *const u8,
3152 message_len: usize,
3153 ),
3154>;
3155#[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"]
3156pub type SysDecodePngFn = ::std::option::Option<
3157 unsafe extern "C" fn(
3158 userdata: *mut ::std::os::raw::c_void,
3159 allocator: *const Allocator,
3160 data: *const u8,
3161 data_len: usize,
3162 out: *mut SysImage,
3163 ) -> bool,
3164>;
3165pub mod SysOption {
3166 #[doc = " System option identifiers for ghostty_sys_set()."]
3167 pub type Type = ::std::os::raw::c_uint;
3168 #[doc = " Set the userdata pointer passed to all sys callbacks.\n\n Input type: void* (or NULL)"]
3169 pub const GHOSTTY_SYS_OPT_USERDATA: Type = 0;
3170 #[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)"]
3171 pub const GHOSTTY_SYS_OPT_DECODE_PNG: Type = 1;
3172 #[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)"]
3173 pub const GHOSTTY_SYS_OPT_LOG: Type = 2;
3174 #[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)"]
3175 pub const GHOSTTY_SYS_OPT_MAX_VALUE: Type = 2147483647;
3176}
3177unsafe extern "C" {
3178 #[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"]
3179 pub fn ghostty_sys_set(
3180 option: SysOption::Type,
3181 value: *const ::std::os::raw::c_void,
3182 ) -> Result::Type;
3183}
3184unsafe extern "C" {
3185 #[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);"]
3186 pub fn ghostty_sys_log_stderr(
3187 userdata: *mut ::std::os::raw::c_void,
3188 level: SysLogLevel::Type,
3189 scope: *const u8,
3190 scope_len: usize,
3191 message: *const u8,
3192 message_len: usize,
3193 );
3194}
3195#[repr(C)]
3196#[derive(Debug, Copy, Clone)]
3197pub struct KeyEventImpl {
3198 _unused: [u8; 0],
3199}
3200#[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"]
3201pub type KeyEvent = *mut KeyEventImpl;
3202pub mod KeyAction {
3203 #[doc = " Keyboard input event types.\n"]
3204 pub type Type = ::std::os::raw::c_uint;
3205 #[doc = " Key was released"]
3206 pub const RELEASE: Type = 0;
3207 #[doc = " Key was pressed"]
3208 pub const PRESS: Type = 1;
3209 #[doc = " Key is being repeated (held down)"]
3210 pub const REPEAT: Type = 2;
3211 #[doc = " Key is being repeated (held down)"]
3212 pub const MAX_VALUE: Type = 2147483647;
3213}
3214#[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"]
3215pub type Mods = u16;
3216pub mod Key {
3217 #[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"]
3218 pub type Type = ::std::os::raw::c_uint;
3219 pub const UNIDENTIFIED: Type = 0;
3220 pub const BACKQUOTE: Type = 1;
3221 pub const BACKSLASH: Type = 2;
3222 pub const BRACKET_LEFT: Type = 3;
3223 pub const BRACKET_RIGHT: Type = 4;
3224 pub const COMMA: Type = 5;
3225 pub const DIGIT_0: Type = 6;
3226 pub const DIGIT_1: Type = 7;
3227 pub const DIGIT_2: Type = 8;
3228 pub const DIGIT_3: Type = 9;
3229 pub const DIGIT_4: Type = 10;
3230 pub const DIGIT_5: Type = 11;
3231 pub const DIGIT_6: Type = 12;
3232 pub const DIGIT_7: Type = 13;
3233 pub const DIGIT_8: Type = 14;
3234 pub const DIGIT_9: Type = 15;
3235 pub const EQUAL: Type = 16;
3236 pub const INTL_BACKSLASH: Type = 17;
3237 pub const INTL_RO: Type = 18;
3238 pub const INTL_YEN: Type = 19;
3239 pub const A: Type = 20;
3240 pub const B: Type = 21;
3241 pub const C: Type = 22;
3242 pub const D: Type = 23;
3243 pub const E: Type = 24;
3244 pub const F: Type = 25;
3245 pub const G: Type = 26;
3246 pub const H: Type = 27;
3247 pub const I: Type = 28;
3248 pub const J: Type = 29;
3249 pub const K: Type = 30;
3250 pub const L: Type = 31;
3251 pub const M: Type = 32;
3252 pub const N: Type = 33;
3253 pub const O: Type = 34;
3254 pub const P: Type = 35;
3255 pub const Q: Type = 36;
3256 pub const R: Type = 37;
3257 pub const S: Type = 38;
3258 pub const T: Type = 39;
3259 pub const U: Type = 40;
3260 pub const V: Type = 41;
3261 pub const W: Type = 42;
3262 pub const X: Type = 43;
3263 pub const Y: Type = 44;
3264 pub const Z: Type = 45;
3265 pub const MINUS: Type = 46;
3266 pub const PERIOD: Type = 47;
3267 pub const QUOTE: Type = 48;
3268 pub const SEMICOLON: Type = 49;
3269 pub const SLASH: Type = 50;
3270 pub const ALT_LEFT: Type = 51;
3271 pub const ALT_RIGHT: Type = 52;
3272 pub const BACKSPACE: Type = 53;
3273 pub const CAPS_LOCK: Type = 54;
3274 pub const CONTEXT_MENU: Type = 55;
3275 pub const CONTROL_LEFT: Type = 56;
3276 pub const CONTROL_RIGHT: Type = 57;
3277 pub const ENTER: Type = 58;
3278 pub const META_LEFT: Type = 59;
3279 pub const META_RIGHT: Type = 60;
3280 pub const SHIFT_LEFT: Type = 61;
3281 pub const SHIFT_RIGHT: Type = 62;
3282 pub const SPACE: Type = 63;
3283 pub const TAB: Type = 64;
3284 pub const CONVERT: Type = 65;
3285 pub const KANA_MODE: Type = 66;
3286 pub const NON_CONVERT: Type = 67;
3287 pub const DELETE: Type = 68;
3288 pub const END: Type = 69;
3289 pub const HELP: Type = 70;
3290 pub const HOME: Type = 71;
3291 pub const INSERT: Type = 72;
3292 pub const PAGE_DOWN: Type = 73;
3293 pub const PAGE_UP: Type = 74;
3294 pub const ARROW_DOWN: Type = 75;
3295 pub const ARROW_LEFT: Type = 76;
3296 pub const ARROW_RIGHT: Type = 77;
3297 pub const ARROW_UP: Type = 78;
3298 pub const NUM_LOCK: Type = 79;
3299 pub const NUMPAD_0: Type = 80;
3300 pub const NUMPAD_1: Type = 81;
3301 pub const NUMPAD_2: Type = 82;
3302 pub const NUMPAD_3: Type = 83;
3303 pub const NUMPAD_4: Type = 84;
3304 pub const NUMPAD_5: Type = 85;
3305 pub const NUMPAD_6: Type = 86;
3306 pub const NUMPAD_7: Type = 87;
3307 pub const NUMPAD_8: Type = 88;
3308 pub const NUMPAD_9: Type = 89;
3309 pub const NUMPAD_ADD: Type = 90;
3310 pub const NUMPAD_BACKSPACE: Type = 91;
3311 pub const NUMPAD_CLEAR: Type = 92;
3312 pub const NUMPAD_CLEAR_ENTRY: Type = 93;
3313 pub const NUMPAD_COMMA: Type = 94;
3314 pub const NUMPAD_DECIMAL: Type = 95;
3315 pub const NUMPAD_DIVIDE: Type = 96;
3316 pub const NUMPAD_ENTER: Type = 97;
3317 pub const NUMPAD_EQUAL: Type = 98;
3318 pub const NUMPAD_MEMORY_ADD: Type = 99;
3319 pub const NUMPAD_MEMORY_CLEAR: Type = 100;
3320 pub const NUMPAD_MEMORY_RECALL: Type = 101;
3321 pub const NUMPAD_MEMORY_STORE: Type = 102;
3322 pub const NUMPAD_MEMORY_SUBTRACT: Type = 103;
3323 pub const NUMPAD_MULTIPLY: Type = 104;
3324 pub const NUMPAD_PAREN_LEFT: Type = 105;
3325 pub const NUMPAD_PAREN_RIGHT: Type = 106;
3326 pub const NUMPAD_SUBTRACT: Type = 107;
3327 pub const NUMPAD_SEPARATOR: Type = 108;
3328 pub const NUMPAD_UP: Type = 109;
3329 pub const NUMPAD_DOWN: Type = 110;
3330 pub const NUMPAD_RIGHT: Type = 111;
3331 pub const NUMPAD_LEFT: Type = 112;
3332 pub const NUMPAD_BEGIN: Type = 113;
3333 pub const NUMPAD_HOME: Type = 114;
3334 pub const NUMPAD_END: Type = 115;
3335 pub const NUMPAD_INSERT: Type = 116;
3336 pub const NUMPAD_DELETE: Type = 117;
3337 pub const NUMPAD_PAGE_UP: Type = 118;
3338 pub const NUMPAD_PAGE_DOWN: Type = 119;
3339 pub const ESCAPE: Type = 120;
3340 pub const F1: Type = 121;
3341 pub const F2: Type = 122;
3342 pub const F3: Type = 123;
3343 pub const F4: Type = 124;
3344 pub const F5: Type = 125;
3345 pub const F6: Type = 126;
3346 pub const F7: Type = 127;
3347 pub const F8: Type = 128;
3348 pub const F9: Type = 129;
3349 pub const F10: Type = 130;
3350 pub const F11: Type = 131;
3351 pub const F12: Type = 132;
3352 pub const F13: Type = 133;
3353 pub const F14: Type = 134;
3354 pub const F15: Type = 135;
3355 pub const F16: Type = 136;
3356 pub const F17: Type = 137;
3357 pub const F18: Type = 138;
3358 pub const F19: Type = 139;
3359 pub const F20: Type = 140;
3360 pub const F21: Type = 141;
3361 pub const F22: Type = 142;
3362 pub const F23: Type = 143;
3363 pub const F24: Type = 144;
3364 pub const F25: Type = 145;
3365 pub const FN: Type = 146;
3366 pub const FN_LOCK: Type = 147;
3367 pub const PRINT_SCREEN: Type = 148;
3368 pub const SCROLL_LOCK: Type = 149;
3369 pub const PAUSE: Type = 150;
3370 pub const BROWSER_BACK: Type = 151;
3371 pub const BROWSER_FAVORITES: Type = 152;
3372 pub const BROWSER_FORWARD: Type = 153;
3373 pub const BROWSER_HOME: Type = 154;
3374 pub const BROWSER_REFRESH: Type = 155;
3375 pub const BROWSER_SEARCH: Type = 156;
3376 pub const BROWSER_STOP: Type = 157;
3377 pub const EJECT: Type = 158;
3378 pub const LAUNCH_APP_1: Type = 159;
3379 pub const LAUNCH_APP_2: Type = 160;
3380 pub const LAUNCH_MAIL: Type = 161;
3381 pub const MEDIA_PLAY_PAUSE: Type = 162;
3382 pub const MEDIA_SELECT: Type = 163;
3383 pub const MEDIA_STOP: Type = 164;
3384 pub const MEDIA_TRACK_NEXT: Type = 165;
3385 pub const MEDIA_TRACK_PREVIOUS: Type = 166;
3386 pub const POWER: Type = 167;
3387 pub const SLEEP: Type = 168;
3388 pub const AUDIO_VOLUME_DOWN: Type = 169;
3389 pub const AUDIO_VOLUME_MUTE: Type = 170;
3390 pub const AUDIO_VOLUME_UP: Type = 171;
3391 pub const WAKE_UP: Type = 172;
3392 pub const COPY: Type = 173;
3393 pub const CUT: Type = 174;
3394 pub const PASTE: Type = 175;
3395 pub const MAX_VALUE: Type = 2147483647;
3396}
3397unsafe extern "C" {
3398 #[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"]
3399 pub fn ghostty_key_event_new(allocator: *const Allocator, event: *mut KeyEvent)
3400 -> Result::Type;
3401}
3402unsafe extern "C" {
3403 #[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"]
3404 pub fn ghostty_key_event_free(event: KeyEvent);
3405}
3406unsafe extern "C" {
3407 #[doc = " Set the key action (press, release, repeat).\n\n"]
3408 pub fn ghostty_key_event_set_action(event: KeyEvent, action: KeyAction::Type);
3409}
3410unsafe extern "C" {
3411 #[doc = " Get the key action (press, release, repeat).\n\n"]
3412 pub fn ghostty_key_event_get_action(event: KeyEvent) -> KeyAction::Type;
3413}
3414unsafe extern "C" {
3415 #[doc = " Set the physical key code.\n\n"]
3416 pub fn ghostty_key_event_set_key(event: KeyEvent, key: Key::Type);
3417}
3418unsafe extern "C" {
3419 #[doc = " Get the physical key code.\n\n"]
3420 pub fn ghostty_key_event_get_key(event: KeyEvent) -> Key::Type;
3421}
3422unsafe extern "C" {
3423 #[doc = " Set the modifier keys bitmask.\n\n"]
3424 pub fn ghostty_key_event_set_mods(event: KeyEvent, mods: Mods);
3425}
3426unsafe extern "C" {
3427 #[doc = " Get the modifier keys bitmask.\n\n"]
3428 pub fn ghostty_key_event_get_mods(event: KeyEvent) -> Mods;
3429}
3430unsafe extern "C" {
3431 #[doc = " Set the consumed modifiers bitmask.\n\n"]
3432 pub fn ghostty_key_event_set_consumed_mods(event: KeyEvent, consumed_mods: Mods);
3433}
3434unsafe extern "C" {
3435 #[doc = " Get the consumed modifiers bitmask.\n\n"]
3436 pub fn ghostty_key_event_get_consumed_mods(event: KeyEvent) -> Mods;
3437}
3438unsafe extern "C" {
3439 #[doc = " Set whether the key event is part of a composition sequence.\n\n"]
3440 pub fn ghostty_key_event_set_composing(event: KeyEvent, composing: bool);
3441}
3442unsafe extern "C" {
3443 #[doc = " Get whether the key event is part of a composition sequence.\n\n"]
3444 pub fn ghostty_key_event_get_composing(event: KeyEvent) -> bool;
3445}
3446unsafe extern "C" {
3447 #[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"]
3448 pub fn ghostty_key_event_set_utf8(
3449 event: KeyEvent,
3450 utf8: *const ::std::os::raw::c_char,
3451 len: usize,
3452 );
3453}
3454unsafe extern "C" {
3455 #[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"]
3456 pub fn ghostty_key_event_get_utf8(
3457 event: KeyEvent,
3458 len: *mut usize,
3459 ) -> *const ::std::os::raw::c_char;
3460}
3461unsafe extern "C" {
3462 #[doc = " Set the unshifted Unicode codepoint.\n\n"]
3463 pub fn ghostty_key_event_set_unshifted_codepoint(event: KeyEvent, codepoint: u32);
3464}
3465unsafe extern "C" {
3466 #[doc = " Get the unshifted Unicode codepoint.\n\n"]
3467 pub fn ghostty_key_event_get_unshifted_codepoint(event: KeyEvent) -> u32;
3468}
3469#[repr(C)]
3470#[derive(Debug, Copy, Clone)]
3471pub struct KeyEncoderImpl {
3472 _unused: [u8; 0],
3473}
3474#[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"]
3475pub type KeyEncoder = *mut KeyEncoderImpl;
3476#[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"]
3477pub type KittyKeyFlags = u8;
3478pub mod OptionAsAlt {
3479 #[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"]
3480 pub type Type = ::std::os::raw::c_uint;
3481 #[doc = " Option key is not treated as alt"]
3482 pub const FALSE: Type = 0;
3483 #[doc = " Option key is treated as alt"]
3484 pub const TRUE: Type = 1;
3485 #[doc = " Only left option key is treated as alt"]
3486 pub const LEFT: Type = 2;
3487 #[doc = " Only right option key is treated as alt"]
3488 pub const RIGHT: Type = 3;
3489 #[doc = " Only right option key is treated as alt"]
3490 pub const MAX_VALUE: Type = 2147483647;
3491}
3492pub mod KeyEncoderOption {
3493 #[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"]
3494 pub type Type = ::std::os::raw::c_uint;
3495 #[doc = " Terminal DEC mode 1: cursor key application mode (value: bool)"]
3496 pub const CURSOR_KEY_APPLICATION: Type = 0;
3497 #[doc = " Terminal DEC mode 66: keypad key application mode (value: bool)"]
3498 pub const KEYPAD_KEY_APPLICATION: Type = 1;
3499 #[doc = " Terminal DEC mode 1035: ignore keypad with numlock (value: bool)"]
3500 pub const IGNORE_KEYPAD_WITH_NUMLOCK: Type = 2;
3501 #[doc = " Terminal DEC mode 1036: alt sends escape prefix (value: bool)"]
3502 pub const ALT_ESC_PREFIX: Type = 3;
3503 #[doc = " xterm modifyOtherKeys mode 2 (value: bool)"]
3504 pub const MODIFY_OTHER_KEYS_STATE_2: Type = 4;
3505 #[doc = " Kitty keyboard protocol flags (value: GhosttyKittyKeyFlags bitmask)"]
3506 pub const KITTY_FLAGS: Type = 5;
3507 #[doc = " macOS option-as-alt setting (value: GhosttyOptionAsAlt)"]
3508 pub const MACOS_OPTION_AS_ALT: Type = 6;
3509 #[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"]
3510 pub const BACKARROW_KEY_MODE: Type = 7;
3511 #[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"]
3512 pub const MAX_VALUE: Type = 2147483647;
3513}
3514unsafe extern "C" {
3515 #[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"]
3516 pub fn ghostty_key_encoder_new(
3517 allocator: *const Allocator,
3518 encoder: *mut KeyEncoder,
3519 ) -> Result::Type;
3520}
3521unsafe extern "C" {
3522 #[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"]
3523 pub fn ghostty_key_encoder_free(encoder: KeyEncoder);
3524}
3525unsafe extern "C" {
3526 #[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"]
3527 pub fn ghostty_key_encoder_setopt(
3528 encoder: KeyEncoder,
3529 option: KeyEncoderOption::Type,
3530 value: *const ::std::os::raw::c_void,
3531 );
3532}
3533unsafe extern "C" {
3534 #[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"]
3535 pub fn ghostty_key_encoder_setopt_from_terminal(encoder: KeyEncoder, terminal: Terminal);
3536}
3537unsafe extern "C" {
3538 #[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"]
3539 pub fn ghostty_key_encoder_encode(
3540 encoder: KeyEncoder,
3541 event: KeyEvent,
3542 out_buf: *mut ::std::os::raw::c_char,
3543 out_buf_size: usize,
3544 out_len: *mut usize,
3545 ) -> Result::Type;
3546}
3547#[repr(C)]
3548#[derive(Debug, Copy, Clone)]
3549pub struct MouseEventImpl {
3550 _unused: [u8; 0],
3551}
3552#[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"]
3553pub type MouseEvent = *mut MouseEventImpl;
3554pub mod MouseAction {
3555 #[doc = " Mouse event action type.\n"]
3556 pub type Type = ::std::os::raw::c_uint;
3557 #[doc = " Mouse button was pressed."]
3558 pub const PRESS: Type = 0;
3559 #[doc = " Mouse button was released."]
3560 pub const RELEASE: Type = 1;
3561 #[doc = " Mouse moved."]
3562 pub const MOTION: Type = 2;
3563 #[doc = " Mouse moved."]
3564 pub const MAX_VALUE: Type = 2147483647;
3565}
3566pub mod MouseButton {
3567 #[doc = " Mouse button identity.\n"]
3568 pub type Type = ::std::os::raw::c_uint;
3569 pub const UNKNOWN: Type = 0;
3570 pub const LEFT: Type = 1;
3571 pub const RIGHT: Type = 2;
3572 pub const MIDDLE: Type = 3;
3573 pub const FOUR: Type = 4;
3574 pub const FIVE: Type = 5;
3575 pub const SIX: Type = 6;
3576 pub const SEVEN: Type = 7;
3577 pub const EIGHT: Type = 8;
3578 pub const NINE: Type = 9;
3579 pub const TEN: Type = 10;
3580 pub const ELEVEN: Type = 11;
3581 pub const MAX_VALUE: Type = 2147483647;
3582}
3583#[doc = " Mouse position in surface-space pixels.\n"]
3584#[repr(C)]
3585#[derive(Debug, Default, Copy, Clone)]
3586pub struct MousePosition {
3587 pub x: f32,
3588 pub y: f32,
3589}
3590#[allow(clippy::unnecessary_operation, clippy::identity_op)]
3591const _: () = {
3592 ["Size of MousePosition"][::std::mem::size_of::<MousePosition>() - 8usize];
3593 ["Alignment of MousePosition"][::std::mem::align_of::<MousePosition>() - 4usize];
3594 ["Offset of field: MousePosition::x"][::std::mem::offset_of!(MousePosition, x) - 0usize];
3595 ["Offset of field: MousePosition::y"][::std::mem::offset_of!(MousePosition, y) - 4usize];
3596};
3597unsafe extern "C" {
3598 #[doc = " Create a new mouse event instance.\n\n"]
3599 pub fn ghostty_mouse_event_new(
3600 allocator: *const Allocator,
3601 event: *mut MouseEvent,
3602 ) -> Result::Type;
3603}
3604unsafe extern "C" {
3605 #[doc = " Free a mouse event instance.\n\n"]
3606 pub fn ghostty_mouse_event_free(event: MouseEvent);
3607}
3608unsafe extern "C" {
3609 #[doc = " Set the event action.\n\n"]
3610 pub fn ghostty_mouse_event_set_action(event: MouseEvent, action: MouseAction::Type);
3611}
3612unsafe extern "C" {
3613 #[doc = " Get the event action.\n\n"]
3614 pub fn ghostty_mouse_event_get_action(event: MouseEvent) -> MouseAction::Type;
3615}
3616unsafe extern "C" {
3617 #[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"]
3618 pub fn ghostty_mouse_event_set_button(event: MouseEvent, button: MouseButton::Type);
3619}
3620unsafe extern "C" {
3621 #[doc = " Clear the event button.\n\n This sets the event button to \"none\".\n\n"]
3622 pub fn ghostty_mouse_event_clear_button(event: MouseEvent);
3623}
3624unsafe extern "C" {
3625 #[doc = " Get the event button.\n\n"]
3626 pub fn ghostty_mouse_event_get_button(
3627 event: MouseEvent,
3628 out_button: *mut MouseButton::Type,
3629 ) -> bool;
3630}
3631unsafe extern "C" {
3632 #[doc = " Set keyboard modifiers held during the event.\n\n"]
3633 pub fn ghostty_mouse_event_set_mods(event: MouseEvent, mods: Mods);
3634}
3635unsafe extern "C" {
3636 #[doc = " Get keyboard modifiers held during the event.\n\n"]
3637 pub fn ghostty_mouse_event_get_mods(event: MouseEvent) -> Mods;
3638}
3639unsafe extern "C" {
3640 #[doc = " Set the event position in surface-space pixels.\n\n"]
3641 pub fn ghostty_mouse_event_set_position(event: MouseEvent, position: MousePosition);
3642}
3643unsafe extern "C" {
3644 #[doc = " Get the event position in surface-space pixels.\n\n"]
3645 pub fn ghostty_mouse_event_get_position(event: MouseEvent) -> MousePosition;
3646}
3647#[repr(C)]
3648#[derive(Debug, Copy, Clone)]
3649pub struct MouseEncoderImpl {
3650 _unused: [u8; 0],
3651}
3652#[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"]
3653pub type MouseEncoder = *mut MouseEncoderImpl;
3654pub mod MouseTrackingMode {
3655 #[doc = " Mouse tracking mode.\n"]
3656 pub type Type = ::std::os::raw::c_uint;
3657 #[doc = " Mouse reporting disabled."]
3658 pub const NONE: Type = 0;
3659 #[doc = " X10 mouse mode."]
3660 pub const X10: Type = 1;
3661 #[doc = " Normal mouse mode (button press/release only)."]
3662 pub const NORMAL: Type = 2;
3663 #[doc = " Button-event tracking mode."]
3664 pub const BUTTON: Type = 3;
3665 #[doc = " Any-event tracking mode."]
3666 pub const ANY: Type = 4;
3667 #[doc = " Any-event tracking mode."]
3668 pub const MAX_VALUE: Type = 2147483647;
3669}
3670pub mod MouseFormat {
3671 #[doc = " Mouse output format.\n"]
3672 pub type Type = ::std::os::raw::c_uint;
3673 pub const X10: Type = 0;
3674 pub const UTF8: Type = 1;
3675 pub const SGR: Type = 2;
3676 pub const URXVT: Type = 3;
3677 pub const SGR_PIXELS: Type = 4;
3678 pub const MAX_VALUE: Type = 2147483647;
3679}
3680#[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"]
3681#[repr(C)]
3682#[derive(Debug, Default, Copy, Clone)]
3683pub struct MouseEncoderSize {
3684 #[doc = " Size of this struct in bytes. Must be set to sizeof(GhosttyMouseEncoderSize)."]
3685 pub size: usize,
3686 #[doc = " Full screen width in pixels."]
3687 pub screen_width: u32,
3688 #[doc = " Full screen height in pixels."]
3689 pub screen_height: u32,
3690 #[doc = " Cell width in pixels. Must be non-zero."]
3691 pub cell_width: u32,
3692 #[doc = " Cell height in pixels. Must be non-zero."]
3693 pub cell_height: u32,
3694 #[doc = " Top padding in pixels."]
3695 pub padding_top: u32,
3696 #[doc = " Bottom padding in pixels."]
3697 pub padding_bottom: u32,
3698 #[doc = " Right padding in pixels."]
3699 pub padding_right: u32,
3700 #[doc = " Left padding in pixels."]
3701 pub padding_left: u32,
3702}
3703#[allow(clippy::unnecessary_operation, clippy::identity_op)]
3704const _: () = {
3705 ["Size of MouseEncoderSize"][::std::mem::size_of::<MouseEncoderSize>() - 40usize];
3706 ["Alignment of MouseEncoderSize"][::std::mem::align_of::<MouseEncoderSize>() - 8usize];
3707 ["Offset of field: MouseEncoderSize::size"]
3708 [::std::mem::offset_of!(MouseEncoderSize, size) - 0usize];
3709 ["Offset of field: MouseEncoderSize::screen_width"]
3710 [::std::mem::offset_of!(MouseEncoderSize, screen_width) - 8usize];
3711 ["Offset of field: MouseEncoderSize::screen_height"]
3712 [::std::mem::offset_of!(MouseEncoderSize, screen_height) - 12usize];
3713 ["Offset of field: MouseEncoderSize::cell_width"]
3714 [::std::mem::offset_of!(MouseEncoderSize, cell_width) - 16usize];
3715 ["Offset of field: MouseEncoderSize::cell_height"]
3716 [::std::mem::offset_of!(MouseEncoderSize, cell_height) - 20usize];
3717 ["Offset of field: MouseEncoderSize::padding_top"]
3718 [::std::mem::offset_of!(MouseEncoderSize, padding_top) - 24usize];
3719 ["Offset of field: MouseEncoderSize::padding_bottom"]
3720 [::std::mem::offset_of!(MouseEncoderSize, padding_bottom) - 28usize];
3721 ["Offset of field: MouseEncoderSize::padding_right"]
3722 [::std::mem::offset_of!(MouseEncoderSize, padding_right) - 32usize];
3723 ["Offset of field: MouseEncoderSize::padding_left"]
3724 [::std::mem::offset_of!(MouseEncoderSize, padding_left) - 36usize];
3725};
3726pub mod MouseEncoderOption {
3727 #[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"]
3728 pub type Type = ::std::os::raw::c_uint;
3729 #[doc = " Mouse tracking mode (value: GhosttyMouseTrackingMode)."]
3730 pub const EVENT: Type = 0;
3731 #[doc = " Mouse output format (value: GhosttyMouseFormat)."]
3732 pub const FORMAT: Type = 1;
3733 #[doc = " Renderer size context (value: GhosttyMouseEncoderSize)."]
3734 pub const SIZE: Type = 2;
3735 #[doc = " Whether any mouse button is currently pressed (value: bool)."]
3736 pub const ANY_BUTTON_PRESSED: Type = 3;
3737 #[doc = " Whether to enable motion deduplication by last cell (value: bool)."]
3738 pub const TRACK_LAST_CELL: Type = 4;
3739 #[doc = " Whether to enable motion deduplication by last cell (value: bool)."]
3740 pub const MAX_VALUE: Type = 2147483647;
3741}
3742unsafe extern "C" {
3743 #[doc = " Create a new mouse encoder instance.\n\n"]
3744 pub fn ghostty_mouse_encoder_new(
3745 allocator: *const Allocator,
3746 encoder: *mut MouseEncoder,
3747 ) -> Result::Type;
3748}
3749unsafe extern "C" {
3750 #[doc = " Free a mouse encoder instance.\n\n"]
3751 pub fn ghostty_mouse_encoder_free(encoder: MouseEncoder);
3752}
3753unsafe extern "C" {
3754 #[doc = " Set an option on the mouse encoder.\n\n A null pointer value does nothing. It does not reset to defaults.\n\n"]
3755 pub fn ghostty_mouse_encoder_setopt(
3756 encoder: MouseEncoder,
3757 option: MouseEncoderOption::Type,
3758 value: *const ::std::os::raw::c_void,
3759 );
3760}
3761unsafe extern "C" {
3762 #[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"]
3763 pub fn ghostty_mouse_encoder_setopt_from_terminal(encoder: MouseEncoder, terminal: Terminal);
3764}
3765unsafe extern "C" {
3766 #[doc = " Reset internal encoder state.\n\n This clears motion deduplication state (last tracked cell).\n\n"]
3767 pub fn ghostty_mouse_encoder_reset(encoder: MouseEncoder);
3768}
3769unsafe extern "C" {
3770 #[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"]
3771 pub fn ghostty_mouse_encoder_encode(
3772 encoder: MouseEncoder,
3773 event: MouseEvent,
3774 out_buf: *mut ::std::os::raw::c_char,
3775 out_buf_size: usize,
3776 out_len: *mut usize,
3777 ) -> Result::Type;
3778}
3779unsafe extern "C" {
3780 #[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"]
3781 pub fn ghostty_paste_is_safe(data: *const ::std::os::raw::c_char, len: usize) -> bool;
3782}
3783unsafe extern "C" {
3784 #[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"]
3785 pub fn ghostty_paste_encode(
3786 data: *mut ::std::os::raw::c_char,
3787 data_len: usize,
3788 bracketed: bool,
3789 buf: *mut ::std::os::raw::c_char,
3790 buf_len: usize,
3791 out_written: *mut usize,
3792 ) -> Result::Type;
3793}