]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.C
This commit cleans up everything related to singleton. The other important change...
[lyx.git] / src / mathed / InsetMathNest.C
index 787b0b11a53c9b25a5cd1a5c683b3cd5b58742a8..b23dc673d7ab2cb402690711501588e44b1b8eb9 100644 (file)
 
 #include "support/lstrings.h"
 
-#include "frontends/Dialogs.h"
-#include "frontends/Gui.h"
-#include "frontends/LyXView.h"
 #include "frontends/Painter.h"
 #include "frontends/Selection.h"
 #include "frontends/nullpainter.h"
 
+#include "funcrequest.h"
+#include "lyxserver.h"
+#include "lyxsocket.h"
+
 #include <sstream>
 
 using lyx::cap::copySelection;
@@ -64,9 +65,6 @@ using lyx::cap::cutSelection;
 using lyx::cap::replaceSelection;
 using lyx::cap::selClearOrDel;
 
-using lyx::frontend::Gui;
-using lyx::frontend::Clipboard;
-
 using std::endl;
 using std::string;
 using std::istringstream;
@@ -939,7 +937,17 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
                        RefInset tmp(name);
                        data = tmp.createDialogStr(name);
                }
-               cur.bv().owner()->getDialogs().show(name, data, 0);
+               cur.bv().showInsetDialog(name, data, 0);
+               break;
+       }
+
+       case LFUN_INSET_INSERT: {
+               MathArray ar;
+               if (createInsetMath_fromDialogStr(lyx::to_utf8(cmd.argument()), ar)) {
+                       recordUndo(cur);
+                       cur.insert(ar);
+               } else
+                       cur.undispatched();
                break;
        }
 
@@ -1027,6 +1035,15 @@ bool InsetMathNest::getStatus(LCursor & cur, FuncRequest const & cmd,
                flag.enabled(currentMode() == MATH_MODE);
                break;
 
+       case LFUN_INSET_INSERT: {
+               // Don't test createMathInset_fromDialogStr(), since
+               // getStatus is not called with a valid reference and the
+               // dialog would not be applyable.
+               string const name = cmd.getArg(0);
+               flag.enabled(name == "ref");
+               break;
+       }
+
        case LFUN_MATH_DELIM:
        case LFUN_MATH_BIGDELIM:
                // Don't do this with multi-cell selections
@@ -1089,7 +1106,7 @@ void InsetMathNest::lfunMousePress(LCursor & cur, FuncRequest & cmd)
                if (cur.selection())
                        asArray(lyx::to_utf8(bv.cursor().selectionAsString(false)), ar);
                else
-                       asArray(lyx::to_utf8(bv.owner()->gui().selection().get()), ar);
+                       asArray(lyx::to_utf8(theSelection().get()), ar);
 
                cur.insert(ar);
                bv.mouseSetCursor(cur);
@@ -1120,13 +1137,13 @@ void InsetMathNest::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
        //lyxerr << "## lfunMouseRelease: buttons: " << cmd.button() << endl;
 
        if (cmd.button() == mouse_button::button1) {
-               //cur.bv().owner()->gui().selection().put(cur.grabSelection());
+               //theSelection().put(cur.grabSelection());
                return;
        }
 
        if (cmd.button() == mouse_button::button3) {
                // try to dispatch to enclosed insets first
-               cur.bv().owner()->getDialogs().show("mathpanel");
+               cur.bv().showDialog("mathpanel");
                return;
        }