From e9780fe317b3bad923dee327d68a06562c926029 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 16 May 2007 09:35:12 +0000 Subject: [PATCH] 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 --- src/Bidi.cpp | 6 ++++++ src/Bidi.h | 3 +++ src/Text2.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Bidi.cpp b/src/Bidi.cpp index 8c3a81b208..df1f7495d6 100644 --- a/src/Bidi.cpp +++ b/src/Bidi.cpp @@ -224,4 +224,10 @@ bool reverseDirectionNeeded(Cursor const & cur) } +bool isWithinRtlParagraph(Cursor const & cur) +{ + return cur.innerParagraph().isRightToLeftPar( + cur.bv().buffer()->params()); +} + } // namespace lyx diff --git a/src/Bidi.h b/src/Bidi.h index 5c722a9b90..2fdb3abad3 100644 --- a/src/Bidi.h +++ b/src/Bidi.h @@ -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 diff --git a/src/Text2.cpp b/src/Text2.cpp index a51fee46a7..d7af2bafc8 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -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(); } -- 2.39.5