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;
}
}
- 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(),
+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.
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 }
};
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 */
};
#include "insets/insettoc.h"
#include "insets/inseturl.h"
#include "insets/insetwrap.h"
+
#include "frontends/Dialogs.h"
#include "frontends/LyXView.h"
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;
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;
+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_;
ControlBibitem::ControlBibitem(Dialog & d)
- : ControlCommand(d, LFUN_BIBITEM_APPLY)
+ : ControlCommand(d, "bibitem")
{}
ControlBibtex::ControlBibtex(Dialog & d)
- : ControlCommand(d, LFUN_BIBTEX_APPLY)
+ : ControlCommand(d, "bibtex")
{}
ControlCitation::ControlCitation(Dialog & d)
- : ControlCommand(d, LFUN_CITATION_APPLY)
+ : ControlCommand(d, "citation")
{}
#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)
{}
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));
}
#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_; }
///
///
InsetCommandParams params_;
/// Flags what action is taken by Kernel::dispatch()
- kb_action const action_;
+ string const lfun_name_;
};
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));
}
ControlIndex::ControlIndex(Dialog & d)
- : ControlCommand(d, LFUN_INDEX_APPLY)
+ : ControlCommand(d, "index")
{}
ControlRef::ControlRef(Dialog & d)
- : ControlCommand(d, LFUN_REF_APPLY)
+ : ControlCommand(d, "ref")
{}
ControlToc::ControlToc(Dialog & d)
- : ControlCommand(d, LFUN_TOC_APPLY)
+ : ControlCommand(d, "toc")
{}
ControlUrl::ControlUrl(Dialog & d)
- : ControlCommand(d, LFUN_URL_APPLY)
+ : ControlCommand(d, "url")
{}
+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):
dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd)
{
- if (cmd.action != LFUN_BIBITEM_APPLY)
+ if (cmd.action != LFUN_INSET_APPLY)
return UNDISPATCHED;
InsetCommandParams p;
dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
{
- if (cmd.action != LFUN_BIBTEX_APPLY)
+ if (cmd.action != LFUN_INSET_APPLY)
return UNDISPATCHED;
InsetCommandParams p;
#include "frontends/Painter.h"
+#include "support/lstrings.h"
+
#include "Lsstream.h"
using std::ostream;
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);
string const InsetCommandMailer::inset2string() const
{
- return params2string(inset_.params());
+ return params2string(name(), inset_.params());
}
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);
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";
///
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_;
}
switch (cmd.action) {
- case LFUN_ERT_APPLY: {
+ case LFUN_INSET_APPLY: {
if (!bv)
return UNDISPATCHED;
string const InsetERTMailer::inset2string() const
{
- return params2string(inset_.status());
+ return params2string(name(), inset_.status());
}
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);
}
///
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_;
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;
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;
}
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);
}
+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.
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;
// Eventually trigger dialog with button 3
// not 1
ostringstream data;
+ data << "ref LatexCommand ";
WriteStream wsdata(data);
write(wsdata);
wsdata << "\n\\end_inset\n\n";
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;
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);
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;
}