5 #include <sigc++/signal_system.h>
11 #include FORMS_H_LOCATION
12 #include "commandtags.h"
13 #include "kbsequence.h"
14 #include "insets/lyxinset.h"
20 /** This class encapsulates all the LyX command operations.
21 This is the class of the LyX's "high level event handler".
22 Every user command is processed here, either invocated from
23 keyboard or from the GUI. All GUI objects, including buttons and
24 menus should use this class and never call kernel functions directly.
26 class LyXFunc : public SigC::Object {
28 /// The status of a function.
34 /// Command cannot be executed
45 /// LyX dispatcher, executes lyx actions.
46 string const Dispatch(int action, string const & arg = string());
48 /// The same but uses the name of a lyx command.
49 string const Dispatch(string const & cmd);
52 void miniDispatch(string const & cmd);
55 void initMiniBuffer();
58 int processKeySym(KeySym k, unsigned int state);
60 /// we need one internall which is called from inside LyXAction and
61 /// can contain the string argument.
62 func_status getStatus(int ac) const;
63 func_status getStatus(int ac, string const & not_to_use_arg) const;
65 /// The last key was meta
66 bool wasMetaKey() const;
68 // These can't be global because are part of the
69 // internal state (ale970227)
70 /// Get the current keyseq string
71 string const keyseqStr() const;
73 /// Is the key sequence uncomplete?
74 bool keyseqUncomplete() const;
76 /// get options for the current keyseq
77 string const keyseqOptions() const;
79 /// True if lyxfunc reports an error
80 bool errorStat() const { return errorstat; }
81 /// Buffer to store result messages
82 void setMessage(string const & m);
83 /// Buffer to store result messages
84 void setErrorMessage(string const &) const;
85 /// Buffer to store result messages
86 string const getMessage() const { return dispatch_buffer; }
87 /// Handle a accented char keysequenze
88 void handleKeyFunc(kb_action action);
89 /// Should a hint message be displayed?
90 void setHintMessage(bool);
99 kb_sequence cancel_meta_seq;
101 unsigned meta_fake_bit;
103 void moveCursorUpdate(bool flag = true, bool selecting = false);
105 void setupLocalKeymap();
107 kb_action lyx_dead_action;
109 kb_action lyx_calling_dead_action;
110 /// Error status, only Dispatch can change this flag
111 mutable bool errorstat;
113 /** Buffer to store messages and result data. Is there a
114 good reason to have this one as static in Dispatch? (Ale)
116 mutable string dispatch_buffer;
117 /// Command name and shortcut information
118 string commandshortcut;
120 // I think the following should be moved to BufferView. (Asger)
123 void MenuNew(bool fromTemplate);
126 void Open(string const &);
129 void doImport(string const &);
136 // This return or directly text (default) of getLyXText()
138 LyXText * TEXT(bool) const;
140 // This is the same for all lyxfunc objects
145 /*-------------------- inlines --------------------------*/
148 bool LyXFunc::wasMetaKey() const
150 return (meta_fake_bit != 0);
155 string const LyXFunc::keyseqStr() const
157 // Why not just remove this function
159 keyseq.print(text, true);
165 string const LyXFunc::keyseqOptions() const
167 // Why not just remove this function
169 keyseq.printOptions(text);
175 bool LyXFunc::keyseqUncomplete() const
177 return (keyseq.length > 0);
182 void LyXFunc::setHintMessage(bool hm)
189 void operator|=(LyXFunc::func_status & fs, LyXFunc::func_status f)
191 fs = static_cast<LyXFunc::func_status>(fs | f);