Prepare ANNOUNCE and NEWS for rc2
[lyx.git] / src / LyXAction.h
blob70381a00227556b8ee6a15c0ee25d985343701b0
1 // -*- C++ -*-
2 /**
3 * \file LyXAction.h
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
8 * \author John Levon
10 * Full author contact details are available in file CREDITS.
13 #ifndef LYXACTION_H
14 #define LYXACTION_H
16 #include "FuncCode.h"
18 #include <map>
19 #include <string>
22 namespace lyx {
24 class FuncRequest;
26 /**
27 * This class is a container for LyX actions. It associates a name to
28 * most of them and describes some of their properties.
30 class LyXAction {
31 public:
32 /// category of an action, used in the Shortcuts dialog
33 enum func_type {
34 Hidden, //< Not listed for configuration
35 Edit, //< Cursor and mouse movement, copy/paste etc
36 Math, //< Mathematics
37 Buffer, //< Buffer and window related
38 Layout, //< Font, Layout and textclass related
39 System, //< Lyx preference, server etc
42 private:
43 /// information for an action
44 struct FuncInfo {
45 /// the action name
46 std::string name;
47 /// the func_attrib values set
48 unsigned int attrib;
49 /// the category of this func
50 func_type type;
53 public:
54 /// noncopyable
55 LyXAction(LyXAction const &);
56 void operator=(LyXAction const &);
58 /// type for map between a function name and its action
59 typedef std::map<std::string, FuncCode> func_map;
60 /// type for map between an action and its info
61 typedef std::map<FuncCode, FuncInfo> info_map;
63 /// possible "permissions" for an action
64 enum func_attrib {
65 Noop = 0, //< nothing special about this func
66 ReadOnly = 1, //< can be used in RO mode (perhaps this should change); no automatic markDirty
67 NoBuffer = 2, //< Can be used when there is no document open
68 Argument = 4, //< Requires argument
69 NoUpdate = 8, //< Does not (usually) require update
70 SingleParUpdate = 16 //< Usually only requires this par updated
73 LyXAction();
75 /**
76 * Returns an pseudoaction from a string
77 * If you include arguments in func_name, a new pseudoaction
78 * will be created if needed.
80 FuncRequest lookupFunc(std::string const & func_name) const;
82 /// Return the name (and argument) associated with the given (pseudo) action
83 std::string const getActionName(FuncCode action) const;
85 func_type const getActionType(FuncCode action) const;
87 /// True if the command has `flag' set
88 bool funcHasFlag(FuncCode action, func_attrib flag) const;
90 /// iterator across all real actions
91 typedef func_map::const_iterator const_func_iterator;
93 /// return an iterator to the start of all real actions
94 const_func_iterator func_begin() const;
96 /// return an iterator to the end of all real actions
97 const_func_iterator func_end() const;
99 private:
100 /// populate the action container with our actions
101 void init();
102 /// add the given action
103 void newFunc(FuncCode, std::string const & name, unsigned int attrib, func_type type);
106 * This is a list of all the LyXFunc names with the
107 * coresponding action number. It is usually only used by the
108 * minibuffer or when assigning commands to keys during init.
110 func_map lyx_func_map;
113 * This is a mapping from action number to an object holding
114 * info about this action. f.ex. command name (string),
115 * command attributes (ro)
117 info_map lyx_info_map;
120 /// singleton instance
121 extern LyXAction lyxaction;
124 } // namespace lyx
126 #endif // LYXACTION_H