4 * Copyright 1995-2002 the LyX Team
5 * Read the file COPYING
13 #include "funcrequest.h"
14 #include <boost/utility.hpp>
17 * This class is a container for LyX actions. It also
18 * stores and managers "pseudo-actions". Pseudo-actions
19 * are not part of the kb_action enum, but are created
20 * dynamically, for encapsulating a real action and an
21 * argument. They are used for things like the menus.
23 class LyXAction : boost::noncopyable {
25 /// information for an action
29 /// the func_attrib values set
34 /// type for map between a function name and its action
35 typedef std::map<string, kb_action> func_map;
36 /// type for map between an action and its info
37 typedef std::map<kb_action, func_info> info_map;
38 /// type for a map between a pseudo-action and its stored action/arg
39 typedef std::map<unsigned int, FuncRequest> pseudo_map;
40 /// map from argument to pseudo-action
41 typedef std::map<string, unsigned int> arg_item;
42 /// map from an action to all its dependent pseudo-actions
43 typedef std::map<kb_action, arg_item> arg_map;
45 /// possible "permissions" for an action
47 Noop = 0, //< nothing special about this func
48 ReadOnly = 1, //< can be used in RO mode (perhaps this should change)
49 NoBuffer = 2, //< Can be used when there is no document open
50 Argument = 4 //< Requires argument
56 * Returns an pseudoaction from a string
57 * If you include arguments in func_name, a new pseudoaction
58 * will be created if needed.
60 int LookupFunc(string const & func_name);
62 /// Returns a pseudo-action given an action and its argument.
63 int getPseudoAction(kb_action action, string const & arg);
66 * Given a pseudo-action, return the real action and
69 FuncRequest retrieveActionArg(int pseudo) const;
71 /// Search for an existent pseudoaction, return -1 if it doesn't exist.
72 int searchActionArg(kb_action action, string const & arg) const;
74 /// Return the name (and argument) associated with the given (pseudo) action
75 string const getActionName(int action) const;
77 /// True if the command has `flag' set
78 bool funcHasFlag(kb_action action, func_attrib flag) const;
80 /// iterator across all real actions
81 typedef func_map::const_iterator const_func_iterator;
83 /// return an iterator to the start of all real actions
84 const_func_iterator func_begin() const;
86 /// return an iterator to the end of all real actions
87 const_func_iterator func_end() const;
90 /// populate the action container with our actions
92 /// add the given action
93 void newFunc(kb_action, string const & name, unsigned int attrib);
96 * This is a list of all the LyXFunc names with the
97 * coresponding action number. It is usually only used by the
98 * minibuffer or when assigning commands to keys during init.
100 func_map lyx_func_map;
103 * This is a mapping from action number to an object holding
104 * info about this action. f.ex. command name (string),
105 * command attributes (ro)
107 info_map lyx_info_map;
110 * A mapping from the automatically created pseudo action number
111 * to the real action and its argument.
113 pseudo_map lyx_pseudo_map;
116 * A (multi) mapping from the lyx action to all the generated
117 * pseudofuncs and the arguments the action should use.
122 /// singleton instance
123 extern LyXAction lyxaction;
125 #endif // LYXACTION_H