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>
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(kb_keymap * kb);
56 /// return the status bar state string
57 std::string 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);
81 BufferView * view() const;
86 /// the last character added to the key sequence, in ISO encoded form
87 char_type encoded_last_key;
90 boost::scoped_ptr<kb_sequence> keyseq;
92 boost::scoped_ptr<kb_sequence> cancel_meta_seq;
94 key_modifier::state meta_fake_bit;
96 /// Error status, only Dispatch can change this flag
97 mutable bool errorstat;
99 /** Buffer to store messages and result data. Is there a
100 good reason to have this one as static in Dispatch? (Ale)
102 mutable docstring dispatch_buffer;
104 /// send a post-dispatch status message
105 void sendDispatchMessage(docstring const & msg,
106 FuncRequest const & ev);
108 // I think the following should be moved to BufferView. (Asger)
110 void menuNew(std::string const & argument, bool fromTemplate);
112 void open(std::string const &);
114 void doImport(std::string const &);
118 bool ensureBufferClean(BufferView * bv);
121 /// Implementation is in lyx_main.C
122 extern LyXFunc & theLyXFunc();
124 /// Implementation is in lyx_main.C
125 extern FuncStatus getStatus(FuncRequest const & action);
127 /// Implementation is in lyx_main.C
128 extern void dispatch(FuncRequest const & action);