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 void dispatch(kb_action ac, string argument = string(), bool verbose = false);
40 /// Dispatch via a string argument
41 void dispatch(string const & s, bool verbose = false);
43 /// Dispatch via a pseudo action, also displaying shortcut/command name
44 void dispatch(int ac, bool verbose = false);
46 /// return the status bar state string
47 string const view_status_message();
50 void processKeySym(LyXKeySymPtr key, key_modifier::state state);
52 /// we need one internal which is called from inside LyXAction and
53 /// can contain the string argument.
54 FuncStatus getStatus(int ac) const;
56 FuncStatus getStatus(kb_action action,
57 string const & argument = string()) const;
59 /// The last key was meta
60 bool wasMetaKey() const;
62 /// True if lyxfunc reports an error
63 bool errorStat() const { return errorstat; }
64 /// Buffer to store result messages
65 void setMessage(string const & m) const;
66 /// Buffer to store result messages
67 void setErrorMessage(string const &) const;
68 /// Buffer to store result messages from getStatus
69 void setStatusMessage(string const &) const;
70 /// Buffer to store result messages
71 string const getMessage() const { return dispatch_buffer; }
72 /// Buffer to store result messages
73 string const getStatusMessage() const { return status_buffer; }
74 /// Handle a accented char key sequence
75 void handleKeyFunc(kb_action action);
85 kb_sequence cancel_meta_seq;
87 key_modifier::state meta_fake_bit;
89 void moveCursorUpdate(bool flag = true, bool selecting = false);
91 void setupLocalKeymap();
93 kb_action lyx_dead_action;
95 kb_action lyx_calling_dead_action;
96 /// Error status, only Dispatch can change this flag
97 mutable bool errorstat;
99 /** Buffer to store messages and result data. Is there a
100 good reason to have this one as static in Dispatch? (Ale)
102 mutable string dispatch_buffer;
103 /** Buffer to store messages and result data from getStatus
105 mutable string status_buffer;
107 /// send a post-dispatch status message
108 void sendDispatchMessage(string const & msg, kb_action ac, string const & arg, bool verbose);
110 // I think the following should be moved to BufferView. (Asger)
113 void menuNew(string const & argument, bool fromTemplate);
116 void open(string const &);
119 void doImport(string const &);
126 // This return or directly text (default) of getLyXText()
128 LyXText * TEXT(bool) const;
133 /*-------------------- inlines --------------------------*/
136 bool LyXFunc::wasMetaKey() const
138 return (meta_fake_bit != key_modifier::none);