X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyX.cpp;h=7b5c07636f00556e3b9fa21e5d44ecc3a9424b2c;hb=0a7705a6736a85c3c751f7b4e9998833cdb71fc9;hp=8acdb53a788f758525931854deab862bad7c7141;hpb=2d632d0c6587fce50dcb490c325349e44ce4ed4a;p=lyx.git diff --git a/src/LyX.cpp b/src/LyX.cpp index 8acdb53a78..7b5c07636f 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -17,7 +17,7 @@ #include "LyX.h" -#include "ASpell_local.h" +#include "AspellChecker.h" #include "Buffer.h" #include "BufferList.h" #include "CmdDef.h" @@ -29,6 +29,7 @@ #include "ErrorList.h" #include "Format.h" #include "FuncStatus.h" +#include "HunspellChecker.h" #include "KeyMap.h" #include "Language.h" #include "LayoutFile.h" @@ -118,27 +119,21 @@ void reconfigureUserLyXDir() } // namespace anon - /// The main application class private implementation. struct LyX::Impl { - Impl() + Impl() : spell_checker_(0), aspell_checker_(0), hunspell_checker_(0) { // Set the default User Interface language as soon as possible. // The language used will be derived from the environment // variables. messages_["GUI"] = Messages(); - -#if defined(USE_ASPELL) - spell_checker_ = new ASpell(); -#else - spell_checker_ = 0; -#endif } ~Impl() { - delete spell_checker_; + delete aspell_checker_; + delete hunspell_checker_; } /// our function handler @@ -184,6 +179,10 @@ struct LyX::Impl graphics::Previews preview_; /// SpellChecker * spell_checker_; + /// + SpellChecker * aspell_checker_; + /// + SpellChecker * hunspell_checker_; }; /// @@ -751,7 +750,7 @@ bool LyX::init() if (!LyXSetStyle()) return false; //...and the modules - moduleList.read(); + theModuleList.read(); // read keymap and ui files in batch mode as well // because InsetInfo needs to know these to produce @@ -766,8 +765,6 @@ bool LyX::init() // load user bind file user.bind pimpl_->toplevel_keymap_.read("user", 0, KeyMap::MissingOK); - pimpl_->lyxfunc_.initKeySequences(&pimpl_->toplevel_keymap_); - if (lyxerr.debugging(Debug::LYXRC)) lyxrc.print(); @@ -960,7 +957,7 @@ int parse_dbg(string const & arg, string const &, string &) } lyxerr << to_utf8(bformat(_("Setting debug level to %1$s"), from_utf8(arg))) << endl; - lyxerr.level(Debug::value(arg)); + lyxerr.setLevel(Debug::value(arg)); Debug::showLevel(lyxerr, lyxerr.level()); return 1; } @@ -1275,7 +1272,31 @@ CmdDef & theTopLevelCmdDef() SpellChecker * theSpellChecker() { + if (!singleton_->pimpl_->spell_checker_) + setSpellChecker(); 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