-
- // Are we already at rightmost pos in row?
- if (right_pos == -1) {
-
- Cursor new_cur = cur;
- if (!new_cur.posVisToNewRow(false)) {
- LYXERR(Debug::RTL, "not moving!");
- return false;
- }
-
- // we actually move the cursor at the end of this function, for now
- // just keep track of the new position...
- new_pit = new_cur.pit();
- new_pos = new_cur.pos();
- new_boundary = new_cur.boundary();
-
- LYXERR(Debug::RTL, "right edge, moving: " << int(new_pit) << ","
- << int(new_pos) << "," << (new_boundary ? 1 : 0));
-
- }
- // normal movement to the right
- else {
- // Recall, if the cursor is at position 'x', that means *before*
- // the character at position 'x'. In RTL, "before" means "to the
- // right of", in LTR, "to the left of". So currently our situation
- // is this: the position to our right is 'right_pos' (i.e., we're
- // currently to the left of 'right_pos'). In order to move to the
- // right, it depends whether or not the character at 'right_pos' is RTL.
- new_pos_is_RTL = cur.paragraph().getFontSettings(
- cur.bv().buffer().params(), right_pos).isVisibleRightToLeft();
- // If the character at 'right_pos' *is* LTR, then in order to move to
- // the right of it, we need to be *after* 'right_pos', i.e., move to
- // position 'right_pos' + 1.
- if (!new_pos_is_RTL) {
- new_pos = right_pos + 1;
- // if the position *after* right_pos is RTL, set boundary to
- // true (we want to be *after* right_pos, not before right_pos + 1!)
- new_boundary = cur.paragraph().getFontSettings(
- cur.bv().buffer().params(), new_pos).isVisibleRightToLeft();
- }
- // Otherwise (if the character at position 'right_pos' is RTL), then
- // moving to the right of it is as easy as setting the new position
- // to 'right_pos'.
- else {
- new_pos = right_pos;
- new_boundary = false;
- }
-
- }
-
- LYXERR(Debug::RTL, "moving to: " << new_pos
- << (new_boundary ? " (boundary)" : ""));
-
- return setCursor(cur, new_pit, new_pos, true, new_boundary);