Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

LyX Class Reference

initial startup. More...

#include <lyx_main.h>

Inheritance diagram for LyX:

Inheritance graph
[legend]
Collaboration diagram for LyX:

Collaboration graph
[legend]
List of all members.

Public Methods

 LyX (int &argc, char *argv[])

Static Public Methods

void emergencyCleanup ()
 in the case of failure. More...


Private Methods

void init (bool)
 initial LyX set up. More...

void defaultKeyBindings (kb_keymap *kbmap)
 set up the default key bindings. More...

void deadKeyBindings (kb_keymap *kbmap)
 set up the default dead key bindings if requested. More...

void queryUserLyXDir (bool explicit_userdir)
 check, set up and configure the user dir if necessary. More...

void readRcFile (string const &name)
 read lyxrc/preferences. More...

void readUIFile (string const &name)
 read the given ui (menu/toolbar) file. More...

void readLanguagesFile (string const &name)
 read the given languages file. More...

void readEncodingsFile (string const &name)
 read the given encodings file. More...

bool easyParse (int &argc, char *argv[])
 parsing of non-gui LyX options. Returns true if gui. More...

void printError (ErrorItem const &)
 shows up a parsing error on screen. More...


Private Attributes

bool first_start
 has this user started lyx for the first time? More...

string batch_command
 the parsed command line batch command if any. More...


Detailed Description

initial startup.

Definition at line 39 of file lyx_main.h.


Constructor & Destructor Documentation

LyX::LyX int &    argc,
char *    argv[]
 

Definition at line 96 of file lyx_main.C.

References _, batch_command, defaultKeyBindings, easyParse, lyx_gui::exit, lyx::support::i18nLibFileSearch, init, Debug::INIT, lyxerr, lyx_gui::parse_init, lyx_gui::parse_lyxrc, and toplevel_keymap.

00097 {
00098         // Here we need to parse the command line. At least
00099         // we need to parse for "-dbg" and "-help"
00100         bool const want_gui = easyParse(argc, argv);
00101 
00102         // Global bindings (this must be done as early as possible.) (Lgb)
00103         toplevel_keymap.reset(new kb_keymap);
00104         defaultKeyBindings(toplevel_keymap.get());
00105 
00106         // set the DisplayTranslator only once; should that be done here??
00107         // if this should not be in this file, please also remove
00108         // #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
00109         grfx::setDisplayTranslator();
00110 
00111         if (want_gui) {
00112                 lyx_gui::parse_init(argc, argv);
00113         }
00114 
00115         // check for any spurious extra arguments
00116         // other than documents
00117         for (int argi = 1; argi < argc ; ++argi) {
00118                 if (argv[argi][0] == '-') {
00119                         lyxerr << bformat(_("Wrong command line option `%1$s'. Exiting."),
00120                                 argv[argi]) << endl;
00121                         exit(1);
00122                 }
00123         }
00124 
00125         // Initialization of LyX (reads lyxrc and more)
00126         lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
00127         init(want_gui);
00128         lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
00129 
00130         if (want_gui) {
00131                 lyx_gui::parse_lyxrc();
00132         }
00133 
00134         vector<string> files;
00135 
00136         for (int argi = argc - 1; argi >= 1; --argi) {
00137                 files.push_back(argv[argi]);
00138         }
00139 
00140         if (first_start)
00141                 files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
00142 
00143         // Execute batch commands if available
00144         if (!batch_command.empty()) {
00145                 lyxerr[Debug::INIT] << "About to handle -x '"
00146                        << batch_command << '\'' << endl;
00147 
00148                 Buffer * last_loaded = 0;
00149 
00150                 vector<string>::const_iterator it = files.begin();
00151                 vector<string>::const_iterator end = files.end();
00152 
00153                 for (; it != end; ++it) {
00154                         // get absolute path of file and add ".lyx" to
00155                         // the filename if necessary
00156                         string s = FileSearch(string(), *it, "lyx");
00157                         if (s.empty()) {
00158                                 s = *it;
00159                         }
00160 
00161                         last_loaded = bufferlist.newBuffer(s, false);
00162                         last_loaded->error.connect(boost::bind(&LyX::printError, this, _1));
00163                         loadLyXFile(last_loaded, s);
00164                 }
00165 
00166                 files.clear();
00167 
00168                 bool success = false;
00169 
00170                 // try to dispatch to last loaded buffer first
00171                 bool const dispatched = last_loaded->dispatch(batch_command, &success);
00172 
00173                 if (dispatched) {
00174                         QuitLyX();
00175                         exit(!success);
00176                 }
00177         }
00178 
00179         lyx_gui::start(batch_command, files);
00180 }


