]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_main.C
next step...
[lyx.git] / src / lyx_main.C
index 6993f748a23af0a2c59aa8ffdfda1748d848fb97..b085903939e1c8531b2ff1ba4ce3a2e6610e3f79 100644 (file)
@@ -17,7 +17,7 @@
 #pragma implementation
 #endif
 
-#include "version.h"
+#include <version.h>
 #include "lyx_main.h"
 #include "lyx_gui.h"
 #include "LyXView.h"
@@ -220,7 +220,7 @@ void error_handler(int err_sig)
        signal(SIGSEGV, SIG_DFL);
        signal(SIGTERM, SIG_DFL);
 
-       bufferlist.emergencyWriteAll();
+       LyX::emergencyCleanup();
 
        lyxerr << "Bye." << endl;
        if (err_sig!= SIGHUP && 
@@ -374,7 +374,6 @@ void LyX::init(bool gui)
                system_lyxdir = LYX_DIR;
                path_shown = true;
        }
-
        // Report the system directory if debugging is on
        if (!path_shown)
                lyxerr[Debug::INIT] << "System directory: '"
@@ -557,6 +556,19 @@ void LyX::defaultKeyBindings(kb_keymap  * kbmap)
 }
 
 
+void LyX::emergencyCleanup()
+{
+       // what to do about tmpfiles is non-obvious. we would
+       // like to delete any we find, but our lyxdir might
+       // contain documents etc. which might be helpful on
+       // a crash
+       bufferlist.emergencyWriteAll();
+       if (lyxserver)
+               lyxserver->emergencyCleanup();
+}
+
 // LyX can optionally take over the handling of deadkeys
 void LyX::deadKeyBindings(kb_keymap * kbmap)
 {
@@ -752,7 +764,6 @@ void setDebuggingLevel(string const & dbgLevel)
 // Give command line help
 void commandLineHelp()
 {
-       lyxerr << "LyX " LYX_VERSION << " of " LYX_RELEASE << endl;
        lyxerr <<
                _("Usage: lyx [ command line switches ] [ name.lyx ... ]\n"
                  "Command line switches (case sensitive):\n"
@@ -770,9 +781,21 @@ void commandLineHelp()
                  "\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-version        summarize version and build info\n"
                  "Check the LyX man page for more details.") << endl;
 }
 
+// Give command line version information
+void commandLineVersionInfo()
+{
+       lyxerr << "LyX " << lyx_version
+              << " of " << lyx_release_date << endl;
+       lyxerr << "Built on " << __DATE__ << ", " << __TIME__ << endl;
+
+       lyxerr << lyx_version_info << endl;
+}
+
+
 } // namespace anon
 
 
@@ -822,6 +845,11 @@ bool LyX::easyParse(int * argc, char * argv[])
                        commandLineHelp();
                        exit(0);
                } 
+               // Check for --version or -version
+               else if (arg == "--version" || arg == "-version") {
+                       commandLineVersionInfo();
+                       exit(0);
+               }
                // Check for "-nw": No XWindows as for emacs this should
                // give a LyX that could be used in a terminal window.
                //else if (arg == "-nw") {