2002-08-14 02:29:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file funcrequest.C
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-08-14 02:29:28 +00:00
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
2003-08-23 00:17:00 +00:00
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-08-14 02:29:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2002-11-04 00:15:56 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2002-08-14 02:29:28 +00:00
|
|
|
|
#include "funcrequest.h"
|
2004-02-03 11:49:05 +00:00
|
|
|
|
|
2003-09-05 17:23:11 +00:00
|
|
|
|
#include "support/std_sstream.h"
|
2003-02-26 18:03:48 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
#include <iostream>
|
2004-02-03 11:49:05 +00:00
|
|
|
|
#include <vector>
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::getline;
|
2003-02-26 18:03:48 +00:00
|
|
|
|
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2003-02-26 18:03:48 +00:00
|
|
|
|
using std::vector;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2002-08-14 02:29:28 +00:00
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest()
|
2004-01-15 17:34:44 +00:00
|
|
|
|
: action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest(kb_action act)
|
2004-01-15 17:34:44 +00:00
|
|
|
|
: action(act), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest(kb_action act, string const & arg)
|
2004-01-15 17:34:44 +00:00
|
|
|
|
: action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-01-15 17:34:44 +00:00
|
|
|
|
FuncRequest::FuncRequest(kb_action act, int ax, int ay, mouse_button::state but)
|
|
|
|
|
: action(act), x(ax), y(ay), button_(but)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg)
|
2004-01-15 17:34:44 +00:00
|
|
|
|
: action(cmd.action), argument(arg),
|
2002-08-20 13:00:25 +00:00
|
|
|
|
x(cmd.x), y(cmd.y), button_(cmd.button_)
|
|
|
|
|
{}
|
2002-11-04 00:15:56 +00:00
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2002-08-19 10:11:13 +00:00
|
|
|
|
mouse_button::state FuncRequest::button() const
|
|
|
|
|
{
|
|
|
|
|
return button_;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2003-02-26 18:03:48 +00:00
|
|
|
|
void split(vector<string> & args, string str)
|
|
|
|
|
{
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream is(str);
|
2003-02-26 18:03:48 +00:00
|
|
|
|
while (is) {
|
|
|
|
|
char c;
|
|
|
|
|
string s;
|
|
|
|
|
is >> c;
|
2003-03-04 09:27:27 +00:00
|
|
|
|
if (c == '"')
|
2003-02-26 18:03:48 +00:00
|
|
|
|
getline(is, s, '"');
|
|
|
|
|
else {
|
|
|
|
|
is.putback(c);
|
|
|
|
|
is >> s;
|
|
|
|
|
}
|
|
|
|
|
args.push_back(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-21 18:57:15 +00:00
|
|
|
|
string FuncRequest::getArg(unsigned int i) const
|
2003-02-26 18:03:48 +00:00
|
|
|
|
{
|
|
|
|
|
vector<string> args;
|
|
|
|
|
split(args, argument);
|
|
|
|
|
return i < args.size() ? args[i] : string();
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
|
|
|
|
|
{
|
|
|
|
|
return lhs.action == rhs.action && lhs.argument == rhs.argument;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & os, FuncRequest const & cmd)
|
|
|
|
|
{
|
|
|
|
|
return os
|
2004-04-03 08:37:12 +00:00
|
|
|
|
<< " action: " << cmd.action
|
2003-11-10 09:06:48 +00:00
|
|
|
|
<< " arg: '" << cmd.argument << "'"
|
2004-04-03 08:37:12 +00:00
|
|
|
|
<< " x: " << cmd.x
|
|
|
|
|
<< " y: " << cmd.y;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
}
|