Add locaDispatch methods to various inset classes. refactor the LFUN_XYZ_APPLY

code but do not yet attempt to collapse them into LFUN_DIALOG_APPLY.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6289 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-02-26 19:28:38 +00:00
parent c6c5eb530c
commit 86e2d69f18
12 changed files with 361 additions and 344 deletions

View File

@ -9,51 +9,43 @@
#include <config.h> #include <config.h>
#include "BufferView_pimpl.h" #include "BufferView_pimpl.h"
#include "frontends/WorkArea.h" #include "bufferlist.h"
#include "frontends/screen.h" #include "bufferview_funcs.h"
#include "frontends/LyXScreenFactory.h" #include "commandtags.h"
#include "frontends/WorkAreaFactory.h" #include "debug.h"
#include "frontends/Dialogs.h" #include "factory.h"
#include "frontends/Alert.h" #include "FloatList.h"
#include "frontends/FileDialog.h" #include "funcrequest.h"
#include "frontends/mouse_state.h" #include "gettext.h"
#include "intl.h"
#include "iterators.h"
#include "lyx_cb.h" // added for Dispatch functions
#include "lyx_main.h"
#include "lyxfind.h"
#include "lyxfunc.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxrc.h"
#include "lyxrow.h" #include "lyxrow.h"
#include "paragraph.h" #include "paragraph.h"
#include "frontends/LyXView.h"
#include "commandtags.h"
#include "lyxfunc.h"
#include "debug.h"
#include "bufferview_funcs.h"
#include "TextCache.h"
#include "bufferlist.h"
#include "lyxrc.h"
#include "intl.h"
// added for Dispatch functions
#include "lyx_cb.h"
#include "lyx_main.h"
#include "FloatList.h"
#include "gettext.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "TextCache.h"
#include "undo_funcs.h" #include "undo_funcs.h"
#include "funcrequest.h"
#include "iterators.h"
#include "lyxfind.h"
#include "insets/insetbibitem.h"
#include "insets/insetbibtex.h"
#include "insets/insetcite.h"
#include "insets/insetert.h"
#include "insets/insetfloatlist.h" #include "insets/insetfloatlist.h"
#include "insets/insetgraphics.h" #include "insets/insetgraphics.h"
#include "insets/insetinclude.h" #include "insets/insetinclude.h"
#include "insets/insetindex.h"
#include "insets/insetlatexaccent.h"
#include "insets/insetmarginal.h"
#include "insets/insetref.h" #include "insets/insetref.h"
#include "insets/insettext.h" #include "insets/insettext.h"
#include "insets/insettoc.h"
#include "insets/inseturl.h" #include "frontends/Alert.h"
#include "frontends/Dialogs.h"
#include "frontends/FileDialog.h"
#include "frontends/LyXView.h"
#include "frontends/LyXScreenFactory.h"
#include "frontends/mouse_state.h"
#include "frontends/screen.h"
#include "frontends/WorkArea.h"
#include "frontends/WorkAreaFactory.h"
#include "mathed/formulabase.h" #include "mathed/formulabase.h"
@ -969,8 +961,12 @@ void BufferView::Pimpl::trackChanges()
} }
bool BufferView::Pimpl::dispatch(FuncRequest const & ev) bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
{ {
// Make sure that the cached BufferView is correct.
FuncRequest ev = ev_in;
ev.setView(bv_);
lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:" lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
<< " action[" << ev.action << ']' << " action[" << ev.action << ']'
<< " arg[" << ev.argument << ']' << " arg[" << ev.argument << ']'
@ -1169,212 +1165,71 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
case LFUN_MATH_DISPLAY: // Open or create a displayed math inset case LFUN_MATH_DISPLAY: // Open or create a displayed math inset
case LFUN_MATH_MODE: // Open or create an inlined math inset case LFUN_MATH_MODE: // Open or create an inlined math inset
case LFUN_GREEK: // Insert a single greek letter case LFUN_GREEK: // Insert a single greek letter
mathDispatch(FuncRequest(bv_, ev.action, ev.argument)); mathDispatch(ev);
break; break;
case LFUN_BIBITEM_APPLY: { case LFUN_BIBITEM_APPLY:
InsetCommandParams params; case LFUN_BIBTEX_APPLY:
InsetCommandMailer::string2params(ev.argument, params); case LFUN_CITATION_APPLY:
case LFUN_ERT_APPLY:
InsetBase * base = case LFUN_INDEX_APPLY:
owner_->getDialogs().getOpenInset("bibitem"); case LFUN_REF_APPLY:
InsetBibitem * inset = 0; case LFUN_TOC_APPLY:
if (base) { case LFUN_URL_APPLY: {
inset = dynamic_cast<InsetBibitem *>(base); string name;
if (!inset) switch (ev.action) {
break; case LFUN_BIBITEM_APPLY:
name = "bibitem";
if (params.getContents() != break;
inset->params().getContents()) { case LFUN_BIBTEX_APPLY:
bv_->ChangeCitationsIfUnique( name = "bibtex";
inset->params().getContents(), break;
params.getContents()); case LFUN_CITATION_APPLY:
} name = "citation";
inset->setParams(params); break;
} else { case LFUN_ERT_APPLY:
inset = new InsetBibitem(params); name = "ert";
if (!insertInset(inset)) { break;
delete inset; case LFUN_INDEX_APPLY:
break; name = "index";
} break;
} case LFUN_REF_APPLY:
updateInset(inset, true); name = "ref";
break;
// We need to do a redraw because the maximum case LFUN_TOC_APPLY:
// InsetBibitem width could have changed name = "toc";
#warning please check you mean repaint() not update(), break;
#warning and whether the repaint() is needed at all case LFUN_URL_APPLY:
bv_->repaint(); name = "url";
bv_->fitCursor(); break;
} default:
break; break;
case LFUN_BIBTEX_APPLY: {
InsetCommandParams params;
InsetCommandMailer::string2params(ev.argument, params);
InsetBase * base =
owner_->getDialogs().getOpenInset("bibtex");
InsetBibtex * inset = 0;
if (base) {
inset = dynamic_cast<InsetBibtex *>(base);
if (!inset)
break;
if (params.getContents() !=
inset->params().getContents()) {
bv_->ChangeCitationsIfUnique(
inset->params().getContents(),
params.getContents());
}
inset->setParams(params);
} else {
inset = new InsetBibtex(params);
if (!insertInset(inset)) {
delete inset;
break;
}
}
updateInset(inset, true);
}
break;
case LFUN_CITATION_APPLY: {
InsetCommandParams params;
InsetCommandMailer::string2params(ev.argument, params);
InsetBase * base =
owner_->getDialogs().getOpenInset("citation");
InsetCitation * inset = 0;
if (base) {
inset = dynamic_cast<InsetCitation *>(base);
if (!inset)
break;
inset->setParams(params);
} else {
inset = new InsetCitation(params);
if (!insertInset(inset)) {
delete inset;
break;
} else {
inset->setLoadingBuffer(bv_->buffer(), false);
}
}
updateInset(inset, true);
}
break;
case LFUN_ERT_APPLY: {
InsetBase * base = owner_->getDialogs().getOpenInset("ert");
InsetERT * inset = 0;
if (base) {
inset = dynamic_cast<InsetERT *>(base);
if (!inset)
break;
} else {
inset = new InsetERT(bv_->buffer()->params);
if (!insertInset(inset)) {
delete inset;
break;
}
} }
InsetERT::ERTStatus status; InsetBase * base = owner_->getDialogs().getOpenInset(name);
InsetERTMailer::string2params(ev.argument, status);
inset->status(bv_, status);
updateInset(inset, true);
}
break;
case LFUN_INDEX_APPLY: {
InsetCommandParams params;
InsetCommandMailer::string2params(ev.argument, params);
InsetBase * base = owner_->getDialogs().getOpenInset("index");
InsetIndex * inset = 0;
if (base) {
inset = dynamic_cast<InsetIndex *>(base);
if (!inset)
break;
inset->setParams(params);
} else {
InsetIndex * inset = new InsetIndex(params);
if (!insertInset(inset)) {
delete inset;
break;
}
}
updateInset(inset, true);
}
break;
case LFUN_REF_APPLY: {
dispatch_result result = UNDISPATCHED;
InsetBase * base = owner_->getDialogs().getOpenInset("ref");
Inset * inset = 0; Inset * inset = 0;
if (base) { if (base) {
// This works both for 'original' and 'mathed' insets. // This works both for 'original' and 'mathed' insets.
result = base->localDispatch(ev); // Note that the localDispatch performs updateInset
// also.
base->localDispatch(ev);
} else { } else {
InsetCommandParams params; inset = createInset(ev);
InsetCommandMailer::string2params(ev.argument, params); if (inset && insertInset(inset)) {
updateInset(inset, true);
inset = new InsetRef(params, *buffer_); } else {
if (!insertInset(inset)) {
delete inset; delete inset;
result = UNDISPATCHED;
}
updateInset(inset, true);
}
}
break;
case LFUN_TOC_APPLY: {
InsetCommandParams params;
InsetCommandMailer::string2params(ev.argument, params);
InsetBase * base = owner_->getDialogs().getOpenInset("toc");
InsetTOC * inset = 0;
if (base) {
InsetTOC * inset = dynamic_cast<InsetTOC *>(base);
if (!inset)
break;
inset->setParams(params);
} else {
InsetTOC * inset = new InsetTOC(params);
if (!insertInset(inset)) {
delete inset;
break;
} }
} }
updateInset(inset, true);
}
break;
case LFUN_URL_APPLY: { if (ev.action == LFUN_BIBITEM_APPLY) {
InsetCommandParams params; // We need to do a redraw because the maximum
InsetCommandMailer::string2params(ev.argument, params); // InsetBibitem width could have changed
#warning please check you mean repaint() not update(),
InsetBase * base = owner_->getDialogs().getOpenInset("url"); #warning and whether the repaint() is needed at all
InsetUrl * inset = 0; bv_->repaint();
if (base) { bv_->fitCursor();
inset = dynamic_cast<InsetUrl *>(base);
if (!inset)
break;
inset->setParams(params);
} else {
InsetUrl * inset = new InsetUrl(params);
if (!insertInset(inset)) {
delete inset;
break;
}
} }
updateInset(inset, true);
} }
break; break;

View File

@ -1,3 +1,12 @@
2003-02-26 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (dispatch): callapse the various LFUN_XYZ_APPLY
blocks together.
Rearrange the ~includes. Strip out the unnecessary ones.
* factory.C (createInset): reformat.
create new insets for the various LFUN_XYZ_APPLY lfuns.
2003-02-26 John Levon <levon@movementarian.org> 2003-02-26 John Levon <levon@movementarian.org>
* lyxrow.h: * lyxrow.h:

View File

@ -19,7 +19,9 @@
#include "lyxtext.h" #include "lyxtext.h"
#include "insets/insetbibitem.h" #include "insets/insetbibitem.h"
#include "insets/insetbibtex.h"
#include "insets/insetcaption.h" #include "insets/insetcaption.h"
#include "insets/insetcite.h"
#include "insets/insetert.h" #include "insets/insetert.h"
#include "insets/insetexternal.h" #include "insets/insetexternal.h"
#include "insets/insetfloat.h" #include "insets/insetfloat.h"
@ -49,123 +51,175 @@ Inset * createInset(FuncRequest const & cmd)
BufferParams const & params = bv->buffer()->params; BufferParams const & params = bv->buffer()->params;
switch (cmd.action) { switch (cmd.action) {
case LFUN_INSET_MINIPAGE:
return new InsetMinipage(params);
case LFUN_INSET_MINIPAGE: case LFUN_INSERT_NOTE:
return new InsetMinipage(params); return new InsetNote(params);
case LFUN_INSERT_NOTE: case LFUN_INSET_ERT:
return new InsetNote(params); return new InsetERT(params);
case LFUN_INSET_ERT: case LFUN_INSET_EXTERNAL:
return new InsetERT(params); return new InsetExternal;
case LFUN_INSET_EXTERNAL: case LFUN_INSET_FOOTNOTE:
return new InsetExternal; return new InsetFoot(params);
case LFUN_INSET_FOOTNOTE: case LFUN_INSET_MARGINAL:
return new InsetFoot(params); return new InsetMarginal(params);
case LFUN_INSET_MARGINAL: case LFUN_INSET_OPTARG:
return new InsetMarginal(params); return new InsetOptArg(params);
case LFUN_INSET_OPTARG: case LFUN_INSERT_BIBITEM:
return new InsetOptArg(params); return new InsetBibitem(InsetCommandParams("bibitem"));
case LFUN_INSERT_BIBITEM: case LFUN_INSET_FLOAT:
return new InsetBibitem(InsetCommandParams("bibitem")); // check if the float type exists
if (params.getLyXTextClass().floats().typeExist(cmd.argument))
return new InsetFloat(params, cmd.argument);
lyxerr << "Non-existent float type: " << cmd.argument << endl;
return 0;
case LFUN_INSET_FLOAT: case LFUN_INSET_WIDE_FLOAT:
// check if the float type exists // check if the float type exists
if (params.getLyXTextClass().floats().typeExist(cmd.argument)) if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
return new InsetFloat(params, cmd.argument); InsetFloat * p = new InsetFloat(params, cmd.argument);
lyxerr << "Non-existent float type: " << cmd.argument << endl; p->wide(true, params);
return 0;
case LFUN_INSET_WIDE_FLOAT:
// check if the float type exists
if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
InsetFloat * p = new InsetFloat(params, cmd.argument);
p->wide(true, params);
}
lyxerr << "Non-existent float type: " << cmd.argument << endl;
return 0;
case LFUN_INSET_WRAP:
if (cmd.argument == "figure")
return new InsetWrap(params, cmd.argument);
lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
return 0;
case LFUN_INDEX_INSERT: {
// Try and generate a valid index entry.
InsetCommandParams icp("index");
string const contents = cmd.argument.empty() ?
bv->getLyXText()->getStringToIndex(bv) :
cmd.argument;
icp.setContents(contents);
string data = InsetCommandMailer::params2string(icp);
LyXView * lv = bv->owner();
if (icp.getContents().empty()) {
lv->getDialogs().show("index", data, 0);
} else {
FuncRequest fr(bv, LFUN_INDEX_APPLY, data);
lv->dispatch(fr);
}
return 0;
} }
lyxerr << "Non-existent float type: " << cmd.argument << endl;
return 0;
case LFUN_TABULAR_INSERT: case LFUN_INSET_WRAP:
if (!cmd.argument.empty()) { if (cmd.argument == "figure")
int r = 2; return new InsetWrap(params, cmd.argument);
int c = 2; lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
::sscanf(cmd.argument.c_str(),"%d%d", &r, &c); return 0;
return new InsetTabular(*bv->buffer(), r, c);
}
bv->owner()->getDialogs().showTabularCreate();
return 0;
case LFUN_INSET_CAPTION: case LFUN_INDEX_INSERT: {
if (bv->theLockingInset()) { // Try and generate a valid index entry.
lyxerr << "Locking inset code: " InsetCommandParams icp("index");
<< static_cast<int>(bv->theLockingInset()->lyxCode()); string const contents = cmd.argument.empty() ?
InsetCaption * inset = new InsetCaption(params); bv->getLyXText()->getStringToIndex(bv) :
inset->setOwner(bv->theLockingInset()); cmd.argument;
inset->setAutoBreakRows(true); icp.setContents(contents);
inset->setDrawFrame(0, InsetText::LOCKED);
inset->setFrameColor(0, LColor::captionframe);
return inset;
}
return 0;
case LFUN_INDEX_PRINT: string data = InsetCommandMailer::params2string(icp);
return new InsetPrintIndex(InsetCommandParams("printindex")); LyXView * lv = bv->owner();
case LFUN_TOC_INSERT: if (icp.getContents().empty()) {
return new InsetTOC(InsetCommandParams("tableofcontents")); lv->getDialogs().show("index", data, 0);
} else {
case LFUN_PARENTINSERT: FuncRequest fr(bv, LFUN_INDEX_APPLY, data);
return new InsetParent( lv->dispatch(fr);
InsetCommandParams("lyxparent", cmd.argument), *bv->buffer());
case LFUN_INSERT_URL:
{
InsetCommandParams p;
p.setFromString(cmd.argument);
return new InsetUrl(p);
} }
return 0;
#if 0
case LFUN_INSET_LIST:
return new InsetList;
case LFUN_INSET_THEOREM:
return new InsetTheorem;
#endif
default:
break;
} }
case LFUN_TABULAR_INSERT:
if (!cmd.argument.empty()) {
int r = 2;
int c = 2;
::sscanf(cmd.argument.c_str(),"%d%d", &r, &c);
return new InsetTabular(*bv->buffer(), r, c);
}
bv->owner()->getDialogs().showTabularCreate();
return 0;
case LFUN_INSET_CAPTION:
if (bv->theLockingInset()) {
lyxerr << "Locking inset code: "
<< static_cast<int>(bv->theLockingInset()->lyxCode());
InsetCaption * inset = new InsetCaption(params);
inset->setOwner(bv->theLockingInset());
inset->setAutoBreakRows(true);
inset->setDrawFrame(0, InsetText::LOCKED);
inset->setFrameColor(0, LColor::captionframe);
return inset;
}
return 0;
case LFUN_INDEX_PRINT:
return new InsetPrintIndex(InsetCommandParams("printindex"));
case LFUN_TOC_INSERT:
return new InsetTOC(InsetCommandParams("tableofcontents"));
case LFUN_PARENTINSERT:
return new InsetParent(
InsetCommandParams("lyxparent", cmd.argument), *bv->buffer());
case LFUN_INSERT_URL:
{
InsetCommandParams p;
p.setFromString(cmd.argument);
return new InsetUrl(p);
}
#if 0
case LFUN_INSET_LIST:
return new InsetList;
case LFUN_INSET_THEOREM:
return new InsetTheorem;
#endif
case LFUN_BIBITEM_APPLY: {
InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp);
return new InsetBibitem(icp);
}
case LFUN_BIBTEX_APPLY: {
InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp);
return new InsetBibtex(icp);
}
case LFUN_CITATION_APPLY: {
InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp);
InsetCitation * inset = new InsetCitation(icp);
inset->setLoadingBuffer(bv->buffer(), false);
return inset;
}
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());
}
case LFUN_TOC_APPLY: {
InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp);
return new InsetTOC(icp);
}
case LFUN_URL_APPLY: {
InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp);
return new InsetUrl(icp);
}
default:
break;
}
return 0; return 0;
} }

