From 04cc422391d4d2693cc7ab67f2322b458bb7ca97 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 1 Feb 2012 00:47:57 +0000 Subject: [PATCH] Close the spell checker after all lines have been checked rather than only once there are no errors remaining. Closes #1442. Originally committed to SVN as r6410. --- aegisub/src/dialog_spellchecker.cpp | 15 +++++++++++---- aegisub/src/dialog_spellchecker.h | 14 +++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index 98396bf99..b43784b62 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -56,6 +56,9 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context) : wxDialog(context->parent, -1, _("Spell Checker")) , context(context) , spellchecker(SpellCheckerFactory::GetSpellChecker()) +, start_line(0) +, active_line(0) +, has_looped(false) { SetIcon(BitmapToIcon(GETIMAGE(spellcheck_toolbutton_24))); @@ -203,16 +206,21 @@ void DialogSpellChecker::OnClose(wxCommandEvent&) { } bool DialogSpellChecker::FindNext() { - AssDialogue *active_line = context->selectionController->GetActiveLine(); + AssDialogue *real_active_line = context->selectionController->GetActiveLine(); + // User has changed the active line; restart search from this position + if (real_active_line != active_line) { + active_line = real_active_line; + has_looped = false; + start_line = active_line; + } + int start_pos = context->editBox->GetReverseUnicodePosition(context->editBox->GetCurrentPos()); int commit_id = -1; if (CheckLine(active_line, start_pos, &commit_id)) return true; - AssDialogue *start_line = active_line; std::list::iterator it = find(context->ass->Line.begin(), context->ass->Line.end(), active_line); - bool has_looped = false; // Note that it is deliberate that the start line is checked twice, as if // the cursor is past the first misspelled word in the current line, that @@ -298,4 +306,3 @@ void DialogSpellChecker::SetWord(wxString const& word) { add_button->Enable(spellchecker->CanAddWord(word)); } - diff --git a/aegisub/src/dialog_spellchecker.h b/aegisub/src/dialog_spellchecker.h index 96c5f461c..6ed99d7d1 100644 --- a/aegisub/src/dialog_spellchecker.h +++ b/aegisub/src/dialog_spellchecker.h @@ -58,16 +58,20 @@ class DialogSpellChecker : public wxDialog { wxArrayString dictionary_lang_codes; int word_start; ///< Start index of the current misspelled word - int word_end; ///< End index of the current misspelled word + int word_end; ///< End index of the current misspelled word - wxTextCtrl *orig_word; ///< The word being corrected + wxTextCtrl *orig_word; ///< The word being corrected wxTextCtrl *replace_word; ///< The replacement that will be used if "Replace" is clicked - wxListBox *suggest_list; ///< The list of suggested replacements + wxListBox *suggest_list; ///< The list of suggested replacements - wxComboBox *language; ///< The list of available languages - wxButton *add_button; ///< Add word to currently active dictionary + wxComboBox *language; ///< The list of available languages + wxButton *add_button; ///< Add word to 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 + bool has_looped; ///< Has the search already looped from the end to beginning? + /// Find the next misspelled word and close the dialog if there are none /// @return Are there any more misspelled words? bool FindNext();