Please try this patch for second approach. Please make sure I'm not
breaking anything.
See discussion here http://bugzilla.lyx.org/show_bug.cgi?id=3551
Index: Text2.cpp
===================================================================
--- Text2.cpp (revision 18129)
+++ Text2.cpp (working copy)
@@ -915,8 +915,12 @@
bool Text::cursorLeft(Cursor & cur)
{
+ bool direction = false;
+ if (isRTL(*cur.bv().buffer(), cur.paragraph()))
+ direction = !direction;
// Tell BufferView to test for FitCursor in any case!
cur.updateFlags(Update::FitCursor);
+
if (!cur.boundary() && cur.pos() > 0 &&
cur.textRow().pos() == cur.pos() &&
@@ -926,7 +930,7 @@
}
if (cur.pos() != 0) {
bool updateNeeded = setCursor(cur, cur.pit(), cur.pos() - 1, true, false);
- if (!checkAndActivateInset(cur, false)) {
+ if (!checkAndActivateInset(cur, direction)) {
/** FIXME: What's this cause purpose???
bool boundary = cur.boundary();
if (false && !boundary &&
@@ -949,6 +953,9 @@
bool Text::cursorRight(Cursor & cur)
{
// Tell BufferView to test for FitCursor in any case!
+ bool direction = true;
+ if (isRTL(*cur.bv().buffer(), cur.paragraph()))
+ direction = !direction;
cur.updateFlags(Update::FitCursor);
if (cur.pos() != cur.lastpos()) {
@@ -957,7 +964,7 @@
true, false);
bool updateNeeded = false;
- if (!checkAndActivateInset(cur, true)) {
+ if (!checkAndActivateInset(cur, direction)) {
if (cur.textRow().endpos() == cur.pos() + 1 &&
cur.textRow().endpos() != cur.lastpos() &&
!cur.paragraph().isLineSeparator(cur.pos()) &&
Index: Cursor.cpp
===================================================================
--- Cursor.cpp (revision 18129)
+++ Cursor.cpp (working copy)
@@ -360,10 +360,14 @@
{
BOOST_ASSERT(!empty());
//lyxerr << "Leaving inset to the left" << endl;
+ const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
inset().notifyCursorLeaves(*this);
if (depth() == 1)
return false;
pop();
+ if (depth() == 1 && isRTL()) {
+ pos() += lastpos() - lp + 1;
+ }
return true;
}
@@ -376,8 +380,11 @@
inset().notifyCursorLeaves(*this);
if (depth() == 1)
return false;
+
pop();
- pos() += lastpos() - lp + 1;
+ if (!(depth() == 1 && isRTL())) {
+ pos() += lastpos() - lp + 1;
+ }
return true;
}