View File

@ -1,3 +1,15 @@
2003-02-26 Angus Leeming <leeming@lyx.org>
* insetbibitem.[Ch] (localDispatch):
* insetbibtex.[Ch] (localDispatch):
new method. Modify inset on receipt of LFUN_XYZ_APPLY.
* insetcommand.C (localDispatch):
act only on receipt of LFUN_XYZ_APPLY.
* insetert.C (localDispatch): reformat.
add LFUN_XYZ_APPLY to the switch.
2003-02-26 John Levon <levon@movementarian.org> 2003-02-26 John Levon <levon@movementarian.org>
* insettext.C: use RowPainter * insettext.C: use RowPainter

View File

@ -12,6 +12,7 @@
#include "insetbibitem.h" #include "insetbibitem.h"
#include "buffer.h" #include "buffer.h"
#include "BufferView.h" #include "BufferView.h"
#include "funcrequest.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "frontends/font_metrics.h" #include "frontends/font_metrics.h"
@ -48,6 +49,29 @@ Inset * InsetBibitem::clone(Buffer const &, bool) const
} }
dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd)
{
if (cmd.action != LFUN_BIBITEM_APPLY)
return UNDISPATCHED;
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
return UNDISPATCHED;
if (view() && p.getContents() != params().getContents()) {
view()->ChangeCitationsIfUnique(params().getContents(),
p.getContents());
}
setParams(p);
if (view())
view()->updateInset(this, true);
return DISPATCHED;
}
void InsetBibitem::setCounter(int c) void InsetBibitem::setCounter(int c)
{ {
counter = c; counter = c;

View File

@ -30,6 +30,8 @@ public:
~InsetBibitem(); ~InsetBibitem();
/// ///
Inset * clone(Buffer const &, bool same_id = false) const; Inset * clone(Buffer const &, bool same_id = false) const;
/// small wrapper for the time being
virtual dispatch_result localDispatch(FuncRequest const & cmd);
/** Currently \bibitem is used as a LyX2.x command, /** Currently \bibitem is used as a LyX2.x command,
so we need this method. so we need this method.
*/ */

View File

@ -12,7 +12,9 @@
#include "insetbibtex.h" #include "insetbibtex.h"
#include "buffer.h" #include "buffer.h"
#include "BufferView.h"
#include "debug.h" #include "debug.h"
#include "funcrequest.h"
#include "gettext.h" #include "gettext.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -44,6 +46,28 @@ InsetBibtex::~InsetBibtex()
} }
dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
{
if (cmd.action != LFUN_BIBTEX_APPLY)
return UNDISPATCHED;
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
return UNDISPATCHED;
if (view() && p.getContents() != params().getContents()) {
view()->ChangeCitationsIfUnique(params().getContents(),
p.getContents());
}
setParams(p);
if (view())
view()->updateInset(this, true);
return DISPATCHED;
}
string const InsetBibtex::getScreenLabel(Buffer const *) const string const InsetBibtex::getScreenLabel(Buffer const *) const
{ {
return _("BibTeX Generated References"); return _("BibTeX Generated References");

View File

@ -30,6 +30,8 @@ public:
Inset * clone(Buffer const &, bool same_id = false) const { Inset * clone(Buffer const &, bool same_id = false) const {
return new InsetBibtex(params(), same_id); return new InsetBibtex(params(), same_id);
} }
/// small wrapper for the time being
virtual dispatch_result localDispatch(FuncRequest const & cmd);
/// ///
string const getScreenLabel(Buffer const *) const; string const getScreenLabel(Buffer const *) const;
/// ///

View File

@ -65,6 +65,17 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const
dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) 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:
return UNDISPATCHED;
}
InsetCommandParams p; InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p); InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty()) if (p.getCmdName().empty())

