mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-28 19:46:35 +00:00
config: change quick terminal size C layout to tagged union
This commit is contained in:
@@ -7200,25 +7200,36 @@ pub const QuickTerminalSize = struct {
|
||||
|
||||
/// C API structure for QuickTerminalSize
|
||||
pub const C = extern struct {
|
||||
primary: CSize,
|
||||
secondary: CSize,
|
||||
};
|
||||
primary: C.Size,
|
||||
secondary: C.Size,
|
||||
|
||||
pub const CSize = extern struct {
|
||||
type: Type,
|
||||
value: u32,
|
||||
pub const Size = extern struct {
|
||||
tag: Tag,
|
||||
value: Value,
|
||||
|
||||
pub const Type = enum(u8) { none, percentage, pixels };
|
||||
pub const Tag = enum(u8) { none, percentage, pixels };
|
||||
|
||||
pub const none: CSize = .{ .type = .none, .value = 0 };
|
||||
pub const Value = extern union {
|
||||
percentage: f32,
|
||||
pixels: u32,
|
||||
};
|
||||
|
||||
fn percentage(v: f32) CSize {
|
||||
return .{ .type = .percentage, .value = @bitCast(v) };
|
||||
}
|
||||
pub const none: C.Size = .{ .tag = .none, .value = undefined };
|
||||
|
||||
fn pixels(v: u32) CSize {
|
||||
return .{ .type = .pixels, .value = v };
|
||||
}
|
||||
pub fn percentage(v: f32) C.Size {
|
||||
return .{
|
||||
.tag = .percentage,
|
||||
.value = .{ .percentage = v },
|
||||
};
|
||||
}
|
||||
|
||||
pub fn pixels(v: u32) C.Size {
|
||||
return .{
|
||||
.tag = .pixels,
|
||||
.value = .{ .pixels = v },
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
pub fn cval(self: QuickTerminalSize) C {
|
||||
|
||||
Reference in New Issue
Block a user