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_ENVIRONMENT_INSERT, "environment-insert", "", Noop },
172 { LFUN_GOTOERROR, "error-next",
173 N_("Go to next error"), ReadOnly },
174 { LFUN_REMOVEERRORS, "error-remove-all",
175 N_("Remove all error boxes"), ReadOnly },
176 { LFUN_INSET_ERT, "ert-insert",
177 N_("Insert a new ERT Inset"), Noop },
178 { LFUN_FILE_INSERT, "file-insert", "", Noop },
179 { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", _("Insert ASCII files as lines"), Noop },
180 { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", _("Insert ASCII file as a paragraph"), Noop },
181 { LFUN_FILE_NEW, "file-new", "", NoBuffer },
182 { LFUN_FILE_OPEN, "file-open", N_("Open a file"), NoBuffer },
183 { LFUN_MENUSEARCH, "find-replace", N_("Find & Replace"),
185 { LFUN_INSET_FLOAT, "float-insert", N_("Insert a Float"), Noop },
186 { LFUN_INSET_WIDE_FLOAT, "float-wide-insert",
187 N_("Insert a wide Float"), Noop },
188 { LFUN_INSET_WRAP, "wrap-insert", N_("Insert a Wrap"), Noop },
189 { LFUN_BOLD, "font-bold", N_("Toggle bold"), Noop },
190 { LFUN_CODE, "font-code", N_("Toggle code style"), Noop },
191 { LFUN_DEFAULT, "font-default", N_("Default font style"),
193 { LFUN_EMPH, "font-emph", N_("Toggle emphasize"), Noop },
194 { LFUN_FREEFONT_APPLY, "font-free-apply",
195 N_("Toggle user defined style"), Noop },
196 { LFUN_FREEFONT_UPDATE, "font-free-update", "", Noop },
197 { LFUN_NOUN, "font-noun", N_("Toggle noun style"), Noop },
198 { LFUN_ROMAN, "font-roman", N_("Toggle roman font style"),
200 { LFUN_SANS, "font-sans", N_("Toggle sans font style"), Noop },
201 { LFUN_FRAK, "font-frak", N_("Toggle fraktur font style"), Noop },
202 { LFUN_ITAL, "font-ital", N_("Toggle italic font style"), Noop },
203 { LFUN_FONT_SIZE, "font-size", N_("Set font size"), Noop },
204 { LFUN_FONT_STATE, "font-state", N_("Show font state"),
206 { LFUN_UNDERLINE, "font-underline",
207 N_("Toggle font underline"), Noop },
208 { LFUN_INSET_FOOTNOTE, "footnote-insert",
209 N_("Insert Footnote"), Noop },
210 { LFUN_RIGHTSEL, "forward-select", N_("Select next char"),
212 { LFUN_HFILL, "hfill-insert",
213 N_("Insert horizontal fill"), Noop },
214 { LFUN_HELP_OPEN, "help-open", N_("Open a Help file"),
216 { LFUN_HTMLURL, "html-insert", "", Noop },
217 { LFUN_HYPHENATION, "hyphenation-point-insert",
218 N_("Insert hyphenation point"), Noop },
219 { LFUN_LIGATURE_BREAK, "ligature-break-insert",
220 N_("Insert ligature break"), Noop },
221 { LFUN_INDEX_INSERT, "index-insert",
222 N_("Insert index item"), Noop },
223 { LFUN_INDEX_PRINT, "index-print", N_("Insert index list"),
225 { LFUN_KMAP_OFF, "keymap-off", N_("Turn off keymap"),
227 { LFUN_KMAP_PRIM, "keymap-primary",
228 N_("Use primary keymap"), ReadOnly },
229 { LFUN_KMAP_SEC, "keymap-secondary",
230 N_("Use secondary keymap"), ReadOnly },
231 { LFUN_KMAP_TOGGLE, "keymap-toggle", N_("Toggle keymap"),
233 { LFUN_INSERT_LABEL, "label-insert", N_("Insert Label"),
235 { LFUN_INSET_OPTARG, "optional-insert", N_("Insert Optional Argument"),
237 { LFUN_INSERT_BIBITEM, "bibitem-insert",
238 N_("Insert Bibliography Key"), Noop },
239 { LFUN_LANGUAGE, "language", N_("Change language"), Noop },
240 { LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"),
242 { LFUN_LAYOUT, "layout", "", Noop },
243 { LFUN_LAYOUT_CHARACTER, "layout-character", "", Noop },
244 { LFUN_LAYOUT_COPY, "layout-copy",
245 N_("Copy paragraph environment type"), Noop },
246 { LFUN_LAYOUT_DOCUMENT, "layout-document", "", ReadOnly },
247 { LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", "", ReadOnly },
248 { LFUN_LAYOUT_PASTE, "layout-paste",
249 N_("Paste paragraph environment type"), Noop },
250 { LFUN_LAYOUT_PREAMBLE, "layout-preamble", "", ReadOnly },
251 { LFUN_LAYOUT_TABULAR, "layout-tabular",
252 N_("Open the tabular layout"), Noop },
253 { LFUN_HOME, "line-begin",
254 N_("Go to beginning of line"), ReadOnly },
255 { LFUN_HOMESEL, "line-begin-select",
256 N_("Select to beginning of line"), ReadOnly },
257 { LFUN_DELETE_LINE_FORWARD, "line-delete-forward", "", Noop },
258 { LFUN_END, "line-end", N_("Go to end of line"), ReadOnly },
259 { LFUN_ENDSEL, "line-end-select",
260 N_("Select to end of line"), ReadOnly },
262 { LFUN_INSET_LIST, "list-insert", "", Noop },
264 { LFUN_QUIT, "lyx-quit", N_("Exit"), NoBuffer },
265 { LFUN_INSET_MARGINAL, "marginalnote-insert",
266 N_("Insert margin note"), Noop },
267 { LFUN_MARK_OFF, "mark-off", "", ReadOnly },
268 { LFUN_MARK_ON, "mark-on", "", ReadOnly },
269 { LFUN_SETMARK, "mark-toggle", "", ReadOnly },
270 { LFUN_MATH_DELIM, "math-delim", "", Noop },
271 { LFUN_MATH_DISPLAY, "math-display", "", Noop },
272 { LFUN_GREEK, "math-greek", N_("Math Greek"), Noop },
273 { LFUN_GREEK_TOGGLE, "math-greek-toggle", "", Noop },
274 { LFUN_INSERT_MATH, "math-insert",
275 N_("Insert math symbol"), Noop },
276 { LFUN_SUBSCRIPT, "math-subscript", N_("Add subscript"), Noop },
277 { LFUN_SUPERSCRIPT, "math-superscript", N_("Add superscript"), Noop },
278 { LFUN_MATH_LIMITS, "math-limits", "", Noop },
279 { LFUN_MATH_MACRO, "math-macro", "", Noop },
280 { LFUN_MATH_MUTATE, "math-mutate", "", Noop },
281 { LFUN_MATH_SPACE, "math-space", "", Noop },
282 { LFUN_MATH_IMPORT_SELECTION, "math-import-selection", "", Noop },
283 { LFUN_INSERT_MATRIX, "math-matrix", "", Noop },
284 { LFUN_MATH_MODE, "math-mode", N_("Math mode"), Noop },
285 { LFUN_MATH_NONUMBER, "math-nonumber", "", Noop },
286 { LFUN_MATH_NUMBER, "math-number", "", Noop },
287 { LFUN_MATH_EXTERN, "math-extern", "", Noop },
288 { LFUN_MATH_PANEL, "math-panel", "", Noop },
289 { LFUN_MATH_SIZE, "math-size", "", Noop },
290 { LFUN_MENU_OPEN_BY_NAME, "menu-open", "", NoBuffer },
291 { LFUN_MENU_SEPARATOR, "menu-separator-insert", "", Noop },
292 { LFUN_META_FAKE, "meta-prefix", "", NoBuffer },
293 { LFUN_INSET_MINIPAGE, "minipage-insert", "", Noop },
294 { LFUN_INSERT_NOTE, "note-insert", "", Noop },
295 { LFUN_GOTONOTE, "note-next", "", ReadOnly },
296 { LFUN_INSET_TOGGLE, "inset-toggle",
297 N_("toggle inset"), ReadOnly },
298 { LFUN_DOWN_PARAGRAPH, "paragraph-down",
299 N_("Go one paragraph down"), ReadOnly },
300 { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select",
301 N_("Select next paragraph"), ReadOnly },
302 { LFUN_GOTO_PARAGRAPH, "paragraph-goto",
303 N_("Go to paragraph"), ReadOnly },
304 { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop },
305 { LFUN_UP_PARAGRAPH, "paragraph-up",
306 N_("Go one paragraph up"), ReadOnly },
307 { LFUN_UP_PARAGRAPHSEL, "paragraph-up-select",
308 N_("Select previous paragraph"), ReadOnly },
309 { LFUN_PARENTINSERT, "parent-insert", "", Noop },
310 { LFUN_PASTE, "paste", N_("Paste") , Noop },
311 { LFUN_DIALOG_PREFERENCES, "dialog-preferences",
312 N_("Edit Preferences"), NoBuffer },
313 { LFUN_SAVEPREFERENCES, "preferences-save",
314 N_("Save Preferences"), NoBuffer },
315 { LFUN_PASTESELECTION, "primary-selection-paste", "", Noop },
316 { LFUN_PROTECTEDSPACE, "protected-space-insert",
317 N_("Insert protected space"), Noop },
318 { LFUN_QUOTE, "quote-insert", N_("Insert quote"), Noop },
319 { LFUN_RECONFIGURE, "reconfigure",
320 N_("Reconfigure"), NoBuffer },
321 { LFUN_REDO, "redo", N_("Redo"), Noop },
322 { LFUN_REF_GOTO, "reference-goto", "", ReadOnly },
323 { LFUN_REFERENCE_GOTO, "reference-next", "", ReadOnly },
324 { LFUN_NEXT, "screen-down", "", ReadOnly },
325 { LFUN_NEXTSEL, "screen-down-select", "", ReadOnly },
326 { LFUN_SCREEN_FONT_UPDATE, "screen-font-update",
328 { LFUN_CENTER, "screen-recenter", "", ReadOnly },
329 { LFUN_PRIOR, "screen-up", "", ReadOnly },
330 { LFUN_PRIORSEL, "screen-up-select", "", ReadOnly },
331 { LFUN_SCROLL_INSET, "inset-scroll", N_("Scroll inset"),
333 { LFUN_SELFINSERT, "self-insert", "", Noop },
334 { LFUN_CHARATCURSOR, "server-char-after", "", ReadOnly },
335 { LFUN_GETFONT, "server-get-font", "", ReadOnly },
336 { LFUN_GETLAYOUT, "server-get-layout", "", ReadOnly },
337 { LFUN_GETNAME, "server-get-name", "", ReadOnly },
338 { LFUN_GETTIP, "server-get-tip", "", ReadOnly },
339 { LFUN_GETXY, "server-get-xy", "", ReadOnly },
340 { LFUN_GOTOFILEROW, "server-goto-file-row", "", Noop },
341 { LFUN_NOTIFY, "server-notify", "", ReadOnly },
342 { LFUN_SETXY, "server-set-xy", "", ReadOnly },
343 { LFUN_SET_COLOR, "set-color", "", ReadOnly|NoBuffer },
344 { LFUN_SPELLCHECK, "spellchecker", "", Noop },
345 { LFUN_SHIFT_TAB, "tab-backward", "", Noop },
346 { LFUN_TAB, "tab-forward", "", Noop },
347 { LFUN_TABINSERT, "tab-insert", "", Noop },
348 { LFUN_TABULAR_INSERT, "tabular-insert", N_("Insert Table"), Noop },
349 { LFUN_TABULAR_FEATURE, "tabular-feature",
350 N_("Tabular Features"), Noop },
352 { LFUN_INSET_THEOREM, "theorem-insert", "", Noop },
354 { LFUN_THESAURUS_ENTRY, "thesaurus-entry", N_("Open thesaurus"), ReadOnly },
355 { LFUN_TOC_INSERT, "toc-insert",
356 N_("Insert table of contents"), Noop },
357 { LFUN_TOCVIEW, "toc-view",
358 N_("View table of contents"), ReadOnly },
359 { LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar",
360 N_("Toggle cursor does/doesn't follow the scrollbar"),
362 { LFUN_UNDO, "undo", N_("Undo"), Noop },
363 { LFUN_UP, "up", "", ReadOnly },
364 { LFUN_UPSEL, "up-select", "", ReadOnly },
365 { LFUN_URL, "url-insert", "", Noop },
366 { LFUN_VC_CHECKIN, "vc-check-in", "", ReadOnly },
367 { LFUN_VC_CHECKOUT, "vc-check-out", "", ReadOnly },
368 { LFUN_VC_HISTORY, "vc-history", "", ReadOnly },
369 { LFUN_VC_REGISTER, "vc-register",
370 N_("Register document under version control"), ReadOnly },
371 { LFUN_VC_REVERT, "vc-revert", "", ReadOnly },
372 { LFUN_VC_UNDO, "vc-undo-last", "", ReadOnly },
373 { LFUN_WORDLEFT, "word-backward", "", ReadOnly },
374 { LFUN_WORDLEFTSEL, "word-backward-select", "", ReadOnly },
375 { LFUN_CAPITALIZE_WORD, "word-capitalize", "", Noop },
376 { LFUN_DELETE_WORD_BACKWARD, "word-delete-backward",
378 { LFUN_DELETE_WORD_FORWARD, "word-delete-forward", "", Noop },
379 { LFUN_WORDFINDBACKWARD, "word-find-backward", "", ReadOnly },
380 { LFUN_WORDFINDFORWARD, "word-find-forward", "", ReadOnly },
381 { LFUN_WORDRIGHT, "word-forward", "", ReadOnly },
382 { LFUN_WORDRIGHTSEL, "word-forward-select", "", ReadOnly },
383 { LFUN_LOWCASE_WORD, "word-lowcase", "", Noop },
384 { LFUN_WORDSEL, "word-select", "", ReadOnly },
385 { LFUN_UPCASE_WORD, "word-upcase", "", Noop },
386 { LFUN_MESSAGE, "message",
387 N_("Show message in minibuffer"), NoBuffer },
388 { LFUN_TRANSPOSE_CHARS, "chars-transpose", "", Noop },
389 { LFUN_FLOAT_LIST, "float-list", "Insert a float list", Noop },
390 { LFUN_ESCAPE, "escape", "", Noop },
391 { LFUN_HELP_ABOUTLYX, "help-aboutlyx",
392 N_("Display information about LyX"), NoBuffer },
393 { LFUN_HELP_TEXINFO, "help-Texinfo",
394 N_("Display information about the TeX installation"), NoBuffer },
395 { LFUN_FORKS_SHOW, "show-forks",
396 N_("Show the processes forked by LyX"), NoBuffer },
397 { LFUN_FORKS_KILL, "kill-forks",
398 N_("Kill the forked process with this PID"), NoBuffer },
399 { LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", "", NoBuffer },
400 { LFUN_TRACK_CHANGES, "track-changes", N_("Begin tracking changes"), Noop },
401 { LFUN_MERGE_CHANGES, "merge-changes", N_("Merge changes"), Noop },
402 { LFUN_ACCEPT_CHANGE, "accept-change", N_("Accept selected change"), Noop },
403 { LFUN_REJECT_CHANGE, "reject-change", N_("Reject selected change"), Noop },
404 { LFUN_ACCEPT_ALL_CHANGES, "accept-all-changes", N_("Accept all changes"), Noop },
405 { LFUN_REJECT_ALL_CHANGES, "reject-all-changes", N_("Reject all changes"), Noop },
407 { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset",
408 N_("Show the inset's dialog"), Noop },
409 { LFUN_DIALOG_SHOW_NEXT_INSET, "dialog-show-next-inset",
410 N_("Show the inset's dialog"), Noop },
411 { LFUN_DIALOG_UPDATE, "dialog-update",
412 N_("Update the dialog"), Noop },
413 { LFUN_DIALOG_HIDE, "dialog-hide",
414 N_("Hide the dialog"), Noop },
415 { LFUN_DIALOG_DISCONNECT_INSET, "dialog-disconnect-inset",
416 N_("Disconnect the dialog from the current inset"), Noop },
417 { LFUN_INSET_APPLY, "inset-apply", "", Noop },
418 { LFUN_INSET_MODIFY, "", "internal only", Noop },
419 { LFUN_INSET_DIALOG_UPDATE, "", "internal only", Noop },
420 { LFUN_PARAGRAPH_APPLY, "paragraph-params-apply",
421 N_("Apply these params to the paragraph"), Noop },
422 { LFUN_PARAGRAPH_UPDATE, "", "internal only", Noop },
423 { LFUN_NOACTION, "", "", Noop }
426 for (int i = 0; items[i].action != LFUN_NOACTION; ++i) {
427 newFunc(items[i].action, items[i].name,
428 _(items[i].helpText), items[i].attrib);
435 LyXAction::LyXAction()
441 int LyXAction::searchActionArg(kb_action action, string const & arg) const
443 arg_map::const_iterator pit = lyx_arg_map.find(action);
445 if (pit == lyx_arg_map.end()) {
446 lyxerr[Debug::ACTION] << "Action " << action
447 << " does not have any pseudo actions."
449 return LFUN_UNKNOWN_ACTION;
452 arg_item::const_iterator aci = pit->second.find(arg);
454 if (aci == pit->second.end()) {
455 lyxerr[Debug::ACTION]
456 << "Action " << action
457 << "does not have any pseudoactions with arg "
459 return LFUN_UNKNOWN_ACTION;
462 lyxerr[Debug::ACTION] << "Pseudoaction exists["
464 << arg << "] = " << aci->second << endl;
470 int LyXAction::getPseudoAction(kb_action action, string const & arg)
472 int const psdaction = searchActionArg(action, arg);
474 if (isPseudoAction(psdaction)) return psdaction;
476 static unsigned int pseudo_counter = LFUN_LASTACTION;
478 // Create new pseudo action.
479 lyx_pseudo_map[++pseudo_counter] = FuncRequest(0, action, arg);
481 // First ensure that the action is in lyx_arg_map;
483 // get the arg_item map
484 arg_map::iterator ami = lyx_arg_map.find(action);
485 // put the new pseudo function in it
486 ami->second[arg] = pseudo_counter;
488 lyxerr[Debug::ACTION] << "Creating new pseudoaction "
489 << pseudo_counter << " for [" << action
490 << '|' << arg << "]\n";
492 return pseudo_counter;
496 FuncRequest LyXAction::retrieveActionArg(int pseudo) const
498 if (!isPseudoAction(pseudo))
499 return FuncRequest(static_cast<kb_action>(pseudo));
501 pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo);
503 if (pit != lyx_pseudo_map.end()) {
504 lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
505 << pit->second.action << '|'
506 << pit->second.argument << "]\n";
509 lyxerr << "Lyx Error: Unrecognized pseudo-action "
511 return FuncRequest(LFUN_UNKNOWN_ACTION);
516 // Returns an action tag from a string.
517 int LyXAction::LookupFunc(string const & func)
519 string const func2 = trim(func);
520 if (func2.empty()) return LFUN_NOACTION;
522 // split action and arg
524 string const argstr = split(func2, actstr, ' ');
525 lyxerr[Debug::ACTION] << "Action: " << actstr << '\n';
526 lyxerr[Debug::ACTION] << "Arg : " << argstr << '\n';
528 func_map::const_iterator fit = lyx_func_map.find(actstr);
530 if (!argstr.empty() && fit != lyx_func_map.end()) {
531 // might be pseudo (or create one)
532 return getPseudoAction(fit->second, argstr);
535 return fit != lyx_func_map.end() ? fit->second : LFUN_UNKNOWN_ACTION;
539 string const LyXAction::getActionName(int action) const
541 FuncRequest ev = retrieveActionArg(action);
542 if (!ev.argument.empty())
543 ev.argument.insert(string::size_type(0), 1, ' ');
545 info_map::const_iterator const it = lyx_info_map.find(ev.action);
547 if (it != lyx_info_map.end())
548 return it->second.name + ev.argument;
553 string const LyXAction::helpText(int pseudoaction) const
555 FuncRequest ev = retrieveActionArg(pseudoaction);
559 info_map::const_iterator ici = lyx_info_map.find(ev.action);
560 if (ici != lyx_info_map.end()) {
561 if (lyxerr.debugging(Debug::ACTION)) {
562 lyxerr << "Action: " << ev.action << '\n';
564 << ici->second.name << '\n';
565 lyxerr << " attrib: "
566 << ici->second.attrib << '\n';
568 << ici->second.helpText << '\n';
570 help = ici->second.helpText;
571 // if the is no help text use the name of the func instead.
572 if (help.empty()) help = ici->second.name;
576 help = _("No description available!");
577 } else if (!ev.argument.empty()) {
586 bool LyXAction::funcHasFlag(kb_action action,
587 LyXAction::func_attrib flag) const
589 info_map::const_iterator ici = lyx_info_map.find(action);
591 if (ici != lyx_info_map.end()) {
592 return ici->second.attrib & flag;
594 // it really should exist, but...
595 lyxerr << "LyXAction::funcHasFlag: "
596 "No info about kb_action: " << action << '\n';
602 LyXAction::const_func_iterator LyXAction::func_begin() const
604 return lyx_func_map.begin();
608 LyXAction::const_func_iterator LyXAction::func_end() const
610 return lyx_func_map.end();
614 ostream & operator<<(ostream & o, kb_action action)
616 return o << int(action);