mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-06-05 15:08:38 +03:00
macos: new tab implementation
This commit is contained in:
@ -23,6 +23,20 @@ struct GhosttyApp: App {
|
|||||||
TerminalView(app: ghostty.app!)
|
TerminalView(app: ghostty.app!)
|
||||||
.modifier(WindowObservationModifier())
|
.modifier(WindowObservationModifier())
|
||||||
}
|
}
|
||||||
|
}.commands {
|
||||||
|
CommandGroup(after: .newItem) {
|
||||||
|
Button("New Tab", action: newTab).keyboardShortcut("t", modifiers: [.command])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new tab in the currently active window
|
||||||
|
func newTab() {
|
||||||
|
guard let currentWindow = NSApp.keyWindow else { return }
|
||||||
|
guard let windowController = currentWindow.windowController else { return }
|
||||||
|
windowController.newWindowForTab(nil)
|
||||||
|
if let newWindow = NSApp.keyWindow, currentWindow != newWindow {
|
||||||
|
currentWindow.addTabbedWindow(newWindow, ordered: .above)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ struct TerminalView: View {
|
|||||||
let app: ghostty_app_t
|
let app: ghostty_app_t
|
||||||
@FocusState private var surfaceFocus: Bool
|
@FocusState private var surfaceFocus: Bool
|
||||||
@Environment(\.isKeyWindow) private var isKeyWindow: Bool
|
@Environment(\.isKeyWindow) private var isKeyWindow: Bool
|
||||||
|
@Environment(\.openWindow) private var openWindow
|
||||||
@State private var title: String = "Ghostty"
|
@State private var title: String = "Ghostty"
|
||||||
|
|
||||||
// This is true if the terminal is considered "focused". The terminal is focused if
|
// This is true if the terminal is considered "focused". The terminal is focused if
|
||||||
|
@ -219,6 +219,8 @@ fn newTab(self: *App, msg: Message.NewWindow) !void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In embedded mode, it is up to the embedder to implement tabbing
|
||||||
|
// on their own.
|
||||||
if (comptime build_config.artifact != .exe) {
|
if (comptime build_config.artifact != .exe) {
|
||||||
log.warn("tabbing is not supported in embedded mode", .{});
|
log.warn("tabbing is not supported in embedded mode", .{});
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user