mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
Merge pull request #1293 from mitchellh/mrn/window-new-tab-pos-macos
macos: respect window-new-tab-position config setting when opening new tabs
This commit is contained in:
@ -124,13 +124,26 @@ class TerminalManager {
|
|||||||
tg.removeWindow(window)
|
tg.removeWindow(window)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our windows start our invisible. We need to make it visible. If we
|
// Our windows start out invisible. We need to make it visible. If we
|
||||||
// don't do this then various features such as window blur won't work because
|
// don't do this then various features such as window blur won't work because
|
||||||
// the macOS APIs only work on a visible window.
|
// the macOS APIs only work on a visible window.
|
||||||
controller.showWindow(self)
|
controller.showWindow(self)
|
||||||
|
|
||||||
// Add the window to the tab group and show it
|
// Add the window to the tab group and show it.
|
||||||
parent.addTabbedWindow(window, ordered: .above)
|
switch ghostty.windowNewTabPosition {
|
||||||
|
case "end":
|
||||||
|
// If we already have a tab group and we want the new tab to open at the end,
|
||||||
|
// then we use the last window in the tab group as the parent.
|
||||||
|
if let last = parent.tabGroup?.windows.last {
|
||||||
|
last.addTabbedWindow(window, ordered: .above)
|
||||||
|
} else {
|
||||||
|
fallthrough
|
||||||
|
}
|
||||||
|
case "current": fallthrough
|
||||||
|
default:
|
||||||
|
parent.addTabbedWindow(window, ordered: .above)
|
||||||
|
}
|
||||||
|
|
||||||
window.makeKeyAndOrderFront(self)
|
window.makeKeyAndOrderFront(self)
|
||||||
|
|
||||||
// It takes an event loop cycle until the macOS tabGroup state becomes
|
// It takes an event loop cycle until the macOS tabGroup state becomes
|
||||||
|
@ -84,6 +84,16 @@ extension Ghostty {
|
|||||||
guard let ptr = v else { return "" }
|
guard let ptr = v else { return "" }
|
||||||
return String(cString: ptr)
|
return String(cString: ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// window-new-tab-position
|
||||||
|
var windowNewTabPosition: String {
|
||||||
|
guard let config = self.config else { return "" }
|
||||||
|
var v: UnsafePointer<Int8>? = nil
|
||||||
|
let key = "window-new-tab-position"
|
||||||
|
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return "" }
|
||||||
|
guard let ptr = v else { return "" }
|
||||||
|
return String(cString: ptr)
|
||||||
|
}
|
||||||
|
|
||||||
/// True if we need to confirm before quitting.
|
/// True if we need to confirm before quitting.
|
||||||
var needsConfirmQuit: Bool {
|
var needsConfirmQuit: Bool {
|
||||||
|
Reference in New Issue
Block a user