* qt_helpers.cpp:
[lyx.git] / src / LyXFunc.h
bloba8d76b182dcd0ecce2a2b13e38f1b4ed54d28a01
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.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author John Levon
10 * \author André Pönitz
12 * Full author contact details are available in file CREDITS.
15 #ifndef LYXFUNC_H
16 #define LYXFUNC_H
18 #include "FuncCode.h"
19 #include "KeySequence.h"
21 #include "support/docstring.h"
23 namespace lyx {
25 class Buffer;
26 class BufferView;
27 class DocumentClass;
28 class FuncRequest;
29 class FuncStatus;
30 class KeySymbol;
31 class Text;
33 namespace support {
34 class FileName;
37 namespace frontend {
38 class LyXView;
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.
47 class LyXFunc
49 public:
50 ///
51 explicit LyXFunc();
53 /// LyX dispatcher, executes lyx actions.
54 void dispatch(FuncRequest const &);
56 ///
57 void setLyXView(frontend::LyXView * lv);
59 ///
60 void initKeySequences(KeyMap * kb);
62 /// return the status bar state string
63 docstring viewStatusMessage();
65 ///
66 void processKeySym(KeySymbol const & key, KeyModifier state);
68 ///
69 FuncStatus getStatus(FuncRequest const & action) const;
71 /// The last key was meta
72 bool wasMetaKey() const;
74 /// True if lyxfunc reports an error
75 bool errorStat() const { return errorstat; }
76 /// Buffer to store result messages
77 void setMessage(docstring const & m) const;
78 /// Buffer to store result messages
79 void setErrorMessage(docstring const &) const;
80 /// Buffer to store result messages
81 docstring const getMessage() const { return dispatch_buffer; }
82 /// Handle a accented char key sequence
83 void handleKeyFunc(FuncCode action);
84 /// goto a bookmark
85 /// openFile: whether or not open a file if the file is not opened
86 /// switchToBuffer: whether or not switch to buffer if the buffer is
87 /// not the current buffer
88 void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
90 /// cursor x position before dispatch started
91 int cursorBeforeDispatchX() const { return cursorPosBeforeDispatchX_; }
92 /// cursor y position before dispatch started
93 int cursorBeforeDispatchY() const { return cursorPosBeforeDispatchY_; }
95 private:
96 ///
97 BufferView * view() const;
99 ///
100 frontend::LyXView * lyx_view_;
102 /// the last character added to the key sequence, in UCS4 encoded form
103 char_type encoded_last_key;
106 KeySequence keyseq;
108 KeySequence cancel_meta_seq;
110 KeyModifier meta_fake_bit;
112 /// cursor position before dispatch started
113 int cursorPosBeforeDispatchX_;
114 int cursorPosBeforeDispatchY_;
116 /// Error status, only Dispatch can change this flag
117 mutable bool errorstat;
119 /** Buffer to store messages and result data. Is there a
120 good reason to have this one as static in Dispatch? (Ale)
122 mutable docstring dispatch_buffer;
124 /// send a post-dispatch status message
125 void sendDispatchMessage(docstring const & msg,
126 FuncRequest const & ev);
129 void reloadBuffer();
130 /// make sure the document is saved
131 bool ensureBufferClean(BufferView * bv);
133 void updateLayout(DocumentClass const * const oldlayout, Buffer * buffer);
136 /// Implementation is in LyX.cpp
137 extern LyXFunc & theLyXFunc();
139 /// Implementation is in LyX.cpp
140 extern FuncStatus getStatus(FuncRequest const & action);
142 /// Implementation is in LyX.cpp
143 extern void dispatch(FuncRequest const & action);
145 } // namespace lyx
147 #endif