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.h"
22 #include "support/docstring.h"
24 #include <boost/signals/trackable.hpp>
39 /** This class encapsulates all the LyX command operations.
40 This is the class of the LyX's "high level event handler".
41 Every user command is processed here, either invocated from
42 keyboard or from the GUI. All GUI objects, including buttons and
43 menus should use this class and never call kernel functions directly.
45 class LyXFunc : public boost::signals::trackable {
50 /// LyX dispatcher, executes lyx actions.
51 void dispatch(FuncRequest const &);
54 void setLyXView(frontend::LyXView * lv);
57 void initKeySequences(KeyMap * kb);
59 /// return the status bar state string
60 docstring const viewStatusMessage();
63 void processKeySym(KeySymbol const & key, KeyModifier state);
66 FuncStatus getStatus(FuncRequest const & action) const;
68 /// The last key was meta
69 bool wasMetaKey() const;
71 /// True if lyxfunc reports an error
72 bool errorStat() const { return errorstat; }
73 /// Buffer to store result messages
74 void setMessage(docstring const & m) const;
75 /// Buffer to store result messages
76 void setErrorMessage(docstring const &) const;
77 /// Buffer to store result messages
78 docstring const getMessage() const { return dispatch_buffer; }
79 /// Handle a accented char key sequence
80 void handleKeyFunc(kb_action action);
82 /// openFile: whether or not open a file if the file is not opened
83 /// switchToBuffer: whether or not switch to buffer if the buffer is
84 /// not the current buffer
85 void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
89 BufferView * view() const;
92 frontend::LyXView * lyx_view_;
94 /// the last character added to the key sequence, in UCS4 encoded form
95 char_type encoded_last_key;
100 KeySequence cancel_meta_seq;
102 KeyModifier meta_fake_bit;
104 /// Error status, only Dispatch can change this flag
105 mutable bool errorstat;
107 /** Buffer to store messages and result data. Is there a
108 good reason to have this one as static in Dispatch? (Ale)
110 mutable docstring dispatch_buffer;
112 /// send a post-dispatch status message
113 void sendDispatchMessage(docstring const & msg,
114 FuncRequest const & ev);
116 // I think the following should be moved to BufferView. (Asger)
118 void menuNew(std::string const & argument, bool fromTemplate);
120 void open(std::string const &);
122 void doImport(std::string const &);
128 bool ensureBufferClean(BufferView * bv);
130 void updateLayout(TextClassPtr const & oldlayout, Buffer * buffer);
133 /// Implementation is in LyX.cpp
134 extern LyXFunc & theLyXFunc();
136 /// Implementation is in LyX.cpp
137 extern FuncStatus getStatus(FuncRequest const & action);
139 /// Implementation is in LyX.cpp
140 extern void dispatch(FuncRequest const & action);