Member Function Documentation

void LyX::deadKeyBindings kb_keymap   kbmap [private]
 

set up the default dead key bindings if requested.

Definition at line 569 of file lyx_main.C.

References kb_keymap::bind, LFUN_ACUTE, LFUN_BREVE, LFUN_CARON, LFUN_CEDILLA, LFUN_CIRCLE, LFUN_CIRCUMFLEX, LFUN_DOT, LFUN_GRAVE, LFUN_HUNG_UMLAUT, LFUN_MACRON, LFUN_OGONEK, LFUN_TIE, LFUN_TILDE, LFUN_UMLAUT, and LFUN_UNDERDOT.

00570 {
00571         // bindKeyings for transparent handling of deadkeys
00572         // The keysyms are gotten from XFree86 X11R6
00573         kbmap->bind("~C-~S-~M-dead_acute", LFUN_ACUTE);
00574         kbmap->bind("~C-~S-~M-dead_breve", LFUN_BREVE);
00575         kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON);
00576         kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
00577         kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
00578         kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
00579         kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT);
00580         kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE);
00581         kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
00582         kbmap->bind("~C-~S-~M-dead_macron", LFUN_MACRON);
00583         // nothing with this name
00584         // kbmap->bind("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
00585         kbmap->bind("~C-~S-~M-dead_tilde", LFUN_TILDE);
00586         kbmap->bind("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
00587         // nothing with this name either...
00588         //kbmap->bind("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
00589         kbmap->bind("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
00590         kbmap->bind("~C-~S-~M-dead_tie", LFUN_TIE);
00591         kbmap->bind("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
00592 }

void LyX::defaultKeyBindings kb_keymap   kbmap [private]
 

set up the default key bindings.

Definition at line 498 of file lyx_main.C.

References kb_keymap::bind, LFUN_BACKSPACE, LFUN_BREAKPARAGRAPH, LFUN_CELL_BACKWARD, LFUN_CELL_FORWARD, LFUN_CELL_SPLIT, LFUN_DELETE, LFUN_DOWN, LFUN_END, LFUN_HOME, LFUN_LEFT, LFUN_NEXT, LFUN_PRIOR, LFUN_RIGHT, LFUN_SUBSCRIPT, LFUN_SUPERSCRIPT, and LFUN_UP.

Referenced by LyX.

00499 {
00500         kbmap->bind("Right", LFUN_RIGHT);
00501         kbmap->bind("Left", LFUN_LEFT);
00502         kbmap->bind("Up", LFUN_UP);
00503         kbmap->bind("Down", LFUN_DOWN);
00504 
00505         kbmap->bind("Tab", LFUN_CELL_FORWARD);
00506         kbmap->bind("ISO_Left_Tab", LFUN_CELL_FORWARD); // jbl 2001-23-02
00507 
00508         kbmap->bind("Home", LFUN_HOME);
00509         kbmap->bind("End", LFUN_END);
00510         kbmap->bind("Prior", LFUN_PRIOR);
00511         kbmap->bind("Next", LFUN_NEXT);
00512 
00513         kbmap->bind("Return", LFUN_BREAKPARAGRAPH);
00514         //kbmap->bind("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
00515 
00516         kbmap->bind("Delete", LFUN_DELETE);
00517         kbmap->bind("BackSpace", LFUN_BACKSPACE);
00518 
00519         // sub- and superscript -MV
00520         kbmap->bind("~S-underscore", LFUN_SUBSCRIPT);
00521         kbmap->bind("~S-asciicircum", LFUN_SUPERSCRIPT);
00522 
00523         // kbmap->bindings to enable the use of the numeric keypad
00524         // e.g. Num Lock set
00525         //kbmap->bind("KP_0", LFUN_SELFINSERT);
00526         //kbmap->bind("KP_Decimal", LFUN_SELFINSERT);
00527         kbmap->bind("KP_Enter", LFUN_BREAKPARAGRAPH);
00528         //kbmap->bind("KP_1", LFUN_SELFINSERT);
00529         //kbmap->bind("KP_2", LFUN_SELFINSERT);
00530         //kbmap->bind("KP_3", LFUN_SELFINSERT);
00531         //kbmap->bind("KP_4", LFUN_SELFINSERT);
00532         //kbmap->bind("KP_5", LFUN_SELFINSERT);
00533         //kbmap->bind("KP_6", LFUN_SELFINSERT);
00534         //kbmap->bind("KP_Add", LFUN_SELFINSERT);
00535         //kbmap->bind("KP_7", LFUN_SELFINSERT);
00536         //kbmap->bind("KP_8", LFUN_SELFINSERT);
00537         //kbmap->bind("KP_9", LFUN_SELFINSERT);
00538         //kbmap->bind("KP_Divide", LFUN_SELFINSERT);
00539         //kbmap->bind("KP_Multiply", LFUN_SELFINSERT);
00540         //kbmap->bind("KP_Subtract", LFUN_SELFINSERT);
00541         kbmap->bind("KP_Right", LFUN_RIGHT);
00542         kbmap->bind("KP_Left", LFUN_LEFT);
00543         kbmap->bind("KP_Up", LFUN_UP);
00544         kbmap->bind("KP_Down", LFUN_DOWN);
00545         kbmap->bind("KP_Home", LFUN_HOME);
00546         kbmap->bind("KP_End", LFUN_END);
00547         kbmap->bind("KP_Prior", LFUN_PRIOR);
00548         kbmap->bind("KP_Next", LFUN_NEXT);
00549 
00550         kbmap->bind("C-Tab", LFUN_CELL_SPLIT);  // ale970515
00551         kbmap->bind("S-Tab", LFUN_CELL_BACKWARD);  // jug20000522
00552         kbmap->bind("S-ISO_Left_Tab", LFUN_CELL_BACKWARD); // jbl 2001-23-02
00553 }

bool LyX::easyParse int &    argc,
char *    argv[]
[private]
 

parsing of non-gui LyX options. Returns true if gui.

Definition at line 889 of file lyx_main.C.

References batch, batch_command, is_gui, parse_dbg, parse_execute, parse_export, parse_help, parse_import, parse_sysdir, parse_userdir, and parse_version.

Referenced by LyX.

00890 {
00891         std::map<string, cmd_helper> cmdmap;
00892 
00893         cmdmap["-dbg"] = parse_dbg;
00894         cmdmap["-help"] = parse_help;
00895         cmdmap["--help"] = parse_help;
00896         cmdmap["-version"] = parse_version;
00897         cmdmap["--version"] = parse_version;
00898         cmdmap["-sysdir"] = parse_sysdir;
00899         cmdmap["-userdir"] = parse_userdir;
00900         cmdmap["-x"] = parse_execute;
00901         cmdmap["--execute"] = parse_execute;
00902         cmdmap["-e"] = parse_export;
00903         cmdmap["--export"] = parse_export;
00904         cmdmap["-i"] = parse_import;
00905         cmdmap["--import"] = parse_import;
00906 
00907         for (int i = 1; i < argc; ++i) {
00908                 std::map<string, cmd_helper>::const_iterator it
00909                         = cmdmap.find(argv[i]);
00910 
00911                 // don't complain if not found - may be parsed later
00912                 if (it == cmdmap.end())
00913                         continue;
00914 
00915                 string arg((i + 1 < argc) ? argv[i + 1] : "");
00916                 string arg2((i + 2 < argc) ? argv[i + 2] : "");
00917 
00918                 int const remove = 1 + it->second(arg, arg2);
00919 
00920                 // Now, remove used arguments by shifting
00921                 // the following ones remove places down.
00922                 argc -= remove;
00923                 for (int j = i; j < argc; ++j)
00924                         argv[j] = argv[j + remove];
00925                 --i;
00926         }
00927 
00928         batch_command = batch;
00929 
00930         return is_gui;
00931 }

void LyX::emergencyCleanup   [static]
 

in the case of failure.

Definition at line 556 of file lyx_main.C.

References bufferlist, LyXServer::emergencyCleanup, BufferList::emergencyWriteAll, and lyxserver.

Referenced by error_handler, and LyX_XErrHandler.

00557 {
00558         // what to do about tmpfiles is non-obvious. we would
00559         // like to delete any we find, but our lyxdir might
00560         // contain documents etc. which might be helpful on
00561         // a crash
00562 
00563         bufferlist.emergencyWriteAll();
00564         if (lyxserver)
00565                 lyxserver->emergencyCleanup();
00566 }

void LyX::init bool    [private]
 

initial LyX set up.

Definition at line 237 of file lyx_main.C.

References _, lyx::support::AddName, lyx::support::AddPath, os::binname, os::binpath, build_lyxdir, lyx::support::CreateLyXTmpDir, DebugStream::debugging, error_handler, lyx_gui::exit, lyx::support::FileOpenSearch, lyx::support::FileSearch, first_start, lyx::support::GetEnvPath, os::getTmpDir, Debug::INIT, lastfiles, lyx::support::LibFileSearch, LYX_DIR, lyxerr, Debug::LYXRC, lyx::support::LyXReadLink, LyXSetStyle, lyx::support::MakeAbsPath, lyx::support::NormalizePath, lyx::support::OnlyFilename, lyx::support::OnlyPath, PACKAGE, queryUserLyXDir, readEncodingsFile, readLanguagesFile, readRcFile, readUIFile, lyx_gui::roman_font_name, lyx_gui::sans_font_name, os::setTmpDir, system_lyxdir, system_tempdir, TOP_SRCDIR, lyx_gui::typewriter_font_name, and user_lyxdir.

Referenced by LyX.

00238 {
00239         signal(SIGHUP, error_handler);
00240         signal(SIGFPE, error_handler);
00241         signal(SIGSEGV, error_handler);
00242         signal(SIGINT, error_handler);
00243         signal(SIGTERM, error_handler);
00244 
00245         //
00246         // Determine path of binary
00247         //
00248 
00249         string binpath = os::binpath();
00250         string binname = os::binname();
00251         string fullbinname = MakeAbsPath(binname, binpath);
00252 
00253         if (binpath.empty()) {
00254                 lyxerr << _("Warning: could not determine path of binary.")
00255                        << "\n"
00256                        << _("If you have problems, try starting LyX with an absolute path.")
00257                        << endl;
00258         }
00259         lyxerr[Debug::INIT] << "Name of binary: " << binname << endl;
00260         lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
00261 
00262         //
00263         // Determine system directory.
00264         //
00265 
00266         // Directories are searched in this order:
00267         // 1) -sysdir command line parameter
00268         // 2) LYX_DIR_14x environment variable
00269         // 3) Maybe <path of binary>/TOP_SRCDIR/lib
00270         // 4) <path of binary>/../share/<name of binary>/
00271         // 4a) repeat 4 after following the Symlink if <path of
00272         //     binary> is a symbolic link.
00273         // 5) hardcoded lyx_dir
00274         // The directory is checked for the presence of the file
00275         // "chkconfig.ltx", and if that is present, the directory
00276         // is accepted as the system directory.
00277         // If no chkconfig.ltx file is found, a warning is given,
00278         // and the hardcoded lyx_dir is used.
00279 
00280         // If we had a command line switch, system_lyxdir is already set
00281         string searchpath;
00282         if (!system_lyxdir.empty())
00283                 searchpath = MakeAbsPath(system_lyxdir) + ';';
00284 
00285         string const lyxdir = GetEnvPath("LYX_DIR_14x");
00286 
00287         if (!lyxdir.empty()) {
00288                 lyxerr[Debug::INIT] << "LYX_DIR_14x: " << lyxdir << endl;
00289                 searchpath += lyxdir + ';';
00290         }
00291 
00292         string fullbinpath = binpath;
00293         FileInfo file(fullbinname, true);
00294         if (file.isLink()) {
00295                 lyxerr[Debug::INIT] << "binary is a link" << endl;
00296                 string link;
00297                 if (LyXReadLink(fullbinname, link, true)) {
00298                         // Path of binary/../share/name of binary/
00299                         searchpath += NormalizePath(AddPath(binpath,
00300                                                             "../share/")
00301                                                     + OnlyFilename(binname));
00302                         searchpath += ';';
00303                         fullbinpath = link;
00304                         binpath = MakeAbsPath(OnlyPath(fullbinpath));
00305                 }
00306         }
00307 
00308         bool followlink;
00309         do {
00310                 // Path of binary/../share/name of binary/
00311                 searchpath += NormalizePath(AddPath(binpath, "../share/") +
00312                       OnlyFilename(binname)) + ';';
00313 
00314                 // Follow Symlinks
00315                 FileInfo file(fullbinpath, true);
00316                 followlink = file.isLink();
00317                 if (followlink) {
00318                         lyxerr[Debug::INIT] << " directory " << fullbinpath
00319                                             << " is a link" << endl;
00320                         string link;
00321                         if (LyXReadLink(fullbinpath, link, true)) {
00322                                 fullbinpath = link;
00323                                 binpath = MakeAbsPath(OnlyPath(fullbinpath));
00324                         }
00325                         else {
00326                                 followlink = false;
00327                         }
00328                 }
00329         } while (followlink);
00330 
00331         // <path of binary>/TOP_SRCDIR/lib
00332         build_lyxdir = MakeAbsPath("../lib", binpath);
00333         if (!FileSearch(build_lyxdir, "lyxrc.defaults").empty()) {
00334                 searchpath += MakeAbsPath(AddPath(TOP_SRCDIR, "lib"),
00335                                           binpath) + ';';
00336                 lyxerr[Debug::INIT] << "Checking whether LyX is run in "
00337                         "place... yes" << endl;
00338         } else {
00339                 lyxerr[Debug::INIT]
00340                         << "Checking whether LyX is run in place... no"
00341                         << endl;
00342                 build_lyxdir.erase();
00343         }
00344 
00345         // Hardcoded dir
00346         searchpath += LYX_DIR;
00347 
00348         lyxerr[Debug::INIT] << "System directory search path: "
00349                             << searchpath << endl;
00350 
00351         string const filename = "chkconfig.ltx";
00352         string const temp = FileOpenSearch(searchpath, filename, string());
00353         system_lyxdir = OnlyPath(temp);
00354 
00355         // Reduce "path/../path" stuff out of system directory
00356         system_lyxdir = NormalizePath(system_lyxdir);
00357 
00358         bool path_shown = false;
00359 
00360         // Warn if environment variable is set, but unusable
00361         if (!lyxdir.empty()) {
00362                 if (system_lyxdir != NormalizePath(lyxdir)) {
00363                         lyxerr <<_("LYX_DIR_14x environment variable no good.")
00364                                << '\n'
00365                                << _("System directory set to: ")
00366                                << system_lyxdir << endl;
00367                         path_shown = true;
00368                 }
00369         }
00370 
00371         // Warn the user if we couldn't find "chkconfig.ltx"
00372         if (system_lyxdir == "./") {
00373                 lyxerr <<_("LyX Warning! Couldn't determine system directory. ")
00374                        <<_("Try the '-sysdir' command line parameter or ")
00375                        <<_("set the environment variable LYX_DIR_14x to the "
00376                            "LyX system directory ")
00377                        << _("containing the file `chkconfig.ltx'.") << endl;
00378                 if (!path_shown) {
00379                         FileInfo fi(LYX_DIR);
00380                         if (!fi.exist()) {
00381                                 lyxerr << "Couldn't even find the default LYX_DIR." << endl
00382                                         << "Giving up." << endl;
00383                                 exit(1);
00384                         }
00385                         lyxerr << bformat(_("Using built-in default %1$s but expect problems."),
00386                                 LYX_DIR) << endl;
00387                 } else {
00388                         lyxerr << _("Expect problems.") << endl;
00389                 }
00390                 system_lyxdir = LYX_DIR;
00391                 path_shown = true;
00392         }
00393 
00394         if (!path_shown)
00395                 lyxerr[Debug::INIT] << "System directory: '"
00396                                     << system_lyxdir << '\'' << endl;
00397 
00398         //
00399         // Determine user lyx-dir
00400         //
00401 
00402         // Directories are searched in this order:
00403         // 1) -userdir command line parameter
00404         // 2) LYX_USERDIR_14x environment variable
00405         // 3) $HOME/.<name of binary>
00406 
00407         // If we had a command line switch, user_lyxdir is already set
00408         bool explicit_userdir = true;
00409         if (user_lyxdir.empty()) {
00410 
00411                 // LYX_USERDIR_14x environment variable
00412                 user_lyxdir = GetEnvPath("LYX_USERDIR_14x");
00413 
00414                 // default behaviour
00415                 if (user_lyxdir.empty())
00416                         user_lyxdir = AddPath(GetEnvPath("HOME"),
00417                                                         string(".") + PACKAGE);
00418                         explicit_userdir = false;
00419         }
00420 
00421         lyxerr[Debug::INIT] << "User LyX directory: '"
00422                             <<  user_lyxdir << '\'' << endl;
00423 
00424         // Check that user LyX directory is ok. We don't do that if
00425         // running in batch mode.
00426         if (gui) {
00427                 queryUserLyXDir(explicit_userdir);
00428         } else {
00429                 first_start = false;
00430         }
00431 
00432         // Disable gui when easyparse says so
00433         lyx_gui::use_gui = gui;
00434 
00435         if (lyxrc.template_path.empty()) {
00436                 lyxrc.template_path = AddPath(system_lyxdir, "templates");
00437         }
00438 
00439         if (lyxrc.lastfiles.empty()) {
00440                 lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
00441         }
00442 
00443         if (lyxrc.roman_font_name.empty())
00444                 lyxrc.roman_font_name = lyx_gui::roman_font_name();
00445         if (lyxrc.sans_font_name.empty())
00446                 lyxrc.sans_font_name = lyx_gui::sans_font_name();
00447         if (lyxrc.typewriter_font_name.empty())
00448                 lyxrc.typewriter_font_name = lyx_gui::typewriter_font_name();
00449 
00450         //
00451         // Read configuration files
00452         //
00453 
00454         readRcFile("lyxrc.defaults");
00455         system_lyxrc = lyxrc;
00456         system_formats = formats;
00457         system_converters = converters;
00458         system_lcolor = lcolor;
00459 
00460         string prefsfile = "preferences";
00461         // back compatibility to lyxs < 1.1.6
00462         if (LibFileSearch(string(), prefsfile).empty())
00463                 prefsfile = "lyxrc";
00464         if (!LibFileSearch(string(), prefsfile).empty())
00465                 readRcFile(prefsfile);
00466 
00467         readEncodingsFile("encodings");
00468         readLanguagesFile("languages");
00469 
00470         // Load the layouts
00471         lyxerr[Debug::INIT] << "Reading layouts..." << endl;
00472         LyXSetStyle();
00473 
00474         // Ensure that we have really read a bind file, so that LyX is
00475         // usable.
00476         lyxrc.readBindFileIfNeeded();
00477 
00478         // Read menus
00479         readUIFile(lyxrc.ui_file);
00480 
00481         if (lyxerr.debugging(Debug::LYXRC))
00482                 lyxrc.print();
00483 
00484         os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
00485         system_tempdir = os::getTmpDir();
00486         if (lyxerr.debugging(Debug::INIT)) {
00487                 lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
00488         }
00489 
00490         lyxerr[Debug::INIT] << "Reading lastfiles `"
00491                             << lyxrc.lastfiles << "'..." << endl;
00492         lastfiles.reset(new LastFiles(lyxrc.lastfiles,
00493                                       lyxrc.check_lastfiles,
00494                                       lyxrc.num_lastfiles));
00495 }

void LyX::printError ErrorItem const &    [private]
 

shows up a parsing error on screen.

Definition at line 229 of file lyx_main.C.

References _, ErrorItem::description, and ErrorItem::error.

00230 {
00231         std::cerr << _("LyX: ") << ei.error
00232                   << ':' << ei.description << std::endl;
00233 
00234 }

void LyX::queryUserLyXDir bool    explicit_userdir [private]
 

check, set up and configure the user dir if necessary.

Definition at line 595 of file lyx_main.C.

References _, lyx::support::AddName, lyx::support::createDirectory, first_start, lyx::support::GetEnvPath, lyxerr, Path, system_lyxdir, and user_lyxdir.

Referenced by init.

00596 {
00597         string const configure_script = AddName(system_lyxdir, "configure");
00598 
00599         // Does user directory exist?
00600         FileInfo fileInfo(user_lyxdir);
00601         if (fileInfo.isOK() && fileInfo.isDir()) {
00602                 first_start = false;
00603                 FileInfo script(configure_script);
00604                 FileInfo defaults(AddName(user_lyxdir, "lyxrc.defaults"));
00605                 if (defaults.isOK() && script.isOK()
00606                     && defaults.getModificationTime() < script.getModificationTime()) {
00607                         lyxerr << _("LyX: reconfiguring user directory")
00608                                << endl;
00609                         Path p(user_lyxdir);
00610                         ::system(configure_script.c_str());
00611                         lyxerr << "LyX: " << _("Done!") << endl;
00612                 }
00613                 return;
00614         }
00615 
00616         first_start = !explicit_userdir;
00617 
00618         lyxerr << bformat(_("LyX: Creating directory %1$s"
00619                                   " and running configure..."), user_lyxdir) << endl;
00620 
00621         if (!createDirectory(user_lyxdir, 0755)) {
00622                 // Failed, let's use $HOME instead.
00623                 user_lyxdir = GetEnvPath("HOME");
00624                 lyxerr << bformat(_("Failed. Will use %1$s instead."),
00625                         user_lyxdir) << endl;
00626                 return;
00627         }
00628 
00629         // Run configure in user lyx directory
00630         Path p(user_lyxdir);
00631         ::system(configure_script.c_str());
00632         lyxerr << "LyX: " << _("Done!") << endl;
00633 }

void LyX::readEncodingsFile string const &    name [private]
 

read the given encodings file.

Definition at line 753 of file lyx_main.C.

References Debug::INIT, lyx::support::LibFileSearch, lyxerr, and showFileError.

Referenced by init.

00754 {
00755         lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
00756 
00757         string const enc_path = LibFileSearch(string(), name);
00758         if (enc_path.empty()) {
00759                 showFileError(name);
00760                 return;
00761         }
00762         encodings.read(enc_path);
00763 }

void LyX::readLanguagesFile string const &    name [private]
 

read the given languages file.

Definition at line 739 of file lyx_main.C.

References Debug::INIT, lyx::support::LibFileSearch, lyxerr, and showFileError.

Referenced by init.

00740 {
00741         lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
00742 
00743         string const lang_path = LibFileSearch(string(), name);
00744         if (lang_path.empty()) {
00745                 showFileError(name);
00746                 return;
00747         }
00748         languages.read(lang_path);
00749 }

void LyX::readRcFile string const &    name [private]
 

read lyxrc/preferences.

Definition at line 636 of file lyx_main.C.

References Debug::INIT, lyx::support::LibFileSearch, lyxerr, and showFileError.

Referenced by init.

00637 {
00638         lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
00639 
00640         string const lyxrc_path = LibFileSearch(string(), name);
00641         if (!lyxrc_path.empty()) {
00642 
00643                 lyxerr[Debug::INIT] << "Found " << name
00644                                     << " in " << lyxrc_path << endl;
00645 
00646                 if (lyxrc.read(lyxrc_path) >= 0)
00647                         return;
00648         }
00649 
00650         showFileError(name);
00651 }

void LyX::readUIFile string const &    name [private]
 

read the given ui (menu/toolbar) file.

Definition at line 655 of file lyx_main.C.

References DebugStream::debugging, LyXLex::getString, Debug::INIT, LyXLex::isOK, LyXLex::lex, lyx::support::LibFileSearch, lyxerr, LyXLex::next, Debug::PARSER, LyXLex::printError, LyXLex::printTable, lyx::support::rtrim, LyXLex::setFile, and showFileError.

Referenced by init.

00656 {
00657         enum Uitags {
00658                 ui_menuset = 1,
00659                 ui_toolbar,
00660                 ui_toolbars,
00661                 ui_include,
00662                 ui_last
00663         };
00664 
00665         struct keyword_item uitags[ui_last - 1] = {
00666                 { "include", ui_include },
00667                 { "menuset", ui_menuset },
00668                 { "toolbar", ui_toolbar },
00669                 { "toolbars", ui_toolbars }
00670         };
00671 
00672         // Ensure that a file is read only once (prevents include loops)
00673         static std::list<string> uifiles;
00674         std::list<string>::const_iterator it  = uifiles.begin();
00675         std::list<string>::const_iterator end = uifiles.end();
00676         it = std::find(it, end, name);
00677         if (it != end) {
00678                 lyxerr[Debug::INIT] << "UI file '" << name
00679                                     << "' has been read already. "
00680                                     << "Is this an include loop?"
00681                                     << endl;
00682                 return;
00683         }
00684 
00685         lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
00686 
00687         string const ui_path = LibFileSearch("ui", name, "ui");
00688 
00689         if (ui_path.empty()) {
00690                 lyxerr[Debug::INIT] << "Could not find " << name << endl;
00691                 showFileError(name);
00692                 return;
00693         }
00694         uifiles.push_back(name);
00695 
00696         lyxerr[Debug::INIT] << "Found " << name
00697                             << " in " << ui_path << endl;
00698         LyXLex lex(uitags, ui_last - 1);
00699         lex.setFile(ui_path);
00700         if (!lex.isOK()) {
00701                 lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
00702                        << endl;
00703         }
00704 
00705         if (lyxerr.debugging(Debug::PARSER))
00706                 lex.printTable(lyxerr);
00707 
00708         while (lex.isOK()) {
00709                 switch (lex.lex()) {
00710                 case ui_include: {
00711                         lex.next(true);
00712                         string const file = lex.getString();
00713                         readUIFile(file);
00714                         break;
00715                 }
00716                 case ui_menuset:
00717                         menubackend.read(lex);
00718                         break;
00719 
00720                 case ui_toolbar:
00721                         toolbarbackend.read(lex);
00722                         break;
00723 
00724                 case ui_toolbars:
00725                         toolbarbackend.readToolbars(lex);
00726                         break;
00727 
00728                 default:
00729                         if (!rtrim(lex.getString()).empty())
00730                                 lex.printError("LyX::ReadUIFile: "
00731                                                "Unknown menu tag: `$$Token'");
00732                         break;
00733                 }
00734         }
00735 }


Member Data Documentation

string LyX::batch_command [private]
 

the parsed command line batch command if any.

Definition at line 71 of file lyx_main.h.

Referenced by easyParse, and LyX.

bool LyX::first_start [private]
 

has this user started lyx for the first time?

Definition at line 69 of file lyx_main.h.

Referenced by init, and queryUserLyXDir.


The documentation for this class was generated from the following files:
Generated on Fri Jul 18 01:17:54 2003 for lyx by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002