]> git.lyx.org Git - lyx.git/blob - src/funcrequest.C
mathed uglyfication
[lyx.git] / src / funcrequest.C
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  */
10
11 #include <config.h>
12
13 #include "funcrequest.h"
14 #include "BufferView.h"
15 #include "lyxfunc.h" // only for setMessage()
16 #include "frontends/LyXView.h"
17 #include "debug.h"
18 #include "support/std_sstream.h"
19
20 #include <iostream>
21
22 using std::endl;
23 using std::getline;
24
25 using std::istringstream;
26 using std::vector;
27 using std::string;
28
29
30 FuncRequest::FuncRequest()
31         : action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none)
32 {}
33
34
35 FuncRequest::FuncRequest(kb_action act)
36         : action(act), x(0), y(0), button_(mouse_button::none)
37 {}
38
39
40 FuncRequest::FuncRequest(kb_action act, string const & arg)
41         : action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
42 {}
43
44
45 FuncRequest::FuncRequest(kb_action act, int ax, int ay, mouse_button::state but)
46         : action(act), x(ax), y(ay), button_(but)
47 {}
48
49
50 FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg)
51         : action(cmd.action), argument(arg),
52           x(cmd.x), y(cmd.y), button_(cmd.button_)
53 {}
54
55
56 mouse_button::state FuncRequest::button() const
57 {
58         return button_;
59 }
60
61
62 void FuncRequest::message(string const & msg) const
63 {
64 #warning FIXME
65         //if (view_)
66         //      view_->owner()->getLyXFunc().setMessage(msg);
67         //else
68         lyxerr  << "Dropping message '" << msg << "'" << endl;
69 }
70
71
72 void FuncRequest::errorMessage(string const & msg) const
73 {
74 #warning FIXME
75         //if (view_)
76         //      view_->owner()->getLyXFunc().setErrorMessage(msg);
77         //else
78         lyxerr  << "Dropping error message '" << msg << "'" << endl;
79 }
80
81
82 void split(vector<string> & args, string str)
83 {
84         istringstream is(str);
85         while (is) {
86                 char c;
87                 string s;
88                 is >> c;
89                 if (c == '"')
90                         getline(is, s, '"');
91                 else {
92                         is.putback(c);
93                         is >> s;
94                 }
95                 args.push_back(s);
96         }
97 }
98
99
100 string FuncRequest::getArg(unsigned int i) const
101 {
102         vector<string> args;
103         split(args, argument);
104         return i < args.size() ? args[i] : string();
105 }
106
107
108 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs)
109 {
110         return lhs.action == rhs.action && lhs.argument == rhs.argument;
111 }
112
113
114 std::ostream & operator<<(std::ostream & os, FuncRequest const & cmd)
115 {
116         return os
117                 << " action: " << cmd.action 
118                 << " arg: '" << cmd.argument << "'"
119                 << " x: " << cmd.x 
120                 << " y: " << cmd.y; 
121 }