]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
John's Layout Tabular UI improvements and Martins fixes to clearing the
[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         /// True if lyxfunc reports an error
59         bool errorStat() const { return errorstat; }
60         /// Buffer to store result messages
61         void setMessage(string const & m);
62         /// Buffer to store result messages
63         void setErrorMessage(string const &) const; 
64         /// Buffer to store result messages
65         string const getMessage() const { return dispatch_buffer; }
66         /// Handle a accented char keysequenze
67         void handleKeyFunc(kb_action action);
68         /// Should a hint message be displayed?
69         void setHintMessage(bool);
70 private:
71         ///
72         LyXView * owner;
73         ///
74         static int psd_idx;
75         ///
76         kb_sequence keyseq;
77         ///
78         kb_sequence cancel_meta_seq;
79         ///
80         unsigned meta_fake_bit;
81         ///
82         void moveCursorUpdate(bool flag = true, bool selecting = false);
83         ///
84         void setupLocalKeymap();
85         ///
86         kb_action lyx_dead_action;
87         ///
88         kb_action lyx_calling_dead_action;
89         /// Error status, only Dispatch can change this flag
90         mutable bool errorstat;
91
92         /** Buffer to store messages and result data. Is there a
93             good reason to have this one as static in Dispatch? (Ale)
94         */
95         mutable string dispatch_buffer;
96         /// Command name and shortcut information
97         string commandshortcut;
98
99         // I think the following should be moved to BufferView. (Asger)
100
101         ///
102         void menuNew(bool fromTemplate);
103
104         ///
105         void open(string const &);
106
107         ///
108         void doImport(string const &);
109
110         ///
111         void closeBuffer();
112         ///
113         void reloadBuffer();
114         ///
115         //  This return or directly text (default) of getLyXText()
116         ///
117         LyXText * TEXT(bool) const;
118         ///
119         //  This is the same for all lyxfunc objects
120         static bool show_sc;
121 };
122      
123      
124 /*--------------------  inlines  --------------------------*/
125
126 inline
127 bool LyXFunc::wasMetaKey() const 
128
129         return (meta_fake_bit != 0);
130 }
131      
132
133 inline
134 void LyXFunc::setHintMessage(bool hm) 
135
136         show_sc = hm;
137 }
138
139 #endif