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 "kbsequence.h"
21 #include "support/docstring.h"
23 #include <boost/scoped_ptr.hpp>
24 #include <boost/signals/trackable.hpp>
35 /** This class encapsulates all the LyX command operations.
36 This is the class of the LyX's "high level event handler".
37 Every user command is processed here, either invocated from
38 keyboard or from the GUI. All GUI objects, including buttons and
39 menus should use this class and never call kernel functions directly.
41 class LyXFunc : public boost::signals::trackable {
46 /// LyX dispatcher, executes lyx actions.
47 void dispatch(FuncRequest const &);
50 void setLyXView(LyXView * lv);
53 void initKeySequences(kb_keymap * kb);
55 /// return the status bar state string
56 std::string const viewStatusMessage();
59 void processKeySym(LyXKeySymPtr key, key_modifier::state state);
62 FuncStatus getStatus(FuncRequest const & action) const;
64 /// The last key was meta
65 bool wasMetaKey() const;
67 /// True if lyxfunc reports an error
68 bool errorStat() const { return errorstat; }
69 /// Buffer to store result messages
70 void setMessage(lyx::docstring const & m) const;
71 /// Buffer to store result messages
72 void setErrorMessage(lyx::docstring const &) const;
73 /// Buffer to store result messages
74 lyx::docstring const getMessage() const { return dispatch_buffer; }
75 /// Handle a accented char key sequence
76 void handleKeyFunc(kb_action action);
80 BufferView * view() const;
85 /// the last character added to the key sequence, in ISO encoded form
86 lyx::char_type encoded_last_key;
89 boost::scoped_ptr<kb_sequence> keyseq;
91 boost::scoped_ptr<kb_sequence> cancel_meta_seq;
93 key_modifier::state meta_fake_bit;
95 /// Error status, only Dispatch can change this flag
96 mutable bool errorstat;
98 /** Buffer to store messages and result data. Is there a
99 good reason to have this one as static in Dispatch? (Ale)
101 mutable lyx::docstring dispatch_buffer;
103 /// send a post-dispatch status message
104 void sendDispatchMessage(lyx::docstring const & msg,
105 FuncRequest const & ev);
107 // I think the following should be moved to BufferView. (Asger)
109 void menuNew(std::string const & argument, bool fromTemplate);
111 void open(std::string const &);
113 void doImport(std::string const &);
117 bool ensureBufferClean(BufferView * bv);
120 /// Implementation is in lyx_main.C
121 extern LyXFunc & theLyXFunc();
125 /// Implementation is in lyx_main.C
126 extern FuncStatus getStatus(FuncRequest const & action);
128 /// Implementation is in lyx_main.C
129 extern void dispatch(FuncRequest const & action);