1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
17 #pragma implementation
25 #include "frontends/Alert.h"
26 #include "frontends/GUIRunTime.h"
28 #include "support/path.h"
29 #include "support/filetools.h"
31 #include "bufferlist.h"
33 #include "support/FileInfo.h"
34 #include "lastfiles.h"
36 #include "lyxserver.h"
40 #include "MenuBackend.h"
41 #include "ToolbarDefaults.h"
44 #include "converter.h"
46 #include "support/os.h"
50 #ifndef CXX_GLOBAL_CSTD
54 extern void LoadLyXFile(string const &);
55 extern void QuitLyX();
59 string system_tempdir;
60 string user_lyxdir; // Default $HOME/.lyx
62 // Should this be kept global? Asger says Yes.
65 LastFiles * lastfiles;
67 // This is the global bufferlist object
68 BufferList bufferlist;
70 LyXServer * lyxserver = 0;
71 // this should be static, but I need it in buffer.C
72 bool finished = false; // flag, that we are quitting the program
74 // convenient to have it here.
75 boost::scoped_ptr<kb_keymap> toplevel_keymap;
78 LyX::LyX(int * argc, char * argv[])
80 // Prevent crash with --help
84 // Here we need to parse the command line. At least
85 // we need to parse for "-dbg" and "-help"
86 bool gui = easyParse(argc, argv);
88 // Global bindings (this must be done as early as possible.) (Lgb)
89 toplevel_keymap.reset(new kb_keymap);
90 defaultKeyBindings(toplevel_keymap.get());
92 // Make the GUI object, and let it take care of the
93 // command line arguments that concerns it.
94 lyxerr[Debug::INIT] << "Initializing LyXGUI..." << endl;
95 lyxGUI = new LyXGUI(this, argc, argv, gui);
96 lyxerr[Debug::INIT] << "Initializing LyXGUI...done" << endl;
98 // Now the GUI and LyX have taken care of their arguments, so
99 // the only thing left on the command line should be
100 // filenames. Let's check anyway.
101 for (int argi = 1; argi < *argc ; ++argi) {
102 if (argv[argi][0] == '-') {
103 lyxerr << _("Wrong command line option `")
105 << _("'. Exiting.") << endl;
110 // Initialization of LyX (reads lyxrc and more)
111 lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
113 lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
117 // Load the files specified in the command line.
119 lyxerr[Debug::INFO] << "Opening document..." << endl;
120 else if ((*argc) > 2)
121 lyxerr[Debug::INFO] << "Opening documents..." << endl;
123 Buffer * last_loaded = 0;
125 for (int argi = (*argc) - 1; argi >= 1; --argi) {
126 Buffer * loadb = bufferlist.loadLyXFile(argv[argi]);
133 string const splash =
134 i18nLibFileSearch("examples", "splash.lyx");
135 lyxerr[Debug::INIT] << "Opening splash document "
136 << splash << "..." << endl;
137 Buffer * loadb = bufferlist.loadLyXFile(splash);
143 if (last_loaded != 0) {
144 lyxerr[Debug::INIT] << "Yes we loaded some files." << endl;
146 lyxGUI->regBuf(last_loaded);
149 // Execute batch commands if available
150 if (!batch_command.empty()) {
151 lyxerr << "About to handle -x '"
152 << batch_command << "'" << endl;
154 // no buffer loaded, create one
156 last_loaded = bufferlist.newFile("tmpfile", string());
158 // try to dispatch to last loaded buffer first
159 bool dispatched = last_loaded->dispatch(batch_command);
161 // if this was successful, return.
162 // Maybe we could do something more clever than aborting...
164 lyxerr << "We are done!" << endl;
169 // otherwise, let the GUI handle the batch command
170 lyxGUI->regBuf(last_loaded);
171 lyxGUI->getLyXView()->getLyXFunc()->dispatch(batch_command);
176 // Let the ball begin...
181 // A destructor is always necessary (asierra-970604)
192 void error_handler(int err_sig)
196 lyxerr << "\nlyx: SIGHUP signal caught" << endl;
202 lyxerr << "\nlyx: SIGFPE signal caught" << endl;
205 lyxerr << "\nlyx: SIGSEGV signal caught" << endl;
207 "Sorry, you have found a bug in LyX. "
208 "Please read the bug-reporting instructions "
209 "in Help->Introduction and send us a bug report, "
210 "if necessary. Thanks !" << endl;
217 // Deinstall the signal handlers
218 signal(SIGHUP, SIG_DFL);
219 signal(SIGINT, SIG_DFL);
220 signal(SIGFPE, SIG_DFL);
221 signal(SIGSEGV, SIG_DFL);
222 signal(SIGTERM, SIG_DFL);
224 LyX::emergencyCleanup();
226 lyxerr << "Bye." << endl;
227 if (err_sig!= SIGHUP &&
228 (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))
236 void LyX::init(bool gui)
238 // Install the signal handlers
239 signal(SIGHUP, error_handler);
240 signal(SIGFPE, error_handler);
241 signal(SIGSEGV, error_handler);
242 signal(SIGINT, error_handler);
243 signal(SIGTERM, error_handler);
246 // Determine path of binary
250 string binpath = os::binpath();
251 string binname = os::binname();
252 fullbinpath = binpath;
254 if (binpath.empty()) {
255 lyxerr << _("Warning: could not determine path of binary.")
257 << _("If you have problems, try starting LyX with an absolute path.")
260 lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
263 // Determine system directory.
266 // Directories are searched in this order:
267 // 1) -sysdir command line parameter
268 // 2) LYX_DIR_11x environment variable
269 // 3) Maybe <path of binary>/TOP_SRCDIR/lib
270 // 4) <path of binary>/../share/<name of binary>/
271 // 4a) repeat 4 after following the Symlink if <path of
272 // binary> is a symbolic link.
273 // 5) hardcoded lyx_dir
274 // The directory is checked for the presence of the file
275 // "chkconfig.ltx", and if that is present, the directory
276 // is accepted as the system directory.
277 // If no chkconfig.ltx file is found, a warning is given,
278 // and the hardcoded lyx_dir is used.
280 // If we had a command line switch, system_lyxdir is already set
282 if (!system_lyxdir.empty())
283 searchpath= MakeAbsPath(system_lyxdir) + ';';
285 // LYX_DIR_11x environment variable
286 string const lyxdir = GetEnvPath("LYX_DIR_11x");
288 if (!lyxdir.empty()) {
289 lyxerr[Debug::INIT] << "LYX_DIR_11x: " << lyxdir << endl;
290 searchpath += lyxdir + ';';
293 // <path of binary>/TOP_SRCDIR/lib
294 build_lyxdir = MakeAbsPath("../lib", binpath);
295 if (!FileSearch(build_lyxdir, "lyxrc.defaults").empty()) {
296 searchpath += MakeAbsPath(AddPath(TOP_SRCDIR, "lib"),
298 lyxerr[Debug::INIT] << "Checking whether LyX is run in "
299 "place... yes" << endl;
302 << "Checking whether LyX is run in place... no"
304 build_lyxdir.erase();
309 // Path of binary/../share/name of binary/
310 searchpath += NormalizePath(AddPath(binpath, "../share/") +
311 OnlyFilename(binname)) + ';';
314 FileInfo file(fullbinpath, true);
315 followlink = file.isLink();
318 if (LyXReadLink(fullbinpath, link)) {
320 binpath = MakeAbsPath(OnlyPath(fullbinpath));
326 } while (followlink);
329 searchpath += LYX_DIR;
331 // If debugging, show complete search path
332 lyxerr[Debug::INIT] << "System directory search path: "
333 << searchpath << endl;
335 string const filename = "chkconfig.ltx";
336 string const temp = FileOpenSearch(searchpath, filename, string());
337 system_lyxdir = OnlyPath(temp);
339 // Reduce "path/../path" stuff out of system directory
340 system_lyxdir = NormalizePath(system_lyxdir);
342 bool path_shown = false;
344 // Warn if environment variable is set, but unusable
345 if (!lyxdir.empty()) {
346 if (system_lyxdir != NormalizePath(lyxdir)) {
347 lyxerr <<_("LYX_DIR_11x environment variable no good.")
349 << _("System directory set to: ")
350 << system_lyxdir << endl;
355 // Warn the user if we couldn't find "chkconfig.ltx"
356 if (system_lyxdir == "./") {
357 lyxerr <<_("LyX Warning! Couldn't determine system directory. ")
358 <<_("Try the '-sysdir' command line parameter or ")
359 <<_("set the environment variable LYX_DIR_11x to the "
360 "LyX system directory ")
361 << _("containing the file `chkconfig.ltx'.") << endl;
363 FileInfo fi(LYX_DIR);
365 lyxerr << "Couldn't even find the default LYX_DIR." << endl
366 << "Giving up." << endl;
369 lyxerr << _("Using built-in default ")
370 << LYX_DIR << _(" but expect problems.")
373 lyxerr << _("Expect problems.") << endl;
375 system_lyxdir = LYX_DIR;
378 // Report the system directory if debugging is on
380 lyxerr[Debug::INIT] << "System directory: '"
381 << system_lyxdir << '\'' << endl;
384 // Determine user lyx-dir
387 // Directories are searched in this order:
388 // 1) -userdir command line parameter
389 // 2) LYX_USERDIR_11x environment variable
390 // 3) $HOME/.<name of binary>
392 // If we had a command line switch, user_lyxdir is already set
393 bool explicit_userdir = true;
394 if (user_lyxdir.empty()) {
396 // LYX_USERDIR_11x environment variable
397 user_lyxdir = GetEnvPath("LYX_USERDIR_11x");
400 if (user_lyxdir.empty())
401 user_lyxdir = AddPath(GetEnvPath("HOME"),
402 string(".") + PACKAGE);
403 explicit_userdir = false;
406 lyxerr[Debug::INIT] << "User LyX directory: '"
407 << user_lyxdir << '\'' << endl;
409 // Check that user LyX directory is ok. We don't do that if
410 // running in batch mode.
412 queryUserLyXDir(explicit_userdir);
418 // Shine up lyxrc defaults
421 // Default template path: system_dir/templates
422 if (lyxrc.template_path.empty()){
423 lyxrc.template_path = AddPath(system_lyxdir, "templates");
426 // Default lastfiles file: $HOME/.lyx/lastfiles
427 if (lyxrc.lastfiles.empty()){
428 lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
431 // Disable gui when either lyxrc or easyparse says so
433 lyxrc.use_gui = false;
435 // Calculate screen dpi as average of x-DPI and y-DPI:
437 lyxrc.dpi = GUIRunTime::getScreenDPI();
438 lyxerr[Debug::INIT] << "DPI setting detected to be "
439 << lyxrc.dpi + 0.5 << endl;
441 lyxrc.dpi = 1; // I hope this is safe
445 // Read configuration files
448 readRcFile("lyxrc.defaults");
449 system_lyxrc = lyxrc;
450 system_formats = formats;
451 system_converters = converters;
452 system_lcolor = lcolor;
454 // If there is a preferences file we read that instead
455 // of the old lyxrc file.
456 if (!readRcFile("preferences"))
460 readEncodingsFile("encodings");
462 readLanguagesFile("languages");
465 lyxerr[Debug::INIT] << "Reading layouts..." << endl;
468 // Ensure that we have really read a bind file, so that LyX is
470 lyxrc.readBindFileIfNeeded();
473 readUIFile(lyxrc.ui_file);
475 // Bind the X dead keys to the corresponding LyX functions if
477 if (lyxrc.override_x_deadkeys)
478 deadKeyBindings(toplevel_keymap.get());
480 if (lyxerr.debugging(Debug::LYXRC)) {
484 // Create temp directory
485 os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
486 system_tempdir = os::getTmpDir();
487 if (lyxerr.debugging(Debug::INIT)) {
488 lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
491 // load the lastfiles mini-database
492 lyxerr[Debug::INIT] << "Reading lastfiles `"
493 << lyxrc.lastfiles << "'..." << endl;
494 lastfiles = new LastFiles(lyxrc.lastfiles,
495 lyxrc.check_lastfiles,
496 lyxrc.num_lastfiles);
498 // start up the lyxserver. (is this a bit early?) (Lgb)
499 // 0.12 this will be way to early, we need the GUI to be initialized
500 // first, so move it for now.
501 // lyxserver = new LyXServer;
505 // These are the default bindings known to LyX
506 void LyX::defaultKeyBindings(kb_keymap * kbmap)
508 kbmap->bind("Right", LFUN_RIGHT);
509 kbmap->bind("Left", LFUN_LEFT);
510 kbmap->bind("Up", LFUN_UP);
511 kbmap->bind("Down", LFUN_DOWN);
513 kbmap->bind("Tab", LFUN_TAB);
514 kbmap->bind("ISO_Left_Tab", LFUN_TAB); // jbl 2001-23-02
516 kbmap->bind("Home", LFUN_HOME);
517 kbmap->bind("End", LFUN_END);
518 kbmap->bind("Prior", LFUN_PRIOR);
519 kbmap->bind("Next", LFUN_NEXT);
521 kbmap->bind("Return", LFUN_BREAKPARAGRAPH);
522 //kbmap->bind("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
524 kbmap->bind("Delete", LFUN_DELETE);
525 kbmap->bind("BackSpace", LFUN_BACKSPACE);
527 // kbmap->bindings to enable the use of the numeric keypad
529 //kbmap->bind("KP_0", LFUN_SELFINSERT);
530 //kbmap->bind("KP_Decimal", LFUN_SELFINSERT);
531 kbmap->bind("KP_Enter", LFUN_BREAKPARAGRAPH);
532 //kbmap->bind("KP_1", LFUN_SELFINSERT);
533 //kbmap->bind("KP_2", LFUN_SELFINSERT);
534 //kbmap->bind("KP_3", LFUN_SELFINSERT);
535 //kbmap->bind("KP_4", LFUN_SELFINSERT);
536 //kbmap->bind("KP_5", LFUN_SELFINSERT);
537 //kbmap->bind("KP_6", LFUN_SELFINSERT);
538 //kbmap->bind("KP_Add", LFUN_SELFINSERT);
539 //kbmap->bind("KP_7", LFUN_SELFINSERT);
540 //kbmap->bind("KP_8", LFUN_SELFINSERT);
541 //kbmap->bind("KP_9", LFUN_SELFINSERT);
542 //kbmap->bind("KP_Divide", LFUN_SELFINSERT);
543 //kbmap->bind("KP_Multiply", LFUN_SELFINSERT);
544 //kbmap->bind("KP_Subtract", LFUN_SELFINSERT);
545 kbmap->bind("KP_Right", LFUN_RIGHT);
546 kbmap->bind("KP_Left", LFUN_LEFT);
547 kbmap->bind("KP_Up", LFUN_UP);
548 kbmap->bind("KP_Down", LFUN_DOWN);
549 kbmap->bind("KP_Home", LFUN_HOME);
550 kbmap->bind("KP_End", LFUN_END);
551 kbmap->bind("KP_Prior", LFUN_PRIOR);
552 kbmap->bind("KP_Next", LFUN_NEXT);
554 kbmap->bind("C-Tab", LFUN_TABINSERT); // ale970515
555 kbmap->bind("S-Tab", LFUN_SHIFT_TAB); // jug20000522
556 kbmap->bind("S-ISO_Left_Tab", LFUN_SHIFT_TAB); // jbl 2001-23-02
560 void LyX::emergencyCleanup()
562 // what to do about tmpfiles is non-obvious. we would
563 // like to delete any we find, but our lyxdir might
564 // contain documents etc. which might be helpful on
567 bufferlist.emergencyWriteAll();
569 lyxserver->emergencyCleanup();
573 // LyX can optionally take over the handling of deadkeys
574 void LyX::deadKeyBindings(kb_keymap * kbmap)
576 // bindKeyings for transparent handling of deadkeys
577 // The keysyms are gotten from XFree86 X11R6
578 kbmap->bind("~C-~S-~M-dead_acute", LFUN_ACUTE);
579 kbmap->bind("~C-~S-~M-dead_breve", LFUN_BREVE);
580 kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON);
581 kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
582 kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
583 kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
584 kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT);
585 kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE);
586 kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
587 kbmap->bind("~C-~S-~M-dead_macron", LFUN_MACRON);
588 // nothing with this name
589 // kbmap->bind("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
590 kbmap->bind("~C-~S-~M-dead_tilde", LFUN_TILDE);
591 kbmap->bind("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
592 // nothing with this name either...
593 //kbmap->bind("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
594 kbmap->bind("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
595 kbmap->bind("~C-~S-~M-dead_tie", LFUN_TIE);
596 kbmap->bind("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
600 // This one is not allowed to use anything on the main form, since that
601 // one does not exist yet. (Asger)
602 void LyX::queryUserLyXDir(bool explicit_userdir)
604 // Does user directory exist?
605 FileInfo fileInfo(user_lyxdir);
606 if (fileInfo.isOK() && fileInfo.isDir()) {
610 first_start = !explicit_userdir;
613 // If the user specified explicitely a directory, ask whether
614 // to create it (otherwise, always create it)
615 if (explicit_userdir &&
616 !Alert::askQuestion(_("You have specified an invalid LyX directory."),
617 _("It is needed to keep your own configuration."),
618 _("Should I try to set it up for you (recommended)?"))) {
619 lyxerr << _("Running without personal LyX directory.") << endl;
620 // No, let's use $HOME instead.
621 user_lyxdir = GetEnvPath("HOME");
625 // Tell the user what is going on
626 lyxerr << _("LyX: Creating directory ") << user_lyxdir
627 << _(" and running configure...") << endl;
629 // Create directory structure
630 if (!createDirectory(user_lyxdir, 0755)) {
631 // Failed, let's use $HOME instead.
632 user_lyxdir = GetEnvPath("HOME");
633 lyxerr << _("Failed. Will use ") << user_lyxdir
634 << _(" instead.") << endl;
638 // Run configure in user lyx directory
640 ::system(AddName(system_lyxdir, "configure").c_str());
641 lyxerr << "LyX: " << _("Done!") << endl;
645 // Read the rc file `name'
646 bool LyX::readRcFile(string const & name)
648 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
650 string const lyxrc_path = LibFileSearch(string(), name);
651 if (!lyxrc_path.empty()){
652 lyxerr[Debug::INIT] << "Found " << name
653 << " in " << lyxrc_path << endl;
654 if (lyxrc.read(lyxrc_path) < 0) {
655 Alert::alert(_("LyX Warning!"),
656 _("Error while reading ") + lyxrc_path + ".",
657 _("Using built-in defaults."));
662 lyxerr[Debug::INIT] << "Could not find " << name << endl;
669 // Read the ui file `name'
670 void LyX::readUIFile(string const & name)
678 struct keyword_item uitags[ui_last-1] = {
679 { "menuset", ui_menuset },
680 { "toolbar", ui_toolbar }
683 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
685 string const ui_path = LibFileSearch("ui", name, "ui");
687 if (ui_path.empty()) {
688 lyxerr[Debug::INIT] << "Could not find " << name << endl;
689 menubackend.defaults();
693 lyxerr[Debug::INIT] << "Found " << name
694 << " in " << ui_path << endl;
695 LyXLex lex(uitags, ui_last - 1);
696 lex.setFile(ui_path);
698 lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
702 if (lyxerr.debugging(Debug::PARSER))
703 lex.printTable(lyxerr);
708 menubackend.read(lex);
712 toolbardefaults.read(lex);
716 if(!strip(lex.getString()).empty())
717 lex.printError("LyX::ReadUIFile: "
718 "Unknown menu tag: `$$Token'");
725 // Read the languages file `name'
726 void LyX::readLanguagesFile(string const & name)
728 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
730 string const lang_path = LibFileSearch(string(), name);
731 if (lang_path.empty()) {
732 lyxerr[Debug::INIT] << "Could not find " << name << endl;
733 languages.setDefaults();
736 languages.read(lang_path);
740 // Read the encodings file `name'
741 void LyX::readEncodingsFile(string const & name)
743 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
745 string const enc_path = LibFileSearch(string(), name);
746 if (enc_path.empty()) {
747 lyxerr[Debug::INIT] << "Could not find " << name << endl;
750 encodings.read(enc_path);
756 // Set debugging level and report result to user
757 void setDebuggingLevel(string const & dbgLevel)
759 lyxerr << _("Setting debug level to ") << dbgLevel << endl;
760 lyxerr.level(Debug::value(dbgLevel));
761 Debug::showLevel(lyxerr, lyxerr.level());
765 // Give command line help
766 void commandLineHelp()
769 _("Usage: lyx [ command line switches ] [ name.lyx ... ]\n"
770 "Command line switches (case sensitive):\n"
771 "\t-help summarize LyX usage\n"
772 "\t-userdir dir try to set user directory to dir\n"
773 "\t-sysdir dir try to set system directory to dir\n"
774 "\t-geometry WxH+X+Y set geometry of the main window\n"
775 "\t-dbg feature[,feature]...\n"
776 " select the features to debug.\n"
777 " Type `lyx -dbg' to see the list of features\n"
778 "\t-x [--execute] command\n"
779 " where command is a lyx command.\n"
780 "\t-e [--export] fmt\n"
781 " where fmt is the export format of choice.\n"
782 "\t-i [--import] fmt file.xxx\n"
783 " where fmt is the import format of choice\n"
784 " and file.xxx is the file to be imported.\n"
785 "\t-version summarize version and build info\n"
786 "Check the LyX man page for more details.") << endl;
789 // Give command line version information
790 void commandLineVersionInfo()
792 lyxerr << "LyX " << lyx_version
793 << " of " << lyx_release_date << endl;
794 lyxerr << "Built on " << __DATE__ << ", " << __TIME__ << endl;
796 lyxerr << lyx_version_info << endl;
803 bool LyX::easyParse(int * argc, char * argv[])
806 int removeargs = 0; // used when options are read
807 for (int i = 1; i < *argc; ++i) {
808 string arg = argv[i];
810 // Check for -dbg int
813 setDebuggingLevel(argv[i + 1]);
816 lyxerr << _("List of supported debug flags:")
818 Debug::showTags(lyxerr);
822 // Check for "-sysdir"
823 else if (arg == "-sysdir") {
825 system_lyxdir = argv[i + 1];
828 lyxerr << _("Missing directory for -sysdir switch!")
833 // Check for "-userdir"
834 else if (arg == "-userdir") {
836 user_lyxdir = argv[i + 1];
839 lyxerr << _("Missing directory for -userdir switch!")
844 // Check for --help or -help
845 else if (arg == "--help" || arg == "-help") {
849 // Check for --version or -version
850 else if (arg == "--version" || arg == "-version") {
851 commandLineVersionInfo();
854 // Check for "-nw": No XWindows as for emacs this should
855 // give a LyX that could be used in a terminal window.
856 //else if (arg == "-nw") {
860 // Check for "-x": Execute commands
861 else if (arg == "-x" || arg == "--execute") {
863 batch_command = string(argv[i + 1]);
867 lyxerr << _("Missing command string after -x switch!") << endl;
869 // Argh. Setting gui to false segfaults..
873 else if (arg == "-e" || arg == "--export") {
875 string type(argv[i+1]);
877 batch_command = "buffer-export " + type;
880 lyxerr << _("Missing file type [eg latex, "
882 << arg << _(" switch!") << endl;
884 else if (arg == "-i" || arg == "--import") {
886 string type(argv[i+1]);
887 string file(argv[i+2]);
890 batch_command = "buffer-import " + type + " " + file;
891 lyxerr << "batch_command: "
892 << batch_command << endl;
895 lyxerr << _("Missing type [eg latex, "
897 << arg << _(" switch!") << endl;
900 if (removeargs > 0) {
901 // Now, remove used arguments by shifting
902 // the following ones removeargs places down.
903 (*argc) -= removeargs;
904 for (int j = i; j < (*argc); ++j)
905 argv[j] = argv[j + removeargs];
906 --i; // After shift, check this number again.