Changer chg = make_change(mi.base.macro_nesting,
mathMacro_->nesting() == 1 ? 0 : mathMacro_->nesting());
- MathRow::Element e_beg(MathRow::BEG_ARG);
+ MathRow::Element e_beg(mi, MathRow::BEG_ARG);
e_beg.macro = mathMacro_;
e_beg.ar = &mathMacro_->cell(idx_);
mrow.push_back(e_beg);
// then we insert a box instead.
if (!has_contents && mathMacro_->nesting() == 1) {
// mathclass is ord because it should be spaced as a normal atom
- MathRow::Element e(MathRow::BOX, MC_ORD);
+ MathRow::Element e(mi, MathRow::BOX, MC_ORD);
e.color = Color_mathline;
mrow.push_back(e);
has_contents = true;
}
- MathRow::Element e_end(MathRow::END_ARG);
+ MathRow::Element e_end(mi, MathRow::END_ARG);
e_end.macro = mathMacro_;
e_end.ar = &mathMacro_->cell(idx_);
|| d->editing_[mi.base.bv])
return InsetMath::addToMathRow(mrow, mi);
- MathRow::Element e_beg(MathRow::BEG_MACRO);
+ MathRow::Element e_beg(mi, MathRow::BEG_MACRO);
e_beg.macro = this;
mrow.push_back(e_beg);
// insert a grey box instead.
if (!has_contents && mi.base.macro_nesting == 1) {
// mathclass is unknown because it is irrelevant for spacing
- MathRow::Element e(MathRow::BOX);
+ MathRow::Element e(mi, MathRow::BOX);
e.color = Color_mathmacroblend;
mrow.push_back(e);
has_contents = true;
}
- MathRow::Element e_end(MathRow::END_MACRO);
+ MathRow::Element e_end(mi, MathRow::END_MACRO);
e_end.macro = this;
mrow.push_back(e_end);
namespace lyx {
-MathRow::Element::Element(Type t, MathClass mc)
- : type(t), mclass(mc), before(0), after(0), inset(0),
- compl_unique_to(0), macro(0), color(Color_red)
+MathRow::Element::Element(MetricsInfo const & mi, Type t, MathClass mc)
+ : type(t), mclass(mc), before(0), after(0), macro_nesting(mi.base.macro_nesting),
+ inset(0), compl_unique_to(0), macro(0), color(Color_red)
{}
MathRow::MathRow(MetricsInfo & mi, MathData const * ar)
{
// First there is a dummy element of type "open"
- push_back(Element(DUMMY, MC_OPEN));
+ push_back(Element(mi, DUMMY, MC_OPEN));
// Then insert the MathData argument
bool const has_contents = ar->addToMathRow(*this, mi);
// empty arrays are visible when they are editable
// we reserve the necessary space anyway (even if nothing gets drawn)
if (!has_contents) {
- Element e(BOX, MC_ORD);
+ Element e(mi, BOX, MC_ORD);
e.color = mi.base.macro_nesting == 0 ? Color_mathline : Color_none;
push_back(e);
}
// Finally there is a dummy element of type "close"
- push_back(Element(DUMMY, MC_CLOSE));
+ push_back(Element(mi, DUMMY, MC_CLOSE));
/* Do spacing only in math mode. This test is a bit clumsy,
* but it is used in other places for guessing the current mode.
// arguments, it is necessary to keep track of them.
map<MathMacro const *, Dimension> dim_macros;
map<MathData const *, Dimension> dim_arrays;
- // this vector remembers the stack of macro nesting values
- vector<int> macro_nesting;
- macro_nesting.push_back(mi.base.macro_nesting);
CoordCache & coords = mi.base.bv->coordCache();
for (Element const & e : elements_) {
- mi.base.macro_nesting = macro_nesting.back();
+ mi.base.macro_nesting = e.macro_nesting;
Dimension d;
switch (e.type) {
case DUMMY:
coords.insets().add(e.inset, d);
break;
case BEG_MACRO:
- macro_nesting.push_back(e.macro->nesting());
e.macro->macro()->lock();
// Add a macro to current list
dim_macros[e.macro] = Dimension();
break;
case END_MACRO:
LATTEST(dim_macros.find(e.macro) != dim_macros.end());
- macro_nesting.pop_back();
e.macro->macro()->unlock();
// Cache the dimension of the macro and remove it from
// tracking map.
break;
// This is basically like macros
case BEG_ARG:
- if (e.macro) {
- macro_nesting.push_back(e.macro->nesting());
+ if (e.macro)
e.macro->macro()->unlock();
- }
dim_arrays[e.ar] = Dimension();
break;
case END_ARG:
LATTEST(dim_arrays.find(e.ar) != dim_arrays.end());
- if (e.macro) {
- macro_nesting.pop_back();
+ if (e.macro)
e.macro->macro()->lock();
- }
coords.arrays().add(e.ar, dim_arrays[e.ar]);
dim_arrays.erase(e.ar);
break;