one more step towards good word-level movement: let paragraph breaks be word boundaries

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25405 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2008-06-30 12:45:27 +00:00
parent d3bf7155b8
commit 0bc9149eda

View 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);
}