10 #include "commandtags.h" // for kb_action enum
11 #include "FuncStatus.h"
12 #include "kbsequence.h"
15 #include "frontends/mouse_state.h"
16 #include "frontends/key_state.h"
17 #include "frontends/LyXKeySym.h"
19 #include <boost/signals/trackable.hpp>
25 /** This class encapsulates all the LyX command operations.
26 This is the class of the LyX's "high level event handler".
27 Every user command is processed here, either invocated from
28 keyboard or from the GUI. All GUI objects, including buttons and
29 menus should use this class and never call kernel functions directly.
31 class LyXFunc : public boost::signals::trackable {
37 /// LyX dispatcher, executes lyx actions.
38 string const dispatch(kb_action ac, string argument = string());
40 /// The same as dispatch, but also shows shortcuts and command
41 /// name in minibuffer if show_sc is true (more to come?)
42 void verboseDispatch(kb_action action,
43 string const & argument,
46 /// Same as above, using a pseudoaction as argument
47 void verboseDispatch(int ac, bool show_sc);
49 /// Same as above, when the command is provided as a string
50 void verboseDispatch(string const & s, bool show_sc);
53 void miniDispatch(string const & s);
56 void initMiniBuffer();
59 void processKeySym(LyXKeySymPtr key, key_modifier::state state);
61 /// we need one internal which is called from inside LyXAction and
62 /// can contain the string argument.
63 FuncStatus getStatus(int ac) const;
65 FuncStatus getStatus(kb_action action,
66 string const & argument = string()) const;
68 /// The last key was meta
69 bool wasMetaKey() const;
71 /// True if lyxfunc reports an error
72 bool errorStat() const { return errorstat; }
73 /// Buffer to store result messages
74 void setMessage(string const & m) const;
75 /// Buffer to store result messages
76 void setErrorMessage(string const &) const;
77 /// Buffer to store result messages from getStatus
78 void setStatusMessage(string const &) const;
79 /// Buffer to store result messages
80 string const getMessage() const { return dispatch_buffer; }
81 /// Buffer to store result messages
82 string const getStatusMessage() const { return status_buffer; }
83 /// Handle a accented char key sequence
84 void handleKeyFunc(kb_action action);
94 kb_sequence cancel_meta_seq;
96 key_modifier::state meta_fake_bit;
98 void moveCursorUpdate(bool flag = true, bool selecting = false);
100 void setupLocalKeymap();
102 kb_action lyx_dead_action;
104 kb_action lyx_calling_dead_action;
105 /// Error status, only Dispatch can change this flag
106 mutable bool errorstat;
108 /** Buffer to store messages and result data. Is there a
109 good reason to have this one as static in Dispatch? (Ale)
111 mutable string dispatch_buffer;
112 /** Buffer to store messages and result data from getStatus
114 mutable string status_buffer;
115 /// Command name and shortcut information
116 string commandshortcut;
118 // I think the following should be moved to BufferView. (Asger)
121 void menuNew(string const & argument, bool fromTemplate);
124 void open(string const &);
127 void doImport(string const &);
134 // This return or directly text (default) of getLyXText()
136 LyXText * TEXT(bool) const;
141 /*-------------------- inlines --------------------------*/
144 bool LyXFunc::wasMetaKey() const
146 return (meta_fake_bit != key_modifier::none);