]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
implement DependsOn tag for layout files; more uninteresting cleanup
[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
10 #include "commandtags.h" // for kb_action enum
11 #include "FuncStatus.h"
12 #include "kbsequence.h"
13 #include "LString.h"
14
15 #include "frontends/mouse_state.h"
16 #include "frontends/key_state.h"
17 #include "frontends/LyXKeySym.h"
18
19 #include <boost/signals/trackable.hpp>
20
21 class LyXView;
22 class LyXText;
23
24
25 /** This class encapsulates all the LyX command operations.
26     This is the class of the LyX's "high level event handler".
27     Every user command is processed here, either invocated from
28     keyboard or from the GUI. All GUI objects, including buttons and
29     menus should use this class and never call kernel functions directly.
30 */
31 class LyXFunc : public boost::signals::trackable {
32 public:
33         ///
34         explicit
35         LyXFunc(LyXView *);
36
37         /// LyX dispatcher, executes lyx actions.
38         void dispatch(kb_action ac, string argument = string(), bool verbose = false);
39
40         /// Dispatch via a string argument
41         void dispatch(string const & s, bool verbose = false);
42  
43         /// Dispatch via a pseudo action, also displaying shortcut/command name
44         void dispatch(int ac, bool verbose = false);
45
46         /// return the status bar state string
47         string const view_status_message();
48
49         ///
50         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
51
52         /// we need one internal which is called from inside LyXAction and
53         /// can contain the string argument.
54         FuncStatus getStatus(int ac) const;
55         ///
56         FuncStatus getStatus(kb_action action,
57                              string const & argument = string()) const;
58
59         /// The last key was meta
60         bool wasMetaKey() const;
61
62         /// True if lyxfunc reports an error
63         bool errorStat() const { return errorstat; }
64         /// Buffer to store result messages
65         void setMessage(string const & m) const;
66         /// Buffer to store result messages
67         void setErrorMessage(string const &) const;
68         /// Buffer to store result messages from getStatus
69         void setStatusMessage(string const &) const;
70         /// Buffer to store result messages
71         string const getMessage() const { return dispatch_buffer; }
72         /// Buffer to store result messages
73         string const getStatusMessage() const { return status_buffer; }
74         /// Handle a accented char key sequence
75         void handleKeyFunc(kb_action action);
76
77 private:
78         ///
79         LyXView * owner;
80         ///
81         static int psd_idx;
82         ///
83         kb_sequence keyseq;
84         ///
85         kb_sequence cancel_meta_seq;
86         ///
87         key_modifier::state meta_fake_bit;
88         ///
89         void moveCursorUpdate(bool flag = true, bool selecting = false);
90         ///
91         void setupLocalKeymap();
92         ///
93         kb_action lyx_dead_action;
94         ///
95         kb_action lyx_calling_dead_action;
96         /// Error status, only Dispatch can change this flag
97         mutable bool errorstat;
98
99         /** Buffer to store messages and result data. Is there a
100             good reason to have this one as static in Dispatch? (Ale)
101         */
102         mutable string dispatch_buffer;
103         /** Buffer to store messages and result data from getStatus
104         */
105         mutable string status_buffer;
106
107         /// send a post-dispatch status message
108         void sendDispatchMessage(string const & msg, kb_action ac, string const & arg, bool verbose);
109
110         // I think the following should be moved to BufferView. (Asger)
111
112         ///
113         void menuNew(string const & argument, 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 };
131
132
133 /*--------------------  inlines  --------------------------*/
134
135 inline
136 bool LyXFunc::wasMetaKey() const
137 {
138         return (meta_fake_bit != key_modifier::none);
139 }
140
141
142 #endif