import CoreGraphics import Foundation import HelderCore /// Where a focus request sends the keyboard. Views observe `WorkspaceModel.focusRequest` and take /// first responder when it names them. public enum FocusTarget: Equatable, Sendable { case panel(Panel) /// ⌘C without a selection, outside a terminal: the commit message field. case commitMessage } /// A focus request; `id` makes a repeated request for the same target observable. public struct FocusRequest: Equatable { public var target: FocusTarget public var id = UUID() public init(_ target: FocusTarget) { self.target = target } } /// A text selection read from the focused text view, for ⌘→ and ⌘F. public struct TextSelectionInfo: Equatable, Sendable { public var text: String /// 1-based, inclusive. public var startLine: Int public var endLine: Int public init(text: String, startLine: Int, endLine: Int) { self.text = text self.startLine = startLine self.endLine = endLine } } public enum ZoomStep: Equatable, Sendable { case reset case bigger case smaller } /// Everything the user can ask a workspace window to do. Views, menus and the key router all call /// `WorkspaceModel.perform(_:)` with one of these, so one shortcut and its button can never drift apart. public enum Command: Equatable, Sendable { // MARK: Overlays /// ⌘F; the seed is the first line of the current selection. case showSearch(seed: String) /// ⌘N case showNote /// `?` case showShortcuts /// ⇧⌘O: the other recent projects. case showRecentProjects /// ⌘↑/⌘↓ from the editor. case showRecentFiles(initialSelection: Int) /// Right-click or ⌘→ on a row; `anchor` is in window coordinates. case showContextMenu(ContextTarget, anchor: CGPoint) /// Esc: closes the one open overlay, with its own close behaviour (the note saves, Diff restores the mode). case dismissOverlay /// The confirm overlay's yes. case confirmPending /// The name prompt's ↵ with the typed name. case submitName(String) /// The pass-on prompt's ↵: inserts `text` into the agent and toasts `reference`. case passToAgent(text: String, reference: String?) // MARK: Launcher case launcherMove(Int) case launcherSelect(Int) case launcherActivate // MARK: Layout and focus /// ⌘G: the Source Control pane toggle. case toggleGit /// A title-bar pane toggle: shows or hides one column. case togglePane(Panel) /// ⌘L case toggleAutoFit /// ⌘. case toggleHidden /// Moves keyboard focus to a column (and takes first responder). case focus(Panel) /// ⌘←/⌘→ outside a text field. case focusNeighbour(step: Int) // MARK: Row cursor in Source Control and Explorer /// ↑/↓ case moveRowCursor(Int) /// ↵: git row opens its half, a file opens, a folder toggles. case openSelectedRow /// ⌘→ on a row: its context menu, anchored to the column's right edge. case openRowMenu // MARK: Editor case open(String, OpenOptions) /// ⌘S case save /// ⌘W: closes the active file, or the window when none is open. case closeFileOrWindow /// ⌘M case cycleMode /// ⌘→ with a selection: the pass-on prompt for it. nil falls back to the editor's line selection. case passSelection(TextSelectionInfo?) /// ⌘A outside a text field: the whole open file in its pane. case selectAllInFile // MARK: Git /// ⌘↵ case commit /// ⌘P case push /// ⌘C without a selection, outside a terminal case focusCommitMessage // MARK: Note /// ⌘P while the note is open. case passNote // MARK: Clean copy /// The clean-copy popup's Copy and ⌘↩: copies its text and closes it. case copyCleanCopy // MARK: Project and window /// ⌘O case openFolder case openRecentProject(String) /// ⌘R: git, tree and the open file, re-read from disk. case refresh /// ⇧⌘N case newWindow /// View → Actual Size, Zoom In, Zoom Out: the code and terminal text size. case zoom(ZoomStep) /// A context-menu item. case context(ContextAction) }