10 #include <sigc++/signal_system.h>
12 #include "commandtags.h" // for kb_action enum
13 #include "func_status.h"
14 #include "kbsequence.h"
21 /** This class encapsulates all the LyX command operations.
22 This is the class of the LyX's "high level event handler".
23 Every user command is processed here, either invocated from
24 keyboard or from the GUI. All GUI objects, including buttons and
25 menus should use this class and never call kernel functions directly.
27 class LyXFunc : public SigC::Object {
33 /// LyX dispatcher, executes lyx actions.
34 string const dispatch(int action, string const & arg = string());
36 /// The same but uses the name of a lyx command.
37 string const dispatch(string const & cmd);
40 void miniDispatch(string const & cmd);
43 void initMiniBuffer();
46 void processKeySym(KeySym k, unsigned int state);
48 /// we need one internall which is called from inside LyXAction and
49 /// can contain the string argument.
50 func_status::value_type getStatus(int ac) const;
52 func_status::value_type getStatus(int ac,
53 string const & not_to_use_arg) const;
55 /// The last key was meta
56 bool wasMetaKey() const;
58 // These can't be global because are part of the
59 // internal state (ale970227)
60 /// Get the current keyseq string
61 string const keyseqStr() const;
63 /// Is the key sequence uncomplete?
64 bool keyseqUncomplete() const;
66 /// get options for the current keyseq
67 string const keyseqOptions() const;
69 /// True if lyxfunc reports an error
70 bool errorStat() const { return errorstat; }
71 /// Buffer to store result messages
72 void setMessage(string const & m);
73 /// Buffer to store result messages
74 void setErrorMessage(string const &) const;
75 /// Buffer to store result messages
76 string const getMessage() const { return dispatch_buffer; }
77 /// Handle a accented char keysequenze
78 void handleKeyFunc(kb_action action);
79 /// Should a hint message be displayed?
80 void setHintMessage(bool);
89 kb_sequence cancel_meta_seq;
91 unsigned meta_fake_bit;
93 void moveCursorUpdate(bool flag = true, bool selecting = false);
95 void setupLocalKeymap();
97 kb_action lyx_dead_action;
99 kb_action lyx_calling_dead_action;
100 /// Error status, only Dispatch can change this flag
101 mutable bool errorstat;
103 /** Buffer to store messages and result data. Is there a
104 good reason to have this one as static in Dispatch? (Ale)
106 mutable string dispatch_buffer;
107 /// Command name and shortcut information
108 string commandshortcut;
110 // I think the following should be moved to BufferView. (Asger)
113 void menuNew(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;
130 // This is the same for all lyxfunc objects
135 /*-------------------- inlines --------------------------*/
138 bool LyXFunc::wasMetaKey() const
140 return (meta_fake_bit != 0);
145 string const LyXFunc::keyseqStr() const
147 // Why not just remove this function
149 keyseq.print(text, true);
155 string const LyXFunc::keyseqOptions() const
157 // Why not just remove this function
159 keyseq.printOptions(text);
165 bool LyXFunc::keyseqUncomplete() const
167 return (keyseq.length > 0);
172 void LyXFunc::setHintMessage(bool hm)