3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
13 #include "support/lstrings.h"
21 NAMING RULES FOR USER-COMMANDS
22 Here's the set of rules to apply when a new command name is introduced:
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'.
34 (May 19 1996, 12:04, RvdK)
41 /// return true if the given action is a pseudo-action
42 inline bool isPseudoAction(int a)
44 return a > int(LFUN_LASTACTION);
50 void LyXAction::newFunc(kb_action action, string const & name,
51 string const & helpText, unsigned int attrib)
53 lyx_func_map[name] = action;
56 tmpinfo.attrib = attrib;
57 tmpinfo.helpText = helpText;
58 lyx_info_map[action] = tmpinfo;
62 void LyXAction::init()
64 // This function was changed to use the array below in initalization
65 // instead of calling newFunc numerous times because of compilation
66 // times. Since the array is not static we get back the memory it
67 // occupies after the init is completed. It compiles several
76 char const * helpText;
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", N_("Insert appendix"), Noop },
99 { LFUN_APROPOS, "apropos", N_("Describe command"),
101 { LFUN_LEFTSEL, "backward-select",
102 N_("Select previous char"), ReadOnly },
103 { LFUN_BOOKMARK_GOTO, "bookmark-goto", "", ReadOnly },
104 { LFUN_BOOKMARK_SAVE, "bookmark-save", "", ReadOnly },
105 { LFUN_BREAKLINE, "break-line", "", Noop },
106 { LFUN_BREAKPARAGRAPH, "break-paragraph", "", Noop },
107 { LFUN_BREAKPARAGRAPHKEEPLAYOUT, "break-paragraph-keep-layout",
109 { LFUN_BREAKPARAGRAPH_SKIP, "break-paragraph-skip", "", Noop },
110 { LFUN_BUILDPROG, "build-program",
111 N_("Build program"), ReadOnly },
112 { LFUN_AUTOSAVE, "buffer-auto-save", N_("Autosave"), Noop },
113 { LFUN_BEGINNINGBUF, "buffer-begin",
114 N_("Go to beginning of document"), ReadOnly },
115 { LFUN_BEGINNINGBUFSEL, "buffer-begin-select",
116 N_("Select to beginning of document"), ReadOnly },
117 { LFUN_CHILDOPEN, "buffer-child-open", "", ReadOnly },
118 { LFUN_RUNCHKTEX, "buffer-chktex", N_("Check TeX"), ReadOnly },
119 { LFUN_CLOSEBUFFER, "buffer-close", N_("Close"), ReadOnly },
120 { LFUN_ENDBUF, "buffer-end",
121 N_("Go to end of document"), ReadOnly },
122 { LFUN_ENDBUFSEL, "buffer-end-select",
123 N_("Select to end of document"), ReadOnly },
124 { LFUN_EXPORT, "buffer-export", N_("Export to"), ReadOnly },
125 { LFUN_IMPORT, "buffer-import",
126 N_("Import document"), NoBuffer },
127 { LFUN_MENUNEW, "buffer-new", N_("New document") , NoBuffer },
128 { LFUN_MENUNEWTMPLT,"buffer-new-template",
129 N_("New document from template"), NoBuffer },
130 { LFUN_MENUPRINT, "buffer-print", N_("Print"), ReadOnly },
131 { LFUN_MENURELOAD, "buffer-reload",
132 N_("Revert to saved"), ReadOnly },
133 { LFUN_SWITCHBUFFER, "buffer-switch",
134 N_("Switch to an open document"), ReadOnly },
135 { LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only",
136 N_("Toggle read-only"), ReadOnly },
137 { LFUN_UPDATE, "buffer-update", N_("Update"), ReadOnly },
138 { LFUN_PREVIEW, "buffer-view", N_("View") , ReadOnly },
139 { LFUN_MENUWRITE, "buffer-write", N_("Save"), ReadOnly },
140 { LFUN_WRITEAS, "buffer-write-as", N_("Save As"),
142 { LFUN_CANCEL, "cancel", N_("Cancel"), NoBuffer },
143 { LFUN_INSET_CAPTION, "caption-insert", "", Noop },
144 { LFUN_LEFT, "char-backward", N_("Go one char back"),
146 { LFUN_RIGHT, "char-forward", N_("Go one char forward"),
148 { LFUN_EXEC_COMMAND, "command-execute", "", NoBuffer },
149 { LFUN_PREFIX, "command-prefix",
150 N_("Execute command"), NoBuffer },
151 { LFUN_SEQUENCE, "command-sequence", "", NoBuffer },
152 { LFUN_COPY, "copy", N_("Copy"), ReadOnly },
153 { LFUN_CUT, "cut", N_("Cut"), Noop },
154 { LFUN_DATE_INSERT, "date-insert", "", Noop },
155 { LFUN_BACKSPACE, "delete-backward", "", Noop },
156 { LFUN_BACKSPACE_SKIP, "delete-backward-skip", "", Noop },
157 { LFUN_DELETE, "delete-forward", "", Noop },
158 { LFUN_DELETE_SKIP, "delete-forward-skip", "", Noop },
159 { LFUN_DEPTH_MIN, "depth-decrement",
160 N_("Decrement environment depth"), Noop },
161 { LFUN_DEPTH_PLUS, "depth-increment",
162 N_("Increment environment depth"), Noop },
163 { LFUN_LDOTS, "dots-insert", N_("Insert ... dots"), Noop },
164 { LFUN_DOWN, "down", N_("Go down"), ReadOnly },
165 { LFUN_DOWNSEL, "down-select",
166 N_("Select next line"), ReadOnly },
167 { LFUN_DROP_LAYOUTS_CHOICE, "drop-layouts-choice",
168 N_("Choose Paragraph Environment"), ReadOnly },
169 { LFUN_END_OF_SENTENCE, "end-of-sentence-period-insert",
170 N_("Insert end of sentence period"), Noop },
171 { LFUN_GOTOERROR, "error-next",
172 N_("Go to next error"), ReadOnly },
173 { LFUN_REMOVEERRORS, "error-remove-all",
174 N_("Remove all error boxes"), ReadOnly },
175 { LFUN_INSET_ERT, "ert-insert",
176 N_("Insert a new ERT Inset"), Noop },
177 { LFUN_FILE_INSERT, "file-insert", "", Noop },
178 { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", _("Insert ASCII files as lines"), Noop },
179 { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", _("Insert ASCII file as a paragraph"), Noop },
180 { LFUN_FILE_NEW, "file-new", "", NoBuffer },
181 { LFUN_FILE_OPEN, "file-open", N_("Open a file"), NoBuffer },
182 { LFUN_MENUSEARCH, "find-replace", N_("Find & Replace"),
184 { LFUN_INSET_FLOAT, "float-insert", N_("Insert a Float"), Noop },
185 { LFUN_INSET_WIDE_FLOAT, "float-wide-insert",
186 N_("Insert a wide Float"), Noop },
187 { LFUN_INSET_WRAP, "wrap-insert", N_("Insert a Wrap"), Noop },
188 { LFUN_BOLD, "font-bold", N_("Toggle bold"), Noop },
189 { LFUN_CODE, "font-code", N_("Toggle code style"), Noop },
190 { LFUN_DEFAULT, "font-default", N_("Default font style"),
192 { LFUN_EMPH, "font-emph", N_("Toggle emphasize"), Noop },
193 { LFUN_FREE, "font-free", N_("Toggle user defined style"),
195 { LFUN_NOUN, "font-noun", N_("Toggle noun style"), Noop },
196 { LFUN_ROMAN, "font-roman", N_("Toggle roman font style"),
198 { LFUN_SANS, "font-sans", N_("Toggle sans font style"), Noop },
199 { LFUN_FRAK, "font-frak", N_("Toggle fraktur font style"), Noop },
200 { LFUN_ITAL, "font-ital", N_("Toggle italic font style"), Noop },
201 { LFUN_FONT_SIZE, "font-size", N_("Set font size"), Noop },
202 { LFUN_FONT_STATE, "font-state", N_("Show font state"),
204 { LFUN_UNDERLINE, "font-underline",
205 N_("Toggle font underline"), Noop },
206 { LFUN_INSET_FOOTNOTE, "footnote-insert",
207 N_("Insert Footnote"), Noop },
208 { LFUN_RIGHTSEL, "forward-select", N_("Select next char"),
210 { LFUN_HFILL, "hfill-insert",
211 N_("Insert horizontal fill"), Noop },
212 { LFUN_HELP_OPEN, "help-open", N_("Open a Help file"),
214 { LFUN_HTMLURL, "html-insert", "", Noop },
215 { LFUN_HYPHENATION, "hyphenation-point-insert",
216 N_("Insert hyphenation point"), Noop },
217 { LFUN_LIGATURE_BREAK, "ligature-break-insert",
218 N_("Insert ligature break"), Noop },
219 { LFUN_INDEX_INSERT, "index-insert",
220 N_("Insert index item"), Noop },
221 { LFUN_INDEX_PRINT, "index-print", N_("Insert index list"),
223 { LFUN_KMAP_OFF, "keymap-off", N_("Turn off keymap"),
225 { LFUN_KMAP_PRIM, "keymap-primary",
226 N_("Use primary keymap"), ReadOnly },
227 { LFUN_KMAP_SEC, "keymap-secondary",
228 N_("Use secondary keymap"), ReadOnly },
229 { LFUN_KMAP_TOGGLE, "keymap-toggle", N_("Toggle keymap"),
231 { LFUN_INSERT_LABEL, "label-insert", N_("Insert Label"),
233 { LFUN_INSET_OPTARG, "optional-insert", N_("Insert Optional Argument"),
235 { LFUN_INSERT_BIBITEM, "bibitem-insert",
236 N_("Insert Bibliography Key"), Noop },
237 { LFUN_LANGUAGE, "language", N_("Change language"), Noop },
238 { LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"),
240 { LFUN_LAYOUT, "layout", "", Noop },
241 { LFUN_LAYOUT_CHARACTER, "layout-character", "", Noop },
242 { LFUN_LAYOUT_COPY, "layout-copy",
243 N_("Copy paragraph environment type"), Noop },
244 { LFUN_LAYOUT_DOCUMENT, "layout-document", "", ReadOnly },
245 { LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", "", ReadOnly },
246 { LFUN_LAYOUT_PASTE, "layout-paste",
247 N_("Paste paragraph environment type"), Noop },
248 { LFUN_LAYOUT_PREAMBLE, "layout-preamble", "", ReadOnly },
249 { LFUN_LAYOUT_TABULAR, "layout-tabular",
250 N_("Open the tabular layout"), Noop },
251 { LFUN_HOME, "line-begin",
252 N_("Go to beginning of line"), ReadOnly },
253 { LFUN_HOMESEL, "line-begin-select",
254 N_("Select to beginning of line"), ReadOnly },
255 { LFUN_DELETE_LINE_FORWARD, "line-delete-forward", "", Noop },
256 { LFUN_END, "line-end", N_("Go to end of line"), ReadOnly },
257 { LFUN_ENDSEL, "line-end-select",
258 N_("Select to end of line"), ReadOnly },
260 { LFUN_INSET_LIST, "list-insert", "", Noop },
262 { LFUN_QUIT, "lyx-quit", N_("Exit"), NoBuffer },
263 { LFUN_INSET_MARGINAL, "marginalnote-insert",
264 N_("Insert margin note"), Noop },
265 { LFUN_MARK_OFF, "mark-off", "", ReadOnly },
266 { LFUN_MARK_ON, "mark-on", "", ReadOnly },
267 { LFUN_SETMARK, "mark-toggle", "", ReadOnly },
268 { LFUN_MATH_DELIM, "math-delim", "", Noop },
269 { LFUN_MATH_DISPLAY, "math-display", "", Noop },
270 { LFUN_GREEK, "math-greek", N_("Math Greek"), Noop },
271 { LFUN_GREEK_TOGGLE, "math-greek-toggle", "", Noop },
272 { LFUN_INSERT_MATH, "math-insert",
273 N_("Insert math symbol"), Noop },
274 { LFUN_SUBSCRIPT, "math-subscript", N_("Add subscript"), Noop },
275 { LFUN_SUPERSCRIPT, "math-superscript", N_("Add superscript"), Noop },
276 { LFUN_MATH_LIMITS, "math-limits", "", Noop },
277 { LFUN_MATH_MACRO, "math-macro", "", Noop },
278 { LFUN_MATH_MUTATE, "math-mutate", "", Noop },
279 { LFUN_MATH_SPACE, "math-space", "", Noop },
280 { LFUN_MATH_IMPORT_SELECTION, "math-import-selection", "", Noop },
281 { LFUN_INSERT_MATRIX, "math-matrix", "", Noop },
282 { LFUN_MATH_MODE, "math-mode", N_("Math mode"), Noop },
283 { LFUN_MATH_NONUMBER, "math-nonumber", "", Noop },
284 { LFUN_MATH_NUMBER, "math-number", "", Noop },
285 { LFUN_MATH_EXTERN, "math-extern", "", Noop },
286 { LFUN_MATH_PANEL, "math-panel", "", Noop },
287 { LFUN_MATH_SIZE, "math-size", "", Noop },
288 { LFUN_MENU_OPEN_BY_NAME, "menu-open", "", NoBuffer },
289 { LFUN_MENU_SEPARATOR, "menu-separator-insert", "", Noop },
290 { LFUN_META_FAKE, "meta-prefix", "", NoBuffer },
291 { LFUN_INSET_MINIPAGE, "minipage-insert", "", Noop },
292 { LFUN_INSERT_NOTE, "note-insert", "", Noop },
293 { LFUN_GOTONOTE, "note-next", "", ReadOnly },
294 { LFUN_INSET_TOGGLE, "inset-toggle",
295 N_("toggle inset"), ReadOnly },
296 { LFUN_DOWN_PARAGRAPH, "paragraph-down",
297 N_("Go one paragraph down"), ReadOnly },
298 { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select",
299 N_("Select next paragraph"), ReadOnly },
300 { LFUN_GOTO_PARAGRAPH, "paragraph-goto",
301 N_("Go to paragraph"), ReadOnly },
302 { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop },
303 { LFUN_UP_PARAGRAPH, "paragraph-up",
304 N_("Go one paragraph up"), ReadOnly },
305 { LFUN_UP_PARAGRAPHSEL, "paragraph-up-select",
306 N_("Select previous paragraph"), ReadOnly },
307 { LFUN_PARENTINSERT, "parent-insert", "", Noop },
308 { LFUN_PASTE, "paste", N_("Paste") , Noop },
309 { LFUN_DIALOG_PREFERENCES, "dialog-preferences",
310 N_("Edit Preferences"), NoBuffer },
311 { LFUN_SAVEPREFERENCES, "preferences-save",
312 N_("Save Preferences"), NoBuffer },
313 { LFUN_PASTESELECTION, "primary-selection-paste", "", Noop },
314 { LFUN_PROTECTEDSPACE, "protected-space-insert",
315 N_("Insert protected space"), Noop },
316 { LFUN_QUOTE, "quote-insert", N_("Insert quote"), Noop },
317 { LFUN_RECONFIGURE, "reconfigure",
318 N_("Reconfigure"), NoBuffer },
319 { LFUN_REDO, "redo", N_("Redo"), Noop },
320 { LFUN_REF_GOTO, "reference-goto", "", ReadOnly },
321 { LFUN_REFERENCE_GOTO, "reference-next", "", ReadOnly },
322 { LFUN_NEXT, "screen-down", "", ReadOnly },
323 { LFUN_NEXTSEL, "screen-down-select", "", ReadOnly },
324 { LFUN_SCREEN_FONT_UPDATE, "screen-font-update",
326 { LFUN_CENTER, "screen-recenter", "", ReadOnly },
327 { LFUN_PRIOR, "screen-up", "", ReadOnly },
328 { LFUN_PRIORSEL, "screen-up-select", "", ReadOnly },
329 { LFUN_SCROLL_INSET, "inset-scroll", N_("Scroll inset"),
331 { LFUN_SELFINSERT, "self-insert", "", Noop },
332 { LFUN_CHARATCURSOR, "server-char-after", "", ReadOnly },
333 { LFUN_GETFONT, "server-get-font", "", ReadOnly },
334 { LFUN_GETLAYOUT, "server-get-layout", "", ReadOnly },
335 { LFUN_GETNAME, "server-get-name", "", ReadOnly },
336 { LFUN_GETTIP, "server-get-tip", "", ReadOnly },
337 { LFUN_GETXY, "server-get-xy", "", ReadOnly },
338 { LFUN_GOTOFILEROW, "server-goto-file-row", "", Noop },
339 { LFUN_NOTIFY, "server-notify", "", ReadOnly },
340 { LFUN_SETXY, "server-set-xy", "", ReadOnly },
341 { LFUN_SET_COLOR, "set-color", "", ReadOnly|NoBuffer },
342 { LFUN_SPELLCHECK, "spellchecker", "", Noop },
343 { LFUN_SHIFT_TAB, "tab-backward", "", Noop },
344 { LFUN_TAB, "tab-forward", "", Noop },
345 { LFUN_TABINSERT, "tab-insert", "", Noop },
346 { LFUN_TABULAR_INSERT, "tabular-insert", N_("Insert Table"), Noop },
347 { LFUN_TABULAR_FEATURE, "tabular-feature",
348 N_("Tabular Features"), Noop },
350 { LFUN_INSET_THEOREM, "theorem-insert", "", Noop },
352 { LFUN_THESAURUS_ENTRY, "thesaurus-entry", N_("Open thesaurus"), ReadOnly },
353 { LFUN_TOC_INSERT, "toc-insert",
354 N_("Insert table of contents"), Noop },
355 { LFUN_TOCVIEW, "toc-view",
356 N_("View table of contents"), ReadOnly },
357 { LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar",
358 N_("Toggle cursor does/doesn't follow the scrollbar"),
360 { LFUN_UNDO, "undo", N_("Undo"), Noop },
361 { LFUN_UP, "up", "", ReadOnly },
362 { LFUN_UPSEL, "up-select", "", ReadOnly },
363 { LFUN_URL, "url-insert", "", Noop },
364 { LFUN_VC_CHECKIN, "vc-check-in", "", ReadOnly },
365 { LFUN_VC_CHECKOUT, "vc-check-out", "", ReadOnly },
366 { LFUN_VC_HISTORY, "vc-history", "", ReadOnly },
367 { LFUN_VC_REGISTER, "vc-register",
368 N_("Register document under version control"), ReadOnly },
369 { LFUN_VC_REVERT, "vc-revert", "", ReadOnly },
370 { LFUN_VC_UNDO, "vc-undo-last", "", ReadOnly },
371 { LFUN_WORDLEFT, "word-backward", "", ReadOnly },
372 { LFUN_WORDLEFTSEL, "word-backward-select", "", ReadOnly },
373 { LFUN_CAPITALIZE_WORD, "word-capitalize", "", Noop },
374 { LFUN_DELETE_WORD_BACKWARD, "word-delete-backward",
376 { LFUN_DELETE_WORD_FORWARD, "word-delete-forward", "", Noop },
377 { LFUN_WORDFINDBACKWARD, "word-find-backward", "", ReadOnly },
378 { LFUN_WORDFINDFORWARD, "word-find-forward", "", ReadOnly },
379 { LFUN_WORDRIGHT, "word-forward", "", ReadOnly },
380 { LFUN_WORDRIGHTSEL, "word-forward-select", "", ReadOnly },
381 { LFUN_LOWCASE_WORD, "word-lowcase", "", Noop },
382 { LFUN_WORDSEL, "word-select", "", ReadOnly },
383 { LFUN_UPCASE_WORD, "word-upcase", "", Noop },
384 { LFUN_MESSAGE, "message",
385 N_("Show message in minibuffer"), NoBuffer },
386 { LFUN_TRANSPOSE_CHARS, "chars-transpose", "", Noop },
387 { LFUN_FLOAT_LIST, "float-list", "Insert a float list", Noop },
388 { LFUN_ESCAPE, "escape", "", Noop },
389 { LFUN_HELP_ABOUTLYX, "help-aboutlyx",
390 N_("Display information about LyX"), NoBuffer },
391 { LFUN_HELP_TEXINFO, "help-Texinfo",
392 N_("Display information about the TeX installation"), NoBuffer },
393 { LFUN_FORKS_SHOW, "show-forks",
394 N_("Show the processes forked by LyX"), NoBuffer },
395 { LFUN_FORKS_KILL, "kill-forks",
396 N_("Kill the forked process with this PID"), NoBuffer },
397 { LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", "", NoBuffer },
398 { LFUN_TRACK_CHANGES, "track-changes", N_("Begin tracking changes"), Noop },
399 { LFUN_MERGE_CHANGES, "merge-changes", N_("Merge changes"), Noop },
400 { LFUN_ACCEPT_CHANGE, "accept-change", N_("Accept selected change"), Noop },
401 { LFUN_REJECT_CHANGE, "reject-change", N_("Reject selected change"), Noop },
402 { LFUN_ACCEPT_ALL_CHANGES, "accept-all-changes", N_("Accept all changes"), Noop },
403 { LFUN_REJECT_ALL_CHANGES, "reject-all-changes", N_("Reject all changes"), Noop },
405 { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset",
406 N_("Show the inset's dialog"), Noop },
407 { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-next-inset",
408 N_("Show the inset's dialog"), Noop },
409 { LFUN_DIALOG_UPDATE, "dialog-update",
410 N_("Update the dialog"), Noop },
411 { LFUN_DIALOG_HIDE, "dialog-hide",
412 N_("Hide the dialog"), Noop },
413 { LFUN_DIALOG_DISCONNECT_INSET, "dialog-disconnect-inset",
414 N_("Disconnect the dialog from the current inset"), Noop },
415 { LFUN_INSET_APPLY, "inset-apply", "", Noop },
416 { LFUN_INSET_MODIFY, "", "internal only", Noop },
417 { LFUN_INSET_DIALOG_UPDATE, "", "internal only", Noop },
418 { LFUN_NOACTION, "", "", Noop }
421 for (int i = 0; items[i].action != LFUN_NOACTION; ++i) {
422 newFunc(items[i].action, items[i].name,
423 _(items[i].helpText), items[i].attrib);
430 LyXAction::LyXAction()
436 int LyXAction::searchActionArg(kb_action action, string const & arg) const
438 arg_map::const_iterator pit = lyx_arg_map.find(action);
440 if (pit == lyx_arg_map.end()) {
441 lyxerr[Debug::ACTION] << "Action " << action
442 << " does not have any pseudo actions."
444 return LFUN_UNKNOWN_ACTION;
447 arg_item::const_iterator aci = pit->second.find(arg);
449 if (aci == pit->second.end()) {
450 lyxerr[Debug::ACTION]
451 << "Action " << action
452 << "does not have any pseudoactions with arg "
454 return LFUN_UNKNOWN_ACTION;
457 lyxerr[Debug::ACTION] << "Pseudoaction exists["
459 << arg << "] = " << aci->second << endl;
465 int LyXAction::getPseudoAction(kb_action action, string const & arg)
467 int const psdaction = searchActionArg(action, arg);
469 if (isPseudoAction(psdaction)) return psdaction;
471 static unsigned int pseudo_counter = LFUN_LASTACTION;
473 // Create new pseudo action.
474 lyx_pseudo_map[++pseudo_counter] = FuncRequest(0, action, arg);
476 // First ensure that the action is in lyx_arg_map;
478 // get the arg_item map
479 arg_map::iterator ami = lyx_arg_map.find(action);
480 // put the new pseudo function in it
481 ami->second[arg] = pseudo_counter;
483 lyxerr[Debug::ACTION] << "Creating new pseudoaction "
484 << pseudo_counter << " for [" << action
485 << '|' << arg << "]\n";
487 return pseudo_counter;
491 FuncRequest LyXAction::retrieveActionArg(int pseudo) const
493 if (!isPseudoAction(pseudo))
494 return FuncRequest(static_cast<kb_action>(pseudo));
496 pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo);
498 if (pit != lyx_pseudo_map.end()) {
499 lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
500 << pit->second.action << '|'
501 << pit->second.argument << "]\n";
504 lyxerr << "Lyx Error: Unrecognized pseudo-action "
506 return FuncRequest(LFUN_UNKNOWN_ACTION);
511 // Returns an action tag from a string.
512 int LyXAction::LookupFunc(string const & func)
514 string const func2 = trim(func);
515 if (func2.empty()) return LFUN_NOACTION;
517 // split action and arg
519 string const argstr = split(func2, actstr, ' ');
520 lyxerr[Debug::ACTION] << "Action: " << actstr << '\n';
521 lyxerr[Debug::ACTION] << "Arg : " << argstr << '\n';
523 func_map::const_iterator fit = lyx_func_map.find(actstr);
525 if (!argstr.empty() && fit != lyx_func_map.end()) {
526 // might be pseudo (or create one)
527 return getPseudoAction(fit->second, argstr);
530 return fit != lyx_func_map.end() ? fit->second : LFUN_UNKNOWN_ACTION;
534 string const LyXAction::getActionName(int action) const
536 FuncRequest ev = retrieveActionArg(action);
537 if (!ev.argument.empty())
538 ev.argument.insert(string::size_type(0), 1, ' ');
540 info_map::const_iterator const it = lyx_info_map.find(ev.action);
542 if (it != lyx_info_map.end())
543 return it->second.name + ev.argument;
548 string const LyXAction::helpText(int pseudoaction) const
550 FuncRequest ev = retrieveActionArg(pseudoaction);
554 info_map::const_iterator ici = lyx_info_map.find(ev.action);
555 if (ici != lyx_info_map.end()) {
556 if (lyxerr.debugging(Debug::ACTION)) {
557 lyxerr << "Action: " << ev.action << '\n';
559 << ici->second.name << '\n';
560 lyxerr << " attrib: "
561 << ici->second.attrib << '\n';
563 << ici->second.helpText << '\n';
565 help = ici->second.helpText;
566 // if the is no help text use the name of the func instead.
567 if (help.empty()) help = ici->second.name;
571 help = _("No description available!");
572 } else if (!ev.argument.empty()) {
581 bool LyXAction::funcHasFlag(kb_action action,
582 LyXAction::func_attrib flag) const
584 info_map::const_iterator ici = lyx_info_map.find(action);
586 if (ici != lyx_info_map.end()) {
587 return ici->second.attrib & flag;
589 // it really should exist, but...
590 lyxerr << "LyXAction::funcHasFlag: "
591 "No info about kb_action: " << action << '\n';
597 LyXAction::const_func_iterator LyXAction::func_begin() const
599 return lyx_func_map.begin();
603 LyXAction::const_func_iterator LyXAction::func_end() const
605 return lyx_func_map.end();
609 ostream & operator<<(ostream & o, kb_action action)
611 return o << int(action);