Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for middle position quick terminal #3100

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enum QuickTerminalPosition : String {
case bottom
case left
case right
case center

/// Set the loaded state for a window.
func setLoaded(_ window: NSWindow) {
Expand All @@ -25,6 +26,14 @@ enum QuickTerminalPosition : String {
width: screen.frame.width / 4,
height: screen.frame.height)
), display: false)

case .center:
window.setFrame(.init(
origin: window.frame.origin,
size: .init(
width: screen.frame.width / 2,
height: screen.frame.height / 3)
), display: false)
}
}

Expand Down Expand Up @@ -61,6 +70,10 @@ enum QuickTerminalPosition : String {

case .left, .right:
finalSize.height = screen.frame.height

case .center:
finalSize.width = screen.frame.width / 2
finalSize.height = screen.frame.height / 3
}

return finalSize
Expand All @@ -80,6 +93,9 @@ enum QuickTerminalPosition : String {

case .right:
return .init(x: screen.frame.maxX, y: 0)

case .center:
return .init(x: (screen.visibleFrame.maxX - window.frame.width) / 2, y: screen.visibleFrame.maxY - window.frame.width)
}
}

Expand All @@ -97,6 +113,9 @@ enum QuickTerminalPosition : String {

case .right:
return .init(x: screen.visibleFrame.maxX - window.frame.width, y: window.frame.origin.y)

case .center:
return .init(x: (screen.visibleFrame.maxX - window.frame.width) / 2, y: (screen.visibleFrame.maxY - window.frame.height) / 2)
}
}
}
2 changes: 2 additions & 0 deletions src/config/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ keybind: Keybinds = .{},
/// * `bottom` - Terminal appears at the bottom of the screen.
/// * `left` - Terminal appears at the left of the screen.
/// * `right` - Terminal appears at the right of the screen.
/// * `center` - Terminal appears at the center of the screen.
///
/// Changing this configuration requires restarting Ghostty completely.
@"quick-terminal-position": QuickTerminalPosition = .top,
Expand Down Expand Up @@ -5257,6 +5258,7 @@ pub const QuickTerminalPosition = enum {
bottom,
left,
right,
center,
};

/// See quick-terminal-screen
Expand Down
Loading