+ case LFUN_DIALOG_SHOW_NEW_INSET: {
+ string const name = cmd.getArg(0);
+ string data = trim(to_utf8(cmd.argument()).substr(name.size()));
+ if (decodeInsetParam(name, data, buffer_))
+ lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, name + " " + data));
+ else
+ lyxerr << "Inset type '" << name <<
+ "' not recognized in LFUN_DIALOG_SHOW_NEW_INSET" << endl;
+ break;
+ }
+
+ case LFUN_CITATION_INSERT: {
+ if (argument.empty()) {
+ lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
+ break;
+ }
+ // we can have one optional argument, delimited by '|'
+ // citation-insert <key>|<text_before>
+ // this should be enhanced to also support text_after
+ // and citation style
+ string arg = argument;
+ string opt1;
+ if (contains(argument, "|")) {
+ arg = token(argument, '|', 0);
+ opt1 = token(argument, '|', 1);
+ }
+ InsetCommandParams icp(CITE_CODE);
+ icp["key"] = from_utf8(arg);
+ if (!opt1.empty())
+ icp["before"] = from_utf8(opt1);
+ string icstr = InsetCommand::params2string(icp);
+ FuncRequest fr(LFUN_INSET_INSERT, icstr);
+ lyx::dispatch(fr);
+ break;
+ }
+
+ case LFUN_INSET_APPLY: {
+ string const name = cmd.getArg(0);
+ Inset * inset = editedInset(name);
+ if (!inset) {
+ FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
+ lyx::dispatch(fr);
+ break;
+ }
+ // put cursor in front of inset.
+ if (!setCursorFromInset(inset)) {
+ LASSERT(false, break);
+ }
+ cur.recordUndo();
+ FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
+ inset->dispatch(cur, fr);
+ dr.screenUpdate(cur.result().screenUpdate());
+ if (cur.result().needBufferUpdate())
+ dr.forceBufferUpdate();
+ break;
+ }
+