]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_hullinset.C
more IU
[lyx.git] / src / mathed / math_hullinset.C
index 15ca41d6eaf5f2d42966857ebc0792ae8c7112c7..caf7b2393620ebaef98dcde29ffd0f1252e53f69 100644 (file)
 #include "math_support.h"
 #include "math_extern.h"
 #include "math_charinset.h"
-#include "debug.h"
 #include "textpainter.h"
+#include "dispatchresult.h"
+#include "debug.h"
 #include "funcrequest.h"
-#include "Lsstream.h"
+#include "gettext.h"
 #include "LaTeXFeatures.h"
-#include "support/LAssert.h"
-#include "frontends/Painter.h"
+#include "LColor.h"
+#include "lyxrc.h"
 
 #include "frontends/Alert.h"
-#include "lyxrc.h"
-#include "gettext.h"
-#include "BufferView.h"
 
-#include <vector>
+#include "support/std_sstream.h"
 
-using namespace lyx::support;
 
-using std::vector;
-using std::max;
+using lyx::support::trim;
+
 using std::endl;
-using std::pair;
+using std::max;
+
+using std::string;
 using std::auto_ptr;
+using std::istringstream;
+using std::ostringstream;
+using std::pair;
+
 
 namespace {
 
@@ -264,7 +267,7 @@ void MathHullInset::drawT(TextPainter & pain, int x, int y) const
 string MathHullInset::label(row_type row) const
 {
        row_type n = nrows();
-       Assert(row < n);
+       BOOST_ASSERT(row < n);
        return label_[row];
 }
 
@@ -307,7 +310,8 @@ bool MathHullInset::display() const
 }
 
 
-void MathHullInset::getLabelList(std::vector<string> & labels) const
+void MathHullInset::getLabelList(Buffer const &,
+                                std::vector<string> & labels) const
 {
        for (row_type row = 0; row < nrows(); ++row)
                if (!label_[row].empty() && nonum_[row] != 1)
@@ -430,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)
@@ -495,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
@@ -673,8 +689,8 @@ void MathHullInset::infoize(std::ostream & os) const
 
 void MathHullInset::check() const
 {
-       Assert(nonum_.size() == nrows());
-       Assert(label_.size() == nrows());
+       BOOST_ASSERT(nonum_.size() == nrows());
+       BOOST_ASSERT(label_.size() == nrows());
 }
 
 
@@ -756,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) {
@@ -766,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;
@@ -782,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()) {
@@ -792,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);
@@ -806,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);
                        }
 
@@ -816,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);
@@ -832,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);
        }
 }