Not so soon, I guess, since that FIXME was from r6305.
[lyx.git] / src / FuncRequest.cpp
blob3eb0990a01f7d15e787bf1c6a0247c3914ef3271
1 /**
2 * \file FuncRequest.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author André Pönitz
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "FuncRequest.h"
14 #include "LyXAction.h"
16 #include <iostream>
17 #include <sstream>
18 #include <vector>
20 using namespace std;
22 namespace lyx {
24 FuncRequest const FuncRequest::unknown(LFUN_UNKNOWN_ACTION);
25 FuncRequest const FuncRequest::noaction(LFUN_NOACTION);
27 FuncRequest::FuncRequest(Origin o)
28 : action(LFUN_NOACTION), origin(o), x(0), y(0),
29 button_(mouse_button::none)
33 FuncRequest::FuncRequest(FuncCode act, Origin o)
34 : action(act), origin(o), x(0), y(0), button_(mouse_button::none)
38 FuncRequest::FuncRequest(FuncCode act, docstring const & arg, Origin o)
39 : action(act), argument_(arg), origin(o), x(0), y(0),
40 button_(mouse_button::none)
44 FuncRequest::FuncRequest(FuncCode act, string const & arg, Origin o)
45 : action(act), argument_(from_utf8(arg)), origin(o), x(0), y(0),
46 button_(mouse_button::none)
50 FuncRequest::FuncRequest(FuncCode act, int ax, int ay,
51 mouse_button::state but, Origin o)
52 : action(act), origin(o), x(ax), y(ay), button_(but)
56 FuncRequest::FuncRequest(FuncRequest const & cmd, docstring const & arg, Origin o)
57 : action(cmd.action), argument_(arg), origin(o),
58 x(cmd.x), y(cmd.y), button_(cmd.button_)
62 FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg, Origin o)
63 : action(cmd.action), argument_(from_utf8(arg)), origin(o),
64 x(cmd.x), y(cmd.y), button_(cmd.button_)
68 mouse_button::state FuncRequest::button() const
70 return button_;
74 void splitArg(vector<string> & args, string const & str)
76 istringstream is(str);
77 while (is) {
78 char c;
79 string s;
80 is >> c;
81 if (is) {
82 if (c == '"')
83 getline(is, s, '"');
84 else {
85 is.putback(c);
86 is >> s;
88 args.push_back(s);
94 string FuncRequest::getArg(unsigned int i) const
96 vector<string> args;
97 splitArg(args, to_utf8(argument_));
98 return i < args.size() ? args[i] : string();
102 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
104 return lhs.action == rhs.action && lhs.argument() == rhs.argument();
108 ostream & operator<<(ostream & os, FuncRequest const & cmd)
110 return os
111 << " action: " << cmd.action
112 << " [" << lyxaction.getActionName(cmd.action) << "] "
113 << " arg: '" << to_utf8(cmd.argument()) << "'"
114 << " x: " << cmd.x
115 << " y: " << cmd.y;
119 } // namespace lyx