]> git.lyx.org Git - lyx.git/blob - src/LyXFunc.h
Make the fake sequence for braces highly unlikely (addressing #6478).
[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 "FuncCode.h"
19 #include "KeySequence.h"
20
21 #include "support/docstring.h"
22
23 namespace lyx {
24
25 class Buffer;
26 class BufferView;
27 class DispatchResult;
28 class DocumentClass;
29 class FuncRequest;
30 class FuncStatus;
31 class KeySymbol;
32 class Text;
33
34 namespace support {
35 class FileName;
36 }
37
38 /** This class encapsulates all the LyX command operations.
39     This is the class of the LyX's "high level event handler".
40     Every user command is processed here, either invocated from
41     keyboard or from the GUI. All GUI objects, including buttons and
42     menus should use this class and never call kernel functions directly.
43 */
44 class LyXFunc
45 {
46 public:
47         ///
48         explicit LyXFunc();
49
50         /// LyX dispatcher: executes lyx actions and returns result.
51         void dispatch(FuncRequest const &, DispatchResult &);
52
53         /// LyX dispatcher: executes lyx actions and does necessary
54         /// screen updates depending on results.
55         void dispatch(FuncRequest const &);
56
57         ///
58         FuncStatus getStatus(FuncRequest const & action) const;
59
60         /// True if lyxfunc reports an error
61         bool errorStat() const { return errorstat; }
62         /// Buffer to store result messages
63         void setMessage(docstring const & m) const;
64         /// Buffer to store result messages
65         void setErrorMessage(docstring const &) const;
66         /// Buffer to store result messages
67         docstring const getMessage() const { return dispatch_buffer; }
68         /// goto a bookmark
69         /// openFile: whether or not open a file if the file is not opened
70         /// switchToBuffer: whether or not switch to buffer if the buffer is
71         ///             not the current buffer
72         void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
73
74         /// cursor x position before dispatch started
75         int cursorBeforeDispatchX() const { return cursorPosBeforeDispatchX_; }
76         /// cursor y position before dispatch started
77         int cursorBeforeDispatchY() const { return cursorPosBeforeDispatchY_; }
78
79 private:
80         /// cursor position before dispatch started
81         int cursorPosBeforeDispatchX_;
82         int cursorPosBeforeDispatchY_;
83
84         /// Error status, only Dispatch can change this flag
85         mutable bool errorstat;
86
87         /** Buffer to store messages and result data. Is there a
88             good reason to have this one as static in Dispatch? (Ale)
89         */
90         mutable docstring dispatch_buffer;
91 };
92
93 /// Implementation is in LyX.cpp
94 extern LyXFunc & theLyXFunc();
95
96 /// Implementation is in LyX.cpp
97 extern FuncStatus getStatus(FuncRequest const & action);
98
99 /// Implementation is in LyX.cpp
100 extern void dispatch(FuncRequest const & action);
101
102 /// Implementation is in LyX.cpp
103 extern void dispatch(FuncRequest const & action, DispatchResult & dr);
104
105 } // namespace lyx
106
107 #endif