Add an option to skip over commented lines in the spell checker. Closes #1428.

Originally committed to SVN as r6368.
This commit is contained in:
Thomas Goyne 2012-01-26 20:51:08 +00:00
parent 92ae4a616e
commit 0aec0a9d59
3 changed files with 17 additions and 2 deletions

View file

@ -47,6 +47,10 @@
#include "subs_edit_ctrl.h" #include "subs_edit_ctrl.h"
#include "utils.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) DialogSpellChecker::DialogSpellChecker(agi::Context *context)
: wxDialog(context->parent, -1, _("Spell Checker")) : wxDialog(context->parent, -1, _("Spell Checker"))
, context(context) , context(context)
@ -115,9 +119,15 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context)
} }
{ {
wxButton *button;
wxSizerFlags button_flags = wxSizerFlags().Expand().Bottom().Border(wxBOTTOM, 5); 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); actions_sizer->Add(button = new wxButton(this, -1, _("&Replace")), button_flags);
button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogSpellChecker::OnReplace, this); 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) { bool DialogSpellChecker::CheckLine(AssDialogue *active_line, int start_pos, int *commit_id) {
if (active_line->Comment && skip_comments->GetValue()) return false;
IntPairVector results; IntPairVector results;
GetWordBoundaries(active_line->Text, results); GetWordBoundaries(active_line->Text, results);

View file

@ -34,6 +34,7 @@ namespace agi { struct Context; }
class AssDialogue; class AssDialogue;
class SpellChecker; class SpellChecker;
class wxButton; class wxButton;
class wxCheckBox;
class wxComboBox; class wxComboBox;
class wxListBox; class wxListBox;
class wxTextCtrl; class wxTextCtrl;
@ -65,6 +66,7 @@ class DialogSpellChecker : public wxDialog {
wxComboBox *language; ///< The list of available languages wxComboBox *language; ///< The list of available languages
wxButton *add_button; ///< Add word to currently active dictionary 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 /// Find the next misspelled word and close the dialog if there are none
/// @return Are there any more misspelled words? /// @return Are there any more misspelled words?

View file

@ -456,7 +456,8 @@
}, },
"Spell Checker" : { "Spell Checker" : {
"Backend" : "hunspell", "Backend" : "hunspell",
"Language" : "en_US" "Language" : "en_US",
"Skip Comments" : false
}, },
"Style Editor" : { "Style Editor" : {
"Last" : { "Last" : {