]> git.lyx.org Git - lyx.git/blob - src/LyXAction.C
Alfredo's second patch
[lyx.git] / src / LyXAction.C
1 /**
2  * \file LyXAction.C
3  * Copyright 1995-2002 the LyX Team
4  * Read the file COPYING
5  */
6
7 #include <config.h>
8
9 #include "LyXAction.h"
10
11 #include "debug.h"
12 #include "gettext.h"
13 #include "support/lstrings.h"
14
15 using std::ostream;
16 using std::endl;
17 using std::pair;
18 using std::make_pair;
19
20 /*
21      NAMING RULES FOR USER-COMMANDS
22      Here's the set of rules to apply when a new command name is introduced:
23
24      1) Use the object.event order. That is, use `word-forward'
25         instead of `forward-word'.
26      2) Don't introduce an alias for an already named object. Same for events.
27      3) Forward movement or focus is called `forward' (not `right').
28      4) Backward movement or focus is called `backward' (not `left').
29      5) Upward movement of focus is called `up'.
30      6) Downward movement is called `down'.
31      7) The begin of an object is called `begin' (not `start').
32      8) The end of an object is called `end'.
33
34      (May 19 1996, 12:04, RvdK)
35 */
36
37 LyXAction lyxaction;
38
39 namespace {
40
41 /// return true if the given action is a pseudo-action
42 inline bool isPseudoAction(int a)
43 {
44         return a > int(LFUN_LASTACTION);
45 }
46
47 }
48
49
50 void LyXAction::newFunc(kb_action action, string const & name,
51                         unsigned int attrib)
52 {
53         lyx_func_map[name] = action;
54         func_info tmpinfo;
55         tmpinfo.name = name;
56         tmpinfo.attrib = attrib;
57         lyx_info_map[action] = tmpinfo;
58 }
59
60
61 void LyXAction::init()
62 {
63         // This function was changed to use the array below in initalization
64         // instead of calling newFunc numerous times because of compilation
65         // times. Since the array is not static we get back the memory it
66         // occupies after the init is completed. It compiles several
67         // magnitudes faster.
68
69         static bool init;
70         if (init) return;
71
72         struct ev_item {
73                 kb_action action;
74                 char const * name;
75                 unsigned int attrib;
76         };
77
78         ev_item const items[] = {
79                 { LFUN_ACUTE, "accent-acute", Noop },
80                 { LFUN_BREVE, "accent-breve", Noop },
81                 { LFUN_CARON, "accent-caron", Noop },
82                 { LFUN_CEDILLA, "accent-cedilla", Noop },
83                 { LFUN_CIRCLE, "accent-circle", Noop },
84                 { LFUN_CIRCUMFLEX, "accent-circumflex", Noop },
85                 { LFUN_DOT, "accent-dot", Noop },
86                 { LFUN_GRAVE, "accent-grave", Noop },
87                 { LFUN_HUNG_UMLAUT, "accent-hungarian-umlaut", Noop },
88                 { LFUN_MACRON, "accent-macron", Noop },
89                 { LFUN_OGONEK, "accent-ogonek", Noop },
90                 { LFUN_SPECIAL_CARON, "accent-special-caron", Noop },
91                 { LFUN_TIE, "accent-tie", Noop },
92                 { LFUN_TILDE, "accent-tilde", Noop },
93                 { LFUN_UMLAUT, "accent-umlaut", Noop },
94                 { LFUN_UNDERBAR, "accent-underbar", Noop },
95                 { LFUN_UNDERDOT, "accent-underdot", Noop },
96                 { LFUN_APPENDIX, "appendix", Noop },
97                 { LFUN_LEFTSEL, "backward-select", ReadOnly },
98                 { LFUN_BOOKMARK_GOTO, "bookmark-goto", ReadOnly },
99                 { LFUN_BOOKMARK_SAVE, "bookmark-save", ReadOnly },
100                 { LFUN_BREAKLINE, "break-line", Noop },
101                 { LFUN_BREAKPARAGRAPH, "break-paragraph", Noop },
102                 { LFUN_BREAKPARAGRAPHKEEPLAYOUT, "break-paragraph-keep-layout", Noop },
103                 { LFUN_BREAKPARAGRAPH_SKIP, "break-paragraph-skip", Noop },
104                 { LFUN_BUILDPROG, "build-program", ReadOnly },
105                 { LFUN_AUTOSAVE, "buffer-auto-save", Noop },
106                 { LFUN_BEGINNINGBUF, "buffer-begin", ReadOnly },
107                 { LFUN_BEGINNINGBUFSEL, "buffer-begin-select", ReadOnly },
108                 { LFUN_CHILDOPEN, "buffer-child-open", ReadOnly },
109                 { LFUN_RUNCHKTEX, "buffer-chktex", ReadOnly },
110                 { LFUN_CLOSEBUFFER, "buffer-close", ReadOnly },
111                 { LFUN_ENDBUF, "buffer-end", ReadOnly },
112                 { LFUN_ENDBUFSEL, "buffer-end-select", ReadOnly },
113                 { LFUN_EXPORT, "buffer-export", ReadOnly },
114                 { LFUN_IMPORT, "buffer-import", NoBuffer },
115                 { LFUN_MENUNEW, "buffer-new", NoBuffer },
116                 { LFUN_MENUNEWTMPLT,"buffer-new-template", NoBuffer },
117                 { LFUN_MENUPRINT, "buffer-print", ReadOnly },
118                 { LFUN_MENURELOAD, "buffer-reload", ReadOnly },
119                 { LFUN_SWITCHBUFFER, "buffer-switch", ReadOnly },
120                 { LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only", ReadOnly },
121                 { LFUN_UPDATE, "buffer-update", ReadOnly },
122                 { LFUN_PREVIEW, "buffer-view", ReadOnly },
123                 { LFUN_MENUWRITE, "buffer-write", ReadOnly },
124                 { LFUN_WRITEAS, "buffer-write-as", ReadOnly },
125                 { LFUN_CANCEL, "cancel", NoBuffer },
126                 { LFUN_INSET_CAPTION, "caption-insert", Noop },
127                 { LFUN_LEFT, "char-backward", ReadOnly },
128                 { LFUN_RIGHT, "char-forward", ReadOnly },
129                 { LFUN_EXEC_COMMAND, "command-execute", NoBuffer },
130                 { LFUN_PREFIX, "command-prefix", NoBuffer },
131                 { LFUN_SEQUENCE, "command-sequence", NoBuffer },
132                 { LFUN_COPY, "copy", ReadOnly },
133                 { LFUN_CUT, "cut", Noop },
134                 { LFUN_DATE_INSERT, "date-insert", Noop },
135                 { LFUN_BACKSPACE, "delete-backward", Noop },
136                 { LFUN_BACKSPACE_SKIP, "delete-backward-skip", Noop },
137                 { LFUN_DELETE, "delete-forward", Noop },
138                 { LFUN_DELETE_SKIP, "delete-forward-skip", Noop },
139                 { LFUN_DEPTH_MIN, "depth-decrement", Noop },
140                 { LFUN_DEPTH_PLUS, "depth-increment", Noop },
141                 { LFUN_LDOTS, "dots-insert", Noop },
142                 { LFUN_DOWN, "down", ReadOnly },
143                 { LFUN_DOWNSEL, "down-select", ReadOnly },
144                 { LFUN_DROP_LAYOUTS_CHOICE, "drop-layouts-choice", ReadOnly },
145                 { LFUN_END_OF_SENTENCE, "end-of-sentence-period-insert", Noop },
146                 { LFUN_ENVIRONMENT_INSERT, "environment-insert", Noop },
147                 { LFUN_GOTOERROR, "error-next", ReadOnly },
148                 { LFUN_REMOVEERRORS, "error-remove-all", ReadOnly },
149                 { LFUN_INSET_ERT, "ert-insert", Noop },
150                 { LFUN_FILE_INSERT, "file-insert", Noop },
151                 { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", Noop },
152                 { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", Noop },
153                 { LFUN_FILE_NEW, "file-new", NoBuffer },
154                 { LFUN_FILE_OPEN, "file-open", NoBuffer },
155                 { LFUN_MENUSEARCH, "find-replace", ReadOnly },
156                 { LFUN_INSET_FLOAT, "float-insert", Noop },
157                 { LFUN_INSET_WIDE_FLOAT, "float-wide-insert", Noop },
158                 { LFUN_INSET_WRAP, "wrap-insert", Noop },
159                 { LFUN_BOLD, "font-bold", Noop },
160                 { LFUN_CODE, "font-code", Noop },
161                 { LFUN_DEFAULT, "font-default", Noop },
162                 { LFUN_EMPH, "font-emph", Noop },
163                 { LFUN_FREEFONT_APPLY, "font-free-apply", Noop },
164                 { LFUN_FREEFONT_UPDATE, "font-free-update", Noop },
165                 { LFUN_NOUN, "font-noun", Noop },
166                 { LFUN_ROMAN, "font-roman", Noop },
167                 { LFUN_SANS, "font-sans", Noop },
168                 { LFUN_FRAK, "font-frak", Noop },
169                 { LFUN_ITAL, "font-ital", Noop },
170                 { LFUN_FONT_SIZE, "font-size", Noop },
171                 { LFUN_FONT_STATE, "font-state", ReadOnly },
172                 { LFUN_UNDERLINE, "font-underline", Noop },
173                 { LFUN_INSET_FOOTNOTE, "footnote-insert", Noop },
174                 { LFUN_RIGHTSEL, "forward-select", ReadOnly },
175                 { LFUN_HFILL, "hfill-insert", Noop },
176                 { LFUN_HELP_OPEN, "help-open", NoBuffer | Argument},
177                 { LFUN_HTMLURL, "html-insert", Noop },
178                 { LFUN_HYPHENATION, "hyphenation-point-insert", Noop },
179                 { LFUN_LIGATURE_BREAK, "ligature-break-insert", Noop },
180                 { LFUN_INDEX_INSERT, "index-insert", Noop },
181                 { LFUN_INDEX_PRINT, "index-print", Noop },
182                 { LFUN_KMAP_OFF, "keymap-off", ReadOnly },
183                 { LFUN_KMAP_PRIM, "keymap-primary", ReadOnly },
184                 { LFUN_KMAP_SEC, "keymap-secondary", ReadOnly },
185                 { LFUN_KMAP_TOGGLE, "keymap-toggle", ReadOnly },
186                 { LFUN_INSERT_LABEL, "label-insert", Noop },
187                 { LFUN_INSET_OPTARG, "optional-insert", Noop },
188                 { LFUN_INSERT_BIBITEM, "bibitem-insert", Noop },
189                 { LFUN_LANGUAGE, "language", Noop },
190                 { LFUN_LATEX_LOG, "latex-view-log", ReadOnly },
191                 { LFUN_LAYOUT, "layout", Noop },
192                 { LFUN_LAYOUT_CHARACTER, "layout-character", ReadOnly },
193                 { LFUN_LAYOUT_DOCUMENT, "layout-document", ReadOnly },
194                 { LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", ReadOnly },
195                 { LFUN_LAYOUT_PREAMBLE, "layout-preamble", ReadOnly },
196                 { LFUN_LAYOUT_TABULAR, "layout-tabular", Noop },
197                 { LFUN_HOME, "line-begin", ReadOnly },
198                 { LFUN_HOMESEL, "line-begin-select", ReadOnly },
199                 { LFUN_DELETE_LINE_FORWARD, "line-delete-forward", Noop },
200                 { LFUN_END, "line-end", ReadOnly },
201                 { LFUN_ENDSEL, "line-end-select", ReadOnly },
202 #if 0
203                 { LFUN_INSET_LIST, "list-insert", Noop },
204 #endif
205                 { LFUN_QUIT, "lyx-quit", NoBuffer },
206                 { LFUN_INSET_MARGINAL, "marginalnote-insert", Noop },
207                 { LFUN_MARK_OFF, "mark-off", ReadOnly },
208                 { LFUN_MARK_ON, "mark-on", ReadOnly },
209                 { LFUN_SETMARK, "mark-toggle", ReadOnly },
210                 { LFUN_MATH_DELIM, "math-delim", Noop },
211                 { LFUN_MATH_DISPLAY, "math-display", Noop },
212                 { LFUN_INSERT_MATH, "math-insert", Noop },
213                 { LFUN_SUBSCRIPT, "math-subscript", Noop },
214                 { LFUN_SUPERSCRIPT, "math-superscript", Noop },
215                 { LFUN_MATH_LIMITS, "math-limits", Noop },
216                 { LFUN_MATH_MACRO, "math-macro", Noop },
217                 { LFUN_MATH_MUTATE, "math-mutate", Noop },
218                 { LFUN_MATH_SPACE, "math-space", Noop },
219                 { LFUN_MATH_IMPORT_SELECTION, "math-import-selection", Noop },
220                 { LFUN_INSERT_MATRIX, "math-matrix", Noop },
221                 { LFUN_MATH_MODE, "math-mode", Noop },
222                 { LFUN_MATH_NONUMBER, "math-nonumber", Noop },
223                 { LFUN_MATH_NUMBER, "math-number", Noop },
224                 { LFUN_MATH_EXTERN, "math-extern", Noop },
225                 { LFUN_MATH_PANEL, "math-panel", Noop },
226                 { LFUN_MATH_SIZE, "math-size", Noop },
227                 { LFUN_MENU_OPEN_BY_NAME, "menu-open", NoBuffer },
228                 { LFUN_MENU_SEPARATOR, "menu-separator-insert", Noop },
229                 { LFUN_META_FAKE, "meta-prefix", NoBuffer },
230                 { LFUN_INSET_MINIPAGE, "minipage-insert", Noop },
231                 { LFUN_INSERT_NOTE, "note-insert", Noop },
232                 { LFUN_GOTONOTE, "note-next", ReadOnly },
233                 { LFUN_INSET_TOGGLE, "inset-toggle", ReadOnly },
234                 { LFUN_DOWN_PARAGRAPH, "paragraph-down", ReadOnly },
235                 { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select", ReadOnly },
236                 { LFUN_GOTO_PARAGRAPH, "paragraph-goto", ReadOnly },
237                 { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", Noop },
238                 { LFUN_UP_PARAGRAPH, "paragraph-up", ReadOnly },
239                 { LFUN_UP_PARAGRAPHSEL, "paragraph-up-select", ReadOnly },
240                 { LFUN_PARENTINSERT, "parent-insert", Noop },
241                 { LFUN_PASTE, "paste", Noop },
242                 { LFUN_DIALOG_PREFERENCES, "dialog-preferences", NoBuffer },
243                 { LFUN_SAVEPREFERENCES, "preferences-save", NoBuffer },
244                 { LFUN_PASTESELECTION, "primary-selection-paste", Noop },
245                 { LFUN_PROTECTEDSPACE, "protected-space-insert", Noop },
246                 { LFUN_QUOTE, "quote-insert", Noop },
247                 { LFUN_RECONFIGURE, "reconfigure", NoBuffer },
248                 { LFUN_REDO, "redo", Noop },
249                 { LFUN_REF_GOTO, "reference-goto", ReadOnly },
250                 { LFUN_REFERENCE_GOTO, "reference-next", ReadOnly },
251                 { LFUN_NEXT, "screen-down", ReadOnly },
252                 { LFUN_NEXTSEL, "screen-down-select", ReadOnly },
253                 { LFUN_SCREEN_FONT_UPDATE, "screen-font-update", NoBuffer },
254                 { LFUN_CENTER, "screen-recenter", ReadOnly },
255                 { LFUN_PRIOR, "screen-up", ReadOnly },
256                 { LFUN_PRIORSEL, "screen-up-select", ReadOnly },
257                 { LFUN_SCROLL_INSET, "inset-scroll", ReadOnly },
258                 { LFUN_SELFINSERT, "self-insert", Noop },
259                 { LFUN_CHARATCURSOR, "server-char-after", ReadOnly },
260                 { LFUN_GETFONT, "server-get-font", ReadOnly },
261                 { LFUN_GETLAYOUT, "server-get-layout", ReadOnly },
262                 { LFUN_GETNAME, "server-get-name", ReadOnly },
263                 { LFUN_GETXY, "server-get-xy", ReadOnly },
264                 { LFUN_GOTOFILEROW, "server-goto-file-row", Noop },
265                 { LFUN_NOTIFY, "server-notify", ReadOnly },
266                 { LFUN_SETXY, "server-set-xy", ReadOnly },
267                 { LFUN_SET_COLOR, "set-color", ReadOnly | NoBuffer },
268                 { LFUN_SPELLCHECK, "spellchecker", Noop },
269                 { LFUN_CELL_BACKWARD, "cell-backward", Noop },
270                 { LFUN_CELL_FORWARD, "cell-forward", Noop },
271                 { LFUN_CELL_SPLIT, "cell-split", Noop },
272                 { LFUN_TABULAR_INSERT, "tabular-insert", Noop },
273                 { LFUN_TABULAR_FEATURE, "tabular-feature", Noop },
274 #if 0
275                 { LFUN_INSET_THEOREM, "theorem-insert", Noop },
276 #endif
277                 { LFUN_THESAURUS_ENTRY, "thesaurus-entry", ReadOnly },
278                 { LFUN_TOC_INSERT, "toc-insert", Noop },
279                 { LFUN_TOCVIEW, "toc-view", ReadOnly },
280                 { LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar", ReadOnly },
281                 { LFUN_UNDO, "undo", Noop },
282                 { LFUN_UP, "up", ReadOnly },
283                 { LFUN_UPSEL, "up-select", ReadOnly },
284                 { LFUN_URL, "url-insert", Noop },
285                 { LFUN_VC_CHECKIN, "vc-check-in", ReadOnly },
286                 { LFUN_VC_CHECKOUT, "vc-check-out", ReadOnly },
287                 { LFUN_VC_HISTORY, "vc-history", ReadOnly },
288                 { LFUN_VC_REGISTER, "vc-register", ReadOnly },
289                 { LFUN_VC_REVERT, "vc-revert", ReadOnly },
290                 { LFUN_VC_UNDO, "vc-undo-last", ReadOnly },
291                 { LFUN_WORDLEFT, "word-backward", ReadOnly },
292                 { LFUN_WORDLEFTSEL, "word-backward-select", ReadOnly },
293                 { LFUN_CAPITALIZE_WORD, "word-capitalize", Noop },
294                 { LFUN_DELETE_WORD_BACKWARD, "word-delete-backward", Noop },
295                 { LFUN_DELETE_WORD_FORWARD, "word-delete-forward", Noop },
296                 { LFUN_WORDFINDBACKWARD, "word-find-backward", ReadOnly },
297                 { LFUN_WORDFINDFORWARD, "word-find-forward", ReadOnly },
298                 { LFUN_WORDRIGHT, "word-forward", ReadOnly },
299                 { LFUN_WORDRIGHTSEL, "word-forward-select", ReadOnly },
300                 { LFUN_LOWCASE_WORD, "word-lowcase", Noop },
301                 { LFUN_WORDSEL, "word-select", ReadOnly },
302                 { LFUN_UPCASE_WORD, "word-upcase", Noop },
303                 { LFUN_MESSAGE, "message", NoBuffer },
304                 { LFUN_TRANSPOSE_CHARS, "chars-transpose", Noop },
305                 { LFUN_FLOAT_LIST, "float-list", Noop },
306                 { LFUN_ESCAPE, "escape", Noop },
307                 { LFUN_HELP_ABOUTLYX, "help-aboutlyx", NoBuffer },
308                 { LFUN_HELP_TEXINFO, "help-Texinfo", NoBuffer },
309                 { LFUN_FORKS_SHOW, "show-forks", NoBuffer },
310                 { LFUN_FORKS_KILL, "kill-forks", NoBuffer },
311                 { LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", NoBuffer },
312                 { LFUN_TRACK_CHANGES, "track-changes", Noop },
313                 { LFUN_MERGE_CHANGES, "merge-changes", Noop },
314                 { LFUN_ACCEPT_CHANGE, "accept-change", Noop },
315                 { LFUN_REJECT_CHANGE, "reject-change", Noop },
316                 { LFUN_ACCEPT_ALL_CHANGES, "accept-all-changes", Noop },
317                 { LFUN_REJECT_ALL_CHANGES, "reject-all-changes", Noop },
318                 { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop },
319                 { LFUN_DIALOG_SHOW_NEXT_INSET, "dialog-show-next-inset", Noop },
320                 { LFUN_DIALOG_UPDATE, "dialog-update", Noop },
321                 { LFUN_DIALOG_HIDE, "dialog-hide", Noop },
322                 { LFUN_DIALOG_DISCONNECT_INSET, "dialog-disconnect-inset", Noop },
323                 { LFUN_INSET_APPLY, "inset-apply", Noop },
324                 { LFUN_INSET_INSERT, "inset-insert", Noop },
325                 { LFUN_INSET_MODIFY, "", Noop },
326                 { LFUN_INSET_DIALOG_UPDATE, "", Noop },
327                 { LFUN_INSET_SETTINGS, "inset-settings", ReadOnly },
328                 { LFUN_PARAGRAPH_APPLY, "paragraph-params-apply", Noop },
329                 { LFUN_PARAGRAPH_UPDATE, "", Noop },
330                 { LFUN_NOACTION, "", Noop }
331         };
332
333         for (int i = 0; items[i].action != LFUN_NOACTION; ++i) {
334                 newFunc(items[i].action, items[i].name, items[i].attrib);
335         }
336
337         init = true;
338 }
339
340
341 LyXAction::LyXAction()
342 {
343         init();
344 }
345
346
347 int LyXAction::searchActionArg(kb_action action, string const & arg) const
348 {
349         arg_map::const_iterator pit = lyx_arg_map.find(action);
350
351         if (pit == lyx_arg_map.end()) {
352                 lyxerr[Debug::ACTION] << "Action " << action
353                                       << " does not have any pseudo actions."
354                                       << endl;
355                 return LFUN_UNKNOWN_ACTION;
356         }
357
358         arg_item::const_iterator aci = pit->second.find(arg);
359
360         if (aci == pit->second.end()) {
361                 lyxerr[Debug::ACTION]
362                         << "Action " << action
363                         << "does not have any pseudoactions with arg "
364                         << arg << endl;
365                 return LFUN_UNKNOWN_ACTION;
366         }
367
368         lyxerr[Debug::ACTION] << "Pseudoaction exists["
369                               << action << '|'
370                               << arg << "] = " << aci->second << endl;
371
372         return aci->second;
373 }
374
375
376 int LyXAction::getPseudoAction(kb_action action, string const & arg)
377 {
378         int const psdaction = searchActionArg(action, arg);
379
380         if (isPseudoAction(psdaction)) return psdaction;
381
382         static unsigned int pseudo_counter = LFUN_LASTACTION;
383
384         // Create new pseudo action.
385         lyx_pseudo_map[++pseudo_counter] = FuncRequest(0, action, arg);
386
387         // First ensure that the action is in lyx_arg_map;
388         lyx_arg_map[action];
389         // get the arg_item map
390         arg_map::iterator ami = lyx_arg_map.find(action);
391         // put the new pseudo function in it
392         ami->second[arg] = pseudo_counter;
393
394         lyxerr[Debug::ACTION] << "Creating new pseudoaction "
395                               << pseudo_counter << " for [" << action
396                               << '|' << arg << "]\n";
397
398         return pseudo_counter;
399 }
400
401
402 FuncRequest LyXAction::retrieveActionArg(int pseudo) const
403 {
404         if (!isPseudoAction(pseudo))
405                 return FuncRequest(static_cast<kb_action>(pseudo));
406
407         pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo);
408
409         if (pit != lyx_pseudo_map.end()) {
410                 lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
411                                       << pit->second.action << '|'
412                                       << pit->second.argument << "]\n";
413                 return pit->second;
414         } else {
415                 lyxerr << "Lyx Error: Unrecognized pseudo-action "
416                         << pseudo << endl;
417                 return FuncRequest(LFUN_UNKNOWN_ACTION);
418         }
419 }
420
421
422 // Returns an action tag from a string.
423 int LyXAction::LookupFunc(string const & func)
424 {
425         string const func2 = trim(func);
426         if (func2.empty()) return LFUN_NOACTION;
427
428         // split action and arg
429         string actstr;
430         string const argstr = split(func2, actstr, ' ');
431         lyxerr[Debug::ACTION] << "Action: " << actstr << '\n';
432         lyxerr[Debug::ACTION] << "Arg   : " << argstr << '\n';
433
434         func_map::const_iterator fit = lyx_func_map.find(actstr);
435
436         if (!argstr.empty() && fit != lyx_func_map.end()) {
437                 // might be pseudo (or create one)
438                 return getPseudoAction(fit->second, argstr);
439         }
440
441         return fit != lyx_func_map.end() ? fit->second : LFUN_UNKNOWN_ACTION;
442 }
443
444
445 string const LyXAction::getActionName(int action) const
446 {
447         FuncRequest ev = retrieveActionArg(action);
448         if (!ev.argument.empty())
449                 ev.argument.insert(string::size_type(0), 1, ' ');
450
451         info_map::const_iterator const it = lyx_info_map.find(ev.action);
452
453         if (it != lyx_info_map.end())
454                 return it->second.name + ev.argument;
455         return string();
456 }
457
458
459 bool LyXAction::funcHasFlag(kb_action action,
460                             LyXAction::func_attrib flag) const
461 {
462         info_map::const_iterator ici = lyx_info_map.find(action);
463
464         if (ici != lyx_info_map.end()) {
465                 return ici->second.attrib & flag;
466         } else {
467                 // it really should exist, but...
468                 lyxerr << "LyXAction::funcHasFlag: "
469                         "No info about kb_action: " << action << '\n';
470                 return false;
471         }
472 }
473
474
475 LyXAction::const_func_iterator LyXAction::func_begin() const
476 {
477         return lyx_func_map.begin();
478 }
479
480
481 LyXAction::const_func_iterator LyXAction::func_end() const
482 {
483         return lyx_func_map.end();
484 }
485
486
487 ostream & operator<<(ostream & o, kb_action action)
488 {
489         return o << int(action);
490 }