Sources/Orgstar/Preferences.swift

d6defe0dc0a9a2097c50011a25c810644b5ffaef
orgstar/Sources/Orgstar/Preferences.swift

40 lines · 2296 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        enforceTodoDependencies: Bool, enforceTodoCheckboxDependencies: Bool
23    ) -> EditingOptions {
24        var options = EditingOptions(
25            tagsColumn: tagsColumn, insertHeadingRespectContent: headingAfterSubtree,
26            metaReturnMaySplitLine: splitLine, listAllowAlphabetical: alphabeticalLists, fillColumn: fillColumn,
27            hideEmphasisMarkers: hiddenMarkers, prettyEntities: prettyEntities, subSuperscriptsNeedBraces: true,
28            logDone: LogHow(rawValue: logDone), logIntoDrawer: logIntoDrawer.isEmpty ? nil : logIntoDrawer,
29            hideDrawerStartup: hideDrawerStartup, hideBlockStartup: hideBlockStartup,
30            logReschedule: LogHow(rawValue: logReschedule), logRedeadline: LogHow(rawValue: logRedeadline),
31            useSpeedCommands: useSpeedCommands, startupWithInlineImages: startupWithInlineImages,
32            startupIndented: startupIndented, hideLeadingStars: hideLeadingStars, startupAlignAllTables: startupAlignAllTables,
33            startupTruncated: startupTruncated, spellCheck: spellCheck
34        )
35        options.electricPair = electricPair
36        options.enforceTodoDependencies = enforceTodoDependencies
37        options.enforceTodoCheckboxDependencies = enforceTodoCheckboxDependencies
38        return options
39    }
40}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form