This commit was manufactured by cvs2svn to create tag
[lyx.git] / src / lyxfunc.h
blob3abd7ce1ff968ef609c2358670552abe818e687e
1 // -*- C++ -*-
2 #ifndef LYXFUNC_H
3 #define LYXFUNC_H
5 #ifdef __GNUG__
6 #pragma interface
7 #endif
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;
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.
23 class LyXFunc {
24 public:
25 ///
26 LyXFunc(LyXView*);
27 ///
28 ~LyXFunc();
30 /// LyX distpatcher, executes lyx actions.
31 string Dispatch(int action, char const* arg = 0);
33 /// The same but uses the name of a lyx command.
34 string Dispatch(string const &cmd, string const &arg = string());
37 /// A keyboard event is processed to execute a lyx action.
38 int processKeyEvent(XEvent *ev);
40 /// The last key was meta
41 bool wasMetaKey();
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);
47 /// Is the key sequence uncomplete?
48 bool keyseqUncomplete();
50 /// get options for the current keyseq
51 string keyseqOptions(int l=190);
53 /// Returns the name of a funcion given a keyseq
54 char const* getFunc(char*)
55 { /* unimplemented */ return 0; }
57 /// Return a string with the keybind to an action, if any
58 char const* getKeybind(int)
59 { /* unimplemented */ return 0; }
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);
72 /// Should a hint message be displayed?
73 void setHintMessage(bool);
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;
101 /** Buffer to store messages and result data. Is there a
102 good reason to have this one as static in Dispatch? (Ale)
104 string dispatch_buffer;
105 /// Command name and shortcut information
106 string commandshortcut;
108 // I think the following should be moved to BufferView. (Asger)
111 void MenuNew(bool fromTemplate);
114 void MenuOpen();
117 void doImportLaTeX(bool);
120 void doImportASCII(bool);
123 void MenuInsertLyXFile(string const &);
126 void CloseBuffer();
128 void reloadBuffer();
129 /// This is the same for all lyxfunc objects
130 static bool show_sc;
134 /*-------------------- inlines --------------------------*/
136 inline
137 bool LyXFunc::wasMetaKey()
139 return (meta_fake_bit != 0);
143 inline
144 string LyXFunc::keyseqStr(int l)
146 char text[200];
147 keyseq.print(text, l, true);
148 string tmp(text);
149 return tmp;
153 inline
154 string LyXFunc::keyseqOptions(int l)
156 char text[200];
157 keyseq.printOptions(text, l);
158 string tmp(text);
159 return tmp;
163 inline
164 bool LyXFunc::keyseqUncomplete()
166 return (keyseq.length > 0);
169 inline
170 void LyXFunc::setHintMessage(bool hm)
172 show_sc = hm;
175 #endif