- x += cit->width();
- }
-
- if (cit == row.end()
- && (row.back().font.isRightToLeft() || ppos != row.back().endpos))
- lyxerr << "NOT FOUND!"
- << "ppos=" << ppos << "(" << boundary_corr << ")" << "\n"
- << row;
-
- // Correct position in front of big insets
- bool const boundary_correction = ppos != 0 && boundary;
- if (boundary_correction)
- --ppos;
-
- pos_type cursor_vpos = 0;
-
- Buffer const & buffer = bv_->buffer();
- double x2 = row.x;
- Bidi bidi;
- bidi.computeTables(par, buffer, row);
-
- pos_type const row_pos = row.pos();
- pos_type const end = row.endpos();
- // Spaces at logical line breaks in bidi text must be skipped during
- // cursor positioning. However, they may appear visually in the middle
- // of a row; they must be skipped, wherever they are...
- // * logically "abc_[HEBREW_\nHEBREW]"
- // * visually "abc_[_WERBEH\nWERBEH]"
- pos_type skipped_sep_vpos = -1;
-
- if (end <= row_pos)
- cursor_vpos = row_pos;
- else if (ppos >= end)
- cursor_vpos = text_->isRTL(par) ? row_pos : end;
- else if (ppos > row_pos && ppos >= end)
- //FIXME: this code is never reached!
- // (see http://www.lyx.org/trac/changeset/8251)
- // Place cursor after char at (logical) position pos - 1
- cursor_vpos = (bidi.level(ppos - 1) % 2 == 0)
- ? bidi.log2vis(ppos - 1) + 1 : bidi.log2vis(ppos - 1);
- else
- // Place cursor before char at (logical) position ppos
- cursor_vpos = (bidi.level(ppos) % 2 == 0)
- ? bidi.log2vis(ppos) : bidi.log2vis(ppos) + 1;
-
- pos_type body_pos = par.beginOfBody();
- if (body_pos > 0 &&
- (body_pos > end || !par.isLineSeparator(body_pos - 1)))
- body_pos = 0;
-
- // check for possible inline completion in this row
- DocIterator const & inlineCompletionPos = bv_->inlineCompletionPos();
- pos_type inlineCompletionVPos = -1;
- if (inlineCompletionPos.inTexted()
- && inlineCompletionPos.text() == text_
- && inlineCompletionPos.pit() == pit
- && inlineCompletionPos.pos() - 1 >= row_pos
- && inlineCompletionPos.pos() - 1 < end) {
- // draw logically behind the previous character
- inlineCompletionVPos = bidi.log2vis(inlineCompletionPos.pos() - 1);
- }
-
- // Use font span to speed things up, see below
- FontSpan font_span;
- Font font;
-
- // If the last logical character is a separator, skip it, unless
- // it's in the last row of a paragraph; see skipped_sep_vpos declaration
- if (end > 0 && end < par.size() && par.isSeparator(end - 1))
- skipped_sep_vpos = bidi.log2vis(end - 1);
-
- if (lyxrc.paragraph_markers && text_->isRTL(par)) {
- ParagraphList const & pars_ = text_->paragraphs();
- if (size_type(pit + 1) < pars_.size()) {
- FontInfo f;
- docstring const s = docstring(1, char_type(0x00B6));
- x2 += theFontMetrics(f).width(s);
- }