From c1dc875a05a162c55bde65b7fd26a580181f444a Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 8 Nov 2012 14:05:49 -0800 Subject: [PATCH] Always add the spellchecker language list to the edit box context menu There's really no reason not to include it even if the right-click wasn't on a word, and leaving it out can lead to confusing situations when the dictionary file for the user's currently selected language doesn't exist. --- aegisub/src/subs_edit_ctrl.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/aegisub/src/subs_edit_ctrl.cpp b/aegisub/src/subs_edit_ctrl.cpp index eb3d5fb41..80b6b3466 100644 --- a/aegisub/src/subs_edit_ctrl.cpp +++ b/aegisub/src/subs_edit_ctrl.cpp @@ -277,7 +277,6 @@ void SubsTextEditCtrl::SetTextTo(wxString const& text) { Thaw(); } - void SubsTextEditCtrl::Paste() { wxString data = GetClipboard(); @@ -308,11 +307,17 @@ void SubsTextEditCtrl::OnContextMenu(wxContextMenuEvent &event) { currentWord = line_text.substr(currentWordPos.first, currentWordPos.second); wxMenu menu; - if (!currentWord.empty()) { - if (spellchecker) - AddSpellCheckerEntries(menu); - AddThesaurusEntries(menu); - } + if (spellchecker) + AddSpellCheckerEntries(menu); + + // Append language list + menu.Append(-1,_("Spell checker language"), GetLanguagesMenu( + EDIT_MENU_DIC_LANGS, + lagi_wxString(OPT_GET("Tool/Spell Checker/Language")->GetString()), + to_wx(spellchecker->GetLanguageList()))); + menu.AppendSeparator(); + + AddThesaurusEntries(menu); // Standard actions menu.Append(EDIT_MENU_CUT,_("Cu&t"))->Enable(GetSelectionStart()-GetSelectionEnd() != 0); @@ -332,6 +337,8 @@ void SubsTextEditCtrl::OnContextMenu(wxContextMenuEvent &event) { } void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) { + if (currentWord.empty()) return; + sugs = spellchecker->GetSuggestions(currentWord); if (spellchecker->CheckWord(currentWord)) { if (sugs.empty()) @@ -354,16 +361,11 @@ void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) { // Append "add word" menu.Append(EDIT_MENU_ADD_TO_DICT, wxString::Format(_("Add \"%s\" to dictionary"), to_wx(currentWord)))->Enable(spellchecker->CanAddWord(currentWord)); } - - // Append language list - menu.Append(-1,_("Spell checker language"), GetLanguagesMenu( - EDIT_MENU_DIC_LANGS, - lagi_wxString(OPT_GET("Tool/Spell Checker/Language")->GetString()), - to_wx(spellchecker->GetLanguageList()))); - menu.AppendSeparator(); } void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) { + if (currentWord.empty()) return; + if (!thesaurus) thesaurus.reset(new Thesaurus);