krz/orgstar

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

Sources/Orgstar/Preferences.swift

3a3dedba062790e1580c66d38606eda4b02cb501
orgstar/Sources/Orgstar/Preferences.swift history · blame · raw

37 lines · 2070 bytes

 1import Foundation
 2import OrgApp
 3import OrgCore
 4
 5/// Org preferences, stored in user defaults by the Settings window.
 6enum Preferences {
 7    static let defaultTodoKeywords = OrgPreferences.defaultTodoKeywords
 8
 9    /// TODO keywords for files without `#+TODO`, read at launch.
10    @MainActor
11    static var orgSettings: OrgSettings {
12        // config.toml applies before anything reads settings.
13        ConfigSync.shared.start()
14        return OrgPreferences.orgSettings()
15    }
16
17    static func options(
18        tagsColumn: Int, headingAfterSubtree: Bool, splitLine: Bool, alphabeticalLists: Bool, fillColumn: Int,
19        hiddenMarkers: Bool, prettyEntities: Bool, logDone: String, logIntoDrawer: String,
20        hideDrawerStartup: Bool, hideBlockStartup: Bool, logReschedule: String, logRedeadline: String, useSpeedCommands: Bool, startupWithInlineImages: Bool,
21        startupIndented: Bool, hideLeadingStars: Bool, startupAlignAllTables: Bool, startupTruncated: Bool, spellCheck: Bool, electricPair: Bool
22    ) -> EditingOptions {
23        var options = EditingOptions(
24            tagsColumn: tagsColumn, insertHeadingRespectContent: headingAfterSubtree,
25            metaReturnMaySplitLine: splitLine, listAllowAlphabetical: alphabeticalLists, fillColumn: fillColumn,
26            hideEmphasisMarkers: hiddenMarkers, prettyEntities: prettyEntities, subSuperscriptsNeedBraces: true,
27            logDone: LogHow(rawValue: logDone), logIntoDrawer: logIntoDrawer.isEmpty ? nil : logIntoDrawer,
28            hideDrawerStartup: hideDrawerStartup, hideBlockStartup: hideBlockStartup,
29            logReschedule: LogHow(rawValue: logReschedule), logRedeadline: LogHow(rawValue: logRedeadline),
30            useSpeedCommands: useSpeedCommands, startupWithInlineImages: startupWithInlineImages,
31            startupIndented: startupIndented, hideLeadingStars: hideLeadingStars, startupAlignAllTables: startupAlignAllTables,
32            startupTruncated: startupTruncated, spellCheck: spellCheck
33        )
34        options.electricPair = electricPair
35        return options
36    }
37}