]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_main.C
remove wrong sections
[lyx.git] / src / lyx_main.C
index cf616fbc6b9a1ca8e64571648effdbe3c7460076..cc5e5d1a7ccfe8a15be69df252727f3610fd2625 100644 (file)
@@ -30,6 +30,8 @@
 #include "gettext.h"
 #include "kbmap.h"
 
+using std::endl;
+
 extern void LoadLyXFile(string const &);
 
 string system_lyxdir;
@@ -79,7 +81,7 @@ LyX::LyX(int * argc, char * argv[])
 
        // Initialization of LyX (reads lyxrc and more)
        lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
-       init(argc, argv);
+       init(argc, argv, gui);
        lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
 
        lyxGUI->init();
@@ -114,7 +116,8 @@ LyX::LyX(int * argc, char * argv[])
 
        if (last_loaded != 0) {
                lyxerr.debug() << "Yes we loaded some files." << endl;
-               lyxGUI->regBuf(last_loaded);
+               if (lyxrc.use_gui)
+                       lyxGUI->regBuf(last_loaded);
        }
 
        // Execute batch commands if available
@@ -142,7 +145,7 @@ LyX::~LyX()
 
 extern "C" void error_handler(int err_sig);
 
-void LyX::init(int */*argc*/, char **argv)
+void LyX::init(int */*argc*/, char **argv, bool gui)
 {
        // Install the signal handlers
        signal(SIGHUP, error_handler);
@@ -333,12 +336,18 @@ void LyX::init(int */*argc*/, char **argv)
                lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
        }
 
-       // Calculate screen dpi as average of x-DPI and y-DPI:
-       Screen * scr = DefaultScreenOfDisplay(fl_get_display());
-       lyxrc.dpi = ((HeightOfScreen(scr)* 25.4 / HeightMMOfScreen(scr)) +
-                     (WidthOfScreen(scr)* 25.4 / WidthMMOfScreen(scr))) / 2;
-       lyxerr[Debug::INFO] << "DPI setting detected to be "
-                      << lyxrc.dpi + 0.5 << endl;
+       // Disable gui when either lyxrc or easyparse says so
+       if (!gui)
+               lyxrc.use_gui = false;
+        // Calculate screen dpi as average of x-DPI and y-DPI:
+       if (lyxrc.use_gui) {
+               lyxrc.dpi = getScreenDPI();
+               lyxerr[Debug::INFO] << "DPI setting detected to be "
+                                                << lyxrc.dpi + 0.5 << endl;
+       } else {
+               lyxrc.dpi = 1; // I hope this is safe
+       }
 
        //
        // Read configuration files
@@ -490,7 +499,6 @@ bool LyX::easyParse(int * argc, char * argv[])
                                Debug::showTags(lyxerr);
                                exit(0);
                        }
-                       
                } 
                // Check for "-sysdir"
                else if (arg == "-sysdir") {
@@ -511,10 +519,11 @@ bool LyX::easyParse(int * argc, char * argv[])
                        commandLineHelp();
                        exit(0);
                } 
-               // Check for "-nw": No window
-               else if (arg == "-nw") {
-                       gui = false;
-               }
+               // 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") {
+               //      gui = false;
+               //}
 
                // Check for "-x": Execute commands
                else if (arg == "-x" || arg == "--execute") {
@@ -559,8 +568,7 @@ bool LyX::easyParse(int * argc, char * argv[])
                                        lyxerr << _("Unknown file type '")
                                               << type << _("' after ")
                                               << arg << _(" switch!") << endl;
-                       }
-                       else
+                       } else
                                lyxerr << _("Missing file type [eg latex, "
                                            "ps...] after ")
                                       << arg << _(" switch!") << endl;
@@ -570,6 +578,7 @@ bool LyX::easyParse(int * argc, char * argv[])
 }
 
 
+extern "C"
 void error_handler(int err_sig)
 {
        switch (err_sig) {