Last shot.

Seperate mathed functions for every LFUN_MATH*.

No change to BufferView*.*

A few bugs killed including those reported this morning by Dekel.

Andre'

-- 
André Pönitz ............................................. [EMAIL PROTECTED]
? out
? diff
? backup
? .BufferView_pimpl.C.swp
? mathed/todo
? mathed/formula.h.1
? mathed/math_sqrtinset.h.ok
? mathed/extern.diff
? mathed/test.log
? mathed/test.aux
? mathed/formula.C.1
? mathed/math_root.h.ok
? mathed/math_fracinset.h.my
? mathed/math_fracinset.C.my
? mathed/math_root.C.ok
? mathed/math_sqrtinset.C.ok
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.129
diff -u -p -r1.129 BufferView_pimpl.C
--- BufferView_pimpl.C  2001/07/04 07:19:08     1.129
+++ BufferView_pimpl.C  2001/07/05 13:42:16
@@ -57,10 +57,9 @@
 #include "insets/insetcaption.h"
 #include "insets/insetfloatlist.h"
 #include "insets/insetspecialchar.h"
-#include "mathed/formulamacro.h"
-#include "mathed/formula.h"
 #include "gettext.h"
 #include "ParagraphParameters.h"
+#include "mathed/formulabase.h"
 
 extern LyXTextClass::size_type current_layout;
 extern int greek_kb_flag;
@@ -85,6 +84,7 @@ extern bool math_insert_greek(BufferView
 extern void sigchldhandler(pid_t pid, int * status);
 extern int bibitemMaxWidth(BufferView *, LyXFont const &);
 
+
 namespace {
 
 const unsigned int saved_positions_num = 20;
@@ -2901,62 +2901,35 @@ bool BufferView::Pimpl::Dispatch(kb_acti
                               | BufferView::CHANGE);
                }
                break;
-       
-       // --- insert characters ----------------------------------------
        
+       case LFUN_MATH_MACRO:
+               mathDispatchMathMacro(bv_, argument);
+               break;
+
        case LFUN_MATH_DELIM:     
+               mathDispatchMathDelim(bv_, argument);
+               break;
+
        case LFUN_INSERT_MATRIX:
-       {          
-               if (available()) { 
-                       if (open_new_inset(new InsetFormula, false)) {
-                               bv_->theLockingInset()
-                                       ->localDispatch(bv_, action, argument);
-                       }
-               }
-       }          
-       break;
-              
+               mathDispatchInsertMatrix(bv_, argument);
+               break;
+
        case LFUN_INSERT_MATH:
-       {
-               if (!available())
-                       break;
- 
-               InsetFormula * f = new InsetFormula(LM_OT_EQUATION);
-               open_new_inset(f);
-               f->localDispatch(bv_, LFUN_INSERT_MATH, argument);
-       }
-       break;
-       
-       case LFUN_MATH_DISPLAY:
-       {       
-               if (available())
-                       open_new_inset(new InsetFormula(LM_OT_EQUATION), false);
+               mathDispatchInsertMath(bv_, argument);
                break;
-       }
-                   
-       case LFUN_MATH_MACRO:
-       {
-               if (available()) {
-                       string s(argument);
-                       if (s.empty())
-                               owner_->getLyXFunc()->setErrorMessage(N_("Missing 
argument"));
-                       else {
-                               string const s1 = token(s, ' ', 1);
-                               int const na = s1.empty() ? 0 : lyx::atoi(s1);
-                               open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), 
na), false);
-                       }
-               }
-       }
-       break;
 
