4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
28 * This class is a container for LyX actions. It associates a name to
29 * most of them and describes some of their properties.
33 /// category of an action, used in the Shortcuts dialog
35 Hidden, //< Not listed for configuration
36 Edit, //< Cursor and mouse movement, copy/paste etc
38 Buffer, //< Buffer and window related
39 Layout, //< Font, Layout and textclass related
40 System, //< Lyx preference, server etc
44 /// information for an action
48 /// the FuncAttribs values set
50 /// the category of this func
53 /// type for map between a function name and its action
54 typedef std::map<std::string, FuncCode> FuncMap;
55 /// type for map between an action and its info
56 typedef std::map<FuncCode, FuncInfo> InfoMap;
59 /// possible "permissions" for an action
61 Noop = 0, //< Nothing special about this func
62 ReadOnly = 1, //< Can be used in RO mode (perhaps this should change); no automatic markDirty
63 NoBuffer = 2, //< Can be used when there is no document open
64 Argument = 4, //< Requires argument
65 NoUpdate = 8, //< Does not (usually) require update
66 SingleParUpdate = 16, //< Usually only requires this par updated
67 AtPoint = 32, //< dispatch first to inset at cursor if there is one
68 NoInternal = 64, //< Cannot be used for internal, non-document Buffers
74 * Creates a FuncRequest from a string of the form:
75 * lyx-function [argument]
76 * where the argument is optional and "lyx-function" is in the form you'd
77 * enter it in the mini-buffer.
79 FuncRequest lookupFunc(std::string const & func_name) const;
81 /// Return the command name associated with the given action
82 /// Thus: getActionName(LFUN_ERT_INSERT) --> "ert-insert".
83 std::string const getActionName(FuncCode action) const;
85 FuncType getActionType(FuncCode action) const;
87 /// True if the command has `flag' set
88 bool funcHasFlag(FuncCode action, FuncAttribs flag) const;
90 /// iterator across all LFUNs
91 typedef FuncMap::const_iterator const_iterator;
93 /// return an iterator to the start of the list of LFUNs
94 const_iterator func_begin() const;
96 /// return an iterator to one past the end of the list of LFUNs
97 const_iterator func_end() const;
101 LyXAction(LyXAction const &);
102 void operator=(LyXAction const &);
104 /// populate the action container with our actions
106 /// add the given action
107 void newFunc(FuncCode, std::string const & name, unsigned int attrib, FuncType type);
110 * This maps LyX function names to function codes, e.g.:
111 * lyx_func_map["ert-insert"] == LFUN_ERT_INSERT
113 FuncMap lyx_func_map;
116 * This maps function codes to objects holding info about the corresponding
118 * FuncInfo const & ert = lyx_info_map[LFUN_ERT_INSERT];
120 * ert.name == "ert-insert"'
124 InfoMap lyx_info_map;
127 LyXErr & operator<<(LyXErr &, FuncCode);
129 /// singleton instance
130 extern LyXAction lyxaction;
135 #endif // LYXACTION_H