]> git.lyx.org Git - features.git/commitdiff
Collapse all those LFUN_XYZ_APPLY to a single LFUN_INSET_APPLY.
authorAngus Leeming <leeming@lyx.org>
Thu, 27 Feb 2003 13:26:07 +0000 (13:26 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 27 Feb 2003 13:26:07 +0000 (13:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6293 a592a061-630c-0410-9148-cb99ea01b6c8

28 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/LyXAction.C
src/commandtags.h
src/factory.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBibitem.C
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlCitation.C
src/frontends/controllers/ControlCommand.C
src/frontends/controllers/ControlCommand.h
src/frontends/controllers/ControlERT.C
src/frontends/controllers/ControlIndex.C
src/frontends/controllers/ControlRef.C
src/frontends/controllers/ControlToc.C
src/frontends/controllers/ControlUrl.C
src/insets/ChangeLog
src/insets/insetbibitem.C
src/insets/insetbibtex.C
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/insetert.C
src/insets/insetert.h
src/lyxfunc.C
src/mathed/ChangeLog
src/mathed/formulabase.C
src/mathed/ref_inset.C
src/text3.C

index 12ebd4163ebdce0c0a166a4b08377e33ce0329fd..f29895c2ab0a428873f2fcc97bbe959b53455343 100644 (file)
@@ -1168,43 +1168,8 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                mathDispatch(ev);
                break;
 
-       case LFUN_BIBITEM_APPLY:
-       case LFUN_BIBTEX_APPLY:
-       case LFUN_CITATION_APPLY:
-       case LFUN_ERT_APPLY:
-       case LFUN_INDEX_APPLY:
-       case LFUN_REF_APPLY:
-       case LFUN_TOC_APPLY:
-       case LFUN_URL_APPLY: {
-               string name;
-               switch (ev.action) {
-               case LFUN_BIBITEM_APPLY:
-                       name = "bibitem";
-                       break;
-               case LFUN_BIBTEX_APPLY:
-                       name = "bibtex";
-                       break;
-               case LFUN_CITATION_APPLY:
-                       name = "citation";
-                       break;
-               case LFUN_ERT_APPLY:
-                       name = "ert";
-                       break;
-               case LFUN_INDEX_APPLY:
-                       name = "index";
-                       break;
-               case LFUN_REF_APPLY:
-                       name = "ref";
-                       break;
-               case LFUN_TOC_APPLY:
-                       name = "toc";
-                       break;
-               case LFUN_URL_APPLY:
-                       name = "url";
-                       break;
-               default:
-                       break;
-               }
+       case LFUN_INSET_APPLY: {
+               string const name = ev.getArg(0);
 
                InsetBase * base = owner_->getDialogs().getOpenInset(name);
                Inset * inset = 0;
@@ -1222,7 +1187,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                        }
                }
 
-               if (ev.action == LFUN_BIBITEM_APPLY) {
+               if (name == "bibitem") {
                        // We need to do a redraw because the maximum
                        // InsetBibitem width could have changed
 #warning please check you mean repaint() not update(),
index 82b185641f64c3f06a60d4d08ff80d0a2091d22f..82df282882b5243ce640b9367cfb9a3f4d9b99e6 100644 (file)
@@ -1,6 +1,19 @@
+2003-02-27  Angus Leeming  <leeming@lyx.org>
+
+       * commandtags.h:
+       * LyXAction.C (init):
+       * factory.C (createInset):
+       * BufferView_pimpl.C (dispatch):
+       collapse LFUN_XYZ_APPLY to LFUN_INSET_APPLY.
+
+       * lyxfunc.C (getStatus): remove LFUN_BIBTEX_APPLY, LFUN_CITATION_APPLY.
+
+       * lyxfunc.C (dispatch):
+       * text3.C (dispatch): pass name to params2string.
+
 2003-02-26  Angus Leeming  <leeming@lyx.org>
 
-       * BufferView_pimpl.C (dispatch): callapse the various LFUN_XYZ_APPLY
+       * BufferView_pimpl.C (dispatch): collapse the various LFUN_XYZ_APPLY
        blocks together.
        Rearrange the ~includes. Strip out the unnecessary ones.
 
index 15dc26fb4c1438eddabf23f0c1889b958c5c4867..1470b05bfcb45391af2ad2d0740303fc554c40bb 100644 (file)
@@ -420,14 +420,7 @@ void LyXAction::init()
                  N_("Hide the dialog"), Noop },
                { LFUN_DIALOG_DISCONNECT_INSET, "dialog-disconnect-inset",
                  N_("Disconnect the dialog from the current inset"), Noop },
-               { LFUN_BIBITEM_APPLY, "bibitem-apply", "", Noop },
-               { LFUN_BIBTEX_APPLY, "bibtex-apply", "", Noop },
-               { LFUN_CITATION_APPLY, "citation-apply", "", Noop },
-               { LFUN_ERT_APPLY, "ert-apply", "", Noop },
-               { LFUN_INDEX_APPLY, "index-apply", "", Noop },
-               { LFUN_REF_APPLY, "ref-apply", "", Noop },
-               { LFUN_TOC_APPLY, "toc-apply", "", Noop },
-               { LFUN_URL_APPLY, "url-apply", "", Noop },
+               { LFUN_INSET_APPLY, "inset-apply", "", Noop },
                { LFUN_NOACTION, "", "", Noop }
        };
 
index 571537bd1607c3e988d024aabefe13d2f823762b..eddedebf976dbdabdea3125b53f8426bbb0a12b6 100644 (file)
@@ -296,14 +296,7 @@ enum kb_action {
        LFUN_DIALOG_UPDATE,
        LFUN_DIALOG_HIDE,
        LFUN_DIALOG_DISCONNECT_INSET,
-       LFUN_BIBITEM_APPLY,
-       LFUN_BIBTEX_APPLY,
-       LFUN_CITATION_APPLY,
-       LFUN_ERT_APPLY,
-       LFUN_INDEX_APPLY,
-       LFUN_REF_APPLY,
-       LFUN_TOC_APPLY,
-       LFUN_URL_APPLY,
+       LFUN_INSET_APPLY,
        LFUN_LASTACTION  /* this marks the end of the table */
 };
 
index 0c737dcb96cc2d12e980de3ffb28cdbf62cb2491..288aa0e15043192bde889bc9e3142ab6ab6855e3 100644 (file)
@@ -38,6 +38,7 @@
 #include "insets/insettoc.h"
 #include "insets/inseturl.h"
 #include "insets/insetwrap.h"
+
 #include "frontends/Dialogs.h"
 #include "frontends/LyXView.h"
 
@@ -105,13 +106,13 @@ Inset * createInset(FuncRequest const & cmd)
                        cmd.argument;
                icp.setContents(contents);
 
-               string data = InsetCommandMailer::params2string(icp);
+               string data = InsetCommandMailer::params2string("index", icp);
                LyXView * lv = bv->owner();
 
                if (icp.getContents().empty()) {
                        lv->getDialogs().show("index", data, 0);
                } else {
-                       FuncRequest fr(bv, LFUN_INDEX_APPLY, data);
+                       FuncRequest fr(bv, LFUN_INSET_APPLY, data);
                        lv->dispatch(fr);
                }
                return 0;
@@ -165,57 +166,55 @@ Inset * createInset(FuncRequest const & cmd)
                return new InsetTheorem;
 #endif
 
-       case LFUN_BIBITEM_APPLY: {
-               InsetCommandParams icp;
-               InsetCommandMailer::string2params(cmd.argument, icp);
-               return new InsetBibitem(icp);
-       }
+       case LFUN_INSET_APPLY: {
+               string const name = cmd.getArg(0);
 
-       case LFUN_BIBTEX_APPLY: {
-               InsetCommandParams icp;
-               InsetCommandMailer::string2params(cmd.argument, icp);
-               return new InsetBibtex(icp);
-       }
+               if (name == "bibitem") {
+                       InsetCommandParams icp;
+                       InsetCommandMailer::string2params(cmd.argument, icp);
+                       return new InsetBibitem(icp);
 
-       case LFUN_CITATION_APPLY: {
-               InsetCommandParams icp;
-               InsetCommandMailer::string2params(cmd.argument, icp);
-               InsetCitation * inset = new InsetCitation(icp);
-               inset->setLoadingBuffer(bv->buffer(), false);
-               return inset;
-       }
+               } else if (name == "bibtex") {
+                       InsetCommandParams icp;
+                       InsetCommandMailer::string2params(cmd.argument, icp);
+                       return new InsetBibtex(icp);
 
-       case LFUN_ERT_APPLY: {
-               InsetERT * inset = new InsetERT(params);
-               InsetERT::ERTStatus s;
-               InsetERTMailer::string2params(cmd.argument, s);
-               inset->status(bv, s);
-               return inset;
-       }
-
-       case LFUN_INDEX_APPLY: {
-               InsetCommandParams icp;
-               InsetCommandMailer::string2params(cmd.argument, icp);
-               return new InsetIndex(icp);
-       }
-
-       case LFUN_REF_APPLY: {
-               InsetCommandParams icp;
-               InsetCommandMailer::string2params(cmd.argument, icp);
-               return new InsetRef(icp, *bv->buffer());
-       }
+               } else if (name == "citation") {
+                       InsetCommandParams icp;
+                       InsetCommandMailer::string2params(cmd.argument, icp);
+                       InsetCitation * inset = new InsetCitation(icp);
+                       inset->setLoadingBuffer(bv->buffer(), false);
+                       return inset;
 
-       case LFUN_TOC_APPLY: {
-               InsetCommandParams icp;
-               InsetCommandMailer::string2params(cmd.argument, icp);
-               return new InsetTOC(icp);
-       }
+               } else if (name == "ert") {
+                       InsetERT * inset = new InsetERT(params);
+                       InsetERT::ERTStatus s;
+                       InsetERTMailer::string2params(cmd.argument, s);
+                       inset->status(bv, s);
+                       return inset;
 
-       case LFUN_URL_APPLY: {
-               InsetCommandParams icp;
-               InsetCommandMailer::string2params(cmd.argument, icp);
-               return new InsetUrl(icp);
+               } else if (name == "index") {
+                       InsetCommandParams icp;
+                       InsetCommandMailer::string2params(cmd.argument, icp);
+                       return new InsetIndex(icp);
+
+               } else if (name == "ref") {
+                       InsetCommandParams icp;
+                       InsetCommandMailer::string2params(cmd.argument, icp);
+                       return new InsetRef(icp, *bv->buffer());
+
+               } else if (name == "toc") {
+                       InsetCommandParams icp;
+                       InsetCommandMailer::string2params(cmd.argument, icp);
+                       return new InsetTOC(icp);
+
+               } else if (name == "url") {
+                       InsetCommandParams icp;
+                       InsetCommandMailer::string2params(cmd.argument, icp);
+                       return new InsetUrl(icp);
+               }
        }
+       break;
 
        default:
                break;
index cd85f95cb84cbf79346a27c5eb9855a2af8f9dac..eeaa7ff1c530eab1615934bcfa9d13d4f70a6dd6 100644 (file)
@@ -1,3 +1,21 @@
+2003-02-27  Angus Leeming  <leeming@lyx.org>
+
+       * ControlBibitem.C (c-tor):
+       * ControlBibtex.C (c-tor):
+       * ControlCitation.C (c-tor):
+       * ControlIndex.C (c-tor):
+       * ControlRef.C (c-tor):
+       * ControlToc.C (c-tor):
+       * ControlUrl.C (c-tor):
+       pass "name" to ControlCommand c-tor,
+       not an LFUN.
+
+       * ControlCommand.[Ch] (c-tor, dispatchParams): use "name" rather than a
+       specific LFUN.
+
+       * ControlERT.C (dispatchParams): use "name" rather than a
+       specific LFUN.
+
 2003-02-25  Dekel Tsur  <dekelts@tau.ac.il>
 
        * ControlDocument.C (apply): Call to setLanguage() after updating bp_;
index 42bb262102f400dc3ecc8c5611d9a47bbc796491..cc14a6bed5be0221f9660f6dd6e78e4493fe82b3 100644 (file)
@@ -15,5 +15,5 @@
 
 
 ControlBibitem::ControlBibitem(Dialog & d)
-       : ControlCommand(d, LFUN_BIBITEM_APPLY)
+       : ControlCommand(d, "bibitem")
 {}
index 7747a78ce6f80dfdf3001dd1e07db53639cd7134..68489fffa04923d0573c085eb4148ecca6ba5b65 100644 (file)
@@ -25,7 +25,7 @@ using std::pair;
 
 
 ControlBibtex::ControlBibtex(Dialog & d)
-       : ControlCommand(d, LFUN_BIBTEX_APPLY)
+       : ControlCommand(d, "bibtex")
 {}
 
 
index 844375bd048327199b906afb818987c76ae2626e..50c301b388cf535b30e7a6eff8774783bcfa14a3 100644 (file)
@@ -23,7 +23,7 @@ vector<biblio::CiteStyle> ControlCitation::citeStyles_;
 
 
 ControlCitation::ControlCitation(Dialog & d)
-       : ControlCommand(d, LFUN_CITATION_APPLY)
+       : ControlCommand(d, "citation")
 {}
 
 
index 5c632825c230719b6ed5281a0cd807133ef99943..2b93e47c20fa4ed9ce230dc64a217fe3e1a725b4 100644 (file)
@@ -17,9 +17,9 @@
 #include "insets/insetcommand.h"
 
 
-ControlCommand::ControlCommand(Dialog & dialog, kb_action ac)
+ControlCommand::ControlCommand(Dialog & dialog, string const & lfun_name)
        : Dialog::Controller(dialog),
-         action_(ac)
+         lfun_name_(lfun_name)
 {}
 
 
@@ -39,9 +39,10 @@ void ControlCommand::clearParams()
 
 void ControlCommand::dispatchParams()
 {
-       if (action_ == LFUN_NOACTION)
+       if (lfun_name_.empty())
                return;
 
-       FuncRequest fr(action_, InsetCommandMailer::params2string(params_));
-       kernel().dispatch(fr);
+       string const lfun = InsetCommandMailer::params2string(lfun_name_,
+                                                             params_);
+       kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
 }
index 4e9bde7162a6bb5154097ac01d55fda17cbe77a9..4a87e106855e94ab0ae2ec66567ee196297f873d 100644 (file)
 
 #include "Dialog.h"
 #include "insets/insetcommandparams.h"
-#include "commandtags.h" // kb_action
 
 
 class ControlCommand : public Dialog::Controller {
 public:
-       ///
-       ControlCommand(Dialog &, kb_action=LFUN_NOACTION);
+       /** LFUN_INSET_APPLY requires a name, "citation", "ref" etc so that
+           it knows what to do with the rest of the contents.
+           An empty name indicates that no action will occur on 'Apply'.
+        */
+       ControlCommand(Dialog &, string const & lfun_name = string());
        ///
        InsetCommandParams & params() { return params_; }
        ///
@@ -42,7 +44,7 @@ private:
        ///
        InsetCommandParams params_;
        /// Flags what action is taken by Kernel::dispatch()
-       kb_action const action_;
+       string const lfun_name_;
 };
 
 
index 3e641906949d78bc5b46f79ae3cb6bb5dbb24ad7..65e05a801dfb0c33e75177f76c324a9987b1eaed 100644 (file)
@@ -34,6 +34,6 @@ void ControlERT::clearParams()
 
 void ControlERT::dispatchParams()
 {
-       FuncRequest fr(LFUN_ERT_APPLY, InsetERTMailer::params2string(status_));
-       kernel().dispatch(fr);
+       string const lfun = InsetERTMailer::params2string("ert", status_);
+       kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
 }
index a80a3b3cced06b2779f224b53c68d8694c31e3f5..1b1a652c0c01fa2e915924dfb20547c6765efe62 100644 (file)
@@ -15,5 +15,5 @@
 
 
 ControlIndex::ControlIndex(Dialog & d)
-       : ControlCommand(d, LFUN_INDEX_APPLY)
+       : ControlCommand(d, "index")
 {}
index a681d7ec64ae39c75539bba5d41fd412de18abd9..b311e90624a3fcbcf7a941a21c96a0e6081057f8 100644 (file)
@@ -25,7 +25,7 @@ extern BufferList bufferlist;
 
 
 ControlRef::ControlRef(Dialog & d)
-       : ControlCommand(d, LFUN_REF_APPLY)
+       : ControlCommand(d, "ref")
 {}
 
 
index 17bf7caf79e94835f5d85ce9137c6663b8bbc5d3..f9daa70d044126afba42e1476babbaa3f0fa7602 100644 (file)
@@ -19,7 +19,7 @@ class Buffer;
 
 
 ControlToc::ControlToc(Dialog & d)
-       : ControlCommand(d, LFUN_TOC_APPLY)
+       : ControlCommand(d, "toc")
 {}
 
 
index c755bc80bf9fe198cf7d03a651f3eb0beef355fb..7dfe02e98ee211b5e8e78be524d0936b57c65610 100644 (file)
@@ -15,5 +15,5 @@
 
 
 ControlUrl::ControlUrl(Dialog & d)
-       : ControlCommand(d, LFUN_URL_APPLY)
+       : ControlCommand(d, "url")
 {}
index 5df802c5d14e20d98e38021e84bf49d2183590df..545d42418b27a40d8a10fe072be0d8c5aa3a5a5b 100644 (file)
@@ -1,3 +1,11 @@
+2003-02-27  Angus Leeming  <leeming@lyx.org>
+
+       * insetbibitem.C (localDispatch):
+       * insetbibtex.C (localDispatch):
+       * insetcommand.C:
+       * insetert:
+       collapse LFUN_XYZ_APPLY to LFUN_INSET_APPLY.
+
 2003-02-26  Angus Leeming  <leeming@lyx.org>
 
        * insetbibitem.[Ch] (localDispatch):
index 0bd4e14c0cd1f199d60174912827c456202ff0d7..74defd5eb938866f0ed714d071679a79a1ba79e5 100644 (file)
@@ -51,7 +51,7 @@ Inset * InsetBibitem::clone(Buffer const &, bool) const
 
 dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd)
 {
-       if (cmd.action != LFUN_BIBITEM_APPLY)
+       if (cmd.action != LFUN_INSET_APPLY)
                return UNDISPATCHED;
 
        InsetCommandParams p;
index c30a1048ebcc28c0565e5f2b4b3572eb3165f86c..a400dd1e8c0d6d3d86847100a804f0ffb88b7268 100644 (file)
@@ -48,7 +48,7 @@ InsetBibtex::~InsetBibtex()
 
 dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
 {
-       if (cmd.action != LFUN_BIBTEX_APPLY)
+       if (cmd.action != LFUN_INSET_APPLY)
                return UNDISPATCHED;
 
        InsetCommandParams p;
index 29f0f15fbb7d62778f6281b53584145df3d81b89..4069a825a5d2741c2b824fd2aafc2b8ed9694f18 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "frontends/Painter.h"
 
+#include "support/lstrings.h"
+
 #include "Lsstream.h"
 
 using std::ostream;
@@ -65,16 +67,8 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const
 
 dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
 {
-       switch (cmd.action) {
-       case LFUN_CITATION_APPLY:
-       case LFUN_INDEX_APPLY:
-       case LFUN_REF_APPLY:
-       case LFUN_TOC_APPLY:
-       case LFUN_URL_APPLY:
-               break;
-       default:
+       if (cmd.action != LFUN_INSET_APPLY)
                return UNDISPATCHED;
-       }
 
        InsetCommandParams p;
        InsetCommandMailer::string2params(cmd.argument, p);
@@ -96,7 +90,7 @@ InsetCommandMailer::InsetCommandMailer(string const & name,
 
 string const InsetCommandMailer::inset2string() const
 {
-       return params2string(inset_.params());
+       return params2string(name(), inset_.params());
 }
 
 
@@ -107,10 +101,13 @@ void InsetCommandMailer::string2params(string const & in,
        params.setContents(string());
        params.setOptions(string());
 
-       if (in.empty())
+       string name;
+       string body = split(in, name, ' ');
+
+       if (body.empty())
                return;
 
-       istringstream data(in);
+       istringstream data(body);
        LyXLex lex(0,0);
        lex.setStream(data);
 
@@ -119,9 +116,11 @@ void InsetCommandMailer::string2params(string const & in,
 
 
 string const
-InsetCommandMailer::params2string(InsetCommandParams const & params)
+InsetCommandMailer::params2string(string const & name,
+                                 InsetCommandParams const & params)
 {
        ostringstream data;
+       data << name << ' ';
        params.write(data);
        data << "\\end_inset\n";
 
index f5da108153399f6cffaa9b5b3a395895db0c8e7f..8d2e70b9f34f8c7f976314538034e1b575eeb315 100644 (file)
@@ -92,7 +92,8 @@ public:
        ///
        static void string2params(string const &, InsetCommandParams &);
        ///
-       static string const params2string(InsetCommandParams const &);
+       static string const params2string(string const & name,
+                                         InsetCommandParams const &);
 private:
        ///
        string const name_;
index 073b443d5ece776a9408ae377aa887047113349a..e7ead1e6a929f273df8926ac8d078e321b8b7039 100644 (file)
@@ -450,7 +450,7 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd)
        }
 
        switch (cmd.action) {
-       case LFUN_ERT_APPLY: {
+       case LFUN_INSET_APPLY: {
                if (!bv)
                        return UNDISPATCHED;
 
@@ -746,7 +746,7 @@ InsetERTMailer::InsetERTMailer(InsetERT & inset)
 
 string const InsetERTMailer::inset2string() const
 {
-       return params2string(inset_.status());
+       return params2string(name(), inset_.status());
 }
 
 
@@ -754,15 +754,19 @@ void InsetERTMailer::string2params(string const & in,
                                   InsetERT::ERTStatus & status)
 {
        status = InsetERT::Collapsed;
-       if (in.empty())
+
+       string name;
+       string body = split(in, name, ' ');
+
+       if (body.empty())
                return;
 
-       status = static_cast<InsetERT::ERTStatus>(strToInt(in));
+       status = static_cast<InsetERT::ERTStatus>(strToInt(body));
 }
 
 
 string const
-InsetERTMailer::params2string(InsetERT::ERTStatus status)
+InsetERTMailer::params2string(string const & name, InsetERT::ERTStatus status)
 {
-       return tostr(status);
+       return name + ' ' + tostr(status);
 }
index 9919ae12496aced93bff3d2e1fb291eb6cb17633..4f909b71b5b67bbd83f8ee9a76bef3ebdc4cf488 100644 (file)
@@ -167,7 +167,8 @@ public:
        ///
        static void string2params(string const &, InsetERT::ERTStatus &);
        ///
-       static string const params2string(InsetERT::ERTStatus);
+       static string const params2string(string const & name,
+                                         InsetERT::ERTStatus);
 private:
        ///
        string const name_;
index 904070eb038c87907eb9669cc56aa6eab0bf718a..c5a3f73c8feb7b62b70580a14dea72840da4b830 100644 (file)
@@ -561,12 +561,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_REF_INSERT:
                code = Inset::REF_CODE;
                break;
-       case LFUN_BIBTEX_APPLY:
-               code = Inset::BIBTEX_CODE;
-               break;
-       case LFUN_CITATION_APPLY:
-               code = Inset::CITE_CODE;
-               break;
        case LFUN_INDEX_INSERT:
                code = Inset::INDEX_CODE;
                break;
@@ -1050,7 +1044,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
        case LFUN_TOCVIEW:
        {
                InsetCommandParams p("tableofcontents");
-               string const data = InsetCommandMailer::params2string(p);
+               string const data = InsetCommandMailer::params2string("toc", p);
                owner->getDialogs().show("toc", data, 0);
                break;
        }
@@ -1368,12 +1362,13 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                    name == "toc" ||
                    name == "url") {
                        InsetCommandParams p(name);
-                       data = InsetCommandMailer::params2string(p);
+                       data = InsetCommandMailer::params2string(name, p);
                } else if (name == "citation") {
                        InsetCommandParams p("cite");
-                       data = InsetCommandMailer::params2string(p);
-//             } else if (name == "error" || name == "ert") {
-//                     // need do nothing special
+                       data = InsetCommandMailer::params2string(name, p);
+               } else if (name == "ert") {
+                       data = InsetERTMailer::params2string(name,
+                                                            InsetERT::Open);
                }
                 owner->getDialogs().show(name, data, 0);
        }
index 91f2501f8a6ad835597616d34b0df4e38d243535..22428eac0d81e45c8ecfacc4fac0b46470e978e2 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-27  Angus Leeming  <leeming@lyx.org>
+
+       * formulabase.C (localDispatch): collapse LFUN_REF_APPLY to
+       LFUN_INSET_APPLY.
+
+       * ref_inset.C (changes due to the change to LFUN_INSET_APPLY.
+
 2003-02-26  Angus Leeming  <leeming@lyx.org>
 
        * ref_inset.C (localDispatch): act only on receipt of LFUN_REF_APPLY.
index 82b88de5f9b5fd85dabfa30c9282b9c30941dc05..2e21443aa2fcb333b069d7a582f37ebdf94c624f 100644 (file)
@@ -797,23 +797,29 @@ 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: {
+       case LFUN_INSET_APPLY: {
+               string const name = cmd.getArg(0);
+               if (name != "ref") {
+                       result = UNDISPATCHED;
+                       break;
+               }
+
                InsetBase * base =
-                       bv->owner()->getDialogs().getOpenInset("ref");
+                       bv->owner()->getDialogs().getOpenInset(name);
 
                if (base) {
                        result = base->localDispatch(cmd);
                } else {
                        // Turn 'argument' into a temporary RefInset.
                        MathArray ar;
-                       if (string2RefInset(argument, ar)) {
+                       if (string2RefInset(cmd.argument, ar)) {
                                mathcursor->insert(ar);
                        } else {
                                result = UNDISPATCHED;
index 570c7cf4c5d5981fe67300f7c1841f1fd2f8a385..7848ab0b685d71911399876496435ded63925134 100644 (file)
@@ -54,6 +54,7 @@ RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
                                // Eventually trigger dialog with button 3
                                // not 1
                                ostringstream data;
+                               data << "ref LatexCommand ";
                                WriteStream wsdata(data);
                                write(wsdata);
                                wsdata << "\n\\end_inset\n\n";
@@ -132,7 +133,7 @@ int RefInset::docbook(std::ostream & os, bool) const
 
 dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
 {
-       if (cmd.action != LFUN_REF_APPLY)
+       if (cmd.action != LFUN_INSET_APPLY || cmd.getArg(0) != "ref")
                return UNDISPATCHED;
 
        MathArray ar;
@@ -150,10 +151,16 @@ dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
 
 bool string2RefInset(string const & str, MathArray & ar)
 {
-       // str comes with a head "LatexCommand " and a
+       string name;
+       string body = split(str, name, ' ');
+
+       if (name != "ref")
+               return false;
+
+       // body comes with a head "LatexCommand " and a
        // tail "\nend_inset\n\n". Strip them off.
        string trimmed;
-       string body = split(str, trimmed, ' ');
+       body = split(body, trimmed, ' ');
        split(body, trimmed, '\n');
 
        mathed_parse_cell(ar, trimmed);
index 679996ea185fa5eed0f448bcb5594ab69b6e5392..297504be48ec1b8621ccbeef1a9e3294cd4f0c33 100644 (file)
@@ -1592,14 +1592,14 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
        case LFUN_HTMLURL: {
                InsetCommandParams p("htmlurl");
-               string const data = InsetCommandMailer::params2string(p);
+               string const data = InsetCommandMailer::params2string("url", p);
                bv->owner()->getDialogs().show("url", data, 0);
                break;
        }
 
        case LFUN_URL: {
                InsetCommandParams p("url");
-               string const data = InsetCommandMailer::params2string(p);
+               string const data = InsetCommandMailer::params2string("url", p);
                bv->owner()->getDialogs().show("url", data, 0);
                break;
        }