From 0aec0a9d59b499d05eaacb8dbab99c951cb8bfbe Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 26 Jan 2012 20:51:08 +0000 Subject: [PATCH] Add an option to skip over commented lines in the spell checker. Closes #1428. Originally committed to SVN as r6368. --- aegisub/src/dialog_spellchecker.cpp | 14 +++++++++++++- aegisub/src/dialog_spellchecker.h | 2 ++ aegisub/src/libresrc/default_config.json | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index c09e5e5d0..cd26516c9 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -47,6 +47,10 @@ #include "subs_edit_ctrl.h" #include "utils.h" +static void save_skip_comments(wxCommandEvent &evt) { + OPT_SET("Tool/Spell Checker/Skip Comments")->SetBool(!!evt.GetInt()); +} + DialogSpellChecker::DialogSpellChecker(agi::Context *context) : wxDialog(context->parent, -1, _("Spell Checker")) , context(context) @@ -115,9 +119,15 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context) } { - wxButton *button; 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, save_skip_comments); + + wxButton *button; + actions_sizer->Add(button = new wxButton(this, -1, _("&Replace")), button_flags); button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogSpellChecker::OnReplace, this); @@ -233,6 +243,8 @@ bool DialogSpellChecker::FindNext() { } bool DialogSpellChecker::CheckLine(AssDialogue *active_line, int start_pos, int *commit_id) { + if (active_line->Comment && skip_comments->GetValue()) return false; + IntPairVector results; GetWordBoundaries(active_line->Text, results); diff --git a/aegisub/src/dialog_spellchecker.h b/aegisub/src/dialog_spellchecker.h index b4e0bd5ac..96c5f461c 100644 --- a/aegisub/src/dialog_spellchecker.h +++ b/aegisub/src/dialog_spellchecker.h @@ -34,6 +34,7 @@ namespace agi { struct Context; } class AssDialogue; class SpellChecker; class wxButton; +class wxCheckBox; class wxComboBox; class wxListBox; class wxTextCtrl; @@ -65,6 +66,7 @@ class DialogSpellChecker : public wxDialog { wxComboBox *language; ///< The list of available languages wxButton *add_button; ///< Add word to currently active dictionary + wxCheckBox *skip_comments; ///< Skip over commented lines /// Find the next misspelled word and close the dialog if there are none /// @return Are there any more misspelled words? diff --git a/aegisub/src/libresrc/default_config.json b/aegisub/src/libresrc/default_config.json index b5b36e66f..b5a8194d1 100644 --- a/aegisub/src/libresrc/default_config.json +++ b/aegisub/src/libresrc/default_config.json @@ -456,7 +456,8 @@ }, "Spell Checker" : { "Backend" : "hunspell", - "Language" : "en_US" + "Language" : "en_US", + "Skip Comments" : false }, "Style Editor" : { "Last" : {