3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "funcrequest.h"
14 #include "BufferView.h"
15 #include "lyxfunc.h" // only for setMessage()
16 #include "frontends/LyXView.h"
18 #include "support/std_sstream.h"
25 using std::istringstream;
30 FuncRequest::FuncRequest()
31 : view_(0), action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none)
35 FuncRequest::FuncRequest(kb_action act)
36 : view_(0), action(act), x(0), y(0), button_(mouse_button::none)
40 FuncRequest::FuncRequest(kb_action act, string const & arg)
41 : view_(0), action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
45 FuncRequest::FuncRequest
46 (kb_action act, int ax, int ay, mouse_button::state button)
47 : view_(0), action(act), x(ax), y(ay), button_(button)
51 FuncRequest::FuncRequest(BufferView * view, kb_action act)
52 : view_(view), action(act), x(0), y(0), button_(mouse_button::none)
56 FuncRequest::FuncRequest(BufferView * view, kb_action act, string const & arg)
57 : view_(view), action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
61 FuncRequest::FuncRequest
62 (BufferView * view, kb_action act, int ax, int ay, mouse_button::state but)
63 : view_(view), action(act), x(ax), y(ay), button_(but)
67 FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg)
68 : view_(cmd.view_), action(cmd.action), argument(arg),
69 x(cmd.x), y(cmd.y), button_(cmd.button_)
73 FuncRequest::FuncRequest(FuncRequest const & cmd, BufferView * view)
74 : view_(view), action(cmd.action), argument(cmd.argument),
75 x(cmd.x), y(cmd.y), button_(cmd.button_)
79 BufferView * FuncRequest::view() const
85 void FuncRequest::setView(BufferView * view)
91 mouse_button::state FuncRequest::button() const
97 void FuncRequest::message(string const & msg) const
100 view_->owner()->getLyXFunc().setMessage(msg);
102 lyxerr << "Dropping message '" << msg << "'" << endl;
106 void FuncRequest::errorMessage(string const & msg) const
109 view_->owner()->getLyXFunc().setErrorMessage(msg);
111 lyxerr << "Dropping error message '" << msg << "'" << endl;
115 void split(vector<string> & args, string str)
117 istringstream is(str);
133 string FuncRequest::getArg(unsigned int i) const
136 split(args, argument);
137 return i < args.size() ? args[i] : string();
141 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
143 return lhs.action == rhs.action && lhs.argument == rhs.argument;
147 std::ostream & operator<<(std::ostream & os, FuncRequest const & cmd)
150 << " action: " << cmd.action
151 << " arg: '" << cmd.argument << "'"