]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
Small clean-up.
[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         /// Dispatch via a pseudo action, also displaying shortcut/command name
53         void dispatch(int ac, bool verbose = false);
54
55         /// return the status bar state string
56         string const view_status_message();
57
58         ///
59         typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
60         ///
61         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
62
63         /// we need one internal which is called from inside LyXAction and
64         /// can contain the string argument.
65         FuncStatus getStatus(int ac) const;
66         ///
67         FuncStatus getStatus(FuncRequest const & action) const;
68
69         /// The last key was meta
70         bool wasMetaKey() const;
71
72         /// True if lyxfunc reports an error
73         bool errorStat() const { return errorstat; }
74         /// Buffer to store result messages
75         void setMessage(string const & m) const;
76         /// Buffer to store result messages
77         void setErrorMessage(string const &) const;
78         /// Buffer to store result messages from getStatus
79         void setStatusMessage(string const &) const;
80         /// Buffer to store result messages
81         string const getMessage() const { return dispatch_buffer; }
82         /// Buffer to store result messages
83         string const getStatusMessage() const { return status_buffer; }
84         /// Handle a accented char key sequence
85         void handleKeyFunc(kb_action action);
86
87 private:
88         ///
89         BufferView * view() const;
90
91         ///
92         LyXView * owner;
93
94         /// the last character added to the key sequence, in ISO encoded form
95         char encoded_last_key;
96
97         ///
98         kb_sequence keyseq;
99         ///
100         kb_sequence cancel_meta_seq;
101         ///
102         key_modifier::state meta_fake_bit;
103         ///
104         void moveCursorUpdate();
105         ///
106         void setupLocalKeymap();
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 string dispatch_buffer;
114         /** Buffer to store messages and result data from getStatus
115         */
116         mutable string status_buffer;
117
118         /// send a post-dispatch status message
119         void sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose);
120
121         // I think the following should be moved to BufferView. (Asger)
122
123         ///
124         void menuNew(string const & argument, bool fromTemplate);
125
126         ///
127         void open(string const &);
128
129         ///
130         void doImport(string const &);
131
132         ///
133         void closeBuffer();
134 };
135
136 #endif