]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
hopefully fix tex2lyx linking.
[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 "kbsequence.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         std::string 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
79 private:
80         ///
81         BufferView * view() const;
82
83         ///
84         LyXView * lyx_view_;
85
86         /// the last character added to the key sequence, in ISO encoded form
87         char_type encoded_last_key;
88
89         ///
90         boost::scoped_ptr<kb_sequence> keyseq;
91         ///
92         boost::scoped_ptr<kb_sequence> cancel_meta_seq;
93         ///
94         key_modifier::state meta_fake_bit;
95
96         /// Error status, only Dispatch can change this flag
97         mutable bool errorstat;
98
99         /** Buffer to store messages and result data. Is there a
100             good reason to have this one as static in Dispatch? (Ale)
101         */
102         mutable docstring dispatch_buffer;
103
104         /// send a post-dispatch status message
105         void sendDispatchMessage(docstring const & msg,
106                 FuncRequest const & ev);
107
108         // I think the following should be moved to BufferView. (Asger)
109         ///
110         void menuNew(std::string const & argument, bool fromTemplate);
111         ///
112         void open(std::string const &);
113         ///
114         void doImport(std::string const &);
115         ///
116         void closeBuffer();
117         ///
118         bool ensureBufferClean(BufferView * bv);
119 };
120
121 /// Implementation is in lyx_main.C
122 extern LyXFunc & theLyXFunc();
123
124 /// Implementation is in lyx_main.C
125 extern FuncStatus getStatus(FuncRequest const & action);
126
127 /// Implementation is in lyx_main.C
128 extern void dispatch(FuncRequest const & action);
129
130 } // namespace lyx
131
132 #endif