Am 27.03.2011 um 21:53 schrieb Vincent van Ravesteijn:

> On 3-2-2011 18:27, sw...@lyx.org wrote:
>> Author: switt
>> Date: Thu Feb  3 18:27:13 2011
>> New Revision: 37463
>> URL: http://www.lyx.org/trac/changeset/37463
>> 
>> Log:
>> suppress the misspelled marker only when typing in a word the first time
>> 
>> Modified:
>>    lyx-devel/trunk/src/BufferView.cpp
>>    lyx-devel/trunk/src/Cursor.cpp
>>    lyx-devel/trunk/src/Cursor.h
>>    lyx-devel/trunk/src/DocIterator.cpp
>>    lyx-devel/trunk/src/DocIterator.h
>>    lyx-devel/trunk/src/Paragraph.h
>>    lyx-devel/trunk/src/rowpainter.cpp
>> 
>> Modified: lyx-devel/trunk/src/BufferView.cpp
>> ==============================================================================
>> --- lyx-devel/trunk/src/BufferView.cpp       Thu Feb  3 17:32:28 2011        
>> (r37462)
>> +++ lyx-devel/trunk/src/BufferView.cpp       Thu Feb  3 18:27:13 2011        
>> (r37463)
>> @@ -700,6 +700,7 @@
>> 
>>  void BufferView::bookmarkEditPosition()
>>  {
>> +    d->cursor_.markEditPosition();
>>      // Don't eat cpu time for each keystroke
>>      if (d->cursor_.paragraph().id() == d->bookmark_edit_position_)
>>              return;
> 
> Why do you call markEditPosition here ? AFAICS, bookmarking the current 
> position has nothing to do with checking for new words which is needed for 
> inline spellchecking. Maybe, they need to be done at the same time, but we 
> should then move the call further up the line.

Easy to change - see attached patch.

> 
>> Modified: lyx-devel/trunk/src/Cursor.cpp
>> ==============================================================================
>> --- lyx-devel/trunk/src/Cursor.cpp   Thu Feb  3 17:32:28 2011        (r37462)
>> +++ lyx-devel/trunk/src/Cursor.cpp   Thu Feb  3 18:27:13 2011        (r37463)
>> @@ -503,6 +503,7 @@
>>  void Cursor::resetAnchor()
>>  {
>>      anchor_ = *this;
>> +    checkNewWordPosition();
>>  }
> 
> Why is the new word position check only when the anchor is reset ? I can't 
> see the relationship here.

The idea is to check for cursor moves and clear the new word when the user 
leaves it.
At the time of this first implementation I didn't notice that resetAnchor() 
isn't called
every time the cursor moves. Meanwhile I'd prepared a patch already for that 
but didn't
apply it because of the rc2 freeze. 

>> @@ -519,6 +520,54 @@
>>  }
>> 
>> 
>> +void Cursor::markEditPosition()
>> +{
>> +    if (inTexted()&&  new_word_.empty()) {
>> +            FontSpan ow = locateWord(WHOLE_WORD);
>> +            if (ow.size() == 1) {
>> +                    LYXERR(Debug::DEBUG, "start new word: "
>> +                            <<  " par: "<<  pit()
>> +                            <<  " pos: "<<  ow.first);
>> +                    new_word_ = *this;
>> +            }
>> +    }
>> +}
>> +
> 
> From the name of this function it is totally not clear that it sets new_word_ 
> if a new word is 'born'.  Moreover, later you add an "if 
> (continuous_spellcheck)" which means this function does nothing when 
> continuous spellchecking is not enabled, which is something I cannot possibly 
> conclude from the name and or the comment in Cursor.h.

With "later" you refer to another commit I presume.
This one I did to change CPU cycles when spellcheck on the fly isn't done.

I changed the name of the method.

Stephan

Index: src/Cursor.h
===================================================================
--- src/Cursor.h        (Revision 38094)
+++ src/Cursor.h        (Arbeitskopie)
@@ -293,13 +293,15 @@
        void checkBufferStructure();
 
        /// hook for text input to maintain the "new born word"
-       void markEditPosition();
+       void markNewWordPosition();
 
        /// The position of the new born word
        /// As the user is entering a word without leaving it
        /// the result is not empty. When not in text mode
        /// and after leaving the word the result is empty.
        DocIterator newWord() const { return new_word_; }
+       /// validate the "new born word" position
+       void checkNewWordPosition();
 
 public:
 //private:
@@ -310,8 +312,6 @@
        void saveBeforeDispatchPosXY();
 
 private:
-       /// validate the "new born word" position
-       void checkNewWordPosition();
        /// clear the "new born word" position
        void clearNewWordPosition();
 
Index: src/BufferView.cpp
===================================================================
--- src/BufferView.cpp  (Revision 38094)
+++ src/BufferView.cpp  (Arbeitskopie)
@@ -700,7 +700,6 @@
 
 void BufferView::bookmarkEditPosition()
 {
-       d->cursor_.markEditPosition();
        // Don't eat cpu time for each keystroke
        if (d->cursor_.paragraph().id() == d->bookmark_edit_position_)
                return;
Index: src/Text2.cpp
===================================================================
--- src/Text2.cpp       (Revision 38094)
+++ src/Text2.cpp       (Arbeitskopie)
@@ -567,6 +567,7 @@
        LASSERT(this == cur.text(), /**/);
        cur.boundary(boundary);
        setCursor(cur.top(), par, pos);
+       cur.checkNewWordPosition();
        if (setfont)
                cur.setCurrentFont();
 }
Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp       (Revision 38094)
+++ src/Text3.cpp       (Arbeitskopie)
@@ -1552,6 +1553,7 @@
 
                cur.resetAnchor();
                moveCursor(cur, false);
+               cur.markNewWordPosition();
                bv->bookmarkEditPosition();
                break;
        }
Index: src/Cursor.cpp
===================================================================
--- src/Cursor.cpp      (Revision 38094)
+++ src/Cursor.cpp      (Arbeitskopie)
@@ -269,6 +269,7 @@
        clearTargetX();
        selection_ = false;
        mark_ = false;
+       clearNewWordPosition();
 }
 
 
@@ -518,14 +519,14 @@
 }
 
 
-void Cursor::markEditPosition()
+void Cursor::markNewWordPosition()
 {
        if (lyxrc.spellcheck_continuously && inTexted() && new_word_.empty()) {
-               FontSpan ow = locateWord(WHOLE_WORD);
-               if (ow.size() == 1) {
+               FontSpan nw = locateWord(WHOLE_WORD);
+               if (nw.size() == 1) {
                        LYXERR(Debug::DEBUG, "start new word: "
                                << " par: " << pit()
-                               << " pos: " << ow.first);
+                               << " pos: " << nw.first);
                        new_word_ = *this;
                }
        }
@@ -1970,6 +1937,7 @@
                        updateTextTargetOffset();
                        if (updateNeeded)
                                forceBufferUpdate();
+                       clearNewWordPosition();
                }
                return false;
        }
@@ -2042,6 +2010,7 @@
        if (updateNeeded)
                forceBufferUpdate();
        updateTextTargetOffset();
+       clearNewWordPosition();
        return true;
 }      
 

Reply via email to