4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
17 #include "support/docstring.h"
19 #include "frontends/KeyModifier.h"
20 #include "frontends/mouse_state.h"
32 * This class encapsulates a LyX action and its argument
33 * in order to pass it around easily.
38 /// Where the request came from
42 TOOLBAR, // A toolbar icon
43 KEYBOARD, // a keyboard binding
49 /// just for putting these things in std::container
50 explicit FuncRequest(Origin o = INTERNAL);
51 /// actions without extra argument
52 explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
53 /// actions without extra argument
54 FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
55 KeyModifier modifier, Origin o = INTERNAL);
56 /// actions with extra argument
57 FuncRequest(FuncCode act, docstring const & arg,
59 /// actions with extra argument. FIXME: remove this
60 FuncRequest(FuncCode act, std::string const & arg,
62 /// for changing requests a bit
63 FuncRequest(FuncRequest const & cmd, docstring const & arg,
66 /// access the whole argument
67 docstring const & argument() const { return argument_; }
69 FuncCode action() const { return action_ ; }
71 void setAction(FuncCode act) { action_ = act; }
73 Origin origin() const { return origin_; }
75 void setOrigin(Origin o) { origin_ = o; }
77 frontend::GuiView* view_origin() const { return view_origin_; }
79 void setViewOrigin(frontend::GuiView* o) { view_origin_ = o; }
81 int x() const { return x_; }
83 int y() const { return y_; }
85 void set_y(int y) { y_ = y; }
87 mouse_button::state button() const { return button_; }
89 KeyModifier modifier() { return modifier_; }
91 /// argument parsing, extract argument i as std::string
92 std::string getArg(unsigned int i) const;
93 /// argument parsing, extract argument i as std::string,
94 /// eating all characters up to the end of the command line
95 std::string getLongArg(unsigned int i) const;
98 static FuncRequest const unknown;
100 static FuncRequest const noaction;
102 bool allowAsync() const { return allow_async_; }
104 void allowAsync(bool allow_async) { allow_async_ = allow_async; }
109 /// the action's string argument
111 /// who initiated the action
113 /// to which view should be this command sent (see bug #11004)
114 /// NULL=current view
115 frontend::GuiView* view_origin_;
116 /// the x coordinate of a mouse press
118 /// the y coordinate of a mouse press
120 /// some extra information (like button number)
121 mouse_button::state button_;
123 KeyModifier modifier_;
124 /// Commands should be run synchronously when they
125 /// are launched via "command-sequence" or "repeat" or "buffer-forall"
130 bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
132 std::ostream & operator<<(std::ostream &, FuncRequest const &);
134 LyXErr & operator<<(LyXErr &, FuncRequest const &);
139 #endif // FUNCREQUEST_H