3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #include "rowpainter.h"
19 #include "CoordCache.h"
21 #include "BufferParams.h"
22 #include "BufferView.h"
29 #include "MetricsInfo.h"
30 #include "Paragraph.h"
31 #include "ParagraphMetrics.h"
32 #include "ParagraphParameters.h"
33 #include "TextMetrics.h"
36 #include "frontends/FontMetrics.h"
37 #include "frontends/Painter.h"
39 #include "insets/InsetText.h"
41 #include "support/debug.h"
42 #include "support/gettext.h"
43 #include "support/textutils.h"
45 #include "support/lassert.h"
46 #include <boost/crc.hpp>
52 using frontend::Painter;
53 using frontend::FontMetrics;
55 RowPainter::RowPainter(PainterInfo & pi,
56 Text const & text, pit_type pit, Row const & row, Bidi & bidi, int x, int y)
57 : pi_(pi), text_(text),
58 text_metrics_(pi_.base.bv->textMetrics(&text)),
59 pars_(text.paragraphs()),
60 row_(row), pit_(pit), par_(text.paragraphs()[pit]),
61 pm_(text_metrics_.parMetrics(pit)),
62 bidi_(bidi), change_(pi_.change_),
63 xo_(x), yo_(y), width_(text_metrics_.width())
65 bidi_.computeTables(par_, pi_.base.bv->buffer(), row_);
68 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
71 LASSERT(pit >= 0, /**/);
72 LASSERT(pit < int(text.paragraphs().size()), /**/);
76 FontInfo RowPainter::labelFont() const
78 return text_.labelFont(par_);
82 int RowPainter::leftMargin() const
84 return text_metrics_.leftMargin(text_metrics_.width(), pit_,
88 // If you want to debug inset metrics uncomment the following line:
89 //#define DEBUG_METRICS
90 // This draws green lines around each inset.
93 void RowPainter::paintInset(Inset const * inset, pos_type const pos)
95 Font const font = text_metrics_.displayFont(pit_, pos);
97 LASSERT(inset, return);
98 // Backup full_repaint status because some insets (InsetTabular)
99 // requires a full repaint
100 bool pi_full_repaint = pi_.full_repaint;
102 // FIXME: We should always use font, see documentation of
103 // noFontChange() in Inset.h.
104 pi_.base.font = inset->noFontChange() ?
105 pi_.base.bv->buffer().params().getFont().fontInfo() :
107 pi_.ltr_pos = (bidi_.level(pos) % 2 == 0);
108 pi_.change_ = change_.changed() ? change_ : par_.lookupChange(pos);
110 int const x1 = int(x_);
111 pi_.base.bv->coordCache().insets().add(inset, x1, yo_);
112 // insets are painted completely. Recursive
113 inset->drawBackground(pi_, x1, yo_);
114 inset->drawSelection(pi_, x1, yo_);
115 inset->draw(pi_, x1, yo_);
117 Dimension const & dim = pm_.insetDimension(inset);
119 paintForeignMark(x_, font.language(), dim.descent());
123 // Restore full_repaint status.
124 pi_.full_repaint = pi_full_repaint;
127 int const x2 = x1 + dim.wid;
128 int const y1 = yo_ + dim.des;
129 int const y2 = yo_ - dim.asc;
130 pi_.pain.line(x1, y1, x1, y2, Color_green);
131 pi_.pain.line(x1, y1, x2, y1, Color_green);
132 pi_.pain.line(x2, y1, x2, y2, Color_green);
133 pi_.pain.line(x1, y2, x2, y2, Color_green);
138 void RowPainter::paintHebrewComposeChar(pos_type & vpos, FontInfo const & font)
140 pos_type pos = bidi_.vis2log(vpos);
145 char_type c = par_.getChar(pos);
149 int const width = theFontMetrics(font).width(c);
152 for (pos_type i = pos - 1; i >= 0; --i) {
154 if (!Encodings::isHebrewComposeChar(c)) {
155 if (isPrintableNonspace(c)) {
156 int const width2 = pm_.singleWidth(i,
157 text_metrics_.displayFont(pit_, i));
158 dx = (c == 0x05e8 || // resh
159 c == 0x05d3) // dalet
161 : (width2 - width) / 2;
168 pi_.pain.text(int(x_) + dx, yo_, str, font);
172 void RowPainter::paintArabicComposeChar(pos_type & vpos, FontInfo const & font)
174 pos_type pos = bidi_.vis2log(vpos);
178 char_type c = par_.getChar(pos);
179 c = par_.transformChar(c, pos);
183 int const width = theFontMetrics(font).width(c);
186 for (pos_type i = pos - 1; i >= 0; --i) {
188 if (!Encodings::isArabicComposeChar(c)) {
189 if (isPrintableNonspace(c)) {
190 int const width2 = pm_.singleWidth(i,
191 text_metrics_.displayFont(pit_, i));
192 dx = (width2 - width) / 2;
198 pi_.pain.text(int(x_) + dx, yo_, str, font);
202 void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
203 bool hebrew, bool arabic)
205 // This method takes up 70% of time when typing
206 pos_type pos = bidi_.vis2log(vpos);
208 vector<char_type> str;
210 str.push_back(par_.getChar(pos));
213 char_type c = str[0];
218 str[0] = par_.transformChar(c, pos);
221 pos_type const end = row_.endpos();
222 FontSpan const font_span = par_.fontSpan(pos);
223 // Track-change status.
224 Change const & change_running = par_.lookupChange(pos);
227 bool const selection = (pos >= row_.sel_beg && pos < row_.sel_end)
230 char_type prev_char = ' ';
231 // collect as much similar chars as we can
232 for (++vpos ; vpos < end ; ++vpos) {
233 pos = bidi_.vis2log(vpos);
234 if (pos < font_span.first || pos > font_span.last)
237 bool const new_selection = pos >= row_.sel_beg && pos < row_.sel_end;
238 if (new_selection != selection)
239 // Selection ends or starts here.
242 Change const & change = par_.lookupChange(pos);
243 if (!change_running.isSimilarTo(change))
244 // Track change type or author has changed.
247 char_type c = par_.getChar(pos);
249 if (c == '\t' || prev_char == '\t') {
254 if (!isPrintableNonspace(c))
257 /* Because we do our own bidi, at this point the strings are
258 * already in visual order. However, Qt also applies its own
259 * bidi algorithm to strings that it paints to the screen.
260 * Therefore, if we were to paint Hebrew/Arabic words as a
261 * single string, the letters in the words would get reversed
262 * again. In order to avoid that, we don't collect Hebrew/
263 * Arabic characters, but rather paint them one at a time.
264 * See also http://thread.gmane.org/gmane.editors.lyx.devel/79740
269 /* FIXME: these checks are irrelevant, since 'arabic' and
270 * 'hebrew' alone are already going to trigger a break.
271 * However, this should not be removed completely, because
272 * if an alternative solution is found which allows grouping
273 * of arabic and hebrew characters, then these breaks may have
276 if (arabic && Encodings::isArabicComposeChar(c))
279 if (hebrew && Encodings::isHebrewComposeChar(c))
288 c = par_.transformChar(c, pos);
289 /* see comment in hebrew, explaining why we break */
296 docstring s(&str[0], str.size());
299 s.replace(0,1,from_ascii(" "));
301 if (!selection && !change_running.changed()) {
302 x_ += pi_.pain.text(int(x_), yo_, s, font);
306 FontInfo copy = font;
307 if (change_running.changed())
308 copy.setPaintColor(change_running.color());
310 copy.setPaintColor(Color_selectiontext);
312 x_ += pi_.pain.text(int(x_), yo_, s, copy);
316 void RowPainter::paintForeignMark(double orig_x, Language const * lang,
319 if (!lyxrc.mark_foreign_language)
321 if (lang == latex_language)
323 if (lang == pi_.base.bv->buffer().params().language)
326 int const y = yo_ + 1 + desc;
327 pi_.pain.line(int(orig_x), y, int(x_), y, Color_language);
331 void RowPainter::paintMisspelledMark(double orig_x, int desc)
333 int const y = yo_ + desc;
334 pi_.pain.line(int(orig_x), y, int(x_), y, Color_red, Painter::line_onoffdash, Painter::line_thin);
338 void RowPainter::paintFromPos(pos_type & vpos)
340 pos_type const pos = bidi_.vis2log(vpos);
341 Font const orig_font = text_metrics_.displayFont(pit_, pos);
342 double const orig_x = x_;
344 // usual characters, no insets
345 char_type const c = par_.getChar(pos);
347 // special case languages
348 string const & lang = orig_font.language()->lang();
349 bool const hebrew = lang == "hebrew";
350 bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" ||
353 // draw as many chars as we can
354 if ((!hebrew && !arabic)
355 || (hebrew && !Encodings::isHebrewComposeChar(c))
356 || (arabic && !Encodings::isArabicComposeChar(c))) {
357 paintChars(vpos, orig_font.fontInfo(), hebrew, arabic);
359 paintHebrewComposeChar(vpos, orig_font.fontInfo());
361 paintArabicComposeChar(vpos, orig_font.fontInfo());
364 paintForeignMark(orig_x, orig_font.language());
366 if (lyxrc.spellcheck_continuously && orig_font.isMisspelled())
367 paintMisspelledMark(orig_x, 2);
371 void RowPainter::paintChangeBar()
373 pos_type const start = row_.pos();
374 pos_type end = row_.endpos();
376 if (par_.size() == end) {
377 // this is the last row of the paragraph;
378 // thus, we must also consider the imaginary end-of-par character
382 if (start == end || !par_.isChanged(start, end))
385 int const height = text_metrics_.isLastRow(pit_, row_)
389 pi_.pain.fillRectangle(5, yo_ - row_.ascent(), 3, height, Color_changebar);
393 void RowPainter::paintAppendix()
395 // only draw the appendix frame once (for the main text)
396 if (!par_.params().appendix() || !text_.isMainText())
399 int y = yo_ - row_.ascent();
401 if (par_.params().startOfAppendix())
402 y += 2 * defaultRowHeight();
404 pi_.pain.line(1, y, 1, yo_ + row_.height(), Color_appendix);
405 pi_.pain.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), Color_appendix);
409 void RowPainter::paintDepthBar()
411 depth_type const depth = par_.getDepth();
416 depth_type prev_depth = 0;
417 if (!text_metrics_.isFirstRow(pit_, row_)) {
418 pit_type pit2 = pit_;
421 prev_depth = pars_[pit2].getDepth();
424 depth_type next_depth = 0;
425 if (!text_metrics_.isLastRow(pit_, row_)) {
426 pit_type pit2 = pit_;
427 if (row_.endpos() >= pars_[pit2].size())
429 next_depth = pars_[pit2].getDepth();
432 for (depth_type i = 1; i <= depth; ++i) {
433 int const w = nestMargin() / 5;
434 int x = int(xo_) + w * i;
435 // only consider the changebar space if we're drawing outermost text
436 if (text_.isMainText())
437 x += changebarMargin();
439 int const starty = yo_ - row_.ascent();
440 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
442 pi_.pain.line(x, starty, x, starty + h, Color_depthbar);
445 pi_.pain.fillRectangle(x, starty, w, 2, Color_depthbar);
447 pi_.pain.fillRectangle(x, starty + h, w, 2, Color_depthbar);
452 int RowPainter::paintAppendixStart(int y)
454 FontInfo pb_font = sane_font;
455 pb_font.setColor(Color_appendix);
462 docstring const label = _("Appendix");
463 theFontMetrics(pb_font).rectText(label, w, a, d);
465 int const text_start = int(xo_ + (width_ - w) / 2);
466 int const text_end = text_start + w;
468 pi_.pain.rectText(text_start, y + d, label, pb_font, Color_none, Color_none);
470 pi_.pain.line(int(xo_ + 1), y, text_start, y, Color_appendix);
471 pi_.pain.line(text_end, y, int(xo_ + width_ - 2), y, Color_appendix);
473 return 3 * defaultRowHeight();
477 void RowPainter::paintFirst()
479 ParagraphParameters const & parparams = par_.params();
483 // start of appendix?
484 if (parparams.startOfAppendix())
485 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
487 Buffer const & buffer = pi_.base.bv->buffer();
488 Layout const & layout = par_.layout();
490 if (buffer.params().paragraph_separation == BufferParams::ParagraphSkipSeparation) {
492 if (layout.latextype == LATEX_PARAGRAPH
493 && !par_.getDepth()) {
494 y_top += buffer.params().getDefSkip().inPixels(*pi_.base.bv);
496 Layout const & playout = pars_[pit_ - 1].layout();
497 if (playout.latextype == LATEX_PARAGRAPH
498 && !pars_[pit_ - 1].getDepth()) {
499 // is it right to use defskip here, too? (AS)
500 y_top += buffer.params().getDefSkip().inPixels(*pi_.base.bv);
506 bool const is_rtl = text_.isRTL(par_);
507 bool const is_seq = text_.isFirstInSequence(pit_);
508 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
510 // should we print a label?
511 if (layout.labeltype >= LABEL_STATIC
512 && (layout.labeltype != LABEL_STATIC
513 || layout.latextype != LATEX_ENVIRONMENT
516 FontInfo const font = labelFont();
517 FontMetrics const & fm = theFontMetrics(font);
519 docstring const str = par_.labelString();
523 // this is special code for the chapter layout. This is
524 // printed in an extra row and has a pagebreak at
526 if (layout.counter == "chapter") {
527 double spacing_val = 1.0;
528 if (!parparams.spacing().isDefault()) {
529 spacing_val = parparams.spacing().getValue();
531 spacing_val = buffer.params().spacing().getValue();
534 int const labeladdon = int(fm.maxHeight() * layout.spacing.getValue() * spacing_val);
536 int const maxdesc = int(fm.maxDescent() * layout.spacing.getValue() * spacing_val)
537 + int(layout.parsep) * defaultRowHeight();
540 x = width_ - leftMargin() -
544 pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
547 x = width_ - leftMargin()
548 + fm.width(layout.labelsep);
550 x = x_ - fm.width(layout.labelsep)
554 pi_.pain.text(int(x), yo_, str, font);
558 // the labels at the top of an environment.
559 // More or less for bibliography
561 (layout.labeltype == LABEL_TOP_ENVIRONMENT ||
562 layout.labeltype == LABEL_BIBLIO ||
563 layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
564 FontInfo const font = labelFont();
565 docstring const str = par_.labelString();
567 double spacing_val = 1.0;
568 if (!parparams.spacing().isDefault())
569 spacing_val = parparams.spacing().getValue();
571 spacing_val = buffer.params().spacing().getValue();
573 FontMetrics const & fm = theFontMetrics(font);
575 int const labeladdon = int(fm.maxHeight()
576 * layout.spacing.getValue() * spacing_val);
579 int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
580 + (layout.labelbottomsep * defaultRowHeight()));
583 if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
586 x += (width_ - text_metrics_.rightMargin(pm_) - leftMargin()) / 2;
587 x -= fm.width(str) / 2;
589 x = width_ - leftMargin() - fm.width(str);
591 pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
597 /** Check if the current paragraph is the last paragraph in a
599 static int getEndLabel(pit_type p, Text const & text)
601 ParagraphList const & pars = text.paragraphs();
603 depth_type par_depth = pars[p].getDepth();
604 while (pit != pit_type(pars.size())) {
605 Layout const & layout = pars[pit].layout();
606 int const endlabeltype = layout.endlabeltype;
608 if (endlabeltype != END_LABEL_NO_LABEL) {
609 if (p + 1 == pit_type(pars.size()))
612 depth_type const next_depth =
613 pars[p + 1].getDepth();
614 if (par_depth > next_depth ||
615 (par_depth == next_depth && layout != pars[p + 1].layout()))
621 pit = text.outerHook(pit);
622 if (pit != pit_type(pars.size()))
623 par_depth = pars[pit].getDepth();
625 return END_LABEL_NO_LABEL;
629 void RowPainter::paintLast()
631 bool const is_rtl = text_.isRTL(par_);
632 int const endlabel = getEndLabel(pit_, text_);
634 // paint imaginary end-of-paragraph character
636 Change const & change = par_.lookupChange(par_.size());
637 if (change.changed()) {
638 FontMetrics const & fm =
639 theFontMetrics(pi_.base.bv->buffer().params().getFont());
640 int const length = fm.maxAscent() / 2;
641 Color col = change.color();
643 pi_.pain.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col,
644 Painter::line_solid, Painter::line_thick);
646 if (change.deleted()) {
647 pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1 + length,
648 yo_ + 2, col, Painter::line_solid, Painter::line_thick);
650 pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1,
651 yo_ + 2, col, Painter::line_solid, Painter::line_thick);
659 case END_LABEL_FILLED_BOX: {
660 FontInfo const font = labelFont();
661 FontMetrics const & fm = theFontMetrics(font);
662 int const size = int(0.75 * fm.maxAscent());
663 int const y = yo_ - size;
664 int const max_row_width = width_ - size - Inset::TEXT_TO_INSET_OFFSET;
665 int x = is_rtl ? nestMargin() + changebarMargin()
666 : max_row_width - text_metrics_.rightMargin(pm_);
668 // If needed, move the box a bit to avoid overlapping with text.
669 int const rem = max_row_width - row_.width();
671 x += is_rtl ? rem : - rem;
673 if (endlabel == END_LABEL_BOX)
674 pi_.pain.rectangle(x, y, size, size, Color_eolmarker);
676 pi_.pain.fillRectangle(x, y, size, size, Color_eolmarker);
680 case END_LABEL_STATIC: {
681 FontInfo const font = labelFont();
682 FontMetrics const & fm = theFontMetrics(font);
683 docstring const & str = par_.layout().endlabelstring();
684 double const x = is_rtl ? x_ - fm.width(str) : x_;
685 pi_.pain.text(int(x), yo_, str, font);
689 case END_LABEL_NO_LABEL:
690 if (lyxrc.paragraph_markers && size_type(pit_ + 1) < pars_.size()) {
691 docstring const s = docstring(1, char_type(0x00B6));
692 FontInfo f = FontInfo();
693 FontMetrics const & fm = theFontMetrics(f);
694 f.setColor(Color_paragraphmarker);
695 pi_.pain.text(int(x_), yo_, s, f);
703 void RowPainter::paintOnlyInsets()
705 CoordCache const & cache = pi_.base.bv->coordCache();
706 pos_type const end = row_.endpos();
707 for (pos_type pos = row_.pos(); pos != end; ++pos) {
708 // If outer row has changed, nested insets are repaint completely.
709 Inset const * inset = par_.getInset(pos);
712 if (x_ > pi_.base.bv->workWidth()
713 || !cache.getInsets().has(inset))
715 x_ = cache.getInsets().x(inset);
717 bool const pi_selected = pi_.selected;
718 Cursor const & cur = pi_.base.bv->cursor();
719 if (cur.selection() && cur.text() == &text_
720 && cur.normalAnchor().text() == &text_)
721 pi_.selected = row_.sel_beg <= pos && row_.sel_end > pos;
722 paintInset(inset, pos);
723 pi_.selected = pi_selected;
728 void RowPainter::paintText()
730 pos_type const end = row_.endpos();
731 // Spaces at logical line breaks in bidi text must be skipped during
732 // painting. However, they may appear visually in the middle
733 // of a row; they must be skipped, wherever they are...
734 // * logically "abc_[HEBREW_\nHEBREW]"
735 // * visually "abc_[_WERBEH\nWERBEH]"
736 pos_type skipped_sep_vpos = -1;
737 pos_type body_pos = par_.beginOfBody();
739 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
743 Layout const & layout = par_.layout();
745 Change change_running;
746 int change_last_x = 0;
748 // check for possible inline completion
749 DocIterator const & inlineCompletionPos = pi_.base.bv->inlineCompletionPos();
750 pos_type inlineCompletionVPos = -1;
751 if (inlineCompletionPos.inTexted()
752 && inlineCompletionPos.text() == &text_
753 && inlineCompletionPos.pit() == pit_
754 && inlineCompletionPos.pos() - 1 >= row_.pos()
755 && inlineCompletionPos.pos() - 1 < row_.endpos()) {
756 // draw logically behind the previous character
757 inlineCompletionVPos = bidi_.log2vis(inlineCompletionPos.pos() - 1);
760 // Use font span to speed things up, see below
764 // If the last logical character is a separator, don't paint it, unless
765 // it's in the last row of a paragraph; see skipped_sep_vpos declaration
766 if (end > 0 && end < par_.size() && par_.isSeparator(end - 1))
767 skipped_sep_vpos = bidi_.log2vis(end - 1);
769 for (pos_type vpos = row_.pos(); vpos < end; ) {
770 if (x_ > pi_.base.bv->workWidth())
773 // Skip the separator at the logical end of the row
774 if (vpos == skipped_sep_vpos) {
779 pos_type const pos = bidi_.vis2log(vpos);
781 if (pos >= par_.size()) {
786 // Use font span to speed things up, see above
787 if (vpos < font_span.first || vpos > font_span.last) {
788 font_span = par_.fontSpan(vpos);
789 font = text_metrics_.displayFont(pit_, vpos);
791 // split font span if inline completion is inside
792 if (font_span.first <= inlineCompletionVPos
793 && font_span.last > inlineCompletionVPos)
794 font_span.last = inlineCompletionVPos;
797 const int width_pos = pm_.singleWidth(pos, font);
799 if (x_ + width_pos < 0) {
804 Change const & change = par_.lookupChange(pos);
805 if (change.changed() && !change_running.changed()) {
806 change_running = change;
807 change_last_x = int(x_);
810 Inset const * inset = par_.getInset(pos);
811 bool const highly_editable_inset = inset
812 && inset->editable();
814 // If we reach the end of a change or if the author changes, paint it.
815 // We also don't paint across things like tables
816 if (change_running.changed() && (highly_editable_inset
817 || !change.changed() || !change_running.isSimilarTo(change))) {
818 // Calculate 1/3 height of the buffer's default font
819 FontMetrics const & fm
820 = theFontMetrics(pi_.base.bv->buffer().params().getFont());
821 int const y_bar = change_running.deleted() ?
822 yo_ - fm.maxAscent() / 3 : yo_ + fm.maxAscent() / 6;
823 pi_.pain.line(change_last_x, y_bar, int(x_), y_bar,
824 change_running.color(), Painter::line_solid,
827 // Change might continue with a different author or type
828 if (change.changed() && !highly_editable_inset) {
829 change_running = change;
830 change_last_x = int(x_);
832 change_running.setUnchanged();
835 if (body_pos > 0 && pos == body_pos - 1) {
836 int const lwidth = theFontMetrics(labelFont())
837 .width(layout.labelsep);
839 x_ += row_.label_hfill + lwidth - width_pos;
842 // Is the inline completion in front of character?
843 if (font.isRightToLeft() && vpos == inlineCompletionVPos)
844 paintInlineCompletion(font);
846 if (par_.isSeparator(pos)) {
847 Font const orig_font = text_metrics_.displayFont(pit_, pos);
848 double const orig_x = x_;
851 x_ += row_.separator;
852 paintForeignMark(orig_x, orig_font.language());
856 // If outer row has changed, nested insets are repaint completely.
857 pi_.base.bv->coordCache().insets().add(inset, int(x_), yo_);
859 bool const pi_selected = pi_.selected;
860 Cursor const & cur = pi_.base.bv->cursor();
861 if (cur.selection() && cur.text() == &text_
862 && cur.normalAnchor().text() == &text_)
863 pi_.selected = row_.sel_beg <= pos && row_.sel_end > pos;
864 paintInset(inset, pos);
865 pi_.selected = pi_selected;
869 // paint as many characters as possible.
873 // Is the inline completion after character?
874 if (!font.isRightToLeft() && vpos - 1 == inlineCompletionVPos)
875 paintInlineCompletion(font);
878 // if we reach the end of a struck out range, paint it
879 if (change_running.changed()) {
880 FontMetrics const & fm
881 = theFontMetrics(pi_.base.bv->buffer().params().getFont());
882 int const y_bar = change_running.deleted() ?
883 yo_ - fm.maxAscent() / 3 : yo_ + fm.maxAscent() / 6;
884 pi_.pain.line(change_last_x, y_bar, int(x_), y_bar,
885 change_running.color(), Painter::line_solid, Painter::line_thin);
886 change_running.setUnchanged();
891 void RowPainter::paintInlineCompletion(Font const & font)
893 docstring completion = pi_.base.bv->inlineCompletion();
894 FontInfo f = font.fontInfo();
895 bool rtl = font.isRightToLeft();
897 // draw the unique and the non-unique completion part
898 // Note: this is not time-critical as it is
899 // only done once per screen.
900 size_t uniqueTo = pi_.base.bv->inlineCompletionUniqueChars();
901 docstring s1 = completion.substr(0, uniqueTo);
902 docstring s2 = completion.substr(uniqueTo);
903 ColorCode c1 = Color_inlinecompletion;
904 ColorCode c2 = Color_nonunique_inlinecompletion;
914 pi_.pain.text(int(x_), yo_, s1, f);
915 x_ += theFontMetrics(font).width(s1);
920 pi_.pain.text(int(x_), yo_, s2, f);
921 x_ += theFontMetrics(font).width(s2);