]> git.lyx.org Git - lyx.git/blob - src/LyXFunc.h
rename MathArray into MathData
[lyx.git] / src / LyXFunc.h
1 // -*- C++ -*-
2 /**
3  * \file LyXFunc.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  * \author John Levon
10  * \author André Pönitz
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef LYXFUNC_H
16 #define LYXFUNC_H
17
18 #include "kb_sequence.h"
19 #include "lfuns.h"
20
21 #include "support/docstring.h"
22
23 #include <boost/scoped_ptr.hpp>
24 #include <boost/signals/trackable.hpp>
25
26 namespace lyx {
27
28 class BufferView;
29 class FuncRequest;
30 class FuncStatus;
31 class LyXKeySym;
32 class LyXText;
33 class LyXView;
34
35
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.
41 */
42 class LyXFunc : public boost::signals::trackable {
43 public:
44         ///
45         explicit LyXFunc();
46
47         /// LyX dispatcher, executes lyx actions.
48         void dispatch(FuncRequest const &);
49
50         ///
51         void setLyXView(LyXView * lv);
52
53         ///
54         void initKeySequences(kb_keymap * kb);
55
56         /// return the status bar state string
57         docstring const viewStatusMessage();
58
59         ///
60         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
61
62         ///
63         FuncStatus getStatus(FuncRequest const & action) const;
64
65         /// The last key was meta
66         bool wasMetaKey() const;
67
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);
78         /// goto a bookmark
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);
83
84 private:
85         ///
86         BufferView * view() const;
87
88         ///
89         LyXView * lyx_view_;
90
91         /// the last character added to the key sequence, in UCS4 encoded form
92         char_type encoded_last_key;
93
94         ///
95         boost::scoped_ptr<kb_sequence> keyseq;
96         ///
97         boost::scoped_ptr<kb_sequence> cancel_meta_seq;
98         ///
99         key_modifier::state meta_fake_bit;
100
101         /// Error status, only Dispatch can change this flag
102         mutable bool errorstat;
103
104         /** Buffer to store messages and result data. Is there a
105             good reason to have this one as static in Dispatch? (Ale)
106         */
107         mutable docstring dispatch_buffer;
108
109         /// send a post-dispatch status message
110         void sendDispatchMessage(docstring const & msg,
111                 FuncRequest const & ev);
112
113         // I think the following should be moved to BufferView. (Asger)
114         ///
115         void menuNew(std::string const & argument, bool fromTemplate);
116         ///
117         void open(std::string const &);
118         ///
119         void doImport(std::string const &);
120         ///
121         void closeBuffer();
122         ///
123         void reloadBuffer();
124         ///
125         bool ensureBufferClean(BufferView * bv);
126 };
127
128 /// Implementation is in LyX.cpp
129 extern LyXFunc & theLyXFunc();
130
131 /// Implementation is in LyX.cpp
132 extern FuncStatus getStatus(FuncRequest const & action);
133
134 /// Implementation is in LyX.cpp
135 extern void dispatch(FuncRequest const & action);
136
137 } // namespace lyx
138
139 #endif