macOS: Add support for quick terminal sizing configuration

Added C bindings for the already existing quick-terminal-size
configuration. Created a new QuickTerminalSize struct to hold these
values in Swift. Updated the QuickTerminal implementation to use the
user's configuration if supplied. Retains defaults. Also adds support to
customize the width of the quick terminal (height if quick terminal is
set to right or left).
This commit is contained in:
Friedrich Stoltzfus
2025-06-11 14:41:35 -04:00
committed by Mitchell Hashimoto
parent 5c464e855d
commit 63cd424678
7 changed files with 167 additions and 48 deletions

View File

@@ -7198,6 +7198,35 @@ pub const QuickTerminalSize = struct {
height: u32,
};
/// C API structure for QuickTerminalSize
pub const C = extern struct {
primary_type: u8, // 0 = none, 1 = percentage, 2 = pixels
primary_value: f32,
secondary_type: u8, // 0 = none, 1 = percentage, 2 = pixels
secondary_value: f32,
};
pub fn cval(self: QuickTerminalSize) C {
return .{
.primary_type = if (self.primary) |p| switch (p) {
.percentage => 1,
.pixels => 2,
} else 0,
.primary_value = if (self.primary) |p| switch (p) {
.percentage => |v| v,
.pixels => |v| @floatFromInt(v),
} else 0,
.secondary_type = if (self.secondary) |s| switch (s) {
.percentage => 1,
.pixels => 2,
} else 0,
.secondary_value = if (self.secondary) |s| switch (s) {
.percentage => |v| v,
.pixels => |v| @floatFromInt(v),
} else 0,
};
}
pub fn calculate(
self: QuickTerminalSize,
position: QuickTerminalPosition,