Define InsetCommand::localDispatch and use it for LFUN_REF_APPLY.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6281 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-02-26 15:01:10 +00:00
parent b4a440e1c2
commit fa09ff85c4
5 changed files with 41 additions and 15 deletions

View File

@ -1312,25 +1312,23 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
break;
case LFUN_REF_APPLY: {
InsetCommandParams params;
InsetCommandMailer::string2params(ev.argument, params);
dispatch_result result = UNDISPATCHED;
InsetBase * base = owner_->getDialogs().getOpenInset("ref");
InsetRef * inset = 0;
Inset * inset = 0;
if (base) {
inset = dynamic_cast<InsetRef *>(base);
if (!inset)
break;
inset->setParams(params);
// This works both for 'original' and 'mathed' insets.
result = base->localDispatch(ev);
} else {
InsetRef * inset = new InsetRef(params, *buffer_);
InsetCommandParams params;
InsetCommandMailer::string2params(ev.argument, params);
inset = new InsetRef(params, *buffer_);
if (!insertInset(inset)) {
delete inset;
break;
result = UNDISPATCHED;
}
updateInset(inset, true);
}
updateInset(inset, true);
}
break;

View File

@ -1,3 +1,8 @@
2003-02-26 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (dispatch): use InsetCommand::localDispatch for
LFUN_REF_APPLY.
2003-02-25 John Levon <levon@movementarian.org>
* ispell.C: give the forked command a more accurate name

View File

@ -1,3 +1,7 @@
2003-02-26 Angus Leeming <leeming@lyx.org>
* insetcommand.[Ch] (localDispatch): new method.
2003-02-26 Angus Leeming <leeming@lyx.org>
* insetinclude.C (draw): cache the BufferView* using cache not

View File

@ -11,13 +11,16 @@
#include <config.h>
#include "insetcommand.h"
#include "BufferView.h"
#include "debug.h"
#include "frontends/Painter.h"
#include "Lsstream.h"
#include "funcrequest.h"
#include "lyxlex.h"
#include "frontends/Painter.h"
#include "Lsstream.h"
using std::ostream;
using std::endl;
@ -61,6 +64,20 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const
}
dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
{
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
return UNDISPATCHED;
setParams(p);
if (view())
view()->updateInset(this, true);
return DISPATCHED;
}
InsetCommandMailer::InsetCommandMailer(string const & name,
InsetCommand & inset)
: name_(name), inset_(inset)

View File

@ -70,6 +70,8 @@ public:
InsetCommandParams const & params() const { return p_; }
///
void setParams(InsetCommandParams const &);
/// small wrapper for the time being
virtual dispatch_result localDispatch(FuncRequest const & cmd);
private:
///