]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
Get rid of LyXFunc::dispatch that takes a string.
[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 <boost/shared_ptr.hpp>
22 #include <boost/signals/trackable.hpp>
23
24
25 class BufferView;
26 class FuncRequest;
27 class FuncStatus;
28 class LyXKeySym;
29 class LyXText;
30 class LyXView;
31
32
33 /** This class encapsulates all the LyX command operations.
34     This is the class of the LyX's "high level event handler".
35     Every user command is processed here, either invocated from
36     keyboard or from the GUI. All GUI objects, including buttons and
37     menus should use this class and never call kernel functions directly.
38 */
39 class LyXFunc : public boost::signals::trackable {
40 public:
41         ///
42         explicit
43         LyXFunc(LyXView *);
44
45         /// LyX dispatcher, executes lyx actions.
46         void dispatch(FuncRequest const &, bool verbose = false);
47
48         /// return the status bar state string
49         std::string const view_status_message();
50
51         ///
52         typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
53         ///
54         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
55
56         ///
57         FuncStatus getStatus(FuncRequest const & action) const;
58
59         /// The last key was meta
60         bool wasMetaKey() const;
61
62         /// True if lyxfunc reports an error
63         bool errorStat() const { return errorstat; }
64         /// Buffer to store result messages
65         void setMessage(std::string const & m) const;
66         /// Buffer to store result messages
67         void setErrorMessage(std::string const &) const;
68         /// Buffer to store result messages from getStatus
69         void setStatusMessage(std::string const &) const;
70         /// Buffer to store result messages
71         std::string const getMessage() const { return dispatch_buffer; }
72         /// Buffer to store result messages
73         std::string const getStatusMessage() const { return status_buffer; }
74         /// Handle a accented char key sequence
75         void handleKeyFunc(kb_action action);
76
77 private:
78         ///
79         BufferView * view() const;
80
81         ///
82         LyXView * owner;
83
84         /// the last character added to the key sequence, in ISO encoded form
85         char encoded_last_key;
86
87         ///
88         kb_sequence keyseq;
89         ///
90         kb_sequence cancel_meta_seq;
91         ///
92         key_modifier::state meta_fake_bit;
93         ///
94         void moveCursorUpdate();
95         ///
96         void setupLocalKeymap();
97         /// Error status, only Dispatch can change this flag
98         mutable bool errorstat;
99
100         /** Buffer to store messages and result data. Is there a
101             good reason to have this one as static in Dispatch? (Ale)
102         */
103         mutable std::string dispatch_buffer;
104         /** Buffer to store messages and result data from getStatus
105         */
106         mutable std::string status_buffer;
107
108         /// send a post-dispatch status message
109         void sendDispatchMessage(std::string const & msg, FuncRequest const & ev, bool verbose);
110
111         // I think the following should be moved to BufferView. (Asger)
112
113         ///
114         void menuNew(std::string const & argument, bool fromTemplate);
115
116         ///
117         void open(std::string const &);
118
119         ///
120         void doImport(std::string const &);
121
122         ///
123         void closeBuffer();
124 };
125
126 #endif