-       case LFUN_MATH_MODE:   // Open or create a math inset
-       {               
-               if (available())
-                       open_new_inset(new InsetFormula, false);
-               owner_->getLyXFunc()->setMessage(N_("Math editor mode"));
-       }
-       break;
-         
+       case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection
+               mathDispatchMathImportSelection(bv_, argument);
+               break;
+
+       case LFUN_MATH_DISPLAY:          // Open or create a displayed math inset
+               mathDispatchMathDisplay(bv_, argument);
+               break;
+
+       case LFUN_MATH_MODE:             // Open or create an inlined math inset 
+               mathDispatchMathMode(bv_, argument);
+               break;
+               
        case LFUN_CITATION_INSERT:
        {
                InsetCommandParams p;
Index: commandtags.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/commandtags.h,v
retrieving revision 1.64
diff -u -p -r1.64 commandtags.h
--- commandtags.h       2001/06/27 14:10:24     1.64
+++ commandtags.h       2001/07/05 13:42:16
@@ -148,15 +148,16 @@ enum kb_action {
        LFUN_MATH_SIZE,   //  Alejandro 150896
        LFUN_MATH_MACRO, // ale970510
        LFUN_MATH_MACROARG,  // ale970510  // 120
-       LFUN_MATH_EXTERN,          // Andre' 20010424
-       LFUN_MATH_PANEL,           // Andre' 20010522
-       LFUN_MATH_VALIGN,          // Andre' 20010522
-       LFUN_MATH_HALIGN,          // Andre' 20010522
-       LFUN_MATH_ROW_INSERT,      // Andre' 20010522
-       LFUN_MATH_ROW_DELETE,      // Andre' 20010522
-       LFUN_MATH_COLUMN_INSERT,   // Andre' 20010522
-       LFUN_MATH_COLUMN_DELETE,   // Andre' 20010522
-       LFUN_MATH_MUTATE,          // Andre' 20010523
+       LFUN_MATH_EXTERN,           // Andre' 20010424
+       LFUN_MATH_PANEL,            // Andre' 20010522
+       LFUN_MATH_VALIGN,           // Andre' 20010522
+       LFUN_MATH_HALIGN,           // Andre' 20010522
+       LFUN_MATH_ROW_INSERT,       // Andre' 20010522
+       LFUN_MATH_ROW_DELETE,       // Andre' 20010522
+       LFUN_MATH_COLUMN_INSERT,    // Andre' 20010522
+       LFUN_MATH_COLUMN_DELETE,    // Andre' 20010522
+       LFUN_MATH_MUTATE,           // Andre' 20010523
+       LFUN_MATH_IMPORT_SELECTION, // Andre' 20010704
        LFUN_FIGURE,
        LFUN_DELETE_WORD_FORWARD,
        LFUN_DELETE_WORD_BACKWARD,
Index: mathed/array.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/array.C,v
retrieving revision 1.29
diff -u -p -r1.29 array.C
--- mathed/array.C      2001/07/03 15:04:59     1.29
+++ mathed/array.C      2001/07/05 13:42:16
@@ -105,6 +105,21 @@ byte MathArray::GetChar(int pos) const
        return pos < size() ? bf_[pos + 1] : '\0';
 }
 
+string MathArray::GetString(int & pos) const
+{
+       string s;
+       if (isInset(pos))
+               return s;
+
+       MathTextCodes const fcode = GetCode(pos);
+       do {
+               s += GetChar(pos);
+               next(pos);
+       } while (pos < size() && !isInset(pos) && GetCode(pos) == fcode);
+
+       return s;
+}
+
 MathTextCodes MathArray::GetCode(int pos) const
 {
        return pos < size() ? MathTextCodes(bf_[pos]) : LM_TC_MIN;
Index: mathed/array.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/array.h,v
retrieving revision 1.28
diff -u -p -r1.28 array.h
--- mathed/array.h      2001/07/03 07:56:55     1.28
+++ mathed/array.h      2001/07/05 13:42:16
@@ -21,6 +21,7 @@
 
 #include "mathed/support.h"
 #include "math_defs.h"
+#include "LString.h"
 
 class MathInset;
 class MathScriptInset;
@@ -107,6 +108,9 @@ public:
        MathScriptInset * nextScriptInset(int pos) const;
        ///
        byte GetChar(int pos) const;
+       /// read subsequent chars of the same kind.
+       // pos is afterwards one behind the last char belonging to the string
+       string GetString(int & pos) const;
        ///
        MathTextCodes GetCode(int pos) const;
        ///
Index: mathed/formula.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.C,v
retrieving revision 1.109
diff -u -p -r1.109 formula.C
--- mathed/formula.C    2001/06/28 10:25:20     1.109
+++ mathed/formula.C    2001/07/05 13:42:16
@@ -70,49 +70,56 @@ InsetFormula::InsetFormula(MathInsetType
 {}
 
 
+InsetFormula::InsetFormula(string const & s)
+       : InsetFormulaBase(0)
+{
+       istringstream is(s.c_str());
+       par(mathed_parse(is));
+}
 
+
 Inset * InsetFormula::clone(Buffer const &) const
 {
        return new InsetFormula(*this);
 }
 
 
-void InsetFormula::write(Buffer const * buf, ostream & os) const
+void InsetFormula::write(ostream & os) const
 {
        os << "Formula ";
-       latex(buf, os, false, false);
+       latex(os, false, false);
 }
 
 
-int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const
+int InsetFormula::latex(ostream & os, bool fragile, bool) const
 {
        par()->Write(os, fragile);
        return 1;
 }
 
 
-int InsetFormula::ascii(Buffer const *, ostream & os, int) const
+int InsetFormula::ascii(ostream & os, int) const
 {
        par()->Write(os, false);
        return 1;
 }
 
 
-int InsetFormula::linuxdoc(Buffer const * buf, ostream & os) const
+int InsetFormula::linuxdoc(ostream & os) const
 {
-       return ascii(buf, os, 0);
+       return ascii(os, 0);
 }
 
 
-int InsetFormula::docBook(Buffer const * buf, ostream & os) const
+int InsetFormula::docBook(ostream & os) const
 {
-       return ascii(buf, os, 0);
+       return ascii(os, 0);
 }
 
 
-void InsetFormula::read(Buffer const *, LyXLex & lex)
+void InsetFormula::read(LyXLex & lex)
 {
-       par_ = mathed_parse(lex);
+       par(mathed_parse(lex));
 }
 
 
@@ -167,7 +174,7 @@ InsetFormula::localDispatch(BufferView *
 
                case LFUN_BREAKLINE: 
                        bv->lockedInsetStoreUndo(Undo::INSERT);
-                       par()->breakLine();
+                       mathcursor->breakLine();
                        updateLocal(bv);
                        break;
 
@@ -245,24 +252,29 @@ InsetFormula::localDispatch(BufferView *
                }
 
                case LFUN_MATH_EXTERN:
+                       bv->lockedInsetStoreUndo(Undo::EDIT);
                        handleExtern(arg, bv);
                        updateLocal(bv);
                        break;
 
                case LFUN_MATH_MUTATE:
+               {
+                       bv->lockedInsetStoreUndo(Undo::EDIT);
+                       int x;
+                       int y;
+                       mathcursor->GetPos(x, y);
                        par()->mutate(arg);
-                       updateLocal(bv);
-                       break;
-
-               case LFUN_TABINSERT:
-                       lyxerr << "take index from cursor\n";
-                       par()->splitCell(0);
+                       mathcursor->SetPos(x, y);
+                       mathcursor->normalize();
                        updateLocal(bv);
                        break;
+               }
 
                case LFUN_MATH_DISPLAY:
-                       if (par()->GetType() == LM_OT_SIMPLE)
+                       if (par()->GetType() == LM_OT_SIMPLE) {
                                par()->mutate(LM_OT_EQUATION);
+                               par()->numbered(0, false);
+                       }
                        else
                                par()->mutate(LM_OT_SIMPLE);
                        updateLocal(bv);
@@ -288,7 +300,7 @@ void InsetFormula::handleExtern(const st
        Systemcalls cmd(Systemcalls::System, script, 0);
 
        ifstream is(outfile.c_str());
-       par_ = mathed_parse(is);
+       par(mathed_parse(is));
 }
 
 bool InsetFormula::display() const
@@ -302,6 +314,12 @@ MathMatrixInset * InsetFormula::par() co
        return static_cast<MathMatrixInset *>(par_);
 }
 
+void InsetFormula::par(MathInset * p)
+{ 
+       delete par_;
+       par_ = p ? p : new MathMatrixInset;
+}
+
 
 Inset::Code InsetFormula::lyxCode() const
 {
@@ -332,13 +350,3 @@ int InsetFormula::width(BufferView *, Ly
        par()->Metrics(LM_ST_TEXT);
        return par()->width();
 }
-
-/*
-LyXFont const InsetFormula::ConvertFont(LyXFont const & f) const
-{
-       // We have already discussed what was here
-       LyXFont font(f);
-       font.setLatex(LyXFont::OFF);
-       return font;
-}
-*/
Index: mathed/formula.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.h,v
retrieving revision 1.41
diff -u -p -r1.41 formula.h
--- mathed/formula.h    2001/06/28 10:25:20     1.41
+++ mathed/formula.h    2001/07/05 13:42:16
@@ -21,6 +21,7 @@
 #pragma interface
 #endif
 
+#include "LString.h"
 #include "mathed/formulabase.h"
 #include "math_defs.h"
 
@@ -34,6 +35,8 @@ public:
        ///
        explicit InsetFormula(MathInsetTypes);
        ///
+       explicit InsetFormula(string const &);
+       ///
        int ascent(BufferView *, LyXFont const &) const;
        ///
        int descent(BufferView *, LyXFont const &) const;
@@ -41,19 +44,21 @@ public:
        int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+
        ///
-       void write(Buffer const *, std::ostream &) const;
+       void write(std::ostream &) const;
        ///
-       void read(Buffer const *, LyXLex & lex);
+       void read(LyXLex & lex);
        ///
-       int latex(Buffer const *, std::ostream &,
+       int latex(std::ostream &,
                  bool fragile, bool free_spc) const;
        ///
-       int ascii(Buffer const *, std::ostream &, int linelen) const;
+       int ascii(std::ostream &, int linelen) const;
        ///
-       int linuxdoc(Buffer const *, std::ostream &) const;
+       int linuxdoc(std::ostream &) const;
        ///
-       int docBook(Buffer const *, std::ostream &) const;
+       int docBook(std::ostream &) const;
+
        ///
        Inset * clone(Buffer const &) const;
        ///
@@ -72,5 +77,8 @@ public:
        bool display() const;
        ///
        bool ams() const;
+private:
+       /// Safe setting of contents
+       void par(MathInset *);
 };
 #endif
Index: mathed/formulabase.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.C,v
retrieving revision 1.7
diff -u -p -r1.7 formulabase.C
--- mathed/formulabase.C        2001/07/03 07:56:55     1.7
+++ mathed/formulabase.C        2001/07/05 13:42:16
@@ -23,11 +23,13 @@
 #endif
 
 #include "formula.h"
+#include "formulamacro.h"
 #include "commandtags.h"
 #include "math_cursor.h"
 #include "math_parser.h"
 #include "BufferView.h"
 #include "lyxtext.h"
+#include "lyxfunc.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "debug.h"
@@ -65,7 +67,7 @@ void mathed_init_fonts();
 
 string nicelabel(string const & label)
 {
-       return label.empty() ? string("(#)") : "(" + label + ")";
+       return "(" + (label.empty() ? "#" : label) + ")";
 }
 
 void handleFont(BufferView * bv, MathTextCodes t) 
@@ -75,6 +77,20 @@ void handleFont(BufferView * bv, MathTex
        mathcursor->handleFont(t);
 }
 
+bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
+{
+       LyXText * lt = bv->getLyXText();
+       
+       bv->beforeChange(lt);
+       lt->finishUndo();
+       if (!bv->insertInset(new_inset)) {
+               delete new_inset;
+               return false;
+       }
+       new_inset->edit(bv, 0, 0, 0);
+       return true;
+}
+
 } // namespaces
 
 
@@ -222,32 +238,39 @@ InsetFormulaBase::~InsetFormulaBase()
 }
 
 
-void InsetFormulaBase::write(Buffer const * buf, ostream & os) const
+void InsetFormulaBase::read(Buffer const *, LyXLex & lex)
 {
-       os << "Formula ";
-       latex(buf, os, false, false);
+       read(lex);
 }
 
-
-int InsetFormulaBase::ascii(Buffer const *, ostream & os, int) const
+void InsetFormulaBase::write(Buffer const *, ostream & os) const
 {
-       par_->Write(os, false);
-       return 0;
+       write(os);
 }
 
+int InsetFormulaBase::latex(Buffer const *, ostream & os,
+       bool fragile, bool spacing) const
+{
+       return latex(os, fragile, spacing);
+}
 
-int InsetFormulaBase::linuxdoc(Buffer const * buf, ostream & os) const
+int InsetFormulaBase::ascii(Buffer const *, ostream & os, int spacing) const
 {
-       return ascii(buf, os, 0);
+       return ascii(os, spacing);
 }
 
+int InsetFormulaBase::linuxdoc(Buffer const *, ostream & os) const
+{
+       return linuxdoc(os);
+}
 
-int InsetFormulaBase::docBook(Buffer const * buf, ostream & os) const
+int InsetFormulaBase::docBook(Buffer const *, ostream & os) const
 {
-       return ascii(buf, os, 0);
+       return docBook(os);
 }
 
 
+
 // Check if uses AMS macros
 void InsetFormulaBase::validate(LaTeXFeatures &) const
 {}
@@ -387,8 +410,8 @@ void InsetFormulaBase::insetButtonReleas
                        sel_flag = false;
                        sel_x = 0;
                        sel_y = 0;
-                       bv->updateInset(this, false);
                }
+               bv->updateInset(this, false);
        }
 }
 
