krz/orgstar

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

Sources/Orgstar/Preferences.swift

b8d091bdcbf2889c220b12b2d0640d50cea17c24
orgstar/Sources/Orgstar/Preferences.swift history · blame · raw

24 lines · 1054 bytes

 1import Foundation
 2import OrgCore
 3
 4/// Org preferences, stored in user defaults by the Settings window.
 5enum Preferences {
 6    static let defaultTodoKeywords = "TODO PROJ LOOP STRT WAIT HOLD IDEA | DONE KILL"
 7
 8    /// TODO keywords for files without `#+TODO`, read at launch.
 9    static var orgSettings: OrgSettings {
10        let line = UserDefaults.standard.string(forKey: "todoKeywords") ?? defaultTodoKeywords
11        return OrgSettings.default.withTodoKeywords(line) ?? .default
12    }
13
14    static func options(
15        tagsColumn: Int, headingAfterSubtree: Bool, splitLine: Bool, alphabeticalLists: Bool, fillColumn: Int,
16        hiddenMarkers: Bool, prettyEntities: Bool
17    ) -> EditingOptions {
18        EditingOptions(
19            tagsColumn: tagsColumn, insertHeadingRespectContent: headingAfterSubtree,
20            metaReturnMaySplitLine: splitLine, listAllowAlphabetical: alphabeticalLists, fillColumn: fillColumn,
21            hideEmphasisMarkers: hiddenMarkers, prettyEntities: prettyEntities, subSuperscriptsNeedBraces: true
22        )
23    }
24}