Skip to content
Open
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
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 @@ -216,6 +218,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 @@ -421,6 +425,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 @@ -720,6 +726,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
56 changes: 48 additions & 8 deletions Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4539,6 +4539,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 @@ -6341,7 +6353,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 @@ -7474,7 +7486,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 @@ -7614,7 +7626,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 @@ -8204,7 +8216,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 @@ -8343,7 +8355,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 @@ -8490,7 +8502,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 @@ -9572,6 +9584,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 All @@ -9580,7 +9620,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent

if matchShortcut(
event: event,
shortcut: StoredShortcut(key: "t", command: true, shift: false, option: true, control: false)
shortcut: KeyboardShortcutSettings.shortcut(for: .closeOtherTabsInPane)
) {
if let targetWindow = event.window ?? NSApp.keyWindow ?? NSApp.mainWindow,
targetWindow.identifier?.rawValue == "cmux.settings" {
Expand Down Expand Up @@ -11526,7 +11566,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