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