11 #include "commandtags.h"
13 #include "support/utility.hpp"
15 /** This class encapsulates LyX action and user command operations.
17 class LyXAction : public 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;
104 void newFunc(kb_action, string const & name,
105 string const & helpText, unsigned int attrib);
107 /** This is a list of all the LyXFunc names with the
108 coresponding action number. It is usually only used by the
109 minibuffer or when assigning commands to keys during init. */
110 func_map lyx_func_map;
112 /** This is a mapping from action number to an object holding
113 info about this action. f.ex. helptext, command name (string),
114 command attributes (ro) */
115 info_map lyx_info_map;
117 /** A mapping from the automatically created pseudo action number
118 to the real action and its argument. */
119 mutable pseudo_map lyx_pseudo_map;
121 /** A (multi) mapping from the lyx action to all the generated
122 pseudofuncs and the arguments the action should use. */
123 mutable arg_map lyx_arg_map;
127 /* -------------------- Inlines ------------------ */
131 bool LyXAction::isPseudoAction(int a) const
133 return a > int(LFUN_LASTACTION);