]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
fix bug with ever-growing bst files list (from herbert)
[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 <boost/signals/trackable.hpp>
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 boost::signals::trackable {
28 public:
29         ///
30         explicit
31         LyXFunc(LyXView *);
32
33         /// LyX dispatcher, executes lyx actions.
34         void dispatch(kb_action ac, string argument = string(), bool verbose = false);
35
36         /// Dispatch via a string argument
37         void dispatch(string const & s, bool verbose = false);
38  
39         /// Dispatch via a pseudo action, also displaying shortcut/command name
40         void dispatch(int ac, bool verbose = false);
41
42         /// return the status bar state string
43         string const view_status_message();
44
45         ///
46         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
47
48         /// we need one internal which is called from inside LyXAction and
49         /// can contain the string argument.
50         FuncStatus getStatus(int ac) const;
51         ///
52         FuncStatus getStatus(kb_action action,
53                              string const & argument = string()) const;
54
55         /// The last key was meta
56         bool wasMetaKey() const;
57
58         /// True if lyxfunc reports an error
59         bool errorStat() const { return errorstat; }
60         /// Buffer to store result messages
61         void setMessage(string const & m) const;
62         /// Buffer to store result messages
63         void setErrorMessage(string const &) const;
64         /// Buffer to store result messages from getStatus
65         void setStatusMessage(string const &) const;
66         /// Buffer to store result messages
67         string const getMessage() const { return dispatch_buffer; }
68         /// Buffer to store result messages
69         string const getStatusMessage() const { return status_buffer; }
70         /// Handle a accented char key sequence
71         void handleKeyFunc(kb_action action);
72
73 private:
74         ///
75         LyXView * owner;
76         ///
77         static int psd_idx;
78         ///
79         kb_sequence keyseq;
80         ///
81         kb_sequence cancel_meta_seq;
82         ///
83         key_modifier::state meta_fake_bit;
84         ///
85         void moveCursorUpdate(bool flag = true, bool selecting = false);
86         ///
87         void setupLocalKeymap();
88         ///
89         kb_action lyx_dead_action;
90         ///
91         kb_action lyx_calling_dead_action;
92         /// Error status, only Dispatch can change this flag
93         mutable bool errorstat;
94
95         /** Buffer to store messages and result data. Is there a
96             good reason to have this one as static in Dispatch? (Ale)
97         */
98         mutable string dispatch_buffer;
99         /** Buffer to store messages and result data from getStatus
100         */
101         mutable string status_buffer;
102
103         /// send a post-dispatch status message
104         void sendDispatchMessage(string const & msg, kb_action ac, string const & arg, bool verbose);
105
106         // I think the following should be moved to BufferView. (Asger)
107
108         ///
109         void menuNew(string const & argument, bool fromTemplate);
110
111         ///
112         void open(string const &);
113
114         ///
115         void doImport(string const &);
116
117         ///
118         void closeBuffer();
119         ///
120         void reloadBuffer();
121         ///
122         //  This return or directly text (default) of getLyXText()
123         ///
124         LyXText * TEXT(bool) const;
125         ///
126 };
127
128
129 /*--------------------  inlines  --------------------------*/
130
131 inline
132 bool LyXFunc::wasMetaKey() const
133 {
134         return (meta_fake_bit != key_modifier::none);
135 }
136
137
138 #endif