diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2026-06-16 12:08:21 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2026-06-16 12:22:47 +0200 |
| commit | 501fdce29e4d2c46c4708ad7f44056878e0db3fa (patch) | |
| tree | db923b77037db9f5b37600a6e34c3bb2e8a971be /Sources/NorgKit/Models/TaskStatus.swift | |
Initial extraction from Norganize1.0.0
Diffstat (limited to 'Sources/NorgKit/Models/TaskStatus.swift')
| -rw-r--r-- | Sources/NorgKit/Models/TaskStatus.swift | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Sources/NorgKit/Models/TaskStatus.swift b/Sources/NorgKit/Models/TaskStatus.swift new file mode 100644 index 0000000..74badf3 --- /dev/null +++ b/Sources/NorgKit/Models/TaskStatus.swift @@ -0,0 +1,33 @@ +/// A Norg TODO status. +public enum TaskStatus: String, CaseIterable, Identifiable, Sendable, Hashable, Codable { + case undone = " " + case done = "x" + case needsInput = "?" + case urgent = "!" + case recurring = "+" + case pending = "-" + case onHold = "=" + case cancelled = "_" + + /// Identifier, corresponds to its character. + public var id: String { rawValue } + + /// Creates a TaskStatus based on a UTF-8 character. + public init?(marker: Character) { + self.init(rawValue: String(marker)) + } + + init?(markerByte byte: UInt8) { + switch byte { + case UInt8(ascii: " "): self = .undone + case UInt8(ascii: "x"): self = .done + case UInt8(ascii: "?"): self = .needsInput + case UInt8(ascii: "!"): self = .urgent + case UInt8(ascii: "+"): self = .recurring + case UInt8(ascii: "-"): self = .pending + case UInt8(ascii: "="): self = .onHold + case UInt8(ascii: "_"): self = .cancelled + default: return nil + } + } +} |