Skip to content
Merged
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
14 changes: 14 additions & 0 deletions Sources/Shellraiser/App/ShellraiserApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ struct WorkspaceCommands: Commands {

Divider()

Button("Previous Workspace") {
manager.selectPreviousWorkspace()
}
.keyboardShortcut(.upArrow, modifiers: [.command])
.disabled(manager.workspaces.count <= 1)

Button("Next Workspace") {
manager.selectNextWorkspace()
}
.keyboardShortcut(.downArrow, modifiers: [.command])
.disabled(manager.workspaces.count <= 1)

Divider()

Button("Jump to Next Completed Session") {
manager.jumpToNextCompletedSession()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ extension WorkspaceManager {
}
}

if hasCommand, !hasOption, !hasControl, !hasShift {
switch event.keyCode {
case 126:
return selectPreviousWorkspace()
case 125:
return selectNextWorkspace()
default:
break
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

guard hasCommand, !hasOption, !hasControl else { return false }

guard let key = event.charactersIgnoringModifiers?.lowercased(), !key.isEmpty else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,30 @@ extension WorkspaceManager {
index > 0 && index <= workspaces.count
}

/// Selects the workspace before the current one, wrapping to the last.
/// Returns true if a switch occurred.
@discardableResult
func selectPreviousWorkspace() -> Bool {
guard workspaces.count > 1,
let currentId = window.selectedWorkspaceId,
let currentIndex = workspaces.firstIndex(where: { $0.id == currentId }) else { return false }
let previousIndex = (currentIndex - 1 + workspaces.count) % workspaces.count
selectWorkspace(workspaces[previousIndex].id)
return true
}

/// Selects the workspace after the current one, wrapping to the first.
/// Returns true if a switch occurred.
@discardableResult
func selectNextWorkspace() -> Bool {
guard workspaces.count > 1,
let currentId = window.selectedWorkspaceId,
let currentIndex = workspaces.firstIndex(where: { $0.id == currentId }) else { return false }
let nextIndex = (currentIndex + 1) % workspaces.count
selectWorkspace(workspaces[nextIndex].id)
return true
}

/// Restores first-responder focus to the selected workspace's active terminal surface.
func restoreSelectedWorkspaceTerminalFocus() {
guard let workspaceId = window.selectedWorkspaceId,
Expand Down
Loading