]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.cpp
Kill macro mode when using LFUN_ESCAPE
[lyx.git] / src / mathed / InsetMathNest.cpp
index 596e32aa006e9e2ddb413732fb77a2147cbdf7c9..a03aaefb168a38304e91042f1d076bc59d1a13bd 100644 (file)
@@ -32,8 +32,8 @@
 #include "MathCompletionList.h"
 #include "MathData.h"
 #include "MathFactory.h"
-#include "MathMacro.h"
-#include "MathMacroArgument.h"
+#include "InsetMathMacro.h"
+#include "InsetMathMacroArgument.h"
 #include "MathParser.h"
 #include "MathStream.h"
 #include "MathSupport.h"
@@ -735,20 +735,18 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_MOUSE_DOUBLE:
        case LFUN_WORD_SELECT:
                cur.pos() = 0;
-               cur.resetAnchor();
-               cur.selection(true);
+               cur.bv().mouseSetCursor(cur);
                cur.pos() = cur.lastpos();
-               cur.bv().cursor() = cur;
+               cur.bv().mouseSetCursor(cur, true);
                break;
 
        case LFUN_MOUSE_TRIPLE:
                cur.idx() = 0;
                cur.pos() = 0;
-               cur.resetAnchor();
-               cur.selection(true);
+               cur.bv().mouseSetCursor(cur);
                cur.idx() = cur.lastidx();
                cur.pos() = cur.lastpos();
-               cur.bv().cursor() = cur;
+               cur.bv().mouseSetCursor(cur, true);
                break;
 
        case LFUN_LINE_BEGIN:
@@ -815,8 +813,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cur.recordUndoSelection();
                // if the inset can not be removed from within, delete it
                if (!cur.backspace(cmd.getArg(0) == "force")) {
-                       FuncRequest cmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force");
-                       cur.innerText()->dispatch(cur, cmd);
+                       FuncRequest newcmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force");
+                       cur.innerText()->dispatch(cur, newcmd);
                }
                break;
 
@@ -829,8 +827,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cur.recordUndoSelection();
                // if the inset can not be removed from within, delete it
                if (!cur.erase(cmd.getArg(0) == "force")) {
-                       FuncRequest cmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force");
-                       cur.innerText()->dispatch(cur, cmd);
+                       FuncRequest newcmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force");
+                       cur.innerText()->dispatch(cur, newcmd);
                }
                break;
 
@@ -838,8 +836,12 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (cur.selection())
                        cur.clearSelection();
                else  {
-                       cmd = FuncRequest(LFUN_FINISHED_FORWARD);
-                       cur.undispatched();
+                       if (cur.inMacroMode())
+                               cur.macroModeClose(true);
+                       else {
+                               cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+                               cur.undispatched();
+                       }
                }
                break;
 
@@ -898,7 +900,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                int y = 0;
                istringstream is(to_utf8(cmd.argument()));
                is >> x >> y;
-               cur.setScreenPos(x, y);
+               cur.setTargetX(x);
                break;
        }
 
@@ -1208,7 +1210,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                bool fold = act == LFUN_MATH_MACRO_FOLD;
                bool found = findMacroToFoldUnfold(it, fold);
                if (found) {
-                       MathMacro * macro = it.nextInset()->asInsetMath()->asMacro();
+                       InsetMathMacro * macro = it.nextInset()->asInsetMath()->asMacro();
                        cur.recordUndoInset();
                        if (fold)
                                macro->fold(cur);
@@ -1304,7 +1306,7 @@ bool InsetMathNest::findMacroToFoldUnfold(Cursor & it, bool fold) const {
                // go backward through the current cell
                Inset * inset = it.nextInset();
                while (inset && inset->asInsetMath()) {
-                       MathMacro * macro = inset->asInsetMath()->asMacro();
+                       InsetMathMacro * macro = inset->asInsetMath()->asMacro();
                        if (macro) {
                                // found the an macro to open/close?
                                if (macro->folded() != fold)
@@ -1639,7 +1641,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        cur.backspace();
                        int n = c - '0';
                        if (n >= 1 && n <= 9)
-                               cur.insert(new MathMacroArgument(n));
+                               cur.insert(new InsetMathMacroArgument(n));
                        return true;
                }
 
@@ -2033,8 +2035,7 @@ bool InsetMathNest::insertCompletion(Cursor & cur, docstring const & s,
 #if 0
                // FIXME: this creates duplicates in the completion popup
                // which looks ugly. Moreover the changes the list lengths
-               // which seems to
-               confuse the popup as well.
+               // which seems to confuse the popup as well.
                MathCompletionList::addToFavorites(inset->name());
 #endif
                lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, " "));