Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions GhosttyTabs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
A5001405 /* PanelContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001415 /* PanelContentView.swift */; };
A5001406 /* Workspace.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001416 /* Workspace.swift */; };
A5001407 /* WorkspaceContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001417 /* WorkspaceContentView.swift */; };
A5008390 /* WorkspaceTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5008391 /* WorkspaceTab.swift */; };
A5008392 /* WorkspaceTabBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5008393 /* WorkspaceTabBarView.swift */; };
A5001093 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001090 /* AppDelegate.swift */; };
A5001094 /* NotificationsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001091 /* NotificationsPage.swift */; };
A5001095 /* TerminalNotificationStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001092 /* TerminalNotificationStore.swift */; };
Expand Down Expand Up @@ -212,6 +214,8 @@
A5001419 /* MarkdownPanelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Panels/MarkdownPanelView.swift; sourceTree = "<group>"; };
A5001416 /* Workspace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Workspace.swift; sourceTree = "<group>"; };
A5001417 /* WorkspaceContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkspaceContentView.swift; sourceTree = "<group>"; };
A5008391 /* WorkspaceTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkspaceTab.swift; sourceTree = "<group>"; };
A5008393 /* WorkspaceTabBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkspaceTabBarView.swift; sourceTree = "<group>"; };
A5001090 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A5001091 /* NotificationsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsPage.swift; sourceTree = "<group>"; };
A5001092 /* TerminalNotificationStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalNotificationStore.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -413,6 +417,8 @@
A5001511 /* UITestRecorder.swift */,
A5001520 /* PostHogAnalytics.swift */,
A5001416 /* Workspace.swift */,
A5008391 /* WorkspaceTab.swift */,
A5008393 /* WorkspaceTabBarView.swift */,
A5001417 /* WorkspaceContentView.swift */,
A5001014 /* GhosttyConfig.swift */,
A5001015 /* GhosttyTerminalView.swift */,
Expand Down Expand Up @@ -708,6 +714,8 @@
A5001501 /* UITestRecorder.swift in Sources */,
A5001521 /* PostHogAnalytics.swift in Sources */,
A5001406 /* Workspace.swift in Sources */,
A5008390 /* WorkspaceTab.swift in Sources */,
A5008392 /* WorkspaceTabBarView.swift in Sources */,
A5001407 /* WorkspaceContentView.swift in Sources */,
A5001004 /* GhosttyConfig.swift in Sources */,
A5001005 /* GhosttyTerminalView.swift in Sources */,
Expand Down
54 changes: 47 additions & 7 deletions Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4399,6 +4399,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
)
}

func requestCommandPaletteRenameWorkspaceTab(
preferredWindow: NSWindow? = nil,
source: String = "shortcut.renameWorkspaceTab"
) {
postCommandPaletteRequest(
name: .commandPaletteRenameWorkspaceTabRequested,
preferredWindow: preferredWindow,
source: source,
markPending: true
)
}

private func clearCommandPalettePendingOpen(for window: NSWindow?) {
guard let window,
let windowId = mainWindowId(for: window) else { return }
Expand Down Expand Up @@ -6169,7 +6181,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
terminalPanel.sendText(text)
}

panelsCancellable = tab.$panels
panelsCancellable = tab.panelsPublisher
.map { _ in () }
.sink { _ in finishIfReady() }
readyObserver = NotificationCenter.default.addObserver(
Expand Down Expand Up @@ -7302,7 +7314,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
surfaceId == browserPanelId else { return }
recordFocusedState()
})
panelsCancellable = tab.$panels
panelsCancellable = tab.panelsPublisher
.map { _ in () }
.sink { _ in recordFocusedState() }
DispatchQueue.main.asyncAfter(deadline: .now() + 6.0) { [weak self] in
Expand Down Expand Up @@ -7442,7 +7454,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
surfaceId == panelId else { return }
Task { @MainActor in evaluate() }
})
panelsCancellable = tab.$panels
panelsCancellable = tab.panelsPublisher
.map { _ in () }
.sink { _ in
Task { @MainActor in evaluate() }
Expand Down Expand Up @@ -8032,7 +8044,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
) { _ in
Task { @MainActor in evaluate() }
})
panelsCancellable = workspace.$panels
panelsCancellable = workspace.panelsPublisher
.map { _ in () }
.sink { _ in
Task { @MainActor in evaluate() }
Expand Down Expand Up @@ -8171,7 +8183,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
observedWorkspaceId != workspace.id {
observedWorkspaceId = workspace.id
panelsCancellable?.cancel()
panelsCancellable = workspace.$panels
panelsCancellable = workspace.panelsPublisher
.map { _ in () }
.sink { _ in attemptResolve() }
}
Expand Down Expand Up @@ -8318,7 +8330,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
return
}
panelsCancellable?.cancel()
panelsCancellable = workspace.$panels
panelsCancellable = workspace.panelsPublisher
.map { _ in () }
.sink { _ in attemptFocus() }
guard let terminalPanel = workspace.terminalPanel(for: surfaceId) else {
Expand Down Expand Up @@ -9389,6 +9401,34 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
return true
}

// Workspace tab navigation: Cmd+Opt+] / Cmd+Opt+[ / Cmd+Shift+T
if matchShortcut(event: event, shortcut: KeyboardShortcutSettings.shortcut(for: .nextWorkspaceTab)) {
tabManager?.selectNextWorkspaceTab()
return true
}

if matchShortcut(event: event, shortcut: KeyboardShortcutSettings.shortcut(for: .prevWorkspaceTab)) {
tabManager?.selectPreviousWorkspaceTab()
return true
}

if matchShortcut(event: event, shortcut: KeyboardShortcutSettings.shortcut(for: .newWorkspaceTab)) {
tabManager?.createWorkspaceTabInSelectedWorkspace()
return true
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if matchShortcut(event: event, shortcut: KeyboardShortcutSettings.shortcut(for: .renameWorkspaceTab)) {
requestCommandPaletteRenameWorkspaceTab(
preferredWindow: commandPaletteTargetWindow ?? event.window ?? NSApp.keyWindow ?? NSApp.mainWindow
)
return true
}

if matchShortcut(event: event, shortcut: KeyboardShortcutSettings.shortcut(for: .closeWorkspaceTab)) {
tabManager?.closeSelectedWorkspaceTab()
return true
}

if matchShortcut(event: event, shortcut: KeyboardShortcutSettings.shortcut(for: .renameWorkspace)) {
return requestRenameWorkspaceViaCommandPalette(
preferredWindow: commandPaletteTargetWindow ?? event.window ?? NSApp.keyWindow ?? NSApp.mainWindow
Expand Down Expand Up @@ -11330,7 +11370,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
Task { @MainActor in finishIfFocused() }
})
if let workspace = tabManager.tabs.first(where: { $0.id == tabId }) {
cancellables.append(workspace.$panels
cancellables.append(workspace.panelsPublisher
.map { _ in () }
.sink { _ in
Task { @MainActor in finishIfFocused() }
Expand Down
Loading