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.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \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
|
|
|
|
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "lfuns.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;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-08-08 22:03:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* This class is a container for LyX actions. It also
|
|
|
|
|
* stores and managers "pseudo-actions". Pseudo-actions
|
|
|
|
|
* are not part of the kb_action enum, but are created
|
|
|
|
|
* dynamically, for encapsulating a real action and an
|
|
|
|
|
* argument. They are used for things like the menus.
|
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
|
1999-11-22 16:19:48 +00:00
|
|
|
|
struct func_info {
|
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
|
2003-10-06 15:43:21 +00:00
|
|
|
|
typedef std::map<std::string, kb_action> func_map;
|
2002-08-08 22:03:30 +00:00
|
|
|
|
/// type for map between an action and its info
|
2000-04-04 00:19:15 +00:00
|
|
|
|
typedef std::map<kb_action, func_info> 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 {
|
2002-08-08 22:03:30 +00:00
|
|
|
|
Noop = 0, //< nothing special about this func
|
|
|
|
|
ReadOnly = 1, //< can be used in RO mode (perhaps this should change)
|
|
|
|
|
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
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const getActionName(kb_action action) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-10-18 15:48:51 +00:00
|
|
|
|
func_type const getActionType(kb_action action) const;
|
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
/// True if the command has `flag' set
|
|
|
|
|
bool funcHasFlag(kb_action 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
|
2007-10-18 15:48:51 +00:00
|
|
|
|
void newFunc(kb_action, 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
|
|
|
|
|
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
|