scramble email addresses
[lyx.git] / src / FuncRequest.cpp
blob634111f14795959123559a186c6e5674ef864bf6
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"
15 #include <iostream>
16 #include <sstream>
17 #include <vector>
19 using std::getline;
20 using std::istringstream;
21 using std::vector;
22 using std::string;
25 namespace lyx {
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
73 return button_;
77 void split(vector<string> & args, string const & str)
79 istringstream is(str);
80 while (is) {
81 char c;
82 string s;
83 is >> c;
84 if (is) {
85 if (c == '"')
86 getline(is, s, '"');
87 else {
88 is.putback(c);
89 is >> s;
91 args.push_back(s);
97 string FuncRequest::getArg(unsigned int i) const
99 vector<string> args;
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)
113 return os
114 << " action: " << cmd.action
115 << " arg: '" << to_utf8(cmd.argument()) << "'"
116 << " x: " << cmd.x
117 << " y: " << cmd.y;
121 } // namespace lyx