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"
|
2002-08-20 13:00:25 +00:00
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "lyxfunc.h" // only for setMessage()
|
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
#include "debug.h"
|
2003-09-05 17:23:11 +00:00
|
|
|
|
#include "support/std_sstream.h"
|
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;
|
|
|
|
|
using std::getline;
|
2003-08-02 11:30:30 +00:00
|
|
|
|
using std::endl;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2002-08-14 02:29:28 +00:00
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest()
|
2003-08-27 15:25:27 +00:00
|
|
|
|
: view_(0), action(LFUN_UNKNOWN_ACTION), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest(kb_action act)
|
2003-08-27 15:25:27 +00:00
|
|
|
|
: view_(0), 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)
|
2003-08-27 15:25:27 +00:00
|
|
|
|
: view_(0), action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2002-08-28 08:30:27 +00:00
|
|
|
|
FuncRequest::FuncRequest
|
|
|
|
|
(kb_action act, int ax, int ay, mouse_button::state button)
|
2003-08-27 15:25:27 +00:00
|
|
|
|
: view_(0), action(act), x(ax), y(ay), button_(button)
|
2002-08-28 08:30:27 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2002-08-14 02:29:28 +00:00
|
|
|
|
FuncRequest::FuncRequest(BufferView * view, kb_action act)
|
2003-08-27 15:25:27 +00:00
|
|
|
|
: view_(view), action(act), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest(BufferView * view, kb_action act, string const & arg)
|
2003-08-27 15:25:27 +00:00
|
|
|
|
: view_(view), action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
|
2002-08-14 02:29:28 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest
|
2002-08-19 10:11:13 +00:00
|
|
|
|
(BufferView * view, kb_action act, int ax, int ay, mouse_button::state but)
|
2003-08-27 15:25:27 +00:00
|
|
|
|
: view_(view), 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)
|
|
|
|
|
: view_(cmd.view_), action(cmd.action), argument(arg),
|
|
|
|
|
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-28 08:30:27 +00:00
|
|
|
|
FuncRequest::FuncRequest(FuncRequest const & cmd, BufferView * view)
|
|
|
|
|
: view_(view), action(cmd.action), argument(cmd.argument),
|
|
|
|
|
x(cmd.x), y(cmd.y), button_(cmd.button_)
|
|
|
|
|
{}
|
2002-11-04 00:15:56 +00:00
|
|
|
|
|
2002-08-28 08:30:27 +00:00
|
|
|
|
|
2002-08-14 02:29:28 +00:00
|
|
|
|
BufferView * FuncRequest::view() const
|
|
|
|
|
{
|
|
|
|
|
return view_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FuncRequest::setView(BufferView * view)
|
|
|
|
|
{
|
|
|
|
|
view_ = view;
|
|
|
|
|
}
|
2002-08-19 10:11:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mouse_button::state FuncRequest::button() const
|
|
|
|
|
{
|
|
|
|
|
return button_;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
void FuncRequest::message(string const & msg) const
|
|
|
|
|
{
|
|
|
|
|
if (view_)
|
|
|
|
|
view_->owner()->getLyXFunc().setMessage(msg);
|
|
|
|
|
else
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "Dropping message '" << msg << "'" << endl;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FuncRequest::errorMessage(string const & msg) const
|
|
|
|
|
{
|
|
|
|
|
if (view_)
|
|
|
|
|
view_->owner()->getLyXFunc().setErrorMessage(msg);
|
|
|
|
|
else
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "Dropping error message '" << msg << "'" << endl;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|
2003-02-26 18:03:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void split(vector<string> & args, string str)
|
|
|
|
|
{
|
2003-06-30 15:06:30 +00:00
|
|
|
|
istringstream is(STRCONV(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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string FuncRequest::getArg(int i) const
|
|
|
|
|
{
|
|
|
|
|
vector<string> args;
|
|
|
|
|
split(args, argument);
|
|
|
|
|
return i < args.size() ? args[i] : string();
|
|
|
|
|
}
|