-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-1999 The LyX Team.
+/**
+ * \file LyXAction.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * ====================================================== */
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ * \author John Levon
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
#include <config.h>
-#include <cstdlib>
-#include <cstdio>
-#include <cctype>
-#include <cstring>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "LyXAction.h"
+
#include "debug.h"
-#include "gettext.h"
+#include "funcrequest.h"
+
#include "support/lstrings.h"
- /*
+#include <boost/assert.hpp>
+
+using lyx::support::split;
+using lyx::support::trim;
+
+using std::endl;
+using std::string;
+using std::ostream;
+
+
+/*
NAMING RULES FOR USER-COMMANDS
Here's the set of rules to apply when a new command name is introduced:
-
+
1) Use the object.event order. That is, use `word-forward'
- instead of `forward-word'.
+ instead of `forward-word'.
2) Don't introduce an alias for an already named object. Same for events.
3) Forward movement or focus is called `forward' (not `right').
4) Backward movement or focus is called `backward' (not `left').
6) Downward movement is called `down'.
7) The begin of an object is called `begin' (not `start').
8) The end of an object is called `end'.
-
- (May 19 1996, 12:04, RvdK)
- */
-
-// These are globals.
-LyXAction lyxaction;
-
-
-/* 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 },
- { "command-sequence", LFUN_SEQUENCE },
- { "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;
-};
-
-Alejandro-970604
+ (May 19 1996, 12:04, RvdK)
*/
-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,
-#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
-};
-
-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 ============================================================== */
-
-/* This routines allow binding actions with argument.
- * Provisionally a fixed size array and global functions are used.
- * [asierra 20Jan96]
- */
-#define MAX_PSEUDO_ACTION 128
-
-
-LyXAction::LyXAction()
-{
- lyx_func_args= new kb_func_table[MAX_PSEUDO_ACTION];
- funcCount = sizeof(::lyx_func_table) / sizeof(::kb_func_table);
-}
+LyXAction lyxaction;
-LyXAction::~LyXAction()
+void LyXAction::newFunc(kb_action action, string const & name,
+ unsigned int attrib)
{
- 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;
- }
+ lyx_func_map[name] = action;
+ func_info tmpinfo;
+ tmpinfo.name = name;
+ tmpinfo.attrib = attrib;
+ lyx_info_map[action] = tmpinfo;
}
-// Search for an existent pseudoaction, return -1 if it doesn't exist.
-int LyXAction::searchActionArg(kb_action action, char const *arg)
+void LyXAction::init()
{
- kb_func_table *tb = &lyx_func_args[0];
- for (int i= 0; i<psd_idx; i++) {
- if (action == tb->action && !strcmp(tb->name, arg)) {
+ // 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;
+ if (init) return;
+
+ struct ev_item {
+ kb_action action;
+ char const * name;
+ unsigned int attrib;
+ };
- lyxerr[Debug::KEY] << "Pseudoaction already exist["
- << action << '|'
- << arg << ']' << endl;
+ ev_item const 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_APPENDIX, "appendix", Noop },
+ { LFUN_LEFTSEL, "backward-select", ReadOnly },
+ { LFUN_BOOKMARK_GOTO, "bookmark-goto", ReadOnly },
+ { LFUN_BOOKMARK_SAVE, "bookmark-save", ReadOnly },
+ { 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", ReadOnly },
+ { LFUN_AUTOSAVE, "buffer-auto-save", Noop },
+ { LFUN_BEGINNINGBUF, "buffer-begin", ReadOnly },
+ { LFUN_BEGINNINGBUFSEL, "buffer-begin-select", ReadOnly },
+ { LFUN_CHILDOPEN, "buffer-child-open", ReadOnly },
+ { LFUN_RUNCHKTEX, "buffer-chktex", ReadOnly },
+ { LFUN_CLOSEBUFFER, "buffer-close", ReadOnly },
+ { LFUN_ENDBUF, "buffer-end", ReadOnly },
+ { LFUN_ENDBUFSEL, "buffer-end-select", ReadOnly },
+ { LFUN_EXPORT, "buffer-export", ReadOnly },
+ { LFUN_EXPORT_CUSTOM, "buffer-export-custom", ReadOnly },
+ { LFUN_PRINT, "buffer-print", ReadOnly },
+ { LFUN_IMPORT, "buffer-import", NoBuffer },
+ { LFUN_MENUNEW, "buffer-new", NoBuffer },
+ { LFUN_MENUNEWTMPLT,"buffer-new-template", NoBuffer },
+ { LFUN_MENURELOAD, "buffer-reload", ReadOnly },
+ { LFUN_SWITCHBUFFER, "buffer-switch", ReadOnly },
+ { LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only", ReadOnly },
+ { LFUN_UPDATE, "buffer-update", ReadOnly },
+ { LFUN_PREVIEW, "buffer-view", ReadOnly },
+ { LFUN_MENUWRITE, "buffer-write", ReadOnly },
+ { LFUN_WRITEAS, "buffer-write-as", ReadOnly },
+ { LFUN_CANCEL, "cancel", NoBuffer },
+ { LFUN_INSET_CAPTION, "caption-insert", Noop },
+ { LFUN_LEFT, "char-backward", ReadOnly },
+ { LFUN_RIGHT, "char-forward", ReadOnly },
+ { LFUN_EXEC_COMMAND, "command-execute", NoBuffer },
+ { LFUN_PREFIX, "command-prefix", NoBuffer },
+ { LFUN_SEQUENCE, "command-sequence", NoBuffer },
+ { LFUN_COPY, "copy", ReadOnly },
+ { LFUN_CUT, "cut", Noop },
+ { LFUN_DATE_INSERT, "date-insert", 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", Noop },
+ { LFUN_DEPTH_PLUS, "depth-increment", Noop },
+ { LFUN_LDOTS, "dots-insert", Noop },
+ { LFUN_DOWN, "down", ReadOnly },
+ { LFUN_DOWNSEL, "down-select", ReadOnly },
+ { LFUN_DROP_LAYOUTS_CHOICE, "drop-layouts-choice", ReadOnly },
+ { LFUN_END_OF_SENTENCE, "end-of-sentence-period-insert", Noop },
+ { LFUN_ENVIRONMENT_INSERT, "environment-insert", Noop },
+ { LFUN_GOTOERROR, "error-next", ReadOnly },
+ { LFUN_INSET_ERT, "ert-insert", Noop },
+ { LFUN_FILE_INSERT, "file-insert", Noop },
+ { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", Noop },
+ { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", Noop },
+ { LFUN_FILE_NEW, "file-new", NoBuffer },
+ { LFUN_FILE_OPEN, "file-open", NoBuffer },
+ { LFUN_INSET_FLOAT, "float-insert", Noop },
+ { LFUN_INSET_WIDE_FLOAT, "float-wide-insert", Noop },
+ { LFUN_INSET_WRAP, "wrap-insert", Noop },
+ { LFUN_BOLD, "font-bold", Noop },
+ { LFUN_CODE, "font-code", Noop },
+ { LFUN_DEFAULT, "font-default", Noop },
+ { LFUN_EMPH, "font-emph", Noop },
+ { LFUN_FREEFONT_APPLY, "font-free-apply", Noop },
+ { LFUN_FREEFONT_UPDATE, "font-free-update", Noop },
+ { LFUN_NOUN, "font-noun", Noop },
+ { LFUN_ROMAN, "font-roman", Noop },
+ { LFUN_SANS, "font-sans", Noop },
+ { LFUN_FRAK, "font-frak", Noop },
+ { LFUN_ITAL, "font-ital", Noop },
+ { LFUN_FONT_SIZE, "font-size", Noop },
+ { LFUN_FONT_STATE, "font-state", ReadOnly },
+ { LFUN_UNDERLINE, "font-underline", Noop },
+ { LFUN_INSET_FOOTNOTE, "footnote-insert", Noop },
+ { LFUN_RIGHTSEL, "forward-select", ReadOnly },
+ { LFUN_HFILL, "hfill-insert", Noop },
+ { LFUN_HELP_OPEN, "help-open", NoBuffer | Argument},
+ { LFUN_HTMLURL, "html-insert", Noop },
+ { LFUN_HYPHENATION, "hyphenation-point-insert", Noop },
+ { LFUN_LIGATURE_BREAK, "ligature-break-insert", Noop },
+ { LFUN_INDEX_INSERT, "index-insert", Noop },
+ { LFUN_INDEX_PRINT, "index-print", Noop },
+ { LFUN_KMAP_OFF, "keymap-off", ReadOnly },
+ { LFUN_KMAP_PRIM, "keymap-primary", ReadOnly },
+ { LFUN_KMAP_SEC, "keymap-secondary", ReadOnly },
+ { LFUN_KMAP_TOGGLE, "keymap-toggle", ReadOnly },
+ { LFUN_INSERT_LABEL, "label-insert", Noop },
+ { LFUN_INSET_OPTARG, "optional-insert", Noop },
+ { LFUN_INSERT_BIBITEM, "bibitem-insert", Noop },
+ { LFUN_INSERT_LINE, "line-insert", Noop },
+ { LFUN_INSERT_PAGEBREAK, "pagebreak-insert", Noop },
+ { LFUN_LANGUAGE, "language", Noop },
+ { LFUN_LAYOUT, "layout", Noop },
+ { LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", ReadOnly },
+ { LFUN_LAYOUT_TABULAR, "layout-tabular", Noop },
+ { LFUN_HOME, "line-begin", ReadOnly },
+ { LFUN_HOMESEL, "line-begin-select", ReadOnly },
+ { LFUN_DELETE_LINE_FORWARD, "line-delete-forward", Noop },
+ { LFUN_END, "line-end", ReadOnly },
+ { LFUN_ENDSEL, "line-end-select", ReadOnly },
+#if 0
+ { LFUN_INSET_LIST, "list-insert", Noop },
+#endif
+ { LFUN_QUIT, "lyx-quit", NoBuffer },
+ { LFUN_INSET_MARGINAL, "marginalnote-insert", Noop },
+ { 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_INSERT_MATH, "math-insert", Noop },
+ { LFUN_SUBSCRIPT, "math-subscript", Noop },
+ { LFUN_SUPERSCRIPT, "math-superscript", Noop },
+ { LFUN_MATH_LIMITS, "math-limits", Noop },
+ { LFUN_MATH_MACRO, "math-macro", Noop },
+ { LFUN_MATH_MUTATE, "math-mutate", Noop },
+ { LFUN_MATH_SPACE, "math-space", Noop },
+ { LFUN_MATH_IMPORT_SELECTION, "math-import-selection", Noop },
+ { LFUN_INSERT_MATRIX, "math-matrix", Noop },
+ { LFUN_MATH_MODE, "math-mode", Noop },
+ { LFUN_MATH_NONUMBER, "math-nonumber", Noop },
+ { LFUN_MATH_NUMBER, "math-number", Noop },
+ { LFUN_MATH_EXTERN, "math-extern", Noop },
+ { LFUN_MATH_SIZE, "math-size", Noop },
+ { LFUN_MENU_OPEN_BY_NAME, "menu-open", NoBuffer },
+ { LFUN_MENU_SEPARATOR, "menu-separator-insert", Noop },
+ { LFUN_META_FAKE, "meta-prefix", NoBuffer },
+ { LFUN_INSERT_BRANCH, "branch-insert", Noop },
+ { LFUN_INSERT_CHARSTYLE, "charstyle-insert", Noop },
+ { LFUN_INSERT_NOTE, "note-insert", Noop },
+ { LFUN_INSERT_BOX, "box-insert", Noop },
+ { LFUN_GOTONOTE, "note-next", ReadOnly },
+ { LFUN_INSET_TOGGLE, "", ReadOnly },
+ { LFUN_NEXT_INSET_TOGGLE, "next-inset-toggle", ReadOnly },
+ { LFUN_ALL_INSETS_TOGGLE, "all-insets-toggle", ReadOnly },
+ { LFUN_DOWN_PARAGRAPH, "paragraph-down", ReadOnly },
+ { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select", ReadOnly },
+ { LFUN_GOTO_PARAGRAPH, "paragraph-goto", ReadOnly },
+ { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", Noop },
+ { LFUN_UP_PARAGRAPH, "paragraph-up", ReadOnly },
+ { LFUN_UP_PARAGRAPHSEL, "paragraph-up-select", ReadOnly },
+ { LFUN_PASTE, "paste", Noop },
+ { LFUN_SAVEPREFERENCES, "preferences-save", NoBuffer },
+ { LFUN_PASTESELECTION, "primary-selection-paste", Noop },
+ { LFUN_QUOTE, "quote-insert", Noop },
+ { LFUN_RECONFIGURE, "reconfigure", NoBuffer },
+ { LFUN_REDO, "redo", Noop },
+ { LFUN_REF_GOTO, "reference-goto", ReadOnly },
+ { LFUN_REFERENCE_GOTO, "reference-next", ReadOnly },
+ { LFUN_NEXT, "screen-down", ReadOnly },
+ { LFUN_NEXTSEL, "screen-down-select", ReadOnly },
+ { LFUN_SCREEN_FONT_UPDATE, "screen-font-update", NoBuffer },
+ { LFUN_CENTER, "screen-recenter", ReadOnly },
+ { LFUN_PRIOR, "screen-up", ReadOnly },
+ { LFUN_PRIORSEL, "screen-up-select", ReadOnly },
+ { LFUN_SCROLL_INSET, "inset-scroll", ReadOnly },
+ { LFUN_SELFINSERT, "self-insert", Noop },
+ { LFUN_SPACE_INSERT, "space-insert", Noop },
+ { LFUN_CHARATCURSOR, "server-char-after", ReadOnly },
+ { LFUN_GETFONT, "server-get-font", ReadOnly },
+ { LFUN_GETLAYOUT, "server-get-layout", ReadOnly },
+ { LFUN_GETNAME, "server-get-name", 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_SET_COLOR, "set-color", ReadOnly | NoBuffer },
+ { LFUN_CELL_BACKWARD, "cell-backward", Noop },
+ { LFUN_CELL_FORWARD, "cell-forward", Noop },
+ { LFUN_CELL_SPLIT, "cell-split", Noop },
+ { LFUN_TABULAR_INSERT, "tabular-insert", Noop },
+ { LFUN_TABULAR_FEATURE, "tabular-feature", Noop },
+#if 0
+ { LFUN_INSET_THEOREM, "theorem-insert", Noop },
+#endif
+ { LFUN_THESAURUS_ENTRY, "thesaurus-entry", ReadOnly },
+ { LFUN_TOC_INSERT, "toc-insert", Noop },
+ { LFUN_TOCVIEW, "toc-view", ReadOnly },
+ { LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar", ReadOnly },
+ { LFUN_UNDO, "undo", Noop },
+ { LFUN_UP, "up", ReadOnly },
+ { LFUN_UPSEL, "up-select", ReadOnly },
+ { LFUN_URL, "url-insert", Noop },
+ { LFUN_VC_CHECKIN, "vc-check-in", ReadOnly },
+ { LFUN_VC_CHECKOUT, "vc-check-out", ReadOnly },
+ { LFUN_VC_REGISTER, "vc-register", 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_WORDSEL, "word-select", ReadOnly },
+ { LFUN_UPCASE_WORD, "word-upcase", Noop },
+ { LFUN_MESSAGE, "message", NoBuffer },
+ { LFUN_TRANSPOSE_CHARS, "chars-transpose", Noop },
+ { LFUN_FLOAT_LIST, "float-list", Noop },
+ { LFUN_ESCAPE, "escape", ReadOnly },
+ { LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", NoBuffer },
+ { LFUN_TRACK_CHANGES, "track-changes", Noop },
+ { LFUN_MERGE_CHANGES, "merge-changes", Noop },
+ { LFUN_ACCEPT_CHANGE, "accept-change", Noop },
+ { LFUN_REJECT_CHANGE, "reject-change", Noop },
+ { LFUN_ACCEPT_ALL_CHANGES, "accept-all-changes", Noop },
+ { LFUN_REJECT_ALL_CHANGES, "reject-all-changes", Noop },
+ { LFUN_DIALOG_SHOW, "dialog-show", NoBuffer },
+ { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop },
+ { LFUN_DIALOG_SHOW_NEXT_INSET, "dialog-show-next-inset", Noop },
+ { LFUN_DIALOG_UPDATE, "dialog-update", NoBuffer },
+ { LFUN_DIALOG_HIDE, "dialog-hide", Noop },
+ { LFUN_DIALOG_DISCONNECT_INSET, "dialog-disconnect-inset", Noop },
+ { LFUN_INSET_APPLY, "inset-apply", Noop },
+ { LFUN_INSET_INSERT, "inset-insert", Noop },
+ { LFUN_INSET_MODIFY, "", Noop },
+ { LFUN_INSET_DIALOG_UPDATE, "", Noop },
+ { LFUN_INSET_SETTINGS, "inset-settings", ReadOnly },
+ { LFUN_INSET_DIALOG_SHOW, "inset-dialog-show", Noop },
+ { LFUN_PARAGRAPH_APPLY, "paragraph-params-apply", Noop },
+ { LFUN_PARAGRAPH_UPDATE, "", Noop },
+ { LFUN_EXTERNAL_EDIT, "external-edit", Noop },
+ { LFUN_GRAPHICS_EDIT, "graphics-edit", Noop },
+ { LFUN_REPEAT, "repeat", NoBuffer },
+ { LFUN_WORD_FIND, "word-find", ReadOnly },
+ { LFUN_WORD_REPLACE, "word-replace", Noop },
+ { LFUN_KEYMAP_TOGGLE, "keymap-toggle", Noop },
+ { LFUN_LANGUAGE_BUFFER, "buffer-language", Noop },
+ { LFUN_TEXTCLASS_APPLY, "textclass-apply", Noop },
+ { LFUN_TEXTCLASS_LOAD, "textclass-load", Noop },
+ { LFUN_SAVE_AS_DEFAULT, "buffer-save-as-default", Noop },
+ { LFUN_BUFFERPARAMS_APPLY, "buffer-params-apply", Noop },
+ { LFUN_LYXRC_APPLY, "lyxrc-apply", NoBuffer },
+ { LFUN_INSET_REFRESH, "", Noop },
+ { LFUN_NEXTBUFFER, "buffer-next", ReadOnly },
+ { LFUN_PREVIOUSBUFFER, "buffer-previous", ReadOnly },
+ { LFUN_NOACTION, "", Noop }
+ };
- return LFUN_LASTACTION+i;
- }
- tb++;
+ for (int i = 0; items[i].action != LFUN_NOACTION; ++i) {
+ newFunc(items[i].action, items[i].name, items[i].attrib);
}
- return -1;
-}
-
-// Returns a pseudo-action given an action and its argument.
-int LyXAction::getPseudoAction(kb_action action, char const *arg)
-{
- // 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;
+ init = true;
}
-// Retrieves the real action and its argument.
-int LyXAction::retrieveActionArg(int i, char const** arg)
+LyXAction::LyXAction()
{
- i -= LFUN_LASTACTION;
- if (i >= 0 && i <psd_idx) {
- *arg = lyx_func_args[i].name;
- return (int)lyx_func_args[i].action;
- } else {
- lyxerr << "Lyx Error: Unrecognized pseudo-action" << endl;
- return -1;
- }
+ init();
}
// Returns an action tag from a string.
-int LyXAction::LookupFunc(char const * func)
+FuncRequest 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;
+ string const func2 = trim(func);
+
+ if (func2.empty()) {
+ return FuncRequest(LFUN_NOACTION);
}
- return action;
-}
+ string cmd;
+ string const arg = split(func2, cmd, ' ');
-int LyXAction::getApproxFunc(char const *func)
-{
- 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--;
-
- action = lyx_func_table[last_action_idx].action;
- } else if (last_action_idx<funcCount-1)
- last_action_idx++;
-
- return action;
-}
+ func_map::const_iterator fit = lyx_func_map.find(cmd);
-
-char const *LyXAction::getApproxFuncName(char const *func)
-{
- getApproxFunc(func);
- return lyx_func_table[last_action_idx].name;
+ return fit != lyx_func_map.end() ? FuncRequest(fit->second, arg) : FuncRequest(LFUN_UNKNOWN_ACTION);
}
-char const *LyXAction::getActionName(int action) const
+string const LyXAction::getActionName(kb_action 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 "";
+ info_map::const_iterator const it = lyx_info_map.find(action);
+ return it != lyx_info_map.end() ? it->second.name : 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
+bool LyXAction::funcHasFlag(kb_action action,
+ LyXAction::func_attrib flag) 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++;
- }
- }
- is_sorted = true;
+ info_map::const_iterator ici = lyx_info_map.find(action);
+
+ if (ici == lyx_info_map.end()) {
+ lyxerr << "action: " << action << " is not known." << endl;
+ BOOST_ASSERT(false);
}
- 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!");
+ return ici->second.attrib & flag;
}
-// Function to compare items from the attrib table.
-extern "C" int actioncomp(const void *a, const void *b)
+LyXAction::const_func_iterator LyXAction::func_begin() const
{
- int const *ia= (int const*)a, *ib= (int const*)b;
- return (*ia)-(*ib);
+ return lyx_func_map.begin();
}
-
-bool LyXAction::isFuncRO(kb_action action) const
+
+LyXAction::const_func_iterator LyXAction::func_end() 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;
+ return lyx_func_map.end();
}
+
ostream & operator<<(ostream & o, kb_action action)
{
return o << int(action);