]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
5790b81b1cc68872a678ba2bb73704ec1576eaa7
[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
27 class BufferView;
28 class FuncRequest;
29 class FuncStatus;
30 class LyXKeySym;
31 class LyXText;
32 class LyXView;
33
34
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.
40 */
41 class LyXFunc : public boost::signals::trackable {
42 public:
43         ///
44         explicit LyXFunc();
45
46         /// LyX dispatcher, executes lyx actions.
47         void dispatch(FuncRequest const &);
48
49         ///
50         void setLyXView(LyXView * lv);
51
52         ///
53         void initKeySequences(kb_keymap * kb);
54
55         /// return the status bar state string
56         std::string const viewStatusMessage();
57
58         ///
59         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
60
61         ///
62         FuncStatus getStatus(FuncRequest const & action) const;
63
64         /// The last key was meta
65         bool wasMetaKey() const;
66
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);
77
78 private:
79         ///
80         BufferView * view() const;
81
82         ///
83         LyXView * lyx_view_;
84
85         /// the last character added to the key sequence, in ISO encoded form
86         lyx::char_type encoded_last_key;
87
88         ///
89         boost::scoped_ptr<kb_sequence> keyseq;
90         ///
91         boost::scoped_ptr<kb_sequence> cancel_meta_seq;
92         ///
93         key_modifier::state meta_fake_bit;
94
95         /// Error status, only Dispatch can change this flag
96         mutable bool errorstat;
97
98         /** Buffer to store messages and result data. Is there a
99             good reason to have this one as static in Dispatch? (Ale)
100         */
101         mutable lyx::docstring dispatch_buffer;
102
103         /// send a post-dispatch status message
104         void sendDispatchMessage(lyx::docstring const & msg,
105                 FuncRequest const & ev);
106
107         // I think the following should be moved to BufferView. (Asger)
108         ///
109         void menuNew(std::string const & argument, bool fromTemplate);
110         ///
111         void open(std::string const &);
112         ///
113         void doImport(std::string const &);
114         ///
115         void closeBuffer();
116         ///
117         bool ensureBufferClean(BufferView * bv);
118 };
119
120 /// Implementation is in lyx_main.C
121 extern LyXFunc & theLyXFunc();
122
123 namespace lyx {
124
125 /// Implementation is in lyx_main.C
126 extern FuncStatus getStatus(FuncRequest const & action);
127
128 /// Implementation is in lyx_main.C
129 extern void dispatch(FuncRequest const & action);
130 }
131
132 #endif