*
* \author Angus Leeming
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-
#include "ControlCommand.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)
-{}
+using std::string;
+namespace lyx {
+namespace frontend {
-InsetCommandParams const ControlCommand::getParams(string const & arg)
-{
- InsetCommandParams params;
- params.setFromString(arg);
- return params;
-}
+ControlCommand::ControlCommand(Dialog & dialog, string const & lfun_name)
+ : Dialog::Controller(dialog),
+ lfun_name_(lfun_name)
+{}
-InsetCommandParams const ControlCommand::getParams(InsetCommand const & inset)
+bool ControlCommand::initialiseParams(string const & data)
{
- return inset.params();
+ // The name passed with LFUN_INSET_APPLY is also the name
+ // used to identify the mailer.
+ InsetCommandMailer::string2params(lfun_name_, data, params_);
+ return true;
}
-void ControlCommand::applyParamsToInset()
+void ControlCommand::clearParams()
{
- inset()->setParams(params());
- bufferview()->updateInset(inset(), true);
+ params_ = InsetCommandParams();
}
-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(getLfun(), lfun));
}
+
+} // namespace frontend
+} // namespace lyx