2 * \file FuncRequest.cpp
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"
20 using std::istringstream;
27 FuncRequest const FuncRequest::unknown(LFUN_UNKNOWN_ACTION);
28 FuncRequest const FuncRequest::noaction(LFUN_NOACTION);
30 FuncRequest::FuncRequest(Origin o)
31 : action(LFUN_NOACTION), origin(o), x(0), y(0),
32 button_(mouse_button::none)
36 FuncRequest::FuncRequest(kb_action act, Origin o)
37 : action(act), origin(o), x(0), y(0), button_(mouse_button::none)
41 FuncRequest::FuncRequest(kb_action act, docstring const & arg, Origin o)
42 : action(act), argument_(arg), origin(o), x(0), y(0),
43 button_(mouse_button::none)
47 FuncRequest::FuncRequest(kb_action act, string const & arg, Origin o)
48 : action(act), argument_(from_utf8(arg)), origin(o), x(0), y(0),
49 button_(mouse_button::none)
53 FuncRequest::FuncRequest(kb_action act, int ax, int ay,
54 mouse_button::state but, Origin o)
55 : action(act), origin(o), x(ax), y(ay), button_(but)
59 FuncRequest::FuncRequest(FuncRequest const & cmd, docstring const & arg, Origin o)
60 : action(cmd.action), argument_(arg), origin(o),
61 x(cmd.x), y(cmd.y), button_(cmd.button_)
65 FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg, Origin o)
66 : action(cmd.action), argument_(from_utf8(arg)), origin(o),
67 x(cmd.x), y(cmd.y), button_(cmd.button_)
71 mouse_button::state FuncRequest::button() const
77 void split(vector<string> & args, string const & str)
79 istringstream is(str);
97 string FuncRequest::getArg(unsigned int i) const
100 split(args, to_utf8(argument_));
101 return i < args.size() ? args[i] : string();
105 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
107 return lhs.action == rhs.action && lhs.argument() == rhs.argument();
111 std::ostream & operator<<(std::ostream & os, FuncRequest const & cmd)
114 << " action: " << cmd.action
115 << " arg: '" << to_utf8(cmd.argument()) << "'"