mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Minimal support for hunspell. Spellchecking works but not suggestion, at least on Win/MSVC.
There are two new rc preference: * spellchecker: can now be "aspell" or "hunspell", this is selectable in the SpellChecker preference dialog * hunspelldir_path: needed for hunspell dictionaries which are defined to be in a fixed location. This can be modified in the path preference dialog. The SpellChecker classes could be instanciated on the fly whenerver they are needed if we want that. Please test and help me finish this hunspell integration... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30927 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ad0f2a7dff
commit
21daab357b
@ -15,20 +15,21 @@
|
|||||||
#include "LyXRC.h"
|
#include "LyXRC.h"
|
||||||
#include "WordLangTuple.h"
|
#include "WordLangTuple.h"
|
||||||
|
|
||||||
#include "support/lassert.h"
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
#include "support/docstring_list.h"
|
#include "support/docstring_list.h"
|
||||||
|
#include "support/FileName.h"
|
||||||
|
#include "support/gettext.h"
|
||||||
|
#include "support/lassert.h"
|
||||||
|
#include "support/os.h"
|
||||||
|
|
||||||
#include <hunspell/hunspell.hxx>
|
#include <hunspell/hunspell.hxx>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// FIXME (Abdel): I still got linking problems but if anybody wants
|
|
||||||
// to try, defines this to 1.
|
|
||||||
#define TRY_HUNSPELL 0
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace lyx::support;
|
||||||
|
using namespace lyx::support::os;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
@ -54,24 +55,40 @@ struct HunspellChecker::Private
|
|||||||
|
|
||||||
HunspellChecker::Private::~Private()
|
HunspellChecker::Private::~Private()
|
||||||
{
|
{
|
||||||
#if TRY_HUNSPELL
|
|
||||||
Spellers::iterator it = spellers_.begin();
|
Spellers::iterator it = spellers_.begin();
|
||||||
Spellers::iterator end = spellers_.end();
|
Spellers::iterator end = spellers_.end();
|
||||||
|
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Hunspell * HunspellChecker::Private::addSpeller(string const & lang)
|
Hunspell * HunspellChecker::Private::addSpeller(string const & lang)
|
||||||
{
|
{
|
||||||
// FIXME: not implemented!
|
string hunspell_path = external_path(lyxrc.hunspelldir_path);
|
||||||
|
LYXERR(Debug::FILES, "hunspell path: " << hunspell_path);
|
||||||
|
if (hunspell_path.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
// FIXME: We should we indicate somehow that this language is not
|
hunspell_path += "/" + lang;
|
||||||
// supported.
|
// replace '_' with '-' as this is the convention used by hunspell.
|
||||||
return 0;
|
hunspell_path[hunspell_path.size() - 3] = '-';
|
||||||
|
FileName const affix(hunspell_path + ".aff");
|
||||||
|
FileName const dict(hunspell_path + ".dic");
|
||||||
|
if (!affix.isReadableFile()) {
|
||||||
|
// FIXME: We should indicate somehow that this language is not
|
||||||
|
// supported.
|
||||||
|
LYXERR(Debug::FILES, "Hunspell affix file " << affix << " does not exist");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!dict.isReadableFile()) {
|
||||||
|
LYXERR(Debug::FILES, "Hunspell dictionary file " << dict << " does not exist");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Hunspell * h = new Hunspell(affix.absFilename().c_str(), dict.absFilename().c_str());
|
||||||
|
spellers_[lang] = h;
|
||||||
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -99,31 +116,33 @@ HunspellChecker::~HunspellChecker()
|
|||||||
SpellChecker::Result HunspellChecker::check(WordLangTuple const & wl)
|
SpellChecker::Result HunspellChecker::check(WordLangTuple const & wl)
|
||||||
{
|
{
|
||||||
string const word_to_check = to_utf8(wl.word());
|
string const word_to_check = to_utf8(wl.word());
|
||||||
#if TRY_HUNSPELL
|
|
||||||
Hunspell * h = d->speller(wl.lang_code());
|
Hunspell * h = d->speller(wl.lang_code());
|
||||||
|
if (!h)
|
||||||
|
return OK;
|
||||||
int info;
|
int info;
|
||||||
if (h->spell(word_to_check.c_str(), &info))
|
if (h->spell(word_to_check.c_str(), &info))
|
||||||
return OK;
|
return OK;
|
||||||
// FIXME: What to do with that?
|
|
||||||
switch (info) {
|
if (info & SPELL_COMPOUND) {
|
||||||
case SPELL_COMPOUND:
|
// FIXME: What to do with that?
|
||||||
case SPELL_FORBIDDEN:
|
LYXERR(Debug::FILES, "Hunspell compound word found " << word_to_check);
|
||||||
default:
|
|
||||||
return UNKNOWN_WORD;
|
|
||||||
}
|
}
|
||||||
|
if (info & SPELL_FORBIDDEN) {
|
||||||
|
// FIXME: What to do with that?
|
||||||
|
LYXERR(Debug::FILES, "Hunspell explicit forbidden word found " << word_to_check);
|
||||||
|
}
|
||||||
|
|
||||||
return UNKNOWN_WORD;
|
return UNKNOWN_WORD;
|
||||||
#endif
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HunspellChecker::insert(WordLangTuple const & wl)
|
void HunspellChecker::insert(WordLangTuple const & wl)
|
||||||
{
|
{
|
||||||
string const word_to_check = to_utf8(wl.word());
|
string const word_to_check = to_utf8(wl.word());
|
||||||
#if TRY_HUNSPELL
|
|
||||||
Hunspell * h = d->speller(wl.lang_code());
|
Hunspell * h = d->speller(wl.lang_code());
|
||||||
|
if (!h)
|
||||||
|
return;
|
||||||
h->add(word_to_check.c_str());
|
h->add(word_to_check.c_str());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,14 +157,18 @@ void HunspellChecker::suggest(WordLangTuple const & wl,
|
|||||||
{
|
{
|
||||||
suggestions.clear();
|
suggestions.clear();
|
||||||
string const word_to_check = to_utf8(wl.word());
|
string const word_to_check = to_utf8(wl.word());
|
||||||
#if TRY_HUNSPELL
|
|
||||||
Hunspell * h = d->speller(wl.lang_code());
|
Hunspell * h = d->speller(wl.lang_code());
|
||||||
|
if (!h)
|
||||||
|
return;
|
||||||
char *** suggestion_list = 0;
|
char *** suggestion_list = 0;
|
||||||
|
|
||||||
|
// FIXME: Hunspell::suggest() crashes on Win/MSVC9
|
||||||
|
return;
|
||||||
|
|
||||||
int const suggestion_number = h->suggest(suggestion_list, word_to_check.c_str());
|
int const suggestion_number = h->suggest(suggestion_list, word_to_check.c_str());
|
||||||
if (suggestion_number == 0)
|
if (suggestion_number == 0)
|
||||||
return;
|
return;
|
||||||
h->free_list(suggestion_list, suggestion_number);
|
h->free_list(suggestion_list, suggestion_number);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
37
src/LyX.cpp
37
src/LyX.cpp
@ -29,6 +29,7 @@
|
|||||||
#include "ErrorList.h"
|
#include "ErrorList.h"
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "FuncStatus.h"
|
#include "FuncStatus.h"
|
||||||
|
#include "HunspellChecker.h"
|
||||||
#include "KeyMap.h"
|
#include "KeyMap.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "LayoutFile.h"
|
#include "LayoutFile.h"
|
||||||
@ -118,22 +119,15 @@ void reconfigureUserLyXDir()
|
|||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
/// The main application class private implementation.
|
/// The main application class private implementation.
|
||||||
struct LyX::Impl
|
struct LyX::Impl
|
||||||
{
|
{
|
||||||
Impl()
|
Impl() : spell_checker_(0), aspell_checker_(0), hunspell_checker_(0)
|
||||||
{
|
{
|
||||||
// Set the default User Interface language as soon as possible.
|
// Set the default User Interface language as soon as possible.
|
||||||
// The language used will be derived from the environment
|
// The language used will be derived from the environment
|
||||||
// variables.
|
// variables.
|
||||||
messages_["GUI"] = Messages();
|
messages_["GUI"] = Messages();
|
||||||
|
|
||||||
#if defined(USE_ASPELL)
|
|
||||||
spell_checker_ = new AspellChecker();
|
|
||||||
#else
|
|
||||||
spell_checker_ = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~Impl()
|
~Impl()
|
||||||
@ -184,6 +178,10 @@ struct LyX::Impl
|
|||||||
graphics::Previews preview_;
|
graphics::Previews preview_;
|
||||||
///
|
///
|
||||||
SpellChecker * spell_checker_;
|
SpellChecker * spell_checker_;
|
||||||
|
///
|
||||||
|
SpellChecker * aspell_checker_;
|
||||||
|
///
|
||||||
|
SpellChecker * hunspell_checker_;
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -228,6 +226,7 @@ LyX::LyX()
|
|||||||
{
|
{
|
||||||
singleton_ = this;
|
singleton_ = this;
|
||||||
pimpl_ = new Impl;
|
pimpl_ = new Impl;
|
||||||
|
setSpellChecker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1278,4 +1277,26 @@ SpellChecker * theSpellChecker()
|
|||||||
return singleton_->pimpl_->spell_checker_;
|
return singleton_->pimpl_->spell_checker_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setSpellChecker()
|
||||||
|
{
|
||||||
|
#if defined(USE_ASPELL)
|
||||||
|
if (lyxrc.spellchecker == "aspell") {
|
||||||
|
if (!singleton_->pimpl_->aspell_checker_)
|
||||||
|
singleton_->pimpl_->aspell_checker_ = new AspellChecker();
|
||||||
|
singleton_->pimpl_->spell_checker_ = singleton_->pimpl_->aspell_checker_;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(USE_HUNSPELL)
|
||||||
|
if (lyxrc.spellchecker == "hunspell") {
|
||||||
|
if (!singleton_->pimpl_->hunspell_checker_)
|
||||||
|
singleton_->pimpl_->hunspell_checker_ = new HunspellChecker();
|
||||||
|
singleton_->pimpl_->spell_checker_ = singleton_->pimpl_->hunspell_checker_;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
singleton_->pimpl_->spell_checker_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -139,6 +139,7 @@ private:
|
|||||||
friend Session & theSession();
|
friend Session & theSession();
|
||||||
friend CmdDef & theTopLevelCmdDef();
|
friend CmdDef & theTopLevelCmdDef();
|
||||||
friend SpellChecker * theSpellChecker();
|
friend SpellChecker * theSpellChecker();
|
||||||
|
friend void setSpellChecker();
|
||||||
friend void setRcGuiLanguage();
|
friend void setRcGuiLanguage();
|
||||||
friend void emergencyCleanup();
|
friend void emergencyCleanup();
|
||||||
friend void execBatchCommands();
|
friend void execBatchCommands();
|
||||||
|
@ -1590,6 +1590,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
actOnUpdatedPrefs(lyxrc_orig, lyxrc);
|
actOnUpdatedPrefs(lyxrc_orig, lyxrc);
|
||||||
|
|
||||||
|
setSpellChecker();
|
||||||
|
|
||||||
theApp()->resetGui();
|
theApp()->resetGui();
|
||||||
|
|
||||||
/// We force the redraw in any case because there might be
|
/// We force the redraw in any case because there might be
|
||||||
@ -1969,6 +1971,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
|||||||
case LyXRC::RC_FONT_ENCODING:
|
case LyXRC::RC_FONT_ENCODING:
|
||||||
case LyXRC::RC_FORMAT:
|
case LyXRC::RC_FORMAT:
|
||||||
case LyXRC::RC_GROUP_LAYOUTS:
|
case LyXRC::RC_GROUP_LAYOUTS:
|
||||||
|
case LyXRC::RC_HUNSPELLDIR_PATH:
|
||||||
case LyXRC::RC_INDEX_ALTERNATIVES:
|
case LyXRC::RC_INDEX_ALTERNATIVES:
|
||||||
case LyXRC::RC_INDEX_COMMAND:
|
case LyXRC::RC_INDEX_COMMAND:
|
||||||
case LyXRC::RC_JBIBTEX_COMMAND:
|
case LyXRC::RC_JBIBTEX_COMMAND:
|
||||||
@ -2036,6 +2039,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
|||||||
case LyXRC::RC_SHOW_BANNER:
|
case LyXRC::RC_SHOW_BANNER:
|
||||||
case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
|
case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
|
||||||
case LyXRC::RC_SPELL_COMMAND:
|
case LyXRC::RC_SPELL_COMMAND:
|
||||||
|
case LyXRC::RC_SPELLCHECKER:
|
||||||
case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
|
case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
|
||||||
case LyXRC::RC_SPLITINDEX_COMMAND:
|
case LyXRC::RC_SPLITINDEX_COMMAND:
|
||||||
case LyXRC::RC_TEMPDIRPATH:
|
case LyXRC::RC_TEMPDIRPATH:
|
||||||
|
@ -99,6 +99,7 @@ LexerKeyword lyxrcTags[] = {
|
|||||||
{ "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
|
{ "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
|
||||||
{ "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
|
{ "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
|
||||||
{ "\\gui_language", LyXRC::RC_GUI_LANGUAGE },
|
{ "\\gui_language", LyXRC::RC_GUI_LANGUAGE },
|
||||||
|
{ "\\hunspelldir_path", LyXRC::RC_HUNSPELLDIR_PATH },
|
||||||
{ "\\index_alternatives", LyXRC::RC_INDEX_ALTERNATIVES },
|
{ "\\index_alternatives", LyXRC::RC_INDEX_ALTERNATIVES },
|
||||||
{ "\\index_command", LyXRC::RC_INDEX_COMMAND },
|
{ "\\index_command", LyXRC::RC_INDEX_COMMAND },
|
||||||
{ "\\input", LyXRC::RC_INPUT },
|
{ "\\input", LyXRC::RC_INPUT },
|
||||||
@ -168,6 +169,7 @@ LexerKeyword lyxrcTags[] = {
|
|||||||
{ "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
|
{ "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
|
||||||
{ "\\spell_command", LyXRC::RC_SPELL_COMMAND },
|
{ "\\spell_command", LyXRC::RC_SPELL_COMMAND },
|
||||||
{ "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
|
{ "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
|
||||||
|
{ "\\spellchecker", LyXRC::RC_SPELLCHECKER },
|
||||||
{ "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
|
{ "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
|
||||||
{ "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
|
{ "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
|
||||||
{ "\\template_path", LyXRC::RC_TEMPLATEPATH },
|
{ "\\template_path", LyXRC::RC_TEMPLATEPATH },
|
||||||
@ -269,6 +271,7 @@ void LyXRC::setDefaults()
|
|||||||
backupdir_path.erase();
|
backupdir_path.erase();
|
||||||
display_graphics = true;
|
display_graphics = true;
|
||||||
// Spellchecker settings:
|
// Spellchecker settings:
|
||||||
|
spellchecker = "aspell";
|
||||||
spellchecker_accept_compound = false;
|
spellchecker_accept_compound = false;
|
||||||
spellcheck_continuously = false;
|
spellcheck_continuously = false;
|
||||||
use_kbmap = false;
|
use_kbmap = false;
|
||||||
@ -704,6 +707,13 @@ int LyXRC::read(Lexer & lexrc)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RC_HUNSPELLDIR_PATH:
|
||||||
|
if (lexrc.next()) {
|
||||||
|
hunspelldir_path = os::internal_path(lexrc.getString());
|
||||||
|
hunspelldir_path = expandPath(hunspelldir_path);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case RC_USELASTFILEPOS:
|
case RC_USELASTFILEPOS:
|
||||||
lexrc >> use_lastfilepos;
|
lexrc >> use_lastfilepos;
|
||||||
break;
|
break;
|
||||||
@ -875,6 +885,9 @@ int LyXRC::read(Lexer & lexrc)
|
|||||||
case RC_USE_PIXMAP_CACHE:
|
case RC_USE_PIXMAP_CACHE:
|
||||||
lexrc >> use_pixmap_cache;
|
lexrc >> use_pixmap_cache;
|
||||||
break;
|
break;
|
||||||
|
case RC_SPELLCHECKER:
|
||||||
|
lexrc >> spellchecker;
|
||||||
|
break;
|
||||||
case RC_ALT_LANG:
|
case RC_ALT_LANG:
|
||||||
lexrc >> spellchecker_alt_lang;
|
lexrc >> spellchecker_alt_lang;
|
||||||
break;
|
break;
|
||||||
@ -2132,6 +2145,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
|||||||
}
|
}
|
||||||
if (tag != RC_LAST)
|
if (tag != RC_LAST)
|
||||||
break;
|
break;
|
||||||
|
case RC_HUNSPELLDIR_PATH:
|
||||||
|
if (ignore_system_lyxrc ||
|
||||||
|
hunspelldir_path != system_lyxrc.hunspelldir_path) {
|
||||||
|
string const path = os::external_path(hunspelldir_path);
|
||||||
|
os << "\\hunspelldir_path \"" << path << "\"\n";
|
||||||
|
}
|
||||||
|
if (tag != RC_LAST)
|
||||||
|
break;
|
||||||
case RC_USETEMPDIR:
|
case RC_USETEMPDIR:
|
||||||
if (tag != RC_LAST)
|
if (tag != RC_LAST)
|
||||||
break;
|
break;
|
||||||
@ -2242,6 +2263,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
|||||||
if (tag != RC_LAST)
|
if (tag != RC_LAST)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RC_SPELLCHECKER:
|
||||||
|
if (ignore_system_lyxrc ||
|
||||||
|
spellchecker != system_lyxrc.spellchecker) {
|
||||||
|
os << "\\spellchecker " << spellchecker << '\n';
|
||||||
|
}
|
||||||
|
if (tag != RC_LAST)
|
||||||
|
break;
|
||||||
|
|
||||||
case RC_SPELLCHECK_CONTINUOUSLY:
|
case RC_SPELLCHECK_CONTINUOUSLY:
|
||||||
if (ignore_system_lyxrc ||
|
if (ignore_system_lyxrc ||
|
||||||
spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
|
spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
RC_GEOMETRY_SESSION,
|
RC_GEOMETRY_SESSION,
|
||||||
RC_GROUP_LAYOUTS,
|
RC_GROUP_LAYOUTS,
|
||||||
RC_GUI_LANGUAGE,
|
RC_GUI_LANGUAGE,
|
||||||
|
RC_HUNSPELLDIR_PATH,
|
||||||
RC_INDEX_ALTERNATIVES,
|
RC_INDEX_ALTERNATIVES,
|
||||||
RC_INDEX_COMMAND,
|
RC_INDEX_COMMAND,
|
||||||
RC_INPUT,
|
RC_INPUT,
|
||||||
@ -153,6 +154,7 @@ public:
|
|||||||
RC_SORT_LAYOUTS,
|
RC_SORT_LAYOUTS,
|
||||||
RC_SPELL_COMMAND,
|
RC_SPELL_COMMAND,
|
||||||
RC_SPELLCHECK_CONTINUOUSLY,
|
RC_SPELLCHECK_CONTINUOUSLY,
|
||||||
|
RC_SPELLCHECKER,
|
||||||
RC_SPLITINDEX_COMMAND,
|
RC_SPLITINDEX_COMMAND,
|
||||||
RC_TEMPDIRPATH,
|
RC_TEMPDIRPATH,
|
||||||
RC_TEMPLATEPATH,
|
RC_TEMPLATEPATH,
|
||||||
@ -276,6 +278,8 @@ public:
|
|||||||
///
|
///
|
||||||
std::string thesaurusdir_path;
|
std::string thesaurusdir_path;
|
||||||
///
|
///
|
||||||
|
std::string hunspelldir_path;
|
||||||
|
///
|
||||||
bool auto_region_delete;
|
bool auto_region_delete;
|
||||||
/// flag telling whether lastfiles should be checked for existance
|
/// flag telling whether lastfiles should be checked for existance
|
||||||
bool auto_reset_options;
|
bool auto_reset_options;
|
||||||
@ -328,6 +332,8 @@ public:
|
|||||||
bool use_tooltip;
|
bool use_tooltip;
|
||||||
/// Use pixmap cache?
|
/// Use pixmap cache?
|
||||||
bool use_pixmap_cache;
|
bool use_pixmap_cache;
|
||||||
|
/// Spellchecker engine: aspell, hunspell, etc
|
||||||
|
std::string spellchecker;
|
||||||
/// Alternate language for spellchecker
|
/// Alternate language for spellchecker
|
||||||
std::string spellchecker_alt_lang;
|
std::string spellchecker_alt_lang;
|
||||||
/// Escape characters
|
/// Escape characters
|
||||||
|
@ -64,6 +64,10 @@ public:
|
|||||||
/// Implemented in LyX.cpp
|
/// Implemented in LyX.cpp
|
||||||
SpellChecker * theSpellChecker();
|
SpellChecker * theSpellChecker();
|
||||||
|
|
||||||
|
/// Set the singleton SpellChecker engine.
|
||||||
|
/// Implemented in LyX.cpp
|
||||||
|
void setSpellChecker();
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // SPELL_BASE_H
|
#endif // SPELL_BASE_H
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "PanelStack.h"
|
#include "PanelStack.h"
|
||||||
#include "paper.h"
|
#include "paper.h"
|
||||||
#include "Session.h"
|
#include "Session.h"
|
||||||
|
#include "SpellChecker.h"
|
||||||
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
@ -1129,6 +1130,7 @@ PrefPaths::PrefPaths(GuiPreferences * form)
|
|||||||
connect(workingDirPB, SIGNAL(clicked()), this, SLOT(selectWorkingdir()));
|
connect(workingDirPB, SIGNAL(clicked()), this, SLOT(selectWorkingdir()));
|
||||||
connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(selectLyxPipe()));
|
connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(selectLyxPipe()));
|
||||||
connect(thesaurusDirPB, SIGNAL(clicked()), this, SLOT(selectThesaurusdir()));
|
connect(thesaurusDirPB, SIGNAL(clicked()), this, SLOT(selectThesaurusdir()));
|
||||||
|
connect(hunspellDirPB, SIGNAL(clicked()), this, SLOT(selectHunspelldir()));
|
||||||
connect(workingDirED, SIGNAL(textChanged(QString)),
|
connect(workingDirED, SIGNAL(textChanged(QString)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
connect(exampleDirED, SIGNAL(textChanged(QString)),
|
connect(exampleDirED, SIGNAL(textChanged(QString)),
|
||||||
@ -1156,6 +1158,7 @@ void PrefPaths::apply(LyXRC & rc) const
|
|||||||
rc.backupdir_path = internal_path(fromqstr(backupDirED->text()));
|
rc.backupdir_path = internal_path(fromqstr(backupDirED->text()));
|
||||||
rc.tempdir_path = internal_path(fromqstr(tempDirED->text()));
|
rc.tempdir_path = internal_path(fromqstr(tempDirED->text()));
|
||||||
rc.thesaurusdir_path = internal_path(fromqstr(thesaurusDirED->text()));
|
rc.thesaurusdir_path = internal_path(fromqstr(thesaurusDirED->text()));
|
||||||
|
rc.hunspelldir_path = internal_path(fromqstr(hunspellDirED->text()));
|
||||||
rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
|
rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
|
||||||
// FIXME: should be a checkbox only
|
// FIXME: should be a checkbox only
|
||||||
rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
|
rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
|
||||||
@ -1170,6 +1173,7 @@ void PrefPaths::update(LyXRC const & rc)
|
|||||||
backupDirED->setText(toqstr(external_path(rc.backupdir_path)));
|
backupDirED->setText(toqstr(external_path(rc.backupdir_path)));
|
||||||
tempDirED->setText(toqstr(external_path(rc.tempdir_path)));
|
tempDirED->setText(toqstr(external_path(rc.tempdir_path)));
|
||||||
thesaurusDirED->setText(toqstr(external_path(rc.thesaurusdir_path)));
|
thesaurusDirED->setText(toqstr(external_path(rc.thesaurusdir_path)));
|
||||||
|
hunspellDirED->setText(toqstr(external_path(rc.hunspelldir_path)));
|
||||||
pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
|
pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
|
||||||
// FIXME: should be a checkbox only
|
// FIXME: should be a checkbox only
|
||||||
lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
|
lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
|
||||||
@ -1230,6 +1234,15 @@ void PrefPaths::selectThesaurusdir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PrefPaths::selectHunspelldir()
|
||||||
|
{
|
||||||
|
QString file = browseDir(internalPath(hunspellDirED->text()),
|
||||||
|
qt_("Set the path to the Hunspell dictionaries"));
|
||||||
|
if (!file.isEmpty())
|
||||||
|
hunspellDirED->setText(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrefPaths::selectLyxPipe()
|
void PrefPaths::selectLyxPipe()
|
||||||
{
|
{
|
||||||
QString file = form_->browse(internalPath(lyxserverDirED->text()),
|
QString file = form_->browse(internalPath(lyxserverDirED->text()),
|
||||||
@ -1250,6 +1263,11 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
|
|||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
spellcheckerCB->addItem("aspell");
|
||||||
|
spellcheckerCB->addItem("hunspell");
|
||||||
|
|
||||||
|
connect(spellcheckerCB, SIGNAL(currentIndexChanged(int)),
|
||||||
|
this, SIGNAL(changed()));
|
||||||
connect(altLanguageED, SIGNAL(textChanged(QString)),
|
connect(altLanguageED, SIGNAL(textChanged(QString)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
connect(escapeCharactersED, SIGNAL(textChanged(QString)),
|
connect(escapeCharactersED, SIGNAL(textChanged(QString)),
|
||||||
@ -1263,6 +1281,7 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
|
|||||||
|
|
||||||
void PrefSpellchecker::apply(LyXRC & rc) const
|
void PrefSpellchecker::apply(LyXRC & rc) const
|
||||||
{
|
{
|
||||||
|
rc.spellchecker = fromqstr(spellcheckerCB->currentText());
|
||||||
rc.spellchecker_alt_lang = fromqstr(altLanguageED->text());
|
rc.spellchecker_alt_lang = fromqstr(altLanguageED->text());
|
||||||
rc.spellchecker_esc_chars = fromqstr(escapeCharactersED->text());
|
rc.spellchecker_esc_chars = fromqstr(escapeCharactersED->text());
|
||||||
rc.spellchecker_accept_compound = compoundWordCB->isChecked();
|
rc.spellchecker_accept_compound = compoundWordCB->isChecked();
|
||||||
@ -1272,6 +1291,8 @@ void PrefSpellchecker::apply(LyXRC & rc) const
|
|||||||
|
|
||||||
void PrefSpellchecker::update(LyXRC const & rc)
|
void PrefSpellchecker::update(LyXRC const & rc)
|
||||||
{
|
{
|
||||||
|
spellcheckerCB->setCurrentIndex(spellcheckerCB->findText(
|
||||||
|
toqstr(rc.spellchecker)));
|
||||||
altLanguageED->setText(toqstr(rc.spellchecker_alt_lang));
|
altLanguageED->setText(toqstr(rc.spellchecker_alt_lang));
|
||||||
escapeCharactersED->setText(toqstr(rc.spellchecker_esc_chars));
|
escapeCharactersED->setText(toqstr(rc.spellchecker_esc_chars));
|
||||||
compoundWordCB->setChecked(rc.spellchecker_accept_compound);
|
compoundWordCB->setChecked(rc.spellchecker_accept_compound);
|
||||||
|
@ -300,6 +300,7 @@ private Q_SLOTS:
|
|||||||
void selectBackupdir();
|
void selectBackupdir();
|
||||||
void selectWorkingdir();
|
void selectWorkingdir();
|
||||||
void selectThesaurusdir();
|
void selectThesaurusdir();
|
||||||
|
void selectHunspelldir();
|
||||||
void selectLyxPipe();
|
void selectLyxPipe();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="8" column="0" colspan="3" >
|
<item row="11" column="0" colspan="3" >
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<property name="sizeType" >
|
<property name="sizeType" >
|
||||||
<enum>QSizePolicy::Expanding</enum>
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>329</width>
|
<width>329</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" >
|
<item row="10" column="0" >
|
||||||
<widget class="QLabel" name="pathPrefixLA" >
|
<widget class="QLabel" name="pathPrefixLA" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&PATH prefix:</string>
|
<string>&PATH prefix:</string>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1" colspan="2" >
|
<item row="10" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="pathPrefixED" />
|
<widget class="QLineEdit" name="pathPrefixED" />
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="2" >
|
<item row="6" column="2" >
|
||||||
@ -209,6 +209,29 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="8" column="0" >
|
||||||
|
<widget class="QLabel" name="hunspellDirLA" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Hunspell dictionaries:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>thesaurusDirED</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="1" >
|
||||||
|
<widget class="QLineEdit" name="hunspellDirED" />
|
||||||
|
</item>
|
||||||
|
<item row="8" column="2" >
|
||||||
|
<widget class="QPushButton" name="hunspellDirPB" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Browse...</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0" >
|
<item row="1" column="0" >
|
||||||
<widget class="QLabel" name="altLanguageLA" >
|
<widget class="QLabel" name="altLanguageLA" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Al&ternative language:</string>
|
<string>Al&ternative language:</string>
|
||||||
@ -29,14 +29,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="1" column="1" >
|
||||||
<widget class="QLineEdit" name="altLanguageED" >
|
<widget class="QLineEdit" name="altLanguageED" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Override the language used for the spellchecker</string>
|
<string>Override the language used for the spellchecker</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="2" column="0" >
|
||||||
<widget class="QLabel" name="escapeCharactersLA" >
|
<widget class="QLabel" name="escapeCharactersLA" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Escape characters:</string>
|
<string>&Escape characters:</string>
|
||||||
@ -46,14 +46,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="2" column="1" >
|
||||||
<widget class="QLineEdit" name="escapeCharactersED" >
|
<widget class="QLineEdit" name="escapeCharactersED" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>The characters inserted here are ignored by the spellchecker. </string>
|
<string>The characters inserted here are ignored by the spellchecker. </string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="3" >
|
<item row="3" column="3" >
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<property name="sizeType" >
|
<property name="sizeType" >
|
||||||
<enum>QSizePolicy::Expanding</enum>
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>41</width>
|
<width>41</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="3" >
|
<item row="5" column="0" colspan="3" >
|
||||||
<widget class="QCheckBox" name="spellcheckContinuouslyCB" >
|
<widget class="QCheckBox" name="spellcheckContinuouslyCB" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Mark misspelled words with a wavy underline.</string>
|
<string>Mark misspelled words with a wavy underline.</string>
|
||||||
@ -79,7 +79,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="4" >
|
<item row="6" column="0" colspan="4" >
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -87,7 +87,7 @@
|
|||||||
<property name="sizeType" >
|
<property name="sizeType" >
|
||||||
<enum>QSizePolicy::Expanding</enum>
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
@ -95,7 +95,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item rowspan="2" row="2" column="0" colspan="4" >
|
<item rowspan="2" row="3" column="0" colspan="4" >
|
||||||
<widget class="QCheckBox" name="compoundWordCB" >
|
<widget class="QCheckBox" name="compoundWordCB" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Accept words such as "diskdrive"</string>
|
<string>Accept words such as "diskdrive"</string>
|
||||||
@ -105,6 +105,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QComboBox" name="spellcheckerCB" />
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<widget class="QLabel" name="spellcheckerLA" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Spellchecker engine:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>altLanguageED</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
Loading…
Reference in New Issue
Block a user