mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
* ADD LFUN_SPELLING_ADD and LFUN_SPELLING_IGNORE (bug 6102).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33089 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c129f0f8b3
commit
3a714c6057
@ -442,7 +442,9 @@ enum FuncCode
|
||||
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
|
||||
};
|
||||
|
@ -980,6 +980,28 @@ void LyXAction::init()
|
||||
* \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.
|
||||
|
@ -42,9 +42,11 @@
|
||||
#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"
|
||||
@ -1996,6 +1998,48 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
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
|
||||
@ -2506,6 +2550,11 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
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:
|
||||
case LFUN_LINE_DELETE:
|
||||
|
@ -741,6 +741,16 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
|
||||
}
|
||||
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)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user