]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
Fix natbib bug spotted by JMarc.
[lyx.git] / src / lyxfunc.h
1 // -*- C++ -*-
2 #ifndef LYXFUNC_H
3 #define LYXFUNC_H
4
5 #ifdef __GNUG__
6 #pragma interface
7 #endif
8
9
10 #include "FuncStatus.h"
11 #include "kbsequence.h"
12 #include "commandtags.h"
13 #include "LString.h"
14
15 #include <boost/signals/trackable.hpp>
16
17 class LyXView;
18 class LyXText;
19 class FuncRequest;
20 class BufferView;
21
22
23 /** This class encapsulates all the LyX command operations.
24     This is the class of the LyX's "high level event handler".
25     Every user command is processed here, either invocated from
26     keyboard or from the GUI. All GUI objects, including buttons and
27     menus should use this class and never call kernel functions directly.
28 */
29 class LyXFunc : public boost::signals::trackable {
30 public:
31         ///
32         explicit
33         LyXFunc(LyXView *);
34
35         /// LyX dispatcher, executes lyx actions.
36         void dispatch(FuncRequest const &, bool verbose = false);
37
38         /// Dispatch via a string argument
39         void dispatch(string const & s, bool verbose = false);
40
41         /// Dispatch via a pseudo action, also displaying shortcut/command name
42         void dispatch(int ac, bool verbose = false);
43
44         /// return the status bar state string
45         string const view_status_message();
46
47         ///
48         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
49
50         /// we need one internal which is called from inside LyXAction and
51         /// can contain the string argument.
52         FuncStatus getStatus(int ac) const;
53         ///
54         FuncStatus getStatus(FuncRequest const & action) const;
55
56         /// The last key was meta
57         bool wasMetaKey() const;
58
59         /// True if lyxfunc reports an error
60         bool errorStat() const { return errorstat; }
61         /// Buffer to store result messages
62         void setMessage(string const & m) const;
63         /// Buffer to store result messages
64         void setErrorMessage(string const &) const;
65         /// Buffer to store result messages from getStatus
66         void setStatusMessage(string const &) const;
67         /// Buffer to store result messages
68         string const getMessage() const { return dispatch_buffer; }
69         /// Buffer to store result messages
70         string const getStatusMessage() const { return status_buffer; }
71         /// Handle a accented char key sequence
72         void handleKeyFunc(kb_action action);
73
74 private:
75         ///
76         BufferView * view() const;
77
78         ///
79         LyXView * owner;
80
81         /// the last character added to the key sequence, in ISO encoded form
82         char encoded_last_key;
83
84         ///
85         kb_sequence keyseq;
86         ///
87         kb_sequence cancel_meta_seq;
88         ///
89         key_modifier::state meta_fake_bit;
90         ///
91         void moveCursorUpdate(bool flag = true, bool selecting = false);
92         ///
93         void setupLocalKeymap();
94         /// Error status, only Dispatch can change this flag
95         mutable bool errorstat;
96
97         /** Buffer to store messages and result data. Is there a
98             good reason to have this one as static in Dispatch? (Ale)
99         */
100         mutable string dispatch_buffer;
101         /** Buffer to store messages and result data from getStatus
102         */
103         mutable string status_buffer;
104
105         /// send a post-dispatch status message
106         void sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose);
107
108         // I think the following should be moved to BufferView. (Asger)
109
110         ///
111         void menuNew(string const & argument, bool fromTemplate);
112
113         ///
114         void open(string const &);
115
116         ///
117         void doImport(string const &);
118
119         ///
120         void closeBuffer();
121         ///
122         void reloadBuffer();
123         ///
124         //  This return or directly text (default) of getLyXText()
125         ///
126         LyXText * TEXT(bool) const;
127         ///
128 };
129
130
131 /*--------------------  inlines  --------------------------*/
132
133 inline
134 bool LyXFunc::wasMetaKey() const
135 {
136         return (meta_fake_bit != key_modifier::none);
137 }
138
139
140 #endif