]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
whitespace changes;
[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 "func_status.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(int action, string const & arg = string());
35                          
36         /// The same but uses the name of a lyx command.
37         string const dispatch(string const & cmd);
38
39         ///
40         void miniDispatch(string const & cmd);
41
42         ///
43         void initMiniBuffer();
44                 
45         ///
46         void processKeySym(KeySym k, unsigned int state);
47
48         /// we need one internall which is called from inside LyXAction and
49         /// can contain the string argument.
50         func_status::value_type getStatus(int ac) const;
51         ///
52         func_status::value_type getStatus(int ac, 
53                                           string const & not_to_use_arg) const;
54         
55         /// The last key was meta
56         bool wasMetaKey() const;
57
58         // These can't be global because are part of the
59         // internal state (ale970227)
60         /// Get the current keyseq string
61         string const keyseqStr() const;
62
63         /// Is the key sequence uncomplete?
64         bool keyseqUncomplete() const;
65
66         /// get options for the current keyseq
67         string const keyseqOptions() 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);
73         /// Buffer to store result messages
74         void setErrorMessage(string const &) const; 
75         /// Buffer to store result messages
76         string const getMessage() const { return dispatch_buffer; }
77         /// Handle a accented char keysequenze
78         void handleKeyFunc(kb_action action);
79         /// Should a hint message be displayed?
80         void setHintMessage(bool);
81 private:
82         ///
83         LyXView * owner;
84         ///
85         static int psd_idx;
86         ///
87         kb_sequence keyseq;
88         ///
89         kb_sequence cancel_meta_seq;
90         ///
91         unsigned meta_fake_bit;
92         ///
93         void moveCursorUpdate(bool flag = true, bool selecting = false);
94         ///
95         void setupLocalKeymap();
96         ///
97         kb_action lyx_dead_action;
98         ///
99         kb_action lyx_calling_dead_action;
100         /// Error status, only Dispatch can change this flag
101         mutable bool errorstat;
102
103         /** Buffer to store messages and result data. Is there a
104             good reason to have this one as static in Dispatch? (Ale)
105         */
106         mutable string dispatch_buffer;
107         /// Command name and shortcut information
108         string commandshortcut;
109
110         // I think the following should be moved to BufferView. (Asger)
111
112         ///
113         void menuNew(bool fromTemplate);
114
115         ///
116         void open(string const &);
117
118         ///
119         void doImport(string const &);
120
121         ///
122         void closeBuffer();
123         ///
124         void reloadBuffer();
125         ///
126         //  This return or directly text (default) of getLyXText()
127         ///
128         LyXText * TEXT(bool) const;
129         ///
130         //  This is the same for all lyxfunc objects
131         static bool show_sc;
132 };
133      
134      
135 /*--------------------  inlines  --------------------------*/
136
137 inline
138 bool LyXFunc::wasMetaKey() const 
139
140         return (meta_fake_bit != 0);
141 }
142      
143
144 inline
145 string const LyXFunc::keyseqStr() const
146 {
147         // Why not just remove this function
148         string text;
149         keyseq.print(text, true);
150         return text;
151
152
153
154 inline
155 string const LyXFunc::keyseqOptions() const
156 {
157         // Why not just remove this function
158         string text;
159         keyseq.printOptions(text);
160         return text;
161
162
163
164 inline
165 bool LyXFunc::keyseqUncomplete() const
166
167         return (keyseq.length > 0);
168 }
169
170
171 inline
172 void LyXFunc::setHintMessage(bool hm) 
173
174         show_sc = hm;
175 }
176
177 #endif