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) /// The Git view's commit message field; ⌘G and ⌘C without a selection ask for it. 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) /// `?` 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 (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 and the title bar's Git button: opens or closes the full-screen Git view. case toggleGit /// Esc with the Git view open and no overlay over it. case closeGitView /// ⌘D and the title bar's Schema button, in a Laravel app: opens or closes the full-screen Schema view. case toggleSchemaView /// Esc with nothing selected in the Schema view, and its Close button. case closeSchemaView /// ⌘1–⌘3 and the title-bar pane toggles: 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 the Explorer /// ↑/↓ case moveRowCursor(Int) /// ↵: 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: Explorer tail /// The tail block's close button: ends `tail -f` and removes the block. case closeTail // MARK: Git /// ⌘↵ and the Commit button: always runs git, so its refusal shows in the console. case commit /// The Commit and push button: pushes only after a successful commit. case commitAndPush /// The Add, Stage & Commit button: stages every change, then commits without a push. case stageAllAndCommit /// The Gen. Commit Message button: the Claude CLI writes a message for the staged changes. case generateCommitMessage /// ⌘P case push case pull case stage([String]) case unstage([String]) /// A branch row in the Git view; a remote one switches by its local name. case switchBranch(String, remote: Bool) /// ↵ in the Git console. case submitConsoleInput /// ⌘C without a selection, outside a terminal: opens the Git view on its message field. case focusCommitMessage // MARK: Schema view /// The Run button: `php artisan helder:schema`, then the dump is re-read. case runSchemaDump /// Closes the view and pastes the prompt that writes `HelderSchemaCommand.php` into the agent, unsent. case generateSchemaCommand case copySchemaPrompt /// The detail panel's Pass on to Claude: `@schema:` into the agent. case passSchemaTable(String) case copySchemaTableName(String) /// The top bar's command path: closes the view and opens the command in the editor. case openSchemaCommandFile /// Esc with a table selected. case clearSchemaSelection /// Esc in the table search while it holds text. case clearSchemaSearch // MARK: Clean copy /// The clean-copy popup's Copy and ⌘↩: copies its text and closes it. case copyCleanCopy // MARK: Read aloud /// The title bar's Stop button. case stopReading // 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) }