]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
fix "make dist" target
[lyx.git] / src / lyxfunc.h
1 // -*- C++ -*-
2 #ifndef LYXFUNC_H
3 #define LYXFUNC_H
4
5 #include <sigc++/signal_system.h>
6
7 #ifdef __GNUG__
8 #pragma interface
9 #endif
10
11 #include FORMS_H_LOCATION
12 #include "commandtags.h"
13 #include "kbsequence.h"
14 #include "insets/lyxinset.h"
15 #include "LString.h"
16
17 class LyXView;
18
19
20 /** This class encapsulates all the LyX command operations. 
21     This is the class of the LyX's "high level event handler".
22     Every user command is processed here, either invocated from
23     keyboard or from the GUI. All GUI objects, including buttons and
24     menus should use this class and never call kernel functions directly.
25 */
26 class LyXFunc : public SigC::Object {
27 public:
28         /// The status of a function.
29         enum func_status {
30                 /// No problem
31                 OK = 0,
32                 ///
33                 Unknown = 1,
34                 /// Command cannot be executed
35                 Disabled = 2,
36                 ///
37                 ToggleOn = 4,
38                 ///
39                 ToggleOff = 8
40         };
41         ///
42         explicit
43         LyXFunc(LyXView *);
44     
45         /// LyX dispatcher, executes lyx actions.
46         string const Dispatch(int action, string const & arg = string());
47                          
48         /// The same but uses the name of a lyx command.
49         string const Dispatch(string const & cmd);
50
51         ///
52         void miniDispatch(string const & cmd);
53
54         ///
55         void initMiniBuffer();
56                 
57         ///
58         void processKeySym(KeySym k, unsigned int state);
59
60         /// we need one internall which is called from inside LyXAction and
61         /// can contain the string argument.
62         func_status getStatus(int ac) const;
63         ///
64         func_status getStatus(int ac, string const & not_to_use_arg) const;
65         
66         /// The last key was meta
67         bool wasMetaKey() const;
68
69         // These can't be global because are part of the
70         // internal state (ale970227)
71         /// Get the current keyseq string
72         string const keyseqStr() const;
73
74         /// Is the key sequence uncomplete?
75         bool keyseqUncomplete() const;
76
77         /// get options for the current keyseq
78         string const keyseqOptions() const;
79
80         /// True if lyxfunc reports an error
81         bool errorStat() const { return errorstat; }
82         /// Buffer to store result messages
83         void setMessage(string const & m);
84         /// Buffer to store result messages
85         void setErrorMessage(string const &) const; 
86         /// Buffer to store result messages
87         string const getMessage() const { return dispatch_buffer; }
88         /// Handle a accented char keysequenze
89         void handleKeyFunc(kb_action action);
90         /// Should a hint message be displayed?
91         void setHintMessage(bool);
92 private:
93         ///
94         LyXView * owner;
95         ///
96         static int psd_idx;
97         ///
98         kb_sequence keyseq;
99         ///
100         kb_sequence cancel_meta_seq;
101         ///
102         unsigned meta_fake_bit;
103         ///
104         void moveCursorUpdate(bool flag = true, bool selecting = false);
105         ///
106         void setupLocalKeymap();
107         ///
108         kb_action lyx_dead_action;
109         ///
110         kb_action lyx_calling_dead_action;
111         /// Error status, only Dispatch can change this flag
112         mutable bool errorstat;
113
114         /** Buffer to store messages and result data. Is there a
115             good reason to have this one as static in Dispatch? (Ale)
116         */
117         mutable string dispatch_buffer;
118         /// Command name and shortcut information
119         string commandshortcut;
120
121         // I think the following should be moved to BufferView. (Asger)
122
123         ///
124         void MenuNew(bool fromTemplate);
125
126         ///
127         void Open(string const &);
128
129         ///
130         void doImport(string const &);
131
132         ///
133         void CloseBuffer();
134         ///
135         void reloadBuffer();
136         ///
137         //  This return or directly text (default) of getLyXText()
138         ///
139         LyXText * TEXT(bool) const;
140         ///
141         //  This is the same for all lyxfunc objects
142         static bool show_sc;
143 };
144      
145      
146 /*--------------------  inlines  --------------------------*/
147
148 inline
149 bool LyXFunc::wasMetaKey() const 
150
151         return (meta_fake_bit != 0);
152 }
153      
154
155 inline
156 string const LyXFunc::keyseqStr() const
157 {
158         // Why not just remove this function
159         string text;
160         keyseq.print(text, true);
161         return text;
162
163
164
165 inline
166 string const LyXFunc::keyseqOptions() const
167 {
168         // Why not just remove this function
169         string text;
170         keyseq.printOptions(text);
171         return text;
172
173
174
175 inline
176 bool LyXFunc::keyseqUncomplete() const
177
178         return (keyseq.length > 0);
179 }
180
181
182 inline
183 void LyXFunc::setHintMessage(bool hm) 
184
185         show_sc = hm;
186 }
187
188 ///
189 inline
190 void operator|=(LyXFunc::func_status & fs, LyXFunc::func_status f)
191 {
192         fs = static_cast<LyXFunc::func_status>(fs | f);
193 }
194
195 #endif