]> git.lyx.org Git - features.git/commitdiff
one more step towards good word-level movement: let paragraph breaks be word boundaries
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 30 Jun 2008 12:45:27 +0000 (12:45 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 30 Jun 2008 12:45:27 +0000 (12:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25405 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text.cpp

index 033cbe8aa9044219c0d1bc0f7cdf4ae7dde4b431..b655830651bda24d2be87b80a4a50da7c56350d0 100644 (file)
@@ -589,6 +589,10 @@ bool Text::cursorForwardOneWord(Cursor & cur)
        pos_type pos = cur.pos();
        Paragraph const & par = cur.paragraph();
 
+       // Paragraph boundary is a word boundary
+       if (pos == lastpos && pit != cur.lastpit())
+               return setCursor(cur, pit + 1, 0);
+
        // Skip over either a non-char inset or a full word
        if (pos != lastpos && !par.isLetter(pos) && !par.isChar(pos))
                ++pos;
@@ -599,11 +603,6 @@ bool Text::cursorForwardOneWord(Cursor & cur)
        while (pos != lastpos && par.isChar(pos))
                ++pos;
 
-       if (pos == lastpos && pit != cur.lastpit()) {
-               ++pit;
-               pos = 0;
-       }
-
        return setCursor(cur, pit, pos);
 }
 
@@ -616,6 +615,10 @@ bool Text::cursorBackwardOneWord(Cursor & cur)
        pos_type pos = cur.pos();
        Paragraph & par = cur.paragraph();
 
+       // Paragraph boundary is a word boundary
+       if (pos == 0 && pit != 0)
+               return setCursor(cur, pit - 1, getPar(pit - 1).size());
+
        // Skip through puctuation and spaces.
        while (pos != 0 && par.isChar(pos - 1))
                --pos;
@@ -626,11 +629,6 @@ bool Text::cursorBackwardOneWord(Cursor & cur)
        else while (pos != 0 && par.isLetter(pos - 1))
                        --pos;
 
-       if (pos == 0 && pit != 0) {
-               --pit;
-               pos = getPar(cur.pit() - 1).size();
-       }
-
        return setCursor(cur, pit, pos);
 }