2002-08-14 02:29:28 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file FuncRequest.cpp
|
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
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pö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>
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2008-12-15 15:47:33 +00:00
|
|
|
#include "LyXAction.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
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2002-08-14 02:29:28 +00:00
|
|
|
|
2007-07-17 17:46:54 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2007-10-20 23:27:03 +00:00
|
|
|
FuncRequest const FuncRequest::unknown(LFUN_UNKNOWN_ACTION);
|
|
|
|
FuncRequest const FuncRequest::noaction(LFUN_NOACTION);
|
2007-07-17 17:46:54 +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
|
|
|
{}
|
|
|
|
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest::FuncRequest(FuncCode act, Origin o)
|
2004-11-08 10:54:29 +00:00
|
|
|
: action(act), origin(o), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest::FuncRequest(FuncCode act, docstring const & arg, Origin o)
|
2006-09-01 15:41:38 +00:00
|
|
|
: action(act), argument_(arg), origin(o), x(0), y(0),
|
|
|
|
button_(mouse_button::none)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest::FuncRequest(FuncCode act, string const & arg, Origin o)
|
2006-10-21 00:16:43 +00:00
|
|
|
: action(act), argument_(from_utf8(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
|
|
|
{}
|
|
|
|
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest::FuncRequest(FuncCode 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
|
|
|
{}
|
|
|
|
|
|
|
|
|
2006-09-01 15:41:38 +00:00
|
|
|
FuncRequest::FuncRequest(FuncRequest const & cmd, docstring const & arg, Origin o)
|
|
|
|
: action(cmd.action), argument_(arg), origin(o),
|
|
|
|
x(cmd.x), y(cmd.y), button_(cmd.button_)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2004-11-08 10:54:29 +00:00
|
|
|
FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg, Origin o)
|
2006-10-21 00:16:43 +00:00
|
|
|
: action(cmd.action), argument_(from_utf8(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
|
|
|
|
2007-12-13 21:57:37 +00:00
|
|
|
void splitArg(vector<string> & args, string const & str)
|
2003-02-26 18:03:48 +00:00
|
|
|
{
|
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;
|
2005-07-16 17:27:16 +00:00
|
|
|
if (is) {
|
|
|
|
if (c == '"')
|
|
|
|
getline(is, s, '"');
|
|
|
|
else {
|
|
|
|
is.putback(c);
|
|
|
|
is >> s;
|
|
|
|
}
|
|
|
|
args.push_back(s);
|
2003-02-26 18:03:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2007-12-13 21:57:37 +00:00
|
|
|
splitArg(args, to_utf8(argument_));
|
2003-02-26 18:03:48 +00:00
|
|
|
return i < args.size() ? args[i] : string();
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
|
|
|
|
{
|
2006-09-01 15:41:38 +00:00
|
|
|
return lhs.action == rhs.action && lhs.argument() == rhs.argument();
|
2003-11-10 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
ostream & operator<<(ostream & os, FuncRequest const & cmd)
|
2003-11-10 09:06:48 +00:00
|
|
|
{
|
|
|
|
return os
|
2008-12-15 15:47:33 +00:00
|
|
|
<< " action: " << cmd.action
|
|
|
|
<< " [" << lyxaction.getActionName(cmd.action) << "] "
|
2006-10-21 00:16:43 +00:00
|
|
|
<< " arg: '" << to_utf8(cmd.argument()) << "'"
|
2004-04-03 08:37:12 +00:00
|
|
|
<< " x: " << cmd.x
|
|
|
|
<< " y: " << cmd.y;
|
2003-11-10 09:06:48 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|