LFUN_BUFFER_CLOSE_ALL, // vfr 20090806
LFUN_GRAPHICS_RELOAD, // vfr 20090810
LFUN_SCREEN_SHOW_CURSOR, // vfr, 20090325
+ LFUN_SPELLING_ADD, // spitz 20100118
// 345
+ LFUN_SPELLING_IGNORE, // spitz 20100118
LFUN_LASTACTION // end of the table
};
* \endvar
*/
{ LFUN_WORD_LOWCASE, "word-lowcase", Noop, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_SPELLING_ADD
+ * \li Action: Add the word under the cursor to the respective
+ * spell checker dictionary.
+ * \li Syntax: spelling-add [<STRING>] [<LANG>]
+ * \li Params: <WORD>: word to add
+ <LANG>: language code (see file languages)
+ * \li Origin: JSpitzm, 18 Jan 2010
+ * \endvar
+ */
+ { LFUN_SPELLING_ADD, "spelling-add", ReadOnly, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_SPELLING_IGNORE
+ * \li Action: Let the spell checker ignore the word under the cursor
+ * in the current session for the given language.
+ * \li Syntax: spelling-ignore [<WORD>] [<LANG>]
+ * \li Params: <WORD>: word to ignore
+ <LANG>: language code (see file languages)
+ * \li Origin: JSpitzm, 18 Jan 2010
+ * \endvar
+ */
+ { LFUN_SPELLING_IGNORE, "spelling-ignore", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_THESAURUS_ENTRY
* \li Action: Look up thesaurus entries with respect to the word under the cursor.
#include "LyXRC.h"
#include "Paragraph.h"
#include "ParagraphParameters.h"
+#include "SpellChecker.h"
#include "TextClass.h"
#include "TextMetrics.h"
#include "VSpace.h"
+#include "WordLangTuple.h"
#include "frontends/Application.h"
#include "frontends/Clipboard.h"
break;
}
+ case LFUN_SPELLING_ADD: {
+ docstring word = from_utf8(cmd.getArg(0));
+ string code;
+ string variety;
+ if (word.empty()) {
+ word = cur.selectionAsString(false);
+ // FIXME
+ if (word.size() > 100 || word.empty()) {
+ // Get word or selection
+ selectWordWhenUnderCursor(cur, WHOLE_WORD);
+ word = cur.selectionAsString(false);
+ }
+ code = cur.getFont().language()->code();
+ variety = cur.getFont().language()->variety();
+ } else
+ variety = split(cmd.getArg(1), code, '-');
+ WordLangTuple wl(word, code, variety);
+ theSpellChecker()->insert(wl);
+ break;
+ }
+
+ case LFUN_SPELLING_IGNORE: {
+ docstring word = from_utf8(cmd.getArg(0));
+ string code;
+ string variety;
+ if (word.empty()) {
+ word = cur.selectionAsString(false);
+ // FIXME
+ if (word.size() > 100 || word.empty()) {
+ // Get word or selection
+ selectWordWhenUnderCursor(cur, WHOLE_WORD);
+ word = cur.selectionAsString(false);
+ }
+ code = cur.getFont().language()->code();
+ variety = cur.getFont().language()->variety();
+ } else
+ variety = split(cmd.getArg(1), code, '-');
+ WordLangTuple wl(word, code, variety);
+ theSpellChecker()->accept(wl);
+ break;
+ }
+
case LFUN_PARAGRAPH_PARAMS_APPLY: {
// Given data, an encoding of the ParagraphParameters
// generated in the Paragraph dialog, this function sets
case LFUN_BREAK_PARAGRAPH:
enable = cur.inset().getLayout().isMultiPar();
break;
+
+ case LFUN_SPELLING_ADD:
+ case LFUN_SPELLING_IGNORE:
+ enable = theSpellChecker();
+ break;
case LFUN_WORD_DELETE_FORWARD:
case LFUN_WORD_DELETE_BACKWARD:
}
if (i >= 10)
add(item);
+ if (i > 0)
+ add(MenuItem(MenuItem::Separator));
+ docstring arg = wl.word() + " " + from_ascii(wl.lang_code());
+ if (!wl.lang_variety().empty())
+ arg += from_ascii("-") + from_ascii(wl.lang_variety());
+ add(MenuItem(MenuItem::Command, qt_("Add to personal dictionary|c"),
+ FuncRequest(LFUN_SPELLING_ADD, arg)));
+ add(MenuItem(MenuItem::Command, qt_("Ignore all|I"),
+ FuncRequest(LFUN_SPELLING_IGNORE, arg)));
+
}