]> git.lyx.org Git - features.git/blobdiff - src/mathed/InsetMathNest.cpp
* Lazy MathData to avoid unneeded interpretation of macro definitions
[features.git] / src / mathed / InsetMathNest.cpp
index 99edfadb8bc4bffeac0fd28ca07beafc6732d65b..00d4e2ac6e0c7759f4e48fd7cd99221dc907f65d 100644 (file)
@@ -59,6 +59,8 @@
 
 #include <sstream>
 
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
@@ -68,10 +70,6 @@ using cap::cutSelection;
 using cap::replaceSelection;
 using cap::selClearOrDel;
 
-using std::endl;
-using std::string;
-using std::istringstream;
-
 
 InsetMathNest::InsetMathNest(idx_type nargs)
        : cells_(nargs), lock_(false), mouse_hover_(false)
@@ -132,7 +130,7 @@ void InsetMathNest::cursorPos(BufferView const & bv,
        }
        Point const pt2 = coord_cache.getInsets().xy(this);
        //lyxerr << "retrieving position cache for MathData "
-       //      << pt.x_ << ' ' << pt.y_ << std::endl;
+       //      << pt.x_ << ' ' << pt.y_ << endl;
        x = pt.x_ - pt2.x_ + ar.pos2x(sl.pos());
        y = pt.y_ - pt2.y_;
 //     lyxerr << "pt.y_ : " << pt.y_ << " pt2_.y_ : " << pt2.y_
@@ -442,7 +440,7 @@ void InsetMathNest::handleFont2(Cursor & cur, docstring const & arg)
 
 void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
-       //lyxerr << "InsetMathNest: request: " << cmd << std::endl;
+       //lyxerr << "InsetMathNest: request: " << cmd << endl;
        //CursorSlice sl = cur.current();
 
        switch (cmd.action) {
@@ -925,7 +923,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_MATH_DELIM: {
                docstring ls;
-               docstring rs = support::split(cmd.argument(), ls, ' ');
+               docstring rs = split(cmd.argument(), ls, ' ');
                // Reasonable default values
                if (ls.empty())
                        ls = '(';
@@ -996,12 +994,13 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                bool fold = cmd.action == LFUN_MATH_MACRO_FOLD;
                bool found = findMacroToFoldUnfold(it, fold);
                if (found) {
-                       cur.recordUndo();
+                       MathMacro * macro = it.nextInset()->asInsetMath()->asMacro();
+                       cur.recordUndoInset();
                        if (fold)
-                               it.nextInset()->asInsetMath()->asMacro()->fold(cur);
+                               macro->fold(cur);
                        else
-                               it.nextInset()->asInsetMath()->asMacro()->unfold(cur);
-               }\v
+                               macro->unfold(cur);
+               }
                break;
        }