/*! * \file LyXAction.cpp * 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 * \author Pavel Sanda * * Full author contact details are available in file CREDITS. */ #include #include "LyXAction.h" #include "FuncRequest.h" #include "support/debug.h" #include "support/lstrings.h" #include "support/lassert.h" #include using namespace std; using namespace lyx::support; namespace lyx { /* 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'. 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'). 5) Upward movement of focus is called `up'. 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) */ /* LFUN documentation * * The documentation below is primarily description of purpose and syntax * relating to the different LFUNs. * * Try to find an appropriate (thematical) place when adding the new LFUN * and don't forget to add doxygen commentary. * * Doxygen template below. Some notes: Parameters should be set in uppercase * and put in , [] means optional one. * * Use spaces for indentation (doxy -> .lyx generator is tab-sensitive). */ /*! * \var lyx::FuncCode lyx::LFUN_ * \li Action: * \li Notion: * \li Syntax: * \li Params: * \li Sample: * \li Origin: * \endvar */ LyXAction lyxaction; void LyXAction::newFunc(FuncCode action, string const & name, unsigned int attrib, LyXAction::FuncType type) { lyx_func_map[name] = action; FuncInfo tmpinfo; tmpinfo.name = name; tmpinfo.attrib = attrib; tmpinfo.type = type; lyx_info_map[action] = tmpinfo; } // Needed for LFUNs documentation to be accepted, since doxygen won't take // \var inside functions. #ifndef DOXYGEN_SHOULD_SKIP_THIS 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; if (init) return; struct ev_item { FuncCode action; char const * name; unsigned int attrib; FuncType type; }; ev_item const items[] = { #endif /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_ACUTE * \li Action: Adds an acute accent \htmlonly (á)\endhtmlonly to the next character typed. * \li Syntax: accent-acute * \endvar */ { LFUN_ACCENT_ACUTE, "accent-acute", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_BREVE * \li Action: Adds a breve accent \htmlonly (ă)\endhtmlonly to the next character typed. * \li Syntax: accent-breve * \endvar */ { LFUN_ACCENT_BREVE, "accent-breve", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_CARON * \li Action: Adds a caron \htmlonly (ǎ)\endhtmlonly to the next character typed. * \li Syntax: accent-caron * \endvar */ { LFUN_ACCENT_CARON, "accent-caron", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_CEDILLA * \li Action: Adds a cedilla \htmlonly (ç)\endhtmlonly to the next character typed. * \li Syntax: accent-cedilla * \endvar */ { LFUN_ACCENT_CEDILLA, "accent-cedilla", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_CIRCLE * \li Action: Adds a circle accent \htmlonly (å)\endhtmlonly to the next character typed. * \li Syntax: accent-circle * \endvar */ { LFUN_ACCENT_CIRCLE, "accent-circle", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_CIRCUMFLEX * \li Action: Adds a circumflex \htmlonly (ê)\endhtmlonly to the next character typed. * \li Syntax: accent-circumflex * \endvar */ { LFUN_ACCENT_CIRCUMFLEX, "accent-circumflex", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_DOT * \li Action: Adds a dot accent \htmlonly (ż)\endhtmlonly to the next character typed. * \li Syntax: accent-dot * \endvar */ { LFUN_ACCENT_DOT, "accent-dot", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_GRAVE * \li Action: Adds a grave accent \htmlonly (è)\endhtmlonly to the next character typed. * \li Syntax: accent-grave * \endvar */ { LFUN_ACCENT_GRAVE, "accent-grave", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_HUNGARIAN_UMLAUT * \li Action: Adds a Hungarian umlaut \htmlonly (ő)\endhtmlonly to the next character typed. * \li Syntax: accent-grave * \endvar */ { LFUN_ACCENT_HUNGARIAN_UMLAUT, "accent-hungarian-umlaut", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_MACRON * \li Action: Adds a macron \htmlonly (ā)\endhtmlonly to the next character typed. * \li Syntax: accent-macron * \endvar */ { LFUN_ACCENT_MACRON, "accent-macron", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_OGONEK * \li Action: Adds an ogonek accent \htmlonly (ą)\endhtmlonly to the next character typed. * \li Syntax: accent-ogonek * \endvar */ { LFUN_ACCENT_OGONEK, "accent-ogonek", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_PERISPOMENI * \li Action: Adds a perispomeni (Greek circumflex) over the next character typed. * \li Syntax: accent-perispomeni * \endvar */ { LFUN_ACCENT_PERISPOMENI, "accent-perispomeni", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_TIE * \li Action: Adds a tie \htmlonly (a͡)\endhtmlonly over the next two character typed. * \li Notion: The following char will finish the tie. * \li Syntax: accent-tie * \endvar */ { LFUN_ACCENT_TIE, "accent-tie", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_TILDE * \li Action: Adds a tilde \htmlonly (ã)\endhtmlonly over the next character typed. * \li Syntax: accent-tilde * \endvar */ { LFUN_ACCENT_TILDE, "accent-tilde", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_UMLAUT * \li Action: Adds an umlaut \htmlonly (ä)\endhtmlonly over the next character typed. * \li Syntax: accent-umlaut * \endvar */ { LFUN_ACCENT_UMLAUT, "accent-umlaut", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_UNDERBAR * \li Action: Adds a bar \htmlonly (a̠)\endhtmlonly under the next character typed. * \li Syntax: accent-underbar * \endvar */ { LFUN_ACCENT_UNDERBAR, "accent-underbar", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ACCENT_UNDERDOT * \li Action: Adds a dot \htmlonly (ạ)\endhtmlonly under the next character typed. * \li Syntax: accent-underdot * \endvar */ { LFUN_ACCENT_UNDERDOT, "accent-underdot", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_CAPTION_INSERT * \li Action: Inserts a caption inset. * \li Syntax: caption-insert * \li Origin: Lgb, 18 Jul 2000 * \endvar */ { LFUN_CAPTION_INSERT, "caption-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_DATE_INSERT * \li Action: Inserts the current date. * \li Syntax: date-insert [] * \li Params: : Format of date. The default value (%x) can be set in Preferences->Date format. For possible formats see manual page of strftime function. * \li Origin: jdblair, 31 Jan 2000 * \endvar */ { LFUN_DATE_INSERT, "date-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_FOOTNOTE_INSERT * \li Action: Inserts a footnote inset. * \li Syntax: footnote-insert * \li Origin: Jug, 7 Mar 2000 * \endvar */ { LFUN_FOOTNOTE_INSERT, "footnote-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ERT_INSERT * \li Action: Inserts an ERT inset. * \li Syntax: ert-insert * \li Origin: Jug, 18 Feb 2000 * \endvar */ { LFUN_ERT_INSERT, "ert-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_FLOAT_INSERT * \li Action: Inserts a float inset. * \li Syntax: float-insert * \li Params: : type of float depends on the used textclass. Usually "algorithm", "table", "figure" parameters can be given. * \li Origin: Lgb, 27 Jun 2000 * \endvar */ { LFUN_FLOAT_INSERT, "float-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_FLOAT_WIDE_INSERT * \li Action: Inserts float insets as in #LFUN_FLOAT_INSERT but span multiple columns. * \li Notion: Corresponds to the starred floats (figure*, table*, etc.) in LaTeX. * \li Syntax: float-wide-insert * \li Params: : type of float depends on the used textclass. Usually "algorithm", "table", "figure" parameters can be given. * \li Origin: Lgb, 31 Oct 2001 * \endvar */ { LFUN_FLOAT_WIDE_INSERT, "float-wide-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_FLOAT_LIST_INSERT * \li Action: Inserts the list of floats in the document. * \li Syntax: float-list-insert * \li Params: : type of float depends on the used textclass. Usually "algorithm", "table", "figure" parameters can be given. * \li Origin: Lgb, 3 May 2001 * \endvar */ { LFUN_FLOAT_LIST_INSERT, "float-list-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_WRAP_INSERT * \li Action: Inserts floats wrapped by the text around. * \li Syntax: wrap-insert * \li Params: : table|figure * \li Origin: Dekel, 7 Apr 2002 * \endvar */ { LFUN_WRAP_INSERT, "wrap-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_ARGUMENT_INSERT * \li Action: Inserts an argument (short title) inset. * \li Syntax: argument-insert * \li Params: : see layout declarations * \li Origin: vermeer, 12 Aug 2002 * \endvar */ { LFUN_ARGUMENT_INSERT, "argument-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_NEWPAGE_INSERT * \li Action: Inserts a new page. * \li Syntax: newpage-insert * \li Params: : default: newpage * \li Origin: uwestoehr, 24 Nov 2007 * \endvar */ { LFUN_NEWPAGE_INSERT, "newpage-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_MARGINALNOTE_INSERT * \li Action: Inserts a marginal note. * \li Syntax: marginalnote-insert * \li Origin: Lgb, 26 Jun 2000 * \endvar */ { LFUN_MARGINALNOTE_INSERT, "marginalnote-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_UNICODE_INSERT * \li Action: Inserts a single unicode character. * \li Syntax: unicode-insert * \li Params: : The character to insert, given as its code point, in hexadecimal. * \li Sample: unicode-insert 0x0100 * \li Origin: Lgb, 22 Oct 2006 * \endvar */ { LFUN_UNICODE_INSERT, "unicode-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_LISTING_INSERT * \li Action: Inserts a new listings inset. * \li Syntax: listing-insert * \li Origin: Herbert, 10 Nov 2001; bpeng, 2 May 2007 * \endvar */ { LFUN_LISTING_INSERT, "listing-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_PREVIEW_INSERT * \li Action: Inserts a new preview inset. * \li Syntax: preview-insert * \li Origin: vfr, 28 Mar 2010 * \endvar */ { LFUN_PREVIEW_INSERT, "preview-insert", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_TAB_INSERT * \li Action: Insert a tab into a listings inset. * \li Notion: It also works on a selection. * \li Syntax: tab-insert * \li Origin: vfr, Sep 30 2008 * \endvar */ { LFUN_TAB_INSERT, "tab-insert", SingleParUpdate, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_TAB_DELETE * \li Action: Delete a tab or up to an equivalent amount of spaces from a listings inset. * \li Notion: It also works on a selection - it removes a tab or spaces from the beginning of each line spanned by the selection. This is useful if you want to indent/unindent multiple lines in one action. * \li Syntax: tab-delete * \li Origin: vfr, Sep 30 2008 * \endvar */ { LFUN_TAB_DELETE, "tab-delete", SingleParUpdate, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_QUOTE_INSERT * \li Action: Inserts quotes according to the type and quote-language preference. * \li Notion: Currently English, Swedish, German, Polish, French, Danish quotes are distinguished. * \li Syntax: quote-insert [] [] [] * \li Params: : 'single' for single quotes, otherwise double quotes will be used. * : 'left' for opening quotes, 'right' for closing quotes, otherwise * the side will be guessed from the context. *