9 #include "commandtags.h"
11 #include "insets/lyxinset.h"
16 /** This class encapsulates all the LyX command operations.
17 This is the class of the LyX's "high level event handler".
18 Every user command is processed here, either invocated from
19 keyboard or from the GUI. All GUI objects, including buttons and
20 menus should use this class and never call kernel functions directly.
24 /// The status of a function.
28 Disabled = 2, // Command cannot be executed
35 /// LyX distpatcher, executes lyx actions.
36 string Dispatch(int action, char const * arg = 0);
38 /// The same but uses the name of a lyx command.
39 string Dispatch(string const & cmd);
41 /// A keyboard event is processed to execute a lyx action.
42 int processKeyEvent(XEvent * ev);
45 func_status getStatus(int ac) const;
47 /// The last key was meta
48 bool wasMetaKey() const;
50 // These can't be global because are part of the
51 // internal state (ale970227)
52 /// Get the current keyseq string
53 string keyseqStr() const;
55 /// Is the key sequence uncomplete?
56 bool keyseqUncomplete() const;
58 /// get options for the current keyseq
59 string keyseqOptions() const;
61 /// True if lyxfunc reports an error
62 bool errorStat() const { return errorstat; }
63 /// Buffer to store result messages
64 void setMessage(string const & m);
65 /// Buffer to store result messages
66 void setErrorMessage(string const &) const;
67 /// Buffer to store result messages
68 string getMessage() const { return dispatch_buffer; }
69 /// Get next inset of this class from current cursor position
70 Inset * getInsetByCode(Inset::Code);
72 /// Should a hint message be displayed?
73 void setHintMessage(bool);
82 kb_sequence cancel_meta_seq;
84 unsigned meta_fake_bit;
86 void moveCursorUpdate(bool selecting = false);
88 void setupLocalKeymap();
90 kb_action lyx_dead_action;
92 kb_action lyx_calling_dead_action;
93 /// Error status, only Dispatch can change this flag
94 mutable bool errorstat;
96 /** Buffer to store messages and result data. Is there a
97 good reason to have this one as static in Dispatch? (Ale)
99 mutable string dispatch_buffer;
100 /// Command name and shortcut information
101 string commandshortcut;
103 // I think the following should be moved to BufferView. (Asger)
106 void MenuNew(bool fromTemplate);
112 void doImportLaTeX(bool);
115 void doImportASCII(bool);
118 void MenuInsertLyXFile(string const &);
124 /// This is the same for all lyxfunc objects
129 /*-------------------- inlines --------------------------*/
132 bool LyXFunc::wasMetaKey() const
134 return (meta_fake_bit != 0);
139 string LyXFunc::keyseqStr() const
141 // Why not just remove this function
143 keyseq.print(text, true);
149 string LyXFunc::keyseqOptions() const
151 // Why not just remove this function
153 keyseq.printOptions(text);
159 bool LyXFunc::keyseqUncomplete() const
161 return (keyseq.length > 0);
166 void LyXFunc::setHintMessage(bool hm)
173 void operator|=(LyXFunc::func_status & fs, LyXFunc::func_status f)
175 fs = static_cast<LyXFunc::func_status>(fs | f);