11 #include "funcrequest.h"
12 #include <boost/utility.hpp>
14 /** This class encapsulates LyX action and user command operations.
17 class LyXAction : boost::noncopyable {
31 typedef std::map<string, kb_action> func_map;
33 typedef std::map<kb_action, func_info> info_map;
35 typedef std::map<unsigned int, FuncRequest> pseudo_map;
37 typedef std::map<string, unsigned int> arg_item;
39 typedef std::map<kb_action, arg_item> arg_map;
43 /// nothing special about this func
45 /// can be used in RO mode (perhaps this should change)
47 /// Can be used when there is no document open
49 //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 pseudoaction from a string
60 If you include arguments in func_name, a new psedoaction will be
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 const 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 /// Return the name associated with command
82 string const getActionName(int action) const;
84 /// Return one line help text associated with (pseudo)action
85 string const helpText(int action) const;
87 /// True if the command has `flag' set
88 bool funcHasFlag(kb_action action, func_attrib flag) const;
90 typedef func_map::const_iterator const_func_iterator;
91 const_func_iterator func_begin() const;
92 const_func_iterator func_end() 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;