]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
Switch from SigC signals to boost::signals
[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 "commandtags.h" // for kb_action enum
11 #include "FuncStatus.h"
12 #include "kbsequence.h"
13 #include "LString.h"
14
15 #include "frontends/mouse_state.h"
16 #include "frontends/key_state.h"
17
18 #include <boost/signals/trackable.hpp>
19
20 #include <X11/Xlib.h>
21
22 class LyXView;
23 class LyXText;
24
25
26 /** This class encapsulates all the LyX command operations.
27     This is the class of the LyX's "high level event handler".
28     Every user command is processed here, either invocated from
29     keyboard or from the GUI. All GUI objects, including buttons and
30     menus should use this class and never call kernel functions directly.
31 */
32 class LyXFunc : public boost::signals::trackable {
33 public:
34         ///
35         explicit
36         LyXFunc(LyXView *);
37
38         /// LyX dispatcher, executes lyx actions.
39         string const dispatch(kb_action ac, string argument = string());
40
41         /// The same as dispatch, but also shows shortcuts and command
42         /// name in minibuffer if show_sc is true (more to come?)
43         void verboseDispatch(kb_action action,
44                              string const & argument,
45                              bool show_sc);
46
47         /// Same as above, using a pseudoaction as argument
48         void verboseDispatch(int ac, bool show_sc);
49
50         /// Same as above, when the command is provided as a string
51         void verboseDispatch(string const & s, bool show_sc);
52
53         ///
54         void miniDispatch(string const & s);
55
56         ///
57         void initMiniBuffer();
58
59         ///
60         void processKeySym(KeySym 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(kb_action action,
67                              string const & argument = string()) 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 keysequenze
85         void handleKeyFunc(kb_action action);
86
87 private:
88         ///
89         LyXView * owner;
90         ///
91         static int psd_idx;
92         ///
93         kb_sequence keyseq;
94         ///
95         kb_sequence cancel_meta_seq;
96         ///
97         key_modifier::state meta_fake_bit;
98         ///
99         void moveCursorUpdate(bool flag = true, bool selecting = false);
100         ///
101         void setupLocalKeymap();
102         ///
103         kb_action lyx_dead_action;
104         ///
105         kb_action lyx_calling_dead_action;
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         /// Command name and shortcut information
117         string commandshortcut;
118
119         // I think the following should be moved to BufferView. (Asger)
120
121         ///
122         void menuNew(bool fromTemplate);
123
124         ///
125         void open(string const &);
126
127         ///
128         void doImport(string const &);
129
130         ///
131         void closeBuffer();
132         ///
133         void reloadBuffer();
134         ///
135         //  This return or directly text (default) of getLyXText()
136         ///
137         LyXText * TEXT(bool) const;
138         ///
139 };
140
141
142 /*--------------------  inlines  --------------------------*/
143
144 inline
145 bool LyXFunc::wasMetaKey() const
146 {
147         return (meta_fake_bit != key_modifier::none);
148 }
149
150
151 #endif