]> git.lyx.org Git - features.git/blob - src/lyxfunc.h
The command-sequence patch from Andre'; also remove the comment in first
[features.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 "commandtags.h"
10 #include "kbmap.h"
11 #include "tex-accent.h"
12 #include "LyXAction.h"
13 #include "insets/lyxinset.h"
14 #include "LString.h"
15 class LyXView;
16
17 /** This class encapsulates all the LyX command operations. 
18     This is the class of the LyX's "high level event handler".
19     Every user command is processed here, either invocated from
20     keyboard or from the GUI. All GUI objects, including buttons and
21     menus should use this class and never call kernel functions directly.
22 */
23 class LyXFunc {
24 public:
25         ///
26         LyXFunc(LyXView*);
27         ///
28         ~LyXFunc();
29     
30         /// LyX distpatcher, executes lyx actions.
31         string Dispatch(int action, char const* arg = 0);
32                          
33         /// The same but uses the name of a lyx command.
34         string Dispatch(string const &cmd);
35
36         /// A keyboard event is processed to execute a lyx action. 
37         int  processKeyEvent(XEvent *ev);
38      
39         /// The last key was meta
40         bool wasMetaKey();
41
42         // These can't be global because are part of the internat state (ale970227)
43         /// Get the current keyseq string
44         string keyseqStr(int l = 190);
45
46         /// Is the key sequence uncomplete?
47         bool keyseqUncomplete();
48
49         /// get options for the current keyseq
50         string keyseqOptions(int l = 190);
51
52         /// Returns the name of a funcion given a keyseq
53         char const* getFunc(char*) 
54         { /* unimplemented */ return 0; }
55
56         /// Return a string with the keybind to an action, if any
57         char const* getKeybind(int) 
58         { /* unimplemented */ return 0; }
59
60         /// True if lyxfunc reports an error
61         bool errorStat() const { return errorstat; }
62         /// Buffer to store result messages
63         void setMessage(string const &m);
64         /// Buffer to store result messages
65         void setErrorMessage(string const &); 
66         /// Buffer to store result messages
67         string getMessage() const { return dispatch_buffer; }
68         /// Get next inset of this class from current cursor position  
69         Inset* getInsetByCode(Inset::Code);
70         
71         /// Should a hint message be displayed?
72         void setHintMessage(bool);
73
74 private:
75         ///
76         LyXView *owner;
77         ///
78         static kb_func_table* lyx_func_table;
79         ///
80         static kb_func_table *lyx_func_args;
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 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         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         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 MenuOpen();
114
115         ///
116         void doImportLaTeX(bool);
117
118         ///
119         void doImportASCII(bool);
120
121         ///
122         void MenuInsertLyXFile(string const &);
123
124         ///
125         void CloseBuffer();
126         ///
127         void reloadBuffer();
128         /// This is the same for all lyxfunc objects
129         static bool show_sc;
130 };
131      
132      
133 /*--------------------  inlines  --------------------------*/
134
135 inline
136 bool LyXFunc::wasMetaKey() 
137
138         return (meta_fake_bit != 0);
139 }
140      
141
142 inline
143 string LyXFunc::keyseqStr(int l)
144 {
145         char text[200];
146         keyseq.print(text, l, true);
147         string tmp(text);
148         return tmp;
149
150
151
152 inline
153 string LyXFunc::keyseqOptions(int l)
154 {
155         char text[200];
156         keyseq.printOptions(text, l);
157         string tmp(text);
158         return tmp;
159
160
161
162 inline
163 bool LyXFunc::keyseqUncomplete() 
164
165         return (keyseq.length > 0);
166 }
167
168 inline
169 void LyXFunc::setHintMessage(bool hm) 
170
171         show_sc = hm;
172 }
173
174 #endif