]> git.lyx.org Git - lyx.git/blob - src/lyxfunc.h
white-space changes, removed definitions.h several enum changes because of this,...
[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 "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, string const &arg = string());
35
36         
37         /// A keyboard event is processed to execute a lyx action. 
38         int  processKeyEvent(XEvent *ev);
39      
40         /// The last key was meta
41         bool wasMetaKey();
42
43         // These can't be global because are part of the internat state (ale970227)
44         /// Get the current keyseq string
45         string keyseqStr(int l = 190);
46
47         /// Is the key sequence uncomplete?
48         bool keyseqUncomplete();
49
50         /// get options for the current keyseq
51         string keyseqOptions(int l = 190);
52
53         /// Returns the name of a funcion given a keyseq
54         char const* getFunc(char*) 
55         { /* unimplemented */ return 0; }
56
57         /// Return a string with the keybind to an action, if any
58         char const* getKeybind(int) 
59         { /* unimplemented */ return 0; }
60
61         /// True if lyxfunc reports an error
62         bool errorStat() const { return errorstat; }
63         /// Buffer to store result messages
64         void setMessage(string const &m);
65         /// Buffer to store result messages
66         void setErrorMessage(string const &); 
67         /// Buffer to store result messages
68         string getMessage() const { return dispatch_buffer; }
69         /// Get next inset of this class from current cursor position  
70         Inset* getInsetByCode(Inset::Code);
71         
72         /// Should a hint message be displayed?
73         void setHintMessage(bool);
74
75 private:
76         ///
77         LyXView *owner;
78         ///
79         static kb_func_table* lyx_func_table;
80         ///
81         static kb_func_table *lyx_func_args;
82         ///
83         static int psd_idx;
84         ///
85         kb_sequence keyseq;
86         ///
87         kb_sequence cancel_meta_seq;
88         ///
89         unsigned meta_fake_bit;
90         ///
91         void moveCursorUpdate(bool selecting = false);
92         ///
93         void setupLocalKeymap();
94         ///
95         kb_action lyx_dead_action;
96         ///
97         kb_action lyx_calling_dead_action;
98         /// Error status, only Dispatch can change this flag
99         bool errorstat;
100
101         /** Buffer to store messages and result data. Is there a
102           good reason to have this one as static in Dispatch? (Ale)
103          */
104         string dispatch_buffer;
105         /// Command name and shortcut information
106         string commandshortcut;
107
108         // I think the following should be moved to BufferView. (Asger)
109
110         ///
111         void MenuNew(bool fromTemplate);
112
113         ///
114         void MenuOpen();
115
116         ///
117         void doImportLaTeX(bool);
118
119         ///
120         void doImportASCII(bool);
121
122         ///
123         void MenuInsertLyXFile(string const &);
124
125         ///
126         void CloseBuffer();
127         ///
128         void reloadBuffer();
129         /// This is the same for all lyxfunc objects
130         static bool show_sc;
131 };
132      
133      
134 /*--------------------  inlines  --------------------------*/
135
136 inline
137 bool LyXFunc::wasMetaKey() 
138
139         return (meta_fake_bit != 0);
140 }
141      
142
143 inline
144 string LyXFunc::keyseqStr(int l)
145 {
146         char text[200];
147         keyseq.print(text, l, true);
148         string tmp(text);
149         return tmp;
150
151
152
153 inline
154 string LyXFunc::keyseqOptions(int l)
155 {
156         char text[200];
157         keyseq.printOptions(text, l);
158         string tmp(text);
159         return tmp;
160
161
162
163 inline
164 bool LyXFunc::keyseqUncomplete() 
165
166         return (keyseq.length > 0);
167 }
168
169 inline
170 void LyXFunc::setHintMessage(bool hm) 
171
172         show_sc = hm;
173 }
174
175 #endif