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