- BufferView & bv = *pi.base.bv;
- setXY(bv, x, y);
-
- Dimension const & dim = bv.coordCache().getArrays().dim(this);
-
- if (empty()) {
- pi.pain.rectangle(x, y - dim.ascent(), dim.width(), dim.height(), Color_mathline);
- return;
- }
-
- // don't draw outside the workarea
- if (y + dim.descent() <= 0
- || y - dim.ascent() >= bv.workHeight()
- || x + dim.width() <= 0
- || x >= bv. workWidth())
- return;
-
- DocIterator const & inlineCompletionPos = bv.inlineCompletionPos();
- MathData const * inlineCompletionData = 0;
- if (inlineCompletionPos.inMathed())
- inlineCompletionData = &inlineCompletionPos.cell();
-
- CoordCache::Insets & coords = pi.base.bv->coordCache().insets();
- for (size_t i = 0, n = size(); i != n; ++i) {
- MathAtom const & at = operator[](i);
- coords.add(at.nucleus(), x, y);
- at->drawSelection(pi, x, y);
- at->draw(pi, x, y);
- x += coords.dim(at.nucleus()).wid;
-
- // Is the inline completion here?
- if (inlineCompletionData != this
- || size_t(inlineCompletionPos.pos()) != i + 1)
- continue;
- docstring const & completion = bv.inlineCompletion();
- if (completion.length() == 0)
- continue;
- FontInfo f = pi.base.font;
- augmentFont(f, from_ascii("mathnormal"));
-
- // draw the unique and the non-unique completion part
- // Note: this is not time-critical as it is
- // only done once per screen.
- size_t uniqueTo = bv.inlineCompletionUniqueChars();
- docstring s1 = completion.substr(0, uniqueTo);
- docstring s2 = completion.substr(uniqueTo);
-
- if (!s1.empty()) {
- f.setColor(Color_inlinecompletion);
- pi.pain.text(x, y, s1, f);
- x += mathed_string_width(f, s1);
- }