mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: add configuration support for quick-terminal-size
This commit is contained in:
@ -67,7 +67,7 @@ class QuickTerminalController: BaseTerminalController {
|
|||||||
syncAppearance()
|
syncAppearance()
|
||||||
|
|
||||||
// Setup our initial size based on our configured position
|
// Setup our initial size based on our configured position
|
||||||
position.setLoaded(window)
|
position.setLoaded(window, size: ghostty.config.quickTerminalSize)
|
||||||
|
|
||||||
// Setup our content
|
// Setup our content
|
||||||
window.contentView = NSHostingView(rootView: TerminalView(
|
window.contentView = NSHostingView(rootView: TerminalView(
|
||||||
|
@ -7,7 +7,7 @@ enum QuickTerminalPosition : String {
|
|||||||
case right
|
case right
|
||||||
|
|
||||||
/// Set the loaded state for a window.
|
/// Set the loaded state for a window.
|
||||||
func setLoaded(_ window: NSWindow) {
|
func setLoaded(_ window: NSWindow, size: Double) {
|
||||||
guard let screen = window.screen ?? NSScreen.main else { return }
|
guard let screen = window.screen ?? NSScreen.main else { return }
|
||||||
switch (self) {
|
switch (self) {
|
||||||
case .top, .bottom:
|
case .top, .bottom:
|
||||||
@ -15,14 +15,14 @@ enum QuickTerminalPosition : String {
|
|||||||
origin: window.frame.origin,
|
origin: window.frame.origin,
|
||||||
size: .init(
|
size: .init(
|
||||||
width: screen.frame.width,
|
width: screen.frame.width,
|
||||||
height: screen.frame.height / 4)
|
height: screen.frame.height * CGFloat(size))
|
||||||
), display: false)
|
), display: false)
|
||||||
|
|
||||||
case .left, .right:
|
case .left, .right:
|
||||||
window.setFrame(.init(
|
window.setFrame(.init(
|
||||||
origin: window.frame.origin,
|
origin: window.frame.origin,
|
||||||
size: .init(
|
size: .init(
|
||||||
width: screen.frame.width / 4,
|
width: screen.frame.width / CGFloat(size),
|
||||||
height: screen.frame.height)
|
height: screen.frame.height)
|
||||||
), display: false)
|
), display: false)
|
||||||
}
|
}
|
||||||
|
@ -382,6 +382,14 @@ extension Ghostty {
|
|||||||
let str = String(cString: ptr)
|
let str = String(cString: ptr)
|
||||||
return QuickTerminalScreen(fromGhosttyConfig: str) ?? .main
|
return QuickTerminalScreen(fromGhosttyConfig: str) ?? .main
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var quickTerminalSize: Double {
|
||||||
|
guard let config = self.config else { return 0.25 }
|
||||||
|
var v: Double = 0.25
|
||||||
|
let key = "quick-terminal-size"
|
||||||
|
_ = ghostty_config_get(config, &v, key, UInt(key.count))
|
||||||
|
return v
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var resizeOverlay: ResizeOverlay {
|
var resizeOverlay: ResizeOverlay {
|
||||||
|
@ -1266,6 +1266,21 @@ keybind: Keybinds = .{},
|
|||||||
/// by the operating system.
|
/// by the operating system.
|
||||||
@"quick-terminal-screen": QuickTerminalScreen = .main,
|
@"quick-terminal-screen": QuickTerminalScreen = .main,
|
||||||
|
|
||||||
|
/// This size of the quick terminal screen based on the quick-terminal-position.
|
||||||
|
///
|
||||||
|
/// This value should be a floating-point number between 0 and 1,
|
||||||
|
/// where 1 means it occupies the entire screen.
|
||||||
|
///
|
||||||
|
/// The default value is 0.25, meaning the quick terminal will occupy 25%
|
||||||
|
/// of the screen's dimension. When quick-terminal-position is set to `left` or `right`,
|
||||||
|
/// the dimension is the screen's width. When quick-terminal-position is set to `top` or `bottom`,
|
||||||
|
/// the dimension is the screen's height.
|
||||||
|
///
|
||||||
|
/// Examples:
|
||||||
|
/// * Setting to 0.5 will make the quick terminal occupy 50% of the screen.
|
||||||
|
/// * Setting to 1 will make it occupy 100% of the screen.
|
||||||
|
@"quick-terminal-size": f64 = 0.25,
|
||||||
|
|
||||||
/// Whether to enable shell integration auto-injection or not. Shell integration
|
/// Whether to enable shell integration auto-injection or not. Shell integration
|
||||||
/// greatly enhances the terminal experience by enabling a number of features:
|
/// greatly enhances the terminal experience by enabling a number of features:
|
||||||
///
|
///
|
||||||
@ -2654,6 +2669,9 @@ pub fn finalize(self: *Config) !void {
|
|||||||
if (self.@"window-width" > 0) self.@"window-width" = @max(10, self.@"window-width");
|
if (self.@"window-width" > 0) self.@"window-width" = @max(10, self.@"window-width");
|
||||||
if (self.@"window-height" > 0) self.@"window-height" = @max(4, self.@"window-height");
|
if (self.@"window-height" > 0) self.@"window-height" = @max(4, self.@"window-height");
|
||||||
|
|
||||||
|
// Clamp quick terminal size
|
||||||
|
if (self.@"quick-window-size" > 0) self.@"quick-window-size" = @min(0.25, @max(1, self.@"quick-window-size"));
|
||||||
|
|
||||||
// If URLs are disabled, cut off the first link. The first link is
|
// If URLs are disabled, cut off the first link. The first link is
|
||||||
// always the URL matcher.
|
// always the URL matcher.
|
||||||
if (!self.@"link-url") self.link.links.items = self.link.links.items[1..];
|
if (!self.@"link-url") self.link.links.items = self.link.links.items[1..];
|
||||||
|
Reference in New Issue
Block a user