restores Helder in all its glory

This commit is contained in:
2026-09-28 11:34:49 +02:00
parent c2b38b853c
commit 1d29d0952d
280 changed files with 29205 additions and 7 deletions
+39
View File
@@ -0,0 +1,39 @@
import Foundation
import HelderCore
/// What choosing a launcher row does.
public enum LauncherChoice: Equatable {
/// "Open new project…": the folder picker.
case chooseFolder
case open(path: String)
}
/// The launcher's rows and keyboard cursor: row 0 is "Open new project…", then the recent projects.
public struct LauncherList: Equatable {
public private(set) var recents: [RecentProject]
public private(set) var selection = 0
/// `excluding` drops the window's own project, so ⇧⌘O never offers the folder that is already open.
public init(recents: [RecentProject] = [], excluding root: String? = nil) {
self.recents = recents.filter { $0.path != root }
}
public var count: Int { recents.count + 1 }
/// Moves the cursor, clamped to the first and last row.
public mutating func move(by step: Int) {
selection = min(max(selection + step, 0), count - 1)
}
public mutating func select(_ index: Int) {
selection = min(max(index, 0), count - 1)
}
public func choice(at index: Int) -> LauncherChoice? {
if index == 0 { return .chooseFolder }
guard recents.indices.contains(index - 1) else { return nil }
return .open(path: recents[index - 1].path)
}
public var selectedChoice: LauncherChoice? { choice(at: selection) }
}