]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.cpp
* src/frontends/controllers/Dialog.{cpp,h}:
[lyx.git] / src / mathed / InsetMathNest.cpp
index 14c817d3b9a396487695aee2e614e7010603081b..d2c98e901a9a019e6be973307986c584daa7ba63 100644 (file)
@@ -74,12 +74,13 @@ using std::istringstream;
 
 
 InsetMathNest::InsetMathNest(idx_type nargs)
-       : cells_(nargs), lock_(false)
+       : cells_(nargs), lock_(false), mouse_hover_(false)
 {}
 
 
 InsetMathNest::InsetMathNest(InsetMathNest const & inset)
-       : InsetMath(inset), cells_(inset.cells_), lock_(inset.lock_)
+       : InsetMath(inset), cells_(inset.cells_), lock_(inset.lock_),
+         mouse_hover_(false)
 {}
 
 
@@ -87,6 +88,7 @@ InsetMathNest & InsetMathNest::operator=(InsetMathNest const & inset)
 {
        cells_ = inset.cells_;
        lock_ = inset.lock_;
+       mouse_hover_ = false;
        InsetMath::operator=(inset);
        return *this;
 }
@@ -358,6 +360,13 @@ int InsetMathNest::latex(Buffer const &, odocstream & os,
 }
 
 
+bool InsetMathNest::setMouseHover(bool mouse_hover)
+{
+       mouse_hover_ = mouse_hover;
+       return true;
+}
+
+
 bool InsetMathNest::notifyCursorLeaves(Cursor & /*cur*/)
 {
 #ifdef WITH_WARNINGS
@@ -450,7 +459,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                }
                cur.niceInsert(topaste);
                cur.clearSelection(); // bug 393
-               cur.bv().switchKeyMap();
                finishUndo();
                break;
        }
@@ -537,35 +545,33 @@ goto_char_backwards:
                }
                break;
 
-       case LFUN_UP:
-               cur.updateFlags(Update::Decoration | Update::FitCursor);
-       case LFUN_UP_SELECT:
-               // FIXME Tried to use clearTargetX and macroModeClose, crashed on cur.up()
-               if (cur.inMacroMode()) {
-                       // Make Helge happy
-                       cur.macroModeClose();
-                       break;
-               }
-               cur.selHandle(cmd.action == LFUN_UP_SELECT);
-               if (!cur.upDownInMath(true))
-                       cur.undispatched();
-               // fixes bug 1598. Please check!
-               cur.normalize();
-               break;
-
        case LFUN_DOWN:
+       case LFUN_UP:
                cur.updateFlags(Update::Decoration | Update::FitCursor);
-       case LFUN_DOWN_SELECT:
+       case LFUN_DOWN_SELECT: 
+       case LFUN_UP_SELECT: {
+               // close active macro
                if (cur.inMacroMode()) {
                        cur.macroModeClose();
                        break;
                }
-               cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
-               if (!cur.upDownInMath(false))
+               
+               // stop/start the selection
+               bool select = cmd.action == LFUN_DOWN_SELECT ||
+                       cmd.action == LFUN_UP_SELECT;
+               cur.selHandle(select);
+               
+               // go up/down
+               bool up = cmd.action == LFUN_UP || cmd.action == LFUN_UP_SELECT;
+               bool successful = cur.upDownInMath(up);
+               if (successful) {
+                       // notify left insets and give them chance to set update flags
+                       lyx::notifyCursorLeaves(cur.beforeDispatchCursor(), cur);
+                       cur.fixIfBroken();
+               }       else
                        cur.undispatched();
-               // fixes bug 1598. Please check!
-               cur.normalize();
                break;
+       }
 
        case LFUN_MOUSE_DOUBLE:
        case LFUN_MOUSE_TRIPLE:
@@ -723,7 +729,7 @@ goto_char_backwards:
                    && cur.inMacroMode() && cur.macroName() != "\\"
                    && cur.macroModeClose()) {
                        MathAtom const atom = cur.prevAtom();
-                       if (atom->asNestInset() && atom->nargs() > 0) {
+                       if (atom->asNestInset() && atom->isActive()) {
                                cur.posLeft();
                                cur.pushLeft(*cur.nextInset());
                        }