- 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(text_->layoutFont(pit));
- docstring const s = docstring(1, char_type(0x00B6));
- x2 += theFontMetrics(f).width(s);
- }
- }
-
- // Inline completion RTL special case row_pos == cursor_pos:
- // "__|b" => cursor_pos is right of __
- if (row_pos == inlineCompletionVPos && row_pos == cursor_vpos) {
- font = displayFont(pit, row_pos + 1);
- docstring const & completion = bv_->inlineCompletion();
- if (font.isRightToLeft() && completion.length() > 0)
- x2 += theFontMetrics(font.fontInfo()).width(completion);
- }
-
- for (pos_type vpos = row_pos; vpos < cursor_vpos; ++vpos) {
- // Skip the separator which is at the logical end of the row
- if (vpos == skipped_sep_vpos)
- continue;
- pos_type pos = bidi.vis2log(vpos);
- if (body_pos > 0 && pos == body_pos - 1) {
- FontMetrics const & labelfm = theFontMetrics(
- text_->labelFont(par));
- x2 += row.label_hfill + labelfm.width(par.layout().labelsep);
- if (par.isLineSeparator(body_pos - 1))
- x2 -= singleWidth(pit, body_pos - 1);
- }
-
- // Use font span to speed things up, see above
- if (pos < font_span.first || pos > font_span.last) {
- font_span = par.fontSpan(pos);
- font = displayFont(pit, pos);
- }
-
- x2 += pm.singleWidth(pos, font);
-
- // Inline completion RTL case:
- // "a__|b", __ of b => non-boundary a-pos is right of __
- if (vpos + 1 == inlineCompletionVPos
- && (vpos + 1 < cursor_vpos || !boundary_correction)) {
- font = displayFont(pit, vpos + 1);
- docstring const & completion = bv_->inlineCompletion();
- if (font.isRightToLeft() && completion.length() > 0)
- x2 += theFontMetrics(font.fontInfo()).width(completion);
- }
-
- // Inline completion LTR case:
- // "b|__a", __ of b => non-boundary a-pos is in front of __
- if (vpos == inlineCompletionVPos
- && (vpos + 1 < cursor_vpos || boundary_correction)) {
- font = displayFont(pit, vpos);
- docstring const & completion = bv_->inlineCompletion();
- if (!font.isRightToLeft() && completion.length() > 0)
- x2 += theFontMetrics(font.fontInfo()).width(completion);
- }