GuiSpellchecker::GuiSpellchecker(GuiView & lv)
- : GuiDialog(lv, "spellchecker", qt_("Spellchecker")), exitEarly_(false),
+ : GuiDialog(lv, "spellchecker", qt_("Spellchecker")),
progress_(0), count_(0)
{
setupUi(this);
void GuiSpellchecker::updateContents()
{
- // The clauses below are needed because the spellchecker
- // has many flaws (see bugs 1950, 2218).
- // Basically, we have to distinguish the case where a
- // spellcheck has already been performed for the whole
- // document (exitEarly() == true, isVisible() == false)
- // from the rest (exitEarly() == false, isVisible() == true).
- // FIXME: rewrite the whole beast!
- static bool check_after_early_exit;
- if (exitEarly()) {
- // a spellcheck has already been performed,
+ if (hasFocus())
check();
- check_after_early_exit = true;
- }
- else if (isVisible()) {
- // the above check triggers a second update,
- // and isVisible() is true then. Prevent a
- // second check that skips the first word
- if (check_after_early_exit)
- // don't check, but reset the bool.
- // business as usual after this.
- check_after_early_exit = false;
- else
- // perform spellcheck (default case)
- check();
- }
}
}
-void GuiSpellchecker::clearParams()
-{
- LYXERR(Debug::GUI, "Spellchecker::clearParams");
-}
-
-
void GuiSpellchecker::check()
{
LYXERR(Debug::GUI, "Check the spelling of a word");
DocIterator from = bufferview()->cursor();
- while (from && from.pos() && isLetter(from))
- from.backwardPos();
DocIterator to;
- exitEarly_ = false;
WordLangTuple word_lang;
docstring_list suggestions;
// end of document
if (from == to) {
showSummary();
- exitEarly_ = true;
return;
}
+ if (!isVisible())
+ show();
+
word_ = word_lang;
int const progress_bar = total_
///
bool initialiseParams(std::string const & data);
///
- void clearParams();
+ void clearParams() {}
/// Not needed here
void dispatchParams() {}
///
bool isBufferDependent() const { return true; }
- ///
- bool exitEarly() const { return exitEarly_; }
/// replace word with replacement
void replace(docstring const &);
/// show count of checked words at normal exit
void showSummary();
- /// set to true when spellchecking is finished
- bool exitEarly_;
/// current word being checked and lang code
WordLangTuple word_;
/// values for progress