]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_hullinset.C
more IU
[lyx.git] / src / mathed / math_hullinset.C
index 05427f6554ee21ca8b9470c9cec934b3dabd590d..caf7b2393620ebaef98dcde29ffd0f1252e53f69 100644 (file)
@@ -18,6 +18,7 @@
 #include "math_extern.h"
 #include "math_charinset.h"
 #include "textpainter.h"
+#include "dispatchresult.h"
 #include "debug.h"
 #include "funcrequest.h"
 #include "gettext.h"
@@ -35,6 +36,7 @@ using lyx::support::trim;
 using std::endl;
 using std::max;
 
+using std::string;
 using std::auto_ptr;
 using std::istringstream;
 using std::ostringstream;
@@ -175,7 +177,6 @@ char const * MathHullInset::standardFont() const
 {
        if (type_ == "none")
                return "lyxnochange";
-       lyxerr << "standard font: mathnormal\n";
        return "mathnormal";
 }
 
@@ -433,6 +434,18 @@ void MathHullInset::addRow(row_type row)
 }
 
 
+void MathHullInset::swapRow(row_type row)
+{
+       if (nrows() == 1)
+               return;
+       if (row + 1 == nrows())
+               --row;
+       std::swap(nonum_[row], nonum_[row + 1]);
+       std::swap(label_[row], label_[row + 1]);
+       MathGridInset::swapRow(row);
+}
+
+
 void MathHullInset::delRow(row_type row)
 {
        if (nrows() <= 1)
@@ -498,7 +511,7 @@ void MathHullInset::setType(string const & type)
 
 void MathHullInset::mutate(string const & newtype)
 {
-       //lyxerr << "mutating from '" << type_ << "' to '" << newtype << "'" << endl;
+       lyxerr << "mutating from '" << type_ << "' to '" << newtype << "'" << endl;
 
        // we try to move along the chain
        // none <-> simple <-> equation <-> eqnarray
@@ -759,7 +772,7 @@ void MathHullInset::doExtern
 }
 
 
-dispatch_result MathHullInset::dispatch
+DispatchResult MathHullInset::priv_dispatch
        (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        switch (cmd.action) {
@@ -769,9 +782,9 @@ dispatch_result MathHullInset::dispatch
                                mutate("eqnarray");
                                idx = 1;
                                pos = 0;
-                               return DISPATCHED_POP;
+                               return DispatchResult(true, FINISHED);
                        }
-                       return MathGridInset::dispatch(cmd, idx, pos);
+                       return MathGridInset::priv_dispatch(cmd, idx, pos);
 
                case LFUN_MATH_NUMBER:
                        //lyxerr << "toggling all numbers" << endl;
@@ -785,7 +798,7 @@ dispatch_result MathHullInset::dispatch
                                                numbered(row, !old);
                                //bv->owner()->message(old ? _("No number") : _("Number"));
                        }
-                       return DISPATCHED;
+                       return DispatchResult(true, true);
 
                case LFUN_MATH_NONUMBER:
                        if (display()) {
@@ -795,7 +808,7 @@ dispatch_result MathHullInset::dispatch
                                //bv->owner()->message(old ? _("No number") : _("Number"));
                                numbered(r, !old);
                        }
-                       return DISPATCHED;
+                       return DispatchResult(true, true);
 
                case LFUN_INSERT_LABEL: {
                        row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
@@ -809,7 +822,7 @@ dispatch_result MathHullInset::dispatch
                                        ? Alert::askForText(_("Enter new label to insert:"), default_label)
                                        : Alert::askForText(_("Enter label:"), old_label);
                                if (!res.first)
-                                       return UNDISPATCHED;
+                                       return DispatchResult(false);
                                new_label = trim(res.second);
                        }
 
@@ -819,14 +832,15 @@ dispatch_result MathHullInset::dispatch
                        if (!new_label.empty())
                                numbered(r, true);
                        label(r, new_label);
-                       return DISPATCHED;
+                       return DispatchResult(true, true);
                }
 
                case LFUN_MATH_EXTERN:
                        doExtern(cmd, idx, pos);
-                       return DISPATCHED_POP;
+                       return DispatchResult(true, FINISHED);
 
                case LFUN_MATH_MUTATE: {
+                       lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
                        row_type r = row(idx);
                        col_type c = col(idx);
                        mutate(cmd.argument);
@@ -835,18 +849,18 @@ dispatch_result MathHullInset::dispatch
                                idx = nargs() - 1;
                        if (pos > cell(idx).size())
                                pos = cell(idx).size();
-                       return DISPATCHED_POP;
+                       return DispatchResult(true, FINISHED);
                }
 
                case LFUN_MATH_DISPLAY: {
                        mutate(type_ == "simple" ? "equation" : "simple");
                        idx = 0;
                        pos = cell(idx).size();
-                       return DISPATCHED_POP;
+                       return DispatchResult(true, FINISHED);
                }
 
                default:
-                       return MathGridInset::dispatch(cmd, idx, pos);
+                       return MathGridInset::priv_dispatch(cmd, idx, pos);
        }
 }