]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macrotemplate.C
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / math_macrotemplate.C
index 708b554be8b557a26d8abfe913a839800a29310a..c02ad4c18cd40c4c61a65fb92a8341eaf0022aee 100644 (file)
@@ -36,13 +36,17 @@ using std::endl;
 
 MathMacroTemplate::MathMacroTemplate()
        : MathNestInset(2), numargs_(0), name_(), type_("newcommand")
-{}
+{
+       initMath();
+}
 
 
 MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs,
                string const & type, MathArray const & ar1, MathArray const & ar2)
        : MathNestInset(2), numargs_(numargs), name_(nm), type_(type)
 {
+       initMath();
+
        if (numargs_ > 9)
                lyxerr << "MathMacroTemplate::MathMacroTemplate: wrong # of arguments: "
                        << numargs_ << std::endl;
@@ -54,6 +58,8 @@ MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs,
 MathMacroTemplate::MathMacroTemplate(std::istream & is)
        : MathNestInset(2), numargs_(0), name_()
 {
+       initMath();
+
        MathArray ar;
        mathed_parse_cell(ar, is);
        if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
@@ -64,13 +70,13 @@ MathMacroTemplate::MathMacroTemplate(std::istream & is)
 }
 
 
-auto_ptr<InsetBase> MathMacroTemplate::clone() const
+auto_ptr<InsetBase> MathMacroTemplate::doClone() const
 {
        return auto_ptr<InsetBase>(new MathMacroTemplate(*this));
 }
 
 
-void MathMacroTemplate::edit(LCursor & cur, bool left)
+void MathMacroTemplate::edit(LCursor & cur, bool)
 {
        lyxerr << "MathMacroTemplate: edit left/right" << endl;
        cur.push(*this);
@@ -172,7 +178,7 @@ void MathMacroTemplate::read(Buffer const &, LyXLex & lex)
 void MathMacroTemplate::write(Buffer const &, std::ostream & os) const
 {
        WriteStream wi(os, false, false);
-       os << "FormulaMacro ";
+       os << "FormulaMacro\n";
        write(wi);
 }
 
@@ -180,12 +186,12 @@ void MathMacroTemplate::write(Buffer const &, std::ostream & os) const
 void MathMacroTemplate::write(WriteStream & os) const
 {
        if (type_ == "def") {
-               os << "\n\\def\\" << name_.c_str();
+               os << "\\def\\" << name_.c_str();
                for (int i = 1; i <= numargs_; ++i)
                        os << '#' << i;
        } else {
                // newcommand or renewcommand
-               os << "\n\\" << type_.c_str() << "{\\" << name_.c_str() << '}';
+               os << "\\" << type_.c_str() << "{\\" << name_.c_str() << '}';
                if (numargs_ > 0)
                        os << '[' << numargs_ << ']';
        }