#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "ControlCommand.h"
+#include "Kernel.h"
-#include "BufferView.h"
#include "funcrequest.h"
-#include "lyxfunc.h"
+#include "insets/insetcommand.h"
-ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
- : ControlInset<InsetCommand, InsetCommandParams>(lv, d),
- action_(ac)
+ControlCommand::ControlCommand(Dialog & dialog, string const & lfun_name)
+ : Dialog::Controller(dialog),
+ lfun_name_(lfun_name)
{}
-InsetCommandParams const ControlCommand::getParams(string const & arg)
-{
- InsetCommandParams params;
- params.setFromString(arg);
- return params;
-}
-
-
-InsetCommandParams const ControlCommand::getParams(InsetCommand const & inset)
+bool ControlCommand::initialiseParams(string const & data)
{
- return inset.params();
+ InsetCommandMailer::string2params(data, params_);
+ return true;
}
-void ControlCommand::applyParamsToInset()
+void ControlCommand::clearParams()
{
- inset()->setParams(params());
- bufferview()->updateInset(inset(), true);
+ params_.setCmdName(string());
+ params_.setOptions(string());
+ params_.setContents(string());
}
-void ControlCommand::applyParamsNoInset()
+void ControlCommand::dispatchParams()
{
- if (action_ == LFUN_NOACTION)
+ if (lfun_name_.empty())
return;
- lyxfunc().dispatch(FuncRequest(action_, params().getAsString()));
+
+ string const lfun = InsetCommandMailer::params2string(lfun_name_,
+ params_);
+ kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}