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