X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyX.cpp;h=0c8234d9618e177f01abe99879e453fa15183fe7;hb=021f51e19b3751f8f15d8bd89f7aa6a109624b29;hp=55cd35ceb5b43c87a5d92dd3f2dff86c0fbb269b;hpb=0d626b0008a3fca0e6ef96a42f2054e78eefeede;p=lyx.git diff --git a/src/LyX.cpp b/src/LyX.cpp index 55cd35ceb5..0c8234d961 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -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 AspellChecker(); -#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(); @@ -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