From: Alfredo Braunstein Date: Wed, 31 Mar 2004 17:58:11 +0000 (+0000) Subject: some spellcheck fixes X-Git-Tag: 1.6.10~15391 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3d1fe03e56b436f98d166420112c1de2a93dac41;p=features.git some spellcheck fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8572 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.C b/src/BufferView.C index 67a428ff7b..0215990ca4 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -367,8 +367,11 @@ LyXText * BufferView::text() const void BufferView::setCursor(ParIterator const & par, lyx::pos_type pos) { - LCursor & cur = cursor(); - cur.setCursor(makeDocumentIterator(par, pos), false); + int const last = par.size(); + for (int i = 0; i < last; ++i) + par[i].inset().edit(cursor(), true); + + cursor().setCursor(makeDocumentIterator(par, pos), false); } @@ -393,24 +396,24 @@ void BufferView::putSelectionAt(DocumentIterator const & cur, cursor().clearSelection(); - LyXText & text = *par.text(); + LyXText & text = *cur[0].text(); setCursor(par, cur.pos()); // hack for the chicken and egg problem top_y(text.getPar(par.outerPar()).y); update(); - text.setCursor(cursor(), cur.par(), cur.pos()); + //text.setCursor(cursor(), cur.par(), cur.pos()); cursor().updatePos(); if (length) { - setSelectionRange(cursor(), length); - cursor().setSelection(); if (backwards) { + cursor().setSelection(cursor(), -length); DocumentIterator const it = cursor(); - cursor().setCursor(cursor().anchor_, false); + cursor().setCursor(cursor().anchor_, true); cursor().anchor_ = it; - } + } else + cursor().setSelection(cursor(), length); } fitCursor(); diff --git a/src/ChangeLog b/src/ChangeLog index 34db1e9d05..38dc70cf59 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ + +2004-03-31 Alfredo Braunstein + + * BufferView.C (setCursor, putSelectionAt): call edit to open the + insets where we are putting the cursor. + * ControlSpellchecker.C (isLetter, nextWord): check for inTextEd, + use forwardPos. + 2004-03-31 Angus Leeming * lfuns.h: diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index c660e717d1..0a6b9a6daf 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -151,10 +151,11 @@ namespace { bool isLetter(DocumentIterator const & cur) { - return !cur.empty() + return cur.inTexted() + && cur.inset().allowSpellCheck() + && cur.pos() != cur.lastpos() && cur.paragraph().isLetter(cur.pos()) && !isDeletedText(cur.paragraph(), cur.pos()); - //&& (!cur.nextInset() || cur.nextInset()->allowSpellCheck()); } @@ -162,7 +163,7 @@ WordLangTuple nextWord(DocumentIterator & cur, ptrdiff_t & progress, BufferParams & bp) { // skip until we have real text (will jump paragraphs) - for (; cur.size() && !isLetter(cur); cur.forwardChar()); + for (; cur.size() && !isLetter(cur); cur.forwardPos()); ++progress; // hit end @@ -174,7 +175,7 @@ WordLangTuple nextWord(DocumentIterator & cur, ptrdiff_t & progress, string str; // and find the end of the word (insets like optional hyphens // and ligature break are part of a word) - for (; cur.size() && isLetter(cur); cur.forwardChar(), ++progress) { + for (; cur && isLetter(cur); cur.forwardPos(), ++progress) { if (!cur.paragraph().isInset(cur.pos())) str += cur.paragraph().getChar(cur.pos()); } @@ -203,10 +204,10 @@ void ControlSpellchecker::check() for (start = 0; it != cur; it.forwardPos()) ++start; - for (total = start; it.size(); it.forwardPos()) + for (total = start; it; it.forwardPos()) ++total; - for (; cur.size() && isLetter(cur); cur.forwardPos()) + for (; cur && isLetter(cur); cur.forwardPos()) ++start; while (res == SpellBase::OK || res == SpellBase::IGNORE) { diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index bc9b41eeb3..c15f7dd742 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2004-03-31 Alfredo Braunstein + + * insettext.C (edit): comment the call to updateLocal (dangling now) + * insettext.h: add allowSpellCheck() returning true + 2004-03-31 Angus Leeming * insetcollapsable.[Ch]: (leaveInset): renaming of getOutOfInset. diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 69eef1534a..e02017f57f 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -294,7 +294,9 @@ void InsetText::edit(LCursor & cur, bool left) cur.clearSelection(); finishUndo(); sanitizeEmptyText(cur.bv()); - updateLocal(cur); +#warning can someone check if/when this is needed? +//Andre? +// updateLocal(cur); } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 9766c6bfa6..df3472db78 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -148,6 +148,8 @@ public: ParagraphList const & paragraphs() const; /// bool insetAllowed(Code) const { return true; } + /// + bool allowSpellCheck() const { return true; } protected: ///