@@ -504,15 +527,14 @@ InsetFormulaBase::localDispatch(BufferVi
                updateLocal(bv);
                break;
 
-
        case LFUN_HOME:
                mathcursor->Home();
-               result = DISPATCHED_NOUPDATE;
+               updateLocal(bv);
                break;
 
        case LFUN_END:
                mathcursor->End();
-               result = DISPATCHED_NOUPDATE;
+               updateLocal(bv);
                break;
 
        case LFUN_DELETE_LINE_FORWARD:
@@ -522,14 +544,18 @@ InsetFormulaBase::localDispatch(BufferVi
                break;
 
        case LFUN_TAB:
-               bv->lockedInsetStoreUndo(Undo::INSERT);
-               mathcursor->idxRight();
+               mathcursor->idxNext();
+               updateLocal(bv);
+               break;
+
+       case LFUN_SHIFT_TAB:
+               mathcursor->idxPrev();
                updateLocal(bv);
                break;
 
        case LFUN_TABINSERT:
-               bv->lockedInsetStoreUndo(Undo::INSERT);
-               mathcursor->idxRight();
+               bv->lockedInsetStoreUndo(Undo::EDIT);
+               mathcursor->splitCell();
                updateLocal(bv);
                break;
 
@@ -563,9 +589,9 @@ InsetFormulaBase::localDispatch(BufferVi
                int y1;
                istringstream is(arg.c_str());
                is >> x >> y;
-               lyxerr << "LFUN_SETXY: x: " << x << " y: " << y << "\n";
                par_->GetXY(x1, y1);
                mathcursor->SetPos(x1 + x, y1 + y);
+               updateLocal(bv);
        }
        break;
 
@@ -829,6 +855,9 @@ InsetFormulaBase::localDispatch(BufferVi
        default:
                if ((action == -1 || action == LFUN_SELFINSERT) && !arg.empty()) {
                        unsigned char c = arg[0];
+                       lyxerr << "char: '" << c << "'  int: " << int(c) << endl;
+                       //owner_->getIntl()->getTrans().TranslateAndInsert(c, lt);     
+ 
+                       lyxerr << "trans: '" << c << "'  int: " << int(c) << endl;
                        bv->lockedInsetStoreUndo(Undo::INSERT);
 
                        if (c == ' ' && mathcursor->getAccent() == LM_hat) {
@@ -1042,5 +1071,94 @@ LyXFont const InsetFormulaBase::convertF
 MathInset * InsetFormulaBase::par() const
 {
        return par_;
+}
+
+
+void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
+{
+       if (bv->available()) {
+// Feature "Read math inset from selection" disabled.
+//             // use selection if available..
+//             string sel;
+//             if (action == LFUN_MATH_IMPORT_SELECTION)
+//                     sel = "";
+//             else
+//                     sel = bv->getLyXText()->selectionAsString(bv->buffer());
+
+                       InsetFormula * f;
+//             if (sel.empty()) {
+                               f = new InsetFormula;
+                               openNewInset(bv, f);
+                               // don't do that also for LFUN_MATH_MODE unless you 
+want end up with
+                               // always changing to mathrm when opening an inlined 
+inset
+                               // -- I really hate "LyXfunc overloading"...
+                               if (display)
+                                       f->localDispatch(bv, LFUN_MATH_DISPLAY, 
+string());
+                               f->localDispatch(bv, LFUN_INSERT_MATH, arg);
+//             } else {
+//                     f = new InsetFormula(sel);
+//                     bv->getLyXText()->cutSelection(bv);
+//                     openNewInset(bv, f);
+//             }
+       }
+       bv->owner()->getLyXFunc()->setMessage(N_("Math editor mode"));
+}
+
+void mathDispatchMathDisplay(BufferView * bv, string const & arg)
+{
+       mathDispatchCreation(bv, arg, true);
+}
+       
+void mathDispatchMathMode(BufferView * bv, string const & arg)
+{
+       mathDispatchCreation(bv, arg, false);
+}
+
+void mathDispatchMathImportSelection(BufferView * bv, string const & arg)
+{
+       mathDispatchCreation(bv, arg, true);
+}
+
+void mathDispatchMathMacro(BufferView * bv, string const & arg)
+{
+       if (bv->available()) {
+               string s(arg);
+               if (s.empty())
+                       bv->owner()->getLyXFunc()->setErrorMessage(N_("Missing 
+argument"));
+               else {
+                       string const s1 = token(s, ' ', 1);
+                       int const na = s1.empty() ? 0 : lyx::atoi(s1);
+                       openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
+               }
+       }
+}
+
+void mathDispatchMathDelim(BufferView * bv, string const & arg)
+{         
+       if (bv->available()) { 
+               if (openNewInset(bv, new InsetFormula))
+                       bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
+       }
+}         
+
+
+void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
+{         
+       if (bv->available()) { 
+               if (openNewInset(bv, new InsetFormula))
+                       bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, 
+arg);
+       }
+}         
+
+void mathDispatchInsertMath(BufferView * bv, string const & arg)
+{
+       if (bv->available()) {
+               if (arg.size() && arg[0] == '\\') {
+                       InsetFormula * f = new InsetFormula(arg);
+                       openNewInset(bv, f);
+               } else {
+                       return mathDispatchMathDisplay(bv, arg);
+               }
+       }
 }
 
Index: mathed/formulabase.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.h,v
retrieving revision 1.2
diff -u -p -r1.2 formulabase.h
--- mathed/formulabase.h        2001/06/28 10:25:20     1.2
+++ mathed/formulabase.h        2001/07/05 13:42:16
@@ -1,15 +1,13 @@
 // -*- C++ -*-
 /*
- *  File:        formula.h
- *  Purpose:     Declaration of formula inset
- *  Author:      Alejandro Aguilar Sierra <[EMAIL PROTECTED]> 
- *  Created:     January 1996
+ *  File:        formulabase.h
+ *  Purpose:     Common parts of the math LyX insets
+ *  Author:      André Pönitz
+ *  Created:     May 2001
  *  Description: Allows the edition of math paragraphs inside Lyx. 
  *
- *  Copyright: 1996, Alejandro Aguilar Sierra
+ *  Copyright: 2001, The LyX Project
  *
- *  Version: 0.4, Lyx project.
- *
  *   You are free to use and modify this code under the terms of
  *   the GNU General Public Licence version 2 or later.
  */
@@ -27,6 +25,7 @@
 #include "insets/inset.h"
 
 class Buffer;
+class BufferView;
 class MathInset;
 
 ///
@@ -46,20 +45,39 @@ public:
        virtual int width(BufferView *, LyXFont const &) const = 0;
        ///
        virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
-       ///
-       virtual void write(Buffer const *, std::ostream &) const = 0;
+
+       /// These are just wrappers taking the unused Buffer * dummy parameter
+       /// 
+       virtual void write(Buffer const *, std::ostream &) const;
        ///
-       virtual void read(Buffer const *, LyXLex & lex) = 0;
+       virtual void read(Buffer const *, LyXLex & lex);
        ///
        virtual int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const = 0;
+                 bool fragile, bool free_spc) const;
        ///
-       virtual int ascii(Buffer const *, std::ostream &, int linelen) const = 0;
+       virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
+       ///
+       virtual int linuxdoc(Buffer const *, std::ostream &) const;
+       ///
+       virtual int docBook(Buffer const *, std::ostream &) const;
+
+protected:
+       /// the actual functions don't use the Buffer * parameter
        ///
-       virtual int linuxdoc(Buffer const *, std::ostream &) const = 0;
+       virtual void write(std::ostream &) const = 0;
        ///
-       virtual int docBook(Buffer const *, std::ostream &) const = 0;
+       virtual void read(LyXLex & lex) = 0;
        ///
+       virtual int latex(std::ostream &, bool fragile, bool free_spc) const = 0;
+       ///
+       virtual int ascii(std::ostream &, int linelen) const = 0;
+       ///
+       virtual int linuxdoc(std::ostream &) const = 0;
+       ///
+       virtual int docBook(std::ostream &) const = 0;
+
+public:
+       ///
        virtual void validate(LaTeXFeatures &) const;
        ///
        virtual Inset * clone(Buffer const &) const = 0;
@@ -92,7 +110,7 @@ public:
        ///
        virtual void insetUnlock(BufferView *);
    
-       ///  To allow transparent use of math editing functions
+       /// To allow transparent use of math editing functions
        virtual RESULT localDispatch(BufferView *, kb_action, string const &);
     
        ///
@@ -106,5 +124,24 @@ protected:
        ///
        MathInset * par_;
 };
+
+// We don't really mess want around with mathed stuff outside mathed.
+// So do it here.
+//
+void mathDispatchCreation(BufferView *, string const &, bool);
+//
+void mathDispatchMathDisplay(BufferView *, string const &);
+//
+void mathDispatchMathMode(BufferView *, string const &);
+//
+void mathDispatchMathMacro(BufferView *, string const &);
+//
+void mathDispatchMathDelim(BufferView *, string const &);
+//
+void mathDispatchInsertMath(BufferView *, string const &);
+//
+void mathDispatchInsertMatrix(BufferView *, string const &);
+//
+void mathDispatchMathImportSelection(BufferView *, string const &);
 
 #endif
Index: mathed/formulamacro.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulamacro.C,v
retrieving revision 1.59
diff -u -p -r1.59 formulamacro.C
--- mathed/formulamacro.C       2001/06/28 10:25:20     1.59
+++ mathed/formulamacro.C       2001/07/05 13:42:16
@@ -1,14 +1,12 @@
 /*
- *  File:        formula.h
- *  Purpose:     Implementation of formula inset
- *  Author:      Alejandro Aguilar Sierra <[EMAIL PROTECTED]> 
- *  Created:     January 1996
- *  Description: Allows the edition of math paragraphs inside Lyx. 
+ *  File:        formulamacro.C
+ *  Purpose:     Implementation of the formula macro LyX inset
+ *  Author:      André Pönitz
+ *  Created:     March 2001
+ *  Description: Allows the edition of math macros inside Lyx. 
  *
- *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
+ *  Copyright: 2001  The LyX Project
  *
- *  Version: 0.4, Lyx project.
- *
  *   You are free to use and modify this code under the terms of
  *   the GNU General Public Licence version 2 or later.
  */
@@ -61,40 +59,40 @@ Inset * InsetFormulaMacro::clone(Buffer 
 }
 
 
-void InsetFormulaMacro::write(Buffer const *, ostream & os) const
+void InsetFormulaMacro::write(ostream & os) const
 {
        os << "FormulaMacro ";
        tmacro()->Write(os, false);
 }
 
 
-int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile, 
+int InsetFormulaMacro::latex(ostream & os, bool fragile, 
                             bool /*free_spacing*/) const
 {
        tmacro()->Write(os, fragile);
        return 2;
 }
 
-int InsetFormulaMacro::ascii(Buffer const *, ostream & os, int) const
+int InsetFormulaMacro::ascii(ostream & os, int) const
 {
        tmacro()->Write(os, false);
        return 0;
 }
 
 
-int InsetFormulaMacro::linuxdoc(Buffer const * buf, ostream & os) const
+int InsetFormulaMacro::linuxdoc(ostream & os) const
 {
-       return ascii(buf, os, 0);
+       return ascii(os, 0);
 }
 
 
-int InsetFormulaMacro::docBook(Buffer const * buf, ostream & os) const
+int InsetFormulaMacro::docBook(ostream & os) const
 {
-       return ascii(buf, os, 0);
+       return ascii(os, 0);
 }
 
 
-void InsetFormulaMacro::read(Buffer const *, LyXLex & lex)
+void InsetFormulaMacro::read(LyXLex & lex)
 {
        // Awful hack...
        par_ = mathed_parse(lex);
@@ -141,7 +139,8 @@ void InsetFormulaMacro::draw(BufferView 
        int const w = width(bv, font) - 2;
        int const h = ascent(bv, font) + descent(bv, font) - 2;
 
-       pain.fillRectangle(int(x), y , w, h, LColor::mathbg);
+       // LColor::mathbg used to be "AntiqueWhite" but is "linen" now, too
+       pain.fillRectangle(int(x), y , w, h, LColor::mathmacrobg);
        pain.rectangle(int(x), y, w, h, LColor::mathframe);
 
        if (mathcursor && mathcursor->formula() == this && mathcursor->Selection()) {
@@ -172,11 +171,11 @@ InsetFormulaMacro::localDispatch(BufferV
                case LFUN_MATH_MACROARG: {
                        int const i = lyx::atoi(arg);
                        lyxerr << "inserting macro arg " << i << "\n";
-                       if (i > 0 && i <= tmacro()->nargs()) {
+                       if (i > 0 && i <= tmacro()->numargs()) {
                                mathcursor->insert(new MathMacroArgument(i));
                                updateLocal(bv);
                        } else {
-                               lyxerr << "not in range 0.." << tmacro()->nargs() << 
"\n";
+                               lyxerr << "not in range 0.." << tmacro()->numargs() << 
+"\n";
                        }
                        break;
                }
Index: mathed/formulamacro.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulamacro.h,v
retrieving revision 1.36
diff -u -p -r1.36 formulamacro.h
--- mathed/formulamacro.h       2001/06/28 10:25:20     1.36
+++ mathed/formulamacro.h       2001/07/05 13:42:16
@@ -44,19 +44,20 @@ public:
        int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *,LyXFont const &, int, float &, bool) const;
+
        ///
-       void read(Buffer const *, LyXLex & lex);
+       void read(LyXLex & lex);
        ///
-       void write(Buffer const *, std::ostream & os) const;
+       void write(std::ostream & os) const;
        ///
-       int ascii(Buffer const *, std::ostream &, int linelen) const;
+       int ascii(std::ostream &, int linelen) const;
        ///
-       int latex(Buffer const *, std::ostream & os, bool fragile,
-                 bool free_spc) const;
+       int latex(std::ostream & os, bool fragile, bool free_spc) const;
        ///
-       int linuxdoc(Buffer const *, std::ostream & os) const;
+       int linuxdoc(std::ostream & os) const;
        ///
-       int docBook(Buffer const *, std::ostream &) const;
+       int docBook(std::ostream &) const;
+
        ///
        Inset * clone(Buffer const &) const;
        ///
Index: mathed/math_cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_cursor.C,v
retrieving revision 1.53
diff -u -p -r1.53 math_cursor.C
--- mathed/math_cursor.C        2001/07/03 07:56:55     1.53
+++ mathed/math_cursor.C        2001/07/05 13:42:16
@@ -20,6 +20,7 @@
 #endif
 
 #include <config.h>
+#include <cctype>
 
 #include "math_inset.h"
 #include "math_parser.h"
@@ -51,6 +52,7 @@
 using std::endl;
 using std::min;
 using std::max;
+using std::isalnum;
 
 
 namespace {
@@ -174,8 +176,8 @@ bool MathCursor::Left(bool sel)
                        result = array().next(anchor_);
                }
        } else {
-               MathInset * p = prevActiveInset();
-               if (p) {
+               MathInset * p = prevInset();
+               if (p && p->isActive()) {
                        // We have to move deeper into the previous inset
                        array().prev(cursor_);
                        push(p, false);
@@ -224,8 +226,8 @@ bool MathCursor::Right(bool sel)
                        result = array().next(cursor_);
                }
        } else {
-               MathInset * p = nextActiveInset();
-               if (p) {
+               MathInset * p = nextInset();
+               if (p && p->isActive()) {
                        push(p, true);
                        result = true;
                } else {
@@ -281,6 +283,7 @@ void MathCursor::SetPos(int x, int y)
        while (1) {
                idx_    = -1;
                cursor_ = -1;
+               lyxerr << "found idx: " << idx_ << " cursor: " << cursor_  << "\n";
                int distmin = 1 << 30; // large enough
                for (int i = 0; i < par_->nargs(); ++i) {
                        MathXArray const & ar = par_->xcell(i);
@@ -298,11 +301,11 @@ void MathCursor::SetPos(int x, int y)
                        }
                }
                lyxerr << "found idx: " << idx_ << " cursor: " << cursor_  << "\n";
-               if (nextIsActive() && nextInset()->covers(x, y)) {
-                       MathInset * p = nextActiveInset();
-                       push(p, true);
-               } else if (prevIsActive() && prevInset()->covers(x, y)) {
-                       MathInset * p = prevActiveInset();
+               MathInset * n = nextInset();
+               MathInset * p = prevInset();
+               if (n && (n->isActive() || n->isScriptInset()) && n->covers(x, y))
+                       push(n, true);
+               else if (p && (p->isActive() || p->isScriptInset()) && p->covers(x, 
+y)) {
                        array().prev(cursor_);
                        push(p, false);
                } else 
@@ -661,10 +664,15 @@ void MathCursor::Interpret(string const 
        }
 
        if (p) {
+               bool oldsel = selection;
+               if (oldsel) 
+                       SelCut();
                insert(p);
                if (p->nargs()) {
                        array().prev(cursor_);
                        push(p, true);
+                       if (oldsel) 
+                               SelPaste();
                }
                p->Metrics(p->size());
        }
@@ -920,10 +928,11 @@ void MathCursor::handleFont(MathTextCode
        if (selection)  {
                int const p1 = std::min(cursor_, anchor_);
                int const p2 = std::max(cursor_, anchor_);
-               for (int pos = p1; pos != p2; array().next(pos))
-                       if (!array().isInset(pos)) { 
-                               MathTextCodes c = array().GetCode(pos) == t ? 
LM_TC_VAR : t;
-                               array().setCode(pos, c);
+               MathArray & ar = array();
+               for (int pos = p1; pos != p2; ar.next(pos))
+                       if (!ar.isInset(pos) && isalnum(ar.GetChar(pos))) { 
+                               MathTextCodes c = ar.GetCode(pos) == t ? LM_TC_VAR : t;
+                               ar.setCode(pos, c);
                        }
        } else {
                if (lastcode == t)
@@ -1094,14 +1103,6 @@ MathInset * MathCursor::prevInset() cons
        return array().GetInset(c);
 }
 
-MathInset * MathCursor::prevActiveInset() const
-{
-       if (cursor_ <= 0 || !array().isInset(cursor_ - 1))
-               return 0;
-       MathInset * inset = prevInset();
-       return inset->isActive() ? inset : 0;
-}
-
 
 MathInset * MathCursor::nextInset() const
 {
@@ -1110,15 +1111,6 @@ MathInset * MathCursor::nextInset() cons
 }
 
 
-MathInset * MathCursor::nextActiveInset() const
-{
-       if (!array().isInset(cursor_))
-               return 0;
-       MathInset * inset = nextInset();
-       return inset->isActive() ? inset : 0;
-}
-
-
 MathScriptInset * MathCursor::nearbyScriptInset() const
 {
        normalize();
@@ -1160,24 +1152,12 @@ bool MathCursor::nextIsInset() const
 }
 
 
-bool MathCursor::nextIsActive() const
-{
-       return nextIsInset() && nextInset()->isActive();
-}
-
-
 bool MathCursor::prevIsInset() const
 {
        return cursor_ > 0 && MathIsInset(prevCode());
 }
 
 
-bool MathCursor::prevIsActive() const
-{
-       return prevIsInset() && prevInset()->isActive();
-}
-
-
 bool MathCursor::IsFont() const
 {
        return MathIsFont(nextCode());
@@ -1202,9 +1182,49 @@ void MathCursor::gotoX(int x)
        cursor_ = xarray().x2pos(x);    
 }
 
-void MathCursor::idxRight()
+void MathCursor::idxNext()
 {
-       par_->idxRight(idx_, cursor_);
+       par_->idxNext(idx_, cursor_);
+}
+
+void MathCursor::idxPrev()
+{
+       par_->idxPrev(idx_, cursor_);
+}
+
+void MathCursor::splitCell()
+{
+       if (idx_ == par_->nargs() - 1) 
+               return;
+       MathArray ar = array();
+       ar.erase(0, cursor_);
+       array().erase(cursor_, array().size());
+       ++idx_;
+       cursor_ = 0;
+       array().insert(0, ar);
+}
+
+void MathCursor::breakLine()
+{
+       MathMatrixInset * p = static_cast<MathMatrixInset *>(formula()->par());
+       if (p->GetType() == LM_OT_SIMPLE || p->GetType() == LM_OT_EQUATION)
+               p->mutate(LM_OT_EQNARRAY);
+       p->addRow(row());
+
+       // split line
+       const int r = row();
+       for (int c = col() + 1; c < p->ncols(); ++c) {
+               const int i1 = p->index(r, c);
+               const int i2 = p->index(r + 1, c);      
+               lyxerr << "swapping cells " << i1 << " and " << i2 << "\n";
+               p->cell(i1).swap(p->cell(i2));
+       }
+
+       // split cell
+       splitCell();
+       MathArray & halfcell = array();
+       idx_ += p->ncols() - 1;
+       halfcell.swap(array());
 }
 
 char MathCursor::valign() const
Index: mathed/math_cursor.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_cursor.h,v
retrieving revision 1.22
diff -u -p -r1.22 math_cursor.h
--- mathed/math_cursor.h        2001/07/03 07:56:55     1.22
+++ mathed/math_cursor.h        2001/07/05 13:42:16
@@ -117,13 +117,19 @@ public:
        void setLastCode(MathTextCodes t);
        ///
        void handleFont(MathTextCodes t);
+       /// Splits cells and shifts right part to the next cell
+       void splitCell();
+       /// Splits line and insert new row of cell 
+       void breakLine();
        ///
        MathTextCodes getLastCode() const;
        ///
        int idx() const { return idx_; }
        ///
-       void idxRight();
+       void idxNext();
        ///
+       void idxPrev();
+       ///
        void pullArg();
        ///
        bool isInside(MathInset *) const;
@@ -213,12 +219,8 @@ private:
        ///
        bool nextIsInset() const;
        ///
-       bool nextIsActive() const;
-       ///
        bool prevIsInset() const;
        ///
-       bool prevIsActive() const;
-       ///
        bool IsFont() const;
        ///
        bool IsScript() const;
@@ -227,11 +229,7 @@ private:
        ///
        MathInset * nextInset() const;
        ///
-       MathInset * nextActiveInset() const;
-       ///
        MathInset * prevInset() const;
-       ///
-       MathInset * prevActiveInset() const;
        ///
        MathScriptInset * nearbyScriptInset() const;
 
Index: mathed/math_decorationinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_decorationinset.C,v
retrieving revision 1.9
diff -u -p -r1.9 math_decorationinset.C
--- mathed/math_decorationinset.C       2001/06/28 10:25:20     1.9
+++ mathed/math_decorationinset.C       2001/07/05 13:42:16
@@ -21,25 +21,13 @@ MathDecorationInset::MathDecorationInset
 }
 
 
-bool MathDecorationInset::GetLimits() const
-{ 
-       return deco_ == LM_underbrace || deco_ == LM_overbrace;
-}    
-
-
 MathInset * MathDecorationInset::clone() const
 {   
        return new MathDecorationInset(*this);
 }
 
 
-void MathDecorationInset::draw(Painter & pain, int x, int y)
-{ 
-       xcell(0).draw(pain, x, y);
-       mathed_draw_deco(pain, x, y + 10, width_, 10, deco_);
-}
 
-
 void MathDecorationInset::Metrics(MathStyles st)
 {
        int const h = 2 * mathed_char_height(LM_TC_VAR, size(), 'I',
@@ -50,14 +38,11 @@ void MathDecorationInset::Metrics(MathSt
        descent_ = xcell(0).descent();
 
        int w = width() + 4;
-       if (w < 16)
-               w = 16;
 
-       int dh_ = w / 5;
+       dh_ = w / 5;
        if (dh_ > h)
                dh_ = h;
 
-       int dy_;        
        if (upper_) {
                ascent_ += dh_ + 2;
                dy_ = -ascent_;
@@ -66,6 +51,14 @@ void MathDecorationInset::Metrics(MathSt
                descent_ += dh_ + 4;
        }
        width_ = w;
+}
+
+void MathDecorationInset::draw(Painter & pain, int x, int y)
+{ 
+       xo(x);
+       yo(x);
+       xcell(0).draw(pain, x, y);
+       mathed_draw_deco(pain, x, y + dy_, width_, dh_, deco_);
 }
 
 
Index: mathed/math_decorationinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_decorationinset.h,v
retrieving revision 1.6
diff -u -p -r1.6 math_decorationinset.h
--- mathed/math_decorationinset.h       2001/06/28 10:25:20     1.6
+++ mathed/math_decorationinset.h       2001/07/05 13:42:16
@@ -16,19 +16,21 @@ public:
        ///
        MathDecorationInset(int);
        ///
-       MathInset *  clone() const;
+       MathInset * clone() const;
        ///
        void draw(Painter &, int, int);
        ///
        void Write(std::ostream &, bool fragile) const;
        ///
        void Metrics(MathStyles st);
-       ///
-       bool GetLimits() const;
 private:
        ///
        int deco_;
        ///
        bool upper_;
+       /// height of deco
+       int dh_;
+       /// vertical offset of deco
+       int dy_;
 };
 #endif
Index: mathed/math_funcinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcinset.C,v
retrieving revision 1.9
diff -u -p -r1.9 math_funcinset.C
--- mathed/math_funcinset.C     2001/06/28 10:25:20     1.9
+++ mathed/math_funcinset.C     2001/07/05 13:42:16
@@ -71,9 +71,3 @@ void MathFuncInset::Metrics(MathStyles s
                mathed_string_height(LM_TC_TEXTRM, size_, name_, ascent_, descent_);
        }
 }
-
-
-bool MathFuncInset::GetLimits() const 
-{  
-       return lims_ && (size() == LM_ST_DISPLAY); 
-} 
Index: mathed/math_funcinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcinset.h,v
retrieving revision 1.8
diff -u -p -r1.8 math_funcinset.h
--- mathed/math_funcinset.h     2001/06/28 10:25:20     1.8
+++ mathed/math_funcinset.h     2001/07/05 13:42:16
@@ -26,8 +26,6 @@ public:
        void WriteNormal(std::ostream &) const;
        ///
        void Metrics(MathStyles st);
-       ///
-       bool GetLimits() const;
 private:
        ///
        bool lims_;
Index: mathed/math_grid.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_grid.h,v
retrieving revision 1.3
diff -u -p -r1.3 math_grid.h
--- mathed/math_grid.h  2001/06/28 10:25:20     1.3
+++ mathed/math_grid.h  2001/07/05 13:42:16
@@ -110,11 +110,10 @@ public: 
        void delCol(int);
        ///
        virtual void appendRow();
-
-protected:
        ///
        int index(int row, int col) const;
 
+protected:
        /// row info
        std::vector<RowInfo> rowinfo_;
        /// column info
Index: mathed/math_inset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_inset.C,v
retrieving revision 1.29
diff -u -p -r1.29 math_inset.C
--- mathed/math_inset.C 2001/06/28 10:25:20     1.29
+++ mathed/math_inset.C 2001/07/05 13:42:16
@@ -202,7 +202,7 @@ void MathInset::draw(Painter & pain, int
 }
 
 
-bool MathInset::idxRight(int & idx, int & pos) const
+bool MathInset::idxNext(int & idx, int & pos) const
 {
        if (idx + 1 >= nargs())
                return false;
@@ -212,8 +212,14 @@ bool MathInset::idxRight(int & idx, int 
 }
 
 
-bool MathInset::idxLeft(int & idx, int & pos) const
+bool MathInset::idxRight(int & idx, int & pos) const
 {
+       return idxNext(idx, pos);
+}
+
+
+bool MathInset::idxPrev(int & idx, int & pos) const
+{
        if (idx == 0)
                return false;
        --idx;
@@ -221,6 +227,11 @@ bool MathInset::idxLeft(int & idx, int &
        return true;
 }
 
+
+bool MathInset::idxLeft(int & idx, int & pos) const
+{
+       return idxPrev(idx, pos);
+}
 
 bool MathInset::idxUp(int &, int &) const
 {
Index: mathed/math_inset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_inset.h,v
retrieving revision 1.31
diff -u -p -r1.31 math_inset.h
--- mathed/math_inset.h 2001/06/28 10:25:20     1.31
+++ mathed/math_inset.h 2001/07/05 13:42:16
@@ -95,6 +95,11 @@ public: 
        /// The right key
        virtual bool idxRight(int & idx, int & pos) const;
 
+       /// Move one physical cell up
+       virtual bool idxNext(int & idx, int & pos) const;
+       /// Move one physical cell down
+       virtual bool idxPrev(int & idx, int & pos) const;
+
        /// Target pos when we enter the inset from the left by pressing "Right"
        virtual bool idxFirst(int & idx, int & pos) const;
        /// Target pos when we enter the inset from the left by pressing "Up"
Index: mathed/math_matrixinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.C,v
retrieving revision 1.21
diff -u -p -r1.21 math_matrixinset.C
--- mathed/math_matrixinset.C   2001/06/28 10:25:20     1.21
+++ mathed/math_matrixinset.C   2001/07/05 13:42:16
@@ -379,25 +379,7 @@ void MathMatrixInset::delCol(int col)
        }
 }
 
-void MathMatrixInset::breakLine() 
-{
-       if (GetType() == LM_OT_SIMPLE || GetType() == LM_OT_EQUATION) 
-               mutate(LM_OT_EQNARRAY);
-       addRow(nrows() - 1);
-}
-
 
-void MathMatrixInset::splitCell(int idx)
-{
-       if (idx == nargs() - 1) {
-               lyxerr << "can't split last cell\n";
-               return;
-       }
-
-       lyxerr << "unimplemented\n";
-}
-
-
 string MathMatrixInset::nicelabel(int row) const
 {
        if (nonum_[row])
@@ -521,7 +503,7 @@ void MathMatrixInset::mutate(short newty
                                case LM_OT_EQNARRAY:
                                        MathGridInset::addCol(1);
                                        SetType(LM_OT_EQNARRAY);
-                                       halign("lrl");
+                                       halign("rcl");
                                        mutate(newtype);
                                        break;
                                
Index: mathed/math_matrixinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.h,v
retrieving revision 1.13
diff -u -p -r1.13 math_matrixinset.h
--- mathed/math_matrixinset.h   2001/06/28 10:25:20     1.13
+++ mathed/math_matrixinset.h   2001/07/05 13:42:16
@@ -31,8 +31,6 @@ public: 
        ///
        void Metrics(MathStyles st);
        ///
-       void breakLine();
-       ///
        void draw(Painter &, int, int);
        ///
        string label(int row) const;
@@ -69,9 +67,6 @@ public: 
        ///
        void mutate(short);
 
-       /// Splits cells and shifts right part to the next cell
-       void splitCell(int idx);
-       
 private:
        ///
        void Validate1(LaTeXFeatures & features);
Index: mathed/math_parser.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v
retrieving revision 1.57
diff -u -p -r1.57 math_parser.C
--- mathed/math_parser.C        2001/07/04 17:15:08     1.57
+++ mathed/math_parser.C        2001/07/05 13:42:16
@@ -733,7 +733,7 @@ void mathed_parse(MathArray & array, uns
 
                case LM_TK_SQRT:
                {           
-                       unsigned char c;
+                       unsigned char c = '\0'; // shut up gcc 3.0
                        yyis->get(c);
                        if (c == '[') {
                                MathRootInset * rt = new MathRootInset;

Reply via email to