From 64f3c31a29d99f959a638988e36a7f5167d590c6 Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Sat, 15 Aug 2026 14:30:45 +0800 Subject: [PATCH 1/2] vt-sys: make it #[no_std] --- crates/libghostty-vt-sys/src/bindings.rs | 1061 ++++++++--------- crates/libghostty-vt-sys/src/lib.rs | 21 +- .../libghostty-vt-sys/tools/gen_bindings.rs | 1 + 3 files changed, 536 insertions(+), 547 deletions(-) diff --git a/crates/libghostty-vt-sys/src/bindings.rs b/crates/libghostty-vt-sys/src/bindings.rs index 1a7ce5e..4e66db9 100644 --- a/crates/libghostty-vt-sys/src/bindings.rs +++ b/crates/libghostty-vt-sys/src/bindings.rs @@ -80,7 +80,7 @@ pub const KITTY_KEY_REPORT_ASSOCIATED: u8 = 16; pub const KITTY_KEY_ALL: u8 = 31; pub mod Result { #[doc = " Result codes for libghostty-vt operations."] - pub type Type = ::std::os::raw::c_int; + pub type Type = ::core::ffi::c_int; #[doc = " Operation completed successfully"] pub const SUCCESS: Type = 0; #[doc = " Operation failed due to failed allocation"] @@ -191,7 +191,7 @@ pub struct OscCommandImpl { pub type OscCommand = *mut OscCommandImpl; pub mod FormatterFormat { #[doc = " Terminal content output format.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " Plain text (no escape sequences)."] pub const PLAIN: Type = 0; #[doc = " VT sequences preserving colors, styles, URLs, etc."] @@ -212,16 +212,16 @@ pub struct String { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of String"][::std::mem::size_of::() - 16usize]; - ["Alignment of String"][::std::mem::align_of::() - 8usize]; - ["Offset of field: String::ptr"][::std::mem::offset_of!(String, ptr) - 0usize]; - ["Offset of field: String::len"][::std::mem::offset_of!(String, len) - 8usize]; + ["Size of String"][::core::mem::size_of::() - 16usize]; + ["Alignment of String"][::core::mem::align_of::() - 8usize]; + ["Offset of field: String::ptr"][::core::mem::offset_of!(String, ptr) - 0usize]; + ["Offset of field: String::len"][::core::mem::offset_of!(String, len) - 8usize]; }; impl Default for String { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } @@ -239,17 +239,17 @@ pub struct Buffer { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of Buffer"][::std::mem::size_of::() - 24usize]; - ["Alignment of Buffer"][::std::mem::align_of::() - 8usize]; - ["Offset of field: Buffer::ptr"][::std::mem::offset_of!(Buffer, ptr) - 0usize]; - ["Offset of field: Buffer::cap"][::std::mem::offset_of!(Buffer, cap) - 8usize]; - ["Offset of field: Buffer::len"][::std::mem::offset_of!(Buffer, len) - 16usize]; + ["Size of Buffer"][::core::mem::size_of::() - 24usize]; + ["Alignment of Buffer"][::core::mem::align_of::() - 8usize]; + ["Offset of field: Buffer::ptr"][::core::mem::offset_of!(Buffer, ptr) - 0usize]; + ["Offset of field: Buffer::cap"][::core::mem::offset_of!(Buffer, cap) - 8usize]; + ["Offset of field: Buffer::len"][::core::mem::offset_of!(Buffer, len) - 16usize]; }; impl Default for Buffer { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } @@ -265,10 +265,10 @@ pub struct SurfacePosition { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of SurfacePosition"][::std::mem::size_of::() - 16usize]; - ["Alignment of SurfacePosition"][::std::mem::align_of::() - 8usize]; - ["Offset of field: SurfacePosition::x"][::std::mem::offset_of!(SurfacePosition, x) - 0usize]; - ["Offset of field: SurfacePosition::y"][::std::mem::offset_of!(SurfacePosition, y) - 8usize]; + ["Size of SurfacePosition"][::core::mem::size_of::() - 16usize]; + ["Alignment of SurfacePosition"][::core::mem::align_of::() - 8usize]; + ["Offset of field: SurfacePosition::x"][::core::mem::offset_of!(SurfacePosition, x) - 0usize]; + ["Offset of field: SurfacePosition::y"][::core::mem::offset_of!(SurfacePosition, y) - 8usize]; }; #[doc = " A borrowed list of Unicode scalar values.\n\n Values are encoded as uint32_t scalar values. The memory is not owned by this\n struct. The pointer is only valid for the lifetime documented by the API that\n consumes or produces it.\n\n APIs may document special handling for NULL + len 0, such as “use defaults”."] #[repr(C)] @@ -281,42 +281,42 @@ pub struct Codepoints { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of Codepoints"][::std::mem::size_of::() - 16usize]; - ["Alignment of Codepoints"][::std::mem::align_of::() - 8usize]; - ["Offset of field: Codepoints::ptr"][::std::mem::offset_of!(Codepoints, ptr) - 0usize]; - ["Offset of field: Codepoints::len"][::std::mem::offset_of!(Codepoints, len) - 8usize]; + ["Size of Codepoints"][::core::mem::size_of::() - 16usize]; + ["Alignment of Codepoints"][::core::mem::align_of::() - 8usize]; + ["Offset of field: Codepoints::ptr"][::core::mem::offset_of!(Codepoints, ptr) - 0usize]; + ["Offset of field: Codepoints::len"][::core::mem::offset_of!(Codepoints, len) - 8usize]; }; impl Default for Codepoints { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } } unsafe extern "C" { #[doc = " Return a pointer to a null-terminated JSON string describing the\n layout of every C API struct for the current target.\n\n This is primarily useful for language bindings that can't easily\n set C struct fields and need to do so via byte offsets. For example,\n WebAssembly modules can't share struct definitions with the host.\n\n Example (abbreviated):\n {\n \"GhosttyMouseEncoderSize\": {\n \"size\": 40,\n \"align\": 8,\n \"fields\": {\n \"size\": { \"offset\": 0, \"size\": 8, \"type\": \"u64\" },\n \"screen_width\": { \"offset\": 8, \"size\": 4, \"type\": \"u32\" },\n \"screen_height\": { \"offset\": 12, \"size\": 4, \"type\": \"u32\" },\n \"cell_width\": { \"offset\": 16, \"size\": 4, \"type\": \"u32\" },\n \"cell_height\": { \"offset\": 20, \"size\": 4, \"type\": \"u32\" },\n \"padding_top\": { \"offset\": 24, \"size\": 4, \"type\": \"u32\" },\n \"padding_bottom\": { \"offset\": 28, \"size\": 4, \"type\": \"u32\" },\n \"padding_right\": { \"offset\": 32, \"size\": 4, \"type\": \"u32\" },\n \"padding_left\": { \"offset\": 36, \"size\": 4, \"type\": \"u32\" }\n }\n }\n }\n\n The returned pointer is valid for the lifetime of the process.\n"] - pub fn ghostty_type_json() -> *const ::std::os::raw::c_char; + pub fn ghostty_type_json() -> *const ::core::ffi::c_char; } #[doc = " Function table for custom memory allocator operations.\n\n This vtable defines the interface for a custom memory allocator. All\n function pointers must be valid and non-NULL.\n\n\n If you're not going to use a custom allocator, you can ignore all of\n this. All functions that take an allocator pointer allow NULL to use a\n default allocator.\n\n The interface is based on the Zig allocator interface. I'll say up front\n that it is easy to look at this interface and think \"wow, this is really\n overcomplicated\". The reason for this complexity is well thought out by\n the Zig folks, and it enables a diverse set of allocation strategies\n as shown by the Zig ecosystem. As a consolation, please note that many\n of the arguments are only needed for advanced use cases and can be\n safely ignored in simple implementations. For example, if you look at\n the Zig implementation of the libc allocator in `lib/std/heap.zig`\n (search for CAllocator), you'll see it is very simple.\n\n We chose to align with the Zig allocator interface because:\n\n 1. It is a proven interface that serves a wide variety of use cases\n in the real world via the Zig ecosystem. It's shown to work.\n\n 2. Our core implementation itself is Zig, and this lets us very\n cheaply and easily convert between C and Zig allocators.\n\n NOTE(mitchellh): In the future, we can have default implementations of\n resize/remap and allow those to be null."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct AllocatorVtable { #[doc = " Return a pointer to `len` bytes with specified `alignment`, or return\n `NULL` indicating the allocation failed.\n\n be a power of two between 1 and 16 inclusive."] - pub alloc: ::std::option::Option< + pub alloc: ::core::option::Option< unsafe extern "C" fn( - ctx: *mut ::std::os::raw::c_void, + ctx: *mut ::core::ffi::c_void, len: usize, alignment: u8, ret_addr: usize, - ) -> *mut ::std::os::raw::c_void, + ) -> *mut ::core::ffi::c_void, >, #[doc = " Attempt to expand or shrink memory in place.\n\n `memory_len` must equal the length requested from the most recent\n successful call to `alloc`, `resize`, or `remap`. `alignment` must\n equal the same value that was passed as the `alignment` parameter to\n the original `alloc` call.\n\n `new_len` must be greater than zero.\n"] - pub resize: ::std::option::Option< + pub resize: ::core::option::Option< unsafe extern "C" fn( - ctx: *mut ::std::os::raw::c_void, - memory: *mut ::std::os::raw::c_void, + ctx: *mut ::core::ffi::c_void, + memory: *mut ::core::ffi::c_void, memory_len: usize, alignment: u8, new_len: usize, @@ -324,21 +324,21 @@ pub struct AllocatorVtable { ) -> bool, >, #[doc = " Attempt to expand or shrink memory, allowing relocation.\n\n `memory_len` must equal the length requested from the most recent\n successful call to `alloc`, `resize`, or `remap`. `alignment` must\n equal the same value that was passed as the `alignment` parameter to\n the original `alloc` call.\n\n A non-`NULL` return value indicates the resize was successful. The\n allocation may have same address, or may have been relocated. In either\n case, the allocation now has size of `new_len`. A `NULL` return value\n indicates that the resize would be equivalent to allocating new memory,\n copying the bytes from the old memory, and then freeing the old memory.\n In such case, it is more efficient for the caller to perform the copy.\n\n `new_len` must be greater than zero.\n"] - pub remap: ::std::option::Option< + pub remap: ::core::option::Option< unsafe extern "C" fn( - ctx: *mut ::std::os::raw::c_void, - memory: *mut ::std::os::raw::c_void, + ctx: *mut ::core::ffi::c_void, + memory: *mut ::core::ffi::c_void, memory_len: usize, alignment: u8, new_len: usize, ret_addr: usize, - ) -> *mut ::std::os::raw::c_void, + ) -> *mut ::core::ffi::c_void, >, #[doc = " Free and invalidate a region of memory.\n\n `memory_len` must equal the length requested from the most recent\n successful call to `alloc`, `resize`, or `remap`. `alignment` must\n equal the same value that was passed as the `alignment` parameter to\n the original `alloc` call.\n"] - pub free: ::std::option::Option< + pub free: ::core::option::Option< unsafe extern "C" fn( - ctx: *mut ::std::os::raw::c_void, - memory: *mut ::std::os::raw::c_void, + ctx: *mut ::core::ffi::c_void, + memory: *mut ::core::ffi::c_void, memory_len: usize, alignment: u8, ret_addr: usize, @@ -347,38 +347,38 @@ pub struct AllocatorVtable { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of AllocatorVtable"][::std::mem::size_of::() - 32usize]; - ["Alignment of AllocatorVtable"][::std::mem::align_of::() - 8usize]; + ["Size of AllocatorVtable"][::core::mem::size_of::() - 32usize]; + ["Alignment of AllocatorVtable"][::core::mem::align_of::() - 8usize]; ["Offset of field: AllocatorVtable::alloc"] - [::std::mem::offset_of!(AllocatorVtable, alloc) - 0usize]; + [::core::mem::offset_of!(AllocatorVtable, alloc) - 0usize]; ["Offset of field: AllocatorVtable::resize"] - [::std::mem::offset_of!(AllocatorVtable, resize) - 8usize]; + [::core::mem::offset_of!(AllocatorVtable, resize) - 8usize]; ["Offset of field: AllocatorVtable::remap"] - [::std::mem::offset_of!(AllocatorVtable, remap) - 16usize]; + [::core::mem::offset_of!(AllocatorVtable, remap) - 16usize]; ["Offset of field: AllocatorVtable::free"] - [::std::mem::offset_of!(AllocatorVtable, free) - 24usize]; + [::core::mem::offset_of!(AllocatorVtable, free) - 24usize]; }; #[doc = " Custom memory allocator.\n\n For functions that take an allocator pointer, a NULL pointer indicates\n that the default allocator should be used. The default allocator will\n be libc malloc/free if we're linking to libc. If libc isn't linked,\n a custom allocator is used (currently Zig's SMP allocator).\n\n\n Usage example:\n GhosttyAllocator allocator = {\n .vtable = &my_allocator_vtable,\n .ctx = my_allocator_state\n };"] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Allocator { #[doc = " Opaque context pointer passed to all vtable functions.\n This allows the allocator implementation to maintain state\n or reference external resources needed for memory management."] - pub ctx: *mut ::std::os::raw::c_void, + pub ctx: *mut ::core::ffi::c_void, #[doc = " Pointer to the allocator's vtable containing function pointers\n for memory operations (alloc, resize, remap, free)."] pub vtable: *const AllocatorVtable, } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of Allocator"][::std::mem::size_of::() - 16usize]; - ["Alignment of Allocator"][::std::mem::align_of::() - 8usize]; - ["Offset of field: Allocator::ctx"][::std::mem::offset_of!(Allocator, ctx) - 0usize]; - ["Offset of field: Allocator::vtable"][::std::mem::offset_of!(Allocator, vtable) - 8usize]; + ["Size of Allocator"][::core::mem::size_of::() - 16usize]; + ["Alignment of Allocator"][::core::mem::align_of::() - 8usize]; + ["Offset of field: Allocator::ctx"][::core::mem::offset_of!(Allocator, ctx) - 0usize]; + ["Offset of field: Allocator::vtable"][::core::mem::offset_of!(Allocator, vtable) - 8usize]; }; impl Default for Allocator { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } @@ -393,7 +393,7 @@ unsafe extern "C" { } pub mod OptimizeMode { #[doc = " Build optimization mode."] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; pub const DEBUG: Type = 0; pub const RELEASE_SAFE: Type = 1; pub const RELEASE_SMALL: Type = 2; @@ -402,7 +402,7 @@ pub mod OptimizeMode { } pub mod BuildInfo { #[doc = " Build info data types that can be queried.\n\n Each variant documents the expected output pointer type."] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " Invalid data type. Never results in any data extraction."] pub const INVALID: Type = 0; #[doc = " Whether SIMD-accelerated code paths are enabled.\n\n Output type: bool *"] @@ -430,10 +430,8 @@ pub mod BuildInfo { } unsafe extern "C" { #[doc = " Query a compile-time build configuration value.\n\n The caller must pass a pointer to the correct output type for the\n requested data (see GhosttyBuildInfo variants for types).\n\n data type is invalid\n"] - pub fn ghostty_build_info( - data: BuildInfo::Type, - out: *mut ::std::os::raw::c_void, - ) -> Result::Type; + pub fn ghostty_build_info(data: BuildInfo::Type, out: *mut ::core::ffi::c_void) + -> Result::Type; } #[doc = " RGB color value.\n"] #[repr(C)] @@ -448,11 +446,11 @@ pub struct ColorRgb { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of ColorRgb"][::std::mem::size_of::() - 3usize]; - ["Alignment of ColorRgb"][::std::mem::align_of::() - 1usize]; - ["Offset of field: ColorRgb::r"][::std::mem::offset_of!(ColorRgb, r) - 0usize]; - ["Offset of field: ColorRgb::g"][::std::mem::offset_of!(ColorRgb, g) - 1usize]; - ["Offset of field: ColorRgb::b"][::std::mem::offset_of!(ColorRgb, b) - 2usize]; + ["Size of ColorRgb"][::core::mem::size_of::() - 3usize]; + ["Alignment of ColorRgb"][::core::mem::align_of::() - 1usize]; + ["Offset of field: ColorRgb::r"][::core::mem::offset_of!(ColorRgb, r) - 0usize]; + ["Offset of field: ColorRgb::g"][::core::mem::offset_of!(ColorRgb, g) - 1usize]; + ["Offset of field: ColorRgb::b"][::core::mem::offset_of!(ColorRgb, b) - 2usize]; }; #[doc = " Palette color index (0-255).\n"] pub type ColorPaletteIndex = u8; @@ -464,33 +462,33 @@ pub struct ColorPaletteMask { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of ColorPaletteMask"][::std::mem::size_of::() - 32usize]; - ["Alignment of ColorPaletteMask"][::std::mem::align_of::() - 8usize]; + ["Size of ColorPaletteMask"][::core::mem::size_of::() - 32usize]; + ["Alignment of ColorPaletteMask"][::core::mem::align_of::() - 8usize]; ["Offset of field: ColorPaletteMask::bits"] - [::std::mem::offset_of!(ColorPaletteMask, bits) - 0usize]; + [::core::mem::offset_of!(ColorPaletteMask, bits) - 0usize]; }; #[doc = " An entry in Ghostty's X11 color name table.\n"] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ColorX11Entry { #[doc = " Null-terminated color name. NULL marks the end of the table."] - pub name: *const ::std::os::raw::c_char, + pub name: *const ::core::ffi::c_char, #[doc = " The RGB value of the color."] pub color: ColorRgb, } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of ColorX11Entry"][::std::mem::size_of::() - 16usize]; - ["Alignment of ColorX11Entry"][::std::mem::align_of::() - 8usize]; - ["Offset of field: ColorX11Entry::name"][::std::mem::offset_of!(ColorX11Entry, name) - 0usize]; + ["Size of ColorX11Entry"][::core::mem::size_of::() - 16usize]; + ["Alignment of ColorX11Entry"][::core::mem::align_of::() - 8usize]; + ["Offset of field: ColorX11Entry::name"][::core::mem::offset_of!(ColorX11Entry, name) - 0usize]; ["Offset of field: ColorX11Entry::color"] - [::std::mem::offset_of!(ColorX11Entry, color) - 8usize]; + [::core::mem::offset_of!(ColorX11Entry, color) - 8usize]; }; impl Default for ColorX11Entry { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } @@ -502,7 +500,7 @@ unsafe extern "C" { unsafe extern "C" { #[doc = " Parse an X11 color name.\n\n The color name is resolved from Ghostty's embedded rgb.txt table.\n Leading and trailing spaces and tabs are trimmed, and matching is\n ASCII case-insensitive. Hex values are not accepted by this function.\n\n matches or @p name is NULL\n"] pub fn ghostty_color_parse_x11( - name: *const ::std::os::raw::c_char, + name: *const ::core::ffi::c_char, len: usize, out: *mut ColorRgb, ) -> Result::Type; @@ -510,7 +508,7 @@ unsafe extern "C" { unsafe extern "C" { #[doc = " Parse a flexible Ghostty color value.\n\n Accepts Ghostty's terminal color syntax: X11 color names, hex colors\n in 3-, 6-, 9-, or 12-digit form (the leading # is optional for 3- and\n 6-digit values), and rgb:// or\n rgbi:// specifications. Leading and trailing spaces\n and tabs are trimmed.\n\n fails or @p value is NULL\n"] pub fn ghostty_color_parse( - value: *const ::std::os::raw::c_char, + value: *const ::core::ffi::c_char, len: usize, out: *mut ColorRgb, ) -> Result::Type; @@ -518,7 +516,7 @@ unsafe extern "C" { unsafe extern "C" { #[doc = " Parse a Ghostty palette entry.\n\n Accepts Ghostty palette config syntax: N=COLOR. N is a palette index\n from 0 to 255 in decimal or in 0x, 0o, or 0b-prefixed form. Spaces and\n tabs around N and COLOR are ignored. COLOR accepts the same syntax as\n ghostty_color_parse().\n\n failure, including index overflow\n"] pub fn ghostty_color_parse_palette_entry( - value: *const ::std::os::raw::c_char, + value: *const ::core::ffi::c_char, len: usize, out_index: *mut u8, out_rgb: *mut ColorRgb, @@ -561,7 +559,7 @@ unsafe extern "C" { } pub mod ColorScheme { #[doc = " Color scheme reported in response to a CSI ? 996 n query.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; pub const LIGHT: Type = 0; pub const DARK: Type = 1; pub const MAX_VALUE: Type = 2147483647; @@ -580,21 +578,21 @@ pub struct DeviceAttributesPrimary { #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { ["Size of DeviceAttributesPrimary"] - [::std::mem::size_of::() - 144usize]; + [::core::mem::size_of::() - 144usize]; ["Alignment of DeviceAttributesPrimary"] - [::std::mem::align_of::() - 8usize]; + [::core::mem::align_of::() - 8usize]; ["Offset of field: DeviceAttributesPrimary::conformance_level"] - [::std::mem::offset_of!(DeviceAttributesPrimary, conformance_level) - 0usize]; + [::core::mem::offset_of!(DeviceAttributesPrimary, conformance_level) - 0usize]; ["Offset of field: DeviceAttributesPrimary::features"] - [::std::mem::offset_of!(DeviceAttributesPrimary, features) - 2usize]; + [::core::mem::offset_of!(DeviceAttributesPrimary, features) - 2usize]; ["Offset of field: DeviceAttributesPrimary::num_features"] - [::std::mem::offset_of!(DeviceAttributesPrimary, num_features) - 136usize]; + [::core::mem::offset_of!(DeviceAttributesPrimary, num_features) - 136usize]; }; impl Default for DeviceAttributesPrimary { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } @@ -613,15 +611,15 @@ pub struct DeviceAttributesSecondary { #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { ["Size of DeviceAttributesSecondary"] - [::std::mem::size_of::() - 6usize]; + [::core::mem::size_of::() - 6usize]; ["Alignment of DeviceAttributesSecondary"] - [::std::mem::align_of::() - 2usize]; + [::core::mem::align_of::() - 2usize]; ["Offset of field: DeviceAttributesSecondary::device_type"] - [::std::mem::offset_of!(DeviceAttributesSecondary, device_type) - 0usize]; + [::core::mem::offset_of!(DeviceAttributesSecondary, device_type) - 0usize]; ["Offset of field: DeviceAttributesSecondary::firmware_version"] - [::std::mem::offset_of!(DeviceAttributesSecondary, firmware_version) - 2usize]; + [::core::mem::offset_of!(DeviceAttributesSecondary, firmware_version) - 2usize]; ["Offset of field: DeviceAttributesSecondary::rom_cartridge"] - [::std::mem::offset_of!(DeviceAttributesSecondary, rom_cartridge) - 4usize]; + [::core::mem::offset_of!(DeviceAttributesSecondary, rom_cartridge) - 4usize]; }; #[doc = " Tertiary device attributes (DA3) response data.\n\n Returned as part of GhosttyDeviceAttributes in response to a CSI = c query.\n Response format: DCS ! | D...D ST (DECRPTUI).\n"] #[repr(C)] @@ -633,11 +631,11 @@ pub struct DeviceAttributesTertiary { #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { ["Size of DeviceAttributesTertiary"] - [::std::mem::size_of::() - 4usize]; + [::core::mem::size_of::() - 4usize]; ["Alignment of DeviceAttributesTertiary"] - [::std::mem::align_of::() - 4usize]; + [::core::mem::align_of::() - 4usize]; ["Offset of field: DeviceAttributesTertiary::unit_id"] - [::std::mem::offset_of!(DeviceAttributesTertiary, unit_id) - 0usize]; + [::core::mem::offset_of!(DeviceAttributesTertiary, unit_id) - 0usize]; }; #[doc = " Device attributes response data for all three DA levels.\n\n Filled by the device_attributes callback in response to CSI c,\n CSI > c, or CSI = c queries. The terminal uses whichever sub-struct\n matches the request type.\n"] #[repr(C)] @@ -649,20 +647,20 @@ pub struct DeviceAttributes { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of DeviceAttributes"][::std::mem::size_of::() - 160usize]; - ["Alignment of DeviceAttributes"][::std::mem::align_of::() - 8usize]; + ["Size of DeviceAttributes"][::core::mem::size_of::() - 160usize]; + ["Alignment of DeviceAttributes"][::core::mem::align_of::() - 8usize]; ["Offset of field: DeviceAttributes::primary"] - [::std::mem::offset_of!(DeviceAttributes, primary) - 0usize]; + [::core::mem::offset_of!(DeviceAttributes, primary) - 0usize]; ["Offset of field: DeviceAttributes::secondary"] - [::std::mem::offset_of!(DeviceAttributes, secondary) - 144usize]; + [::core::mem::offset_of!(DeviceAttributes, secondary) - 144usize]; ["Offset of field: DeviceAttributes::tertiary"] - [::std::mem::offset_of!(DeviceAttributes, tertiary) - 152usize]; + [::core::mem::offset_of!(DeviceAttributes, tertiary) - 152usize]; }; impl Default for DeviceAttributes { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } @@ -671,14 +669,14 @@ unsafe extern "C" { #[doc = " Encode a color scheme report into an escape sequence.\n\n Encodes a color scheme report into the provided buffer. Dark color schemes\n emit ESC [ ? 997 ; 1 n, and light color schemes emit ESC [ ? 997 ; 2 n.\n The encoded bytes are identical to the terminal's internal CSI ? 996 n\n query response.\n\n Hosts should gate unsolicited sends on GHOSTTY_MODE_COLOR_SCHEME_REPORT\n (mode 2031) being set, which can be checked via the mode getters.\n\n If the buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE\n and writes the required buffer size to @p out_written. The caller can\n then retry with a sufficiently sized buffer.\n\n GHOSTTY_OUT_OF_SPACE, the required buffer size.\n is too small"] pub fn ghostty_color_scheme_report_encode( scheme: ColorScheme::Type, - buf: *mut ::std::os::raw::c_char, + buf: *mut ::core::ffi::c_char, buf_len: usize, out_written: *mut usize, ) -> Result::Type; } pub mod FocusEvent { #[doc = " Focus event types for focus reporting mode (mode 1004)."] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " Terminal window gained focus"] pub const GAINED: Type = 0; #[doc = " Terminal window lost focus"] @@ -690,7 +688,7 @@ unsafe extern "C" { #[doc = " Encode a focus event into a terminal escape sequence.\n\n Encodes a focus gained (CSI I) or focus lost (CSI O) report into the\n provided buffer.\n\n If the buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE\n and writes the required buffer size to @p out_written. The caller can\n then retry with a sufficiently sized buffer.\n\n GHOSTTY_OUT_OF_SPACE, the required buffer size.\n is too small"] pub fn ghostty_focus_encode( event: FocusEvent::Type, - buf: *mut ::std::os::raw::c_char, + buf: *mut ::core::ffi::c_char, buf_len: usize, out_written: *mut usize, ) -> Result::Type; @@ -701,7 +699,7 @@ pub type Cell = u64; pub type Row = u64; pub mod CellContentTag { #[doc = " Cell content tag.\n\n Describes what kind of content a cell holds.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " A single codepoint (may be zero for empty)."] pub const CODEPOINT: Type = 0; #[doc = " A codepoint that is part of a multi-codepoint grapheme cluster."] @@ -715,7 +713,7 @@ pub mod CellContentTag { } pub mod CellWide { #[doc = " Cell wide property.\n\n Describes the width behavior of a cell.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " Not a wide character, cell width 1."] pub const NARROW: Type = 0; #[doc = " Wide character, cell width 2."] @@ -729,7 +727,7 @@ pub mod CellWide { } pub mod CellSemanticContent { #[doc = " Semantic content type of a cell.\n\n Set by semantic prompt sequences (OSC 133) to distinguish between\n command output, user input, and shell prompt text.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " Regular output content, such as command output."] pub const OUTPUT: Type = 0; #[doc = " Content that is part of user input."] @@ -741,7 +739,7 @@ pub mod CellSemanticContent { } pub mod CellData { #[doc = " Cell data types.\n\n These values specify what type of data to extract from a cell\n using `ghostty_cell_get`.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " Invalid data type. Never results in any data extraction."] pub const INVALID: Type = 0; #[doc = " The codepoint of the cell (0 if empty or bg-color-only).\n\n Output type: uint32_t *"] @@ -771,7 +769,7 @@ pub mod CellData { } pub mod RowSemanticPrompt { #[doc = " Row semantic prompt state.\n\n Indicates whether any cells in a row are part of a shell prompt,\n as reported by OSC 133 sequences.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " No prompt cells in this row."] pub const NONE: Type = 0; #[doc = " Prompt cells exist and this is a primary prompt line."] @@ -783,7 +781,7 @@ pub mod RowSemanticPrompt { } pub mod RowData { #[doc = " Row data types.\n\n These values specify what type of data to extract from a row\n using `ghostty_row_get`.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; #[doc = " Invalid data type. Never results in any data extraction."] pub const INVALID: Type = 0; #[doc = " Whether this row is soft-wrapped.\n\n Output type: bool *"] @@ -810,7 +808,7 @@ unsafe extern "C" { pub fn ghostty_cell_get( cell: Cell, data: CellData::Type, - out: *mut ::std::os::raw::c_void, + out: *mut ::core::ffi::c_void, ) -> Result::Type; } unsafe extern "C" { @@ -819,7 +817,7 @@ unsafe extern "C" { cell: Cell, count: usize, keys: *const CellData::Type, - values: *mut *mut ::std::os::raw::c_void, + values: *mut *mut ::core::ffi::c_void, out_written: *mut usize, ) -> Result::Type; } @@ -828,7 +826,7 @@ unsafe extern "C" { pub fn ghostty_row_get( row: Row, data: RowData::Type, - out: *mut ::std::os::raw::c_void, + out: *mut ::core::ffi::c_void, ) -> Result::Type; } unsafe extern "C" { @@ -837,7 +835,7 @@ unsafe extern "C" { row: Row, count: usize, keys: *const RowData::Type, - values: *mut *mut ::std::os::raw::c_void, + values: *mut *mut ::core::ffi::c_void, out_written: *mut usize, ) -> Result::Type; } @@ -845,7 +843,7 @@ unsafe extern "C" { pub type StyleId = u16; pub mod StyleColorTag { #[doc = " Style color tags.\n\n These values identify the type of color in a style color.\n Use the tag to determine which field in the color value union to access.\n"] - pub type Type = ::std::os::raw::c_uint; + pub type Type = ::core::ffi::c_uint; pub const NONE: Type = 0; pub const PALETTE: Type = 1; pub const RGB: Type = 2; @@ -861,20 +859,20 @@ pub union StyleColorValue { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of StyleColorValue"][::std::mem::size_of::() - 8usize]; - ["Alignment of StyleColorValue"][::std::mem::align_of::() - 8usize]; + ["Size of StyleColorValue"][::core::mem::size_of::() - 8usize]; + ["Alignment of StyleColorValue"][::core::mem::align_of::() - 8usize]; ["Offset of field: StyleColorValue::palette"] - [::std::mem::offset_of!(StyleColorValue, palette) - 0usize]; + [::core::mem::offset_of!(StyleColorValue, palette) - 0usize]; ["Offset of field: StyleColorValue::rgb"] - [::std::mem::offset_of!(StyleColorValue, rgb) - 0usize]; + [::core::mem::offset_of!(StyleColorValue, rgb) - 0usize]; ["Offset of field: StyleColorValue::_padding"] - [::std::mem::offset_of!(StyleColorValue, _padding) - 0usize]; + [::core::mem::offset_of!(StyleColorValue, _padding) - 0usize]; }; impl Default for StyleColorValue { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } @@ -888,16 +886,16 @@ pub struct StyleColor { } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of StyleColor"][::std::mem::size_of::() - 16usize]; - ["Alignment of StyleColor"][::std::mem::align_of::() - 8usize]; - ["Offset of field: StyleColor::tag"][::std::mem::offset_of!(StyleColor, tag) - 0usize]; - ["Offset of field: StyleColor::value"][::std::mem::offset_of!(StyleColor, value) - 8usize]; + ["Size of StyleColor"][::core::mem::size_of::() - 16usize]; + ["Alignment of StyleColor"][::core::mem::align_of::() - 8usize]; + ["Offset of field: StyleColor::tag"][::core::mem::offset_of!(StyleColor, tag) - 0usize]; + ["Offset of field: StyleColor::value"][::core::mem::offset_of!(StyleColor, value) - 8usize]; }; impl Default for StyleColor { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } @@ -919,33 +917,33 @@ pub struct Style { pub strikethrough: bool, pub overline: bool, #[doc = "< One of GHOSTTY_SGR_UNDERLINE_* values"] - pub underline: ::std::os::raw::c_int, + pub underline: ::core::ffi::c_int, } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { - ["Size of Style"][::std::mem::size_of::