]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
move workarea to xforms/ for a better diff.
[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 #include <X11/Xlib.h>
10 #include <sigc++/signal_system.h>
11
12 #include "frontends/mouse_state.h"
13 #include "frontends/key_state.h"
14 #include "commandtags.h" // for kb_action enum
15 #include "FuncStatus.h"
16 #include "kbsequence.h"
17 #include "LString.h"
18
19 class LyXView;
20 class LyXText;
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 SigC::Object {
30 public:
31         ///
32         explicit
33         LyXFunc(LyXView *);
34
35         /// LyX dispatcher, executes lyx actions.
36         string const dispatch(kb_action ac, string argument = string());
37
38         /// The same as dispatch, but also shows shortcuts and command
39         /// name in minibuffer if show_sc is true (more to come?)
40         void verboseDispatch(kb_action action,
41                              string const & argument,
42                              bool show_sc);
43
44         /// Same as above, using a pseudoaction as argument
45         void verboseDispatch(int ac, bool show_sc);
46
47         /// Same as above, when the command is provided as a string
48         void verboseDispatch(string const & s, bool show_sc);
49
50         ///
51         void miniDispatch(string const & s);
52
53         ///
54         void initMiniBuffer();
55
56         ///
57         void processKeySym(KeySym key, key_modifier::state state);
58
59         /// we need one internal which is called from inside LyXAction and
60         /// can contain the string argument.
61         FuncStatus getStatus(int ac) const;
62         ///
63         FuncStatus getStatus(kb_action action,
64                              string const & argument = string()) const;
65
66         /// The last key was meta
67         bool wasMetaKey() const;
68
69         /// True if lyxfunc reports an error
70         bool errorStat() const { return errorstat; }
71         /// Buffer to store result messages
72         void setMessage(string const & m) const;
73         /// Buffer to store result messages
74         void setErrorMessage(string const &) const;
75         /// Buffer to store result messages from getStatus
76         void setStatusMessage(string const &) const;
77         /// Buffer to store result messages
78         string const getMessage() const { return dispatch_buffer; }
79         /// Buffer to store result messages
80         string const getStatusMessage() const { return status_buffer; }
81         /// Handle a accented char keysequenze
82         void handleKeyFunc(kb_action action);
83
84 private:
85         ///
86         LyXView * owner;
87         ///
88         static int psd_idx;
89         ///
90         kb_sequence keyseq;
91         ///
92         kb_sequence cancel_meta_seq;
93         ///
94         key_modifier::state meta_fake_bit;
95         ///
96         void moveCursorUpdate(bool flag = true, bool selecting = false);
97         ///
98         void setupLocalKeymap();
99         ///
100         kb_action lyx_dead_action;
101         ///
102         kb_action lyx_calling_dead_action;
103         /// Error status, only Dispatch can change this flag
104         mutable bool errorstat;
105
106         /** Buffer to store messages and result data. Is there a
107             good reason to have this one as static in Dispatch? (Ale)
108         */
109         mutable string dispatch_buffer;
110         /** Buffer to store messages and result data from getStatus
111         */
112         mutable string status_buffer;
113         /// Command name and shortcut information
114         string commandshortcut;
115
116         // I think the following should be moved to BufferView. (Asger)
117
118         ///
119         void menuNew(bool fromTemplate);
120
121         ///
122         void open(string const &);
123
124         ///
125         void doImport(string const &);
126
127         ///
128         void closeBuffer();
129         ///
130         void reloadBuffer();
131         ///
132         //  This return or directly text (default) of getLyXText()
133         ///
134         LyXText * TEXT(bool) const;
135         ///
136 };
137
138
139 /*--------------------  inlines  --------------------------*/
140
141 inline
142 bool LyXFunc::wasMetaKey() const
143 {
144         return (meta_fake_bit != key_modifier::none);
145 }
146
147
148 #endif