]> git.lyx.org Git - lyx.git/blob - src/LyXFunc.h
Introduce Application::currentWindow() and get rid of lyx_view_ member in LyXFunc.
[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 DocumentClass;
28 class FuncRequest;
29 class FuncStatus;
30 class KeySymbol;
31 class Text;
32
33 namespace support {
34 class FileName;
35 }
36
37 namespace frontend {
38 class LyXView;
39 }
40
41 /** This class encapsulates all the LyX command operations.
42     This is the class of the LyX's "high level event handler".
43     Every user command is processed here, either invocated from
44     keyboard or from the GUI. All GUI objects, including buttons and
45     menus should use this class and never call kernel functions directly.
46 */
47 class LyXFunc
48 {
49 public:
50         ///
51         explicit LyXFunc();
52
53         /// LyX dispatcher, executes lyx actions.
54         void dispatch(FuncRequest const &);
55
56         ///
57         void initKeySequences(KeyMap * kb);
58
59         /// return the status bar state string
60         docstring viewStatusMessage();
61
62         ///
63         void processKeySym(KeySymbol const & key, KeyModifier state);
64
65         ///
66         FuncStatus getStatus(FuncRequest const & action) const;
67
68         /// The last key was meta
69         bool wasMetaKey() const;
70
71         /// True if lyxfunc reports an error
72         bool errorStat() const { return errorstat; }
73         /// Buffer to store result messages
74         void setMessage(docstring const & m) const;
75         /// Buffer to store result messages
76         void setErrorMessage(docstring const &) const;
77         /// Buffer to store result messages
78         docstring const getMessage() const { return dispatch_buffer; }
79         /// Handle a accented char key sequence
80         void handleKeyFunc(FuncCode action);
81         /// goto a bookmark
82         /// openFile: whether or not open a file if the file is not opened
83         /// switchToBuffer: whether or not switch to buffer if the buffer is
84         ///             not the current buffer
85         void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
86
87         /// cursor x position before dispatch started
88         int cursorBeforeDispatchX() const { return cursorPosBeforeDispatchX_; }
89         /// cursor y position before dispatch started
90         int cursorBeforeDispatchY() const { return cursorPosBeforeDispatchY_; }
91
92 private:
93         /// the last character added to the key sequence, in UCS4 encoded form
94         char_type encoded_last_key;
95
96         ///
97         KeySequence keyseq;
98         ///
99         KeySequence cancel_meta_seq;
100         ///
101         KeyModifier meta_fake_bit;
102
103         /// cursor position before dispatch started
104         int cursorPosBeforeDispatchX_;
105         int cursorPosBeforeDispatchY_;
106
107         /// Error status, only Dispatch can change this flag
108         mutable bool errorstat;
109
110         /** Buffer to store messages and result data. Is there a
111             good reason to have this one as static in Dispatch? (Ale)
112         */
113         mutable docstring dispatch_buffer;
114
115         /// send a post-dispatch status message
116         void sendDispatchMessage(docstring const & msg,
117                 FuncRequest const & ev);
118 };
119
120 /// Implementation is in LyX.cpp
121 extern LyXFunc & theLyXFunc();
122
123 /// Implementation is in LyX.cpp
124 extern FuncStatus getStatus(FuncRequest const & action);
125
126 /// Implementation is in LyX.cpp
127 extern void dispatch(FuncRequest const & action);
128
129 } // namespace lyx
130
131 #endif