]> git.lyx.org Git - lyx.git/blob - src/LyXFunc.h
make index label translatable
[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 "KeySequence.h"
19 #include "lfuns.h"
20 #include "TextClass_ptr.h"
21
22 #include "support/docstring.h"
23
24 #include <boost/scoped_ptr.hpp>
25 #include <boost/signals/trackable.hpp>
26
27 namespace lyx {
28
29 class Buffer;
30 class BufferView;
31 class FuncRequest;
32 class FuncStatus;
33 class KeySymbol;
34 class Text;
35
36 namespace frontend {
37 class LyXView;
38 }
39
40 /** This class encapsulates all the LyX command operations.
41     This is the class of the LyX's "high level event handler".
42     Every user command is processed here, either invocated from
43     keyboard or from the GUI. All GUI objects, including buttons and
44     menus should use this class and never call kernel functions directly.
45 */
46 class LyXFunc : public boost::signals::trackable {
47 public:
48         ///
49         explicit LyXFunc();
50
51         /// LyX dispatcher, executes lyx actions.
52         void dispatch(FuncRequest const &);
53
54         ///
55         void setLyXView(frontend::LyXView * lv);
56
57         ///
58         void initKeySequences(KeyMap * kb);
59
60         /// return the status bar state string
61         docstring const viewStatusMessage();
62
63         ///
64         void processKeySym(KeySymbolPtr key, key_modifier::state state);
65
66         ///
67         FuncStatus getStatus(FuncRequest const & action) const;
68
69         /// The last key was meta
70         bool wasMetaKey() const;
71
72         /// True if lyxfunc reports an error
73         bool errorStat() const { return errorstat; }
74         /// Buffer to store result messages
75         void setMessage(docstring const & m) const;
76         /// Buffer to store result messages
77         void setErrorMessage(docstring const &) const;
78         /// Buffer to store result messages
79         docstring const getMessage() const { return dispatch_buffer; }
80         /// Handle a accented char key sequence
81         void handleKeyFunc(kb_action action);
82         /// goto a bookmark
83         /// openFile: whether or not open a file if the file is not opened
84         /// switchToBuffer: whether or not switch to buffer if the buffer is
85         ///             not the current buffer
86         void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
87
88 private:
89         ///
90         BufferView * view() const;
91
92         ///
93         frontend::LyXView * lyx_view_;
94
95         /// the last character added to the key sequence, in UCS4 encoded form
96         char_type encoded_last_key;
97
98         ///
99         boost::scoped_ptr<KeySequence> keyseq;
100         ///
101         boost::scoped_ptr<KeySequence> cancel_meta_seq;
102         ///
103         key_modifier::state meta_fake_bit;
104
105         /// Error status, only Dispatch can change this flag
106         mutable bool errorstat;
107
108         /** Buffer to store messages and result data. Is there a
109             good reason to have this one as static in Dispatch? (Ale)
110         */
111         mutable docstring dispatch_buffer;
112
113         /// send a post-dispatch status message
114         void sendDispatchMessage(docstring const & msg,
115                 FuncRequest const & ev);
116
117         // I think the following should be moved to BufferView. (Asger)
118         ///
119         void menuNew(std::string const & argument, bool fromTemplate);
120         ///
121         void open(std::string const &);
122         ///
123         void doImport(std::string const &);
124         ///
125         void closeBuffer();
126         ///
127         void reloadBuffer();
128         ///
129         bool ensureBufferClean(BufferView * bv);
130         ///
131         void updateLayout(TextClass_ptr const & oldlayout, Buffer * buffer);
132 };
133
134 /// Implementation is in LyX.cpp
135 extern LyXFunc & theLyXFunc();
136
137 /// Implementation is in LyX.cpp
138 extern FuncStatus getStatus(FuncRequest const & action);
139
140 /// Implementation is in LyX.cpp
141 extern void dispatch(FuncRequest const & action);
142
143 } // namespace lyx
144
145 #endif