1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
17 #pragma implementation
25 #include "lyx_gui_misc.h"
27 #include "support/path.h"
28 #include "support/filetools.h"
29 #include "bufferlist.h"
31 #include "support/FileInfo.h"
32 #include "lastfiles.h"
34 #include "lyxserver.h"
38 #include "MenuBackend.h"
39 #include "ToolbarDefaults.h"
42 #include "converter.h"
46 extern void LoadLyXFile(string const &);
47 extern void QuitLyX();
51 string system_tempdir;
52 string user_lyxdir; // Default $HOME/.lyx
54 // Should this be kept global? Asger says Yes.
57 LastFiles * lastfiles;
59 // This is the global bufferlist object
60 BufferList bufferlist;
62 LyXServer * lyxserver = 0;
63 // this should be static, but I need it in buffer.C
64 bool finished = false; // flag, that we are quitting the program
66 // convenient to have it here.
67 kb_keymap * toplevel_keymap;
70 LyX::LyX(int * argc, char * argv[])
72 // Prevent crash with --help
76 // Here we need to parse the command line. At least
77 // we need to parse for "-dbg" and "-help"
78 bool gui = easyParse(argc, argv);
80 // Global bindings (this must be done as early as possible.) (Lgb)
81 toplevel_keymap = new kb_keymap;
82 defaultKeyBindings(toplevel_keymap);
84 // Make the GUI object, and let it take care of the
85 // command line arguments that concerns it.
86 lyxerr[Debug::INIT] << "Initializing LyXGUI..." << endl;
87 lyxGUI = new LyXGUI(this, argc, argv, gui);
88 lyxerr[Debug::INIT] << "Initializing LyXGUI...done" << endl;
90 // Now the GUI and LyX have taken care of their arguments, so
91 // the only thing left on the command line should be
92 // filenames. Let's check anyway.
93 for (int argi = 1; argi < *argc ; ++argi) {
94 if (argv[argi][0] == '-') {
95 lyxerr << _("Wrong command line option `")
97 << _("'. Exiting.") << endl;
102 // Initialization of LyX (reads lyxrc and more)
103 lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
104 init(argc, argv, gui);
105 lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
109 // Load the files specified in the command line.
111 lyxerr[Debug::INFO] << "Opening document..." << endl;
112 else if ((*argc) > 2)
113 lyxerr[Debug::INFO] << "Opening documents..." << endl;
115 Buffer * last_loaded = 0;
117 for (int argi = (*argc) - 1; argi >= 1; --argi) {
118 Buffer * loadb = bufferlist.loadLyXFile(argv[argi]);
125 string splash = i18nLibFileSearch("examples", "splash.lyx");
126 lyxerr[Debug::INIT] << "Opening splash document "
127 << splash << "..." << endl;
128 Buffer * loadb = bufferlist.loadLyXFile(splash);
134 if (last_loaded != 0) {
135 lyxerr[Debug::INIT] << "Yes we loaded some files." << endl;
137 lyxGUI->regBuf(last_loaded);
140 // Execute batch commands if available
141 if (!batch_command.empty()) {
142 lyxerr << "About to handle -x '"
143 << batch_command << "'" << endl;
145 // no buffer loaded, create one
147 last_loaded = bufferlist.newFile("tmpfile", string());
149 // try to dispatch to last loaded buffer first
150 bool dispatched = last_loaded->Dispatch(batch_command);
152 // if this was successful, return.
153 // Maybe we could do something more clever than aborting...
155 lyxerr << "We are done!" << endl;
160 // otherwise, let the GUI handle the batch command
161 lyxGUI->regBuf(last_loaded);
162 lyxGUI->getLyXView()->getLyXFunc()->Dispatch(batch_command);
167 // Let the ball begin...
172 // A destructor is always necessary (asierra-970604)
180 extern "C" void error_handler(int err_sig);
182 void LyX::init(int */*argc*/, char **argv, bool gui)
184 // Install the signal handlers
185 signal(SIGHUP, error_handler);
186 signal(SIGFPE, error_handler);
187 signal(SIGSEGV, error_handler);
188 signal(SIGINT, error_handler);
189 signal(SIGTERM, error_handler);
192 // Determine path of binary
196 string binpath = subst(argv[0], '\\', '/');
197 string binname = OnlyFilename(argv[0]);
198 // Sorry for system specific code. (SMiyata)
199 if (suffixIs(binname, ".exe"))
200 binname.erase(binname.length()-4, string::npos);
202 binpath = ExpandPath(binpath); // This expands ./ and ~/
204 if (!AbsolutePath(binpath)) {
205 string binsearchpath = GetEnvPath("PATH");
206 // This will make "src/lyx" work always :-)
207 binsearchpath += ";.";
208 binpath = FileOpenSearch(binsearchpath, argv[0]);
211 fullbinpath = binpath;
212 binpath = MakeAbsPath(OnlyPath(binpath));
214 // In case we are running in place and compiled with shared libraries
215 if (suffixIs(binpath, "/.libs/"))
216 binpath.erase(binpath.length()-6, string::npos);
218 if (binpath.empty()) {
219 lyxerr << _("Warning: could not determine path of binary.")
221 << _("If you have problems, try starting LyX with an absolute path.")
224 lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
227 // Determine system directory.
230 // Directories are searched in this order:
231 // 1) -sysdir command line parameter
232 // 2) LYX_DIR_11x environment variable
233 // 3) Maybe <path of binary>/TOP_SRCDIR/lib
234 // 4) <path of binary>/../share/<name of binary>/
235 // 4a) repeat 4 after following the Symlink if <path of
236 // binary> is a symbolic link.
237 // 5) hardcoded lyx_dir
238 // The directory is checked for the presence of the file
239 // "chkconfig.ltx", and if that is present, the directory
240 // is accepted as the system directory.
241 // If no chkconfig.ltx file is found, a warning is given,
242 // and the hardcoded lyx_dir is used.
244 // If we had a command line switch, system_lyxdir is already set
246 if (!system_lyxdir.empty())
247 searchpath= MakeAbsPath(system_lyxdir) + ';';
249 // LYX_DIR_11x environment variable
250 string lyxdir = GetEnvPath("LYX_DIR_11x");
252 if (!lyxdir.empty()) {
253 lyxerr[Debug::INIT] << "LYX_DIR_11x: " << lyxdir << endl;
254 searchpath += lyxdir + ';';
257 // <path of binary>/TOP_SRCDIR/lib
258 build_lyxdir = MakeAbsPath("../lib", binpath);
259 if (!FileSearch(build_lyxdir, "lyxrc.defaults").empty()) {
260 searchpath += MakeAbsPath(AddPath(TOP_SRCDIR, "lib"),
262 lyxerr[Debug::INIT] << "Checking whether LyX is run in "
263 "place... yes" << endl;
266 << "Checking whether LyX is run in place... no"
268 build_lyxdir.erase();
273 // Path of binary/../share/name of binary/
274 searchpath += NormalizePath(AddPath(binpath, "../share/") +
275 OnlyFilename(binname)) + ';';
278 FileInfo file(fullbinpath, true);
279 FollowLink = file.isLink();
282 if (LyXReadLink(fullbinpath, Link)) {
284 binpath = MakeAbsPath(OnlyPath(fullbinpath));
290 } while (FollowLink);
293 searchpath += LYX_DIR;
295 // If debugging, show complete search path
296 lyxerr[Debug::INIT] << "System directory search path: "
297 << searchpath << endl;
299 string const filename = "chkconfig.ltx";
300 string temp = FileOpenSearch(searchpath, filename, string());
301 system_lyxdir = OnlyPath(temp);
303 // Reduce "path/../path" stuff out of system directory
304 system_lyxdir = NormalizePath(system_lyxdir);
306 bool path_shown = false;
308 // Warn if environment variable is set, but unusable
309 if (!lyxdir.empty()) {
310 if (system_lyxdir != NormalizePath(lyxdir)) {
311 lyxerr <<_("LYX_DIR_11x environment variable no good.")
313 << _("System directory set to: ")
314 << system_lyxdir << endl;
319 // Warn the user if we couldn't find "chkconfig.ltx"
320 if (system_lyxdir == "./") {
321 lyxerr <<_("LyX Warning! Couldn't determine system directory. ")
322 <<_("Try the '-sysdir' command line parameter or ")
323 <<_("set the environment variable LYX_DIR_11x to the "
324 "LyX system directory ")
325 << _("containing the file `chkconfig.ltx'.") << endl;
327 lyxerr << _("Using built-in default ")
328 << LYX_DIR << _(" but expect problems.")
331 lyxerr << _("Expect problems.") << endl;
332 system_lyxdir = LYX_DIR;
336 // Report the system directory if debugging is on
338 lyxerr[Debug::INIT] << "System directory: '"
339 << system_lyxdir << '\'' << endl;
342 // Determine user lyx-dir
345 // Directories are searched in this order:
346 // 1) -userdir command line parameter
347 // 2) LYX_USERDIR_11x environment variable
348 // 3) $HOME/.<name of binary>
350 // If we had a command line switch, user_lyxdir is already set
351 bool explicit_userdir = true;
352 if (user_lyxdir.empty()) {
354 // LYX_USERDIR_11x environment variable
355 user_lyxdir = GetEnvPath("LYX_USERDIR_11x");
358 if (user_lyxdir.empty())
359 user_lyxdir = AddPath(GetEnvPath("HOME"),
360 string(".") + PACKAGE);
361 explicit_userdir = false;
364 lyxerr[Debug::INIT] << "User LyX directory: '"
365 << user_lyxdir << '\'' << endl;
367 // Check that user LyX directory is ok. We don't do that if
368 // running in batch mode.
370 queryUserLyXDir(explicit_userdir);
375 // Shine up lyxrc defaults
378 // Default template path: system_dir/templates
379 if (lyxrc.template_path.empty()){
380 lyxrc.template_path = AddPath(system_lyxdir, "templates");
383 // Default lastfiles file: $HOME/.lyx/lastfiles
384 if (lyxrc.lastfiles.empty()){
385 lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
388 // Disable gui when either lyxrc or easyparse says so
390 lyxrc.use_gui = false;
392 // Calculate screen dpi as average of x-DPI and y-DPI:
394 lyxrc.dpi = getScreenDPI();
395 lyxerr[Debug::INIT] << "DPI setting detected to be "
396 << lyxrc.dpi + 0.5 << endl;
398 lyxrc.dpi = 1; // I hope this is safe
402 // Read configuration files
405 ReadRcFile("lyxrc.defaults");
406 system_lyxrc = lyxrc;
407 system_formats = formats;
408 system_converters = converters;
409 system_lcolor = lcolor;
411 // If there is a preferences file we read that instead
412 // of the old lyxrc file.
413 if (!ReadRcFile("preferences"))
417 converters.Update(formats);
418 converters.BuildGraph();
421 ReadEncodingsFile("encodings");
423 ReadLangugesFile("languages");
426 lyxerr[Debug::INIT] << "Reading layouts..." << endl;
429 // Ensure that we have really read a bind file, so that LyX is
431 lyxrc.readBindFileIfNeeded();
434 ReadUIFile(lyxrc.ui_file);
436 // Bind the X dead keys to the corresponding LyX functions if
438 if (lyxrc.override_x_deadkeys)
439 deadKeyBindings(toplevel_keymap);
441 if (lyxerr.debugging(Debug::LYXRC)) {
445 // Create temp directory
446 system_tempdir = CreateLyXTmpDir(lyxrc.tempdir_path);
447 if (lyxerr.debugging(Debug::INIT)) {
448 lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
451 // load the lastfiles mini-database
452 lyxerr[Debug::INIT] << "Reading lastfiles `"
453 << lyxrc.lastfiles << "'..." << endl;
454 lastfiles = new LastFiles(lyxrc.lastfiles,
455 lyxrc.check_lastfiles,
456 lyxrc.num_lastfiles);
458 // start up the lyxserver. (is this a bit early?) (Lgb)
459 // 0.12 this will be way to early, we need the GUI to be initialized
460 // first, so move it for now.
461 // lyxserver = new LyXServer;
465 // These are the default bindings known to LyX
466 void LyX::defaultKeyBindings(kb_keymap * kbmap)
468 kbmap->bind("Right", LFUN_RIGHT);
469 kbmap->bind("Left", LFUN_LEFT);
470 kbmap->bind("Up", LFUN_UP);
471 kbmap->bind("Down", LFUN_DOWN);
473 kbmap->bind("Tab", LFUN_TAB);
475 kbmap->bind("Home", LFUN_HOME);
476 kbmap->bind("End", LFUN_END);
477 kbmap->bind("Prior", LFUN_PRIOR);
478 kbmap->bind("Next", LFUN_NEXT);
480 kbmap->bind("Return", LFUN_BREAKPARAGRAPH);
481 kbmap->bind("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
483 kbmap->bind("Delete", LFUN_DELETE);
484 kbmap->bind("BackSpace", LFUN_BACKSPACE);
486 // kbmap->bindings to enable the use of the numeric keypad
488 kbmap->bind("KP_0", LFUN_SELFINSERT);
489 kbmap->bind("KP_Decimal", LFUN_SELFINSERT);
490 kbmap->bind("KP_Enter", LFUN_SELFINSERT);
491 kbmap->bind("KP_1", LFUN_SELFINSERT);
492 kbmap->bind("KP_2", LFUN_SELFINSERT);
493 kbmap->bind("KP_3", LFUN_SELFINSERT);
494 kbmap->bind("KP_4", LFUN_SELFINSERT);
495 kbmap->bind("KP_5", LFUN_SELFINSERT);
496 kbmap->bind("KP_6", LFUN_SELFINSERT);
497 kbmap->bind("KP_Add", LFUN_SELFINSERT);
498 kbmap->bind("KP_7", LFUN_SELFINSERT);
499 kbmap->bind("KP_8", LFUN_SELFINSERT);
500 kbmap->bind("KP_9", LFUN_SELFINSERT);
501 kbmap->bind("KP_Divide", LFUN_SELFINSERT);
502 kbmap->bind("KP_Multiply", LFUN_SELFINSERT);
503 kbmap->bind("KP_Subtract", LFUN_SELFINSERT);
505 /* Most self-insert keys are handled in the 'default:' section of
506 * WorkAreaKeyPress - so we don't have to define them all.
507 * However keys explicit decleared as self-insert are
508 * handled seperatly (LFUN_SELFINSERT.) Lgb. */
510 kbmap->bind("C-Tab", LFUN_TABINSERT); // ale970515
511 kbmap->bind("S-Tab", LFUN_SHIFT_TAB); // jug20000522
515 // LyX can optionally take over the handling of deadkeys
516 void LyX::deadKeyBindings(kb_keymap * kbmap)
518 // bindKeyings for transparent handling of deadkeys
519 // The keysyms are gotten from XFree86 X11R6
520 kbmap->bind("~C-~S-~M-dead_acute", LFUN_ACUTE);
521 kbmap->bind("~C-~S-~M-dead_breve", LFUN_BREVE);
522 kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON);
523 kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
524 kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
525 kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
526 kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT);
527 kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE);
528 kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
529 kbmap->bind("~C-~S-~M-dead_macron", LFUN_MACRON);
530 // nothing with this name
531 // kbmap->bind("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
532 kbmap->bind("~C-~S-~M-dead_tilde", LFUN_TILDE);
533 kbmap->bind("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
534 // nothing with this name either...
535 //kbmap->bind("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
536 kbmap->bind("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
537 kbmap->bind("~C-~S-~M-dead_tie", LFUN_TIE);
538 kbmap->bind("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
542 // This one is not allowed to use anything on the main form, since that
543 // one does not exist yet. (Asger)
544 void LyX::queryUserLyXDir(bool explicit_userdir)
546 // Does user directory exist?
547 FileInfo fileInfo(user_lyxdir);
548 if (fileInfo.isOK() && fileInfo.isDir()) {
556 // Different wording if the user specifically requested a directory
557 if (!AskQuestion( explicit_userdir
558 ? _("You have specified an invalid LyX directory.")
559 : _("You don't have a personal LyX directory.") ,
561 _("It is needed to keep your own configuration."),
562 _("Should I try to set it up for you (recommended)?"))) {
563 lyxerr << _("Running without personal LyX directory.") << endl;
564 // No, let's use $HOME instead.
565 user_lyxdir = GetEnvPath("HOME");
569 // Tell the user what is going on
570 lyxerr << _("LyX: Creating directory ") << user_lyxdir
571 << _(" and running configure...") << endl;
573 // Create directory structure
574 if (!createDirectory(user_lyxdir, 0755)) {
575 // Failed, let's use $HOME instead.
576 user_lyxdir = GetEnvPath("HOME");
577 lyxerr << _("Failed. Will use ") << user_lyxdir
578 << _(" instead.") << endl;
582 // Run configure in user lyx directory
584 ::system(AddName(system_lyxdir, "configure").c_str());
585 lyxerr << "LyX: " << _("Done!") << endl;
589 // Read the rc file `name'
590 bool LyX::ReadRcFile(string const & name)
592 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
594 string lyxrc_path = LibFileSearch(string(), name);
595 if (!lyxrc_path.empty()){
596 lyxerr[Debug::INIT] << "Found " << name
597 << " in " << lyxrc_path << endl;
598 if (lyxrc.read(lyxrc_path) < 0) {
599 WriteAlert(_("LyX Warning!"),
600 _("Error while reading ")+lyxrc_path+".",
601 _("Using built-in defaults."));
606 lyxerr[Debug::INIT] << "Could not find " << name << endl;
611 // Read the ui file `name'
612 void LyX::ReadUIFile(string const & name)
620 struct keyword_item uitags[ui_last-1] = {
621 { "menuset", ui_menuset },
622 { "toolbar", ui_toolbar }
625 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
627 string ui_path = LibFileSearch("ui", name, "ui");
629 if (ui_path.empty()) {
630 lyxerr[Debug::INIT] << "Could not find " << name << endl;
631 menubackend.defaults();
635 lyxerr[Debug::INIT] << "Found " << name
636 << " in " << ui_path << endl;
637 LyXLex lex(uitags, ui_last - 1);
638 lex.setFile(ui_path);
640 lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
644 if (lyxerr.debugging(Debug::PARSER))
645 lex.printTable(lyxerr);
650 menubackend.read(lex);
654 toolbardefaults.read(lex);
658 lex.printError("LyX::ReadUFile: "
659 "Unknown menu tag: `$$Token'");
666 // Read the languages file `name'
667 void LyX::ReadLangugesFile(string const & name)
669 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
671 string lang_path = LibFileSearch(string(), name);
672 if (lang_path.empty()) {
673 lyxerr[Debug::INIT] << "Could not find " << name << endl;
674 languages.setDefaults();
677 languages.read(lang_path);
681 // Read the encodings file `name'
682 void LyX::ReadEncodingsFile(string const & name)
684 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
686 string enc_path = LibFileSearch(string(), name);
687 if (enc_path.empty()) {
688 lyxerr[Debug::INIT] << "Could not find " << name << endl;
691 encodings.read(enc_path);
695 // Set debugging level and report result to user
697 void setDebuggingLevel(string const & dbgLevel)
699 lyxerr << _("Setting debug level to ") << dbgLevel << endl;
700 lyxerr.level(Debug::value(dbgLevel));
701 Debug::showLevel(lyxerr, lyxerr.level());
705 // Give command line help
707 void commandLineHelp()
709 lyxerr << "LyX " LYX_VERSION << " of " LYX_RELEASE << endl;
711 _("Usage: lyx [ command line switches ] [ name.lyx ... ]\n"
712 "Command line switches (case sensitive):\n"
713 "\t-help summarize LyX usage\n"
714 "\t-userdir dir try to set user directory to dir\n"
715 "\t-sysdir dir try to set system directory to dir\n"
716 "\t-geometry WxH+X+Y set geometry of the main window\n"
717 "\t-dbg feature[,feature]...\n"
718 " select the features to debug.\n"
719 " Type `lyx -dbg' to see the list of features\n"
720 "\t-x [--execute] command\n"
721 " where command is a lyx command.\n"
722 "\t-e [--export] fmt\n"
723 " where fmt is the export format of choice.\n"
724 "\t-i [--import] fmt file.xxx\n"
725 " where fmt is the import format of choice\n"
726 " and file.xxx is the file to be imported.\n"
727 "Check the LyX man page for more details.") << endl;
731 bool LyX::easyParse(int * argc, char * argv[])
734 int removeargs = 0; // used when options are read
735 for (int i = 1; i < *argc; ++i) {
736 string arg = argv[i];
738 // Check for -dbg int
741 setDebuggingLevel(argv[i + 1]);
744 lyxerr << _("List of supported debug flags:")
746 Debug::showTags(lyxerr);
750 // Check for "-sysdir"
751 else if (arg == "-sysdir") {
753 system_lyxdir = argv[i + 1];
756 lyxerr << _("Missing directory for -sysdir switch!")
761 // Check for "-userdir"
762 else if (arg == "-userdir") {
764 user_lyxdir = argv[i + 1];
767 lyxerr << _("Missing directory for -userdir switch!")
772 // Check for --help or -help
773 else if (arg == "--help" || arg == "-help") {
777 // Check for "-nw": No XWindows as for emacs this should
778 // give a LyX that could be used in a terminal window.
779 //else if (arg == "-nw") {
783 // Check for "-x": Execute commands
784 else if (arg == "-x" || arg == "--execute") {
786 batch_command = string(argv[i + 1]);
790 lyxerr << _("Missing command string after -x switch!") << endl;
792 // Argh. Setting gui to false segfaults..
796 else if (arg == "-e" || arg == "--export") {
798 string type(argv[i+1]);
800 batch_command = "buffer-export " + type;
803 lyxerr << _("Missing file type [eg latex, "
805 << arg << _(" switch!") << endl;
807 else if (arg == "-i" || arg == "--import") {
809 string type(argv[i+1]);
810 string file(argv[i+2]);
813 batch_command = "buffer-import " + type + " " + file;
814 lyxerr << "batch_command: "
815 << batch_command << endl;
818 lyxerr << _("Missing type [eg latex, "
820 << arg << _(" switch!") << endl;
823 if (removeargs > 0) {
824 // Now, remove used arguments by shifting
825 // the following ones removeargs places down.
826 (*argc) -= removeargs;
827 for (int j = i; j < (*argc); ++j)
828 argv[j] = argv[j + removeargs];
829 --i; // After shift, check this number again.
840 void error_handler(int err_sig)
844 lyxerr << "\nlyx: SIGHUP signal caught" << endl;
850 lyxerr << "\nlyx: SIGFPE signal caught" << endl;
853 lyxerr << "\nlyx: SIGSEGV signal caught" << endl;
855 "Sorry, you have found a bug in LyX."
856 " If possible, please read 'Known bugs'\n"
857 "under the Help menu and then send us "
858 "a full bug report. Thanks!" << endl;
865 // Deinstall the signal handlers
866 signal(SIGHUP, SIG_DFL);
867 signal(SIGINT, SIG_DFL);
868 signal(SIGFPE, SIG_DFL);
869 signal(SIGSEGV, SIG_DFL);
870 signal(SIGTERM, SIG_DFL);
872 bufferlist.emergencyWriteAll();
874 lyxerr << "Bye." << endl;
875 if (err_sig!= SIGHUP &&
876 (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))