ar->updateMacros(&bv->cursor(), mi.macrocontext,
InternalUpdate, mi.base.macro_nesting);
+ pos_type bspos = -1, espos = -1;
+ Cursor const & cur = bv->cursor();
+ InsetMath const * inset = cur.inset().asInsetMath();
+ if (cur.selection() && inset) {
+ CursorSlice const s1 = cur.selBegin();
+ CursorSlice const s2 = cur.selEnd();
+ // Detect inner selection in this math data.
+ if (s1.idx() == s2.idx() && &inset->cell(s1.idx()) == this) {
+ bspos = s1.pos();
+ espos = s2.pos();
+ }
+ }
// FIXME: for completion, try to insert the relevant data in the
// mathrow (like is done for text rows). We could add a pair of
size_t const compl_pos = has_completion ? inlineCompletionPos.pos() : 0;
for (size_t i = 0 ; i < size() ; ++i) {
+ if (i == bspos)
+ mrow.push_back(MathRow::Element(mi, MathRow::BEGIN_SEL));
has_contents |= (*this)[i]->addToMathRow(mrow, mi);
if (i + 1 == compl_pos) {
mrow.back().compl_text = bv->inlineCompletion();
mrow.back().compl_unique_to = bv->inlineCompletionUniqueChars();
}
+ if (i + 1 == espos)
+ mrow.push_back(MathRow::Element(mi, MathRow::END_SEL));
}
return has_contents;
}
#include "BufferView.h"
#include "ColorSet.h"
#include "CoordCache.h"
+#include "LyXRC.h"
#include "MetricsInfo.h"
#include "mathed/InsetMath.h"
Dimension d;
switch (e.type) {
case DUMMY:
+ case BEGIN_SEL:
+ case END_SEL:
break;
case INSET:
e.inset->metrics(mi, d);
void MathRow::draw(PainterInfo & pi, int x, int const y) const
{
+ Changer change_color;
CoordCache & coords = pi.base.bv->coordCache();
for (Element const & e : elements_) {
switch (e.type) {
e.inset->afterDraw(pi);
x += e.before + e.after;
break;
+ case BEGIN_SEL:
+ if (lyxrc.use_system_colors)
+ change_color = pi.base.font.changeColor(Color_selectiontext);
+ break;
+ case END_SEL:
+ change_color = noChange();
+ break;
case BOX: {
if (e.color == Color_none)
break;
if (e.inset)
os << "]";
break;
+ case MathRow::BEGIN_SEL:
+ os << "<sel>";
+ break;
+ case MathRow::END_SEL:
+ os << "</sel>" ;
+ break;
case MathRow::BOX:
os << "<" << e.before << "-[]-" << e.after << ">";
break;
BOX, // an empty box
BEGIN, // an inset and/or a math array begins here
END, // an inset and/or a math array ends here
+ BEGIN_SEL, // the selection begins here
+ END_SEL, // the selection ends here
DUMMY // a dummy element (used before or after row)
};