]> git.lyx.org Git - lyx.git/blobdiff - src/LyXAction.C
remove almost all traces of old table
[lyx.git] / src / LyXAction.C
index 55b26fde65aa04396561959640073f7c08689d00..5347503888a9402b89b2539ca99cab168070fe9e 100644 (file)
@@ -1,20 +1,15 @@
 /* This file is part of
- * ====================================================== 
+ * ======================================================
  * 
  *           LyX, The Document Processor
  *      
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-1999 The LyX Team.
+ *           Copyright 1995-2000 The LyX Team.
  *
  * ====================================================== */
 
 #include <config.h>
 
-#include <cstdlib>
-#include <cstdio>
-#include <cctype>
-#include <cstring>
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 #include "debug.h"
 #include "gettext.h"
 #include "support/lstrings.h"
+#if 1
+// only to get access to NEW_INSETS
+#include "lyxparagraph.h"
+#endif
+#if 1
+// only to get access to NEW_EXPORT
+#include "exporter.h"
+#endif
+
+
+using std::ostream;
+using std::endl;
 
- /*  
+/*  
      NAMING RULES FOR USER-COMMANDS
      Here's the set of rules to apply when a new command name is introduced:
  
      (May 19 1996, 12:04, RvdK)
  */
  
-
 // These are globals. 
 LyXAction lyxaction;
 
+void LyXAction::newFunc(kb_action action, string const & name,
+                       string const & helpText, unsigned int attrib)
+{
+       lyx_func_map[name] = action;
+       func_info tmpinfo;
+       tmpinfo.name = name;
+       tmpinfo.attrib = attrib;
+       tmpinfo.helpText = helpText;
+       lyx_info_map[action] = tmpinfo;
+}
 
