13 #include "commandtags.h"
16 /** This class encapsulates LyX action and user command operations.
34 typedef map<string, kb_action, less<string> > func_map;
36 typedef map<kb_action, func_info, less<kb_action> > info_map;
38 typedef map<unsigned int, pseudo_func, less<unsigned int> > pseudo_map;
40 typedef map<string, unsigned int, less<string> > arg_item;
42 typedef map<kb_action, arg_item, less<kb_action> > arg_map;
46 /// nothing special about this func
48 /// can be used in RO mode (perhaps this should change)
50 /// Can be used when there is no document open
52 //Interactive = 2, // Is interactive (requires a GUI)
53 Argument=4 // Requires argument
54 //MathOnly = 8, // Only math mode
55 //EtcEtc = ... // Or other attributes...
61 /** Returns an action tag from a string. Returns kb_action.
62 Include arguments in func_name ONLY if you
63 want to create new pseudo actions. */
64 int LookupFunc(string const & func_name) const;
66 /** Returns an action tag which name is the most similar to a string.
67 Don't include arguments, they would be ignored. */
68 int getApproxFunc(string const & func) const;
70 /** Returns an action name the most similar to a string.
71 Don't include arguments, they would be ignored. */
72 string getApproxFuncName(string const & func) const;
74 /// Returns a pseudo-action given an action and its argument.
75 int getPseudoAction(kb_action action, string const & arg) const;
77 /// Retrieves the real action and its argument.
78 kb_action retrieveActionArg(int i, string & arg) const;
80 /// Search for an existent pseudoaction, return -1 if it doesn't exist.
81 int searchActionArg(kb_action action, string const & arg) const;
83 /// Check if a value is a pseudo-action.
84 bool isPseudoAction(int) const;
86 /// Return the name associated with command
87 string getActionName(int action) const;
89 /// Return one line help text associated with (pseudo)action
90 string helpText(int action) const;
92 /// True if the command has `flag' set
93 bool funcHasFlag(kb_action action, func_attrib flag) const;
99 void newFunc(kb_action, string const & name,
100 string const & helpText, unsigned int attrib);
102 /** This is a list of all the LyXFunc names with the
103 coresponding action number. It is usually only used by the
104 minibuffer or when assigning commands to keys during init. */
105 func_map lyx_func_map;
107 /** This is a mapping from action number to an object holding
108 info about this action. f.ex. helptext, command name (string),
109 command attributes (ro) */
110 info_map lyx_info_map;
112 /** A mapping from the automatically created pseudo action number
113 to the real action and its argument. */
114 mutable 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. */
118 mutable arg_map lyx_arg_map;
122 /* -------------------- Inlines ------------------ */
126 bool LyXAction::isPseudoAction(int a) const
128 return a > int(LFUN_LASTACTION);