]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
f3ce55520f0e1bbfc1a23f0580859ef77049fac0
[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 #include "support/std_string.h"
21
22 #include <boost/shared_ptr.hpp>
23 #include <boost/signals/trackable.hpp>
24
25 class FuncStatus;
26 class LyXKeySym;
27 class LyXView;
28 class LyXText;
29 class FuncRequest;
30 class BufferView;
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         /// Dispatch via a string argument
49         void dispatch(string const & s, bool verbose = false);
50
51         /// Dispatch via a pseudo action, also displaying shortcut/command name
52         void dispatch(int ac, bool verbose = false);
53
54         /// return the status bar state string
55         string const view_status_message();
56
57         ///
58         typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
59         ///
60         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
61
62         /// we need one internal which is called from inside LyXAction and
63         /// can contain the string argument.
64         FuncStatus getStatus(int ac) const;
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(string const & m) const;
75         /// Buffer to store result messages
76         void setErrorMessage(string const &) const;
77         /// Buffer to store result messages from getStatus
78         void setStatusMessage(string const &) const;
79         /// Buffer to store result messages
80         string const getMessage() const { return dispatch_buffer; }
81         /// Buffer to store result messages
82         string const getStatusMessage() const { return status_buffer; }
83         /// Handle a accented char key sequence
84         void handleKeyFunc(kb_action action);
85
86 private:
87         ///
88         BufferView * view() const;
89
90         ///
91         LyXView * owner;
92
93         /// the last character added to the key sequence, in ISO encoded form
94         char encoded_last_key;
95
96         ///
97         kb_sequence keyseq;
98         ///
99         kb_sequence cancel_meta_seq;
100         ///
101         key_modifier::state meta_fake_bit;
102         ///
103         void moveCursorUpdate();
104         ///
105         void setupLocalKeymap();
106         /// Error status, only Dispatch can change this flag
107         mutable bool errorstat;
108
109         /** Buffer to store messages and result data. Is there a
110             good reason to have this one as static in Dispatch? (Ale)
111         */
112         mutable string dispatch_buffer;
113         /** Buffer to store messages and result data from getStatus
114         */
115         mutable string status_buffer;
116
117         /// send a post-dispatch status message
118         void sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose);
119
120         // I think the following should be moved to BufferView. (Asger)
121
122         ///
123         void menuNew(string const & argument, bool fromTemplate);
124
125         ///
126         void open(string const &);
127
128         ///
129         void doImport(string const &);
130
131         ///
132         void closeBuffer();
133 };
134
135 #endif