]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
improved comments in removeAutoInsets()
[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 const LyXFunc::verboseDispatch(kb_action action,
39                                             string const & argument,
40                                             bool show_sc);
41         
42         /// Same as above, using a pseudoaction as argument
43         void const LyXFunc::verboseDispatch(int ac, bool show_sc);
44
45         /// Same as above, when the command is provided as a string
46         void const LyXFunc::verboseDispatch(string const & s, bool show_sc);
47
48         /// 
49         void LyXFunc::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);
71         /// Buffer to store result messages
72         void setErrorMessage(string const &) const; 
73         /// Buffer to store result messages
74         string const getMessage() const { return dispatch_buffer; }
75         /// Handle a accented char keysequenze
76         void handleKeyFunc(kb_action action);
77
78 private:
79         ///
80         LyXView * owner;
81         ///
82         static int psd_idx;
83         ///
84         kb_sequence keyseq;
85         ///
86         kb_sequence cancel_meta_seq;
87         ///
88         unsigned meta_fake_bit;
89         ///
90         void moveCursorUpdate(bool flag = true, bool selecting = false);
91         ///
92         void setupLocalKeymap();
93         ///
94         kb_action lyx_dead_action;
95         ///
96         kb_action lyx_calling_dead_action;
97         /// Error status, only Dispatch can change this flag
98         mutable bool errorstat;
99
100         /** Buffer to store messages and result data. Is there a
101             good reason to have this one as static in Dispatch? (Ale)
102         */
103         mutable string dispatch_buffer;
104         /// Command name and shortcut information
105         string commandshortcut;
106
107         // I think the following should be moved to BufferView. (Asger)
108
109         ///
110         void menuNew(bool fromTemplate);
111
112         ///
113         void open(string const &);
114
115         ///
116         void doImport(string const &);
117
118         ///
119         void closeBuffer();
120         ///
121         void reloadBuffer();
122         ///
123         //  This return or directly text (default) of getLyXText()
124         ///
125         LyXText * TEXT(bool) const;
126         ///
127 };
128      
129      
130 /*--------------------  inlines  --------------------------*/
131
132 inline
133 bool LyXFunc::wasMetaKey() const 
134
135         return (meta_fake_bit != 0);
136 }
137      
138
139 #endif