-/* This table is sorted alphabetically [asierra 14Jan96] */
-/* This table MUST be sorted alphabetically, incidentally! */ 
-kb_func_table const lyx_func_table[] = {
-       { "accent-acute",                         LFUN_ACUTE },
-       { "accent-breve",                         LFUN_BREVE },
-       { "accent-caron",                         LFUN_CARON },
-       { "accent-cedilla",                       LFUN_CEDILLA },
-       { "accent-circle",                        LFUN_CIRCLE },
-       { "accent-circumflex",                    LFUN_CIRCUMFLEX },
-       { "accent-dot",                           LFUN_DOT },
-       { "accent-grave",                         LFUN_GRAVE },
-       { "accent-hungarian-umlaut",              LFUN_HUNG_UMLAUT },
-       { "accent-macron",                        LFUN_MACRON },
-       { "accent-ogonek",                        LFUN_OGONEK },
-       { "accent-special-caron",                 LFUN_SPECIAL_CARON },
-       { "accent-tie",                           LFUN_TIE },
-       { "accent-tilde",                         LFUN_TILDE },
-       { "accent-umlaut",                        LFUN_UMLAUT },
-       { "accent-underbar",                      LFUN_UNDERBAR },
-       { "accent-underdot",                      LFUN_UNDERDOT },
-       { "accent-vector",                        LFUN_VECTOR }, 
-       { "appendix",                         LFUN_APPENDIX }, 
-       { "apropos",                              LFUN_APROPOS },
-       { "backward-select",                      LFUN_LEFTSEL },
-       { "bibtex-database-add",                  LFUN_BIBDB_ADD },
-       { "bibtex-database-del",                  LFUN_BIBDB_DEL },
-       { "bibtex-insert",                        LFUN_INSERT_BIBTEX },
-       { "bibtex-style",                         LFUN_BIBTEX_STYLE },
-       { "break-line",                           LFUN_BREAKLINE },
-       { "break-paragraph",                      LFUN_BREAKPARAGRAPH },
-       { "break-paragraph-keep-layout",          LFUN_BREAKPARAGRAPHKEEPLAYOUT },
-       { "break-paragraph-skip",                 LFUN_BREAKPARAGRAPH_SKIP },
-       { "buffer-auto-save",                     LFUN_AUTOSAVE },
-       { "buffer-begin",                         LFUN_BEGINNINGBUF },
-       { "buffer-begin-select",                  LFUN_BEGINNINGBUFSEL },
-       { "buffer-child-insert",                  LFUN_CHILDINSERT },  // ale970521
-       { "buffer-child-open",                    LFUN_CHILDOPEN },  // ale970528
-       { "buffer-chktex",                        LFUN_RUNCHKTEX }, // Asger 971030
-       { "buffer-close",                         LFUN_CLOSEBUFFER },         
-       { "buffer-end",                           LFUN_ENDBUF },
-       { "buffer-end-select",                    LFUN_ENDBUFSEL },
-       { "buffer-export",                        LFUN_EXPORT },
-       { "buffer-fax",                           LFUN_FAX },
-       { "buffer-float-insert",                  LFUN_INSERTFOOTNOTE },
-       { "buffer-import",                        LFUN_IMPORT },
-       { "buffer-itemize-bullets-select",        LFUN_BUFFERBULLETSSELECT },
-       { "buffer-new",                           LFUN_MENUNEW },     
-       { "buffer-new-template",                  LFUN_MENUNEWTMPLT },
-       { "buffer-open",                          LFUN_MENUOPEN },    
-       { "buffer-previous",                      LFUN_PREVBUFFER },  
-       { "buffer-print",                         LFUN_MENUPRINT },   
-       { "buffer-reload",                        LFUN_MENURELOAD },   
-       { "buffer-toggle-read-only",              LFUN_READ_ONLY_TOGGLE },
-       { "buffer-typeset",                       LFUN_RUNLATEX },        // Alejandro's proposal
-       { "buffer-typeset-ps",                    LFUN_RUNDVIPS },
-       { "buffer-view",                          LFUN_PREVIEW },
-       { "buffer-view-ps",                       LFUN_PREVIEWPS },
-       { "buffer-write",                         LFUN_MENUWRITE },   
-       { "buffer-write-as",                      LFUN_MENUWRITEAS }, 
-        { "build-program",                        LFUN_BUILDPROG },
-       { "cancel",                               LFUN_CANCEL },
-       { "char-backward",                        LFUN_LEFT },
-       { "char-forward",                         LFUN_RIGHT },
-        { "citation-insert",                     LFUN_INSERT_CITATION },
-       { "command-execute",                      LFUN_EXEC_COMMAND },
-       { "command-prefix",                       LFUN_PREFIX },
-       { "copy",                                 LFUN_COPY },
-       { "cut",                                  LFUN_CUT },
-       { "delete-backward",                      LFUN_BACKSPACE },
-       { "delete-backward-skip",                 LFUN_BACKSPACE_SKIP },
-       { "delete-forward",                       LFUN_DELETE },
-       { "delete-forward-skip",                  LFUN_DELETE_SKIP },
-       { "depth-decrement",                      LFUN_DEPTH_MIN },
-       { "depth-increment",                      LFUN_DEPTH_PLUS },  
-       { "depth-next",                           LFUN_DEPTH },
-       { "dots-insert",                          LFUN_LDOTS },
-       { "down",                                 LFUN_DOWN },                 
-       { "down-select",                          LFUN_DOWNSEL },
-       { "drop-layouts-choice",                  LFUN_DROP_LAYOUTS_CHOICE },
-       { "end-of-sentence-period-insert",        LFUN_END_OF_SENTENCE },
-       { "error-next",                           LFUN_GOTOERROR },   
-       { "error-remove-all",                     LFUN_REMOVEERRORS },
-       { "figure-insert",                        LFUN_FIGURE },
-       { "file-insert",                          LFUN_FILE_INSERT },
-       { "file-insert-ascii",                    LFUN_FILE_INSERT_ASCII },
-       { "file-new",                             LFUN_FILE_NEW },
-       { "file-open",                            LFUN_FILE_OPEN },
-       { "find-replace",                         LFUN_MENUSEARCH },  
-       { "font-bold",                            LFUN_BOLD },        
-       { "font-code",                            LFUN_CODE },        
-       { "font-default",                         LFUN_DEFAULT },
-       { "font-emph",                            LFUN_EMPH },
-       { "font-free",                            LFUN_FREE },
-       { "font-noun",                            LFUN_NOUN },
-       { "font-roman",                           LFUN_ROMAN },
-       { "font-sans",                            LFUN_SANS },
-       { "font-size",                            LFUN_FONT_SIZE },
-       { "font-state",                           LFUN_FONT_STATE }, 
-       { "font-underline",                       LFUN_UNDERLINE },   
-       { "footnote-insert",                      LFUN_FOOTMELT },    
-       { "forward-select",                       LFUN_RIGHTSEL },
-       { "hfill-insert",                         LFUN_HFILL },
-       { "html-insert",                          LFUN_HTMLURL },
-       { "hyphenation-point-insert",             LFUN_HYPHENATION },
-       { "index-insert",                         LFUN_INDEX_INSERT },
-       { "index-insert-last",                    LFUN_INDEX_INSERT_LAST },
-       { "index-print",                          LFUN_INDEX_PRINT },
-#if 0
-       { "inset-latex-insert",                   LFUN_INSERT_INSET_LATEX },
-#endif
-       { "keymap-off",                           LFUN_KMAP_OFF },
-       { "keymap-primary",                       LFUN_KMAP_PRIM },
-       { "keymap-secondary",                     LFUN_KMAP_SEC },
-       { "keymap-toggle",                        LFUN_KMAP_TOGGLE },
-       { "label-insert",                         LFUN_INSERT_LABEL },
-       { "latex-view-log",                       LFUN_LATEX_LOG },
-       { "layout",                               LFUN_LAYOUT },
-       { "layout-character",                     LFUN_LAYOUT_CHARACTER },
-       { "layout-copy",                          LFUN_LAYOUT_COPY },
-       { "layout-document",                      LFUN_LAYOUT_DOCUMENT },
-       //{ "layout-number",                      LFUN_LAYOUTNO }, // internal only
-       { "layout-paper",                         LFUN_LAYOUT_PAPER },
-       { "layout-paragraph",                     LFUN_LAYOUT_PARAGRAPH },
-       { "layout-paste",                         LFUN_LAYOUT_PASTE },
-       { "layout-preamble",                      LFUN_LAYOUT_PREAMBLE },
-       { "layout-quotes",                        LFUN_LAYOUT_QUOTES },
-       { "layout-save-default",                  LFUN_LAYOUT_SAVE_DEFAULT },
-       { "layout-table",                         LFUN_LAYOUT_TABLE },
-       { "line-begin",                           LFUN_HOME },        
-       { "line-begin-select",                    LFUN_HOMESEL },     
-       { "line-delete-forward",                  LFUN_DELETE_LINE_FORWARD },  
-       { "line-end",                             LFUN_END },         
-       { "line-end-select",                      LFUN_ENDSEL },
-       { "loa-insert",                           LFUN_LOA_INSERT },
-       { "lof-insert",                           LFUN_LOF_INSERT },
-       { "lot-insert",                           LFUN_LOT_INSERT },
-       { "lyx-quit",                             LFUN_QUIT },
-       { "marginpar-insert",                     LFUN_MARGINMELT },  
-       { "mark-off",                             LFUN_MARK_OFF },    
-       { "mark-on",                              LFUN_MARK_ON },     
-       { "mark-toggle",                          LFUN_SETMARK }, 
-       { "math-delim",                           LFUN_MATH_DELIM },
-       { "math-display",                         LFUN_MATH_DISPLAY }, // Alejandro's proposal
-       { "math-greek",                           LFUN_GREEK },   
-       { "math-greek-toggle",                    LFUN_GREEK_TOGGLE },   
-       { "math-insert",                          LFUN_INSERT_MATH },   
-       { "math-limits",                          LFUN_MATH_LIMITS },
-        { "math-macro",                           LFUN_MATH_MACRO },
-        { "math-macro-arg",                       LFUN_MATH_MACROARG },
-       { "math-matrix",                          LFUN_INSERT_MATRIX }, 
-       { "math-mode",                            LFUN_MATH_MODE },
-       { "math-nonumber",                        LFUN_MATH_NONUMBER },
-       { "math-number",                          LFUN_MATH_NUMBER }, 
-       { "math-size",                            LFUN_MATH_SIZE }, 
-       { "melt",                                 LFUN_MELT },            // Needs better name. What about "float-disolve" or "float-extract" (Lgb)
-       { "menu-open",                            LFUN_MENU_OPEN_BY_NAME },
-       { "menu-separator-insert",                LFUN_MENU_SEPARATOR },
-       { "meta-prefix",                          LFUN_META_FAKE },
-       { "note-insert",                          LFUN_INSERT_NOTE },
-       { "note-next",                            LFUN_GOTONOTE },
-       { "open-stuff",                           LFUN_OPENSTUFF },       // Needs better name.
-       { "paragraph-down",                       LFUN_DOWN_PARAGRAPH },
-       { "paragraph-down-select",                LFUN_DOWN_PARAGRAPHSEL },
-       { "paragraph-up",                         LFUN_UP_PARAGRAPH },
-       { "paragraph-up-select",                  LFUN_UP_PARAGRAPHSEL },
-        { "parent-insert",                       LFUN_PARENTINSERT },
-       { "paste",                                LFUN_PASTE },
-       { "primary-selection-paste",              LFUN_PASTESELECTION },
-       { "protected-space-insert",               LFUN_PROTECTEDSPACE },
-       { "quote-insert",                         LFUN_QUOTE },
-       { "reconfigure",                          LFUN_RECONFIGURE },
-       { "redo",                                 LFUN_REDO },
-        { "reference-back",                       LFUN_REFBACK },
-        { "reference-goto",                       LFUN_REFGOTO }, 
-       { "reference-insert",                     LFUN_INSERT_REF },
-       { "reference-toggle",                     LFUN_REFTOGGLE },
-       { "screen-down",                          LFUN_NEXT },        
-       { "screen-down-select",                   LFUN_NEXTSEL },     
-       { "screen-recenter",                      LFUN_CENTER },
-       { "screen-up",                            LFUN_PRIOR },       
-       { "screen-up-select",                     LFUN_PRIORSEL },    
-       { "self-insert",                          LFUN_SELFINSERT },
-       { "server-char-after",                    LFUN_CHARATCURSOR },
-       { "server-get-font",                      LFUN_GETFONT },
-       { "server-get-latex",                     LFUN_GETLATEX },
-       { "server-get-layout",                    LFUN_GETLAYOUT },
-       { "server-get-name",                      LFUN_GETNAME },
-       { "server-get-tip",                       LFUN_GETTIP },
-       { "server-get-xy",                        LFUN_GETXY },
-       { "server-goto-file-row",                 LFUN_GOTOFILEROW },
-       { "server-notify",                        LFUN_NOTIFY },
-       { "server-set-xy",                        LFUN_SETXY },
-       { "spellchecker",                         LFUN_SPELLCHECK },  
-       { "symbol-insert",                        LFUN_INSERT_MATH },
-       { "tab-forward",                          LFUN_TAB },
-       { "tab-insert",                           LFUN_TABINSERT },
-       { "table-insert",                         LFUN_TABLE },
-       { "tex-mode",                             LFUN_TEX },
-       { "toc-insert",                           LFUN_TOC_INSERT },
-       { "toc-view",                             LFUN_TOCVIEW },
-       { "toggle-cursor-follows-scrollbar",      LFUN_TOGGLECURSORFOLLOW },
-       { "toolbar-add-to",                       LFUN_ADD_TO_TOOLBAR },
-       { "toolbar-push",                         LFUN_PUSH_TOOLBAR },
-       { "undo",                                 LFUN_UNDO },
-       { "up",                                   LFUN_UP },          
-       { "up-select",                            LFUN_UPSEL },
-       { "url-insert",                           LFUN_URL },
-       { "vc-check-in",                          LFUN_VC_CHECKIN }, 
-       { "vc-check-out",                         LFUN_VC_CHECKOUT }, 
-       { "vc-history",                           LFUN_VC_HISTORY }, 
-       { "vc-register",                          LFUN_VC_REGISTER }, 
-       { "vc-revert",                            LFUN_VC_REVERT }, 
-       { "vc-undo-last",                         LFUN_VC_UNDO }, 
-       { "word-backward",                        LFUN_WORDLEFT },
-       { "word-backward-select",                 LFUN_WORDLEFTSEL },
-       { "word-capitalize",                      LFUN_CAPITALIZE_WORD },
-       { "word-delete-backward",                 LFUN_DELETE_WORD_BACKWARD },
-       { "word-delete-forward",                  LFUN_DELETE_WORD_FORWARD }, 
-       { "word-find-backward",                   LFUN_WORDFINDBACKWARD },
-       { "word-find-forward",                    LFUN_WORDFINDFORWARD },
-       { "word-forward",                         LFUN_WORDRIGHT },
-       { "word-forward-select",                  LFUN_WORDRIGHTSEL },
-       { "word-lowcase",                         LFUN_LOWCASE_WORD },
-       { "word-upcase",                          LFUN_UPCASE_WORD }
-};
-
-
-/* 
-   This table contains the actions that modify a buffer and therefore
-   are not allowed for RO files. Do you think we have too much tables?
-   Each single integer in this table replaces 5 lines of code in lyxfunc
-   that include at least 3 function calls (several integers in the 
-   code segment).
-   The table could in the near future be expanded adding a second integer 
-   field with attributes using these tags:
-
-enum FUNC_ATTRIB {
-    LFAT_NONE= 0,     // Nothing special
-    LFAT_ISRO= 1,     // Is readonly (does not modify a buffer)
-    LFAT_ISIA= 2,     // Is interactive (requires a GUI)
-    LFAT_REQARG= 4,   // Requires argument
-    LFAT_ISMO= 8,     // Only math mode
-    LFAT_ETCETC
-};
 
-struct {
-    kb_action action;
-    unsigned  attrib; 
+struct lfun_item {
+       kb_action action;
+       char const * name;
+       char const * helpText;
+       unsigned int attrib;
 };
 
-Alejandro-970604
-*/
-
-kb_action func_attrib_table[] = {
-       LFUN_ACUTE,
-       LFUN_AUTOSAVE,
-       LFUN_BACKSPACE,
-       LFUN_BACKSPACE_SKIP,
-       LFUN_BIBDB_ADD,
-       LFUN_BIBDB_DEL,
-       LFUN_BIBTEX_STYLE,
-       LFUN_BOLD,
-       LFUN_BREAKLINE,
-       LFUN_BREAKPARAGRAPH,
-       LFUN_BREAKPARAGRAPHKEEPLAYOUT,
-       LFUN_BREAKPARAGRAPH_SKIP,
-       LFUN_BREVE,
-       LFUN_BUFFERBULLETSSELECT,
-       LFUN_CAPITALIZE_WORD,
-       LFUN_CARON,
-       LFUN_CEDILLA,
-       LFUN_CHILDINSERT,
-       LFUN_CIRCLE,
-       LFUN_CIRCUMFLEX,
-       LFUN_CODE,
-       LFUN_CUT,
-       LFUN_DEFAULT,
-       LFUN_DELETE,
-       LFUN_DELETE_LINE_FORWARD,
-       LFUN_DELETE_SKIP,
-       LFUN_DELETE_WORD_BACKWARD,
-       LFUN_DELETE_WORD_FORWARD,
-       LFUN_DEPTH,
-       LFUN_DEPTH_MIN,
-       LFUN_DEPTH_PLUS,
-       LFUN_DOT,
-       LFUN_EMPH,
-       LFUN_END_OF_SENTENCE,
-       LFUN_FIGURE,
-       LFUN_FILE_INSERT,
-       LFUN_FILE_INSERT_ASCII,
-       LFUN_FONT_SIZE,
-       LFUN_FOOTMELT,
-       LFUN_FREE,
-       LFUN_GRAVE,
-       LFUN_HFILL,
-       LFUN_HTMLURL,
-       LFUN_HUNG_UMLAUT,
-       LFUN_HYPHENATION,
-       LFUN_INDEX_INSERT,
-       LFUN_INDEX_INSERT_LAST,
-       LFUN_INDEX_PRINT,
-       LFUN_INSERTFOOTNOTE,
-       LFUN_INSERT_BIBTEX,
-       LFUN_INSERT_CITATION,
-#if 0
-       LFUN_INSERT_INSET_LATEX,
+void LyXAction::init()
+{
+       // This function was changed to use the array below in initalization
+       // instead of calling newFunc numerous times because of compilation
+       // times. Since the array is not static we get back the memory it
+       // occupies after the init is completed. It compiles several
+       // magnitudes faster.
+       
+       static bool init = false;
+       if (init) return;
+
+       lfun_item items[] = {
+               { LFUN_ACUTE, "accent-acute", "", Noop },
+               { LFUN_BREVE, "accent-breve", "", Noop },
+               { LFUN_CARON, "accent-caron", "", Noop },
+               { LFUN_CEDILLA, "accent-cedilla", "", Noop },
+               { LFUN_CIRCLE, "accent-circle", "", Noop },
+               { LFUN_CIRCUMFLEX, "accent-circumflex", "", Noop },
+               { LFUN_DOT, "accent-dot", "", Noop },
+               { LFUN_GRAVE, "accent-grave", "", Noop },
+               { LFUN_HUNG_UMLAUT, "accent-hungarian-umlaut", "", Noop },
+               { LFUN_MACRON, "accent-macron", "", Noop },
+               { LFUN_OGONEK, "accent-ogonek", "", Noop },
+               { LFUN_SPECIAL_CARON, "accent-special-caron", "", Noop },
+               { LFUN_TIE, "accent-tie", "", Noop },
+               { LFUN_TILDE, "accent-tilde", "", Noop },
+               { LFUN_UMLAUT, "accent-umlaut", "", Noop },
+               { LFUN_UNDERBAR, "accent-underbar", "", Noop },
+               { LFUN_UNDERDOT, "accent-underdot", "", Noop },
+               { LFUN_VECTOR, "accent-vector", "", Noop },
+               { LFUN_APPENDIX, "appendix", N_("Insert appendix"), Noop },
+               { LFUN_APROPOS, "apropos", N_("Describe command"),
+                 NoBuffer|ReadOnly },
+               { LFUN_LEFTSEL, "backward-select",
+                 N_("Select previous char"), ReadOnly },
+               { LFUN_BIBDB_ADD, "bibtex-database-add", "", Noop },
+               { LFUN_BIBDB_DEL, "bibtex-database-del", "", Noop },
+               { LFUN_INSERT_BIBTEX, "bibtex-insert", N_("Insert bibtex"),
+                 Noop },
+               { LFUN_BIBTEX_STYLE, "bibtex-style", "", Noop },
+               { LFUN_BREAKLINE, "break-line", "", Noop },
+               { LFUN_BREAKPARAGRAPH, "break-paragraph", "", Noop },
+               { LFUN_BREAKPARAGRAPHKEEPLAYOUT, "break-paragraph-keep-layout",
+                 "", Noop },
+               { LFUN_BREAKPARAGRAPH_SKIP, "break-paragraph-skip", "", Noop },
+               { LFUN_BUILDPROG, "build-program", 
+                 N_("Build program"), ReadOnly },
+               { LFUN_AUTOSAVE, "buffer-auto-save", N_("Autosave"), Noop },
+               { LFUN_BEGINNINGBUF, "buffer-begin",
+                 N_("Go to beginning of document"), ReadOnly },
+               { LFUN_BEGINNINGBUFSEL, "buffer-begin-select",
+                 N_("Select to beginning of document"), ReadOnly },
+               { LFUN_CHILDINSERT, "buffer-child-insert", "", Noop },
+               { LFUN_CHILDOPEN, "buffer-child-open", "", ReadOnly },
+               { LFUN_RUNCHKTEX, "buffer-chktex", N_("Check TeX"), ReadOnly },
+               { LFUN_CLOSEBUFFER, "buffer-close", N_("Close"), ReadOnly },
+               { LFUN_ENDBUF, "buffer-end",
+                 N_("Go to end of document"), ReadOnly },
+               { LFUN_ENDBUFSEL, "buffer-end-select",
+                 N_("Select to end of document"), ReadOnly },
+               { LFUN_EXPORT, "buffer-export", N_("Export to"), ReadOnly },
+               { LFUN_FAX, "buffer-fax", N_("Fax"), ReadOnly },
+#ifndef NEW_INSETS
+               { LFUN_INSERTFOOTNOTE, "buffer-float-insert", "", Noop },
 #endif
-       LFUN_INSERT_LABEL,
-       LFUN_INSERT_MATH,
-       LFUN_INSERT_MATRIX,
-       LFUN_INSERT_NOTE,
-       LFUN_INSERT_REF,
-       LFUN_LAYOUT,
-       LFUN_LAYOUTNO,
-       LFUN_LAYOUT_CHARACTER,
-       LFUN_LAYOUT_PASTE,
-       LFUN_LAYOUT_QUOTES,
-       LFUN_LDOTS,
-       LFUN_LOA_INSERT,
-       LFUN_LOF_INSERT,
-       LFUN_LOT_INSERT,
-       LFUN_LOWCASE_WORD,
-       LFUN_MACRON,
-       LFUN_MARGINMELT,
-       LFUN_MATH_DELIM,
-       LFUN_MATH_DISPLAY,
-       LFUN_MATH_MACRO,
-       LFUN_MATH_MACROARG,
-       LFUN_MATH_MODE,
-       LFUN_MATH_NONUMBER,
-       LFUN_MATH_NUMBER,
-       LFUN_MATH_SIZE,
-       LFUN_MELT,
-       LFUN_MENU_SEPARATOR,
-       LFUN_NOUN,
-       LFUN_OGONEK,
-       LFUN_PARENTINSERT,
-       LFUN_PASTE,
-       LFUN_PASTESELECTION,
-       LFUN_PROTECTEDSPACE,
-       LFUN_QUOTE,
-       LFUN_REDO,
-       LFUN_REFTOGGLE,
-       LFUN_ROMAN,
-       LFUN_SANS,
-       LFUN_SELFINSERT,
-       LFUN_SPECIAL_CARON,
-       LFUN_TABINSERT,
-       LFUN_TABLE,
-       LFUN_TEX,
-       LFUN_TIE,
-       LFUN_TILDE,
-       LFUN_TOC_INSERT,
-       LFUN_UMLAUT,
-       LFUN_UNDERBAR,
-       LFUN_UNDERDOT,
-       LFUN_UNDERLINE,
-       LFUN_UNDO,
-       LFUN_UNKNOWN_ACTION,
-       LFUN_UPCASE_WORD,
-       LFUN_URL,
-       LFUN_VECTOR,
-       LFUN_WORDFINDFORWARD,
-       LFUN_WORDFINDBACKWARD
-};
+               { LFUN_IMPORT, "buffer-import",
+                 N_("Import document"), NoBuffer },
+               { LFUN_BUFFERBULLETSSELECT, "buffer-itemize-bullets-select",
+                 "", Noop },
+               { LFUN_BUFFER_PRINT, "buffer-print-xtl", N_("Print"),
+                 ReadOnly },
+               { LFUN_PRINTER_PARAMS_GET, "printer-params-get",
+                 N_("Get the printer parameters"), ReadOnly },
+               { LFUN_MENUNEW, "buffer-new", N_("New document") , NoBuffer },
+               { LFUN_MENUNEWTMPLT,"buffer-new-template",
+                 N_("New document from template"), NoBuffer },
+               { LFUN_MENUOPEN, "buffer-open", N_("Open"), NoBuffer },
+               { LFUN_MENUPRINT, "buffer-print", N_("Print"), ReadOnly },
+               { LFUN_MENURELOAD, "buffer-reload",
+                 N_("Revert to saved"), ReadOnly },
+               { LFUN_SWITCHBUFFER, "buffer-switch", 
+                 N_("Switch to an open document"), ReadOnly },
+               { LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only",
+                 N_("Toggle read-only"), ReadOnly },
+#ifdef NEW_EXPORT
+               { LFUN_UPDATE, "buffer-update", N_("Update"), ReadOnly },
+               { LFUN_PREVIEW, "buffer-view", N_("View") , ReadOnly },
+#else
+               { LFUN_RUNLATEX, "buffer-typeset", N_("Update DVI"),
+                 ReadOnly },
+               { LFUN_RUNDVIPS, "buffer-typeset-ps",
+                 N_("Update PostScript"), ReadOnly },
+               { LFUN_PREVIEW, "buffer-view", N_("View DVI") , ReadOnly },
+               { LFUN_PREVIEWPS, "buffer-view-ps",
+                 N_("View PostScript") , ReadOnly },
+#endif
+               { LFUN_MENUWRITE, "buffer-write", N_("Save"), ReadOnly },
+               { LFUN_MENUWRITEAS, "buffer-write-as", N_("Save As"),
+                 ReadOnly },
+               { LFUN_CANCEL, "cancel", N_("Cancel"), NoBuffer },
+               { LFUN_LEFT, "char-backward", N_("Go one char back"),
+                 ReadOnly },
+               { LFUN_RIGHT, "char-forward", N_("Go one char forward"),
+                 ReadOnly },
+               { LFUN_CITATION_CREATE, "citation-insert",
+                 N_("Insert citation"), Noop },
+               { LFUN_EXEC_COMMAND, "command-execute", "", NoBuffer },
+               { LFUN_PREFIX, "command-prefix",
+                 N_("Execute command"), NoBuffer },
+               { LFUN_SEQUENCE, "command-sequence", "", Noop },
+               { LFUN_COPY, "copy", N_("Copy"), ReadOnly },
+               { LFUN_CUT, "cut", N_("Cut"), Noop },
+               { LFUN_BACKSPACE, "delete-backward", "", Noop },
+               { LFUN_BACKSPACE_SKIP, "delete-backward-skip", "", Noop },
+               { LFUN_DELETE, "delete-forward", "", Noop },
+               { LFUN_DELETE_SKIP, "delete-forward-skip", "", Noop },
+               { LFUN_DEPTH_MIN, "depth-decrement",
+                 N_("Decrement environment depth"), Noop },
+               { LFUN_DEPTH_PLUS, "depth-increment",
+                 N_("Increment environment depth"), Noop },
+               { LFUN_DEPTH, "depth-next", 
+                 N_("Change environment depth"), Noop },
+               { LFUN_LDOTS, "dots-insert", N_("Insert ... dots"), Noop },
+               { LFUN_DOWN, "down", N_("Go down"), ReadOnly },
+               { LFUN_DOWNSEL, "down-select",
+                 N_("Select next line"), ReadOnly },
+               { LFUN_DROP_LAYOUTS_CHOICE, "drop-layouts-choice",
+                 N_("Choose Paragraph Environment"), ReadOnly },
+               { LFUN_END_OF_SENTENCE, "end-of-sentence-period-insert",
+                 N_("Insert end of sentence period"), Noop },
+               { LFUN_GOTOERROR, "error-next", N_("Go to next error"), Noop },
+               { LFUN_REMOVEERRORS, "error-remove-all",
+                 N_("Remove all error boxes"), ReadOnly },
+               { LFUN_INSET_ERT, "ert-insert",
+                 N_("Insert a new ERT Inset"), Noop },
+               { LFUN_INSET_EXTERNAL, "external-insert",
+                 N_("Insert a new external inset"), Noop },
+               { LFUN_FIGURE, "figure-insert", N_("Insert Figure"), Noop },
+               { LFUN_INSET_GRAPHICS, "graphics-insert",
+                 N_("Insert Graphics"), Noop },
+               { LFUN_FILE_INSERT, "file-insert", "", Noop },
+               { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", "", Noop },
+               { LFUN_FILE_NEW, "file-new", "", NoBuffer },
+               { LFUN_FILE_OPEN, "file-open", "", NoBuffer },
+               { LFUN_MENUSEARCH, "find-replace", N_("Find & Replace"),
+                 ReadOnly },
+               { LFUN_BOLD, "font-bold", N_("Toggle bold"), Noop },
+               { LFUN_CODE, "font-code", N_("Toggle code style"), Noop },
+               { LFUN_DEFAULT, "font-default", N_("Default font style"),
+                 Noop },
+               { LFUN_EMPH, "font-emph", N_("Toggle emphasize"), Noop },
+               { LFUN_FREE, "font-free", N_("Toggle user defined style"),
+                 Noop },
+               { LFUN_NOUN, "font-noun", N_("Toggle noun style"), Noop },
+               { LFUN_ROMAN, "font-roman", N_("Toggle roman font style"),
+                 Noop },
+               { LFUN_SANS, "font-sans", N_("Toggle sans font style"), Noop },
+               { LFUN_FONT_SIZE, "font-size", N_("Set font size"), Noop },
+               { LFUN_FONT_STATE, "font-state", N_("Show font state"),
+                 ReadOnly },
+               { LFUN_UNDERLINE, "font-underline",
+                 N_("Toggle font underline"), Noop },
+#ifndef NEW_INSETS
+               { LFUN_FOOTMELT, "footnote-insert", N_("Insert Footnote"),
+                 Noop },
+#else
+               { LFUN_INSET_FOOTNOTE, "footnote-insert",
+                 N_("Insert Footnote"), Noop },
+#endif
+               { LFUN_INSET_MARGINAL, "marginalnote-insert",
+                 N_("Insert Marginalnote"), Noop },
+               { LFUN_RIGHTSEL, "forward-select", N_("Select next char"),
+                 ReadOnly },
+               { LFUN_HFILL, "hfill-insert",
+                 N_("Insert horizontal fill"), Noop },
+               { LFUN_HELP_COPYRIGHT, "help-copyright",
+                 N_("Display copyright information"), NoBuffer },
+               { LFUN_HELP_CREDITS, "help-credits",
+                 N_("Show the list of people who helped writing LyX"), 
+                 NoBuffer},
+               { LFUN_HELP_OPEN, "help-open", N_("Open a Help file"), 
+                 NoBuffer|Argument},
+               { LFUN_HELP_VERSION, "help-version",
+                 N_("Show the actual LyX version"), NoBuffer},
+               { LFUN_HTMLURL, "html-insert", "", Noop },
+               { LFUN_HYPHENATION, "hyphenation-point-insert",
+                 N_("Insert hyphenation point"), Noop },
+               { LFUN_INDEX_CREATE, "index-insert",
+                 N_("Insert index item"), Noop },
+               { LFUN_INDEX_INSERT_LAST, "index-insert-last",
+                 N_("Insert last index item"), Noop },
+               { LFUN_INDEX_PRINT, "index-print", N_("Insert index list"),
+                 Noop },
+               { LFUN_KMAP_OFF, "keymap-off", N_("Turn off keymap"),
+                 ReadOnly },
+               { LFUN_KMAP_PRIM, "keymap-primary",
+                 N_("Use primary keymap"), ReadOnly },
+               { LFUN_KMAP_SEC, "keymap-secondary",
+                 N_("Use secondary keymap"), ReadOnly },
+               { LFUN_KMAP_TOGGLE, "keymap-toggle", N_("Toggle keymap"),
+                 ReadOnly },
+               { LFUN_INSERT_LABEL, "label-insert", N_("Insert Label"),
+                 Noop },
+               { LFUN_LANGUAGE, "language", N_("Change language"), Noop },
+               { LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"),
+                 ReadOnly },
+               { LFUN_LAYOUT, "layout", "", Noop },
+               { LFUN_LAYOUT_CHARACTER, "layout-character", "", Noop },
+               { LFUN_LAYOUT_COPY, "layout-copy",
+                 N_("Copy paragraph environment type"), Noop },
+               { LFUN_LAYOUT_DOCUMENT, "layout-document", "", ReadOnly },
+               { LFUN_LAYOUTNO, "layout-number", "", Noop }, // internal only
+               { LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", "", ReadOnly },
+               { LFUN_LAYOUT_PAPER, "layout-paper", "", ReadOnly },
+               { LFUN_LAYOUT_PASTE, "layout-paste",
+                 N_("Paste paragraph environment type"), Noop },
+               { LFUN_LAYOUT_PREAMBLE, "layout-preamble", "", ReadOnly },
+               { LFUN_LAYOUT_QUOTES, "layout-quotes", "", ReadOnly },
+               { LFUN_LAYOUT_SAVE_DEFAULT, "layout-save-default", "",
+                 ReadOnly },
+               { LFUN_LAYOUT_TABLE, "layout-table",
+                 N_("Open the table layout"), Noop },
+               { LFUN_LAYOUT_TABULAR, "layout-tabular",
+                 N_("Open the tabular layout"), Noop },
+               { LFUN_HOME, "line-begin",
+                 N_("Go to beginning of line"), ReadOnly },
+               { LFUN_HOMESEL, "line-begin-select",
+                 N_("Select to beginning of line"), ReadOnly },
+               { LFUN_DELETE_LINE_FORWARD, "line-delete-forward", "", Noop },
+               { LFUN_END, "line-end", N_("Go to end of line"), ReadOnly },
+               { LFUN_ENDSEL, "line-end-select",
+                 N_("Select to end of line"), ReadOnly },
+               { LFUN_LOA_INSERT, "loa-insert",
+                 N_("Insert list of algorithms"), Noop },
+               { LFUN_LOAVIEW, "loa-view",
+                 N_("View list of algorithms"), ReadOnly },
+               { LFUN_LOF_INSERT, "lof-insert",
+                 N_("Insert list of figures"), Noop },
+               { LFUN_LOFVIEW, "lof-view",
+                 N_("View list of figures"), ReadOnly },
+               { LFUN_LOT_INSERT, "lot-insert",
+                 N_("Insert list of tables"), Noop },
+               { LFUN_LOTVIEW, "lot-view",
+                 N_("View list of tables"), ReadOnly },
+               { LFUN_QUIT, "lyx-quit", N_("Exit"), NoBuffer },
+#ifndef NEW_INSETS
+               { LFUN_MARGINMELT, "marginpar-insert",
+                 N_("Insert Margin note"), Noop },
+#endif
+               { LFUN_MARK_OFF, "mark-off", "", ReadOnly },
+               { LFUN_MARK_ON, "mark-on", "", ReadOnly },
+               { LFUN_SETMARK, "mark-toggle", "", ReadOnly },
+               { LFUN_MATH_DELIM, "math-delim", "", Noop },
+               { LFUN_MATH_DISPLAY, "math-display", "", Noop },
+               { LFUN_GREEK, "math-greek", N_("Math Greek"), Noop },
+               { LFUN_GREEK_TOGGLE, "math-greek-toggle", "", Noop },
+               { LFUN_INSERT_MATH, "math-insert",
+                 N_("Insert math symbol"), Noop },
+               { LFUN_MATH_LIMITS, "math-limits", "", Noop },
+               { LFUN_MATH_MACRO, "math-macro", "", Noop },
+               { LFUN_MATH_MACROARG, "math-macro-arg", "", Noop },
+               { LFUN_INSERT_MATRIX, "math-matrix", "", Noop },
+               { LFUN_MATH_MODE, "math-mode", N_("Math mode"), Noop },
+               { LFUN_MATH_NONUMBER, "math-nonumber", "", Noop },
+               { LFUN_MATH_NUMBER, "math-number", "", Noop },
+               { LFUN_MATH_PANEL, "math-panel", "", Noop },
+               { LFUN_MATH_SIZE, "math-size", "", Noop },
+               { LFUN_MELT, "melt", N_("Melt"), Noop },
+               { LFUN_MENU_OPEN_BY_NAME, "menu-open", "", NoBuffer },
+               { LFUN_MENU_SEPARATOR, "menu-separator-insert", "", Noop },
+               { LFUN_META_FAKE, "meta-prefix", "", NoBuffer },
+               { LFUN_INSERT_NOTE, "note-insert", "", Noop },
+               { LFUN_GOTONOTE, "note-next", "", ReadOnly },
+               { LFUN_OPENSTUFF, "open-stuff", "", ReadOnly },
+               { LFUN_DOWN_PARAGRAPH, "paragraph-down",
+                 N_("Go one paragraph down"), ReadOnly },
+               { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select",
+                 N_("Select next paragraph"), ReadOnly },
+               { LFUN_GOTO_PARAGRAPH, "paragraph-goto", 
+                 N_("Go to paragraph"), ReadOnly },
+               { LFUN_UP_PARAGRAPH, "paragraph-up",
+                 N_("Go one paragraph up"), ReadOnly },
+               { LFUN_UP_PARAGRAPHSEL, "paragraph-up-select",
+                 N_("Select previous paragraph"), ReadOnly },
+               { LFUN_PARENTINSERT, "parent-insert", "", Noop },
+               { LFUN_PASTE, "paste", N_("Paste") , Noop },
+               { LFUN_DIALOG_PREFERENCES, "dialog-preferences",
+                 N_("Edit Preferences"), NoBuffer },
+               { LFUN_SAVEPREFERENCES, "preferences-save",
+                 N_("Save Preferences"), NoBuffer },
+               { LFUN_PASTESELECTION, "primary-selection-paste", "", Noop },
+               { LFUN_PROTECTEDSPACE, "protected-space-insert",
+                 N_("Insert protected space"), Noop },
+               { LFUN_QUOTE, "quote-insert", N_("Insert quote"), Noop },
+               { LFUN_RECONFIGURE, "reconfigure",
+                 N_("Reconfigure"), NoBuffer },
+               { LFUN_REDO, "redo", N_("Redo"), Noop },
+               { LFUN_REF_BACK, "reference-back", "", ReadOnly },
+               { LFUN_REF_GOTO, "reference-goto", "", ReadOnly },
+               { LFUN_REF_INSERT, "reference-insert",
+                 N_("Insert cross reference"), ReadOnly },
+               { LFUN_NEXT, "screen-down", "", ReadOnly },
+               { LFUN_NEXTSEL, "screen-down-select", "", ReadOnly },
+               { LFUN_CENTER, "screen-recenter", "", ReadOnly },
+               { LFUN_PRIOR, "screen-up", "", ReadOnly },
+               { LFUN_PRIORSEL, "screen-up-select", "", ReadOnly },
+               { LFUN_SCROLL_INSET, "inset-scroll", N_("Scroll inset"),
+                 ReadOnly },
+               { LFUN_SELFINSERT, "self-insert", "", Noop },
+               { LFUN_CHARATCURSOR, "server-char-after", "", ReadOnly },
+               { LFUN_GETFONT, "server-get-font", "", ReadOnly },
+               { LFUN_GETLATEX, "server-get-latex", "", ReadOnly },
+               { LFUN_GETLAYOUT, "server-get-layout", "", ReadOnly },
+               { LFUN_GETNAME, "server-get-name", "", ReadOnly },
+               { LFUN_GETTIP, "server-get-tip", "", ReadOnly },
+               { LFUN_GETXY, "server-get-xy", "", ReadOnly },
+               { LFUN_GOTOFILEROW, "server-goto-file-row", "", Noop },
+               { LFUN_NOTIFY, "server-notify", "", ReadOnly },
+               { LFUN_SETXY, "server-set-xy", "", ReadOnly },
+               { LFUN_SPELLCHECK, "spellchecker", "", Noop },
+               { LFUN_INSERT_MATH, "symbol-insert", "", Noop },
+               { LFUN_SHIFT_TAB, "tab-backward", "", Noop },
+               { LFUN_TAB, "tab-forward", "", Noop },
+               { LFUN_TABINSERT, "tab-insert", "", Noop },
+               { LFUN_DIALOG_TABULAR_INSERT, "dialog-tabular-insert",
+                 N_("Open Insert Tabular Dialog"), Noop },
+               { LFUN_TABULAR_FEATURE, "tabular-feature",
+                 N_("Tabular Features"), Noop },
+               { LFUN_INSET_TABULAR, "tabular-insert",
+                 N_("Insert a new Tabular Inset"), Noop },
+               { LFUN_TEX, "tex-mode", N_("Toggle TeX style"), Noop },
+               { LFUN_INSET_TEXT, "text-insert",
+                 N_("Insert a new Text Inset"), Noop },
+               { LFUN_TOC_INSERT, "toc-insert",
+                 N_("Insert table of contents"), Noop },
+               { LFUN_TOCVIEW, "toc-view",
+                 N_("View table of contents"), ReadOnly },
+               { LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar",
+                 N_("Toggle cursor does/doesn't follow the scrollbar"),
+                 ReadOnly },
+               { LFUN_ADD_TO_TOOLBAR, "toolbar-add-to", "", NoBuffer },
+               { LFUN_PUSH_TOOLBAR, "toolbar-push", "", NoBuffer },
+               { LFUN_UNDO, "undo", N_("Undo"), Noop },
+               { LFUN_UP, "up", "", ReadOnly },
+               { LFUN_UPSEL, "up-select", "", ReadOnly },
+               { LFUN_URL, "url-insert", "", Noop },
+               { LFUN_INSERT_URL, "", "", Noop },
+               { LFUN_VC_CHECKIN, "vc-check-in", "", ReadOnly },
+               { LFUN_VC_CHECKOUT, "vc-check-out", "", ReadOnly },
+               { LFUN_VC_HISTORY, "vc-history", "", ReadOnly },
+               { LFUN_VC_REGISTER, "vc-register",
+                 N_("Register document under version control"), ReadOnly },
+               { LFUN_VC_REVERT, "vc-revert", "", ReadOnly },
+               { LFUN_VC_UNDO, "vc-undo-last", "", ReadOnly },
+               { LFUN_WORDLEFT, "word-backward", "", ReadOnly },
+               { LFUN_WORDLEFTSEL, "word-backward-select", "", ReadOnly },
+               { LFUN_CAPITALIZE_WORD, "word-capitalize", "", Noop },
+               { LFUN_DELETE_WORD_BACKWARD, "word-delete-backward",
+                 "", Noop },
+               { LFUN_DELETE_WORD_FORWARD, "word-delete-forward", "", Noop },
+               { LFUN_WORDFINDBACKWARD, "word-find-backward", "", ReadOnly },
+               { LFUN_WORDFINDFORWARD, "word-find-forward", "", ReadOnly },
+               { LFUN_WORDRIGHT, "word-forward", "", ReadOnly },
+               { LFUN_WORDRIGHTSEL, "word-forward-select", "", ReadOnly },
+               { LFUN_LOWCASE_WORD, "word-lowcase", "", Noop },
+               { LFUN_UPCASE_WORD, "word-upcase", "", Noop },
+               { LFUN_DATE_INSERT, "date-insert", "", Noop },
+               { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop },
+               { LFUN_SET_COLOR, "set-color", "", Noop },
+               { LFUN_INSET_MINIPAGE, "minipage-insert", "", Noop },
+               { LFUN_INSET_FLOAT, "float-insert", "", Noop },
+               { LFUN_INSET_LIST, "list-insert", "", Noop },
+               { LFUN_INSET_THEOREM, "theorem-insert", "", Noop },
+               { LFUN_INSET_CAPTION, "caption-insert", "", Noop },
+               { LFUN_SCREEN_FONT_UPDATE, "screen-font-update", "", NoBuffer },
+               { LFUN_NOACTION, "", "", Noop }
+       };
 
-int LyXAction::psd_idx = 0;
-kb_func_table const * LyXAction::lyx_func_table = &::lyx_func_table[0];
-kb_func_table* LyXAction::lyx_func_args = 0;
-/* === code ============================================================== */
+       int i = 0;
+       while (items[i].action != LFUN_NOACTION) {
+               newFunc(items[i].action,
+                       items[i].name,
+                       _(items[i].helpText),
+                       items[i].attrib);
+               ++i;
+       }
 
-/* This routines allow binding actions with argument.
- * Provisionally a fixed size array and global functions are used.
- * [asierra 20Jan96]
- */
-#define MAX_PSEUDO_ACTION 128
+       init = true;
+}
 
 
 LyXAction::LyXAction()
 {
-       lyx_func_args= new kb_func_table[MAX_PSEUDO_ACTION];
-        funcCount = sizeof(::lyx_func_table) / sizeof(::kb_func_table);
+       init();
 }
 
 
-LyXAction::~LyXAction()
+// Search for an existent pseudoaction, return LFUN_UNKNOWN_ACTION
+// if it doesn't exist.
+int LyXAction::searchActionArg(kb_action action, string const & arg) const
 {
-       if (lyx_func_args) {
-// This is wrong, so I'll just disable it for now.
-// The problem is that we might free memory twice in some situations...
-// It's better to leak a bit that to crash. (Asger)
-//             for (int i= 0; i < psd_idx; i++) {
-//                     free(lyx_func_args[i].name);
-//             }
-               delete[] lyx_func_args;
-               lyx_func_args = 0;
+       arg_map::const_iterator pit = lyx_arg_map.find(action);
+
+       if (pit == lyx_arg_map.end()) {
+               // the action does not have any pseudoactions
+               lyxerr[Debug::ACTION] << "Action " << action
+                                     << " does not have any pseudo actions."
+                                     << endl;
+               return LFUN_UNKNOWN_ACTION;
+       }
+       
+       arg_item::const_iterator aci = (*pit).second.find(arg);
+
+       if (aci == (*pit).second.end()) {
+               // the action does not have any pseudoactions with this arg
+               lyxerr[Debug::ACTION] 
+                       << "Action " << action
+                       << "does not have any pseudoactions with arg "
+                       << arg << endl;
+               return LFUN_UNKNOWN_ACTION;
        }
-}
-
-
-// Search for an existent pseudoaction, return -1 if it doesn't exist.
-int  LyXAction::searchActionArg(kb_action action, char const *arg)
-{
-       kb_func_table *tb = &lyx_func_args[0];
-       for (int i= 0; i<psd_idx; i++) {
-               if (action == tb->action && !strcmp(tb->name, arg)) {    
 
-                       lyxerr[Debug::KEY] << "Pseudoaction already exist[" 
-                                          << action << '|' 
-                                          << arg << ']' << endl;
+       // pseudo action exist
+       lyxerr[Debug::ACTION] << "Pseudoaction exist[" 
+                             << action << '|' 
+                             << arg << "] = " << (*aci).second << endl;
 
-                       return LFUN_LASTACTION+i;
-               }
-               tb++;
-       }
-       return -1;
+       return (*aci).second;
 }
 
 
 // Returns a pseudo-action given an action and its argument.
-int LyXAction::getPseudoAction(kb_action action, char const *arg)
+int LyXAction::getPseudoAction(kb_action action, string const & arg) const
 {
-       // Check if the pseudo-action already exist.
        int psdaction = searchActionArg(action, arg);
-   
-       if (psdaction >= 0) return psdaction;
 
-       if (psd_idx>= MAX_PSEUDO_ACTION) {
-               lyxerr << "Lyx Error: No more pseudo-actions allowed"
-                      << "           Tell the developers." << endl;
-               return -1;
-       }
-       lyx_func_args[psd_idx].name = strdup(arg);
-       lyx_func_args[psd_idx].action = action;
-       psd_idx++;
-       return LFUN_LASTACTION+psd_idx-1;
+       if (isPseudoAction(psdaction)) return psdaction;
+
+       static unsigned int pseudo_counter = LFUN_LASTACTION;
+
+       // Create new pseudo action.
+       pseudo_func tmp_p;
+       tmp_p.action = action;
+       tmp_p.arg = arg;
+       lyx_pseudo_map[++pseudo_counter] = tmp_p;
+
+       // First ensure that the action is in lyx_arg_map;
+       lyx_arg_map[action];
+       // get the arg_item map
+       arg_map::iterator ami = lyx_arg_map.find(action);
+       // put the new pseudo function in it
+       (*ami).second[arg] = pseudo_counter;
+
+       lyxerr[Debug::ACTION] << "Creating new pseudoaction "
+                             << pseudo_counter << " for [" << action
+                             << '|' << arg << "]\n";
+       
+       return pseudo_counter;
 }
 
 
 // Retrieves the real action and its argument.
-int LyXAction::retrieveActionArg(int i, char const** arg)
+// perhaps a pair<kb_action, string> should be returned?
+kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const
 {
-       i -= LFUN_LASTACTION;
-       if (i >= 0 &&  i <psd_idx) {
-               *arg = lyx_func_args[i].name;
-               return (int)lyx_func_args[i].action;
+       pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo);
+
+       if (pit != lyx_pseudo_map.end()) {
+               lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
+                                     << (*pit).second.action << '|'
+                                     << (*pit).second.arg << '\n';
+               arg = (*pit).second.arg;
+               return (*pit).second.action;
        } else {
-               lyxerr << "Lyx Error: Unrecognized pseudo-action" << endl;
-               return -1;
+               lyxerr << "Lyx Error: Unrecognized pseudo-action\n";
+               return LFUN_UNKNOWN_ACTION;
        }
+       
 }
 
 
 // Returns an action tag from a string.
-int LyXAction::LookupFunc(char const * func)
+int LyXAction::LookupFunc(string const & func) const
 {
-       if (!func) 
-               return LFUN_UNKNOWN_ACTION;         
-       if (func[0] == '\0')
-               return LFUN_NOACTION;
-   /* In the scan loop below, l can never become r, so set r one past the last
-      valid func table slot. RVDK_PATCH_5 */
-       int k, l= 0, r = funcCount;
-       int action = LFUN_UNKNOWN_ACTION;
-       char * arg = strchr(const_cast<char*>(func), ' '); // const cast to
-       // help a sun complier, will go away when this func is rewritten
-       // to use std::containers and std::string.
-
-       if (arg) *(arg++) = '\0';      
-
-       while (l < r) {
-               last_action_idx = (l+r)/2;
-               k = strcmp(lyx_func_table[last_action_idx].name, func);
-               if (k == 0) {
-                       action = lyx_func_table[last_action_idx].action;
-                       break;
-               } else
-                       if (k<0) l = last_action_idx+1; else r = last_action_idx;
-       }
-       if (arg && action >= 0) {
-               action = getPseudoAction((kb_action)action, arg);
-               lyxerr[Debug::KEY] << "Pseudo action_arg["
-                                  << action << '|' 
-                                  << arg << ']' << endl;
+       if (func.empty()) return LFUN_NOACTION;
+
+       // split action and arg
+       string actstr;
+       string argstr = split(func, actstr, ' ');
+       lyxerr[Debug::ACTION] << "Action: " << actstr << '\n';
+       lyxerr[Debug::ACTION] << "Arg   : " << argstr << '\n';
+
+       func_map::const_iterator fit = lyx_func_map.find(actstr);
+
+       if (!argstr.empty() && fit != lyx_func_map.end()) {
+               // might be pseudo (or create one)
+               return getPseudoAction((*fit).second, argstr);
        }
-       return action;
+
+       return fit != lyx_func_map.end() ? (*fit).second : LFUN_UNKNOWN_ACTION;
 }
 
 
-int LyXAction::getApproxFunc(char const *func)
+//#ifdef WITH_WARNINGS
+//#warning Not working as it should.
+//#endif
+// I have no clue what is wrong with it... (Lgb)
+int LyXAction::getApproxFunc(string const & func) const
+       // This func should perhaps also be able to return a list of all
+       // actions that has func as a prefix. That should actually be quite
+       // easy, just let it return a vector<int> or something.
 {
-    int action = LookupFunc(func);
-    if (action<0) {
-       int k = strncmp(lyx_func_table[last_action_idx].name,
-                       func, strlen(func));
-       if (k<0 && last_action_idx<funcCount-1) 
-         last_action_idx++;
-       else if (k>0 && last_action_idx>0)
-         last_action_idx--;
+       int action = LookupFunc(func);
+       if (action == LFUN_UNKNOWN_ACTION) {
+               // func is not an action, but perhaps it is
+               // part of one...check if it is prefix if one of the
+               // actions.
+               // Checking for prefix is not so simple, but
+               // using a simple bounding function gives
+               // a similar result.  [ale 19981103]
+               func_map::const_iterator fit = 
+                       lyx_func_map.lower_bound(func);
+               
+               if (fit != lyx_func_map.end()) {
+                       action =  (*fit).second;
+               }
+       } else {  // Go get the next function
+               func_map::const_iterator fit = 
+                       lyx_func_map.upper_bound(func);
+               
+               if (fit != lyx_func_map.end()) {
+                       action =  (*fit).second;
+               }
+       }
        
-       action = lyx_func_table[last_action_idx].action;
-    } else if (last_action_idx<funcCount-1)
-      last_action_idx++;
-    
-    return action;
+       return action;
 }
 
 
-char const *LyXAction::getApproxFuncName(char const *func)
+string const LyXAction::getApproxFuncName(string const & func) const
 {
-    getApproxFunc(func);
-    return lyx_func_table[last_action_idx].name;
+       int f = getApproxFunc(func);
+       // This will return empty string if f isn't an action.
+       return getActionName(f);
 }
 
 
-char const *LyXAction::getActionName(int action) const
+string const LyXAction::getActionName(int action) const
 {
-       // why LFUN_LASTACTION -1? Because LFUN_LASTACTION is too
-       // large an because there is one internal command, hence
-       // lyx_func_table is 2 less then LFUN_LASTACTION (Lgb)
-    for (int i= 0; i < funcCount; i++) {
-       if (lyx_func_table[i].action == action)
-         return lyx_func_table[i].name;
-    }
-    
-    // Hmm.. let's see whether this is a pseudoaction
-    action -= LFUN_LASTACTION;
-    if (action>= 0 && action<psd_idx) {
-       return lyx_func_args[action].name;
-    }
-    
-    return "";
+       kb_action ac;
+       string arg;
+       if (isPseudoAction(action)) {
+               ac = retrieveActionArg(action, arg);
+               arg = " " +arg;
+       } 
+       else
+               ac = static_cast<kb_action>(action);
+
+       info_map::const_iterator iit = lyx_info_map.find(ac);
+
+       if (iit != lyx_info_map.end())
+               return (*iit).second.name + arg;
+       else 
+               return string();
 }
 
 
-// Returns one line help associated with function
-// Now the missing strings are replaced by the command names. (Alejandro)
-char const *LyXAction::helpText(kb_action action) const
+// Returns one line help associated with a (pseudo)action, i.e. appends
+// the argument of the action if necessary
+string const LyXAction::helpText(int pseudoaction) const
 {
-        static bool is_sorted = false;
-       static kb_func_table helpTexts[LFUN_LASTACTION] = 
-       {
-               { _("Describe command"), LFUN_APROPOS },
-               { _("Select previous char"), LFUN_LEFTSEL },
-               { _("Insert bibtex"), LFUN_INSERT_BIBTEX },
-               { _("Autosave"), LFUN_AUTOSAVE },
-               { _("Go to beginning of document"), LFUN_BEGINNINGBUF },
-               { _("Select to beginning of document"), LFUN_BEGINNINGBUFSEL },
-               { _("Close"), LFUN_CLOSEBUFFER },
-               { _("Go to end of document"), LFUN_ENDBUF },
-               { _("Select to end of document"), LFUN_ENDBUFSEL },
-               { _("Fax"), LFUN_FAX },
-               { _("New document"), LFUN_MENUNEW },
-               { _("New document from template"), LFUN_MENUNEWTMPLT },
-               { _("Open"), LFUN_MENUOPEN },
-               { _("Switch to previous document"), LFUN_PREVBUFFER },
-               { _("Print"), LFUN_MENUPRINT },
-               { _("Revert to saved"), LFUN_MENURELOAD },
-               { _("Update DVI"), LFUN_RUNLATEX },
-               { _("Update PostScript"), LFUN_RUNDVIPS },
-               { _("View DVI"), LFUN_PREVIEW },
-               { _("View PostScript"), LFUN_PREVIEWPS },
-                { _("Build program"), LFUN_BUILDPROG },
-               { _("Check TeX"), LFUN_RUNCHKTEX },
-               { _("Save"), LFUN_MENUWRITE },
-               { _("Save As"), LFUN_MENUWRITEAS },
-               { _("Cancel"), LFUN_CANCEL },
-               { _("Go one char back"), LFUN_LEFT },
-               { _("Go one char forward"), LFUN_RIGHT },
-               { _("Insert citation"), LFUN_INSERT_CITATION },
-               { _("Execute command"), LFUN_EXEC_COMMAND },
-               { _("Copy"), LFUN_COPY },
-               { _("Cut"), LFUN_CUT },
-               { _("Decrement environment depth"), LFUN_DEPTH_MIN },
-               { _("Increment environment depth"), LFUN_DEPTH_PLUS },
-               { _("Change environment depth"), LFUN_DEPTH },
-               { _("Change itemize bullet settings"), LFUN_BUFFERBULLETSSELECT },
-               { _("Go down"), LFUN_DOWN },
-               { _("Select next line"), LFUN_DOWNSEL },
-               { _("Choose Paragraph Environment"), LFUN_DROP_LAYOUTS_CHOICE },
-               { _("Go to next error"), LFUN_GOTOERROR },
-               { _("Insert Figure"), LFUN_FIGURE },
-               { _("Find & Replace"), LFUN_MENUSEARCH },
-               { _("Toggle cursor does/doesn't follow the scrollbar"), LFUN_TOGGLECURSORFOLLOW },
-               { _("Toggle bold"), LFUN_BOLD },
-               { _("Toggle code style"), LFUN_CODE },
-               { _("Default font style"), LFUN_DEFAULT },
-               { _("Toggle emphasize"), LFUN_EMPH },
-               { _("Toggle user defined style"), LFUN_FREE },
-               { _("Toggle noun style"), LFUN_NOUN },
-               { _("Toggle roman font style"), LFUN_ROMAN },
-               { _("Toggle sans font style"), LFUN_SANS },
-               { _("Set font size"), LFUN_FONT_SIZE },
-               { _("Show font state"), LFUN_FONT_STATE },
-               { _("Toggle font underline"), LFUN_UNDERLINE },
-               { _("Insert Footnote"), LFUN_FOOTMELT },
-               { _("Select next char"), LFUN_RIGHTSEL },
-               { _("Insert horizontal fill"), LFUN_HFILL },
-               { _("Insert hyphenation point"), LFUN_HYPHENATION },
-               { _("Insert ... dots"), LFUN_LDOTS },
-               { _("Insert end of sentence period"), LFUN_END_OF_SENTENCE },
-               { _("Turn off keymap"), LFUN_KMAP_OFF },
-               { _("Use primary keymap"), LFUN_KMAP_PRIM },
-               { _("Use secondary keymap"), LFUN_KMAP_SEC },
-               { _("Toggle keymap"), LFUN_KMAP_TOGGLE },
-               { _("Insert Label"), LFUN_INSERT_LABEL },
-               { _("Copy paragraph environment type"), LFUN_LAYOUT_COPY },
-               { _("Paste paragraph environment type"), LFUN_LAYOUT_PASTE },
-               { _("Specify paper size and margins"), LFUN_LAYOUT_PAPER },
-               { _("Go to beginning of line"), LFUN_HOME },
-               { _("Select to beginning of line"), LFUN_HOMESEL },
-               { _("Go to end of line"), LFUN_END },
-               { _("Select to end of line"), LFUN_ENDSEL },
-               { _("Exit"), LFUN_QUIT },
-               { _("Insert Margin note"), LFUN_MARGINMELT },
-               { _("Math Greek"), LFUN_GREEK },   
-               { _("Math mode"), LFUN_MATH_MODE },
-               { _("Go one paragraph down"), LFUN_DOWN_PARAGRAPH },
-               { _("Select next paragraph"), LFUN_DOWN_PARAGRAPHSEL },
-               { _("Go one paragraph up"), LFUN_UP_PARAGRAPH },
-               { _("Select previous paragraph"), LFUN_UP_PARAGRAPHSEL },
-               { _("Paste"), LFUN_PASTE },
-               { _("Insert protected space"), LFUN_PROTECTEDSPACE },
-               { _("Insert quote"), LFUN_QUOTE },
-               { _("Reconfigure"), LFUN_RECONFIGURE },
-               { _("Redo"), LFUN_REDO },
-               { _("Insert cross reference"), LFUN_INSERT_REF },
-               { _("Insert Table"), LFUN_TABLE },
-               { _("Toggle TeX style"), LFUN_TEX },
-               { _("Undo"), LFUN_UNDO },
-               { _("Melt"), LFUN_MELT },
-               { _("Import document"), LFUN_IMPORT },
-               { _("Remove all error boxes"), LFUN_REMOVEERRORS },
-               { _("Insert menu separator"), LFUN_MENU_SEPARATOR }
-//             { "reference-back", LFUN_REFBACK },
-//             { "reference-goto", LFUN_REFGOTO }, 
-       };
-        
-        // Sort to make it faster
-        if (!is_sorted) {
-               int i= 0; 
-               while (i < LFUN_LASTACTION-1) {
-                   if (helpTexts[i].action == 0) {
-                       helpTexts[i].action = (kb_action)i;
-                       helpTexts[i].name = getActionName(i);
-                       i++;
-                   } else if (helpTexts[i].action != i) {
-                       int k = helpTexts[i].action;
-                       kb_func_table tmp = helpTexts[k];
-                       helpTexts[k] = helpTexts[i];
-                       helpTexts[i] = tmp;
-                       if (k < i) i++;
-                   } else {
-                       i++;
-                   }
+       string help, arg;
+       kb_action action;
+
+       if (isPseudoAction(pseudoaction)) 
+               action = retrieveActionArg(pseudoaction, arg);
+       else 
+               action = static_cast<kb_action>(pseudoaction);
+
+       info_map::const_iterator ici = lyx_info_map.find(action);
+       if (ici != lyx_info_map.end()) {
+               if (lyxerr.debugging(Debug::ACTION)) {
+                       lyxerr << "Action: " << action << '\n';
+                       lyxerr << "   name: "
+                              << (*ici).second.name << '\n';
+                       lyxerr << " attrib: "
+                              << (*ici).second.attrib << '\n';
+                       lyxerr << "   help: "
+                              << (*ici).second.helpText << '\n';
                }
-               is_sorted = true;
+               help = (*ici).second.helpText;
+               // if the is no help text use the name of the func instead.
+               if (help.empty()) help = (*ici).second.name;
        }
 
-       if (action <= 1 || action >= funcCount)
-               goto no_desc;
-               
-        if (helpTexts[action].action == action) {
-           return helpTexts[action].name;
-       } 
-       //        + string(' ') + int(is_ro) + string(']'));
-  no_desc:
-       // In an ideal world, this never happens:
-       return _("No description available!");
+       if (help.empty()) {
+               help = _("No description available!");
+       } else if (!arg.empty()) {
+               help += ' ';
+               help += arg;
+       }
+
+       return help;
 }
 
 
-// Function to compare items from the attrib table.
-extern "C" int actioncomp(const void *a, const void *b)
+bool LyXAction::funcHasFlag(kb_action action, 
+                            LyXAction::func_attrib flag) const 
 {
-    int const *ia= (int const*)a, *ib= (int const*)b;
-    return (*ia)-(*ib);
-}
+       info_map::const_iterator ici = lyx_info_map.find(action);
+
+       if (ici != lyx_info_map.end()) {
+               return (*ici).second.attrib & flag;
+       } else {
+               // it really should exist, but...
+               lyxerr << "LyXAction::funcHasFlag: "
+                       "No info about kb_action: " << action << '\n';
+               return false;
+       }
 
-bool LyXAction::isFuncRO(kb_action action) const
-{
-    static bool is_sorted = false;    
-    static int fCount = sizeof(::func_attrib_table) / sizeof(kb_action);
-    
-    if (!is_sorted) {
-       qsort(func_attrib_table, fCount, sizeof(kb_action), actioncomp);
-       is_sorted = true;
-//     for (int i= 0; i<fCount; i++) 
-//       fprintf(stdout, "%d: %d\n", i, func_attrib_table[i]);
-    }
-
-    int m, k, l= 0, r = fCount;
-    int is_ro = false;
-
-    while (l < r) {
-       m = (l+r)/2;
-       k = func_attrib_table[m] - action;
-       if (k == 0) {
-           is_ro = true;
-           break;
-       } else
-         if (k<0) l = m+1; else r = m;
-    }
-    lyxerr.debug() << "RO[" << action
-                  << " " << is_ro << "]" << endl;
-    return is_ro;
 }
 
+
 ostream & operator<<(ostream & o, kb_action action)
 {
        return o << int(action);