using std::endl;
using std::vector;
-extern char const * latex_mathenv[];
-extern MathCursor * mathcursor;
-
InsetFormula::InsetFormula()
: par_(new MathMatrixInset)
InsetFormula::InsetFormula(string const & s)
: par_(mathed_parse_normal(s))
{
+ if (!par_)
+ par_ = mathed_parse_normal("$" + s + "$");
+
+ if (!par_) {
+ lyxerr << "cannot interpret '" << s << "' as math\n";
+ par_ = new MathMatrixInset(LM_OT_SIMPLE);
+ }
metrics();
}
}
-void InsetFormula::write(ostream & os) const
+void InsetFormula::write(Buffer const * buf, ostream & os) const
{
os << "Formula ";
- latex(os, false, false);
+ latex(buf, os, false, false);
}
-int InsetFormula::latex(ostream & os, bool fragile, bool) const
+int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const
{
par_->write(os, fragile);
return 1;
}
-int InsetFormula::ascii(ostream & os, int) const
+int InsetFormula::ascii(Buffer const *, ostream & os, int) const
{
par_->write(os, false);
return 1;
}
-int InsetFormula::linuxdoc(ostream & os) const
+int InsetFormula::linuxdoc(Buffer const * buf, ostream & os) const
{
- return ascii(os, 0);
+ return ascii(buf, os, 0);
}
-int InsetFormula::docBook(ostream & os) const
+int InsetFormula::docbook(Buffer const * buf, ostream & os) const
{
- return ascii(os, 0);
+ return ascii(buf, os, 0);
}
-void InsetFormula::read(LyXLex & lex)
+void InsetFormula::read(Buffer const *, LyXLex & lex)
{
par(mathed_parse_normal(lex));
metrics();
par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
}
+
vector<string> const InsetFormula::getLabelList() const
{
return par_->getLabelList();
case LFUN_BREAKLINE:
bv->lockedInsetStoreUndo(Undo::INSERT);
- int x;
- int y;
- mathcursor->getPos(x, y);
mathcursor->breakLine();
mathcursor->normalize();
updateLocal(bv, true);
if (display()) {
bv->lockedInsetStoreUndo(Undo::INSERT);
bool old = par_->numberedType();
- for (int row = 0; row < par_->nrows(); ++row)
+ for (unsigned int row = 0; row < par_->nrows(); ++row)
par_->numbered(row, !old);
bv->owner()->message(old ? _("No number") : _("Number"));
updateLocal(bv, true);
break;
}
+ case LFUN_MATH_COLUMN_INSERT:
+ {
+ if (par_->getType() == LM_OT_ALIGN)
+ par_->mutate(LM_OT_ALIGNAT);
+ par_->addCol(par_->ncols());
+ mathcursor->normalize();
+ updateLocal(bv, true);
+ }
+
default:
result = InsetFormulaBase::localDispatch(bv, action, arg);
}
par_->validate(features);
}
+
bool InsetFormula::insetAllowed(Inset::Code code) const
{
- return code == Inset::LABEL_CODE;
+ return code == Inset::LABEL_CODE && display();
}
MathInsetTypes InsetFormula::getType() const
{
- return par_->getType();;
+ return par_->getType();
}