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