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
|
|
|
|
enum func_type {
|
|
|
|
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;
|
2002-08-08 22:03:30 +00:00
|
|
|
/// the func_attrib 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
|
|
|
|
func_type type;
|
1999-11-22 16:19:48 +00:00
|
|
|
};
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2007-11-07 21:52:11 +00:00
|
|
|
/// noncopyable
|
|
|
|
LyXAction(LyXAction const &);
|
|
|
|
void operator=(LyXAction const &);
|
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/// type for map between a function name and its action
|
2008-03-15 01:20:36 +00:00
|
|
|
typedef std::map<std::string, FuncCode> func_map;
|
2002-08-08 22:03:30 +00:00
|
|
|
/// type for map between an action and its info
|
2008-03-15 01:20:36 +00:00
|
|
|
typedef std::map<FuncCode, FuncInfo> info_map;
|
1999-11-22 16:19:48 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/// possible "permissions" for an action
|
1999-11-22 16:19:48 +00:00
|
|
|
enum func_attrib {
|
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
|
|
|
|
SingleParUpdate = 16 //< Usually only requires this par updated
|
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
|
|
|
/**
|
|
|
|
* Returns an pseudoaction from a string
|
|
|
|
* If you include arguments in func_name, a new pseudoaction
|
|
|
|
* will be created if needed.
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
FuncRequest lookupFunc(std::string const & func_name) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/// Return the name (and argument) associated with the given (pseudo) action
|
2008-03-15 01:20:36 +00:00
|
|
|
std::string const getActionName(FuncCode action) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2008-11-15 13:52:15 +00:00
|
|
|
func_type 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
|
2008-03-15 01:20:36 +00:00
|
|
|
bool funcHasFlag(FuncCode action, func_attrib flag) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/// iterator across all real actions
|
2001-04-17 13:54:24 +00:00
|
|
|
typedef func_map::const_iterator const_func_iterator;
|
2002-08-08 22:03:30 +00:00
|
|
|
|
|
|
|
/// return an iterator to the start of all real actions
|
2001-04-17 13:54:24 +00:00
|
|
|
const_func_iterator func_begin() const;
|
2002-08-08 22:03:30 +00:00
|
|
|
|
|
|
|
/// return an iterator to the end of all real actions
|
2001-04-17 13:54:24 +00:00
|
|
|
const_func_iterator func_end() const;
|
2002-08-08 22:03:30 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
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
|
2008-03-15 01:20:36 +00:00
|
|
|
void newFunc(FuncCode, std::string const & name, unsigned int attrib, func_type type);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/**
|
|
|
|
* This is a list of all the LyXFunc names with the
|
|
|
|
* coresponding action number. It is usually only used by the
|
|
|
|
* minibuffer or when assigning commands to keys during init.
|
|
|
|
*/
|
1999-11-22 16:19:48 +00:00
|
|
|
func_map lyx_func_map;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
/**
|
|
|
|
* This is a mapping from action number to an object holding
|
2003-04-09 20:51:35 +00:00
|
|
|
* info about this action. f.ex. command name (string),
|
2002-08-08 22:03:30 +00:00
|
|
|
* command attributes (ro)
|
|
|
|
*/
|
1999-11-22 16:19:48 +00:00
|
|
|
info_map 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
|