]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
redraw fix 1.
[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 #include "frontends/LyXKeySym.h"
18
19 #include <boost/signals/trackable.hpp>
20
21 class LyXView;
22 class LyXText;
23
24
25 /** This class encapsulates all the LyX command operations.
26     This is the class of the LyX's "high level event handler".
27     Every user command is processed here, either invocated from
28     keyboard or from the GUI. All GUI objects, including buttons and
29     menus should use this class and never call kernel functions directly.
30 */
31 class LyXFunc : public boost::signals::trackable {
32 public:
33         ///
34         explicit
35         LyXFunc(LyXView *);
36
37         /// LyX dispatcher, executes lyx actions.
38         string const dispatch(kb_action ac, string argument = string());
39
40         /// The same as dispatch, but also shows shortcuts and command
41         /// name in minibuffer if show_sc is true (more to come?)
42         void verboseDispatch(kb_action action,
43                              string const & argument,
44                              bool show_sc);
45
46         /// Same as above, using a pseudoaction as argument
47         void verboseDispatch(int ac, bool show_sc);
48
49         /// Same as above, when the command is provided as a string
50         void verboseDispatch(string const & s, bool show_sc);
51
52         ///
53         void miniDispatch(string const & s);
54
55         ///
56         void initMiniBuffer();
57
58         ///
59         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
60
61         /// we need one internal which is called from inside LyXAction and
62         /// can contain the string argument.
63         FuncStatus getStatus(int ac) const;
64         ///
65         FuncStatus getStatus(kb_action action,
66                              string const & argument = string()) 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         LyXView * owner;
89         ///
90         static int psd_idx;
91         ///
92         kb_sequence keyseq;
93         ///
94         kb_sequence cancel_meta_seq;
95         ///
96         key_modifier::state meta_fake_bit;
97         ///
98         void moveCursorUpdate(bool flag = true, bool selecting = false);
99         ///
100         void setupLocalKeymap();
101         ///
102         kb_action lyx_dead_action;
103         ///
104         kb_action lyx_calling_dead_action;
105         /// Error status, only Dispatch can change this flag
106         mutable bool errorstat;
107
108         /** Buffer to store messages and result data. Is there a
109             good reason to have this one as static in Dispatch? (Ale)
110         */
111         mutable string dispatch_buffer;
112         /** Buffer to store messages and result data from getStatus
113         */
114         mutable string status_buffer;
115         /// Command name and shortcut information
116         string commandshortcut;
117
118         // I think the following should be moved to BufferView. (Asger)
119
120         ///
121         void menuNew(bool fromTemplate);
122
123         ///
124         void open(string const &);
125
126         ///
127         void doImport(string const &);
128
129         ///
130         void closeBuffer();
131         ///
132         void reloadBuffer();
133         ///
134         //  This return or directly text (default) of getLyXText()
135         ///
136         LyXText * TEXT(bool) const;
137         ///
138 };
139
140
141 /*--------------------  inlines  --------------------------*/
142
143 inline
144 bool LyXFunc::wasMetaKey() const
145 {
146         return (meta_fake_bit != key_modifier::none);
147 }
148
149
150 #endif