X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyX.cpp;h=0c8234d9618e177f01abe99879e453fa15183fe7;hb=021f51e19b3751f8f15d8bd89f7aa6a109624b29;hp=ebfedd1b81b92ed2b7236412275c79c0b30ad92c;hpb=4daf7b5dfc3ee2372124a75437d17fe9cd5c5f08;p=lyx.git diff --git a/src/LyX.cpp b/src/LyX.cpp index ebfedd1b81..0c8234d961 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_; }; /// @@ -370,6 +369,9 @@ void LyX::prepareExit() cap::clearCutStack(); cap::clearSelection(); + // Write the index file of the converter cache + ConverterCache::get().writeIndex(); + // close buffers first pimpl_->buffer_list_.closeAll(); @@ -748,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 @@ -761,9 +763,7 @@ bool LyX::init() pimpl_->toplevel_keymap_.read("site"); pimpl_->toplevel_keymap_.read(lyxrc.bind_file); // load user bind file user.bind - pimpl_->toplevel_keymap_.read("user"); - - pimpl_->lyxfunc_.initKeySequences(&pimpl_->toplevel_keymap_); + pimpl_->toplevel_keymap_.read("user", 0, KeyMap::MissingOK); if (lyxerr.debugging(Debug::LYXRC)) lyxrc.print(); @@ -981,10 +981,11 @@ int parse_help(string const &, string const &, string &) " where fmt is the export format of choice.\n" " Look on Tools->Preferences->File formats->Format\n" " to get an idea which parameters should be passed.\n" - " Note that the order of -e and -x switches matters." + " Note that the order of -e and -x switches matters.\n" "\t-i [--import] fmt file.xxx\n" " where fmt is the import format of choice\n" " and file.xxx is the file to be imported.\n" + "\t--batch execute commands and exit\n" "\t-version summarize version and build info\n" "Check the LyX man page for more details.")) << endl; exit(0); @@ -1079,6 +1080,13 @@ int parse_geometry(string const & arg1, string const &, string &) } +int parse_batch(string const &, string const &, string &) +{ + use_gui = false; + return 0; +} + + } // namespace anon @@ -1100,6 +1108,7 @@ void LyX::easyParse(int & argc, char * argv[]) cmdmap["-i"] = parse_import; cmdmap["--import"] = parse_import; cmdmap["-geometry"] = parse_geometry; + cmdmap["--batch"] = parse_batch; for (int i = 1; i < argc; ++i) { map::const_iterator it @@ -1263,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