]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formulabase.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / formulabase.C
index 98474106e1785135c3c324532ae2c8720f9b7f65..cca0e6f1c4fb964387eae4e1a02adccf851d64f3 100644 (file)
@@ -427,7 +427,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
                case LFUN_MOUSE_MOTION:
                        //return lfunMouseMotion(cmd);
                case LFUN_MOUSE_RELEASE:
-                       lyxerr << "Mouse single release\n";
+                       //lyxerr << "Mouse single release\n";
                        return lfunMouseRelease(cmd);
                case LFUN_MOUSE_DOUBLE:
                        //lyxerr << "Mouse double\n";
@@ -797,47 +797,32 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        case LFUN_DIALOG_SHOW_NEW_INSET: {
                string const & name = argument;
                if (name == "ref") {
-                       string data = "LatexCommand \\ref{}\n\\end_inset\n\n";
+                       string data = "ref LatexCommand \\ref{}\n\\end_inset\n\n";
                        bv->owner()->getDialogs().show(name, data, 0);
                } else
                        result = UNDISPATCHED;
        }
        break;
 
-       case LFUN_REF_APPLY: {
-               // argument comes with a head "LatexCommand " and a
-               // tail "\nend_inset\n\n". Strip them off.
-               string trimmed;
-               string body = split(argument, trimmed, ' ');
-               split(body, trimmed, '\n');
-               lyxerr << "passing '" << trimmed << "' to the math parser\n";
-
-               MathAtom at;
-               if (!mathed_parse_normal(at, trimmed)) {
-                       result = UNDISPATCHED;
-                       break;
-               }
-
-               RefInset * tmp = at.nucleus()->asRefInset();
-               if (!tmp) {
-                       result = UNDISPATCHED;
-                       break;
-               }
-
+       case LFUN_INSET_APPLY: {
+               string const name = cmd.getArg(0);
                InsetBase * base =
-                       bv->owner()->getDialogs().getOpenInset("ref");
+                       bv->owner()->getDialogs().getOpenInset(name);
+
                if (base) {
-                       RefInset * inset = dynamic_cast<RefInset *>(base);
-                       if (!inset) {
+                       FuncRequest fr(bv, LFUN_INSET_MODIFY, cmd.argument);
+                       result = base->localDispatch(fr);
+               } else {
+                       // Turn 'argument' into a temporary RefInset.
+                       MathArray ar;
+                       if (string2RefInset(cmd.argument, ar)) {
+                               mathcursor->insert(ar);
+                       } else {
                                result = UNDISPATCHED;
-                               break;
                        }
-
-                       *inset = *tmp;
-               } else {
-                       mathcursor->insert(at);
                }
-               updateLocal(bv, true);
+               if (result == DISPATCHED)
+                       updateLocal(bv, true);
        }
        break;