Fix cursor movement inside insets within RTL mode.

* Bidi.{h,cpp}:
  - isWithinRtlParagraph(): new helper function.

* Text2.cpp: use function above for cursor up and down instead of needReverseDirection() which is about cursor left and right.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18364 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-05-16 09:35:12 +00:00
parent 291b765a61
commit e9780fe317
3 changed files with 13 additions and 4 deletions

View File

@ -224,4 +224,10 @@ bool reverseDirectionNeeded(Cursor const & cur)
}
bool isWithinRtlParagraph(Cursor const & cur)
{
return cur.innerParagraph().isRightToLeftPar(
cur.bv().buffer()->params());
}
} // namespace lyx

View File

@ -69,6 +69,9 @@ private:
/// Should interpretation of the arrow keys be reversed?
bool reverseDirectionNeeded(Cursor const & cur);
/// Is current paragraph in RTL mode?
bool isWithinRtlParagraph(Cursor const & cur);
} // namespace lyx
#endif // BIDI_H

View File

@ -998,8 +998,8 @@ bool Text::cursorUp(Cursor & cur)
// handling when the cursor is at the end of line: Use the new
// x-target only if the old one was before the end of line.
if (cur.pos() != pm.rows()[row].endpos()
|| (!reverseDirectionNeeded(cur) && x < cur.targetX())
|| (reverseDirectionNeeded(cur) && x > cur.targetX())) {
|| (!isWithinRtlParagraph(cur) && x < cur.targetX())
|| (isWithinRtlParagraph(cur) && x > cur.targetX())) {
x = cur.targetX();
}
@ -1065,8 +1065,8 @@ bool Text::cursorDown(Cursor & cur)
// handling when the cursor is at the end of line: Use the new
// x-target only if the old one was before the end of line.
if (cur.pos() != pm.rows()[row].endpos()
|| (!reverseDirectionNeeded(cur) && x < cur.targetX())
|| (reverseDirectionNeeded(cur) && x > cur.targetX())) {
|| (!isWithinRtlParagraph(cur) && x < cur.targetX())
|| (isWithinRtlParagraph(cur) && x > cur.targetX())) {
x = cur.targetX();
}