Hello again,

  here is a patch declaring, in textutils.h : 

  inline bool IsWordChar(unsigned char c)

  and in lyxparagraph.h :

  bool LyXParagraph::IsWord( int pos )

  (btw, I have a C++ question, and no Stroutsrup around : is "inline"
  is not needed, when I de-facto "inline" the method in the class
  declaration?) 

  IsWord is used three times, in text.C, twice in
  LyXText::CursorRightOneWord and once in LyXText::CursorLeftOneWord. 

  Cheers,

  Etienne

ps : There are two corrected typos in the patch, too.

======================================================================
--- text.C.orig Mon Jan 11 19:59:34 1999
+++ text.C      Wed Jan 20 12:11:33 1999
@@ -2531,8 +2531,7 @@
 
 /* the cursor set functions have a special mechanism. When they
 * realize, that you left an empty paragraph, they will delete it.
-* They also delet the corresponding row */
-
+* They also delete the corresponding row */
 
 void LyXText::CursorRightOneWord()
 {
@@ -2546,29 +2545,22 @@
                        tmpcursor.pos = 0;
        } else {
                int steps = 0;
-               while (tmpcursor.pos < tmpcursor.par->Last()
-                      && !tmpcursor.par->IsSeparator(tmpcursor.pos)
-                      && !tmpcursor.par->IsKomma(tmpcursor.pos)
-                      && !tmpcursor.par->IsHfill(tmpcursor.pos)
-                      && !tmpcursor.par->IsFloat(tmpcursor.pos)
-                      && !tmpcursor.par->IsInset(tmpcursor.pos))
+
+               // Skip through initial nonword stuff.
+               while ( tmpcursor.pos < tmpcursor.par->Last() &&
+                       ! tmpcursor.par->IsWord( tmpcursor.pos ) ) 
                {
+                 //    printf("Current pos1 %d",tmpcursor.pos) ;
                        tmpcursor.pos++;
                        steps++;
                }
-               while (tmpcursor.pos < tmpcursor.par->Last()
-                      && (tmpcursor.par->IsSeparator(tmpcursor.pos)
-                          || tmpcursor.par->IsKomma(tmpcursor.pos)
-                          || tmpcursor.par->IsHfill(tmpcursor.pos)
-                          || tmpcursor.par->IsFloat(tmpcursor.pos)
-                          || tmpcursor.par->IsInset(tmpcursor.pos)))
+               // Advance through word.
+               while ( tmpcursor.pos < tmpcursor.par->Last() &&
+                       tmpcursor.par->IsWord( tmpcursor.pos ) )
                {
-                       if ((tmpcursor.par->IsInset(tmpcursor.pos)
-                            || tmpcursor.par->IsFloat(tmpcursor.pos)
-                            || tmpcursor.par->IsHfill(tmpcursor.pos))
-                           && steps)
-                               break;
+                 //     printf("Current pos2 %d",tmpcursor.pos) ;
                        tmpcursor.pos++;
+                       steps++;
                }
        }
        SetCursor(tmpcursor.par, tmpcursor.pos);
@@ -2649,19 +2641,15 @@
                        tmpcursor.par = tmpcursor.par->Previous();
                        tmpcursor.pos = tmpcursor.par->Last();
                }
-       } else {
-               while (tmpcursor.pos > 0 
-                      && !tmpcursor.par->IsSeparator(tmpcursor.pos-1)
-                      && !tmpcursor.par->IsKomma(tmpcursor.pos-1)
-                      && !tmpcursor.par->IsHfill(tmpcursor.pos-1)
-                      && !tmpcursor.par->IsFloat(tmpcursor.pos-1)
-                      && !tmpcursor.par->IsInset(tmpcursor.pos-1))
-                       tmpcursor.pos--;
+       } else {                // Here, tmpcursor != 0 
+               while (tmpcursor.pos > 0 &&
+                      tmpcursor.par->IsWord(tmpcursor.pos-1) )
+                       tmpcursor.pos-- ;
        }
        SetCursor(tmpcursor.par, tmpcursor.pos);
 }
 
-/* -------> Select current word. This depeds on behaviour of CursorLeftOneWord(), so 
it is
+/* -------> Select current word. This depends on behaviour of CursorLeftOneWord(), so 
+it is
                        patched as well. */
 
 void LyXText::SelectWord() 
--- textutils.h.orig    Wed Jan 20 10:27:44 1999
+++ textutils.h Wed Jan 20 10:45:57 1999
@@ -81,4 +81,12 @@
 inline bool IsPrintable(unsigned char c) {
        return (c>=' ');
 }
+/// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset. 
+inline bool IsWordChar(unsigned char c) {
+  return !( IsSeparatorChar( c ) 
+           ||  IsKommaChar( c )  
+           ||  IsHfillChar( c )  
+           ||  IsFloatChar( c )  
+           ||  IsInsetChar( c ) ) ;
+}
 #endif
--- lyxparagraph.h.orig Wed Jan 20 10:32:24 1999
+++ lyxparagraph.h      Wed Jan 20 11:27:11 1999
@@ -395,6 +395,11 @@
        /// Used by the spellchecker
        bool IsLetter(int pos);
        
+       /// 
+       bool IsWord( int pos ) {
+         return IsWordChar( GetChar(pos) ) ;
+       }
+
        ///
        int ClearParagraph(){
                int i=0;
======================================================================

Reply via email to