11 #include "commandtags.h"
13 #include <boost/utility.hpp>
15 /** This class encapsulates LyX action and user command operations.
17 class LyXAction : boost::noncopyable {
38 typedef std::map<string, kb_action> func_map;
40 typedef std::map<kb_action, func_info> info_map;
42 typedef std::map<unsigned int, pseudo_func> pseudo_map;
44 typedef std::map<string, unsigned int> arg_item;
46 typedef std::map<kb_action, arg_item> arg_map;
50 /// nothing special about this func
52 /// can be used in RO mode (perhaps this should change)
54 /// Can be used when there is no document open
56 //Interactive = 2, // Is interactive (requires a GUI)
58 Argument = 4 // Requires argument
59 //MathOnly = 8, // Only math mode
60 //EtcEtc = ... // Or other attributes...
66 /** Returns an action tag from a string. Returns kb_action.
67 Include arguments in func_name ONLY if you
68 want to create new pseudo actions. */
69 int LookupFunc(string const & func_name) const;
71 /** Returns an action tag which name is the most similar to a string.
72 Don't include arguments, they would be ignored. */
73 int getApproxFunc(string const & func) const;
75 /** Returns an action name the most similar to a string.
76 Don't include arguments, they would be ignored. */
77 string const getApproxFuncName(string const & func) const;
79 /// Returns a pseudo-action given an action and its argument.
80 int getPseudoAction(kb_action action, string const & arg) const;
82 /// Retrieves the real action and its argument.
83 kb_action retrieveActionArg(int i, string & arg) const;
85 /// Search for an existent pseudoaction, return -1 if it doesn't exist.
86 int searchActionArg(kb_action action, string const & arg) const;
88 /// Check if a value is a pseudo-action.
89 bool isPseudoAction(int) const;
91 /// Return the name associated with command
92 string const getActionName(int action) const;
94 /// Return one line help text associated with (pseudo)action
95 string const helpText(int action) const;
97 /// True if the command has `flag' set
98 bool funcHasFlag(kb_action action, func_attrib flag) const;
100 typedef func_map::const_iterator const_func_iterator;
101 const_func_iterator func_begin() const;
102 const_func_iterator func_end() const;
107 void newFunc(kb_action, string const & name,
108 string const & helpText, unsigned int attrib);
110 /** This is a list of all the LyXFunc names with the
111 coresponding action number. It is usually only used by the
112 minibuffer or when assigning commands to keys during init. */
113 func_map lyx_func_map;
115 /** This is a mapping from action number to an object holding
116 info about this action. f.ex. helptext, command name (string),
117 command attributes (ro) */
118 info_map lyx_info_map;
120 /** A mapping from the automatically created pseudo action number
121 to the real action and its argument. */
122 mutable pseudo_map lyx_pseudo_map;
124 /** A (multi) mapping from the lyx action to all the generated
125 pseudofuncs and the arguments the action should use. */
126 mutable arg_map lyx_arg_map;
130 /* -------------------- Inlines ------------------ */
134 bool LyXAction::isPseudoAction(int a) const
136 return a > int(LFUN_LASTACTION);