]> git.lyx.org Git - lyx.git/blobdiff - src/LyX.cpp
GuiDocument.cpp: remove unneeded conversion
[lyx.git] / src / LyX.cpp
index 1c0609331c64129eab055dcbae0e82807f8cc628..3445dfdc3721494a0f7cdf7dcf3179d5182682ac 100644 (file)
@@ -4,10 +4,10 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Alfredo Braunstein
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  * \author Jean-Marc Lasgouttes
  * \author John Levon
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include "LyX.h"
 
-#include "LayoutFile.h"
+#include "ASpell_local.h"
 #include "Buffer.h"
 #include "BufferList.h"
 #include "CmdDef.h"
-#include "Color.h"
+#include "ColorSet.h"
 #include "ConverterCache.h"
 #include "Converter.h"
 #include "CutAndPaste.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();
@@ -520,8 +536,7 @@ void LyX::execCommands()
                }
                // clear this list to save a few bytes of RAM
                pimpl_->files_to_load_.clear();
-       }
-       else
+       } else
                pimpl_->application_->restoreGuiSession();
 
        // Execute batch commands if available
@@ -544,7 +559,7 @@ The SIGHUP signal does not exist on Windows and does not need to be handled.
 
 Windows handles SIGFPE and SIGSEGV signals as expected.
 
-Cntl+C interrupts (mapped to SIGINT by Windows' POSIX compatability layer)
+Ctrl+C interrupts (mapped to SIGINT by Windows' POSIX compatability layer)
 cause a new thread to be spawned. This may well result in unexpected
 behaviour by the single-threaded LyX.
 
@@ -733,7 +748,7 @@ bool LyX::init()
        if (!LyXSetStyle())
                return false;
        //...and the modules
-       moduleList.load();
+       moduleList.read();
 
        // read keymap and ui files in batch mode as well
        // because InsetInfo needs to know these to produce
@@ -966,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);
@@ -1057,13 +1074,16 @@ int parse_import(string const & type, string const & file, string & batch)
 int parse_geometry(string const & arg1, string const &, string &)
 {
        geometryArg = arg1;
-#if defined(_WIN32) || (defined(__CYGWIN__) && defined(X_DISPLAY_MISSING))
-       // remove also the arg
-       return 1;
-#else
-       // don't remove "-geometry"
+       // don't remove "-geometry", it will be pruned out later in the
+       // frontend if need be.
        return -1;
-#endif
+}
+
+
+int parse_batch(string const &, string const &, string &) 
+{
+       use_gui = false;
+       return 0;
 }
 
 
@@ -1088,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
@@ -1248,4 +1269,10 @@ CmdDef & theTopLevelCmdDef()
        return singleton_->pimpl_->toplevel_cmddef_;
 }
 
+
+SpellChecker * theSpellChecker()
+{
+       return singleton_->pimpl_->spell_checker_;
+}
+
 } // namespace lyx