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