2002-08-14 02:29:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file funcrequest.C
|
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
|
* Read the file COPYING
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*/
|
|
|
|
|
|
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-02-26 18:03:48 +00:00
|
|
|
|
#include "Lsstream.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
using std::getline;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2002-08-14 02:29:28 +00:00
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest()
|
|
|
|
|
: view_(0), action(LFUN_UNKNOWN_ACTION)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest(kb_action act)
|
|
|
|
|
: view_(0), action(act)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest(kb_action act, string const & arg)
|
|
|
|
|
: view_(0), action(act), argument(arg)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2002-08-28 08:30:27 +00:00
|
|
|
|
FuncRequest::FuncRequest
|
|
|
|
|
(kb_action act, int ax, int ay, mouse_button::state button)
|
|
|
|
|
: view_(0), action(act), argument(), x(ax), y(ay), button_(button)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2002-08-14 02:29:28 +00:00
|
|
|
|
FuncRequest::FuncRequest(BufferView * view, kb_action act)
|
|
|
|
|
: view_(view), action(act)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest(BufferView * view, kb_action act, string const & arg)
|
|
|
|
|
: view_(view), action(act), argument(arg)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FuncRequest::FuncRequest
|
2002-08-19 10:11:13 +00:00
|
|
|
|
(BufferView * view, kb_action act, int ax, int ay, mouse_button::state but)
|
|
|
|
|
: view_(view), action(act), argument(), 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
|
|
|
|
|
lyxerr << "Dropping message '" << msg << "'\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FuncRequest::errorMessage(string const & msg) const
|
|
|
|
|
{
|
|
|
|
|
if (view_)
|
|
|
|
|
view_->owner()->getLyXFunc().setErrorMessage(msg);
|
|
|
|
|
else
|
|
|
|
|
lyxerr << "Dropping error message '" << msg << "'\n";
|
|
|
|
|
}
|
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();
|
|
|
|
|
}
|