]> git.lyx.org Git - lyx.git/blob - src/LyXAction.cpp
221564e61ad248a348a7cecb5eef059ba724dd52
[lyx.git] / src / LyXAction.cpp
1 /**
2  * \file LyXAction.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  * \author John Levon
9  * \author André Pönitz
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #include <config.h>
15
16 #include "LyXAction.h"
17
18 #include "support/debug.h"
19 #include "FuncRequest.h"
20
21 #include "support/lstrings.h"
22
23 #include <boost/assert.hpp>
24
25 using namespace std;
26 using namespace lyx::support;
27
28 namespace lyx {
29
30 /*
31      NAMING RULES FOR USER-COMMANDS
32      Here's the set of rules to apply when a new command name is introduced:
33
34      1) Use the object.event order. That is, use `word-forward'
35         instead of `forward-word'.
36      2) Don't introduce an alias for an already named object. Same for events.
37      3) Forward movement or focus is called `forward' (not `right').
38      4) Backward movement or focus is called `backward' (not `left').
39      5) Upward movement of focus is called `up'.
40      6) Downward movement is called `down'.
41      7) The begin of an object is called `begin' (not `start').
42      8) The end of an object is called `end'.
43
44      (May 19 1996, 12:04, RvdK)
45 */
46
47 LyXAction lyxaction;
48
49
50 void LyXAction::newFunc(kb_action action, string const & name,
51                         unsigned int attrib, LyXAction::func_type type)
52 {
53         lyx_func_map[name] = action;
54         func_info tmpinfo;
55         tmpinfo.name = name;
56         tmpinfo.attrib = attrib;
57         tmpinfo.type = type;
58         lyx_info_map[action] = tmpinfo;
59 }
60
61
62 // Needed for LFUNs documentation to be accepted, since doxygen won't take
63 // \var inside functions.
64 #ifndef DOXYGEN_SHOULD_SKIP_THIS
65 void LyXAction::init()
66 #endif
67 {
68         // This function was changed to use the array below in initalization
69         // instead of calling newFunc numerous times because of compilation
70         // times. Since the array is not static we get back the memory it
71         // occupies after the init is completed. It compiles several
72         // magnitudes faster.
73
74         static bool init;
75         if (init) return;
76
77         struct ev_item {
78                 kb_action action;
79                 char const * name;
80                 unsigned int attrib;
81                 func_type type;
82         };
83
84         ev_item const items[] = {
85                 { LFUN_ACCENT_ACUTE, "accent-acute", Noop, Layout },
86                 { LFUN_ACCENT_BREVE, "accent-breve", Noop, Layout },
87                 { LFUN_ACCENT_CARON, "accent-caron", Noop, Layout },
88                 { LFUN_ACCENT_CEDILLA, "accent-cedilla", Noop, Layout },
89                 { LFUN_ACCENT_CIRCLE, "accent-circle", Noop, Layout },
90                 { LFUN_ACCENT_CIRCUMFLEX, "accent-circumflex", Noop, Layout },
91                 { LFUN_ACCENT_DOT, "accent-dot", Noop, Layout },
92                 { LFUN_ACCENT_GRAVE, "accent-grave", Noop, Layout },
93                 { LFUN_ACCENT_HUNGARIAN_UMLAUT, "accent-hungarian-umlaut", Noop, Layout },
94                 { LFUN_ACCENT_MACRON, "accent-macron", Noop, Layout },
95                 { LFUN_ACCENT_OGONEK, "accent-ogonek", Noop, Layout },
96                 { LFUN_ACCENT_SPECIAL_CARON, "accent-special-caron", Noop, Layout },
97                 { LFUN_ACCENT_TIE, "accent-tie", Noop, Layout },
98                 { LFUN_ACCENT_TILDE, "accent-tilde", Noop, Layout },
99                 { LFUN_ACCENT_UMLAUT, "accent-umlaut", Noop, Layout },
100                 { LFUN_ACCENT_UNDERBAR, "accent-underbar", Noop, Layout },
101                 { LFUN_ACCENT_UNDERDOT, "accent-underdot", Noop, Layout },
102
103                 { LFUN_APPENDIX, "appendix", Noop, Edit },
104
105                 { LFUN_BREAK_PARAGRAPH, "break-paragraph", Noop, Edit },
106                 { LFUN_BREAK_PARAGRAPH_SKIP, "break-paragraph-skip", Noop, Edit },
107
108                 { LFUN_CAPTION_INSERT, "caption-insert", Noop, Edit },
109                 { LFUN_DATE_INSERT, "date-insert", Noop, Edit },
110                 { LFUN_FOOTNOTE_INSERT, "footnote-insert", Noop, Edit },
111                 { LFUN_ERT_INSERT, "ert-insert", Noop, Edit },
112                 { LFUN_FLOAT_INSERT, "float-insert", Noop, Edit },
113                 { LFUN_FLOAT_WIDE_INSERT, "float-wide-insert", Noop, Edit },
114                 { LFUN_WRAP_INSERT, "wrap-insert", Noop, Edit },
115                 { LFUN_HFILL_INSERT, "hfill-insert", Noop, Edit },
116                 { LFUN_OPTIONAL_INSERT, "optional-insert", Noop, Edit },
117                 { LFUN_LINE_INSERT, "line-insert", Noop, Edit },
118                 { LFUN_NEWPAGE_INSERT, "newpage-insert", Noop, Edit },
119                 { LFUN_PAGEBREAK_INSERT, "pagebreak-insert", Noop, Edit },
120                 { LFUN_MARGINALNOTE_INSERT, "marginalnote-insert", Noop, Edit },
121                 { LFUN_UNICODE_INSERT, "unicode-insert", Noop, Edit },
122                 { LFUN_LISTING_INSERT, "listing-insert", Noop, Edit },
123                 { LFUN_QUOTE_INSERT, "quote-insert", Noop, Edit },
124                 { LFUN_INFO_INSERT, "info-insert", Noop, Edit },
125                 { LFUN_BRANCH_INSERT, "branch-insert", Noop, Edit },
126                 { LFUN_BOX_INSERT, "box-insert", Noop, Edit },
127                 { LFUN_FLEX_INSERT, "flex-insert", Noop, Edit },
128                 { LFUN_SELF_INSERT, "self-insert", SingleParUpdate, Hidden },
129                 { LFUN_SPACE_INSERT, "space-insert", Noop, Edit },
130                 { LFUN_HYPERLINK_INSERT, "href-insert", Noop, Edit },
131                 { LFUN_SPECIALCHAR_INSERT, "specialchar-insert", Noop, Edit },
132                 { LFUN_CLEARPAGE_INSERT, "clearpage-insert", Noop, Edit },
133                 { LFUN_CLEARDOUBLEPAGE_INSERT, "cleardoublepage-insert", Noop, Edit },
134                 { LFUN_TOC_INSERT, "toc-insert", Noop, Edit },
135 #if 0
136                 { LFUN_LIST_INSERT, "list-insert", Noop, Edit },
137 #endif
138 #if 0
139                 { LFUN_THEOREM_INSERT, "theorem-insert", Noop, Edit },
140 #endif
141
142                 { LFUN_DELETE_BACKWARD_SKIP, "delete-backward-skip", Noop, Edit },
143                 { LFUN_DELETE_FORWARD_SKIP, "delete-forward-skip", Noop, Edit },
144                 { LFUN_DOWN, "down", ReadOnly | NoUpdate, Edit },
145                 { LFUN_DOWN_SELECT, "down-select", ReadOnly | SingleParUpdate, Edit },
146                 { LFUN_UP, "up", ReadOnly | NoUpdate, Edit },
147                 { LFUN_UP_SELECT, "up-select", ReadOnly | SingleParUpdate, Edit },
148                 { LFUN_SCREEN_DOWN, "screen-down", ReadOnly, Edit },
149                 { LFUN_SCREEN_DOWN_SELECT, "screen-down-select", ReadOnly, Edit },
150                 { LFUN_SCREEN_FONT_UPDATE, "screen-font-update", NoBuffer, Layout },
151                 { LFUN_SCROLL, "scroll", ReadOnly, Edit },
152                 { LFUN_SCREEN_RECENTER, "screen-recenter", ReadOnly, Edit },
153                 { LFUN_SCREEN_UP, "screen-up", ReadOnly, Edit },
154                 { LFUN_SCREEN_UP_SELECT, "screen-up-select", ReadOnly, Edit },
155
156                 { LFUN_CHAR_BACKWARD, "char-backward", ReadOnly | NoUpdate, Edit },
157                 { LFUN_CHAR_BACKWARD_SELECT, "char-backward-select", ReadOnly | SingleParUpdate, Edit },
158                 { LFUN_CHAR_DELETE_BACKWARD, "delete-backward", SingleParUpdate, Edit },
159                 { LFUN_CHAR_DELETE_FORWARD, "delete-forward", SingleParUpdate, Edit },
160                 { LFUN_CHAR_FORWARD, "char-forward", ReadOnly | NoUpdate, Edit },
161                 { LFUN_CHAR_FORWARD_SELECT, "char-forward-select", ReadOnly | SingleParUpdate, Edit },
162                 { LFUN_CHAR_LEFT, "char-left", ReadOnly | NoUpdate, Edit },
163                 { LFUN_CHAR_LEFT_SELECT, "char-left-select", ReadOnly | SingleParUpdate, Edit },
164                 { LFUN_CHAR_RIGHT, "char-right", ReadOnly | NoUpdate, Edit },
165                 { LFUN_CHAR_RIGHT_SELECT, "char-right-select", ReadOnly | SingleParUpdate, Edit },
166
167                 { LFUN_WORD_BACKWARD, "word-backward", ReadOnly | NoUpdate, Edit },
168                 { LFUN_WORD_BACKWARD_SELECT, "word-backward-select", ReadOnly | SingleParUpdate, Edit },
169                 { LFUN_WORD_CAPITALIZE, "word-capitalize", Noop, Edit },
170                 { LFUN_WORD_DELETE_BACKWARD, "word-delete-backward", Noop, Edit },
171                 { LFUN_WORD_DELETE_FORWARD, "word-delete-forward", Noop, Edit },
172                 { LFUN_WORD_FIND_BACKWARD, "word-find-backward", ReadOnly, Edit },
173                 { LFUN_WORD_FIND_FORWARD, "word-find-forward", ReadOnly, Edit },
174                 { LFUN_WORD_FORWARD, "word-forward", ReadOnly | NoUpdate, Edit },
175                 { LFUN_WORD_FORWARD_SELECT, "word-forward-select", ReadOnly | SingleParUpdate, Edit },
176                 { LFUN_WORD_LEFT, "word-left", ReadOnly | NoUpdate, Edit },
177                 { LFUN_WORD_LEFT_SELECT, "word-left-select", ReadOnly | SingleParUpdate, Edit },
178                 { LFUN_WORD_LOWCASE, "word-lowcase", Noop, Edit },
179                 { LFUN_WORD_RIGHT, "word-right", ReadOnly | NoUpdate, Edit },
180                 { LFUN_WORD_RIGHT_SELECT, "word-right-select", ReadOnly | SingleParUpdate, Edit },
181                 { LFUN_WORD_SELECT, "word-select", ReadOnly, Edit },
182                 { LFUN_WORD_UPCASE, "word-upcase", Noop, Edit },
183                 { LFUN_WORD_FIND, "word-find", ReadOnly, Edit },
184                 { LFUN_WORD_REPLACE, "word-replace", Noop, Edit },
185
186                 { LFUN_LINE_BEGIN, "line-begin", ReadOnly | NoUpdate, Edit },
187                 { LFUN_LINE_BEGIN_SELECT, "line-begin-select", ReadOnly | SingleParUpdate, Edit },
188                 { LFUN_LINE_BREAK, "line-break", Noop, Edit },
189                 { LFUN_LINE_DELETE, "line-delete-forward", Noop, Edit }, // there is no line-delete-backward
190                 { LFUN_LINE_END, "line-end", ReadOnly | NoUpdate, Edit },
191                 { LFUN_LINE_END_SELECT, "line-end-select", ReadOnly | SingleParUpdate, Edit },
192                 { LFUN_NEW_LINE, "new-line", Noop, Edit },
193
194                 { LFUN_PARAGRAPH_MOVE_DOWN, "paragraph-move-down", Noop, Edit },
195                 { LFUN_PARAGRAPH_MOVE_UP, "paragraph-move-up", Noop, Edit },
196
197                 { LFUN_COPY, "copy", ReadOnly, Edit },
198                 { LFUN_CUT, "cut", Noop, Edit },
199                 { LFUN_PASTE, "paste", Noop, Edit },
200                 { LFUN_CLIPBOARD_PASTE, "clipboard-paste", Noop, Edit },
201                 { LFUN_PRIMARY_SELECTION_PASTE, "primary-selection-paste", Noop, Edit },
202                 { LFUN_UNDO, "undo", Noop, Edit },
203                 { LFUN_REDO, "redo", Noop, Edit },
204                 { LFUN_REPEAT, "repeat", NoBuffer, Edit },
205                 { LFUN_CHARS_TRANSPOSE, "chars-transpose", Noop, Edit },
206
207                 { LFUN_DEPTH_DECREMENT, "depth-decrement", Noop, Edit },
208                 { LFUN_DEPTH_INCREMENT, "depth-increment", Noop, Edit },
209                 { LFUN_ENVIRONMENT_INSERT, "environment-insert", Noop, Edit },
210
211                 { LFUN_FONT_BOLD, "font-bold", Noop, Layout },
212                 { LFUN_FONT_TYPEWRITER, "font-typewriter", Noop, Layout },
213                 { LFUN_FONT_DEFAULT, "font-default", Noop, Layout },
214                 { LFUN_FONT_EMPH, "font-emph", Noop, Layout },
215                 { LFUN_FONT_FREE_APPLY, "font-free-apply", Noop, Layout },
216                 { LFUN_FONT_FREE_UPDATE, "font-free-update", Noop, Layout },
217                 { LFUN_FONT_NOUN, "font-noun", Noop, Layout },
218                 { LFUN_FONT_ROMAN, "font-roman", Noop, Layout },
219                 { LFUN_FONT_SANS, "font-sans", Noop, Layout },
220                 { LFUN_FONT_FRAK, "font-frak", Noop, Layout },
221                 { LFUN_FONT_ITAL, "font-ital", Noop, Layout },
222                 { LFUN_FONT_SIZE, "font-size", Noop, Layout },
223                 { LFUN_FONT_STATE, "font-state", ReadOnly, Layout },
224                 { LFUN_FONT_UNDERLINE, "font-underline", Noop, Layout },
225
226                 { LFUN_INDEX_INSERT, "index-insert", Noop, Edit },
227                 { LFUN_INDEX_PRINT, "index-print", Noop, Edit },
228
229                 { LFUN_NOMENCL_INSERT, "nomencl-insert", Noop, Edit },
230                 { LFUN_NOMENCL_PRINT, "nomencl-print", Noop, Edit },
231
232                 { LFUN_NOTE_INSERT, "note-insert", Noop, Edit },
233                 { LFUN_NOTE_NEXT, "note-next", ReadOnly, Edit },
234
235                 { LFUN_BIBITEM_INSERT, "bibitem-insert", Noop, Edit },
236                 { LFUN_CITATION_INSERT, "citation-insert", Noop, Edit },
237                 { LFUN_BIBTEX_DATABASE_ADD, "bibtex-database-add", Noop, Edit },
238                 { LFUN_BIBTEX_DATABASE_DEL, "bibtex-database-del", Noop, Edit },
239
240                 { LFUN_LAYOUT, "layout", Noop, Layout },
241                 { LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", ReadOnly, Layout },
242                 { LFUN_LAYOUT_TABULAR, "layout-tabular", Noop, Layout },
243                 { LFUN_DROP_LAYOUTS_CHOICE, "drop-layouts-choice", ReadOnly, Layout },
244                 { LFUN_LAYOUT_MODULES_CLEAR, "layout-modules-clear", Noop, Layout },
245                 { LFUN_LAYOUT_MODULE_ADD, "layout-module-add", Noop, Layout },
246                 { LFUN_LAYOUT_RELOAD, "layout-reload", Noop, Layout },
247                 { LFUN_TEXTCLASS_APPLY, "textclass-apply", Noop, Layout },
248                 { LFUN_TEXTCLASS_LOAD, "textclass-load", Noop, Layout },
249
250                 { LFUN_MARK_OFF, "mark-off", ReadOnly, Edit },
251                 { LFUN_MARK_ON, "mark-on", ReadOnly, Edit },
252                 { LFUN_MARK_TOGGLE, "mark-toggle", ReadOnly, Edit },
253                 { LFUN_MATH_DELIM, "math-delim", Noop, Math },
254                 { LFUN_MATH_BIGDELIM, "math-bigdelim", Noop, Math },
255                 { LFUN_MATH_DISPLAY, "math-display", Noop, Math },
256                 { LFUN_MATH_INSERT, "math-insert", Noop, Math },
257                 { LFUN_MATH_SUBSCRIPT, "math-subscript", Noop, Math },
258                 { LFUN_MATH_SUPERSCRIPT, "math-superscript", Noop, Math },
259                 { LFUN_MATH_LIMITS, "math-limits", Noop, Math },
260                 { LFUN_MATH_MACRO, "math-macro", Noop, Math },
261                 { LFUN_MATH_MUTATE, "math-mutate", Noop, Math },
262                 { LFUN_MATH_SPACE, "math-space", Noop, Math },
263                 { LFUN_MATH_IMPORT_SELECTION, "math-import-selection", Noop, Math },
264                 { LFUN_MATH_MATRIX, "math-matrix", Noop, Math },
265                 { LFUN_MATH_MODE, "math-mode", Noop, Math },
266                 { LFUN_MATH_NONUMBER, "math-nonumber", Noop, Math },
267                 { LFUN_MATH_NUMBER, "math-number", Noop, Math },
268                 { LFUN_MATH_EXTERN, "math-extern", Noop, Math },
269                 { LFUN_MATH_SIZE, "math-size", Noop, Math },
270                 { LFUN_MATH_MACRO_UNFOLD, "math-macro-unfold", ReadOnly | SingleParUpdate, Math },
271                 { LFUN_MATH_MACRO_FOLD, "math-macro-fold", ReadOnly | SingleParUpdate, Math },
272                 { LFUN_MATH_MACRO_ADD_PARAM, "math-macro-add-param", Noop, Math },
273                 { LFUN_MATH_MACRO_REMOVE_PARAM, "math-macro-remove-param", Noop, Math },
274                 { LFUN_MATH_MACRO_APPEND_GREEDY_PARAM, "math-macro-append-greedy-param", Noop, Math },
275                 { LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM, "math-macro-remove-greedy-param", Noop, Math },
276                 { LFUN_MATH_MACRO_MAKE_OPTIONAL, "math-macro-make-optional", Noop, Math },
277                 { LFUN_MATH_MACRO_MAKE_NONOPTIONAL, "math-macro-make-nonoptional", Noop, Math },
278                 { LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM, "math-macro-add-optional-param", Noop, Math },
279                 { LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM, "math-macro-remove-optional-param", Noop, Math },
280                 { LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM, "math-macro-add-greedy-optional-param", Noop, Math },
281                 { LFUN_IN_MATHMACROTEMPLATE, "in-mathmacrotemplate", Noop, Math },
282
283                 { LFUN_PARAGRAPH_DOWN, "paragraph-down", ReadOnly | NoUpdate, Edit },
284                 { LFUN_PARAGRAPH_DOWN_SELECT, "paragraph-down-select", ReadOnly, Edit },
285                 { LFUN_PARAGRAPH_GOTO, "paragraph-goto", ReadOnly, Edit },
286                 { LFUN_OUTLINE_UP, "outline-up", Noop, Edit },
287                 { LFUN_OUTLINE_DOWN, "outline-down", Noop, Edit },
288                 { LFUN_OUTLINE_IN, "outline-in", Noop, Edit },
289                 { LFUN_OUTLINE_OUT, "outline-out", Noop, Edit },
290
291                 { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", Noop, Edit },
292                 { LFUN_PARAGRAPH_UP, "paragraph-up", ReadOnly | NoUpdate, Edit },
293                 { LFUN_PARAGRAPH_UP_SELECT, "paragraph-up-select", ReadOnly, Edit },
294
295                 { LFUN_EXTERNAL_EDIT, "external-edit", Noop, Edit },
296                 { LFUN_GRAPHICS_EDIT, "graphics-edit", Noop, Edit },
297
298                 { LFUN_CELL_BACKWARD, "cell-backward", Noop, Edit },
299                 { LFUN_CELL_FORWARD, "cell-forward", Noop, Edit },
300                 { LFUN_CELL_SPLIT, "cell-split", Noop, Edit },
301                 { LFUN_TABULAR_INSERT, "tabular-insert", Noop, Edit },
302                 { LFUN_TABULAR_FEATURE, "tabular-feature", Noop, Edit },
303
304                 { LFUN_VC_CHECK_IN, "vc-check-in", ReadOnly, System },
305                 { LFUN_VC_CHECK_OUT, "vc-check-out", ReadOnly, System },
306                 { LFUN_VC_REGISTER, "vc-register", ReadOnly, System },
307                 { LFUN_VC_REVERT, "vc-revert", ReadOnly, System },
308                 { LFUN_VC_UNDO_LAST, "vc-undo-last", ReadOnly, System },
309
310                 { LFUN_CHANGES_TRACK, "changes-track", Noop, Edit },
311                 { LFUN_CHANGES_OUTPUT, "changes-output", Noop, Edit },
312                 { LFUN_CHANGE_NEXT, "change-next", ReadOnly, Edit },
313                 { LFUN_CHANGES_MERGE, "changes-merge", Noop, Edit },
314                 { LFUN_CHANGE_ACCEPT, "change-accept", Noop, Edit },
315                 { LFUN_CHANGE_REJECT, "change-reject", Noop, Edit },
316                 { LFUN_ALL_CHANGES_ACCEPT, "all-changes-accept", Noop, Edit },
317                 { LFUN_ALL_CHANGES_REJECT, "all-changes-reject", Noop, Edit },
318
319                 { LFUN_INSET_APPLY, "inset-apply", Noop, Edit },
320                 { LFUN_INSET_DISSOLVE, "inset-dissolve", Noop, Edit },
321                 { LFUN_INSET_INSERT, "inset-insert", Noop, Edit },
322                 { LFUN_INSET_MODIFY, "", Noop, Hidden },
323                 { LFUN_INSET_DIALOG_UPDATE, "", Noop, Hidden },
324                 { LFUN_INSET_SETTINGS, "inset-settings", ReadOnly, Edit },
325                 { LFUN_INSET_REFRESH, "", Noop, Hidden },
326                 { LFUN_NEXT_INSET_TOGGLE, "next-inset-toggle", ReadOnly, Edit },
327                 { LFUN_INSET_TOGGLE, "", ReadOnly, Hidden },
328                 { LFUN_ALL_INSETS_TOGGLE, "all-insets-toggle", ReadOnly, Edit },
329
330                 { LFUN_PARAGRAPH_PARAMS, "paragraph-params", Noop, Edit },
331                 { LFUN_PARAGRAPH_PARAMS_APPLY, "paragraph-params-apply", Noop, Edit },
332                 { LFUN_PARAGRAPH_UPDATE, "", Noop, Hidden },
333
334                 { LFUN_FINISHED_FORWARD, "", ReadOnly, Hidden },
335                 { LFUN_FINISHED_BACKWARD, "", ReadOnly, Hidden },
336                 { LFUN_FINISHED_RIGHT, "", ReadOnly, Hidden },
337                 { LFUN_FINISHED_LEFT, "", ReadOnly, Hidden },
338
339                 { LFUN_LANGUAGE, "language", Noop, Edit },
340
341                 { LFUN_LABEL_GOTO, "label-goto", ReadOnly, Edit },
342                 { LFUN_LABEL_INSERT, "label-insert", Noop, Edit },
343                 { LFUN_REFERENCE_NEXT, "reference-next", ReadOnly, Edit },
344
345                 { LFUN_BOOKMARK_GOTO, "bookmark-goto", NoBuffer, Edit },
346                 { LFUN_BOOKMARK_SAVE, "bookmark-save", ReadOnly, Edit },
347                 { LFUN_BOOKMARK_CLEAR, "bookmark-clear", NoBuffer, Edit },
348
349                 { LFUN_ERROR_NEXT, "error-next", ReadOnly, Edit },
350                 { LFUN_HELP_OPEN, "help-open", NoBuffer | Argument, Buffer },
351                 { LFUN_LYX_QUIT, "lyx-quit", NoBuffer, Buffer },
352                 { LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer, Edit },
353                 { LFUN_MENU_OPEN, "menu-open", NoBuffer, Buffer },
354
355                 { LFUN_WINDOW_NEW, "window-new", NoBuffer, Buffer },
356                 { LFUN_WINDOW_CLOSE, "window-close", NoBuffer, Buffer },
357
358                 { LFUN_DIALOG_SHOW, "dialog-show", NoBuffer, Edit },
359                 { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop, Edit },
360                 { LFUN_DIALOG_UPDATE, "dialog-update", NoBuffer, Edit },
361                 { LFUN_DIALOG_HIDE, "dialog-hide", NoBuffer, Edit },
362                 { LFUN_DIALOG_TOGGLE, "dialog-toggle", NoBuffer, Edit },
363                 { LFUN_DIALOG_DISCONNECT_INSET, "dialog-disconnect-inset", Noop, Edit },
364
365                 { LFUN_MOUSE_PRESS, "", ReadOnly, Hidden },
366                 { LFUN_MOUSE_MOTION, "", ReadOnly | SingleParUpdate, Hidden },
367                 { LFUN_MOUSE_RELEASE, "", ReadOnly, Hidden },
368                 { LFUN_MOUSE_DOUBLE, "", ReadOnly, Hidden },
369                 { LFUN_MOUSE_TRIPLE, "", ReadOnly, Hidden },
370
371                 { LFUN_KEYMAP_OFF, "keymap-off", ReadOnly, Edit },
372                 { LFUN_KEYMAP_PRIMARY, "keymap-primary", ReadOnly, Edit },
373                 { LFUN_KEYMAP_SECONDARY, "keymap-secondary", ReadOnly, Edit },
374                 { LFUN_KEYMAP_TOGGLE, "keymap-toggle", ReadOnly, Edit },
375
376                 { LFUN_MESSAGE, "message", NoBuffer, System },
377                 { LFUN_FLOAT_LIST, "float-list", Noop, Edit },
378                 { LFUN_ESCAPE, "escape", ReadOnly, Edit },
379
380                 { LFUN_SERVER_CHAR_AFTER, "server-char-after", ReadOnly, System },
381                 { LFUN_SERVER_GET_FONT, "server-get-font", ReadOnly, System },
382                 { LFUN_SERVER_GET_LAYOUT, "server-get-layout", ReadOnly, System },
383                 { LFUN_SERVER_GET_NAME, "server-get-name", ReadOnly, System },
384                 { LFUN_SERVER_GET_XY, "server-get-xy", ReadOnly, System },
385                 { LFUN_SERVER_GOTO_FILE_ROW, "server-goto-file-row", ReadOnly, System },
386                 { LFUN_SERVER_NOTIFY, "server-notify", ReadOnly, System },
387                 { LFUN_SERVER_SET_XY, "server-set-xy", ReadOnly, System },
388
389                 { LFUN_BUILD_PROGRAM, "build-program", ReadOnly, Buffer },
390
391                 { LFUN_BUFFER_AUTO_SAVE, "buffer-auto-save", Noop, Buffer },
392                 { LFUN_BUFFER_BEGIN, "buffer-begin", ReadOnly, Edit },
393                 { LFUN_BUFFER_BEGIN_SELECT, "buffer-begin-select", ReadOnly, Edit },
394                 { LFUN_BUFFER_CHILD_OPEN, "buffer-child-open", ReadOnly, Buffer },
395                 { LFUN_BUFFER_CHKTEX, "buffer-chktex", ReadOnly, Buffer },
396                 { LFUN_BUFFER_TOGGLE_COMPRESSION, "buffer-toggle-compression", Noop, Buffer },
397                 { LFUN_BUFFER_TOGGLE_EMBEDDING, "buffer-toggle-embedding", Noop, Buffer },
398                 { LFUN_BUFFER_CLOSE, "buffer-close", ReadOnly, Buffer },
399                 { LFUN_BUFFER_END, "buffer-end", ReadOnly, Edit },
400                 { LFUN_BUFFER_END_SELECT, "buffer-end-select", ReadOnly, Edit },
401                 { LFUN_BUFFER_EXPORT, "buffer-export", ReadOnly, Buffer },
402                 { LFUN_BUFFER_EXPORT_CUSTOM, "buffer-export-custom", ReadOnly, Buffer },
403                 { LFUN_BUFFER_PRINT, "buffer-print", ReadOnly, Buffer },
404                 { LFUN_BUFFER_IMPORT, "buffer-import", NoBuffer, Buffer },
405                 { LFUN_BUFFER_NEW, "buffer-new", NoBuffer, Buffer },
406                 { LFUN_BUFFER_NEW_TEMPLATE,"buffer-new-template", NoBuffer, Buffer },
407                 { LFUN_BUFFER_RELOAD, "buffer-reload", ReadOnly, Buffer },
408                 { LFUN_BUFFER_SWITCH, "buffer-switch", NoBuffer | ReadOnly, Edit },
409                 { LFUN_BUFFER_TOGGLE_READ_ONLY, "buffer-toggle-read-only", ReadOnly, Buffer },
410                 { LFUN_BUFFER_UPDATE, "buffer-update", ReadOnly, Edit },
411                 { LFUN_BUFFER_VIEW, "buffer-view", ReadOnly, Edit },
412                 { LFUN_BUFFER_WRITE, "buffer-write", ReadOnly, Buffer },
413                 { LFUN_BUFFER_WRITE_AS, "buffer-write-as", ReadOnly, Buffer },
414                 { LFUN_BUFFER_WRITE_ALL, "buffer-write-all", ReadOnly, Buffer },
415                 { LFUN_BUFFER_NEXT, "buffer-next", ReadOnly, Buffer },
416                 { LFUN_BUFFER_PREVIOUS, "buffer-previous", ReadOnly, Buffer },
417                 { LFUN_MASTER_BUFFER_UPDATE, "master-buffer-update", ReadOnly, Edit },
418                 { LFUN_MASTER_BUFFER_VIEW, "master-buffer-view", ReadOnly, Edit },
419                 { LFUN_BUFFER_LANGUAGE, "buffer-language", Noop, Buffer },
420                 { LFUN_BUFFER_SAVE_AS_DEFAULT, "buffer-save-as-default", Noop, Buffer },
421                 { LFUN_BUFFER_PARAMS_APPLY, "buffer-params-apply", Noop, Buffer },
422
423                 { LFUN_FILE_INSERT, "file-insert", Noop, Buffer },
424                 { LFUN_FILE_INSERT_PLAINTEXT, "file-insert-plaintext", Noop, Edit },
425                 { LFUN_FILE_INSERT_PLAINTEXT_PARA, "file-insert-plaintext-para", Noop, Edit },
426                 { LFUN_FILE_NEW, "file-new", NoBuffer, Buffer },
427                 { LFUN_FILE_OPEN, "file-open", NoBuffer, Buffer },
428
429                 { LFUN_META_PREFIX, "meta-prefix", NoBuffer, System },
430
431                 { LFUN_CALL, "call", NoBuffer, System },
432                 { LFUN_CANCEL, "cancel", NoBuffer, System },
433
434                 { LFUN_COMMAND_EXECUTE, "command-execute", NoBuffer, Edit },
435                 { LFUN_COMMAND_PREFIX, "command-prefix", NoBuffer, Hidden },
436                 { LFUN_COMMAND_SEQUENCE, "command-sequence", NoBuffer, System },
437
438                 { LFUN_PREFERENCES_SAVE, "preferences-save", NoBuffer, Edit },
439                 { LFUN_RECONFIGURE, "reconfigure", NoBuffer, System },
440                 { LFUN_LYXRC_APPLY, "lyxrc-apply", NoBuffer, System },
441                 { LFUN_TOGGLE_CURSOR_FOLLOWS_SCROLLBAR, "toggle-cursor-follows-scrollbar", ReadOnly, Edit },
442
443                 { LFUN_SET_COLOR, "set-color", ReadOnly | NoBuffer, Edit },
444                 { LFUN_THESAURUS_ENTRY, "thesaurus-entry", ReadOnly, Edit },
445                 { LFUN_STATISTICS, "statistics", ReadOnly, System },
446
447                 { LFUN_NOACTION, "", Noop, Hidden }
448         };
449
450         for (int i = 0; items[i].action != LFUN_NOACTION; ++i) {
451                 newFunc(items[i].action, items[i].name, items[i].attrib, items[i].type);
452         }
453
454         init = true;
455 }
456
457
458 LyXAction::LyXAction()
459 {
460         init();
461 }
462
463
464 // Returns an action tag from a string.
465 FuncRequest LyXAction::lookupFunc(string const & func) const
466 {
467         string const func2 = trim(func);
468
469         if (func2.empty()) {
470                 return FuncRequest(LFUN_NOACTION);
471         }
472
473         string cmd;
474         string const arg = split(func2, cmd, ' ');
475
476         func_map::const_iterator fit = lyx_func_map.find(cmd);
477
478         return fit != lyx_func_map.end() ? FuncRequest(fit->second, arg) : FuncRequest(LFUN_UNKNOWN_ACTION);
479 }
480
481
482 string const LyXAction::getActionName(kb_action action) const
483 {
484         info_map::const_iterator const it = lyx_info_map.find(action);
485         return it != lyx_info_map.end() ? it->second.name : string();
486 }
487
488
489 LyXAction::func_type const LyXAction::getActionType(kb_action action) const
490 {
491         info_map::const_iterator const it = lyx_info_map.find(action);
492         return it != lyx_info_map.end() ? it->second.type : Hidden;
493 }
494
495
496 bool LyXAction::funcHasFlag(kb_action action,
497                             LyXAction::func_attrib flag) const
498 {
499         info_map::const_iterator ici = lyx_info_map.find(action);
500
501         if (ici == lyx_info_map.end()) {
502                 LYXERR0("action: " << action << " is not known.");
503                 BOOST_ASSERT(false);
504         }
505
506         return ici->second.attrib & flag;
507 }
508
509
510 LyXAction::const_func_iterator LyXAction::func_begin() const
511 {
512         return lyx_func_map.begin();
513 }
514
515
516 LyXAction::const_func_iterator LyXAction::func_end() const
517 {
518         return lyx_func_map.end();
519 }
520
521
522 } // namespace lyx