]> git.lyx.org Git - lyx.git/blob - src/LyXAction.C
remove almost all traces of old table
[lyx.git] / src / LyXAction.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "LyXAction.h"
18 #include "debug.h"
19 #include "gettext.h"
20 #include "support/lstrings.h"
21 #if 1
22 // only to get access to NEW_INSETS
23 #include "lyxparagraph.h"
24 #endif
25 #if 1
26 // only to get access to NEW_EXPORT
27 #include "exporter.h"
28 #endif
29
30
31 using std::ostream;
32 using std::endl;
33
34 /*  
35      NAMING RULES FOR USER-COMMANDS
36      Here's the set of rules to apply when a new command name is introduced:
37  
38      1) Use the object.event order. That is, use `word-forward'
39         instead of `forward-word'.
40      2) Don't introduce an alias for an already named object. Same for events.
41      3) Forward movement or focus is called `forward' (not `right').
42      4) Backward movement or focus is called `backward' (not `left').
43      5) Upward movement of focus is called `up'.
44      6) Downward movement is called `down'.
45      7) The begin of an object is called `begin' (not `start').
46      8) The end of an object is called `end'.
47  
48      (May 19 1996, 12:04, RvdK)
49  */
50  
51 // These are globals. 
52 LyXAction lyxaction;
53
54 void LyXAction::newFunc(kb_action action, string const & name,
55                         string const & helpText, unsigned int attrib)
56 {
57         lyx_func_map[name] = action;
58         func_info tmpinfo;
59         tmpinfo.name = name;
60         tmpinfo.attrib = attrib;
61         tmpinfo.helpText = helpText;
62         lyx_info_map[action] = tmpinfo;
63 }
64
65
66 struct lfun_item {
67         kb_action action;
68         char const * name;
69         char const * helpText;
70         unsigned int attrib;
71 };
72
73 void LyXAction::init()
74 {
75         // This function was changed to use the array below in initalization
76         // instead of calling newFunc numerous times because of compilation
77         // times. Since the array is not static we get back the memory it
78         // occupies after the init is completed. It compiles several
79         // magnitudes faster.
80         
81         static bool init = false;
82         if (init) return;
83
84         lfun_item items[] = {
85                 { LFUN_ACUTE, "accent-acute", "", Noop },
86                 { LFUN_BREVE, "accent-breve", "", Noop },
87                 { LFUN_CARON, "accent-caron", "", Noop },
88                 { LFUN_CEDILLA, "accent-cedilla", "", Noop },
89                 { LFUN_CIRCLE, "accent-circle", "", Noop },
90                 { LFUN_CIRCUMFLEX, "accent-circumflex", "", Noop },
91                 { LFUN_DOT, "accent-dot", "", Noop },
92                 { LFUN_GRAVE, "accent-grave", "", Noop },
93                 { LFUN_HUNG_UMLAUT, "accent-hungarian-umlaut", "", Noop },
94                 { LFUN_MACRON, "accent-macron", "", Noop },
95                 { LFUN_OGONEK, "accent-ogonek", "", Noop },
96                 { LFUN_SPECIAL_CARON, "accent-special-caron", "", Noop },
97                 { LFUN_TIE, "accent-tie", "", Noop },
98                 { LFUN_TILDE, "accent-tilde", "", Noop },
99                 { LFUN_UMLAUT, "accent-umlaut", "", Noop },
100                 { LFUN_UNDERBAR, "accent-underbar", "", Noop },
101                 { LFUN_UNDERDOT, "accent-underdot", "", Noop },
102                 { LFUN_VECTOR, "accent-vector", "", Noop },
103                 { LFUN_APPENDIX, "appendix", N_("Insert appendix"), Noop },
104                 { LFUN_APROPOS, "apropos", N_("Describe command"),
105                   NoBuffer|ReadOnly },
106                 { LFUN_LEFTSEL, "backward-select",
107                   N_("Select previous char"), ReadOnly },
108                 { LFUN_BIBDB_ADD, "bibtex-database-add", "", Noop },
109                 { LFUN_BIBDB_DEL, "bibtex-database-del", "", Noop },
110                 { LFUN_INSERT_BIBTEX, "bibtex-insert", N_("Insert bibtex"),
111                   Noop },
112                 { LFUN_BIBTEX_STYLE, "bibtex-style", "", Noop },
113                 { LFUN_BREAKLINE, "break-line", "", Noop },
114                 { LFUN_BREAKPARAGRAPH, "break-paragraph", "", Noop },
115                 { LFUN_BREAKPARAGRAPHKEEPLAYOUT, "break-paragraph-keep-layout",
116                   "", Noop },
117                 { LFUN_BREAKPARAGRAPH_SKIP, "break-paragraph-skip", "", Noop },
118                 { LFUN_BUILDPROG, "build-program", 
119                   N_("Build program"), ReadOnly },
120                 { LFUN_AUTOSAVE, "buffer-auto-save", N_("Autosave"), Noop },
121                 { LFUN_BEGINNINGBUF, "buffer-begin",
122                   N_("Go to beginning of document"), ReadOnly },
123                 { LFUN_BEGINNINGBUFSEL, "buffer-begin-select",
124                   N_("Select to beginning of document"), ReadOnly },
125                 { LFUN_CHILDINSERT, "buffer-child-insert", "", Noop },
126                 { LFUN_CHILDOPEN, "buffer-child-open", "", ReadOnly },
127                 { LFUN_RUNCHKTEX, "buffer-chktex", N_("Check TeX"), ReadOnly },
128                 { LFUN_CLOSEBUFFER, "buffer-close", N_("Close"), ReadOnly },
129                 { LFUN_ENDBUF, "buffer-end",
130                   N_("Go to end of document"), ReadOnly },
131                 { LFUN_ENDBUFSEL, "buffer-end-select",
132                   N_("Select to end of document"), ReadOnly },
133                 { LFUN_EXPORT, "buffer-export", N_("Export to"), ReadOnly },
134                 { LFUN_FAX, "buffer-fax", N_("Fax"), ReadOnly },
135 #ifndef NEW_INSETS
136                 { LFUN_INSERTFOOTNOTE, "buffer-float-insert", "", Noop },
137 #endif
138                 { LFUN_IMPORT, "buffer-import",
139                   N_("Import document"), NoBuffer },
140                 { LFUN_BUFFERBULLETSSELECT, "buffer-itemize-bullets-select",
141                   "", Noop },
142                 { LFUN_BUFFER_PRINT, "buffer-print-xtl", N_("Print"),
143                   ReadOnly },
144                 { LFUN_PRINTER_PARAMS_GET, "printer-params-get",
145                   N_("Get the printer parameters"), ReadOnly },
146                 { LFUN_MENUNEW, "buffer-new", N_("New document") , NoBuffer },
147                 { LFUN_MENUNEWTMPLT,"buffer-new-template",
148                   N_("New document from template"), NoBuffer },
149                 { LFUN_MENUOPEN, "buffer-open", N_("Open"), NoBuffer },
150                 { LFUN_MENUPRINT, "buffer-print", N_("Print"), ReadOnly },
151                 { LFUN_MENURELOAD, "buffer-reload",
152                   N_("Revert to saved"), ReadOnly },
153                 { LFUN_SWITCHBUFFER, "buffer-switch", 
154                   N_("Switch to an open document"), ReadOnly },
155                 { LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only",
156                   N_("Toggle read-only"), ReadOnly },
157 #ifdef NEW_EXPORT
158                 { LFUN_UPDATE, "buffer-update", N_("Update"), ReadOnly },
159                 { LFUN_PREVIEW, "buffer-view", N_("View") , ReadOnly },
160 #else
161                 { LFUN_RUNLATEX, "buffer-typeset", N_("Update DVI"),
162                   ReadOnly },
163                 { LFUN_RUNDVIPS, "buffer-typeset-ps",
164                   N_("Update PostScript"), ReadOnly },
165                 { LFUN_PREVIEW, "buffer-view", N_("View DVI") , ReadOnly },
166                 { LFUN_PREVIEWPS, "buffer-view-ps",
167                   N_("View PostScript") , ReadOnly },
168 #endif
169                 { LFUN_MENUWRITE, "buffer-write", N_("Save"), ReadOnly },
170                 { LFUN_MENUWRITEAS, "buffer-write-as", N_("Save As"),
171                   ReadOnly },
172                 { LFUN_CANCEL, "cancel", N_("Cancel"), NoBuffer },
173                 { LFUN_LEFT, "char-backward", N_("Go one char back"),
174                   ReadOnly },
175                 { LFUN_RIGHT, "char-forward", N_("Go one char forward"),
176                   ReadOnly },
177                 { LFUN_CITATION_CREATE, "citation-insert",
178                   N_("Insert citation"), Noop },
179                 { LFUN_EXEC_COMMAND, "command-execute", "", NoBuffer },
180                 { LFUN_PREFIX, "command-prefix",
181                   N_("Execute command"), NoBuffer },
182                 { LFUN_SEQUENCE, "command-sequence", "", Noop },
183                 { LFUN_COPY, "copy", N_("Copy"), ReadOnly },
184                 { LFUN_CUT, "cut", N_("Cut"), Noop },
185                 { LFUN_BACKSPACE, "delete-backward", "", Noop },
186                 { LFUN_BACKSPACE_SKIP, "delete-backward-skip", "", Noop },
187                 { LFUN_DELETE, "delete-forward", "", Noop },
188                 { LFUN_DELETE_SKIP, "delete-forward-skip", "", Noop },
189                 { LFUN_DEPTH_MIN, "depth-decrement",
190                   N_("Decrement environment depth"), Noop },
191                 { LFUN_DEPTH_PLUS, "depth-increment",
192                   N_("Increment environment depth"), Noop },
193                 { LFUN_DEPTH, "depth-next", 
194                   N_("Change environment depth"), Noop },
195                 { LFUN_LDOTS, "dots-insert", N_("Insert ... dots"), Noop },
196                 { LFUN_DOWN, "down", N_("Go down"), ReadOnly },
197                 { LFUN_DOWNSEL, "down-select",
198                   N_("Select next line"), ReadOnly },
199                 { LFUN_DROP_LAYOUTS_CHOICE, "drop-layouts-choice",
200                   N_("Choose Paragraph Environment"), ReadOnly },
201                 { LFUN_END_OF_SENTENCE, "end-of-sentence-period-insert",
202                   N_("Insert end of sentence period"), Noop },
203                 { LFUN_GOTOERROR, "error-next", N_("Go to next error"), Noop },
204                 { LFUN_REMOVEERRORS, "error-remove-all",
205                   N_("Remove all error boxes"), ReadOnly },
206                 { LFUN_INSET_ERT, "ert-insert",
207                   N_("Insert a new ERT Inset"), Noop },
208                 { LFUN_INSET_EXTERNAL, "external-insert",
209                   N_("Insert a new external inset"), Noop },
210                 { LFUN_FIGURE, "figure-insert", N_("Insert Figure"), Noop },
211                 { LFUN_INSET_GRAPHICS, "graphics-insert",
212                   N_("Insert Graphics"), Noop },
213                 { LFUN_FILE_INSERT, "file-insert", "", Noop },
214                 { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", "", Noop },
215                 { LFUN_FILE_NEW, "file-new", "", NoBuffer },
216                 { LFUN_FILE_OPEN, "file-open", "", NoBuffer },
217                 { LFUN_MENUSEARCH, "find-replace", N_("Find & Replace"),
218                   ReadOnly },
219                 { LFUN_BOLD, "font-bold", N_("Toggle bold"), Noop },
220                 { LFUN_CODE, "font-code", N_("Toggle code style"), Noop },
221                 { LFUN_DEFAULT, "font-default", N_("Default font style"),
222                   Noop },
223                 { LFUN_EMPH, "font-emph", N_("Toggle emphasize"), Noop },
224                 { LFUN_FREE, "font-free", N_("Toggle user defined style"),
225                   Noop },
226                 { LFUN_NOUN, "font-noun", N_("Toggle noun style"), Noop },
227                 { LFUN_ROMAN, "font-roman", N_("Toggle roman font style"),
228                   Noop },
229                 { LFUN_SANS, "font-sans", N_("Toggle sans font style"), Noop },
230                 { LFUN_FONT_SIZE, "font-size", N_("Set font size"), Noop },
231                 { LFUN_FONT_STATE, "font-state", N_("Show font state"),
232                   ReadOnly },
233                 { LFUN_UNDERLINE, "font-underline",
234                   N_("Toggle font underline"), Noop },
235 #ifndef NEW_INSETS
236                 { LFUN_FOOTMELT, "footnote-insert", N_("Insert Footnote"),
237                   Noop },
238 #else
239                 { LFUN_INSET_FOOTNOTE, "footnote-insert",
240                   N_("Insert Footnote"), Noop },
241 #endif
242                 { LFUN_INSET_MARGINAL, "marginalnote-insert",
243                   N_("Insert Marginalnote"), Noop },
244                 { LFUN_RIGHTSEL, "forward-select", N_("Select next char"),
245                   ReadOnly },
246                 { LFUN_HFILL, "hfill-insert",
247                   N_("Insert horizontal fill"), Noop },
248                 { LFUN_HELP_COPYRIGHT, "help-copyright",
249                   N_("Display copyright information"), NoBuffer },
250                 { LFUN_HELP_CREDITS, "help-credits",
251                   N_("Show the list of people who helped writing LyX"), 
252                   NoBuffer},
253                 { LFUN_HELP_OPEN, "help-open", N_("Open a Help file"), 
254                   NoBuffer|Argument},
255                 { LFUN_HELP_VERSION, "help-version",
256                   N_("Show the actual LyX version"), NoBuffer},
257                 { LFUN_HTMLURL, "html-insert", "", Noop },
258                 { LFUN_HYPHENATION, "hyphenation-point-insert",
259                   N_("Insert hyphenation point"), Noop },
260                 { LFUN_INDEX_CREATE, "index-insert",
261                   N_("Insert index item"), Noop },
262                 { LFUN_INDEX_INSERT_LAST, "index-insert-last",
263                   N_("Insert last index item"), Noop },
264                 { LFUN_INDEX_PRINT, "index-print", N_("Insert index list"),
265                   Noop },
266                 { LFUN_KMAP_OFF, "keymap-off", N_("Turn off keymap"),
267                   ReadOnly },
268                 { LFUN_KMAP_PRIM, "keymap-primary",
269                   N_("Use primary keymap"), ReadOnly },
270                 { LFUN_KMAP_SEC, "keymap-secondary",
271                   N_("Use secondary keymap"), ReadOnly },
272                 { LFUN_KMAP_TOGGLE, "keymap-toggle", N_("Toggle keymap"),
273                   ReadOnly },
274                 { LFUN_INSERT_LABEL, "label-insert", N_("Insert Label"),
275                   Noop },
276                 { LFUN_LANGUAGE, "language", N_("Change language"), Noop },
277                 { LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"),
278                   ReadOnly },
279                 { LFUN_LAYOUT, "layout", "", Noop },
280                 { LFUN_LAYOUT_CHARACTER, "layout-character", "", Noop },
281                 { LFUN_LAYOUT_COPY, "layout-copy",
282                   N_("Copy paragraph environment type"), Noop },
283                 { LFUN_LAYOUT_DOCUMENT, "layout-document", "", ReadOnly },
284                 { LFUN_LAYOUTNO, "layout-number", "", Noop }, // internal only
285                 { LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", "", ReadOnly },
286                 { LFUN_LAYOUT_PAPER, "layout-paper", "", ReadOnly },
287                 { LFUN_LAYOUT_PASTE, "layout-paste",
288                   N_("Paste paragraph environment type"), Noop },
289                 { LFUN_LAYOUT_PREAMBLE, "layout-preamble", "", ReadOnly },
290                 { LFUN_LAYOUT_QUOTES, "layout-quotes", "", ReadOnly },
291                 { LFUN_LAYOUT_SAVE_DEFAULT, "layout-save-default", "",
292                   ReadOnly },
293                 { LFUN_LAYOUT_TABLE, "layout-table",
294                   N_("Open the table layout"), Noop },
295                 { LFUN_LAYOUT_TABULAR, "layout-tabular",
296                   N_("Open the tabular layout"), Noop },
297                 { LFUN_HOME, "line-begin",
298                   N_("Go to beginning of line"), ReadOnly },
299                 { LFUN_HOMESEL, "line-begin-select",
300                   N_("Select to beginning of line"), ReadOnly },
301                 { LFUN_DELETE_LINE_FORWARD, "line-delete-forward", "", Noop },
302                 { LFUN_END, "line-end", N_("Go to end of line"), ReadOnly },
303                 { LFUN_ENDSEL, "line-end-select",
304                   N_("Select to end of line"), ReadOnly },
305                 { LFUN_LOA_INSERT, "loa-insert",
306                   N_("Insert list of algorithms"), Noop },
307                 { LFUN_LOAVIEW, "loa-view",
308                   N_("View list of algorithms"), ReadOnly },
309                 { LFUN_LOF_INSERT, "lof-insert",
310                   N_("Insert list of figures"), Noop },
311                 { LFUN_LOFVIEW, "lof-view",
312                   N_("View list of figures"), ReadOnly },
313                 { LFUN_LOT_INSERT, "lot-insert",
314                   N_("Insert list of tables"), Noop },
315                 { LFUN_LOTVIEW, "lot-view",
316                   N_("View list of tables"), ReadOnly },
317                 { LFUN_QUIT, "lyx-quit", N_("Exit"), NoBuffer },
318 #ifndef NEW_INSETS
319                 { LFUN_MARGINMELT, "marginpar-insert",
320                   N_("Insert Margin note"), Noop },
321 #endif
322                 { LFUN_MARK_OFF, "mark-off", "", ReadOnly },
323                 { LFUN_MARK_ON, "mark-on", "", ReadOnly },
324                 { LFUN_SETMARK, "mark-toggle", "", ReadOnly },
325                 { LFUN_MATH_DELIM, "math-delim", "", Noop },
326                 { LFUN_MATH_DISPLAY, "math-display", "", Noop },
327                 { LFUN_GREEK, "math-greek", N_("Math Greek"), Noop },
328                 { LFUN_GREEK_TOGGLE, "math-greek-toggle", "", Noop },
329                 { LFUN_INSERT_MATH, "math-insert",
330                   N_("Insert math symbol"), Noop },
331                 { LFUN_MATH_LIMITS, "math-limits", "", Noop },
332                 { LFUN_MATH_MACRO, "math-macro", "", Noop },
333                 { LFUN_MATH_MACROARG, "math-macro-arg", "", Noop },
334                 { LFUN_INSERT_MATRIX, "math-matrix", "", Noop },
335                 { LFUN_MATH_MODE, "math-mode", N_("Math mode"), Noop },
336                 { LFUN_MATH_NONUMBER, "math-nonumber", "", Noop },
337                 { LFUN_MATH_NUMBER, "math-number", "", Noop },
338                 { LFUN_MATH_PANEL, "math-panel", "", Noop },
339                 { LFUN_MATH_SIZE, "math-size", "", Noop },
340                 { LFUN_MELT, "melt", N_("Melt"), Noop },
341                 { LFUN_MENU_OPEN_BY_NAME, "menu-open", "", NoBuffer },
342                 { LFUN_MENU_SEPARATOR, "menu-separator-insert", "", Noop },
343                 { LFUN_META_FAKE, "meta-prefix", "", NoBuffer },
344                 { LFUN_INSERT_NOTE, "note-insert", "", Noop },
345                 { LFUN_GOTONOTE, "note-next", "", ReadOnly },
346                 { LFUN_OPENSTUFF, "open-stuff", "", ReadOnly },
347                 { LFUN_DOWN_PARAGRAPH, "paragraph-down",
348                   N_("Go one paragraph down"), ReadOnly },
349                 { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select",
350                   N_("Select next paragraph"), ReadOnly },
351                 { LFUN_GOTO_PARAGRAPH, "paragraph-goto", 
352                   N_("Go to paragraph"), ReadOnly },
353                 { LFUN_UP_PARAGRAPH, "paragraph-up",
354                   N_("Go one paragraph up"), ReadOnly },
355                 { LFUN_UP_PARAGRAPHSEL, "paragraph-up-select",
356                   N_("Select previous paragraph"), ReadOnly },
357                 { LFUN_PARENTINSERT, "parent-insert", "", Noop },
358                 { LFUN_PASTE, "paste", N_("Paste") , Noop },
359                 { LFUN_DIALOG_PREFERENCES, "dialog-preferences",
360                   N_("Edit Preferences"), NoBuffer },
361                 { LFUN_SAVEPREFERENCES, "preferences-save",
362                   N_("Save Preferences"), NoBuffer },
363                 { LFUN_PASTESELECTION, "primary-selection-paste", "", Noop },
364                 { LFUN_PROTECTEDSPACE, "protected-space-insert",
365                   N_("Insert protected space"), Noop },
366                 { LFUN_QUOTE, "quote-insert", N_("Insert quote"), Noop },
367                 { LFUN_RECONFIGURE, "reconfigure",
368                   N_("Reconfigure"), NoBuffer },
369                 { LFUN_REDO, "redo", N_("Redo"), Noop },
370                 { LFUN_REF_BACK, "reference-back", "", ReadOnly },
371                 { LFUN_REF_GOTO, "reference-goto", "", ReadOnly },
372                 { LFUN_REF_INSERT, "reference-insert",
373                   N_("Insert cross reference"), ReadOnly },
374                 { LFUN_NEXT, "screen-down", "", ReadOnly },
375                 { LFUN_NEXTSEL, "screen-down-select", "", ReadOnly },
376                 { LFUN_CENTER, "screen-recenter", "", ReadOnly },
377                 { LFUN_PRIOR, "screen-up", "", ReadOnly },
378                 { LFUN_PRIORSEL, "screen-up-select", "", ReadOnly },
379                 { LFUN_SCROLL_INSET, "inset-scroll", N_("Scroll inset"),
380                   ReadOnly },
381                 { LFUN_SELFINSERT, "self-insert", "", Noop },
382                 { LFUN_CHARATCURSOR, "server-char-after", "", ReadOnly },
383                 { LFUN_GETFONT, "server-get-font", "", ReadOnly },
384                 { LFUN_GETLATEX, "server-get-latex", "", ReadOnly },
385                 { LFUN_GETLAYOUT, "server-get-layout", "", ReadOnly },
386                 { LFUN_GETNAME, "server-get-name", "", ReadOnly },
387                 { LFUN_GETTIP, "server-get-tip", "", ReadOnly },
388                 { LFUN_GETXY, "server-get-xy", "", ReadOnly },
389                 { LFUN_GOTOFILEROW, "server-goto-file-row", "", Noop },
390                 { LFUN_NOTIFY, "server-notify", "", ReadOnly },
391                 { LFUN_SETXY, "server-set-xy", "", ReadOnly },
392                 { LFUN_SPELLCHECK, "spellchecker", "", Noop },
393                 { LFUN_INSERT_MATH, "symbol-insert", "", Noop },
394                 { LFUN_SHIFT_TAB, "tab-backward", "", Noop },
395                 { LFUN_TAB, "tab-forward", "", Noop },
396                 { LFUN_TABINSERT, "tab-insert", "", Noop },
397                 { LFUN_DIALOG_TABULAR_INSERT, "dialog-tabular-insert",
398                   N_("Open Insert Tabular Dialog"), Noop },
399                 { LFUN_TABULAR_FEATURE, "tabular-feature",
400                   N_("Tabular Features"), Noop },
401                 { LFUN_INSET_TABULAR, "tabular-insert",
402                   N_("Insert a new Tabular Inset"), Noop },
403                 { LFUN_TEX, "tex-mode", N_("Toggle TeX style"), Noop },
404                 { LFUN_INSET_TEXT, "text-insert",
405                   N_("Insert a new Text Inset"), Noop },
406                 { LFUN_TOC_INSERT, "toc-insert",
407                   N_("Insert table of contents"), Noop },
408                 { LFUN_TOCVIEW, "toc-view",
409                   N_("View table of contents"), ReadOnly },
410                 { LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar",
411                   N_("Toggle cursor does/doesn't follow the scrollbar"),
412                   ReadOnly },
413                 { LFUN_ADD_TO_TOOLBAR, "toolbar-add-to", "", NoBuffer },
414                 { LFUN_PUSH_TOOLBAR, "toolbar-push", "", NoBuffer },
415                 { LFUN_UNDO, "undo", N_("Undo"), Noop },
416                 { LFUN_UP, "up", "", ReadOnly },
417                 { LFUN_UPSEL, "up-select", "", ReadOnly },
418                 { LFUN_URL, "url-insert", "", Noop },
419                 { LFUN_INSERT_URL, "", "", Noop },
420                 { LFUN_VC_CHECKIN, "vc-check-in", "", ReadOnly },
421                 { LFUN_VC_CHECKOUT, "vc-check-out", "", ReadOnly },
422                 { LFUN_VC_HISTORY, "vc-history", "", ReadOnly },
423                 { LFUN_VC_REGISTER, "vc-register",
424                   N_("Register document under version control"), ReadOnly },
425                 { LFUN_VC_REVERT, "vc-revert", "", ReadOnly },
426                 { LFUN_VC_UNDO, "vc-undo-last", "", ReadOnly },
427                 { LFUN_WORDLEFT, "word-backward", "", ReadOnly },
428                 { LFUN_WORDLEFTSEL, "word-backward-select", "", ReadOnly },
429                 { LFUN_CAPITALIZE_WORD, "word-capitalize", "", Noop },
430                 { LFUN_DELETE_WORD_BACKWARD, "word-delete-backward",
431                   "", Noop },
432                 { LFUN_DELETE_WORD_FORWARD, "word-delete-forward", "", Noop },
433                 { LFUN_WORDFINDBACKWARD, "word-find-backward", "", ReadOnly },
434                 { LFUN_WORDFINDFORWARD, "word-find-forward", "", ReadOnly },
435                 { LFUN_WORDRIGHT, "word-forward", "", ReadOnly },
436                 { LFUN_WORDRIGHTSEL, "word-forward-select", "", ReadOnly },
437                 { LFUN_LOWCASE_WORD, "word-lowcase", "", Noop },
438                 { LFUN_UPCASE_WORD, "word-upcase", "", Noop },
439                 { LFUN_DATE_INSERT, "date-insert", "", Noop },
440                 { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop },
441                 { LFUN_SET_COLOR, "set-color", "", Noop },
442                 { LFUN_INSET_MINIPAGE, "minipage-insert", "", Noop },
443                 { LFUN_INSET_FLOAT, "float-insert", "", Noop },
444                 { LFUN_INSET_LIST, "list-insert", "", Noop },
445                 { LFUN_INSET_THEOREM, "theorem-insert", "", Noop },
446                 { LFUN_INSET_CAPTION, "caption-insert", "", Noop },
447                 { LFUN_SCREEN_FONT_UPDATE, "screen-font-update", "", NoBuffer },
448                 { LFUN_NOACTION, "", "", Noop }
449         };
450
451         int i = 0;
452         while (items[i].action != LFUN_NOACTION) {
453                 newFunc(items[i].action,
454                         items[i].name,
455                         _(items[i].helpText),
456                         items[i].attrib);
457                 ++i;
458         }
459
460         init = true;
461 }
462
463
464 LyXAction::LyXAction()
465 {
466         init();
467 }
468
469
470 // Search for an existent pseudoaction, return LFUN_UNKNOWN_ACTION
471 // if it doesn't exist.
472 int LyXAction::searchActionArg(kb_action action, string const & arg) const
473 {
474         arg_map::const_iterator pit = lyx_arg_map.find(action);
475
476         if (pit == lyx_arg_map.end()) {
477                 // the action does not have any pseudoactions
478                 lyxerr[Debug::ACTION] << "Action " << action
479                                       << " does not have any pseudo actions."
480                                       << endl;
481                 return LFUN_UNKNOWN_ACTION;
482         }
483         
484         arg_item::const_iterator aci = (*pit).second.find(arg);
485
486         if (aci == (*pit).second.end()) {
487                 // the action does not have any pseudoactions with this arg
488                 lyxerr[Debug::ACTION] 
489                         << "Action " << action
490                         << "does not have any pseudoactions with arg "
491                         << arg << endl;
492                 return LFUN_UNKNOWN_ACTION;
493         }
494
495         // pseudo action exist
496         lyxerr[Debug::ACTION] << "Pseudoaction exist[" 
497                               << action << '|' 
498                               << arg << "] = " << (*aci).second << endl;
499
500         return (*aci).second;
501 }
502
503
504 // Returns a pseudo-action given an action and its argument.
505 int LyXAction::getPseudoAction(kb_action action, string const & arg) const
506 {
507         int psdaction = searchActionArg(action, arg);
508
509         if (isPseudoAction(psdaction)) return psdaction;
510
511         static unsigned int pseudo_counter = LFUN_LASTACTION;
512
513         // Create new pseudo action.
514         pseudo_func tmp_p;
515         tmp_p.action = action;
516         tmp_p.arg = arg;
517         lyx_pseudo_map[++pseudo_counter] = tmp_p;
518
519         // First ensure that the action is in lyx_arg_map;
520         lyx_arg_map[action];
521         // get the arg_item map
522         arg_map::iterator ami = lyx_arg_map.find(action);
523         // put the new pseudo function in it
524         (*ami).second[arg] = pseudo_counter;
525
526         lyxerr[Debug::ACTION] << "Creating new pseudoaction "
527                               << pseudo_counter << " for [" << action
528                               << '|' << arg << "]\n";
529         
530         return pseudo_counter;
531 }
532
533
534 // Retrieves the real action and its argument.
535 // perhaps a pair<kb_action, string> should be returned?
536 kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const
537 {
538         pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo);
539
540         if (pit != lyx_pseudo_map.end()) {
541                 lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
542                                       << (*pit).second.action << '|'
543                                       << (*pit).second.arg << '\n';
544                 arg = (*pit).second.arg;
545                 return (*pit).second.action;
546         } else {
547                 lyxerr << "Lyx Error: Unrecognized pseudo-action\n";
548                 return LFUN_UNKNOWN_ACTION;
549         }
550         
551 }
552
553
554 // Returns an action tag from a string.
555 int LyXAction::LookupFunc(string const & func) const
556 {
557         if (func.empty()) return LFUN_NOACTION;
558
559         // split action and arg
560         string actstr;
561         string argstr = split(func, actstr, ' ');
562         lyxerr[Debug::ACTION] << "Action: " << actstr << '\n';
563         lyxerr[Debug::ACTION] << "Arg   : " << argstr << '\n';
564
565         func_map::const_iterator fit = lyx_func_map.find(actstr);
566
567         if (!argstr.empty() && fit != lyx_func_map.end()) {
568                 // might be pseudo (or create one)
569                 return getPseudoAction((*fit).second, argstr);
570         }
571
572         return fit != lyx_func_map.end() ? (*fit).second : LFUN_UNKNOWN_ACTION;
573 }
574
575
576 //#ifdef WITH_WARNINGS
577 //#warning Not working as it should.
578 //#endif
579 // I have no clue what is wrong with it... (Lgb)
580 int LyXAction::getApproxFunc(string const & func) const
581         // This func should perhaps also be able to return a list of all
582         // actions that has func as a prefix. That should actually be quite
583         // easy, just let it return a vector<int> or something.
584 {
585         int action = LookupFunc(func);
586         if (action == LFUN_UNKNOWN_ACTION) {
587                 // func is not an action, but perhaps it is
588                 // part of one...check if it is prefix if one of the
589                 // actions.
590                 // Checking for prefix is not so simple, but
591                 // using a simple bounding function gives
592                 // a similar result.  [ale 19981103]
593                 func_map::const_iterator fit = 
594                         lyx_func_map.lower_bound(func);
595                 
596                 if (fit != lyx_func_map.end()) {
597                         action =  (*fit).second;
598                 }
599         } else {  // Go get the next function
600                 func_map::const_iterator fit = 
601                         lyx_func_map.upper_bound(func);
602                 
603                 if (fit != lyx_func_map.end()) {
604                         action =  (*fit).second;
605                 }
606         }
607         
608         return action;
609 }
610
611
612 string const LyXAction::getApproxFuncName(string const & func) const
613 {
614         int f = getApproxFunc(func);
615         // This will return empty string if f isn't an action.
616         return getActionName(f);
617 }
618
619
620 string const LyXAction::getActionName(int action) const
621 {
622         kb_action ac;
623         string arg;
624         if (isPseudoAction(action)) {
625                 ac = retrieveActionArg(action, arg);
626                 arg = " " +arg;
627         } 
628         else
629                 ac = static_cast<kb_action>(action);
630
631         info_map::const_iterator iit = lyx_info_map.find(ac);
632
633         if (iit != lyx_info_map.end())
634                 return (*iit).second.name + arg;
635         else 
636                 return string();
637 }
638
639
640 // Returns one line help associated with a (pseudo)action, i.e. appends
641 // the argument of the action if necessary
642 string const LyXAction::helpText(int pseudoaction) const
643 {
644         string help, arg;
645         kb_action action;
646
647         if (isPseudoAction(pseudoaction)) 
648                 action = retrieveActionArg(pseudoaction, arg);
649         else 
650                 action = static_cast<kb_action>(pseudoaction);
651
652         info_map::const_iterator ici = lyx_info_map.find(action);
653         if (ici != lyx_info_map.end()) {
654                 if (lyxerr.debugging(Debug::ACTION)) {
655                         lyxerr << "Action: " << action << '\n';
656                         lyxerr << "   name: "
657                                << (*ici).second.name << '\n';
658                         lyxerr << " attrib: "
659                                << (*ici).second.attrib << '\n';
660                         lyxerr << "   help: "
661                                << (*ici).second.helpText << '\n';
662                 }
663                 help = (*ici).second.helpText;
664                 // if the is no help text use the name of the func instead.
665                 if (help.empty()) help = (*ici).second.name;
666         }
667
668         if (help.empty()) {
669                 help = _("No description available!");
670         } else if (!arg.empty()) {
671                 help += ' ';
672                 help += arg;
673         }
674
675         return help;
676 }
677
678
679 bool LyXAction::funcHasFlag(kb_action action, 
680                             LyXAction::func_attrib flag) const 
681 {
682         info_map::const_iterator ici = lyx_info_map.find(action);
683
684         if (ici != lyx_info_map.end()) {
685                 return (*ici).second.attrib & flag;
686         } else {
687                 // it really should exist, but...
688                 lyxerr << "LyXAction::funcHasFlag: "
689                         "No info about kb_action: " << action << '\n';
690                 return false;
691         }
692
693 }
694
695
696 ostream & operator<<(ostream & o, kb_action action)
697 {
698         return o << int(action);
699 }