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"
25 #include "support/gettext.h"
30 #include "MetricsInfo.h"
31 #include "Paragraph.h"
32 #include "ParagraphMetrics.h"
33 #include "paragraph_funcs.h"
34 #include "ParagraphParameters.h"
35 #include "TextMetrics.h"
38 #include "frontends/FontMetrics.h"
39 #include "frontends/Painter.h"
41 #include "insets/InsetText.h"
43 #include "support/debug.h"
44 #include "support/textutils.h"
46 #include <boost/assert.hpp>
47 #include <boost/crc.hpp>
55 using frontend::Painter;
56 using frontend::FontMetrics;
58 RowPainter::RowPainter(PainterInfo & pi,
59 Text const & text, pit_type pit, Row const & row, Bidi & bidi, int x, int y)
60 : pi_(pi), text_(text),
61 text_metrics_(pi_.base.bv->textMetrics(&text)),
62 pars_(text.paragraphs()),
63 row_(row), pit_(pit), par_(text.paragraphs()[pit]),
64 pm_(text_metrics_.parMetrics(pit)),
65 bidi_(bidi), erased_(pi_.erased_),
66 xo_(x), yo_(y), width_(text_metrics_.width())
68 bidi_.computeTables(par_, pi_.base.bv->buffer(), row_);
71 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
74 BOOST_ASSERT(pit >= 0);
75 BOOST_ASSERT(pit < int(text.paragraphs().size()));
79 FontInfo RowPainter::labelFont() const
81 return text_.labelFont(pi_.base.bv->buffer(), par_);
85 int RowPainter::leftMargin() const
87 return text_metrics_.leftMargin(text_metrics_.width(), pit_,
91 // If you want to debug inset metrics uncomment the following line:
92 //#define DEBUG_METRICS
93 // This draws green lines around each inset.
96 void RowPainter::paintInset(Inset const * inset, pos_type const pos)
98 Font const font = text_metrics_.displayFont(pit_, pos);
101 // Backup full_repaint status because some insets (InsetTabular)
102 // requires a full repaint
103 bool pi_full_repaint = pi_.full_repaint;
105 // FIXME: We should always use font, see documentation of
106 // noFontChange() in Inset.h.
107 pi_.base.font = inset->noFontChange() ?
108 pi_.base.bv->buffer().params().getFont().fontInfo() :
110 pi_.ltr_pos = (bidi_.level(pos) % 2 == 0);
111 pi_.erased_ = erased_ || par_.isDeleted(pos);
112 pi_.base.bv->coordCache().insets().add(inset, int(x_), yo_);
113 // insets are painted completely. Recursive
114 inset->drawSelection(pi_, int(x_), yo_);
115 inset->draw(pi_, int(x_), 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 x1 = int(x_ - dim.width());
129 BOOST_ASSERT(max_witdh_ > 0);
130 int right_margin = text_metrics_.rightMargin(pm_);
131 int const w = max_witdh_ - leftMargin() - right_margin;
132 MetricsInfo mi(pi_.base.bv, font.fontInfo(), w);
133 inset->metrics(mi, dim2);
134 if (dim.wid != dim2.wid)
135 lyxerr << "Error: inset " << to_ascii(inset->getInsetName())
136 << " draw width " << dim.width()
137 << "> metrics width " << dim2.wid << "." << endl;
138 if (dim->asc != dim2.asc)
139 lyxerr << "Error: inset " << to_ascii(inset->getInsetName())
140 << " draw ascent " << dim.ascent()
141 << "> metrics ascent " << dim2.asc << "." << endl;
142 if (dim2.descent() != dim.des)
143 lyxerr << "Error: inset " << to_ascii(inset->getInsetName())
144 << " draw ascent " << dim.descent()
145 << "> metrics descent " << dim2.des << "." << endl;
146 BOOST_ASSERT(dim2.wid == dim.wid);
147 BOOST_ASSERT(dim2.asc == dim.asc);
148 BOOST_ASSERT(dim2.des == dim.des);
149 int const x2 = x1 + dim.wid;
150 int const y1 = yo_ + dim.des;
151 int const y2 = yo_ - dim.asc;
152 pi_.pain.line(x1, y1, x1, y2, Color_green);
153 pi_.pain.line(x1, y1, x2, y1, Color_green);
154 pi_.pain.line(x2, y1, x2, y2, Color_green);
155 pi_.pain.line(x1, y2, x2, y2, Color_green);
160 void RowPainter::paintHebrewComposeChar(pos_type & vpos, FontInfo const & font)
162 pos_type pos = bidi_.vis2log(vpos);
167 char_type c = par_.getChar(pos);
171 int const width = theFontMetrics(font).width(c);
174 for (pos_type i = pos - 1; i >= 0; --i) {
176 if (!Encodings::isHebrewComposeChar(c)) {
177 if (isPrintableNonspace(c)) {
178 int const width2 = pm_.singleWidth(i,
179 text_metrics_.displayFont(pit_, i));
180 dx = (c == 0x05e8 || // resh
181 c == 0x05d3) // dalet
183 : (width2 - width) / 2;
190 pi_.pain.text(int(x_) + dx, yo_, str, font);
194 void RowPainter::paintArabicComposeChar(pos_type & vpos, FontInfo const & font)
196 pos_type pos = bidi_.vis2log(vpos);
200 char_type c = par_.getChar(pos);
201 c = par_.transformChar(c, pos);
205 int const width = theFontMetrics(font).width(c);
208 for (pos_type i = pos - 1; i >= 0; --i) {
210 if (!Encodings::isArabicComposeChar(c)) {
211 if (isPrintableNonspace(c)) {
212 int const width2 = pm_.singleWidth(i,
213 text_metrics_.displayFont(pit_, i));
214 dx = (width2 - width) / 2;
220 pi_.pain.text(int(x_) + dx, yo_, str, font);
224 void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
225 bool hebrew, bool arabic)
227 // This method takes up 70% of time when typing
228 pos_type pos = bidi_.vis2log(vpos);
229 pos_type const end = row_.endpos();
230 FontSpan const font_span = par_.fontSpan(pos);
231 Change::Type const prev_change = par_.lookupChange(pos).type;
234 vector<char_type> str;
236 str.push_back(par_.getChar(pos));
239 char_type c = str[0];
244 str[0] = par_.transformChar(c, pos);
248 pit_type const p0 = pi_.base.bv->cursor().selBegin().pit();
249 bool selection = row_.sel_beg > -1 && row_.sel_beg != row_.sel_end
250 && ((pit_ == p0 && (pos >= row_.sel_beg && pos < row_.sel_end))
251 || (pit_ > p0 && pos < row_.sel_end));
253 // collect as much similar chars as we can
254 for (++vpos ; vpos < end ; ++vpos) {
255 pos = bidi_.vis2log(vpos);
256 if (pos < font_span.first || pos > font_span.last)
259 if (row_.sel_beg > -1 && row_.sel_beg != row_.sel_end &&
260 ((pit_ == p0 && pos == row_.sel_beg) || pos == row_.sel_end))
263 if (prev_change != par_.lookupChange(pos).type)
266 char_type c = par_.getChar(pos);
268 if (!isPrintableNonspace(c))
271 /* Because we do our own bidi, at this point the strings are
272 * already in visual order. However, Qt also applies its own
273 * bidi algorithm to strings that it paints to the screen.
274 * Therefore, if we were to paint Hebrew/Arabic words as a
275 * single string, the letters in the words would get reversed
276 * again. In order to avoid that, we don't collect Hebrew/
277 * Arabic characters, but rather paint them one at a time.
278 * See also http://thread.gmane.org/gmane.editors.lyx.devel/79740
283 /* FIXME: these checks are irrelevant, since 'arabic' and
284 * 'hebrew' alone are already going to trigger a break.
285 * However, this should not be removed completely, because
286 * if an alternative solution is found which allows grouping
287 * of arabic and hebrew characters, then these breaks may have
290 if (arabic && Encodings::isArabicComposeChar(c))
293 if (hebrew && Encodings::isHebrewComposeChar(c))
302 c = par_.transformChar(c, pos);
303 /* see comment in hebrew, explaining why we break */
310 docstring s(&str[0], str.size());
312 if (selection || prev_change != Change::UNCHANGED) {
313 FontInfo copy = font;
315 copy.setColor(Color_selectiontext);
316 } else if (prev_change == Change::DELETED) {
317 copy.setColor(Color_deletedtext);
318 } else if (prev_change == Change::INSERTED) {
319 copy.setColor(Color_addedtext);
321 x_ += pi_.pain.text(int(x_), yo_, s, copy);
323 x_ += pi_.pain.text(int(x_), yo_, s, font);
328 void RowPainter::paintForeignMark(double orig_x, Language const * lang,
331 if (!lyxrc.mark_foreign_language)
333 if (lang == latex_language)
335 if (lang == pi_.base.bv->buffer().params().language)
338 int const y = yo_ + 1 + desc;
339 pi_.pain.line(int(orig_x), y, int(x_), y, Color_language);
343 void RowPainter::paintFromPos(pos_type & vpos)
345 pos_type const pos = bidi_.vis2log(vpos);
346 Font const orig_font = text_metrics_.displayFont(pit_, pos);
347 double const orig_x = x_;
349 // usual characters, no insets
350 char_type const c = par_.getChar(pos);
352 // special case languages
353 string const & lang = orig_font.language()->lang();
354 bool const hebrew = lang == "hebrew";
355 bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" ||
358 // draw as many chars as we can
359 if ((!hebrew && !arabic)
360 || (hebrew && !Encodings::isHebrewComposeChar(c))
361 || (arabic && !Encodings::isArabicComposeChar(c))) {
362 paintChars(vpos, orig_font.fontInfo(), hebrew, arabic);
364 paintHebrewComposeChar(vpos, orig_font.fontInfo());
366 paintArabicComposeChar(vpos, orig_font.fontInfo());
369 paintForeignMark(orig_x, orig_font.language());
373 void RowPainter::paintChangeBar()
375 pos_type const start = row_.pos();
376 pos_type end = row_.endpos();
378 if (par_.size() == end) {
379 // this is the last row of the paragraph;
380 // thus, we must also consider the imaginary end-of-par character
384 if (start == end || !par_.isChanged(start, end))
387 int const height = text_metrics_.isLastRow(pit_, row_)
391 pi_.pain.fillRectangle(5, yo_ - row_.ascent(), 3, height, Color_changebar);
395 void RowPainter::paintAppendix()
397 // only draw the appendix frame once (for the main text)
398 if (!par_.params().appendix() || !text_.isMainText(pi_.base.bv->buffer()))
401 int y = yo_ - row_.ascent();
403 if (par_.params().startOfAppendix())
404 y += 2 * defaultRowHeight();
406 pi_.pain.line(1, y, 1, yo_ + row_.height(), Color_appendix);
407 pi_.pain.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), Color_appendix);
411 void RowPainter::paintDepthBar()
413 depth_type const depth = par_.getDepth();
418 depth_type prev_depth = 0;
419 if (!text_metrics_.isFirstRow(pit_, row_)) {
420 pit_type pit2 = pit_;
423 prev_depth = pars_[pit2].getDepth();
426 depth_type next_depth = 0;
427 if (!text_metrics_.isLastRow(pit_, row_)) {
428 pit_type pit2 = pit_;
429 if (row_.endpos() >= pars_[pit2].size())
431 next_depth = pars_[pit2].getDepth();
434 for (depth_type i = 1; i <= depth; ++i) {
435 int const w = nestMargin() / 5;
436 int x = int(xo_) + w * i;
437 // only consider the changebar space if we're drawing outermost text
438 if (text_.isMainText(pi_.base.bv->buffer()))
439 x += changebarMargin();
441 int const starty = yo_ - row_.ascent();
442 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
444 pi_.pain.line(x, starty, x, starty + h, Color_depthbar);
447 pi_.pain.fillRectangle(x, starty, w, 2, Color_depthbar);
449 pi_.pain.fillRectangle(x, starty + h, w, 2, Color_depthbar);
454 int RowPainter::paintAppendixStart(int y)
456 FontInfo pb_font = sane_font;
457 pb_font.setColor(Color_appendix);
464 docstring const label = _("Appendix");
465 theFontMetrics(pb_font).rectText(label, w, a, d);
467 int const text_start = int(xo_ + (width_ - w) / 2);
468 int const text_end = text_start + w;
470 pi_.pain.rectText(text_start, y + d, label, pb_font, Color_none, Color_none);
472 pi_.pain.line(int(xo_ + 1), y, text_start, y, Color_appendix);
473 pi_.pain.line(text_end, y, int(xo_ + width_ - 2), y, Color_appendix);
475 return 3 * defaultRowHeight();
479 void RowPainter::paintFirst()
481 ParagraphParameters const & parparams = par_.params();
485 // start of appendix?
486 if (parparams.startOfAppendix())
487 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
489 Buffer const & buffer = pi_.base.bv->buffer();
490 Layout const & layout = par_.layout();
492 if (buffer.params().paragraph_separation == BufferParams::ParagraphSkipSeparation) {
494 if (layout.latextype == LATEX_PARAGRAPH
495 && !par_.getDepth()) {
496 y_top += buffer.params().getDefSkip().inPixels(*pi_.base.bv);
498 Layout const & playout = pars_[pit_ - 1].layout();
499 if (playout.latextype == LATEX_PARAGRAPH
500 && !pars_[pit_ - 1].getDepth()) {
501 // is it right to use defskip here, too? (AS)
502 y_top += buffer.params().getDefSkip().inPixels(*pi_.base.bv);
508 bool const is_rtl = text_.isRTL(buffer, par_);
509 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
510 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
512 // should we print a label?
513 if (layout.labeltype >= LABEL_STATIC
514 && (layout.labeltype != LABEL_STATIC
515 || layout.latextype != LATEX_ENVIRONMENT
518 FontInfo const font = labelFont();
519 FontMetrics const & fm = theFontMetrics(font);
521 docstring const str = par_.labelString();
525 // this is special code for the chapter layout. This is
526 // printed in an extra row and has a pagebreak at
528 if (layout.counter == "chapter") {
529 double spacing_val = 1.0;
530 if (!parparams.spacing().isDefault()) {
531 spacing_val = parparams.spacing().getValue();
533 spacing_val = buffer.params().spacing().getValue();
536 int const labeladdon = int(fm.maxHeight() * layout.spacing.getValue() * spacing_val);
538 int const maxdesc = int(fm.maxDescent() * layout.spacing.getValue() * spacing_val)
539 + int(layout.parsep) * defaultRowHeight();
542 x = width_ - leftMargin() -
546 pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
549 x = width_ - leftMargin()
550 + fm.width(layout.labelsep);
552 x = x_ - fm.width(layout.labelsep)
556 pi_.pain.text(int(x), yo_, str, font);
560 // the labels at the top of an environment.
561 // More or less for bibliography
563 (layout.labeltype == LABEL_TOP_ENVIRONMENT ||
564 layout.labeltype == LABEL_BIBLIO ||
565 layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
566 FontInfo const font = labelFont();
567 docstring const str = par_.labelString();
569 double spacing_val = 1.0;
570 if (!parparams.spacing().isDefault())
571 spacing_val = parparams.spacing().getValue();
573 spacing_val = buffer.params().spacing().getValue();
575 FontMetrics const & fm = theFontMetrics(font);
577 int const labeladdon = int(fm.maxHeight()
578 * layout.spacing.getValue() * spacing_val);
581 int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
582 + (layout.labelbottomsep * defaultRowHeight()));
585 if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
588 x += (width_ - text_metrics_.rightMargin(pm_) - leftMargin()) / 2;
589 x -= fm.width(str) / 2;
591 x = width_ - leftMargin() - fm.width(str);
593 pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
599 void RowPainter::paintLast()
601 bool const is_rtl = text_.isRTL(pi_.base.bv->buffer(), par_);
602 int const endlabel = getEndLabel(pit_, text_.paragraphs());
604 // paint imaginary end-of-paragraph character
606 if (par_.isInserted(par_.size()) || par_.isDeleted(par_.size())) {
607 FontMetrics const & fm = theFontMetrics(pi_.base.bv->buffer().params().getFont());
608 int const length = fm.maxAscent() / 2;
609 ColorCode col = par_.isInserted(par_.size()) ? Color_addedtext : Color_deletedtext;
611 pi_.pain.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col,
612 Painter::line_solid, Painter::line_thick);
613 pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1, yo_ + 2, col,
614 Painter::line_solid, Painter::line_thick);
621 case END_LABEL_FILLED_BOX: {
622 FontInfo const font = labelFont();
623 FontMetrics const & fm = theFontMetrics(font);
624 int const size = int(0.75 * fm.maxAscent());
625 int const y = yo_ - size;
626 int const max_row_width = width_ - size - Inset::TEXT_TO_INSET_OFFSET;
627 int x = is_rtl ? nestMargin() + changebarMargin()
628 : max_row_width - text_metrics_.rightMargin(pm_);
630 // If needed, move the box a bit to avoid overlapping with text.
631 int const rem = max_row_width - row_.width();
633 x += is_rtl ? rem : - rem;
635 if (endlabel == END_LABEL_BOX)
636 pi_.pain.rectangle(x, y, size, size, Color_eolmarker);
638 pi_.pain.fillRectangle(x, y, size, size, Color_eolmarker);
642 case END_LABEL_STATIC: {
643 FontInfo const font = labelFont();
644 FontMetrics const & fm = theFontMetrics(font);
645 docstring const & str = par_.layout().endlabelstring();
646 double const x = is_rtl ?
648 : - text_metrics_.rightMargin(pm_) - row_.width();
649 pi_.pain.text(int(x), yo_, str, font);
653 case END_LABEL_NO_LABEL:
659 void RowPainter::paintOnlyInsets()
661 pos_type const end = row_.endpos();
662 for (pos_type pos = row_.pos(); pos != end; ++pos) {
663 // If outer row has changed, nested insets are repaint completely.
664 Inset const * inset = par_.getInset(pos);
667 if (x_ > pi_.base.bv->workWidth())
669 x_ = pi_.base.bv->coordCache().getInsets().x(inset);
670 paintInset(inset, pos);
675 void RowPainter::paintText()
677 pos_type const end = row_.endpos();
678 // Spaces at logical line breaks in bidi text must be skipped during
679 // painting. However, they may appear visually in the middle
680 // of a row; they must be skipped, wherever they are...
681 // * logically "abc_[HEBREW_\nHEBREW]"
682 // * visually "abc_[_WERBEH\nWERBEH]"
683 pos_type skipped_sep_vpos = -1;
684 pos_type body_pos = par_.beginOfBody();
686 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
690 Layout const & layout = par_.layout();
692 bool running_strikeout = false;
693 bool is_struckout = false;
694 int last_strikeout_x = 0;
696 // check for possible inline completion
697 DocIterator const & inlineCompletionPos = pi_.base.bv->inlineCompletionPos();
698 pos_type inlineCompletionVPos = -1;
699 if (inlineCompletionPos.inTexted()
700 && inlineCompletionPos.text() == &text_
701 && inlineCompletionPos.pit() == pit_
702 && inlineCompletionPos.pos() - 1 >= row_.pos()
703 && inlineCompletionPos.pos() - 1 < row_.endpos()) {
704 // draw logically behind the previous character
705 inlineCompletionVPos = bidi_.log2vis(inlineCompletionPos.pos() - 1);
708 // Use font span to speed things up, see below
712 // If the last logical character is a separator, don't paint it, unless
713 // it's in the last row of a paragraph; see skipped_sep_vpos declaration
714 if (end > 0 && end < par_.size() && par_.isSeparator(end - 1))
715 skipped_sep_vpos = bidi_.log2vis(end - 1);
717 for (pos_type vpos = row_.pos(); vpos < end; ) {
718 if (x_ > pi_.base.bv->workWidth())
721 // Skip the separator at the logical end of the row
722 if (vpos == skipped_sep_vpos) {
727 pos_type const pos = bidi_.vis2log(vpos);
729 if (pos >= par_.size()) {
734 // Use font span to speed things up, see above
735 if (vpos < font_span.first || vpos > font_span.last) {
736 font_span = par_.fontSpan(vpos);
737 font = text_metrics_.displayFont(pit_, vpos);
739 // split font span if inline completion is inside
740 if (font_span.first <= inlineCompletionVPos
741 && font_span.last > inlineCompletionVPos)
742 font_span.last = inlineCompletionVPos;
745 const int width_pos = pm_.singleWidth(pos, font);
747 if (x_ + width_pos < 0) {
753 is_struckout = par_.isDeleted(pos);
755 if (is_struckout && !running_strikeout) {
756 running_strikeout = true;
757 last_strikeout_x = int(x_);
760 Inset const * inset = par_.getInset(pos);
761 bool const highly_editable_inset = inset
762 && inset->editable() == Inset::HIGHLY_EDITABLE;
764 // If we reach the end of a struck out range, paint it.
765 // We also don't paint across things like tables
766 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
767 // Calculate 1/3 height of the buffer's default font
768 FontMetrics const & fm
769 = theFontMetrics(pi_.base.bv->buffer().params().getFont());
770 int const middle = yo_ - fm.maxAscent() / 3;
771 pi_.pain.line(last_strikeout_x, middle, int(x_), middle,
772 Color_deletedtext, Painter::line_solid, Painter::line_thin);
773 running_strikeout = false;
776 if (body_pos > 0 && pos == body_pos - 1) {
777 int const lwidth = theFontMetrics(labelFont())
778 .width(layout.labelsep);
780 x_ += row_.label_hfill + lwidth - width_pos;
783 // Is the inline completion in front of character?
784 if (font.isRightToLeft() && vpos == inlineCompletionVPos)
785 paintInlineCompletion(font);
787 if (par_.isSeparator(pos)) {
788 Font const orig_font = text_metrics_.displayFont(pit_, pos);
789 double const orig_x = x_;
792 x_ += row_.separator;
793 paintForeignMark(orig_x, orig_font.language());
797 // If outer row has changed, nested insets are repaint completely.
798 pi_.base.bv->coordCache().insets().add(inset, int(x_), yo_);
799 paintInset(inset, pos);
803 // paint as many characters as possible.
807 // Is the inline completion after character?
808 if (!font.isRightToLeft() && vpos - 1 == inlineCompletionVPos)
809 paintInlineCompletion(font);
812 // if we reach the end of a struck out range, paint it
813 if (running_strikeout) {
814 // calculate 1/3 height of the buffer's default font
815 FontMetrics const & fm
816 = theFontMetrics(pi_.base.bv->buffer().params().getFont());
817 int const middle = yo_ - fm.maxAscent() / 3;
818 pi_.pain.line(last_strikeout_x, middle, int(x_), middle,
819 Color_deletedtext, Painter::line_solid, Painter::line_thin);
820 running_strikeout = false;
825 void RowPainter::paintInlineCompletion(Font const & font)
827 docstring completion = pi_.base.bv->inlineCompletion();
828 FontInfo f = font.fontInfo();
829 bool rtl = font.isRightToLeft();
831 // draw the unique and the non-unique completion part
832 // Note: this is not time-critical as it is
833 // only done once per screen.
834 size_t uniqueTo = pi_.base.bv->inlineCompletionUniqueChars();
835 docstring s1 = completion.substr(0, uniqueTo);
836 docstring s2 = completion.substr(uniqueTo);
837 ColorCode c1 = Color_inlinecompletion;
838 ColorCode c2 = Color_nonunique_inlinecompletion;
843 reverse(s1.begin(), s1.end());
844 reverse(s2.begin(), s2.end());
850 pi_.pain.text(int(x_), yo_, s1, f);
851 x_ += theFontMetrics(font).width(s1);
856 pi_.pain.text(int(x_), yo_, s2, f);
857 x_ += theFontMetrics(font).width(s2);