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"
21 #include "support/docstring.h"
23 #include <boost/scoped_ptr.hpp>
24 #include <boost/signals/trackable.hpp>
36 /** This class encapsulates all the LyX command operations.
37 This is the class of the LyX's "high level event handler".
38 Every user command is processed here, either invocated from
39 keyboard or from the GUI. All GUI objects, including buttons and
40 menus should use this class and never call kernel functions directly.
42 class LyXFunc : public boost::signals::trackable {
47 /// LyX dispatcher, executes lyx actions.
48 void dispatch(FuncRequest const &);
51 void setLyXView(LyXView * lv);
54 void initKeySequences(KeyMap * kb);
56 /// return the status bar state string
57 docstring const viewStatusMessage();
60 void processKeySym(LyXKeySymPtr key, key_modifier::state state);
63 FuncStatus getStatus(FuncRequest const & action) const;
65 /// The last key was meta
66 bool wasMetaKey() const;
68 /// True if lyxfunc reports an error
69 bool errorStat() const { return errorstat; }
70 /// Buffer to store result messages
71 void setMessage(docstring const & m) const;
72 /// Buffer to store result messages
73 void setErrorMessage(docstring const &) const;
74 /// Buffer to store result messages
75 docstring const getMessage() const { return dispatch_buffer; }
76 /// Handle a accented char key sequence
77 void handleKeyFunc(kb_action action);
79 /// openFile: whether or not open a file if the file is not opened
80 /// switchToBuffer: whether or not switch to buffer if the buffer is
81 /// not the current buffer
82 void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
86 BufferView * view() const;
91 /// the last character added to the key sequence, in UCS4 encoded form
92 char_type encoded_last_key;
95 boost::scoped_ptr<KeySequence> keyseq;
97 boost::scoped_ptr<KeySequence> cancel_meta_seq;
99 key_modifier::state meta_fake_bit;
101 /// Error status, only Dispatch can change this flag
102 mutable bool errorstat;
104 /** Buffer to store messages and result data. Is there a
105 good reason to have this one as static in Dispatch? (Ale)
107 mutable docstring dispatch_buffer;
109 /// send a post-dispatch status message
110 void sendDispatchMessage(docstring const & msg,
111 FuncRequest const & ev);
113 // I think the following should be moved to BufferView. (Asger)
115 void menuNew(std::string const & argument, bool fromTemplate);
117 void open(std::string const &);
119 void doImport(std::string const &);
125 bool ensureBufferClean(BufferView * bv);
128 /// Implementation is in LyX.cpp
129 extern LyXFunc & theLyXFunc();
131 /// Implementation is in LyX.cpp
132 extern FuncStatus getStatus(FuncRequest const & action);
134 /// Implementation is in LyX.cpp
135 extern void dispatch(FuncRequest const & action);