]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcommand.C
The markDirty() and fitCursor() changes
[lyx.git] / src / insets / insetcommand.C
index 4069a825a5d2741c2b824fd2aafc2b8ed9694f18..dd2ae21cc49b19dd84af1a06c965dd2e71d2cea8 100644 (file)
@@ -67,21 +67,39 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const
 
 dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
 {
-       if (cmd.action != LFUN_INSET_APPLY)
-               return UNDISPATCHED;
-
-       InsetCommandParams p;
-       InsetCommandMailer::string2params(cmd.argument, p);
-       if (p.getCmdName().empty())
-               return UNDISPATCHED;
-
-       setParams(p);
-       if (view())
-               view()->updateInset(this, true);
-
-       return DISPATCHED;
+       dispatch_result result = UNDISPATCHED;
+
+       switch (cmd.action) {
+       case LFUN_INSET_MODIFY: {
+               InsetCommandParams p;
+               InsetCommandMailer::string2params(cmd.argument, p);
+               if (p.getCmdName().empty())
+                       break;
+
+               setParams(p);
+               cmd.view()->updateInset(this);
+               result = DISPATCHED;
+       }
+       break;
+
+       case LFUN_INSET_DIALOG_UPDATE: {
+               InsetCommandMailer mailer(cmd.argument, *this);
+               mailer.updateDialog(cmd.view());
+       }
+       break;
+
+       case LFUN_MOUSE_RELEASE:
+               edit(cmd.view(), cmd.x, cmd.y, cmd.button());
+               break;
+
+       default:
+               break;
+       }
+
+       return result;
 }
 
+
 InsetCommandMailer::InsetCommandMailer(string const & name,
                                       InsetCommand & inset)
        : name_(name), inset_(inset)
@@ -101,17 +119,26 @@ void InsetCommandMailer::string2params(string const & in,
        params.setContents(string());
        params.setOptions(string());
 
-       string name;
-       string body = split(in, name, ' ');
-
-       if (body.empty())
-               return;
-
-       istringstream data(body);
+       istringstream data(in);
        LyXLex lex(0,0);
        lex.setStream(data);
 
-       params.read(lex);
+       if (lex.isOK()) {
+               lex.next();
+               string const name = lex.getString();
+       }
+
+       // This is part of the inset proper that is usually swallowed
+       // by Buffer::readInset
+       if (lex.isOK()) {
+               lex.next();
+               string const token = lex.getString();
+               if (token != "LatexCommand")
+                       return;
+       }
+       if (lex.isOK()) {
+               params.read(lex);
+       }
 }