]> git.lyx.org Git - features.git/commitdiff
some spellcheck fixes
authorAlfredo Braunstein <abraunst@lyx.org>
Wed, 31 Mar 2004 17:58:11 +0000 (17:58 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Wed, 31 Mar 2004 17:58:11 +0000 (17:58 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8572 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/ChangeLog
src/frontends/controllers/ControlSpellchecker.C
src/insets/ChangeLog
src/insets/insettext.C
src/insets/insettext.h

index 67a428ff7b71156af01da8d724f24ac208ed878c..0215990ca49c986dc7b1b6c885d6f51954123ed9 100644 (file)
@@ -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();
index 34db1e9d050128eb5e670fecc5068c08fa69c8ea..38dc70cf597af3e9960f3e2a2ed2f502e8803ed5 100644 (file)
@@ -1,3 +1,11 @@
+
+2004-03-31  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * 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  <leeming@lyx.org>
 
        * lfuns.h:
index c660e717d1e5e74cce0e2895da265da360862c1a..0a6b9a6daf23826c7027b7ad03e3cbe6f0e757d3 100644 (file)
@@ -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) {
index bc9b41eeb392c1f8448c3bd43b036beb780a4603..c15f7dd742b374fa6fb030b884446065bc741eec 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-31  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * insettext.C (edit): comment the call to updateLocal (dangling now)
+       * insettext.h: add allowSpellCheck() returning true
+
 2004-03-31  Angus Leeming  <angus@localhost.localdomain>
 
        * insetcollapsable.[Ch]: (leaveInset): renaming of getOutOfInset.
index 69eef1534aa79f5504876f4b62e7e9017a163bf1..e02017f57fa1cefbd11a49c63d60a02bdcaa62b1 100644 (file)
@@ -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);
 }
 
 
index 9766c6bfa6c10a63f4baf55cc4eb4aab26600116..df3472db786da2a1757ec024d29ea7fd2ea41861 100644 (file)
@@ -148,6 +148,8 @@ public:
        ParagraphList const & paragraphs() const;
        ///
        bool insetAllowed(Code) const { return true; }
+       ///
+       bool allowSpellCheck() const { return true; }
        
 protected:
        ///