4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * \author André Pönitz
12 * Full author contact details are available in file CREDITS.
18 #include "KeySequence.h"
20 #include "TextClass_ptr.h"
22 #include "support/docstring.h"
24 #include <boost/scoped_ptr.hpp>
25 #include <boost/signals/trackable.hpp>
40 /** This class encapsulates all the LyX command operations.
41 This is the class of the LyX's "high level event handler".
42 Every user command is processed here, either invocated from
43 keyboard or from the GUI. All GUI objects, including buttons and
44 menus should use this class and never call kernel functions directly.
46 class LyXFunc : public boost::signals::trackable {
51 /// LyX dispatcher, executes lyx actions.
52 void dispatch(FuncRequest const &);
55 void setLyXView(frontend::LyXView * lv);
58 void initKeySequences(KeyMap * kb);
60 /// return the status bar state string
61 docstring const viewStatusMessage();
64 void processKeySym(KeySymbolPtr key, key_modifier::state state);
67 FuncStatus getStatus(FuncRequest const & action) const;
69 /// The last key was meta
70 bool wasMetaKey() const;
72 /// True if lyxfunc reports an error
73 bool errorStat() const { return errorstat; }
74 /// Buffer to store result messages
75 void setMessage(docstring const & m) const;
76 /// Buffer to store result messages
77 void setErrorMessage(docstring const &) const;
78 /// Buffer to store result messages
79 docstring const getMessage() const { return dispatch_buffer; }
80 /// Handle a accented char key sequence
81 void handleKeyFunc(kb_action action);
83 /// openFile: whether or not open a file if the file is not opened
84 /// switchToBuffer: whether or not switch to buffer if the buffer is
85 /// not the current buffer
86 void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
90 BufferView * view() const;
93 frontend::LyXView * lyx_view_;
95 /// the last character added to the key sequence, in UCS4 encoded form
96 char_type encoded_last_key;
99 boost::scoped_ptr<KeySequence> keyseq;
101 boost::scoped_ptr<KeySequence> cancel_meta_seq;
103 key_modifier::state meta_fake_bit;
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 docstring dispatch_buffer;
113 /// send a post-dispatch status message
114 void sendDispatchMessage(docstring const & msg,
115 FuncRequest const & ev);
117 // I think the following should be moved to BufferView. (Asger)
119 void menuNew(std::string const & argument, bool fromTemplate);
121 void open(std::string const &);
123 void doImport(std::string const &);
129 bool ensureBufferClean(BufferView * bv);
131 void updateLayout(TextClass_ptr const & oldlayout, Buffer * buffer);
134 /// Implementation is in LyX.cpp
135 extern LyXFunc & theLyXFunc();
137 /// Implementation is in LyX.cpp
138 extern FuncStatus getStatus(FuncRequest const & action);
140 /// Implementation is in LyX.cpp
141 extern void dispatch(FuncRequest const & action);