krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Sources/OrgCore/Semantic/SemanticSettings.swift

main
orgstar/Sources/OrgCore/Semantic/SemanticSettings.swift history · blame · raw

47 lines · 1570 bytes

4 symbols in this file
 1/// App-wide settings that change what a document means without changing how it parses.
 2public struct SemanticSettings: Sendable, Equatable {
 3    public enum PropertyInheritance: Sendable, Equatable {
 4        /// org's default: properties apply only to their own heading.
 5        case none
 6        case all
 7        /// Upper-cased property keys that inherit.
 8        case only(Set<String>)
 9    }
10
11    public var tagInheritance: Bool
12    public var tagsExcludedFromInheritance: Set<String>
13    public var propertyInheritance: PropertyInheritance
14
15    public init(
16        tagInheritance: Bool = true,
17        tagsExcludedFromInheritance: Set<String> = [],
18        propertyInheritance: PropertyInheritance = .none
19    ) {
20        self.tagInheritance = tagInheritance
21        self.tagsExcludedFromInheritance = tagsExcludedFromInheritance
22        self.propertyInheritance = propertyInheritance
23    }
24
25    public static let `default` = SemanticSettings()
26}
27
28/// Where a resolved value came from.
29public enum ValueSource: Sendable, Equatable {
30    case defaults
31    /// A file-level keyword such as `#+FILETAGS` or `#+PROPERTY`.
32    case file
33    /// A heading, by index into `DocumentModel.headings`.
34    case heading(Int)
35    /// The element itself: a `#+HEADER` line or a block's begin line.
36    case element
37}
38
39public struct Resolved<Value: Sendable & Equatable>: Sendable, Equatable {
40    public let value: Value
41    public let source: ValueSource
42
43    public init(_ value: Value, _ source: ValueSource) {
44        self.value = value
45        self.source = source
46    }
47}