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>
38 /** This class encapsulates all the LyX command operations.
39 This is the class of the LyX's "high level event handler".
40 Every user command is processed here, either invocated from
41 keyboard or from the GUI. All GUI objects, including buttons and
42 menus should use this class and never call kernel functions directly.
44 class LyXFunc : public boost::signals::trackable {
49 /// LyX dispatcher, executes lyx actions.
50 void dispatch(FuncRequest const &);
53 void setLyXView(frontend::LyXView * lv);
56 void initKeySequences(KeyMap * kb);
58 /// return the status bar state string
59 docstring const viewStatusMessage();
62 void processKeySym(KeySymbolPtr key, key_modifier::state state);
65 FuncStatus getStatus(FuncRequest const & action) const;
67 /// The last key was meta
68 bool wasMetaKey() const;
70 /// True if lyxfunc reports an error
71 bool errorStat() const { return errorstat; }
72 /// Buffer to store result messages
73 void setMessage(docstring const & m) const;
74 /// Buffer to store result messages
75 void setErrorMessage(docstring const &) const;
76 /// Buffer to store result messages
77 docstring const getMessage() const { return dispatch_buffer; }
78 /// Handle a accented char key sequence
79 void handleKeyFunc(kb_action action);
81 /// openFile: whether or not open a file if the file is not opened
82 /// switchToBuffer: whether or not switch to buffer if the buffer is
83 /// not the current buffer
84 void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
88 BufferView * view() const;
91 frontend::LyXView * lyx_view_;
93 /// the last character added to the key sequence, in UCS4 encoded form
94 char_type encoded_last_key;
97 boost::scoped_ptr<KeySequence> keyseq;
99 boost::scoped_ptr<KeySequence> cancel_meta_seq;
101 key_modifier::state meta_fake_bit;
103 /// Error status, only Dispatch can change this flag
104 mutable bool errorstat;
106 /** Buffer to store messages and result data. Is there a
107 good reason to have this one as static in Dispatch? (Ale)
109 mutable docstring dispatch_buffer;
111 /// send a post-dispatch status message
112 void sendDispatchMessage(docstring const & msg,
113 FuncRequest const & ev);
115 // I think the following should be moved to BufferView. (Asger)
117 void menuNew(std::string const & argument, bool fromTemplate);
119 void open(std::string const &);
121 void doImport(std::string const &);
127 bool ensureBufferClean(BufferView * bv);
130 /// Implementation is in LyX.cpp
131 extern LyXFunc & theLyXFunc();
133 /// Implementation is in LyX.cpp
134 extern FuncStatus getStatus(FuncRequest const & action);
136 /// Implementation is in LyX.cpp
137 extern void dispatch(FuncRequest const & action);