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-11-10 09:06:48 +00:00
|
|
|
|
#include <iostream>
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
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
|
|
|
|
|
2004-11-08 10:54:29 +00:00
|
|
|
|
FuncRequest::FuncRequest(Origin o)
|
2004-11-26 14:52:54 +00:00
|
|
|
|
: action(LFUN_NOACTION), origin(o), x(0), y(0),
|
2004-11-08 10:54:29 +00:00
|
|
|
|
button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-11-08 10:54:29 +00:00
|
|
|
|
FuncRequest::FuncRequest(kb_action act, Origin o)
|
|
|
|
|
: action(act), origin(o), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-11-08 10:54:29 +00:00
|
|
|
|
FuncRequest::FuncRequest(kb_action act, string const & arg, Origin o)
|
2004-11-26 14:52:54 +00:00
|
|
|
|
: action(act), argument(arg), origin(o), x(0), y(0),
|
2004-11-08 10:54:29 +00:00
|
|
|
|
button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-11-26 14:52:54 +00:00
|
|
|
|
FuncRequest::FuncRequest(kb_action act, int ax, int ay,
|
2004-11-08 10:54:29 +00:00
|
|
|
|
mouse_button::state but, Origin o)
|
|
|
|
|
: action(act), origin(o), x(ax), y(ay), button_(but)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-11-08 10:54:29 +00:00
|
|
|
|
FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg, Origin o)
|
|
|
|
|
: action(cmd.action), argument(arg), origin(o),
|
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
|
|
|
|
}
|