]> git.lyx.org Git - lyx.git/blobdiff - src/LyX.cpp
GuiDocument.cpp: remove unneeded conversion
[lyx.git] / src / LyX.cpp
index c056d0310757092e7e8ecdb26a5a7e36d807a7f7..3445dfdc3721494a0f7cdf7dcf3179d5182682ac 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "LyX.h"
 
-#include "LayoutFile.h"
+#include "ASpell_local.h"
 #include "Buffer.h"
 #include "BufferList.h"
 #include "CmdDef.h"
@@ -31,6 +31,7 @@
 #include "FuncStatus.h"
 #include "KeyMap.h"
 #include "Language.h"
+#include "LayoutFile.h"
 #include "Lexer.h"
 #include "LyXAction.h"
 #include "LyXFunc.h"
@@ -127,7 +128,19 @@ struct LyX::Impl
                // 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_;
+       }
+
        /// our function handler
        LyXFunc lyxfunc_;
        ///
@@ -169,6 +182,8 @@ struct LyX::Impl
 
        ///
        graphics::Previews preview_;
+       ///
+       SpellChecker * spell_checker_;
 };
 
 ///
@@ -296,12 +311,13 @@ int LyX::exec(int & argc, char * argv[])
                        Buffer * buf = *I;
                        if (buf != buf->masterBuffer())
                                continue;
-                       bool success = false;
                        vector<string>::const_iterator bcit  = pimpl_->batch_commands.begin();
                        vector<string>::const_iterator bcend = pimpl_->batch_commands.end();
+                       DispatchResult dr;
                        for (; bcit != bcend; bcit++) {
-                               buf->dispatch(*bcit, &success);
-                               final_success |= success;
+                               LYXERR(Debug::ACTION, "Buffer::dispatch: cmd: " << *bcit);
+                               buf->dispatch(*bcit, dr);
+                               final_success |= !dr.error();
                        }
                }
                prepareExit();
@@ -965,9 +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."
                  "\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);
@@ -1062,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
 
 
@@ -1083,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<string, cmd_helper>::const_iterator it
@@ -1243,4 +1269,10 @@ CmdDef & theTopLevelCmdDef()
        return singleton_->pimpl_->toplevel_cmddef_;
 }
 
+
+SpellChecker * theSpellChecker()
+{
+       return singleton_->pimpl_->spell_checker_;
+}
+
 } // namespace lyx