replace most &dquot;...&dquot; by <...>
[lyx.git] / src / funcrequest.C
blob382ac4fa4a10a3279d12c17096d7864c32163cd4
1 /**
2  * \file funcrequest.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
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;
21 using std::istringstream;
22 using std::vector;
23 using std::string;
26 FuncRequest::FuncRequest()
27         : action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none)
31 FuncRequest::FuncRequest(kb_action act)
32         : action(act), x(0), y(0), button_(mouse_button::none)
36 FuncRequest::FuncRequest(kb_action act, string const & arg)
37         : action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
41 FuncRequest::FuncRequest(kb_action act, int ax, int ay, mouse_button::state but)
42         : action(act), x(ax), y(ay), button_(but)
46 FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg)
47         : action(cmd.action), argument(arg),
48           x(cmd.x), y(cmd.y), button_(cmd.button_)
52 mouse_button::state FuncRequest::button() const
54         return button_;
58 void split(vector<string> & args, string str)
60         istringstream is(str);
61         while (is) {
62                 char c;
63                 string s;
64                 is >> c;
65                 if (c == '"')
66                         getline(is, s, '"');
67                 else {
68                         is.putback(c);
69                         is >> s;
70                 }
71                 args.push_back(s);
72         }
76 string FuncRequest::getArg(unsigned int i) const
78         vector<string> args;
79         split(args, argument);
80         return i < args.size() ? args[i] : string();
84 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
86         return lhs.action == rhs.action && lhs.argument == rhs.argument;
90 std::ostream & operator<<(std::ostream & os, FuncRequest const & cmd)
92         return os
93                 << " action: " << cmd.action
94                 << " arg: '" << cmd.argument << "'"
95                 << " x: " << cmd.x
96                 << " y: " << cmd.y;