InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf)
- : InsetMathNest(buf, 3), numargs_(0), argsInLook_(0), optionals_(0),
+ : InsetMathNest(buf, 3), look_(buf), numargs_(0), argsInLook_(0), optionals_(0),
type_(MacroTypeNewcommand), redefinition_(false), lookOutdated_(true),
premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0)
{
InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf, docstring const & name, int numargs,
int optionals, MacroType type, vector<MathData> const & optionalValues,
MathData const & def, MathData const & display)
- : InsetMathNest(buf, optionals + 3), numargs_(numargs), argsInLook_(numargs),
- optionals_(optionals), optionalValues_(optionalValues),
+ : InsetMathNest(buf, optionals + 3), look_(buf), numargs_(numargs),
+ argsInLook_(numargs), optionals_(optionals), optionalValues_(optionalValues),
type_(type), redefinition_(false), lookOutdated_(true),
premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0)
{
look_.push_back(MathAtom(
new InsetDisplayLabelBox(buffer_, MathAtom(
new InsetMathWrapper(&cell(displayIdx()))), _("LyX"), *this)));
+
+ look_.setContentsBuffer();
}
{}
+void MathData::setContentsBuffer()
+{
+ if (buffer_)
+ for (MathAtom & at : *this)
+ at.nucleus()->setBuffer(*buffer_);
+}
+
+
void MathData::setBuffer(Buffer & b)
{
buffer_ = &b;
- for (MathAtom & at : *this)
- at.nucleus()->setBuffer(b);
+ setContentsBuffer();
}
{
LBUFERR(pos <= size());
base_type::insert(begin() + pos, t);
+ if (buffer_)
+ operator[](pos)->setBuffer(*buffer_);
}
{
LBUFERR(pos <= size());
base_type::insert(begin() + pos, ar.begin(), ar.end());
+ if (buffer_)
+ for (size_type i = 0 ; i < ar.size() ; ++i)
+ operator[](pos + i)->setBuffer(*buffer_);
+}
+
+
+void MathData::push_back(MathAtom const & t)
+{
+ base_type::push_back(t);
+ if (buffer_)
+ back()->setBuffer(*buffer_);
}
using base_type::clear;
using base_type::begin;
using base_type::end;
- using base_type::push_back;
using base_type::pop_back;
using base_type::back;
using base_type::front;
void insert(size_type pos, MathAtom const & at);
/// inserts multiple atoms at position pos
void insert(size_type pos, MathData const & ar);
+ /// inserts single atom at end
+ void push_back(MathAtom const & at);
/// erase range from pos1 to pos2
void erase(iterator pos1, iterator pos2);
void updateMacros(Cursor * cur, MacroContext const & mc, UpdateType, int nesting);
///
void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false);
- ///
+ /// Change associated buffer for this object and its contents
void setBuffer(Buffer & b);
+ /// Update assiociated buffer for the contents of the object
+ void setContentsBuffer();
protected:
/// cached values for super/subscript placement
bool macro = pf & Parse::MACRODEF;
if ((str.size() == 1 && quiet) || (!mathed_parse_cell(ar, str, pf) && quiet && !macro))
mathed_parse_cell(ar, str, pf | Parse::VERBATIM);
+
+ // set the buffer of the MathData contents
+ ar.setContentsBuffer();
}