4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
18 #include <boost/utility.hpp>
29 * This class is a container for LyX actions. It also
30 * stores and managers "pseudo-actions". Pseudo-actions
31 * are not part of the kb_action enum, but are created
32 * dynamically, for encapsulating a real action and an
33 * argument. They are used for things like the menus.
35 class LyXAction : boost::noncopyable {
37 /// information for an action
41 /// the func_attrib values set
46 /// type for map between a function name and its action
47 typedef std::map<std::string, kb_action> func_map;
48 /// type for map between an action and its info
49 typedef std::map<kb_action, func_info> info_map;
51 /// possible "permissions" for an action
53 Noop = 0, //< nothing special about this func
54 ReadOnly = 1, //< can be used in RO mode (perhaps this should change)
55 NoBuffer = 2, //< Can be used when there is no document open
56 Argument = 4, //< Requires argument
57 NoUpdate = 8, //< Does not (usually) require update
58 SingleParUpdate = 16 //< Usually only requires this par updated
64 * Returns an pseudoaction from a string
65 * If you include arguments in func_name, a new pseudoaction
66 * will be created if needed.
68 FuncRequest lookupFunc(std::string const & func_name) const;
70 /// Return the name (and argument) associated with the given (pseudo) action
71 std::string const getActionName(kb_action action) const;
73 /// True if the command has `flag' set
74 bool funcHasFlag(kb_action action, func_attrib flag) const;
76 /// iterator across all real actions
77 typedef func_map::const_iterator const_func_iterator;
79 /// return an iterator to the start of all real actions
80 const_func_iterator func_begin() const;
82 /// return an iterator to the end of all real actions
83 const_func_iterator func_end() const;
86 /// populate the action container with our actions
88 /// add the given action
89 void newFunc(kb_action, std::string const & name, unsigned int attrib);
92 * This is a list of all the LyXFunc names with the
93 * coresponding action number. It is usually only used by the
94 * minibuffer or when assigning commands to keys during init.
96 func_map lyx_func_map;
99 * This is a mapping from action number to an object holding
100 * info about this action. f.ex. command name (string),
101 * command attributes (ro)
103 info_map lyx_info_map;
106 /// singleton instance
107 extern LyXAction lyxaction;
112 #endif // LYXACTION_H