]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
Oops...
[lyx.git] / src / lyxfunc.C
index 2b0a43513ad719c84fc1109c83a6b888a45c3ca0..8821b45569a775d4cb2a96ce2a9bcf24529b8458 100644 (file)
@@ -34,7 +34,7 @@
 #include "frontends/lyx_gui.h"
 #include "vspace.h"
 #include "FloatList.h"
-#include "converter.h"
+#include "format.h"
 #include "exporter.h"
 #include "importer.h"
 #include "TextCache.h"
@@ -43,6 +43,8 @@
 #include "ParagraphParameters.h"
 
 #include "insets/insetcommand.h"
+#include "insets/inseterror.h"
+#include "insets/insetert.h"
 #include "insets/insettabular.h"
 
 #include "mathed/formulamacro.h"
@@ -517,9 +519,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_TABULAR_INSERT:
                code = Inset::TABULAR_CODE;
                break;
-       case LFUN_INSET_EXTERNAL:
-               code = Inset::EXTERNAL_CODE;
-               break;
        case LFUN_INSET_MARGINAL:
                code = Inset::MARGIN_CODE;
                break;
@@ -559,13 +558,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_REF_INSERT:
                code = Inset::REF_CODE;
                break;
-       case LFUN_CITATION_CREATE:
-       case LFUN_CITATION_INSERT:
-               code = Inset::CITE_CODE;
-               break;
-       case LFUN_INSERT_BIBTEX:
-               code = Inset::BIBTEX_CODE;
-               break;
        case LFUN_INDEX_INSERT:
                code = Inset::INDEX_CODE;
                break;
@@ -583,7 +575,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                break;
        case LFUN_HTMLURL:
        case LFUN_URL:
-       case LFUN_INSERT_URL:
                code = Inset::URL_CODE;
                break;
        case LFUN_QUOTE:
@@ -1047,27 +1038,10 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                break;
 
        case LFUN_TOCVIEW:
-#if 0
-       case LFUN_LOFVIEW:
-       case LFUN_LOTVIEW:
-       case LFUN_LOAVIEW:
-#endif
        {
-               InsetCommandParams p;
-
-#if 0
-               if (action == LFUN_TOCVIEW)
-#endif
-                       p.setCmdName("tableofcontents");
-#if 0
-               else if (action == LFUN_LOAVIEW)
-                       p.setCmdName("listof{algorithm}{List of Algorithms}");
-               else if (action == LFUN_LOFVIEW)
-                       p.setCmdName("listoffigures");
-               else
-                       p.setCmdName("listoftables");
-#endif
-               owner->getDialogs().createTOC(p.getAsString());
+               InsetCommandParams p("tableofcontents");
+               string const data = InsetCommandMailer::params2string("toc", p);
+               owner->getDialogs().show("toc", data, 0);
                break;
        }
 
@@ -1374,27 +1348,80 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                owner->getDialogs().showMathPanel();
                break;
 
-       case LFUN_CITATION_CREATE:
-       {
-               InsetCommandParams p("cite");
+       case LFUN_DIALOG_SHOW_NEW_INSET: {
+               string const & name = argument;
+               string data;
+               if (name == "bibitem" ||
+                   name == "bibtex" ||
+                   name == "index" ||
+                   name == "ref" ||
+                   name == "toc" ||
+                   name == "url") {
+                       InsetCommandParams p(name);
+                       data = InsetCommandMailer::params2string(name, p);
+               } else if (name == "citation") {
+                       InsetCommandParams p("cite");
+                       data = InsetCommandMailer::params2string(name, p);
+               } else if (name == "ert") {
+                       data = InsetERTMailer::params2string(name,
+                                                            InsetERT::Open);
+               }
+               owner->getDialogs().show(name, data, 0);
+       }
+       break;
 
-               if (!argument.empty()) {
-                       // This should be set at source, ie when typing
-                       // "citation-insert foo" in the minibuffer.
-                       // Question: would pybibliographer also need to be
-                       // changed. Suspect so. Leave as-is therefore.
-                       if (contains(argument, "|")) {
-                               p.setContents(token(argument, '|', 0));
-                               p.setOptions(token(argument, '|', 1));
-                       } else {
-                               p.setContents(argument);
-                       }
-                       dispatch(FuncRequest(view(), LFUN_CITATION_INSERT, p.getAsString()));
-               } else
-                       owner->getDialogs().createCitation(p.getAsString());
+       case LFUN_DIALOG_SHOW_NEXT_INSET: {
        }
        break;
 
+       case LFUN_DIALOG_UPDATE: {
+               string const & name = argument;
+               // Can only update a dialog connected to an existing inset
+               InsetBase * i = owner->getDialogs().getOpenInset(name);
+               if (!i)
+                       break;
+
+               if (name == "bibitem" ||
+                   name == "bibtex" ||
+                   name == "citation" ||
+                   name == "index" ||
+                   name == "ref" ||
+                   name == "toc" ||
+                   name == "url") {
+                       InsetCommand * inset = dynamic_cast<InsetCommand *>(i);
+                       if (!inset)
+                               break;
+
+                       InsetCommandMailer mailer(name, *inset);
+                       mailer.updateDialog();
+
+               } else if (name == "error") {
+                       InsetError * inset = dynamic_cast<InsetError *>(i);
+                       if (!inset)
+                               break;
+
+                       owner->getDialogs().update("error",
+                                                  inset->getContents());
+
+               } else if (name == "ert") {
+                       InsetERT * inset = dynamic_cast<InsetERT *>(i);
+                       if (!inset)
+                               break;
+
+                       InsetERTMailer mailer(*inset);
+                       mailer.updateDialog();
+               }
+       }
+       break;
+
+       case LFUN_DIALOG_HIDE:
+               owner ->getDialogs().hide(argument);
+               break;
+
+       case LFUN_DIALOG_DISCONNECT_INSET:
+               owner->getDialogs().disconnect(argument);
+               break;
+
        case LFUN_CHILDOPEN:
        {
                string const filename =