diff --git a/Twig/Base.lproj/Main.storyboard b/Twig/Base.lproj/Main.storyboard index 3e1909d..b5fa8dd 100644 --- a/Twig/Base.lproj/Main.storyboard +++ b/Twig/Base.lproj/Main.storyboard @@ -581,11 +581,11 @@ - + - + @@ -597,13 +597,13 @@ - + - + @@ -612,7 +612,7 @@ - + @@ -621,7 +621,7 @@ - + @@ -630,7 +630,7 @@ - + @@ -672,7 +672,7 @@ - + @@ -692,7 +692,7 @@ - + @@ -712,7 +712,7 @@ - + @@ -743,7 +743,7 @@ - + @@ -763,7 +763,7 @@ - + @@ -772,7 +772,7 @@ - + @@ -791,6 +791,26 @@ + + + + + + + + + + @@ -803,6 +823,7 @@ + @@ -815,7 +836,7 @@ - + @@ -908,7 +929,7 @@ - + diff --git a/Twig/Controllers/MarkdownViewController.swift b/Twig/Controllers/MarkdownViewController.swift index 89ef253..9deccd0 100644 --- a/Twig/Controllers/MarkdownViewController.swift +++ b/Twig/Controllers/MarkdownViewController.swift @@ -247,6 +247,7 @@ class MarkdownViewController: NSViewController, NSTextViewDelegate { syntaxHighlight() view.updateLayer() reGeneratePreview() + self.markdownTextView.isContinuousSpellCheckingEnabled = preferences.spellcheckEnabled } @objc private func reGeneratePreview() { diff --git a/Twig/Controllers/PreferencesViewController.swift b/Twig/Controllers/PreferencesViewController.swift index 71b0aa5..775ea79 100644 --- a/Twig/Controllers/PreferencesViewController.swift +++ b/Twig/Controllers/PreferencesViewController.swift @@ -18,6 +18,7 @@ class PreferencesViewController: NSViewController, NSFontChanging { @IBOutlet weak var modernTitlebar: NSButton! @IBOutlet weak var useSystemAppearance: NSButton! @IBOutlet weak var showSidebar: NSButton! + @IBOutlet weak var enableSpellcheck: NSButton! override func viewDidLoad() { super.viewDidLoad() @@ -35,6 +36,7 @@ class PreferencesViewController: NSViewController, NSFontChanging { modernTitlebar.state = getState(preferences.modernTitlebar) useSystemAppearance.state = getState(preferences.useSystemAppearance) showSidebar.state = getState(preferences.showSidebar) + enableSpellcheck.state = getState(preferences.spellcheckEnabled) } private func getState(_ state: Bool) -> NSControl.StateValue { @@ -84,6 +86,11 @@ class PreferencesViewController: NSViewController, NSFontChanging { postNotification() } + @IBAction func enableSpellcheckChanged(_ sender: NSButton) { + preferences.spellcheckEnabled = sender.state.rawValue.bool + postNotification() + } + func changeFont(_ sender: NSFontManager?) { if let fontManager = sender { preferences.font = fontManager.convert(preferences.font) diff --git a/Twig/Models/Preferences.swift b/Twig/Models/Preferences.swift index 3cfb722..72e3c79 100644 --- a/Twig/Models/Preferences.swift +++ b/Twig/Models/Preferences.swift @@ -39,6 +39,10 @@ class Preferences { if defaults.object(forKey: "showSidebar") != nil { showSidebar = defaults.bool(forKey: "showSidebar") } + + if defaults.object(forKey: "spellcheckEnabled") != nil { + spellcheckEnabled = defaults.bool(forKey: "spellcheckEnabled") + } } public var showPreviewOnStartup = true { @@ -83,6 +87,12 @@ class Preferences { } } + public var spellcheckEnabled = true { + willSet(newVal) { + setDefaults(key: "spellcheckEnabled", newVal) + } + } + public var font: NSFont { get { let fontSize = defaults.double(forKey: "fontSize")