#include <config.h>
#include "MathMacroTemplate.h"
-#include "MathMLStream.h"
+#include "MathStream.h"
#include "MathParser.h"
#include "MathSupport.h"
using support::bformat;
-using std::string;
using std::auto_ptr;
using std::ostream;
using std::endl;
MathMacroTemplate::MathMacroTemplate()
- : InsetMathNest(2), numargs_(0), name_(), type_("newcommand")
+ : InsetMathNest(2), numargs_(0), name_(), type_(from_ascii("newcommand"))
{
initMath();
}
-MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs,
- string const & type, MathArray const & ar1, MathArray const & ar2)
- : InsetMathNest(2), numargs_(numargs), name_(nm), type_(type)
+MathMacroTemplate::MathMacroTemplate(docstring const & name, int numargs,
+ docstring const & type, MathArray const & ar1, MathArray const & ar2)
+ : InsetMathNest(2), numargs_(numargs), name_(name), type_(type)
{
initMath();
}
-MathMacroTemplate::MathMacroTemplate(std::istream & is)
+MathMacroTemplate::MathMacroTemplate(docstring const & str)
: InsetMathNest(2), numargs_(0), name_()
{
initMath();
MathArray ar;
- mathed_parse_cell(ar, is);
+ mathed_parse_cell(ar, str);
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
- lyxerr << "cannot read macro from '" << ar << "'" << endl;
+ lyxerr << "Cannot read macro from '" << ar << "'" << endl;
return;
}
operator=( *(ar[0]->asMacroTemplate()) );
void MathMacroTemplate::edit(LCursor & cur, bool)
{
- lyxerr << "MathMacroTemplate: edit left/right" << endl;
+ //lyxerr << "MathMacroTemplate: edit left/right" << endl;
cur.push(*this);
}
}
-string MathMacroTemplate::name() const
+docstring MathMacroTemplate::name() const
{
return name_;
}
// FIXME UNICODE
// delete the conversion when bformat() will return a docstring.
// delete the conversion when bformat() takes a docstring arg.
- return bformat(_(" Macro: %1$s: "), from_utf8(name_));
+ return bformat(_(" Macro: %1$s: "), name_);
}
void MathMacroTemplate::read(Buffer const &, LyXLex & lex)
{
MathArray ar;
- mathed_parse_cell(ar, lex.getStream());
+ lex.next(); // eat \begin_inset FormulaMacro line
+ docstring const str = lex.getDocString();
+ lex.next(); // eat that macro definition
+ lex.next(); // eat the \\end_insrt line
+ //lyxerr << "Got to read from: " << to_utf8(str) << endl;
+ mathed_parse_cell(ar, str);
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
- lyxerr << "cannot read macro from '" << ar << "'" << endl;
+ lyxerr << "Cannot read macro from '" << ar << "'" << endl;
+ lyxerr << "Read: " << to_utf8(asString(ar)) << endl;
return;
}
operator=( *(ar[0]->asMacroTemplate()) );