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