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