diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index 7d0cc0c93..ef2152b33 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -124,11 +125,16 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context) { wxSizerFlags button_flags = wxSizerFlags().Expand().Bottom().Border(wxBOTTOM, 5); - skip_comments = new wxCheckBox(this, -1, _("&Skip Comments")); - actions_sizer->Add(skip_comments, button_flags); - skip_comments->SetValue(OPT_GET("Tool/Spell Checker/Skip Comments")->GetBool()); - skip_comments->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, - [](wxCommandEvent &evt) { OPT_SET("Tool/Spell Checker/Skip Comments")->SetBool(!!evt.GetInt()); }); + auto make_checkbox = [&](wxString const& text, const char *opt) { + auto checkbox = new wxCheckBox(this, -1, text); + actions_sizer->Add(checkbox, button_flags); + checkbox->SetValue(OPT_GET(opt)->GetBool()); + checkbox->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, + [=](wxCommandEvent &evt) { OPT_SET(opt)->SetBool(!!evt.GetInt()); }); + }; + + make_checkbox(_("&Skip Comments"), "Tool/Spell Checker/Skip Comments"); + make_checkbox(_("Ignore &UPPERCASE words"), "Tool/Spell Checker/Skip Uppercase"); wxButton *button; @@ -240,12 +246,14 @@ bool DialogSpellChecker::FindNext() { } bool DialogSpellChecker::CheckLine(AssDialogue *active_line, int start_pos, int *commit_id) { - if (active_line->Comment && skip_comments->GetValue()) return false; + if (active_line->Comment && OPT_GET("Tool/Spell Checker/Skip Comments")->GetBool()) return false; std::string text = active_line->Text; auto tokens = agi::ass::TokenizeDialogueBody(text); agi::ass::SplitWords(text, tokens); + bool ignore_uppercase = OPT_GET("Tool/Spell Checker/Skip Uppercase")->GetBool(); + word_start = 0; for (auto const& tok : tokens) { if (tok.type != agi::ass::DialogueTokenType::WORD || word_start < start_pos) { @@ -256,7 +264,7 @@ bool DialogSpellChecker::CheckLine(AssDialogue *active_line, int start_pos, int word_len = tok.length; std::string word = text.substr(word_start, word_len); - if (auto_ignore.count(word) || spellchecker->CheckWord(word)) { + if (auto_ignore.count(word) || spellchecker->CheckWord(word) || (ignore_uppercase && word == boost::locale::to_upper(word))) { word_start += tok.length; continue; } diff --git a/aegisub/src/dialog_spellchecker.h b/aegisub/src/dialog_spellchecker.h index 2e6707771..3e39b34ea 100644 --- a/aegisub/src/dialog_spellchecker.h +++ b/aegisub/src/dialog_spellchecker.h @@ -59,7 +59,6 @@ class DialogSpellChecker : public wxDialog { wxComboBox *language; ///< The list of available languages wxButton *add_button; ///< Add word to currently active dictionary wxButton *remove_button; ///< Remove word from currently active dictionary - wxCheckBox *skip_comments; ///< Skip over commented lines AssDialogue *start_line; ///< The first line checked AssDialogue *active_line; ///< The most recently checked line diff --git a/aegisub/src/libresrc/default_config.json b/aegisub/src/libresrc/default_config.json index e466f23f6..2e0b17f98 100644 --- a/aegisub/src/libresrc/default_config.json +++ b/aegisub/src/libresrc/default_config.json @@ -490,7 +490,8 @@ "Spell Checker" : { "Backend" : "hunspell", "Language" : "en_US", - "Skip Comments" : false + "Skip Comments" : false, + "Skip Uppercase" : false }, "Style Editor" : { "Last" : { diff --git a/aegisub/src/libresrc/osx/default_config.json b/aegisub/src/libresrc/osx/default_config.json index 630ce21d5..d57a46b63 100644 --- a/aegisub/src/libresrc/osx/default_config.json +++ b/aegisub/src/libresrc/osx/default_config.json @@ -490,7 +490,8 @@ "Spell Checker" : { "Backend" : "hunspell", "Language" : "en_US", - "Skip Comments" : false + "Skip Comments" : false, + "Skip Uppercase" : false }, "Style Editor" : { "Last" : {