-
-
Notifications
You must be signed in to change notification settings - Fork 473
Expand file tree
/
Copy pathScrollCommand.swift
More file actions
21 lines (19 loc) · 737 Bytes
/
ScrollCommand.swift
File metadata and controls
21 lines (19 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import AppKit
import Common
struct ScrollCommand: Command {
let args: ScrollCmdArgs
/*conforms*/ let shouldResetClosedWindowsCache = false
func run(_ env: CmdEnv, _ io: CmdIo) async throws -> Bool {
let root = focus.workspace.rootTilingContainer
guard root.layout == .scrolling else {
return io.err("scroll command only works when the workspace root container uses the scrolling layout")
}
let direction: CardinalDirection = switch args.direction.val {
case .left: .left
case .right: .right
}
root.clampScrollingIndex()
guard let target = root.scroll(in: direction) else { return true }
return target.focusWindow()
}
}