// get macro data
MathMacroTemplate & macroTemplate =
static_cast<MathMacroTemplate &>(*iit->inset);
- MacroContext mc(*this, it);
+ MacroContext mc(this, it);
macroTemplate.updateToContext(mc);
// valid?
continue;
// register macro
+ // FIXME (Abdel), I don't understandt why we pass 'it' here
+ // instead of 'macroTemplate' defined above... is this correct?
d->macros[macroTemplate.name()][it] =
- Impl::ScopeMacro(scope, MacroData(*this, it));
+ Impl::ScopeMacro(scope, MacroData(const_cast<Buffer *>(this), it));
}
// next paragraph
// update macro in all cells of the InsetMathNest
DocIterator::idx_type n = minset->nargs();
- MacroContext mc = MacroContext(*this, it);
+ MacroContext mc = MacroContext(this, it);
for (DocIterator::idx_type i = 0; i < n; ++i) {
MathData & data = minset->cell(i);
data.updateMacros(0, mc);
if (in && in->interpretString(*this, s))
return true;
MathAtom atom = buffer()->getMacro(name, *this, false) ?
- MathAtom(new MathMacro(name)) : createInsetMath(name);
+ MathAtom(new MathMacro(buffer(), name)) : createInsetMath(name, buffer());
// try to put argument into macro, if we just inserted a macro
bool macroArg = false;
} else {
// cursor in between. split cell
MathData::iterator bt = cell().begin();
- MathAtom at = createInsetMath(from_utf8(font));
- at.nucleus()->cell(0) = MathData(bt, bt + pos());
+ MathAtom at = createInsetMath(from_utf8(font), buffer());
+ at.nucleus()->cell(0) = MathData(buffer(), bt, bt + pos());
cell().erase(bt, bt + pos());
popBackward();
plainInsert(at);
if (i1.idx() == i2.idx()) {
if (i1.inset().asInsetMath()) {
MathData::const_iterator it = i1.cell().begin();
- return asString(MathData(it + i1.pos(), it + i2.pos()));
+ Buffer * buf = cur.buffer();
+ return asString(MathData(buf, it + i1.pos(), it + i2.pos()));
} else {
return from_ascii("unknown selection 1");
}
#ifdef ENABLE_ASSERTIONS
const int old_pos = cur.pos();
#endif
- cur.insert(new InsetMathHull(hullSimple, cur.buffer()));
+ cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
#ifdef ENABLE_ASSERTIONS
LASSERT(old_pos == cur.pos(), /**/);
#endif
} else
cur.insert(formula);
} else {
- cur.insert(new MathMacroTemplate(sel, cur.buffer()));
+ cur.insert(new MathMacroTemplate(cur.buffer(), sel));
}
}
if (valid)
// It may happen that sel is empty but there is a selection
replaceSelection(cur);
- cur.insert(new InsetMathHull(hullRegexp, cur.buffer()));
+ cur.insert(new InsetMathHull(cur.buffer(), hullRegexp));
cur.nextInset()->edit(cur, true);
cur.niceInsert(sel);
MacroType type = MacroTypeNewcommand;
if (s2 == "def")
type = MacroTypeDef;
- MathMacroTemplate * inset = new MathMacroTemplate(from_utf8(token(s, ' ', 0)), nargs, false, type, cur.buffer());
+ MathMacroTemplate * inset = new MathMacroTemplate(cur.buffer(),
+ from_utf8(token(s, ' ', 0)), nargs, false, type);
inset->setBuffer(bv->buffer());
insertInset(cur, inset);
case LFUN_MATH_BIGDELIM: {
cur.recordUndo();
cap::replaceSelection(cur);
- cur.insert(new InsetMathHull(hullSimple, cur.buffer()));
+ cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
checkAndActivateInset(cur, true);
LASSERT(cur.inMathed(), /**/);
cur.dispatch(cmd);
- right_margin;
Font const & font = ii->inset->noFontChange() ?
bufferfont : displayFont(pit, ii->pos);
- MacroContext mc(buffer, parPos);
+ MacroContext mc(&buffer, parPos);
MetricsInfo mi(bv_, font.fontInfo(), w, mc);
ii->inset->metrics(mi, dim);
Dimension const old_dim = pm.insetDimension(ii->inset);
protected:
/// Constructors
- Inset() : buffer_(0) {}
+ Inset(Buffer * buf = 0) : buffer_(buf) {}
Inset(Inset const &) : buffer_(0) {}
/// replicate ourselves
namespace lyx {
-CommandInset::CommandInset(docstring const & name, bool needs_math_mode)
- : InsetMathNest(2), name_(name), needs_math_mode_(needs_math_mode),
+CommandInset::CommandInset(Buffer * buf, docstring const & name, bool needs_math_mode)
+ : InsetMathNest(buf, 2), name_(name), needs_math_mode_(needs_math_mode),
set_label_(false)
{
lock_ = true;
class CommandInset : public InsetMathNest {
public:
///
- explicit CommandInset(docstring const & name, bool needs_math_mode = true);
+ explicit CommandInset(Buffer * buf, docstring const & name,
+ bool needs_math_mode = true);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
class InsetFormulaMacro : public InsetMathNest {
public:
///
- InsetFormulaMacro();
+ InsetFormulaMacro(Buffer * buf);
/// construct a macro hull from its name and the number of arguments
- InsetFormulaMacro(docstring const & name, int nargs, docstring const & t);
+ InsetFormulaMacro(Buffer * buf, docstring const & name, int nargs, docstring const & t);
/// constructs a mocro from its LaTeX definition
explicit InsetFormulaMacro(docstring const & s);
///
MathData & InsetMath::cell(idx_type)
{
- static MathData dummyCell;
+ static MathData dummyCell(&buffer());
LYXERR0("I don't have any cell");
return dummyCell;
}
class InsetMath : public Inset {
public:
+ ///
+ InsetMath(Buffer * buf = 0) : Inset(buf) {}
/// identification as math inset
InsetMath * asInsetMath() { return this; }
/// identification as math inset
using support::bformat;
-InsetMathAMSArray::InsetMathAMSArray(docstring const & name, int m, int n)
- : InsetMathGrid(m, n), name_(name)
+InsetMathAMSArray::InsetMathAMSArray(Buffer * buf, docstring const & name,
+ int m, int n)
+ : InsetMathGrid(buf, m, n), name_(name)
{}
-InsetMathAMSArray::InsetMathAMSArray(docstring const & name)
- : InsetMathGrid(1, 1), name_(name)
+InsetMathAMSArray::InsetMathAMSArray(Buffer * buf, docstring const & name)
+ : InsetMathGrid(buf, 1, 1), name_(name)
{}
class InsetMathAMSArray : public InsetMathGrid {
public:
///
- InsetMathAMSArray(docstring const &, int m, int n);
+ InsetMathAMSArray(Buffer * buf, docstring const &, int m, int n);
///
- InsetMathAMSArray(docstring const &);
+ InsetMathAMSArray(Buffer * buf, docstring const &);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathArray::InsetMathArray(docstring const & name, int m, int n)
- : InsetMathGrid(m, n), name_(name)
+InsetMathArray::InsetMathArray(Buffer * buf, docstring const & name, int m,
+ int n)
+ : InsetMathGrid(buf, m, n), name_(name)
{}
-InsetMathArray::InsetMathArray(docstring const & name, int m, int n,
- char valign, docstring const & halign)
- : InsetMathGrid(m, n, valign, halign), name_(name)
+InsetMathArray::InsetMathArray(Buffer * buf, docstring const & name, int m,
+ int n, char valign, docstring const & halign)
+ : InsetMathGrid(buf, m, n, valign, halign), name_(name)
{}
-InsetMathArray::InsetMathArray(docstring const & name, docstring const & str)
- : InsetMathGrid(1, 1), name_(name)
+InsetMathArray::InsetMathArray(Buffer * buf, docstring const & name,
+ docstring const & str)
+ : InsetMathGrid(buf, 1, 1), name_(name)
{
vector< vector<string> > dat;
istringstream is(to_utf8(str));
for (row_type row = 0; row < dat.size(); ++row)
for (col_type col = 0; col < dat[0].size(); ++col)
mathed_parse_cell(cell(index(row, col)),
- from_utf8(dat[row][col]),
- Parse::NORMAL, &buffer());
+ from_utf8(dat[row][col]), Parse::NORMAL);
}
class InsetMathArray : public InsetMathGrid {
public:
///
- InsetMathArray(docstring const &, int m, int n);
+ InsetMathArray(Buffer * buf, docstring const &, int m, int n);
///
- InsetMathArray(docstring const &, int m, int n,
+ InsetMathArray(Buffer * buf, docstring const &, int m, int n,
char valign, docstring const & halign);
/// convenience constructor from whitespace/newline separated data
- InsetMathArray(docstring const &, docstring const & str);
+ InsetMathArray(Buffer * buf, docstring const &, docstring const & str);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathBoldSymbol::InsetMathBoldSymbol(Kind kind)
- : InsetMathNest(1), kind_(kind)
+InsetMathBoldSymbol::InsetMathBoldSymbol(Buffer * buf, Kind kind)
+ : InsetMathNest(buf, 1), kind_(kind)
{}
BM_HEAVY
};
///
- InsetMathBoldSymbol(Kind kind = AMS_BOLD);
+ InsetMathBoldSymbol(Buffer * buf, Kind kind = AMS_BOLD);
///
docstring name() const;
///
//
/////////////////////////////////////////////////////////////////////
-InsetMathBox::InsetMathBox(docstring const & name)
- : InsetMathNest(1), name_(name)
+InsetMathBox::InsetMathBox(Buffer * buf, docstring const & name)
+ : InsetMathNest(buf, 1), name_(name)
{}
/////////////////////////////////////////////////////////////////////
-InsetMathFBox::InsetMathFBox()
- : InsetMathNest(1)
+InsetMathFBox::InsetMathFBox(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
/////////////////////////////////////////////////////////////////////
-InsetMathMakebox::InsetMathMakebox(bool framebox)
- : InsetMathNest(3), framebox_(framebox)
+InsetMathMakebox::InsetMathMakebox(Buffer * buf, bool framebox)
+ : InsetMathNest(buf, 3), framebox_(framebox)
{}
//
/////////////////////////////////////////////////////////////////////
-InsetMathBoxed::InsetMathBoxed()
- : InsetMathNest(1)
+InsetMathBoxed::InsetMathBoxed(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
class InsetMathBox : public InsetMathNest {
public:
///
- explicit InsetMathBox(docstring const & name);
+ explicit InsetMathBox(Buffer * buf, docstring const & name);
///
mode_type currentMode() const { return TEXT_MODE; }
///
class InsetMathFBox : public InsetMathNest {
public:
///
- InsetMathFBox();
+ InsetMathFBox(Buffer * buf);
///
mode_type currentMode() const { return TEXT_MODE; }
///
class InsetMathMakebox : public InsetMathNest {
public:
///
- InsetMathMakebox(bool framebox);
+ InsetMathMakebox(Buffer * buf, bool framebox);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
class InsetMathBoxed : public InsetMathNest {
public:
///
- InsetMathBoxed();
+ InsetMathBoxed(Buffer * buf);
///
void validate(LaTeXFeatures & features) const;
///
namespace lyx {
-InsetMathBrace::InsetMathBrace()
- : InsetMathNest(1)
+InsetMathBrace::InsetMathBrace(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
InsetMathBrace::InsetMathBrace(MathData const & ar)
- : InsetMathNest(1)
+ : InsetMathNest(const_cast<Buffer *>(ar.buffer()), 1)
{
cell(0) = ar;
}
class InsetMathBrace : public InsetMathNest {
public:
///
- InsetMathBrace();
+ InsetMathBrace(Buffer * buf);
///
InsetMathBrace(MathData const & ar);
/// identifies brace insets
namespace lyx {
-InsetMathCases::InsetMathCases(row_type n)
- : InsetMathGrid(2, n, 'c', from_ascii("ll"))
+InsetMathCases::InsetMathCases(Buffer * buf, row_type n)
+ : InsetMathGrid(buf, 2, n, 'c', from_ascii("ll"))
{}
class InsetMathCases : public InsetMathGrid {
public:
///
- explicit InsetMathCases(row_type rows = 1u);
+ explicit InsetMathCases(Buffer * buf, row_type rows = 1u);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathColor::InsetMathColor(bool oldstyle, ColorCode color)
- : InsetMathNest(1), oldstyle_(oldstyle),
+InsetMathColor::InsetMathColor(Buffer * buf, bool oldstyle, ColorCode color)
+ : InsetMathNest(buf, 1), oldstyle_(oldstyle),
color_(from_utf8(lcolor.getLaTeXName(color)))
{}
-InsetMathColor::InsetMathColor(bool oldstyle, docstring const & color)
- : InsetMathNest(1), oldstyle_(oldstyle), color_(color)
+InsetMathColor::InsetMathColor(Buffer * buf, bool oldstyle,
+ docstring const & color)
+ : InsetMathNest(buf, 1), oldstyle_(oldstyle), color_(color)
{}
class InsetMathColor : public InsetMathNest {
public:
/// Create a color inset from LyX color number
- explicit InsetMathColor(bool oldstyle,
- ColorCode color = Color_none);
+ InsetMathColor(Buffer * buf, bool oldstyle, ColorCode color = Color_none);
/// Create a color inset from LaTeX color name
- explicit InsetMathColor(bool oldstyle, docstring const & color);
+ InsetMathColor(Buffer * buf, bool oldstyle, docstring const & color);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
/// we write extra braces in any case...
namespace lyx {
-InsetMathComment::InsetMathComment()
- : InsetMathNest(1)
+InsetMathComment::InsetMathComment(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
-InsetMathComment::InsetMathComment(docstring const & str)
- : InsetMathNest(1)
+InsetMathComment::InsetMathComment(Buffer * buf, docstring const & str)
+ : InsetMathNest(buf, 1)
{
// FIXME UNICODE
asArray(str, cell(0));
class InsetMathComment : public InsetMathNest {
public:
///
- InsetMathComment();
+ InsetMathComment(Buffer * buf);
///
- explicit InsetMathComment(docstring const &);
+ explicit InsetMathComment(Buffer * buf, docstring const &);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathDecoration::InsetMathDecoration(latexkeys const * key)
- : InsetMathNest(1), key_(key)
+InsetMathDecoration::InsetMathDecoration(Buffer * buf, latexkeys const * key)
+ : InsetMathNest(buf, 1), key_(key)
{
// lyxerr << " creating deco " << key->name << endl;
}
class InsetMathDecoration : public InsetMathNest {
public:
///
- explicit InsetMathDecoration(latexkeys const * key);
+ explicit InsetMathDecoration(Buffer * buf, latexkeys const * key);
///
void draw(PainterInfo &, int x, int y) const;
///
}
-InsetMathDelim::InsetMathDelim(docstring const & l, docstring const & r)
- : InsetMathNest(1), left_(l), right_(r)
+InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l,
+ docstring const & r)
+ : InsetMathNest(buf, 1), left_(l), right_(r)
{}
-InsetMathDelim::InsetMathDelim
- (docstring const & l, docstring const & r, MathData const & ar)
- : InsetMathNest(1), left_(l), right_(r)
+InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l, docstring const & r,
+ MathData const & ar)
+ : InsetMathNest(buf, 1), left_(l), right_(r)
{
cell(0) = ar;
}
class InsetMathDelim : public InsetMathNest {
public:
///
- InsetMathDelim(docstring const & left, docstring const & right);
+ InsetMathDelim(Buffer * buf, docstring const & left, docstring const & right);
///
- InsetMathDelim(docstring const & left, docstring const & right, MathData const &);
+ InsetMathDelim(Buffer * buf, docstring const & left, docstring const & right,
+ MathData const &);
///
InsetMathDelim * asDelimInset() { return this; }
///
namespace lyx {
-InsetMathDiff::InsetMathDiff()
- : InsetMathNest(1)
+InsetMathDiff::InsetMathDiff(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
class InsetMathDiff : public InsetMathNest {
public:
///
- InsetMathDiff();
+ InsetMathDiff(Buffer * buf);
///
void addDer(MathData const & der);
///
namespace lyx {
-InsetMathEnsureMath::InsetMathEnsureMath()
- : InsetMathNest(1)
+InsetMathEnsureMath::InsetMathEnsureMath(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
/// Inset for ensuring math mode
class InsetMathEnsureMath : public InsetMathNest {
public:
- InsetMathEnsureMath();
+ InsetMathEnsureMath(Buffer * buf);
///
mode_type currentMode() const { return MATH_MODE; }
///
namespace lyx {
-InsetMathEnv::InsetMathEnv(docstring const & name)
- : InsetMathNest(1), name_(name)
+InsetMathEnv::InsetMathEnv(Buffer * buf, docstring const & name)
+ : InsetMathNest(buf, 1), name_(name)
{}
class InsetMathEnv : public InsetMathNest {
public:
///
- InsetMathEnv(docstring const & name_);
+ InsetMathEnv(Buffer * buf, docstring const & name_);
///
void draw(PainterInfo &, int x, int y) const;
///
namespace lyx {
-InsetMathExFunc::InsetMathExFunc(docstring const & name)
- : InsetMathNest(1), name_(name)
+InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name)
+ : InsetMathNest(buf, 1), name_(name)
{}
-InsetMathExFunc::InsetMathExFunc(docstring const & name, MathData const & ar)
- : InsetMathNest(1), name_(name)
+InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name, MathData const & ar)
+ : InsetMathNest(buf, 1), name_(name)
{
cell(0) = ar;
}
class InsetMathExFunc : public InsetMathNest {
public:
///
- explicit InsetMathExFunc(docstring const & name);
+ InsetMathExFunc(Buffer * buf, docstring const & name);
///
- InsetMathExFunc(docstring const & name, MathData const & ar);
+ InsetMathExFunc(Buffer * buf, docstring const & name, MathData const & ar);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathExInt::InsetMathExInt(docstring const & name)
- : InsetMathNest(4), symbol_(name)
+InsetMathExInt::InsetMathExInt(Buffer * buf, docstring const & name)
+ : InsetMathNest(buf, 4), symbol_(name)
{}
// 0 - core
class InsetMathExInt : public InsetMathNest {
public:
///
- explicit InsetMathExInt(docstring const & name_);
+ explicit InsetMathExInt(Buffer * buf, docstring const & name_);
///
void symbol(docstring const &);
///
namespace lyx {
-InsetMathFont::InsetMathFont(latexkeys const * key)
- : InsetMathNest(1), key_(key)
+InsetMathFont::InsetMathFont(Buffer * buf, latexkeys const * key)
+ : InsetMathNest(buf, 1), key_(key)
{}
class InsetMathFont : public InsetMathNest {
public:
///
- explicit InsetMathFont(latexkeys const * key);
+ explicit InsetMathFont(Buffer * buf, latexkeys const * key);
///
InsetMathFont * asFontInset() { return this; }
///
namespace lyx {
-InsetMathFontOld::InsetMathFontOld(latexkeys const * key)
- : InsetMathNest(1), key_(key)
+InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key)
+ : InsetMathNest(buf, 1), key_(key)
{
//lock(true);
}
class InsetMathFontOld : public InsetMathNest {
public:
///
- explicit InsetMathFontOld(latexkeys const * key);
+ explicit InsetMathFontOld(Buffer * buf, latexkeys const * key);
/// we are in text mode.
mode_type currentMode() const { return TEXT_MODE; }
/// we write extra braces in any case...
/////////////////////////////////////////////////////////////////////
-InsetMathFracBase::InsetMathFracBase(idx_type ncells)
- : InsetMathNest(ncells)
+InsetMathFracBase::InsetMathFracBase(Buffer * buf, idx_type ncells)
+ : InsetMathNest(buf, ncells)
{}
/////////////////////////////////////////////////////////////////////
-InsetMathFrac::InsetMathFrac(Kind kind, InsetMath::idx_type ncells)
- : InsetMathFracBase(ncells), kind_(kind)
+InsetMathFrac::InsetMathFrac(Buffer * buf, Kind kind, InsetMath::idx_type ncells)
+ : InsetMathFracBase(buf, ncells), kind_(kind)
{}
/////////////////////////////////////////////////////////////////////
-InsetMathBinom::InsetMathBinom(Kind kind)
- : kind_(kind)
+InsetMathBinom::InsetMathBinom(Buffer * buf, Kind kind)
+ : InsetMathFracBase(buf), kind_(kind)
{}
class InsetMathFracBase : public InsetMathNest {
public:
///
- explicit InsetMathFracBase(idx_type ncells = 2);
+ InsetMathFracBase(Buffer * buf, idx_type ncells = 2);
///
bool idxUpDown(Cursor &, bool up) const;
///
UNIT
};
///
- explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
+ explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
///
bool idxForward(Cursor &) const;
///
BRACK
};
///
- explicit InsetMathBinom(Kind kind = BINOM);
+ explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
///
void write(WriteStream & os) const;
///
//////////////////////////////////////////////////////////////
-InsetMathGrid::InsetMathGrid()
- : InsetMathNest(1),
+InsetMathGrid::InsetMathGrid(Buffer * buf)
+ : InsetMathNest(buf, 1),
rowinfo_(1 + 1),
colinfo_(1 + 1),
cellinfo_(1),
}
-InsetMathGrid::InsetMathGrid(col_type m, row_type n)
- : InsetMathNest(m * n),
+InsetMathGrid::InsetMathGrid(Buffer * buf, col_type m, row_type n)
+ : InsetMathNest(buf, m * n),
rowinfo_(n + 1),
colinfo_(m + 1),
cellinfo_(m * n),
}
-InsetMathGrid::InsetMathGrid(col_type m, row_type n, char v, docstring const & h)
- : InsetMathNest(m * n),
+InsetMathGrid::InsetMathGrid(Buffer * buf, col_type m, row_type n, char v,
+ docstring const & h)
+ : InsetMathNest(buf, m * n),
rowinfo_(n + 1),
colinfo_(m + 1),
cellinfo_(m * n),
is >> n;
topaste = cap::selection(n);
}
- InsetMathGrid grid(1, 1);
+ InsetMathGrid grid(buffer_, 1, 1);
if (!topaste.empty())
if ((topaste.size() == 1 && topaste.at(0) < 0x80)
- || !mathed_parse_normal(grid, topaste, parseflg,
- cur.buffer())) {
+ || !mathed_parse_normal(grid, topaste, parseflg)) {
resetGrid(grid);
- mathed_parse_normal(grid, topaste,
- parseflg | Parse::VERBATIM,
- cur.buffer());
+ mathed_parse_normal(grid, topaste, parseflg | Parse::VERBATIM);
}
if (grid.nargs() == 1) {
public:
/// sets nrows and ncols to 1, vertical alingment to 'c'
- InsetMathGrid();
+ InsetMathGrid(Buffer * buf);
/// Note: columns first!
- InsetMathGrid(col_type m, row_type n);
+ InsetMathGrid(Buffer * buf, col_type m, row_type n);
///
- InsetMathGrid(col_type m, row_type n, char valign, docstring const & halign);
+ InsetMathGrid(Buffer * buf, col_type m, row_type n, char valign,
+ docstring const & halign);
///
void metrics(MetricsInfo & mi, Dimension &) const;
///
static InsetLabel * dummy_pointer = 0;
InsetMathHull::InsetMathHull(Buffer * buf)
- : InsetMathGrid(1, 1), type_(hullNone), nonum_(1, false),
+ : InsetMathGrid(buf, 1, 1), type_(hullNone), nonum_(1, false),
label_(1, dummy_pointer), preview_(new RenderPreview(this))
{
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
}
-InsetMathHull::InsetMathHull(HullType type, Buffer * buf)
- : InsetMathGrid(getCols(type), 1), type_(type), nonum_(1, false),
+InsetMathHull::InsetMathHull(Buffer * buf, HullType type)
+ : InsetMathGrid(buf, getCols(type), 1), type_(type), nonum_(1, false),
label_(1, dummy_pointer), preview_(new RenderPreview(this))
{
buffer_ = buf;
}
-InsetMathHull::InsetMathHull(InsetMathHull const & other) : InsetMathGrid()
+InsetMathHull::InsetMathHull(InsetMathHull const & other) : InsetMathGrid(other)
{
operator=(other);
}
MathData ar;
for (idx_type i = 0; i < nargs(); ++i)
ar.append(cell(i));
- *this = InsetMathHull(hullSimple, &buffer());
+ *this = InsetMathHull(buffer_, hullSimple);
cell(0) = ar;
setDefaults();
}
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 2 * row;
pos_type pos = firstRelOp(cell(i));
- cell(i + 1) = MathData(cell(i).begin() + pos, cell(i).end());
+ cell(i + 1) = MathData(buffer_, cell(i).begin() + pos, cell(i).end());
cell(i).erase(pos, cell(i).size());
}
}
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 3 * row + 1;
if (cell(i).size()) {
- cell(i + 1) = MathData(cell(i).begin() + 1, cell(i).end());
+ cell(i + 1) = MathData(buffer_, cell(i).begin() + 1, cell(i).end());
cell(i).erase(1, cell(i).size());
}
}
ar = cur.cell();
lyxerr << "use whole cell: " << ar << endl;
} else {
- ar = MathData(cur.cell().begin() + pos + 1, cur.cell().end());
+ ar = MathData(buffer_, cur.cell().begin() + pos + 1, cur.cell().end());
lyxerr << "use partial cell form pos: " << pos << endl;
}
cur.cell().append(eq);
if (cur.inset().asInsetMath()->name() == font)
cur.handleFont(to_utf8(font));
else {
- cur.handleNest(createInsetMath(font));
+ cur.handleNest(createInsetMath(font, cur.buffer()));
cur.insert(arg);
}
}
bool b;
font.fromString(to_utf8(arg), b);
if (font.fontInfo().color() != Color_inherit) {
- MathAtom at = MathAtom(new InsetMathColor(true, font.fontInfo().color()));
+ MathAtom at = MathAtom(new InsetMathColor(buffer_, true, font.fontInfo().color()));
cur.handleNest(at, 0);
}
}
void InsetMathHull::read(Lexer & lex)
{
MathAtom at;
- mathed_parse_normal(at, lex, Parse::NORMAL, &buffer());
+ mathed_parse_normal(buffer_, at, lex, Parse::NORMAL);
operator=(*at->asHullInset());
}
bool InsetMathHull::readQuiet(Lexer & lex)
{
MathAtom at;
- bool success = mathed_parse_normal(at, lex, Parse::QUIET, &buffer());
+ bool success = mathed_parse_normal(buffer_, at, lex, Parse::QUIET);
if (success)
operator=(*at->asHullInset());
return success;
class InsetMathHull : public InsetMathGrid {
public:
///
- InsetMathHull(Buffer * buf = 0);
+ InsetMathHull(Buffer * buf);
///
- explicit InsetMathHull(HullType type, Buffer * buf = 0);
+ InsetMathHull(Buffer * buf, HullType type);
///
~InsetMathHull();
///
namespace lyx {
-InsetMathLefteqn::InsetMathLefteqn()
- : InsetMathNest(1)
+InsetMathLefteqn::InsetMathLefteqn(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
class InsetMathLefteqn : public InsetMathNest {
public:
///
- InsetMathLefteqn();
+ InsetMathLefteqn(Buffer * buf);
///
docstring name() const;
///
namespace lyx {
-InsetMathLim::InsetMathLim
- (MathData const & f, MathData const & x, MathData const & x0)
- : InsetMathNest(3)
+InsetMathLim::InsetMathLim(Buffer * buf, MathData const & f, MathData const & x,
+ MathData const & x0)
+ : InsetMathNest(buf, 3)
{
cell(0) = f;
cell(1) = x;
class InsetMathLim : public InsetMathNest {
public:
///
- InsetMathLim(MathData const & f, MathData const & x, MathData const & x0);
+ InsetMathLim(Buffer * buf, MathData const & f, MathData const & x,
+ MathData const & x0);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
explicit InsetMathMatrix(InsetMathGrid const &);
///
- explicit InsetMathMatrix(docstring const & str);
+ explicit InsetMathMatrix(Buffer * buf, docstring const & str);
/// identifies MatrixInsets
InsetMathMatrix const * asMatrixInset() const { return this; }
using cap::selClearOrDel;
-InsetMathNest::InsetMathNest(idx_type nargs)
- : cells_(nargs), lock_(false), mouse_hover_(false)
-{}
+InsetMathNest::InsetMathNest(Buffer * buf, idx_type nargs)
+ : InsetMath(buf), cells_(nargs), lock_(false), mouse_hover_(false)
+{
+ setBuffer(*buf);
+}
InsetMathNest::InsetMathNest(InsetMathNest const & inset)
if (cur.inset().asInsetMath()->name() == font)
cur.handleFont(to_utf8(font));
else
- handleNest(cur, createInsetMath(font), arg);
+ handleNest(cur, createInsetMath(font, cur.buffer()), arg);
}
font.fromString(to_utf8(arg), b);
if (font.fontInfo().color() != Color_inherit &&
font.fontInfo().color() != Color_ignore)
- handleNest(cur, MathAtom(new InsetMathColor(true, font.fontInfo().color())));
+ handleNest(cur, MathAtom(new InsetMathColor(buffer_, true, font.fontInfo().color())));
// FIXME: support other font changes here as well?
}
case LFUN_FONT_UNDERLINE:
cur.recordUndo();
- cur.handleNest(createInsetMath("underline"));
+ cur.handleNest(createInsetMath("underline", cur.buffer()));
break;
case LFUN_MATH_MODE: {
#if 1
selClearOrDel(cur);
//cur.plainInsert(MathAtom(new InsetMathMBox(cur.bv())));
if (currentMode() <= Inset::TEXT_MODE)
- cur.plainInsert(MathAtom(new InsetMathEnsureMath));
+ cur.plainInsert(MathAtom(new InsetMathEnsureMath(buffer_)));
else
- cur.plainInsert(MathAtom(new InsetMathBox(from_ascii("mbox"))));
+ cur.plainInsert(MathAtom(new InsetMathBox(buffer_, from_ascii("mbox"))));
cur.posBackward();
cur.pushBackward(*cur.nextInset());
cur.niceInsert(save_selection);
cur.macroModeClose();
docstring const save_selection = grabAndEraseSelection(cur);
selClearOrDel(cur);
- cur.plainInsert(MathAtom(new InsetMathHull(hullRegexp, cur.buffer())));
+ cur.plainInsert(MathAtom(new InsetMathHull(buffer_, hullRegexp)));
cur.posBackward();
cur.pushBackward(*cur.nextInset());
cur.niceInsert(save_selection);
if (n < 1)
n = 1;
v_align += 'c';
- cur.niceInsert(
- MathAtom(new InsetMathArray(from_ascii("array"), m, n, (char)v_align[0], h_align)));
+ cur.niceInsert(MathAtom(new InsetMathArray(buffer_,
+ from_ascii("array"), m, n, (char)v_align[0], h_align)));
break;
}
if (n < 1)
n = 1;
cur.niceInsert(
- MathAtom(new InsetMathAMSArray(name, m, n)));
+ MathAtom(new InsetMathAMSArray(buffer_, name, m, n)));
break;
}
if (rs.empty())
rs = ')';
cur.recordUndo();
- cur.handleNest(MathAtom(new InsetMathDelim(ls, rs)));
+ cur.handleNest(MathAtom(new InsetMathDelim(buffer_, ls, rs)));
break;
}
docstring const & name = cmd.argument();
string data;
if (name == "ref") {
- InsetMathRef tmp(name);
+ InsetMathRef tmp(buffer_, name);
data = tmp.createDialogStr(to_utf8(name));
} else if (name == "mathspace") {
InsetMathSpace tmp;
save_selection = grabAndEraseSelection(cur);
cur.clearTargetX();
+ Buffer * buf = cur.buffer();
// handle macroMode
if (cur.inMacroMode()) {
if (c == '\\') {
cur.backspace();
if (currentMode() <= InsetMath::TEXT_MODE)
- cur.niceInsert(createInsetMath("textbackslash"));
+ cur.niceInsert(createInsetMath("textbackslash", buf));
else
- cur.niceInsert(createInsetMath("backslash"));
+ cur.niceInsert(createInsetMath("backslash", buf));
} else if (c == '^' && currentMode() == InsetMath::MATH_MODE) {
cur.backspace();
- cur.niceInsert(createInsetMath("mathcircumflex"));
+ cur.niceInsert(createInsetMath("mathcircumflex", buf));
} else if (c == '{') {
cur.backspace();
- cur.niceInsert(MathAtom(new InsetMathBrace));
+ cur.niceInsert(MathAtom(new InsetMathBrace(buf)));
} else if (c == '%') {
cur.backspace();
- cur.niceInsert(MathAtom(new InsetMathComment));
+ cur.niceInsert(MathAtom(new InsetMathComment(buf)));
} else if (c == '#') {
LASSERT(cur.activeMacro(), /**/);
cur.activeMacro()->setName(name + docstring(1, c));
} else {
cur.backspace();
- cur.niceInsert(createInsetMath(docstring(1, c)));
+ cur.niceInsert(createInsetMath(docstring(1, c), buf));
}
return true;
}
}
}
if (c == '{')
- cur.niceInsert(MathAtom(new InsetMathBrace));
+ cur.niceInsert(MathAtom(new InsetMathBrace(buf)));
else if (c != ' ')
interpretChar(cur, c);
return true;
return true;
}
if (c == '~') {
- cur.niceInsert(createInsetMath("sim"));
+ cur.niceInsert(createInsetMath("sim", buf));
return true;
}
if (currentMode() == InsetMath::MATH_MODE && !isAsciiOrMathAlpha(c)) {
- MathAtom at = createInsetMath("text");
+ MathAtom at = createInsetMath("text", buf);
at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
cur.niceInsert(at);
cur.posForward();
}
} else {
if (c == '^') {
- cur.niceInsert(createInsetMath("textasciicircum"));
+ cur.niceInsert(createInsetMath("textasciicircum", buf));
return true;
}
if (c == '~') {
- cur.niceInsert(createInsetMath("textasciitilde"));
+ cur.niceInsert(createInsetMath("textasciitilde", buf));
return true;
}
}
if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' ||
c == '%' || c == '_') {
- cur.niceInsert(createInsetMath(docstring(1, c)));
+ cur.niceInsert(createInsetMath(docstring(1, c), buf));
return true;
}
//lyxerr << "handling script: up: " << up << endl;
if (cur.inMacroMode() && cur.macroName() == "\\") {
if (up)
- cur.niceInsert(createInsetMath("mathcircumflex"));
+ cur.niceInsert(createInsetMath("mathcircumflex", cur.buffer()));
else
interpretChar(cur, '_');
return true;
// one if in the very first position of the array
if (cur.pos() == 0) {
//lyxerr << "new scriptinset" << endl;
- cur.insert(new InsetMathScript(up));
+ cur.insert(new InsetMathScript(buffer_, up));
} else {
//lyxerr << "converting prev atom " << endl;
- cur.prevAtom() = MathAtom(new InsetMathScript(cur.prevAtom(), up));
+ cur.prevAtom() = MathAtom(new InsetMathScript(buffer_, cur.prevAtom(), up));
}
--cur.pos();
InsetMathScript * inset = cur.nextAtom().nucleus()->asScriptInset();
class InsetMathNest : public InsetMath {
public:
/// nestinsets have a fixed size to start with
- explicit InsetMathNest(idx_type ncells);
+ InsetMathNest(Buffer * buf, idx_type ncells);
///
virtual ~InsetMathNest() {}
///
/// Inset for overset
class InsetMathOverset : public InsetMathFracBase {
public:
+ ///
+ InsetMathOverset(Buffer * buf) : InsetMathFracBase(buf) {}
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathPar::InsetMathPar(MathData const & ar)
+InsetMathPar::InsetMathPar(Buffer * buf, MathData const & ar)
+ : InsetMathHull(buf)
{
cells_[0] = ar;
}
class InsetMathPar : public InsetMathHull {
public:
///
- InsetMathPar() {}
+ InsetMathPar(Buffer * buf) : InsetMathHull(buf) {}
///
- InsetMathPar(MathData const & ar);
+ InsetMathPar(Buffer * buf, MathData const & ar);
///
mode_type currentMode() const { return TEXT_MODE; }
///
namespace lyx {
-InsetMathPhantom::InsetMathPhantom(Kind k)
- : InsetMathNest(1), kind_(k)
+InsetMathPhantom::InsetMathPhantom(Buffer * buf, Kind k)
+ : InsetMathNest(buf, 1), kind_(k)
{}
hphantom
};
///
- explicit InsetMathPhantom(Kind);
+ explicit InsetMathPhantom(Buffer * buf, Kind);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathRef::InsetMathRef()
- : CommandInset(from_ascii("ref"), false)
+InsetMathRef::InsetMathRef(Buffer * buf)
+ : CommandInset(buf, from_ascii("ref"), false)
{}
-InsetMathRef::InsetMathRef(docstring const & data)
- : CommandInset(data, false)
+InsetMathRef::InsetMathRef(Buffer * buf, docstring const & data)
+ : CommandInset(buf, data, false)
{}
class InsetMathRef : public CommandInset {
public:
///
- InsetMathRef();
+ InsetMathRef(Buffer * buf);
///
- explicit InsetMathRef(docstring const & data);
+ explicit InsetMathRef(Buffer * buf, docstring const & data);
///
//void write(WriteStream & os) const;
///
namespace lyx {
-InsetMathRoot::InsetMathRoot()
- : InsetMathNest(2)
+InsetMathRoot::InsetMathRoot(Buffer * buf)
+ : InsetMathNest(buf, 2)
{}
class InsetMathRoot : public InsetMathNest {
public:
///
- InsetMathRoot();
+ InsetMathRoot(Buffer * buf);
///
bool idxUpDown(Cursor & cur, bool up) const;
///
namespace lyx {
-InsetMathScript::InsetMathScript()
- : InsetMathNest(1), cell_1_is_up_(false), limits_(0)
+InsetMathScript::InsetMathScript(Buffer * buf)
+ : InsetMathNest(buf, 1), cell_1_is_up_(false), limits_(0)
{}
-InsetMathScript::InsetMathScript(bool up)
- : InsetMathNest(2), cell_1_is_up_(up), limits_(0)
+InsetMathScript::InsetMathScript(Buffer * buf, bool up)
+ : InsetMathNest(buf, 2), cell_1_is_up_(up), limits_(0)
{}
-InsetMathScript::InsetMathScript(MathAtom const & at, bool up)
- : InsetMathNest(2), cell_1_is_up_(up), limits_(0)
+InsetMathScript::InsetMathScript(Buffer * buf, MathAtom const & at, bool up)
+ : InsetMathNest(buf, 2), cell_1_is_up_(up), limits_(0)
{
LASSERT(nargs() >= 1, /**/);
cell(0).push_back(at);
class InsetMathScript : public InsetMathNest {
public:
/// create inset without scripts
- InsetMathScript();
+ InsetMathScript(Buffer * buf);
/// create inset with single script
- explicit InsetMathScript(bool up);
+ explicit InsetMathScript(Buffer * buf, bool up);
/// create inset with single script and given nucleus
- InsetMathScript(MathAtom const & at, bool up);
+ InsetMathScript(Buffer * buf, MathAtom const & at, bool up);
///
mode_type currentMode() const { return MATH_MODE; }
///
namespace lyx {
-InsetMathSize::InsetMathSize(latexkeys const * l)
- : InsetMathNest(1), key_(l), style_(Styles(convert<int>(l->extra)))
+InsetMathSize::InsetMathSize(Buffer * buf, latexkeys const * l)
+ : InsetMathNest(buf, 1), key_(l), style_(Styles(convert<int>(l->extra)))
{}
class InsetMathSize : public InsetMathNest {
public:
///
- explicit InsetMathSize(latexkeys const * l);
+ explicit InsetMathSize(Buffer * buf, latexkeys const * l);
/// we write extra braces in any case...
bool extraBraces() const { return true; }
///
using support::bformat;
-InsetMathSplit::InsetMathSplit(docstring const & name, char valign)
- : InsetMathGrid(1, 1, valign, docstring()), name_(name)
+InsetMathSplit::InsetMathSplit(Buffer * buf, docstring const & name,
+ char valign)
+ : InsetMathGrid(buf, 1, 1, valign, docstring()), name_(name)
{
}
class InsetMathSplit : public InsetMathGrid {
public:
///
- explicit InsetMathSplit(docstring const & name, char valign = 'c');
+ explicit InsetMathSplit(Buffer * buf, docstring const & name,
+ char valign = 'c');
///
void draw(PainterInfo & pi, int x, int y) const;
///
namespace lyx {
-InsetMathSqrt::InsetMathSqrt()
- : InsetMathNest(1)
+InsetMathSqrt::InsetMathSqrt(Buffer * buf)
+ : InsetMathNest(buf, 1)
{}
class InsetMathSqrt : public InsetMathNest {
public:
///
- InsetMathSqrt();
+ InsetMathSqrt(Buffer * buf);
///
void draw(PainterInfo &, int x, int y) const;
///
namespace lyx {
-InsetMathStackrel::InsetMathStackrel()
+InsetMathStackrel::InsetMathStackrel(Buffer * buf) : InsetMathFracBase(buf)
{}
class InsetMathStackrel : public InsetMathFracBase {
public:
///
- InsetMathStackrel();
+ InsetMathStackrel(Buffer * buf);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
using support::bformat;
-InsetMathSubstack::InsetMathSubstack()
- : InsetMathGrid(1, 1)
+InsetMathSubstack::InsetMathSubstack(Buffer * buf)
+ : InsetMathGrid(buf, 1, 1)
{}
class InsetMathSubstack : public InsetMathGrid {
public:
///
- InsetMathSubstack();
+ InsetMathSubstack(Buffer * buf);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n)
- : InsetMathGrid(m, n), name_(name)
+InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
+ int n)
+ : InsetMathGrid(buf, m, n), name_(name)
{}
-InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n,
- char valign, docstring const & halign)
- : InsetMathGrid(m, n, valign, halign), name_(name)
+InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
+ int n, char valign, docstring const & halign)
+ : InsetMathGrid(buf, m, n, valign, halign), name_(name)
{}
class InsetMathTabular : public InsetMathGrid {
public:
///
- InsetMathTabular(docstring const &, int m, int n);
+ InsetMathTabular(Buffer * buf, docstring const &, int m, int n);
///
- InsetMathTabular(docstring const &, int m, int n,
+ InsetMathTabular(Buffer * buf, docstring const &, int m, int n,
char valign, docstring const & halign);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
/// Inset for underset
class InsetMathUnderset : public InsetMathFracBase {
public:
+ ///
+ InsetMathUnderset(Buffer * buf) : InsetMathFracBase(buf) {}
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
namespace lyx {
-InsetMathXArrow::InsetMathXArrow(docstring const & name)
- : InsetMathFracBase(), name_(name)
+InsetMathXArrow::InsetMathXArrow(Buffer * buf, docstring const & name)
+ : InsetMathFracBase(buf), name_(name)
{}
class InsetMathXArrow : public InsetMathFracBase {
public:
///
- explicit InsetMathXArrow(docstring const & name);
+ explicit InsetMathXArrow(Buffer * buf, docstring const & name);
///
void draw(PainterInfo & pi, int x, int y) const;
///
namespace lyx {
-InsetMathXYMatrix::InsetMathXYMatrix(Length const & s, char c)
- : InsetMathGrid(1, 1), spacing_(s), spacing_code_(c)
-{}
+InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c)
+ : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c)
+{
+}
Inset * InsetMathXYMatrix::clone() const
class InsetMathXYMatrix : public InsetMathGrid {
public:
///
- InsetMathXYMatrix(Length const & = Length(), char c = '\0');
+ InsetMathXYMatrix(Buffer * buf, Length const & = Length(), char c = '\0');
///
void metrics(MetricsInfo &, Dimension &) const;
///
//
/////////////////////////////////////////////////////////////////////
-MacroData::MacroData()
- : queried_(true), numargs_(0), optionals_(0), lockCount_(0),
+MacroData::MacroData(Buffer * buf)
+ : buffer_(buf), queried_(true), numargs_(0), optionals_(0), lockCount_(0),
redefinition_(false), type_(MacroTypeNewcommand)
{}
-MacroData::MacroData(Buffer const & buf, DocIterator const & pos)
- : buffer_(&buf), pos_(pos), queried_(false), numargs_(0),
+MacroData::MacroData(Buffer * buf, DocIterator const & pos)
+ : buffer_(buf), pos_(pos), queried_(false), numargs_(0),
optionals_(0), lockCount_(0), redefinition_(false),
type_(MacroTypeNewcommand)
{
}
-MacroData::MacroData(MathMacroTemplate const & macro)
- : queried_(false), numargs_(0), optionals_(0), lockCount_(0),
+MacroData::MacroData(Buffer * buf, MathMacroTemplate const & macro)
+ : buffer_(buf), queried_(false), numargs_(0), optionals_(0), lockCount_(0),
redefinition_(false), type_(MacroTypeNewcommand)
{
queryData(macro);
updateData();
// Hack. Any inset with a cell would do.
- static InsetMathSqrt inset;
+ static InsetMathSqrt inset(0);
+ inset.setBuffer(const_cast<Buffer &>(*buffer_));
// FIXME UNICODE
asArray(display_.empty() ? definition_ : display_, inset.cell(0));
}
-void MacroTable::insert(docstring const & def, string const & requires)
+void MacroTable::insert(Buffer * buf, docstring const & def, string const & requires)
{
//lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl;
- MathMacroTemplate mac(def);
- MacroData data(mac);
+ MathMacroTemplate mac(buf, def);
+ MacroData data(buf, mac);
data.requires() = requires;
insert(mac.name(), data);
}
//
/////////////////////////////////////////////////////////////////////
-MacroContext::MacroContext(Buffer const & buf, DocIterator const & pos)
+MacroContext::MacroContext(Buffer const * buf, DocIterator const & pos)
: buf_(buf), pos_(pos)
{
}
MacroData const * MacroContext::get(docstring const & name) const
{
- return buf_.getMacro(name, pos_);
+ return buf_->getMacro(name, pos_);
}
} // namespace lyx
class MacroData {
public:
/// Constructor to make STL containers happy
- MacroData();
+ MacroData(Buffer * buf = 0);
/// Create lazy MacroData which only queries the macro template when needed
- MacroData(Buffer const & buf, DocIterator const & pos);
+ MacroData(Buffer * buf, DocIterator const & pos);
/// Create non-lazy MacroData which directly queries the macro template
- MacroData(MathMacroTemplate const & macro);
+ MacroData(Buffer * buf, MathMacroTemplate const & macro);
///
docstring const & definition() const { updateData(); return definition_; }
{
public:
/// Parse full "\\def..." or "\\newcommand..." or ...
- void insert(docstring const & definition, std::string const &);
+ void insert(Buffer * buf, docstring const & definition, std::string const &);
/// Insert pre-digested macro definition
void insert(docstring const & name, MacroData const & data);
///
class MacroContext {
public:
/// construct context for the insets at pos
- MacroContext(Buffer const & buf, DocIterator const & pos);
+ MacroContext(Buffer const * buf, DocIterator const & pos);
/// Lookup macro
MacroData const * get(docstring const & name) const;
private:
///
- Buffer const & buf_;
+ Buffer const * buf_;
///
DocIterator const & pos_;
};
namespace lyx {
-MathData::MathData(const_iterator from, const_iterator to)
- : base_type(from, to)
+MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
+ : base_type(from, to), buffer_(buf)
{}
void MathData::detachMacroParameters(Cursor * cur, const size_type macroPos)
{
MathMacro * macroInset = operator[](macroPos).nucleus()->asMacro();
+ Buffer * buf = cur->buffer();
// detach all arguments
vector<MathData> detachedArgs;
for (size_t q = 0; q < arg.size(); ++q) {
if (arg[q]->getChar() == ']') {
// put brace
- brace = new InsetMathBrace();
+ brace = new InsetMathBrace(buf);
break;
}
}
size_t & pos, MathAtom & scriptToPutAround,
const pos_type macroPos, const int thisPos, const int thisSlice)
{
+ Buffer * buf = cur ? cur->buffer() : 0;
// insert optional arguments?
while (params.size() < numOptionalParams
&& pos < size()
}
// add everything between [ and ] as optional argument
- MathData optarg(begin() + pos + 1, begin() + right);
+ MathData optarg(buf, begin() + pos + 1, begin() + right);
// a brace?
bool brace = false;
namespace lyx {
+class Buffer;
class BufferView;
class Cursor;
class DocIterator;
public:
///
- MathData() {}
+ MathData(Buffer * buf = 0) : buffer_(buf) {}
///
- MathData(const_iterator from, const_iterator to);
+ MathData(Buffer * buf, const_iterator from, const_iterator to);
+ ///
+ Buffer * buffer() { return buffer_; }
+ ///
+ Buffer const * buffer() const { return buffer_; }
///
void append(MathData const & ar);
mutable int slevel_;
mutable int sshift_;
mutable int kerning_;
-
+ Buffer * buffer_;
+
private:
/// is this an exact match at this position?
bool find1(MathData const & ar, size_type pos) const;
MathData & ar,
TestItemFunc testOpen,
TestItemFunc testClose,
- ReplaceArgumentFunc replaceArg
-)
+ ReplaceArgumentFunc replaceArg)
{
+ Buffer * buf = ar.buffer();
// use indices rather than iterators for the loop because we are going
// to modify the array.
for (size_t i = 0; i < ar.size(); ++i) {
continue;
// replace the original stuff by the new inset
- ar[i] = replaceArg(MathData(it + 1, jt));
+ ar[i] = replaceArg(MathData(buf, it + 1, jt));
ar.erase(it + 1, jt + 1);
}
}
void splitScripts(MathData & ar)
{
+ Buffer * buf = ar.buffer();
//lyxerr << "\nScripts from: " << ar << endl;
for (size_t i = 0; i < ar.size(); ++i) {
InsetMathScript const * script = ar[i]->asScriptInset();
// create extra script inset and move superscript over
InsetMathScript * p = ar[i].nucleus()->asScriptInset();
- auto_ptr<InsetMathScript> q(new InsetMathScript(true));
+ auto_ptr<InsetMathScript> q(new InsetMathScript(buf, true));
swap(q->up(), p->up());
p->removeScript(true);
void extractExps(MathData & ar)
{
+ Buffer * buf = ar.buffer();
//lyxerr << "\nExps from: " << ar << endl;
for (size_t i = 0; i + 1 < ar.size(); ++i) {
// is this 'e'?
continue;
// create a proper exp-inset as replacement
- ar[i] = MathAtom(new InsetMathExFunc(from_ascii("exp"), sup->cell(1)));
+ ar[i] = MathAtom(new InsetMathExFunc(buf, from_ascii("exp"), sup->cell(1)));
ar.erase(i + 1);
}
//lyxerr << "\nExps to: " << ar << endl;
//
void extractDets(MathData & ar)
{
+ Buffer * buf = ar.buffer();
//lyxerr << "\ndet from: " << ar << endl;
for (MathData::iterator it = ar.begin(); it != ar.end(); ++it) {
InsetMathDelim const * del = (*it)->asDelimInset();
continue;
if (!del->isAbs())
continue;
- *it = MathAtom(new InsetMathExFunc(from_ascii("det"), del->cell(0)));
+ *it = MathAtom(new InsetMathExFunc(buf, from_ascii("det"), del->cell(0)));
}
//lyxerr << "\ndet to: " << ar << endl;
}
MathAtom replaceParenDelims(const MathData & ar)
{
- return MathAtom(new InsetMathDelim(from_ascii("("), from_ascii(")"), ar));
+ return MathAtom(new InsetMathDelim(const_cast<Buffer *>(ar.buffer()),
+ from_ascii("("), from_ascii(")"), ar));
}
MathAtom replaceBracketDelims(const MathData & ar)
{
- return MathAtom(new InsetMathDelim(from_ascii("["), from_ascii("]"), ar));
+ return MathAtom(new InsetMathDelim(const_cast<Buffer *>(ar.buffer()),
+ from_ascii("["), from_ascii("]"), ar));
}
if (ar.size() < 2)
return;
+ Buffer * buf = ar.buffer();
+
//lyxerr << "\nFunctions from: " << ar << endl;
for (size_t i = 0; i + 1 < ar.size(); ++i) {
MathData::iterator it = ar.begin() + i;
extractScript(exp, jt, ar.end(), true);
// create a proper inset as replacement
- auto_ptr<InsetMathExFunc> p(new InsetMathExFunc(name));
+ auto_ptr<InsetMathExFunc> p(new InsetMathExFunc(buf, name));
// jt points to the "argument". Get hold of this.
MathData::iterator st = extractArgument(p->cell(0), jt, ar.end(), true);
if (ar.size() < 3)
return;
+ Buffer * buf = ar.buffer();
+
//lyxerr << "\nIntegrals from: " << ar << endl;
for (size_t i = 0; i + 1 < ar.size(); ++i) {
MathData::iterator it = ar.begin() + i;
continue;
// core ist part from behind the scripts to the 'd'
- auto_ptr<InsetMathExInt> p(new InsetMathExInt(from_ascii("int")));
+ auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, from_ascii("int")));
// handle scripts if available
if (!testIntSymbol(*it)) {
p->cell(2) = (*it)->asScriptInset()->down();
p->cell(3) = (*it)->asScriptInset()->up();
}
- p->cell(0) = MathData(it + 1, jt);
+ p->cell(0) = MathData(buf, it + 1, jt);
// use the "thing" behind the 'd' as differential
MathData::iterator tt = extractArgument(p->cell(1), jt + 1, ar.end());
if (ar.size() < 2)
return;
+ Buffer * buf = ar.buffer();
+
//lyxerr << "\nSums from: " << ar << endl;
for (size_t i = 0; i + 1 < ar.size(); ++i) {
MathData::iterator it = ar.begin() + i;
continue;
// create a proper inset as replacement
- auto_ptr<InsetMathExInt> p(new InsetMathExInt(from_ascii("sum")));
+ auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, from_ascii("sum")));
// collect lower bound and summation index
InsetMathScript const * sub = ar[i]->asScriptInset();
if (xt != ar.end()) {
// we found a '=', use everything in front of that as index,
// and everything behind as lower index
- p->cell(1) = MathData(ar.begin(), xt);
- p->cell(2) = MathData(xt + 1, ar.end());
+ p->cell(1) = MathData(buf, ar.begin(), xt);
+ p->cell(2) = MathData(buf, xt + 1, ar.end());
} else {
// use everything as summation index, don't use scripts.
p->cell(1) = ar;
void extractDiff(MathData & ar)
{
+ Buffer * buf = ar.buffer();
//lyxerr << "\nDiffs from: " << ar << endl;
for (size_t i = 0; i < ar.size(); ++i) {
MathData::iterator it = ar.begin() + i;
}
// create a proper diff inset
- auto_ptr<InsetMathDiff> diff(new InsetMathDiff);
+ auto_ptr<InsetMathDiff> diff(new InsetMathDiff(buf));
// collect function, let jt point behind last used item
MathData::iterator jt = it + 1;
// FIXME
//n = 1;
if (numer.size() > 2)
- diff->cell(0) = MathData(numer.begin() + 2, numer.end());
+ diff->cell(0) = MathData(buf, numer.begin() + 2, numer.end());
else
jt = extractTerm(diff->cell(0), jt, ar.end());
} else {
// simply d f(x) / d... or d/d...
if (numer.size() > 1)
- diff->cell(0) = MathData(numer.begin() + 1, numer.end());
+ diff->cell(0) = MathData(buf, numer.begin() + 1, numer.end());
else
jt = extractTerm(diff->cell(0), jt, ar.end());
}
if (extractNumber(script->up(), mult)) {
//lyxerr << "mult: " << mult << endl;
for (int i = 0; i < mult; ++i)
- diff->addDer(MathData(dt + 1, st));
+ diff->addDer(MathData(buf, dt + 1, st));
}
} else {
// just d.../dx
- diff->addDer(MathData(dt + 1, et));
+ diff->addDer(MathData(buf, dt + 1, et));
}
dt = et;
}
// assume 'extractDelims' ran before
void extractLims(MathData & ar)
{
+ Buffer * buf = ar.buffer();
//lyxerr << "\nLimits from: " << ar << endl;
for (size_t i = 0; i < ar.size(); ++i) {
MathData::iterator it = ar.begin() + i;
continue;
// the -> splits the subscript int x and x0
- MathData x = MathData(s.begin(), st);
- MathData x0 = MathData(st + 1, s.end());
+ MathData x = MathData(buf, s.begin(), st);
+ MathData x0 = MathData(buf, st + 1, s.end());
// use something behind the script as core
MathData f;
ar.erase(it + 1, tt);
// create a proper inset as replacement
- *it = MathAtom(new InsetMathLim(f, x, x0));
+ *it = MathAtom(new InsetMathLim(buf, f, x, x0));
}
//lyxerr << "\nLimits to: " << ar << endl;
}
vs << ar;
string expr = to_utf8(os.str());
string out;
-
+ // FIXME const cast
+ Buffer * buf = const_cast<Buffer *>(ar.buffer());
lyxerr << "pipe: ar: '" << ar << "'\n"
<< "pipe: expr: '" << expr << "'" << endl;
out = out.substr(i + 6);
// parse output as matrix or single number
- MathAtom at(new InsetMathArray(from_ascii("array"), from_utf8(out)));
+ MathAtom at(new InsetMathArray(buf, from_ascii("array"), from_utf8(out)));
InsetMathArray const * mat = at->asArrayInset();
- MathData res;
+ MathData res(buf);
if (mat->ncols() == 1 && mat->nrows() == 1)
res.append(mat->cell(0));
else {
- res.push_back(MathAtom(new InsetMathDelim(from_ascii("("), from_ascii(")"))));
+ res.push_back(MathAtom(
+ new InsetMathDelim(buf, from_ascii("("), from_ascii(")"))));
res.back().nucleus()->cell(0).push_back(at);
}
return res;
string macro;
string requires;
is >> macro >> requires;
- MacroTable::globalMacros().insert(from_utf8(macro), requires);
+ MacroTable::globalMacros().insert(0, from_utf8(macro), requires);
continue;
}
}
-MathAtom createInsetMath(char const * const s)
+MathAtom createInsetMath(char const * const s, Buffer * buf)
{
- return createInsetMath(from_utf8(s));
+ return createInsetMath(from_utf8(s), buf);
}
-MathAtom createInsetMath(docstring const & s)
+MathAtom createInsetMath(docstring const & s, Buffer * buf)
{
//lyxerr << "creating inset with name: '" << to_utf8(s) << '\'' << endl;
latexkeys const * l = in_word_set(s);
docstring const & inset = l->inset;
//lyxerr << " found inset: '" << inset << '\'' << endl;
if (inset == "ref")
- return MathAtom(new InsetMathRef(l->name));
+ return MathAtom(new InsetMathRef(buf, l->name));
if (inset == "overset")
- return MathAtom(new InsetMathOverset);
+ return MathAtom(new InsetMathOverset(buf));
if (inset == "underset")
- return MathAtom(new InsetMathUnderset);
+ return MathAtom(new InsetMathUnderset(buf));
if (inset == "decoration")
- return MathAtom(new InsetMathDecoration(l));
+ return MathAtom(new InsetMathDecoration(buf, l));
if (inset == "space")
return MathAtom(new InsetMathSpace(to_ascii(l->name), ""));
if (inset == "dots")
// InsetMathMBox is proposed to replace InsetMathBox,
// but is not ready yet (it needs a BufferView for
// construction)
- return MathAtom(new InsetMathBox(l->name));
+ return MathAtom(new InsetMathBox(buf, l->name));
// if (inset == "fbox")
// return MathAtom(new InsetMathFBox(l));
if (inset == "style")
- return MathAtom(new InsetMathSize(l));
+ return MathAtom(new InsetMathSize(buf, l));
if (inset == "font")
- return MathAtom(new InsetMathFont(l));
+ return MathAtom(new InsetMathFont(buf, l));
if (inset == "oldfont")
- return MathAtom(new InsetMathFontOld(l));
+ return MathAtom(new InsetMathFontOld(buf, l));
if (inset == "matrix")
- return MathAtom(new InsetMathAMSArray(s));
+ return MathAtom(new InsetMathAMSArray(buf, s));
if (inset == "split")
- return MathAtom(new InsetMathSplit(s));
+ return MathAtom(new InsetMathSplit(buf, s));
if (inset == "big")
// we can't create a InsetMathBig, since the argument
// is missing.
&& s[2] >= '1' && s[2] <= '9')
return MathAtom(new MathMacroArgument(s[2] - '0'));
if (s == "boxed")
- return MathAtom(new InsetMathBoxed());
+ return MathAtom(new InsetMathBoxed(buf));
if (s == "fbox")
- return MathAtom(new InsetMathFBox());
+ return MathAtom(new InsetMathFBox(buf));
if (s == "framebox")
- return MathAtom(new InsetMathMakebox(true));
+ return MathAtom(new InsetMathMakebox(buf, true));
if (s == "makebox")
- return MathAtom(new InsetMathMakebox(false));
+ return MathAtom(new InsetMathMakebox(buf, false));
if (s == "kern")
return MathAtom(new InsetMathKern);
if (s.substr(0, 8) == "xymatrix") {
spacing = Length(to_ascii(s.substr(i)));
}
}
- return MathAtom(new InsetMathXYMatrix(spacing, spacing_code));
+ return MathAtom(new InsetMathXYMatrix(buf, spacing, spacing_code));
}
if (s == "xrightarrow" || s == "xleftarrow")
- return MathAtom(new InsetMathXArrow(s));
+ return MathAtom(new InsetMathXArrow(buf, s));
if (s == "split" || s == "gathered" || s == "aligned" || s == "alignedat")
- return MathAtom(new InsetMathSplit(s));
+ return MathAtom(new InsetMathSplit(buf, s));
if (s == "cases")
- return MathAtom(new InsetMathCases);
+ return MathAtom(new InsetMathCases(buf));
if (s == "substack")
- return MathAtom(new InsetMathSubstack);
+ return MathAtom(new InsetMathSubstack(buf));
if (s == "subarray" || s == "array")
- return MathAtom(new InsetMathArray(s, 1, 1));
+ return MathAtom(new InsetMathArray(buf, s, 1, 1));
if (s == "sqrt")
- return MathAtom(new InsetMathSqrt);
+ return MathAtom(new InsetMathSqrt(buf));
if (s == "root")
- return MathAtom(new InsetMathRoot);
+ return MathAtom(new InsetMathRoot(buf));
if (s == "tabular")
- return MathAtom(new InsetMathTabular(s, 1, 1));
+ return MathAtom(new InsetMathTabular(buf, s, 1, 1));
if (s == "stackrel")
- return MathAtom(new InsetMathStackrel);
+ return MathAtom(new InsetMathStackrel(buf));
if (s == "binom")
- return MathAtom(new InsetMathBinom(InsetMathBinom::BINOM));
+ return MathAtom(new InsetMathBinom(buf, InsetMathBinom::BINOM));
if (s == "dbinom")
- return MathAtom(new InsetMathBinom(InsetMathBinom::DBINOM));
+ return MathAtom(new InsetMathBinom(buf, InsetMathBinom::DBINOM));
if (s == "tbinom")
- return MathAtom(new InsetMathBinom(InsetMathBinom::TBINOM));
+ return MathAtom(new InsetMathBinom(buf, InsetMathBinom::TBINOM));
if (s == "choose")
- return MathAtom(new InsetMathBinom(InsetMathBinom::CHOOSE));
+ return MathAtom(new InsetMathBinom(buf, InsetMathBinom::CHOOSE));
if (s == "brace")
- return MathAtom(new InsetMathBinom(InsetMathBinom::BRACE));
+ return MathAtom(new InsetMathBinom(buf, InsetMathBinom::BRACE));
if (s == "brack")
- return MathAtom(new InsetMathBinom(InsetMathBinom::BRACK));
+ return MathAtom(new InsetMathBinom(buf, InsetMathBinom::BRACK));
if (s == "frac")
- return MathAtom(new InsetMathFrac);
+ return MathAtom(new InsetMathFrac(buf));
if (s == "cfrac")
- return MathAtom(new InsetMathFrac(InsetMathFrac::CFRAC));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRAC));
if (s == "dfrac")
- return MathAtom(new InsetMathFrac(InsetMathFrac::DFRAC));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::DFRAC));
if (s == "tfrac")
- return MathAtom(new InsetMathFrac(InsetMathFrac::TFRAC));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::TFRAC));
if (s == "over")
- return MathAtom(new InsetMathFrac(InsetMathFrac::OVER));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::OVER));
if (s == "nicefrac")
- return MathAtom(new InsetMathFrac(InsetMathFrac::NICEFRAC));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::NICEFRAC));
if (s == "unitfrac")
- return MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNITFRAC));
// These string values are only for math toolbar use, no LaTeX names
if (s == "unitfracthree")
- return MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC, 3));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNITFRAC, 3));
if (s == "unitone")
- return MathAtom(new InsetMathFrac(InsetMathFrac::UNIT, 1));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNIT, 1));
if (s == "unittwo")
- return MathAtom(new InsetMathFrac(InsetMathFrac::UNIT));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNIT));
if (s == "cfracleft")
- return MathAtom(new InsetMathFrac(InsetMathFrac::CFRACLEFT));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRACLEFT));
if (s == "cfracright")
- return MathAtom(new InsetMathFrac(InsetMathFrac::CFRACRIGHT));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRACRIGHT));
//if (s == "infer")
// return MathAtom(new MathInferInset);
if (s == "atop")
- return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP));
+ return MathAtom(new InsetMathFrac(buf, InsetMathFrac::ATOP));
if (s == "lefteqn")
- return MathAtom(new InsetMathLefteqn);
+ return MathAtom(new InsetMathLefteqn(buf));
if (s == "boldsymbol")
- return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::AMS_BOLD));
+ return MathAtom(new InsetMathBoldSymbol(buf, InsetMathBoldSymbol::AMS_BOLD));
if (s == "bm")
- return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::BM_BOLD));
+ return MathAtom(new InsetMathBoldSymbol(buf, InsetMathBoldSymbol::BM_BOLD));
if (s == "heavysymbol" || s == "hm")
- return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::BM_HEAVY));
+ return MathAtom(new InsetMathBoldSymbol(buf, InsetMathBoldSymbol::BM_HEAVY));
if (s == "color" || s == "normalcolor")
- return MathAtom(new InsetMathColor(true));
+ return MathAtom(new InsetMathColor(buf, true));
if (s == "textcolor")
- return MathAtom(new InsetMathColor(false));
+ return MathAtom(new InsetMathColor(buf, false));
if (s == "hphantom")
- return MathAtom(new InsetMathPhantom(InsetMathPhantom::hphantom));
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::hphantom));
if (s == "phantom")
- return MathAtom(new InsetMathPhantom(InsetMathPhantom::phantom));
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::phantom));
if (s == "vphantom")
- return MathAtom(new InsetMathPhantom(InsetMathPhantom::vphantom));
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::vphantom));
if (s == "ensuremath")
- return MathAtom(new InsetMathEnsureMath);
+ return MathAtom(new InsetMathEnsureMath(buf));
if (isSpecialChar(s))
return MathAtom(new InsetMathSpecialChar(s));
if (s == "regexp")
- return MathAtom(new InsetMathHull(hullRegexp));
+ return MathAtom(new InsetMathHull(buf, hullRegexp));
- return MathAtom(new MathMacro(s));
+ return MathAtom(new MathMacro(buf, s));
}
class MathData;
-MathAtom createInsetMath(docstring const &);
-MathAtom createInsetMath(char const * const);
+MathAtom createInsetMath(docstring const &, Buffer * buf);
+MathAtom createInsetMath(char const * const, Buffer * buf);
/** Fills ar with the contents of str.
* str is created by the frontend dialog's and returned to the LyX core.
};
-MathMacro::MathMacro(docstring const & name)
- : InsetMathNest(0), name_(name), displayMode_(DISPLAY_INIT),
- attachedArgsNum_(0), optionals_(0), nextFoldMode_(true),
- macro_(0), needsUpdate_(false), appetite_(9)
+MathMacro::MathMacro(Buffer * buf, docstring const & name)
+ : InsetMathNest(buf, 0), name_(name), displayMode_(DISPLAY_INIT),
+ expanded_(buf), attachedArgsNum_(0), optionals_(0), nextFoldMode_(true),
+ macroBackup_(buf), macro_(0), needsUpdate_(false), appetite_(9)
{}
cur.recordUndoInset();
cur.popForward();
cur.backspace();
- cur.insert(createInsetMath(unfolded_name));
+ cur.insert(createInsetMath(unfolded_name, cur.buffer()));
if (left)
cur.backwardPos();
cur.updateFlags(Update::Force);
class MathMacro : public InsetMathNest {
public:
/// A macro can be built from an existing template
- MathMacro(docstring const & name);
+ MathMacro(Buffer * buf, docstring const & name);
///
virtual MathMacro * asMacro() { return this; }
///
class InsetLabelBox : public InsetMathNest {
public:
///
- InsetLabelBox(MathAtom const & atom, docstring label,
+ InsetLabelBox(Buffer * buf, MathAtom const & atom, docstring label,
MathMacroTemplate const & parent, bool frame = false);
- InsetLabelBox(docstring label, MathMacroTemplate const & parent,
+ InsetLabelBox(Buffer * buf, docstring label, MathMacroTemplate const & parent,
bool frame = false);
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
};
-InsetLabelBox::InsetLabelBox(MathAtom const & atom, docstring label,
+InsetLabelBox::InsetLabelBox(Buffer * buf, MathAtom const & atom, docstring label,
MathMacroTemplate const & parent, bool frame)
- : InsetMathNest(1), parent_(parent), label_(label), frame_(frame)
+ : InsetMathNest(buf, 1), parent_(parent), label_(label), frame_(frame)
{
cell(0).insert(0, atom);
}
-InsetLabelBox::InsetLabelBox(docstring label,
+InsetLabelBox::InsetLabelBox(Buffer * buf, docstring label,
MathMacroTemplate const & parent, bool frame)
- : InsetMathNest(1), parent_(parent), label_(label), frame_(frame)
+ : InsetMathNest(buf, 1), parent_(parent), label_(label), frame_(frame)
{
}
class DisplayLabelBox : public InsetLabelBox {
public:
///
- DisplayLabelBox(MathAtom const & atom, docstring label,
+ DisplayLabelBox(Buffer * buf, MathAtom const & atom, docstring label,
MathMacroTemplate const & parent);
///
};
-DisplayLabelBox::DisplayLabelBox(MathAtom const & atom,
+DisplayLabelBox::DisplayLabelBox(Buffer * buf, MathAtom const & atom,
docstring label,
MathMacroTemplate const & parent)
- : InsetLabelBox(atom, label, parent, true)
+ : InsetLabelBox(buf, atom, label, parent, true)
{
}
class InsetColoredCell : public InsetMathNest {
public:
///
- InsetColoredCell(ColorCode min, ColorCode max);
+ InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max);
///
- InsetColoredCell(ColorCode min, ColorCode max, MathAtom const & atom);
+ InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max, MathAtom const & atom);
///
void draw(PainterInfo &, int x, int y) const;
///
};
-InsetColoredCell::InsetColoredCell(ColorCode min, ColorCode max)
- : InsetMathNest(1), min_(min), max_(max)
+InsetColoredCell::InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max)
+ : InsetMathNest(buf, 1), min_(min), max_(max)
{
}
-InsetColoredCell::InsetColoredCell(ColorCode min, ColorCode max, MathAtom const & atom)
- : InsetMathNest(1), min_(min), max_(max)
+InsetColoredCell::InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max, MathAtom const & atom)
+ : InsetMathNest(buf, 1), min_(min), max_(max)
{
cell(0).insert(0, atom);
}
MathMacroTemplate::MathMacroTemplate(Buffer * buf)
- : InsetMathNest(3), numargs_(0), argsInLook_(0), optionals_(0),
+ : InsetMathNest(buf, 3), numargs_(0), argsInLook_(0), optionals_(0),
type_(MacroTypeNewcommand), lookOutdated_(true)
{
- buffer_ = buf;
initMath();
}
-MathMacroTemplate::MathMacroTemplate(docstring const & name, int numargs,
- int optionals, MacroType type, Buffer * buf,
- vector<MathData> const & optionalValues,
+MathMacroTemplate::MathMacroTemplate(Buffer * buf, docstring const & name, int numargs,
+ int optionals, MacroType type, vector<MathData> const & optionalValues,
MathData const & def, MathData const & display)
- : InsetMathNest(optionals + 3), numargs_(numargs), argsInLook_(numargs),
+ : InsetMathNest(buf, optionals + 3), numargs_(numargs), argsInLook_(numargs),
optionals_(optionals), optionalValues_(optionalValues),
type_(type), lookOutdated_(true)
{
- buffer_ = buf;
initMath();
if (numargs_ > 9)
}
-MathMacroTemplate::MathMacroTemplate(docstring const & str, Buffer * buf)
- : InsetMathNest(3), numargs_(0), optionals_(0),
+MathMacroTemplate::MathMacroTemplate(Buffer * buf, docstring const & str)
+ : InsetMathNest(buf, 3), numargs_(0), optionals_(0),
type_(MacroTypeNewcommand), lookOutdated_(true)
{
buffer_ = buf;
initMath();
- MathData ar;
- mathed_parse_cell(ar, str, Parse::NORMAL, buf);
+ MathData ar(buf);
+ mathed_parse_cell(ar, str, Parse::NORMAL);
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
lyxerr << "Cannot read macro from '" << ar << "'" << endl;
asArray(from_ascii("invalidmacro"), cell(0));
argsInLook_ = args;
// \foo
- look_.push_back(MathAtom(new InsetLabelBox(_("Name"), *this, false)));
+ look_.push_back(MathAtom(
+ new InsetLabelBox(buffer_, _("Name"), *this, false)));
MathData & nameData = look_[look_.size() - 1].nucleus()->cell(0);
nameData.push_back(MathAtom(new InsetNameWrapper(&cell(0), *this)));
// [#1][#2]
int i = 0;
if (optionals_ > 0) {
- look_.push_back(MathAtom(new InsetLabelBox(_("optional"), *this, false)));
+ look_.push_back(MathAtom(
+ new InsetLabelBox(buffer_, _("optional"), *this, false)));
MathData * optData = &look_[look_.size() - 1].nucleus()->cell(0);
for (; i < optionals_; ++i) {
// color it light grey, if it is to be removed when the cursor leaves
if (i == argsInLook_) {
optData->push_back(MathAtom(
- new InsetColoredCell(Color_mathbg, Color_mathmacrooldarg)));
+ new InsetColoredCell(buffer_, Color_mathbg, Color_mathmacrooldarg)));
optData = &(*optData)[optData->size() - 1].nucleus()->cell(0);
}
MathData arg;
arg.push_back(MathAtom(new MathMacroArgument(i + 1)));
if (i >= argsInLook_) {
- look_.push_back(MathAtom(new InsetColoredCell(
+ look_.push_back(MathAtom(new InsetColoredCell(buffer_,
Color_mathbg, Color_mathmacrooldarg,
MathAtom(new InsetMathBrace(arg)))));
} else
for (; i < argsInLook_; ++i) {
MathData arg;
arg.push_back(MathAtom(new MathMacroArgument(i + 1)));
- look_.push_back(MathAtom(new InsetColoredCell(
+ look_.push_back(MathAtom(new InsetColoredCell(buffer_,
Color_mathbg, Color_mathmacronewarg,
MathAtom(new InsetMathBrace(arg)))));
}
// definition
look_.push_back(MathAtom(
- new InsetLabelBox(MathAtom(
+ new InsetLabelBox(buffer_, MathAtom(
new InsetMathWrapper(&cell(defIdx()))), _("TeX"), *this, true)));
// display
look_.push_back(MathAtom(
- new DisplayLabelBox(MathAtom(
+ new DisplayLabelBox(buffer_, MathAtom(
new InsetMathWrapper(&cell(displayIdx()))), _("LyX"), *this)));
}
void MathMacroTemplate::read(Lexer & lex)
{
- MathData ar;
- mathed_parse_cell(ar, lex.getStream(), Parse::NORMAL, &buffer());
+ MathData ar(buffer_);
+ mathed_parse_cell(ar, lex.getStream(), Parse::NORMAL);
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
lyxerr << "Cannot read macro from '" << ar << "'" << endl;
lyxerr << "Read: " << to_utf8(asString(ar)) << endl;
class MathMacroTemplate : public InsetMathNest {
public:
///
- MathMacroTemplate(Buffer * buf = 0);
+ MathMacroTemplate(Buffer * buf);
///
- MathMacroTemplate(docstring const & name, int nargs, int optional,
- MacroType type, Buffer * buf = 0,
+ MathMacroTemplate(Buffer * buf, docstring const & name, int nargs,
+ int optional, MacroType type,
std::vector<MathData> const & optionalValues = std::vector<MathData>(),
MathData const & def = MathData(),
MathData const & display = MathData());
///
- explicit MathMacroTemplate(const docstring & str, Buffer * buf = 0);
+ MathMacroTemplate(Buffer * buf, const docstring & str);
///
bool editable() const { return true; }
///
bool Parser::parse(MathAtom & at)
{
skipSpaces();
- MathData ar;
+ MathData ar(buffer_);
parse(ar, false, InsetMath::UNDECIDED_MODE);
if (ar.size() != 1 || ar.front()->getType() == hullNone) {
if (!(mode_ & Parse::QUIET))
lyxerr << "unusual contents found: " << ar << endl;
- at = MathAtom(new InsetMathPar(ar));
+ at = MathAtom(new InsetMathPar(buffer_, ar));
//if (at->nargs() > 0)
// at.nucleus()->cell(0) = ar;
//else
MathData Parser::parse(unsigned flags, mode_type mode)
{
- MathData ar;
+ MathData ar(buffer_);
parse(ar, flags, mode);
return ar;
}
bool Parser::parse(MathData & array, unsigned flags, mode_type mode)
{
- InsetMathGrid grid(1, 1);
+ InsetMathGrid grid(buffer_, 1, 1);
parse1(grid, flags, mode, false);
array = grid.cell(0);
return success_;
InsetMathGrid::row_type cellrow = 0;
InsetMathGrid::col_type cellcol = 0;
MathData * cell = &grid.cell(grid.index(cellrow, cellcol));
+ Buffer * buf = buffer_;
if (grid.asHullInset())
grid.asHullInset()->numbered(cellrow, numbered);
Token const & n = getToken();
if (n.cat() == catMath) {
// TeX's $$...$$ syntax for displayed math
- cell->push_back(MathAtom(new InsetMathHull(hullEquation, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullEquation)));
parse2(cell->back(), FLAG_SIMPLE, InsetMath::MATH_MODE, false);
getToken(); // skip the second '$' token
} else {
// simple $...$ stuff
putback();
if (mode == InsetMath::UNDECIDED_MODE) {
- cell->push_back(MathAtom(new InsetMathHull(hullSimple, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullSimple)));
parse2(cell->back(), FLAG_SIMPLE, InsetMath::MATH_MODE, false);
} else {
// Don't create nested math hulls (bug #5392)
- cell->push_back(MathAtom(new InsetMathEnsureMath));
+ cell->push_back(MathAtom(new InsetMathEnsureMath(buffer_)));
parse(cell->back().nucleus()->cell(0), FLAG_SIMPLE, InsetMath::MATH_MODE);
}
}
// we need no new script inset if the last thing was a scriptinset,
// which has that script already not the same script already
if (!cell->size())
- cell->push_back(MathAtom(new InsetMathScript(up)));
+ cell->push_back(MathAtom(new InsetMathScript(buffer_, up)));
else if (cell->back()->asScriptInset() &&
!cell->back()->asScriptInset()->has(up))
cell->back().nucleus()->asScriptInset()->ensure(up);
else if (cell->back()->asScriptInset())
- cell->push_back(MathAtom(new InsetMathScript(up)));
+ cell->push_back(MathAtom(new InsetMathScript(buffer_, up)));
else
- cell->back() = MathAtom(new InsetMathScript(cell->back(), up));
+ cell->back() = MathAtom(new InsetMathScript(buffer_, cell->back(), up));
InsetMathScript * p = cell->back().nucleus()->asScriptInset();
// special handling of {}-bases
// Here we could remove the brace inset for things
|| mode == InsetMath::TEXT_MODE) {
cell->push_back(MathAtom(new InsetMathChar(c)));
} else {
- MathAtom at = createInsetMath("text");
+ MathAtom at = createInsetMath("text", buf);
at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
while (nextToken().cat() == catOther
&& !isAsciiOrMathAlpha(nextToken().character())) {
break;
s += t.asString();
}
- cell->push_back(MathAtom(new InsetMathComment(s)));
+ cell->push_back(MathAtom(new InsetMathComment(buffer_, s)));
skipSpaces();
}
if (nextToken().cat() == catBegin)
parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
- cell->push_back(MathAtom(new MathMacroTemplate(name,
- nargs, 0, MacroTypeDef, buffer_,
+ cell->push_back(MathAtom(new MathMacroTemplate(buffer_, name,
+ nargs, 0, MacroTypeDef,
vector<MathData>(), def, display)));
}
if (nextToken().cat() == catBegin)
parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
- cell->push_back(MathAtom(new MathMacroTemplate(name,
- nargs, optionals, MacroTypeNewcommand, buffer_,
+ cell->push_back(MathAtom(new MathMacroTemplate(buffer_, name,
+ nargs, optionals, MacroTypeNewcommand,
optionalValues, def, display)));
}
if (nextToken().cat() == catBegin)
parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
- cell->push_back(MathAtom(new MathMacroTemplate(name,
- nargs, optionals, MacroTypeNewcommandx, buffer_,
+ cell->push_back(MathAtom(new MathMacroTemplate(buffer_, name,
+ nargs, optionals, MacroTypeNewcommandx,
optionalValues, def, display)));
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullSimple, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullSimple)));
parse2(cell->back(), FLAG_SIMPLE2, InsetMath::MATH_MODE, false);
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullEquation, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullEquation)));
parse2(cell->back(), FLAG_EQUATION, InsetMath::MATH_MODE, false);
}
MathData ar;
parse(ar, FLAG_OPTION, mode);
if (ar.size()) {
- cell->push_back(MathAtom(new InsetMathRoot));
+ cell->push_back(MathAtom(new InsetMathRoot(buffer_)));
cell->back().nucleus()->cell(0) = ar;
parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
} else {
- cell->push_back(MathAtom(new InsetMathSqrt));
+ cell->push_back(MathAtom(new InsetMathSqrt(buffer_)));
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
}
}
MathData ar;
parse(ar, FLAG_OPTION, mode);
if (ar.size()) {
- cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNIT)));
+ cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::UNIT)));
cell->back().nucleus()->cell(0) = ar;
parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
} else {
- cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNIT, 1)));
+ cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::UNIT, 1)));
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
}
}
MathData ar;
parse(ar, FLAG_OPTION, mode);
if (ar.size()) {
- cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC, 3)));
+ cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::UNITFRAC, 3)));
cell->back().nucleus()->cell(2) = ar;
} else {
- cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC)));
+ cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::UNITFRAC)));
}
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
docstring const arg = getArg('[', ']');
//lyxerr << "got so far: '" << arg << "'" << endl;
if (arg == "l")
- cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::CFRACLEFT)));
+ cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::CFRACLEFT)));
else if (arg == "r")
- cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::CFRACRIGHT)));
+ cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::CFRACRIGHT)));
else if (arg.empty() || arg == "c")
- cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::CFRAC)));
+ cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::CFRAC)));
else {
error("found invalid optional argument");
break;
}
else if (t.cs() == "xrightarrow" || t.cs() == "xleftarrow") {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode);
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
}
else if (t.cs() == "ref" || t.cs() == "eqref" || t.cs() == "prettyref"
|| t.cs() == "pageref" || t.cs() == "vpageref" || t.cs() == "vref") {
- cell->push_back(MathAtom(new InsetMathRef(t.cs())));
+ cell->push_back(MathAtom(new InsetMathRef(buffer_, t.cs())));
parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode);
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
}
skipSpaces();
Token const & tr = getToken();
docstring const r = tr.cs() == "|" ? from_ascii("Vert") : tr.asString();
- cell->push_back(MathAtom(new InsetMathDelim(l, r, ar)));
+ cell->push_back(MathAtom(new InsetMathDelim(buf, l, r, ar)));
}
else if (t.cs() == "right") {
if (name == "array" || name == "subarray") {
docstring const valign = parse_verbatim_option() + 'c';
docstring const halign = parse_verbatim_item();
- cell->push_back(MathAtom(new InsetMathArray(name,
+ cell->push_back(MathAtom(new InsetMathArray(buffer_, name,
InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
parse2(cell->back(), FLAG_END, mode, false);
}
else if (name == "tabular") {
docstring const valign = parse_verbatim_option() + 'c';
docstring const halign = parse_verbatim_item();
- cell->push_back(MathAtom(new InsetMathTabular(name,
+ cell->push_back(MathAtom(new InsetMathTabular(buffer_, name,
InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
parse2(cell->back(), FLAG_END, InsetMath::TEXT_MODE, false);
}
else if (name == "split" || name == "cases") {
- cell->push_back(createInsetMath(name));
+ cell->push_back(createInsetMath(name, buf));
parse2(cell->back(), FLAG_END, mode, false);
}
docstring const valign = parse_verbatim_option() + 'c';
// ignore this for a while
getArg('{', '}');
- cell->push_back(MathAtom(new InsetMathSplit(name, (char)valign[0])));
+ cell->push_back(MathAtom(new InsetMathSplit(buffer_, name, (char)valign[0])));
parse2(cell->back(), FLAG_END, mode, false);
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullSimple, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullSimple)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, true);
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullEquation, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullEquation)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, (name == "equation"));
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullEqnArray, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullEqnArray)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullAlign, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullAlign)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullFlAlign, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullFlAlign)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
}
}
// ignore this for a while
getArg('{', '}');
- cell->push_back(MathAtom(new InsetMathHull(hullAlignAt, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullAlignAt)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
}
}
// ignore this for a while
getArg('{', '}');
- cell->push_back(MathAtom(new InsetMathHull(hullXAlignAt, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullXAlignAt)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
}
}
// ignore this for a while
getArg('{', '}');
- cell->push_back(MathAtom(new InsetMathHull(hullXXAlignAt, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullXXAlignAt)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullMultline, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullMultline)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
}
error("bad math environment");
break;
}
- cell->push_back(MathAtom(new InsetMathHull(hullGather, buffer_)));
+ cell->push_back(MathAtom(new InsetMathHull(buffer_, hullGather)));
parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
}
else if (latexkeys const * l = in_word_set(name)) {
if (l->inset == "matrix") {
- cell->push_back(createInsetMath(name));
+ cell->push_back(createInsetMath(name, buf));
parse2(cell->back(), FLAG_END, mode, false);
} else if (l->inset == "split") {
docstring const valign = parse_verbatim_option() + 'c';
- cell->push_back(MathAtom(new InsetMathSplit(name, (char)valign[0])));
+ cell->push_back(MathAtom(
+ new InsetMathSplit(buffer_, name, (char)valign[0])));
parse2(cell->back(), FLAG_END, mode, false);
} else {
success_ = false;
<< "'." << endl;
}
// create generic environment inset
- cell->push_back(MathAtom(new InsetMathEnv(name)));
+ cell->push_back(MathAtom(new InsetMathEnv(buffer_, name)));
parse(cell->back().nucleus()->cell(0), FLAG_END, mode);
}
}
<< to_utf8(name) << "'" << endl;
}
// create generic environment inset
- cell->push_back(MathAtom(new InsetMathEnv(name)));
+ cell->push_back(MathAtom(new InsetMathEnv(buffer_, name)));
parse(cell->back().nucleus()->cell(0), FLAG_END, mode);
}
}
if (grid.asHullInset()) {
grid.asHullInset()->label(cellrow, label);
} else {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
cell->push_back(MathAtom(new InsetMathBrace(ar)));
}
}
else if (t.cs() == "choose" || t.cs() == "over"
|| t.cs() == "atop" || t.cs() == "brace"
|| t.cs() == "brack") {
- MathAtom at = createInsetMath(t.cs());
+ MathAtom at = createInsetMath(t.cs(), buf);
at.nucleus()->cell(0) = *cell;
cell->clear();
parse(at.nucleus()->cell(1), flags, mode);
else if (t.cs() == "color") {
docstring const color = parse_verbatim_item();
- cell->push_back(MathAtom(new InsetMathColor(true, color)));
+ cell->push_back(MathAtom(new InsetMathColor(buffer_, true, color)));
parse(cell->back().nucleus()->cell(0), flags, mode);
return success_;
}
else if (t.cs() == "textcolor") {
docstring const color = parse_verbatim_item();
- cell->push_back(MathAtom(new InsetMathColor(false, color)));
+ cell->push_back(MathAtom(new InsetMathColor(buffer_, false, color)));
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, InsetMath::TEXT_MODE);
}
else if (t.cs() == "normalcolor") {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse(cell->back().nucleus()->cell(0), flags, mode);
return success_;
}
else if (t.cs() == "substack") {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse2(cell->back(), FLAG_ITEM, mode, false);
}
odocstringstream os;
while (good() && nextToken().cat() != catBegin)
os << getToken().asInput();
- cell->push_back(createInsetMath(t.cs() + os.str()));
+ cell->push_back(createInsetMath(t.cs() + os.str(), buf));
parse2(cell->back(), FLAG_ITEM, mode, false);
}
else if (t.cs() == "framebox" || t.cs() == "makebox") {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse(cell->back().nucleus()->cell(0), FLAG_OPTION, InsetMath::TEXT_MODE);
parse(cell->back().nucleus()->cell(1), FLAG_OPTION, InsetMath::TEXT_MODE);
parse(cell->back().nucleus()->cell(2), FLAG_ITEM, InsetMath::TEXT_MODE);
else if (t.cs() == "tag") {
if (nextToken().character() == '*') {
getToken();
- cell->push_back(createInsetMath(t.cs() + '*'));
+ cell->push_back(createInsetMath(t.cs() + '*', buf));
} else
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, InsetMath::TEXT_MODE);
}
else {
// Since the Length class cannot use length variables
// we must not create an InsetMathSpace.
- cell->push_back(MathAtom(new MathMacro(name)));
+ cell->push_back(MathAtom(new MathMacro(buffer_, name)));
MathData ar;
mathed_parse_cell(ar, '{' + arg + '}',
- Parse::NORMAL, buffer_);
+ Parse::NORMAL);
cell->append(ar);
}
}
else if (t.cs() == "infer") {
MathData ar;
parse(ar, FLAG_OPTION, mode);
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse2(cell->back(), FLAG_ITEM, mode, false);
}
cell->push_back(MathAtom(
new InsetMathBig(t.cs(), delim)));
else {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
putback();
}
}
else if (l->inset == "font") {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse(cell->back().nucleus()->cell(0),
FLAG_ITEM, asMode(mode, l->extra));
}
else if (l->inset == "oldfont") {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse(cell->back().nucleus()->cell(0),
flags | FLAG_ALIGN, asMode(mode, l->extra));
if (prevToken().cat() != catAlign &&
}
else if (l->inset == "style") {
- cell->push_back(createInsetMath(t.cs()));
+ cell->push_back(createInsetMath(t.cs(), buf));
parse(cell->back().nucleus()->cell(0),
flags | FLAG_ALIGN, mode);
if (prevToken().cat() != catAlign &&
}
else {
- MathAtom at = createInsetMath(t.cs());
+ MathAtom at = createInsetMath(t.cs(), buf);
for (InsetMath::idx_type i = 0; i < at->nargs(); ++i)
parse(at.nucleus()->cell(i),
FLAG_ITEM, asMode(mode, l->extra));
}
if (!is_unicode_symbol) {
MathAtom at = is_user_macro ?
- MathAtom(new MathMacro(t.cs()))
- : createInsetMath(t.cs());
+ MathAtom(new MathMacro(buffer_, t.cs()))
+ : createInsetMath(t.cs(), buf);
InsetMath::mode_type m = mode;
//if (m == InsetMath::UNDECIDED_MODE)
//lyxerr << "default creation: m1: " << m << endl;
} // anonymous namespace
-bool mathed_parse_cell(MathData & ar, docstring const & str,
- Parse::flags f, Buffer * buf)
+bool mathed_parse_cell(MathData & ar, docstring const & str, Parse::flags f)
{
- return Parser(str, f, buf).parse(ar, 0, f & Parse::TEXTMODE ?
+ return Parser(str, f, ar.buffer()).parse(ar, 0, f & Parse::TEXTMODE ?
InsetMath::TEXT_MODE : InsetMath::MATH_MODE);
}
-bool mathed_parse_cell(MathData & ar, istream & is,
- Parse::flags f, Buffer * buf)
+bool mathed_parse_cell(MathData & ar, istream & is, Parse::flags f)
{
- return Parser(is, f, buf).parse(ar, 0, f & Parse::TEXTMODE ?
+ return Parser(is, f, ar.buffer()).parse(ar, 0, f & Parse::TEXTMODE ?
InsetMath::TEXT_MODE : InsetMath::MATH_MODE);
}
-bool mathed_parse_normal(MathAtom & t, docstring const & str,
- Parse::flags f, Buffer * buf)
+bool mathed_parse_normal(Buffer * buf, MathAtom & t, docstring const & str,
+ Parse::flags f)
{
return Parser(str, f, buf).parse(t);
}
-bool mathed_parse_normal(MathAtom & t, Lexer & lex,
- Parse::flags f, Buffer * buf)
+bool mathed_parse_normal(Buffer * buf, MathAtom & t, Lexer & lex,
+ Parse::flags f)
{
return Parser(lex, f, buf).parse(t);
}
bool mathed_parse_normal(InsetMathGrid & grid, docstring const & str,
- Parse::flags f, Buffer * buf)
+ Parse::flags f)
{
- return Parser(str, f, buf).parse1(grid, 0, f & Parse::TEXTMODE ?
+ return Parser(str, f, &grid.buffer()).parse1(grid, 0, f & Parse::TEXTMODE ?
InsetMath::TEXT_MODE : InsetMath::MATH_MODE, false);
}
latexkeys const * in_word_set(docstring const & str);
/// parse formula from a string
-bool mathed_parse_normal(MathAtom &, docstring const &,
- Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+bool mathed_parse_normal(Buffer * buf, MathAtom &, docstring const &,
+ Parse::flags f = Parse::NORMAL);
/// parse formula from the LyX lexxer
-bool mathed_parse_normal(MathAtom &, Lexer &,
- Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+bool mathed_parse_normal(Buffer * buf, MathAtom &, Lexer &,
+ Parse::flags f = Parse::NORMAL);
/// parse formula from a string into a grid
bool mathed_parse_normal(InsetMathGrid &, docstring const &,
- Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+ Parse::flags f = Parse::NORMAL);
/// parse a single cell from a string
bool mathed_parse_cell(MathData & ar, docstring const &,
- Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+ Parse::flags f = Parse::NORMAL);
/// parse a single cell from a stream. Only use this for reading from .lyx
/// file format, for the reason see Parser::tokenize(std::istream &).
bool mathed_parse_cell(MathData & ar, std::istream &,
- Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+ Parse::flags f = Parse::NORMAL);
void initParser();