]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_nestinset.C
Andreas' patch to prevent crash on click on previewd inset
[lyx.git] / src / mathed / math_nestinset.C
index 5f83787f054781e42a0c2f2cb50d6f94ed5f9b9b..a71327a84e455bbe11473dd3744f4dc27cc79d51 100644 (file)
@@ -88,7 +88,7 @@ MathArray const & MathNestInset::cell(idx_type i) const
 }
 
 
-void MathNestInset::getCursorPos(CursorSlice const & sl,
+void MathNestInset::cursorPos(CursorSlice const & sl, bool boundary,
        int & x, int & y) const
 {
 // FIXME: This is a hack. Ideally, the coord cache should not store
@@ -458,6 +458,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_FINISHED_DOWN:
+               ++cur.pos();
                cur.bv().cursor() = cur;
                break;
 
@@ -473,8 +474,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                } else if (cur.posRight() || idxRight(cur)
                        || cur.popRight() || cur.selection())
                        ;
-               else
+               else {
                        cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                       cur.undispatched();
+               }
                break;
 
        case LFUN_LEFTSEL:
@@ -490,8 +493,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                } else if (cur.posLeft() || idxLeft(cur)
                        || cur.popLeft() || cur.selection())
                        ;
-               else
+               else {
                        cmd = FuncRequest(LFUN_FINISHED_LEFT);
+                       cur.undispatched();
+               }
                break;
 
        case LFUN_UPSEL:
@@ -503,8 +508,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                        break;
                }
                cur.selHandle(cmd.action == LFUN_UPSEL);
-               if (!cur.up())
+               if (!cur.up()) {
                        cmd = FuncRequest(LFUN_FINISHED_UP);
+                       cur.undispatched();
+               }
                // fixes bug 1598. Please check!
                cur.normalize();
                break;
@@ -516,8 +523,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                        break;
                }
                cur.selHandle(cmd.action == LFUN_DOWNSEL);
-               if (!cur.down())
+               if (!cur.down()) {
                        cmd = FuncRequest(LFUN_FINISHED_DOWN);
+                       cur.undispatched();
+               }
                // fixes bug 1598. Please check!
                cur.normalize();
                break;
@@ -642,8 +651,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                        cur.insert(cmd.argument);
                        break;
                }
-               if (!interpret(cur, cmd.argument[0]))
+               if (!interpret(cur, cmd.argument[0])) {
                        cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                       cur.undispatched();
+               }
                break;
 
        //case LFUN_GETXY:
@@ -718,7 +729,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                        handleFont(cur, cmd.argument, "mathrm");
                break;
        case LFUN_CODE:
+               if (currentMode() == TEXT_MODE)
                        handleFont(cur, cmd.argument, "texttt");
+               else
+                       handleFont(cur, cmd.argument, "mathtt");
                break;
        case LFUN_FRAK:
                handleFont(cur, cmd.argument, "mathfrak");
@@ -913,28 +927,18 @@ bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
                }
                flag.setOnOff(cmd.argument[0] == align);
                break;
+#endif
+       /// We have to handle them since 1.4 blocks all unhandled actions
+       case LFUN_ITAL:
        case LFUN_BOLD:
-               flag.setOnOff(tc == "mathbf");
-               break;
        case LFUN_SANS:
-               flag.setOnOff(tc == "mathsf");
-               break;
        case LFUN_EMPH:
-               flag.setOnOff(tc == "mathcal");
-               break;
-       case LFUN_ROMAN:
-               flag.setOnOff(tc == "mathrm");
-               break;
        case LFUN_CODE:
-               flag.setOnOff(tc == "mathtt");
-               break;
        case LFUN_NOUN:
-               flag.setOnOff(tc == "mathbb");
-               break;
+       case LFUN_ROMAN:
        case LFUN_DEFAULT:
-               flag.setOnOff(tc == "mathnormal");
+               flag.enabled(true);
                break;
-#endif
        case LFUN_MATH_MUTATE:
                //flag.setOnOff(mathcursor::formula()->hullType() == cmd.argument);
                flag.setOnOff(false);