#include <config.h>
#include "FuncRequest.h"
+#include "LyXAction.h"
+
+#include "support/lstrings.h"
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
+using namespace lyx::support;
namespace lyx {
}
-void splitArg(vector<string> & args, string const & str)
+namespace {
+
+void splitArg(vector<string> & args, string const & str, unsigned int max)
{
istringstream is(str);
while (is) {
+ if (args.size() == max) {
+ string s;
+ getline(is, s);
+ args.push_back(trim(s));
+ return;
+ }
+
char c;
string s;
is >> c;
}
}
+}
string FuncRequest::getArg(unsigned int i) const
{
vector<string> args;
- splitArg(args, to_utf8(argument_));
+ splitArg(args, to_utf8(argument_), string::npos);
+ return i < args.size() ? args[i] : string();
+}
+
+
+string FuncRequest::getLongArg(unsigned int i) const
+{
+ vector<string> args;
+ splitArg(args, to_utf8(argument_), i);
return i < args.size() ? args[i] : string();
}
ostream & operator<<(ostream & os, FuncRequest const & cmd)
{
return os
- << " action: " << cmd.action
+ << " action: " << cmd.action
+ << " [" << lyxaction.getActionName(cmd.action) << "] "
<< " arg: '" << to_utf8(cmd.argument()) << "'"
<< " x: " << cmd.x
<< " y: " << cmd.y;