View File

@ -450,24 +450,37 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd)
} }
switch (cmd.action) { switch (cmd.action) {
case LFUN_MOUSE_PRESS: case LFUN_ERT_APPLY: {
lfunMousePress(cmd); if (!bv)
return DISPATCHED; return UNDISPATCHED;
case LFUN_MOUSE_MOTION: InsetERT::ERTStatus status_;
lfunMouseMotion(cmd); InsetERTMailer::string2params(cmd.argument, status_);
return DISPATCHED;
case LFUN_MOUSE_RELEASE: status(bv, status_);
lfunMouseRelease(cmd); bv->updateInset(this, true);
return DISPATCHED; return DISPATCHED;
}
break;
case LFUN_MOUSE_PRESS:
lfunMousePress(cmd);
return DISPATCHED;
case LFUN_LAYOUT: case LFUN_MOUSE_MOTION:
bv->owner()->setLayout(inset.paragraph()->layout()->name()); lfunMouseMotion(cmd);
break; return DISPATCHED;
default: case LFUN_MOUSE_RELEASE:
result = InsetCollapsable::localDispatch(cmd); lfunMouseRelease(cmd);
return DISPATCHED;
case LFUN_LAYOUT:
bv->owner()->setLayout(inset.paragraph()->layout()->name());
break;
default:
result = InsetCollapsable::localDispatch(cmd);
} }
switch (cmd.action) { switch (cmd.action) {

View File

@ -1,3 +1,7 @@
2003-02-26 Angus Leeming <leeming@lyx.org>
* ref_inset.C (localDispatch): act only on receipt of LFUN_REF_APPLY.
2003-02-26 Angus Leeming <leeming@lyx.org> 2003-02-26 Angus Leeming <leeming@lyx.org>
* formula.C (draw): cache the BufferView* using cache not * formula.C (draw): cache the BufferView* using cache not

View File

@ -132,11 +132,18 @@ int RefInset::docbook(std::ostream & os, bool) const
dispatch_result RefInset::localDispatch(FuncRequest const & cmd) dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
{ {
if (cmd.action != LFUN_REF_APPLY)
return UNDISPATCHED;
MathArray ar; MathArray ar;
if (!string2RefInset(cmd.argument, ar)) if (!string2RefInset(cmd.argument, ar))
return UNDISPATCHED; return UNDISPATCHED;
*this = *ar[0].nucleus()->asRefInset(); *this = *ar[0].nucleus()->asRefInset();
// if (cmd.view())
// // This does not compile because updateInset expects
// // an Inset* and 'this' isn't.
// cmd.view()->updateInset(this, true);
return DISPATCHED; return DISPATCHED;
} }