1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-08-08 22:03:30 +00:00
|
|
|
/**
|
|
|
|
* \file LyXAction.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.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-08-08 22:03:30 +00:00
|
|
|
*/
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
#ifndef LYXACTION_H
|
|
|
|
#define LYXACTION_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
#include "FuncCode.h"
|
1999-11-25 13:15:52 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2003-09-04 03:54:04 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2003-09-04 03:54:04 +00:00
|
|
|
class FuncRequest;
|
2008-09-23 13:18:51 +00:00
|
|
|
class LyXErr;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/**
|
2008-06-20 08:25:13 +00:00
|
|
|
* This class is a container for LyX actions. It associates a name to
|
2008-06-20 08:26:03 +00:00
|
|
|
* most of them and describes some of their properties.
|
1999-09-27 18:44:28 +00:00
|
|
|
*/
|
2007-11-07 21:52:11 +00:00
|
|
|
class LyXAction {
|
2007-10-18 15:48:51 +00:00
|
|
|
public:
|
|
|
|
/// category of an action, used in the Shortcuts dialog
|
2010-01-05 20:56:37 +00:00
|
|
|
enum FuncType {
|
2007-10-18 15:48:51 +00:00
|
|
|
Hidden, //< Not listed for configuration
|
|
|
|
Edit, //< Cursor and mouse movement, copy/paste etc
|
|
|
|
Math, //< Mathematics
|
|
|
|
Buffer, //< Buffer and window related
|
|
|
|
Layout, //< Font, Layout and textclass related
|
|
|
|
System, //< Lyx preference, server etc
|
|
|
|
};
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
private:
|
2002-08-08 22:03:30 +00:00
|
|
|
/// information for an action
|
2008-03-15 01:20:36 +00:00
|
|
|
struct FuncInfo {
|
2002-08-08 22:03:30 +00:00
|
|
|
/// the action name
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string name;
|
2010-01-05 21:59:12 +00:00
|
|
|
/// the FuncAttribs values set
|
1999-11-22 16:19:48 +00:00
|
|
|
unsigned int attrib;
|
2007-10-18 15:48:51 +00:00
|
|
|
/// the category of this func
|
2010-01-05 20:56:37 +00:00
|
|
|
FuncType type;
|
1999-11-22 16:19:48 +00:00
|
|
|
};
|
2010-01-05 20:56:37 +00:00
|
|
|
/// type for map between a function name and its action
|
|
|
|
typedef std::map<std::string, FuncCode> FuncMap;
|
|
|
|
/// type for map between an action and its info
|
|
|
|
typedef std::map<FuncCode, FuncInfo> InfoMap;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2002-08-08 22:03:30 +00:00
|
|
|
/// possible "permissions" for an action
|
2010-01-05 20:56:37 +00:00
|
|
|
enum FuncAttribs {
|
2009-01-13 00:58:01 +00:00
|
|
|
Noop = 0, //< Nothing special about this func
|
|
|
|
ReadOnly = 1, //< Can be used in RO mode (perhaps this should change); no automatic markDirty
|
2002-08-08 22:03:30 +00:00
|
|
|
NoBuffer = 2, //< Can be used when there is no document open
|
2005-02-08 02:06:39 +00:00
|
|
|
Argument = 4, //< Requires argument
|
2005-10-07 12:00:41 +00:00
|
|
|
NoUpdate = 8, //< Does not (usually) require update
|
2009-03-30 13:49:52 +00:00
|
|
|
SingleParUpdate = 16, //< Usually only requires this par updated
|
|
|
|
AtPoint = 32, //< dispatch first to inset at cursor if there is one
|
2009-09-21 12:36:22 +00:00
|
|
|
NoInternal = 64, //< Cannot be used for internal, non-document Buffers
|
1999-11-22 16:19:48 +00:00
|
|
|
};
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
LyXAction();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/**
|
2010-01-05 20:48:12 +00:00
|
|
|
* Creates a FuncRequest from a string of the form:
|
|
|
|
* lyx-function [argument]
|
|
|
|
* where the argument is optional and "lyx-function" is in the form you'd
|
|
|
|
* enter it in the mini-buffer.
|
2002-08-08 22:03:30 +00:00
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
FuncRequest lookupFunc(std::string const & func_name) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2010-01-05 20:48:12 +00:00
|
|
|
/// Return the command name associated with the given action
|
|
|
|
/// Thus: getActionName(LFUN_ERT_INSERT) --> "ert-insert".
|
2008-03-15 01:20:36 +00:00
|
|
|
std::string const getActionName(FuncCode action) const;
|
2010-01-05 20:40:21 +00:00
|
|
|
///
|
2010-01-05 20:56:37 +00:00
|
|
|
FuncType getActionType(FuncCode action) const;
|
2007-10-18 15:48:51 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
/// True if the command has `flag' set
|
2010-01-05 20:56:37 +00:00
|
|
|
bool funcHasFlag(FuncCode action, FuncAttribs flag) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2010-01-06 19:25:12 +00:00
|
|
|
/// iterator across all LFUNs
|
2010-01-05 21:00:05 +00:00
|
|
|
typedef FuncMap::const_iterator const_iterator;
|
2002-08-08 22:03:30 +00:00
|
|
|
|
2010-01-06 19:25:12 +00:00
|
|
|
/// return an iterator to the start of the list of LFUNs
|
2010-01-05 21:00:05 +00:00
|
|
|
const_iterator func_begin() const;
|
2002-08-08 22:03:30 +00:00
|
|
|
|
2010-01-06 19:25:12 +00:00
|
|
|
/// return an iterator to one past the end of the list of LFUNs
|
2010-01-05 21:00:05 +00:00
|
|
|
const_iterator func_end() const;
|
2002-08-08 22:03:30 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
2010-01-05 21:15:36 +00:00
|
|
|
/// noncopyable
|
|
|
|
LyXAction(LyXAction const &);
|
|
|
|
void operator=(LyXAction const &);
|
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/// populate the action container with our actions
|
1999-11-22 16:19:48 +00:00
|
|
|
void init();
|
2002-08-08 22:03:30 +00:00
|
|
|
/// add the given action
|
2010-01-05 20:56:37 +00:00
|
|
|
void newFunc(FuncCode, std::string const & name, unsigned int attrib, FuncType type);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/**
|
2010-01-05 21:09:22 +00:00
|
|
|
* This maps LyX function names to function codes, e.g.:
|
|
|
|
* lyx_func_map["ert-insert"] == LFUN_ERT_INSERT
|
2002-08-08 22:03:30 +00:00
|
|
|
*/
|
2010-01-05 20:56:37 +00:00
|
|
|
FuncMap lyx_func_map;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/**
|
2010-01-05 21:09:22 +00:00
|
|
|
* This maps function codes to objects holding info about the corresponding
|
|
|
|
* action. E.g., if
|
|
|
|
* FuncInfo const & ert = lyx_info_map[LFUN_ERT_INSERT];
|
|
|
|
* then:
|
|
|
|
* ert.name == "ert-insert"'
|
|
|
|
* ert.attrib == Noop
|
|
|
|
* ert.type == Edit
|
2002-08-08 22:03:30 +00:00
|
|
|
*/
|
2010-01-05 20:56:37 +00:00
|
|
|
InfoMap lyx_info_map;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2008-09-23 13:18:51 +00:00
|
|
|
LyXErr & operator<<(LyXErr &, FuncCode);
|
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/// singleton instance
|
|
|
|
extern LyXAction lyxaction;
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
#endif // LYXACTION_H
|