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"
14 #include "LyXAction.h"
16 #include "support/lstrings.h"
23 using namespace lyx::support;
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(FuncCode act, Origin o)
37 : action(act), origin(o), x(0), y(0), button_(mouse_button::none)
41 FuncRequest::FuncRequest(FuncCode 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(FuncCode 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(FuncCode 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
79 void splitArg(vector<string> & args, string const & str, unsigned int max)
81 istringstream is(str);
83 if (args.size() == max) {
86 args.push_back(trim(s));
107 string FuncRequest::getArg(unsigned int i) const
110 splitArg(args, to_utf8(argument_), string::npos);
111 return i < args.size() ? args[i] : string();
115 string FuncRequest::getLongArg(unsigned int i) const
118 splitArg(args, to_utf8(argument_), i);
119 return i < args.size() ? args[i] : string();
123 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
125 return lhs.action == rhs.action && lhs.argument() == rhs.argument();
129 ostream & operator<<(ostream & os, FuncRequest const & cmd)
132 << " action: " << cmd.action
133 << " [" << lyxaction.getActionName(cmd.action) << "] "
134 << " arg: '" << to_utf8(cmd.argument()) << "'"