2003-08-23 00:17:00 +00:00
|
|
|
// -*- C++ -*-
|
2002-08-07 23:43:38 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file FuncRequest.h
|
2003-08-23 00:17:00 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-08-07 23:43:38 +00:00
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-23 00:17:00 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-08-07 23:43:38 +00:00
|
|
|
*/
|
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
#ifndef FUNCREQUEST_H
|
|
|
|
#define FUNCREQUEST_H
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
#include "FuncCode.h"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2006-09-01 15:41:38 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
#include "frontends/mouse_state.h"
|
|
|
|
|
2004-02-03 11:49:05 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2012-06-07 17:19:04 +02:00
|
|
|
class LyXErr;
|
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
/**
|
2002-08-07 23:43:38 +00:00
|
|
|
* This class encapsulates a LyX action and its argument
|
|
|
|
* in order to pass it around easily.
|
2002-08-07 08:11:41 +00:00
|
|
|
*/
|
2008-03-15 01:20:36 +00:00
|
|
|
class FuncRequest
|
|
|
|
{
|
2002-08-13 17:43:40 +00:00
|
|
|
public:
|
2004-11-08 10:54:29 +00:00
|
|
|
/// Where the request came from
|
|
|
|
enum Origin {
|
2004-11-26 14:52:54 +00:00
|
|
|
INTERNAL,
|
2006-11-09 14:56:57 +00:00
|
|
|
MENU, // A menu entry
|
|
|
|
TOOLBAR, // A toolbar icon
|
2004-11-08 10:54:29 +00:00
|
|
|
KEYBOARD, // a keyboard binding
|
2009-04-08 21:06:58 +00:00
|
|
|
COMMANDBUFFER,
|
Fix bugs #6871 and #8119.
Both bugs above were due to a missing screen update. This patch
updates the current view after dispatching a lyxserver command
and thus solves both.
The patch is quite strightforward and the only difficulty was due
to the fact that the lyxserver needs the result of the dispatched
command. Now, GuiApplication::dispatch(FuncRequest const &)
does update the view, but does not return any result, while
GuiApplication::dispatch(FuncRequest const &, DispatchResult &),
which is also called by the former, does not update the view.
So, I split the first one, isolating the code performing the update,
such that the second one can also update the current view when
the caller is the lyx server. When the action is initiated by
anything different from the lyx server, the behavior is unchanged.
(cherry picked from commit ea3154184833f4f2426eb2a956878e83ddd822d9)
2012-04-13 02:57:25 +02:00
|
|
|
LYXSERVER,
|
2009-04-08 21:06:58 +00:00
|
|
|
TOC
|
2004-11-08 10:54:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// just for putting these things in std::container
|
|
|
|
explicit FuncRequest(Origin o = INTERNAL);
|
2002-08-13 17:43:40 +00:00
|
|
|
/// actions without extra argument
|
2008-03-15 01:20:36 +00:00
|
|
|
explicit FuncRequest(FuncCode act, Origin o = INTERNAL);
|
2002-08-28 08:30:27 +00:00
|
|
|
/// actions without extra argument
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode act, int x, int y, mouse_button::state button,
|
2004-11-26 14:52:54 +00:00
|
|
|
Origin o = INTERNAL);
|
2002-08-13 17:43:40 +00:00
|
|
|
/// actions with extra argument
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode act, docstring const & arg,
|
2006-09-01 15:41:38 +00:00
|
|
|
Origin o = INTERNAL);
|
|
|
|
/// actions with extra argument. FIXME: remove this
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode act, std::string const & arg,
|
2004-11-08 10:54:29 +00:00
|
|
|
Origin o = INTERNAL);
|
2002-08-20 13:00:25 +00:00
|
|
|
/// for changing requests a bit
|
2006-10-21 00:16:43 +00:00
|
|
|
FuncRequest(FuncRequest const & cmd, docstring const & arg,
|
2006-09-01 15:41:38 +00:00
|
|
|
Origin o = INTERNAL);
|
|
|
|
/// for changing requests a bit. FIXME: remove this
|
2004-11-26 14:52:54 +00:00
|
|
|
FuncRequest(FuncRequest const & cmd, std::string const & arg,
|
2004-11-08 10:54:29 +00:00
|
|
|
Origin o = INTERNAL);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
2010-04-09 19:00:42 +00:00
|
|
|
/// access the whole argument
|
|
|
|
docstring const & argument() const { return argument_; }
|
|
|
|
///
|
|
|
|
FuncCode action() const { return action_ ; }
|
|
|
|
///
|
|
|
|
void setAction(FuncCode act) { action_ = act; }
|
|
|
|
///
|
|
|
|
Origin origin() const { return origin_; }
|
|
|
|
///
|
|
|
|
void setOrigin(Origin o) { origin_ = o; }
|
|
|
|
///
|
|
|
|
int x() const { return x_; }
|
|
|
|
///
|
|
|
|
int y() const { return y_; }
|
|
|
|
///
|
|
|
|
void set_y(int y) { y_ = y; }
|
|
|
|
///
|
|
|
|
mouse_button::state button() const { return button_; }
|
2002-08-13 17:43:40 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
/// argument parsing, extract argument i as std::string
|
|
|
|
std::string getArg(unsigned int i) const;
|
2009-12-02 09:39:39 +00:00
|
|
|
/// argument parsing, extract argument i as std::string,
|
|
|
|
/// eating all characters up to the end of the command line
|
|
|
|
std::string getLongArg(unsigned int i) const;
|
|
|
|
|
2007-10-20 23:27:03 +00:00
|
|
|
///
|
|
|
|
static FuncRequest const unknown;
|
|
|
|
///
|
|
|
|
static FuncRequest const noaction;
|
2006-09-01 15:41:38 +00:00
|
|
|
private:
|
2010-04-09 18:15:17 +00:00
|
|
|
/// the action
|
|
|
|
FuncCode action_;
|
2010-04-12 15:40:51 +00:00
|
|
|
/// the action's string argument
|
|
|
|
docstring argument_;
|
2004-11-08 10:54:29 +00:00
|
|
|
/// who initiated the action
|
2010-04-09 18:15:17 +00:00
|
|
|
Origin origin_;
|
2002-08-12 09:53:04 +00:00
|
|
|
/// the x coordinate of a mouse press
|
2010-04-09 18:15:17 +00:00
|
|
|
int x_;
|
2002-08-12 09:53:04 +00:00
|
|
|
/// the y coordinate of a mouse press
|
2010-04-09 18:15:17 +00:00
|
|
|
int y_;
|
2002-08-12 09:53:04 +00:00
|
|
|
/// some extra information (like button number)
|
2002-08-19 10:11:13 +00:00
|
|
|
mouse_button::state button_;
|
2002-08-07 08:11:41 +00:00
|
|
|
};
|
|
|
|
|
2003-09-21 23:00:47 +00:00
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
bool operator==(FuncRequest const & lhs, FuncRequest const & rhs);
|
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream &, FuncRequest const &);
|
2003-09-21 23:00:47 +00:00
|
|
|
|
2012-06-07 17:19:04 +02:00
|
|
|
LyXErr & operator<<(LyXErr &, FuncRequest const &);
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2002-08-07 23:43:38 +00:00
|
|
|
#endif // FUNCREQUEST_H
|