feat: add support for middle position in quick terminal

This update introduces the ability to launch the quick terminal
in the middle position.

Resolves #2494
This commit is contained in:
Damien Mehala
2024-12-24 14:44:21 +01:00
parent b1756b93b8
commit 1497e90f95
2 changed files with 20 additions and 0 deletions

View File

@ -5,6 +5,7 @@ enum QuickTerminalPosition : String {
case bottom case bottom
case left case left
case right case right
case middle
/// Set the loaded state for a window. /// Set the loaded state for a window.
func setLoaded(_ window: NSWindow) { func setLoaded(_ window: NSWindow) {
@ -25,6 +26,14 @@ enum QuickTerminalPosition : String {
width: screen.frame.width / 4, width: screen.frame.width / 4,
height: screen.frame.height) height: screen.frame.height)
), display: false) ), display: false)
case .middle:
window.setFrame(.init(
origin: window.frame.origin,
size: .init(
width: screen.frame.width / 2,
height: screen.frame.height / 3)
), display: false)
} }
} }
@ -61,6 +70,10 @@ enum QuickTerminalPosition : String {
case .left, .right: case .left, .right:
finalSize.height = screen.frame.height finalSize.height = screen.frame.height
case .middle:
finalSize.width = screen.frame.width / 2
finalSize.height = screen.frame.height / 3
} }
return finalSize return finalSize
@ -80,6 +93,9 @@ enum QuickTerminalPosition : String {
case .right: case .right:
return .init(x: screen.frame.maxX, y: 0) return .init(x: screen.frame.maxX, y: 0)
case .middle:
return .init(x: (screen.visibleFrame.maxX - window.frame.width) / 2, y: screen.visibleFrame.maxY - window.frame.width)
} }
} }
@ -97,6 +113,9 @@ enum QuickTerminalPosition : String {
case .right: case .right:
return .init(x: screen.visibleFrame.maxX - window.frame.width, y: window.frame.origin.y) return .init(x: screen.visibleFrame.maxX - window.frame.width, y: window.frame.origin.y)
case .middle:
return .init(x: (screen.visibleFrame.maxX - window.frame.width) / 2, y: (screen.visibleFrame.maxY - window.frame.height) / 2)
} }
} }
} }

View File

@ -5257,6 +5257,7 @@ pub const QuickTerminalPosition = enum {
bottom, bottom,
left, left,
right, right,
middle,
}; };
/// See quick-terminal-screen /// See quick-terminal-screen