From: Angus Leeming Date: Sun, 16 Jan 2005 21:01:41 +0000 (+0000) Subject: The LyXRC::prepend_path patch as tested on the Mac by Andreas. X-Git-Tag: 1.6.10~14652 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3f938d4dbfdccd9829d4d1216a51805f55f07bfe;p=features.git The LyXRC::prepend_path patch as tested on the Mac by Andreas. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9485 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index d5b171f48b..1a81bcc627 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2005-01-16 Angus Leeming + + * lyx_main.[Ch] (init): rewrite code to prepend the CWD to the PATH + for MacOSX and Windows to use prependEnvPath. + Strip out the hard-coded block to add elements to the PATH for + MacOSX and replace it with a call to prependEnvPath using the + contents of LyXRC::path_prefix. + (queryUserLyXDir): strip out the code to run reconfigure, instead + returning a boolean indicating the necessity to do so. + (reconfigureUserLyXDir): contains the code to reconfigure the + user support directory. Is now called after the various LyXRC data + files have been read. + + * lyxrc.[Ch]: add path_prefix var and code to read/write it. + 2005-01-14 Georg Baum * converter.[Ch] (convert): take a new parameter try_default. Use diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 8941658acc..f36d3678ab 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2005-01-15 Angus Leeming + + * QPrefs.C, QPrefsDialog.C, ui/QPrefPathsModule.ui: add an interface + to modify LyXRC::path_prefix. + 2005-01-15 Angus Leeming * ui/Makefile.am: enable Qt's uic to process the .ui files diff --git a/src/frontends/qt2/QPrefs.C b/src/frontends/qt2/QPrefs.C index 52120b67ad..3e2a9bedd9 100644 --- a/src/frontends/qt2/QPrefs.C +++ b/src/frontends/qt2/QPrefs.C @@ -244,6 +244,7 @@ void QPrefs::apply() rc.template_path = fromqstr(pathsmod->templateDirED->text()); rc.backupdir_path = fromqstr(pathsmod->backupDirED->text()); rc.tempdir_path = fromqstr(pathsmod->tempDirED->text()); + rc.path_prefix = fromqstr(pathsmod->pathPrefixED->text()); // FIXME: should be a checkbox only rc.lyxpipes = fromqstr(pathsmod->lyxserverDirED->text()); @@ -560,10 +561,10 @@ void QPrefs::update_contents() pathsmod->templateDirED->setText(toqstr(rc.template_path)); pathsmod->backupDirED->setText(toqstr(rc.backupdir_path)); pathsmod->tempDirED->setText(toqstr(rc.tempdir_path)); + pathsmod->pathPrefixED->setText(toqstr(rc.path_prefix)); // FIXME: should be a checkbox only pathsmod->lyxserverDirED->setText(toqstr(rc.lyxpipes)); - QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule); spellmod->spellCommandCO->setCurrentItem(0); diff --git a/src/frontends/qt2/QPrefsDialog.C b/src/frontends/qt2/QPrefsDialog.C index 1a6496fa22..4ace42d6c5 100644 --- a/src/frontends/qt2/QPrefsDialog.C +++ b/src/frontends/qt2/QPrefsDialog.C @@ -248,6 +248,7 @@ QPrefsDialog::QPrefsDialog(QPrefs * form) connect(pathsModule->backupDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(pathsModule->tempDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(pathsModule->lyxserverDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(pathsModule->pathPrefixED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(spellcheckerModule->spellCommandCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(spellcheckerModule->altLanguageED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); connect(spellcheckerModule->escapeCharactersED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); diff --git a/src/frontends/qt2/ui/QPrefPathsModule.ui b/src/frontends/qt2/ui/QPrefPathsModule.ui index dda3befe4c..3201a546fd 100644 --- a/src/frontends/qt2/ui/QPrefPathsModule.ui +++ b/src/frontends/qt2/ui/QPrefPathsModule.ui @@ -13,8 +13,8 @@ 0 0 - 294 - 196 + 387 + 329 @@ -34,7 +34,7 @@ QLayoutWidget name - Layout2 + Layout3 @@ -52,11 +52,11 @@ tempDirED - + QPushButton name - templateDirPB + lyxserverDirPB text @@ -67,33 +67,33 @@ false - - QLineEdit - - name - workingDirED - - - - QPushButton + + QLabel name - tempDirPB + templateDirLA text - Browse... + &Document templates: + + buddy + templateDirED + + + + QLineEdit - autoDefault - false + name + workingDirED - + QLineEdit name - templateDirED + backupDirED @@ -111,56 +111,56 @@ backupDirED - + QLabel name - templateDirLA + tempDirLA text - &Document templates: + &Temporary directory: buddy - templateDirED + tempDirED - + QLabel name - lyxserverDirLA + pathPrefixLA text - Ly&XServer pipe: + &PATH prefix: buddy - lyxserverDirED + pathPrefixED - + QLabel name - tempDirLA + workingDirLA text - &Temporary directory: + &Working directory: buddy - tempDirED + workingDirED - + QPushButton name - lyxserverDirPB + workingDirPB text @@ -171,18 +171,25 @@ false - + QLineEdit name - backupDirED + templateDirED - + + QLineEdit + + name + lyxserverDirED + + + QPushButton name - workingDirPB + tempDirPB text @@ -193,33 +200,33 @@ false - - QLabel + + QPushButton name - workingDirLA + backupDirPB text - &Working directory: + Browse... - - buddy - workingDirED + + autoDefault + false - + QLineEdit name - lyxserverDirED + pathPrefixED - + QPushButton name - backupDirPB + templateDirPB text @@ -230,6 +237,21 @@ false + + QLabel + + name + lyxserverDirLA + + + text + Ly&XServer pipe: + + + buddy + lyxserverDirED + + diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 3ffbd9a7f0..4efdf27f25 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2005-01-15 Angus Leeming + + * FormPreferences.C, forms/form_preferences.fd: add an interface + to modify LyXRC::path_prefix. + 2005-01-13 Angus Leeming * FormPreferences.C: code to get/set the value diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 02ffb2bb5e..d05f4a4e95 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -2193,6 +2193,7 @@ void FormPreferences::Paths::apply(LyXRC & rc) rc.document_path = getString(dialog_->input_default_path); rc.template_path = getString(dialog_->input_template_path); rc.tempdir_path = getString(dialog_->input_temp_dir); + rc.path_prefix = getString(dialog_->input_path_prefix); int button = fl_get_button(dialog_->check_last_files); string str = getString(dialog_->input_lastfiles); @@ -2225,6 +2226,7 @@ void FormPreferences::Paths::build() fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED); + fl_set_input_return(dialog_->input_path_prefix, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED); fl_set_counter_bounds(dialog_->counter_lastfiles, 0, maxlastfiles); @@ -2235,6 +2237,7 @@ void FormPreferences::Paths::build() setPrehandler(dialog_->input_default_path); setPrehandler(dialog_->counter_lastfiles); setPrehandler(dialog_->input_template_path); + setPrehandler(dialog_->input_path_prefix); setPrehandler(dialog_->check_last_files); setPrehandler(dialog_->input_lastfiles); setPrehandler(dialog_->check_make_backups); @@ -2265,6 +2268,10 @@ FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH); if (ob == dialog_->input_serverpipe) return LyXRC::getDescription(LyXRC::RC_SERVERPIPE); + if (ob == dialog_->input_path_prefix) + return _("Specify those directories which should be" + "prepended to the PATH environment variable. " + "Use the OS native format."); return string(); } @@ -2400,6 +2407,7 @@ void FormPreferences::Paths::update(LyXRC const & rc) fl_set_input(dialog_->input_backup_path, str.c_str()); fl_set_input(dialog_->input_temp_dir, rc.tempdir_path.c_str()); + fl_set_input(dialog_->input_path_prefix, rc.path_prefix.c_str()); str.erase(); if (rc.check_lastfiles) diff --git a/src/frontends/xforms/forms/form_preferences.fd b/src/frontends/xforms/forms/form_preferences.fd index 5c567b36b8..82cea1b7c0 100644 --- a/src/frontends/xforms/forms/form_preferences.fd +++ b/src/frontends/xforms/forms/form_preferences.fd @@ -2155,7 +2155,7 @@ argument: 0 Name: form_preferences_paths Width: 450 Height: 350 -Number of Objects: 16 +Number of Objects: 17 -------------------- class: FL_BOX @@ -2451,6 +2451,24 @@ name: button_serverpipe_browse callback: C_FormDialogView_InputCB argument: 0 +-------------------- +class: FL_INPUT +type: NORMAL_INPUT +box: 170 285 170 30 +boxtype: FL_DOWN_BOX +colors: FL_COL1 FL_MCOL +alignment: FL_ALIGN_LEFT +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: PATH prefix:|#T +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: input_path_prefix +callback: C_FormDialogView_InputCB +argument: 0 + =============== FORM =============== Name: form_preferences_inputs_misc Width: 450 diff --git a/src/lyx_main.C b/src/lyx_main.C index cca4ee899f..6dbcca3a22 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -69,6 +69,7 @@ using lyx::support::i18nLibFileSearch; using lyx::support::LibFileSearch; using lyx::support::package; using lyx::support::Path; +using lyx::support::prependEnvPath; using lyx::support::QuoteName; using lyx::support::rtrim; @@ -111,6 +112,20 @@ void showFileError(string const & error) exit(EXIT_FAILURE); } + +void reconfigureUserLyXDir() +{ + string const configure_script = + AddName(package().system_support(), "configure"); + string const configure_command = + "sh " + QuoteName(configure_script); + + lyxerr << _("LyX: reconfiguring user directory") << endl; + Path p(package().user_support()); + ::system(configure_command.c_str()); + lyxerr << "LyX: " << _("Done!") << endl; +} + } // namespace anon @@ -346,26 +361,16 @@ void LyX::init(bool gui) #if !defined (USE_POSIX_PACKAGING) // Add the directory containing the LyX executable to the path // so that LyX can find things like reLyX. - if (package.build_support().empty()) { - vector path = getEnvPath("PATH"); - path.insert(path.begin(), package.binary_dir()); - setEnvPath("PATH", path); - } -#endif -#if defined (USE_MACOSX_PACKAGING) - // This hard-coded nastiness should be moved into a LyXRC variable. - vector path = getEnvPath("PATH"); - path.insert(path.begin(), "/usr/local/teTeX/bin/powerpc-apple-darwin-current"); - path.insert(path.begin(), "/usr/local/bin"); - path.insert(path.begin(), "/sw/bin"); - lyxerr[Debug::INIT] << "Running from LyX/Mac bundle. " - "Setting PATH to: " << GetEnv("PATH") << endl; + if (package.build_support().empty()) + prependEnvPath("PATH", package.binary_dir()); #endif // Check that user LyX directory is ok. We don't do that if // running in batch mode. + bool reconfigure = false; if (gui) { - queryUserLyXDir(package().explicit_user_support()); + reconfigure = + queryUserLyXDir(package().explicit_user_support()); } else { first_start = false; } @@ -430,7 +435,17 @@ void LyX::init(bool gui) if (lyxerr.debugging(Debug::LYXRC)) lyxrc.print(); - package().document_dir() = lyxrc.document_path; + os::cygwin_path_fix(lyxrc.cygwin_path_fix); + prependEnvPath("PATH", lyxrc.path_prefix); + + // Having reset the PATH we're now in a position to run configure + // if necessary. + if (reconfigure) + reconfigureUserLyXDir(); + + FileInfo fi(lyxrc.document_path); + if (fi.isOK() && fi.isDir()) + package().document_dir() = lyxrc.document_path; package().temp_dir() = createLyXTmpDir(lyxrc.tempdir_path); if (package().temp_dir().empty()) { @@ -552,26 +567,23 @@ void LyX::deadKeyBindings(kb_keymap * kbmap) } -void LyX::queryUserLyXDir(bool explicit_userdir) +bool LyX::queryUserLyXDir(bool explicit_userdir) { - string const configure_script = AddName(package().system_support(), "configure"); - string const configure_command = "sh " + QuoteName(configure_script); + bool reconfigure = false; // Does user directory exist? FileInfo fileInfo(package().user_support()); if (fileInfo.isOK() && fileInfo.isDir()) { first_start = false; + string const configure_script = + AddName(package().system_support(), "configure"); FileInfo script(configure_script); FileInfo defaults(AddName(package().user_support(), "lyxrc.defaults")); if (defaults.isOK() && script.isOK() && defaults.getModificationTime() < script.getModificationTime()) { - lyxerr << _("LyX: reconfiguring user directory") - << endl; - Path p(package().user_support()); - ::system(configure_command.c_str()); - lyxerr << "LyX: " << _("Done!") << endl; + reconfigure = true; } - return; + return reconfigure; } first_start = !explicit_userdir; @@ -592,8 +604,10 @@ void LyX::queryUserLyXDir(bool explicit_userdir) exit(1); } - lyxerr << bformat(_("LyX: Creating directory %1$s" - " and running configure..."), package().user_support()) << endl; + lyxerr << bformat(_("LyX: Creating directory %1$s"), + package().user_support()) + << endl; + reconfigure = true; if (!createDirectory(package().user_support(), 0755)) { // Failed, so let's exit. @@ -602,10 +616,7 @@ void LyX::queryUserLyXDir(bool explicit_userdir) exit(1); } - // Run configure in user lyx directory - Path p(package().user_support()); - ::system(configure_command.c_str()); - lyxerr << "LyX: " << _("Done!") << endl; + return reconfigure; } diff --git a/src/lyx_main.h b/src/lyx_main.h index 908c60119f..a196e8909a 100644 --- a/src/lyx_main.h +++ b/src/lyx_main.h @@ -61,8 +61,13 @@ private: void defaultKeyBindings(kb_keymap * kbmap); /// set up the default dead key bindings if requested void deadKeyBindings(kb_keymap * kbmap); - /// check, set up and configure the user dir if necessary - void queryUserLyXDir(bool explicit_userdir); + /** Check for the existence of the user's support directory and, + * if not present, create it. Exits the program if the directory + * cannot be created. + * \returns true if the user-side configuration script + * (lib/configure) should be re-run in this directory. + */ + bool queryUserLyXDir(bool explicit_userdir); /// read lyxrc/preferences void readRcFile(std::string const & name); /// read the given ui (menu/toolbar) file diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 9753450d6f..3420f6443d 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -650,6 +650,9 @@ void loadTextclass(string const & name) } } + +void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new); + } //namespace anon @@ -1486,6 +1489,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; case LFUN_LYXRC_APPLY: { + LyXRC const lyxrc_orig = lyxrc; + istringstream ss(argument); bool const success = lyxrc.read(ss) == 0; @@ -1493,7 +1498,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd) lyxerr << "Warning in LFUN_LYXRC_APPLY!\n" << "Unable to read lyxrc data" << endl; + break; } + + actOnUpdatedPrefs(lyxrc_orig, lyxrc); break; } @@ -1854,3 +1862,139 @@ bool LyXFunc::wasMetaKey() const { return (meta_fake_bit != key_modifier::none); } + + +namespace { + +void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) +{ + // Why the switch you might ask. It is a trick to ensure that all + // the elements in the LyXRCTags enum is handled. As you can see + // there are no breaks at all. So it is just a huge fall-through. + // The nice thing is that we will get a warning from the compiler + // if we forget an element. + LyXRC::LyXRCTags tag = LyXRC::RC_LAST; + switch (tag) { + case LyXRC::RC_ACCEPT_COMPOUND: + case LyXRC::RC_ALT_LANG: + case LyXRC::RC_ASCIIROFF_COMMAND: + case LyXRC::RC_ASCII_LINELEN: + case LyXRC::RC_AUTOREGIONDELETE: + case LyXRC::RC_AUTORESET_OPTIONS: + case LyXRC::RC_AUTOSAVE: + case LyXRC::RC_AUTO_NUMBER: + case LyXRC::RC_BACKUPDIR_PATH: + case LyXRC::RC_BIBTEX_COMMAND: + case LyXRC::RC_BINDFILE: + case LyXRC::RC_CHECKLASTFILES: + case LyXRC::RC_CHKTEX_COMMAND: + case LyXRC::RC_CONVERTER: + case LyXRC::RC_COPIER: + case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR: + case LyXRC::RC_CUSTOM_EXPORT_COMMAND: + case LyXRC::RC_CUSTOM_EXPORT_FORMAT: + case LyXRC::RC_CYGWIN_PATH_FIX: + if (lyxrc_orig.cygwin_path_fix != lyxrc_new.cygwin_path_fix) { + namespace os = lyx::support::os; + os::cygwin_path_fix(lyxrc_new.cygwin_path_fix); + } + case LyXRC::RC_DATE_INSERT_FORMAT: + case LyXRC::RC_DEFAULT_LANGUAGE: + case LyXRC::RC_DEFAULT_PAPERSIZE: + case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN: + case LyXRC::RC_DISPLAY_GRAPHICS: + case LyXRC::RC_DOCUMENTPATH: + if (lyxrc_orig.document_path != lyxrc_new.document_path) { + FileInfo fi(lyxrc_new.document_path); + if (fi.isOK() && fi.isDir()) { + using lyx::support::package; + package().document_dir() = lyxrc.document_path; + } + } + case LyXRC::RC_ESC_CHARS: + case LyXRC::RC_FONT_ENCODING: + case LyXRC::RC_FORMAT: + case LyXRC::RC_INDEX_COMMAND: + case LyXRC::RC_INPUT: + case LyXRC::RC_KBMAP: + case LyXRC::RC_KBMAP_PRIMARY: + case LyXRC::RC_KBMAP_SECONDARY: + case LyXRC::RC_LABEL_INIT_LENGTH: + case LyXRC::RC_LANGUAGE_AUTO_BEGIN: + case LyXRC::RC_LANGUAGE_AUTO_END: + case LyXRC::RC_LANGUAGE_COMMAND_BEGIN: + case LyXRC::RC_LANGUAGE_COMMAND_END: + case LyXRC::RC_LANGUAGE_COMMAND_LOCAL: + case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS: + case LyXRC::RC_LANGUAGE_PACKAGE: + case LyXRC::RC_LANGUAGE_USE_BABEL: + case LyXRC::RC_LASTFILES: + case LyXRC::RC_MAKE_BACKUP: + case LyXRC::RC_MARK_FOREIGN_LANGUAGE: + case LyXRC::RC_NUMLASTFILES: + case LyXRC::RC_PATH_PREFIX: + if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) { + using lyx::support::prependEnvPath; + prependEnvPath("PATH", lyxrc.path_prefix); + } + case LyXRC::RC_PERS_DICT: + case LyXRC::RC_POPUP_BOLD_FONT: + case LyXRC::RC_POPUP_FONT_ENCODING: + case LyXRC::RC_POPUP_NORMAL_FONT: + case LyXRC::RC_PREVIEW: + case LyXRC::RC_PREVIEW_HASHED_LABELS: + case LyXRC::RC_PREVIEW_SCALE_FACTOR: + case LyXRC::RC_PRINTCOLLCOPIESFLAG: + case LyXRC::RC_PRINTCOPIESFLAG: + case LyXRC::RC_PRINTER: + case LyXRC::RC_PRINTEVENPAGEFLAG: + case LyXRC::RC_PRINTEXSTRAOPTIONS: + case LyXRC::RC_PRINTFILEEXTENSION: + case LyXRC::RC_PRINTLANDSCAPEFLAG: + case LyXRC::RC_PRINTODDPAGEFLAG: + case LyXRC::RC_PRINTPAGERANGEFLAG: + case LyXRC::RC_PRINTPAPERDIMENSIONFLAG: + case LyXRC::RC_PRINTPAPERFLAG: + case LyXRC::RC_PRINTREVERSEFLAG: + case LyXRC::RC_PRINTSPOOL_COMMAND: + case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX: + case LyXRC::RC_PRINTTOFILE: + case LyXRC::RC_PRINTTOPRINTER: + case LyXRC::RC_PRINT_ADAPTOUTPUT: + case LyXRC::RC_PRINT_COMMAND: + case LyXRC::RC_RTL_SUPPORT: + case LyXRC::RC_SCREEN_DPI: + case LyXRC::RC_SCREEN_FONT_ENCODING: + case LyXRC::RC_SCREEN_FONT_ROMAN: + case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY: + case LyXRC::RC_SCREEN_FONT_SANS: + case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY: + case LyXRC::RC_SCREEN_FONT_SCALABLE: + case LyXRC::RC_SCREEN_FONT_SIZES: + case LyXRC::RC_SCREEN_FONT_TYPEWRITER: + case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY: + case LyXRC::RC_SCREEN_ZOOM: + case LyXRC::RC_SERVERPIPE: + case LyXRC::RC_SET_COLOR: + case LyXRC::RC_SHOW_BANNER: + case LyXRC::RC_SPELL_COMMAND: + case LyXRC::RC_TEMPDIRPATH: + case LyXRC::RC_TEMPLATEPATH: + case LyXRC::RC_UIFILE: + case LyXRC::RC_USER_EMAIL: + case LyXRC::RC_USER_NAME: + case LyXRC::RC_USETEMPDIR: + case LyXRC::RC_USE_ALT_LANG: + case LyXRC::RC_USE_ESC_CHARS: + case LyXRC::RC_USE_INP_ENC: + case LyXRC::RC_USE_PERS_DICT: + case LyXRC::RC_USE_SPELL_LIB: + case LyXRC::RC_VIEWDVI_PAPEROPTION: + case LyXRC::RC_VIEWER: + case LyXRC::RC_WHEEL_JUMP: + case LyXRC::RC_LAST: + break; + } +} + +} // namespace anon diff --git a/src/lyxrc.C b/src/lyxrc.C index 9ffa6c8efa..a0b794349c 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -36,7 +36,6 @@ #include "support/convert.h" #include "support/filetools.h" #include "support/lstrings.h" -#include "support/os.h" #include "support/userinfo.h" using lyx::support::ascii_lowercase; @@ -46,8 +45,6 @@ using lyx::support::GetEnv; using lyx::support::LibFileSearch; using lyx::support::token; -namespace os = lyx::support::os; - using std::cout; using std::endl; @@ -107,6 +104,7 @@ keyword_item lyxrcTags[] = { { "\\make_backup", LyXRC::RC_MAKE_BACKUP }, { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE }, { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES }, + { "\\path_prefix", LyXRC::RC_PATH_PREFIX }, { "\\personal_dictionary", LyXRC::RC_PERS_DICT }, { "\\popup_bold_font", LyXRC::RC_POPUP_BOLD_FONT }, { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING }, @@ -394,10 +392,9 @@ int LyXRC::read(LyXLex & lexrc) case RC_CYGWIN_PATH_FIX: if (lexrc.next()) { cygwin_path_fix = lexrc.getBool(); - os::cygwin_path_fix(cygwin_path_fix); } break; - + case RC_KBMAP_PRIMARY: if (lexrc.next()) { string const kmap(lexrc.getString()); @@ -1131,6 +1128,11 @@ int LyXRC::read(LyXLex & lexrc) user_email = lexrc.getString(); break; + case RC_PATH_PREFIX: + if (lexrc.next()) + path_prefix = lexrc.getString(); + break; + case RC_LAST: break; // this is just a dummy } } @@ -1215,6 +1217,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const << "#\n\n"; // bind files are not done here. + + case RC_PATH_PREFIX: + if (ignore_system_lyxrc || + path_prefix != system_lyxrc.path_prefix) { + os << "\\path_prefix \"" << path_prefix << "\"\n"; + } + case RC_UIFILE: if (ignore_system_lyxrc || ui_file != system_lyxrc.ui_file) { @@ -2021,336 +2030,374 @@ string const LyXRC::getDescription(LyXRCTags tag) string str; switch (tag) { - case RC_FONT_ENCODING: - str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages."); + case RC_ACCEPT_COMPOUND: + str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?"); break; - case RC_PRINTER: - str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER."); + case RC_ALT_LANG: + case RC_USE_ALT_LANG: + str = _("Specify an alternate language. The default is to use the language of the document."); break; - case RC_PRINT_COMMAND: - str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\"."); + case RC_ASCIIROFF_COMMAND: + str = _("Use to define an external program to render tables in the ASCII output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"none\" is specified, an internal routine is used."); break; - case RC_PRINTEVENPAGEFLAG: - str = _("The option to print only even pages."); + case RC_ASCII_LINELEN: + str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text)."); break; - case RC_PRINTODDPAGEFLAG: - str = _("The option to print only odd pages."); + case RC_AUTOREGIONDELETE: + str = _("De-select if you don't want the current selection to be replaced automatically by what you type."); break; - case RC_PRINTPAGERANGEFLAG: - str = _("The option for specifying a comma-separated list of pages to print."); + case RC_AUTORESET_OPTIONS: + str = _("De-select if you don't want the class options to be reset to defaults after class change."); break; - case RC_PRINTCOPIESFLAG: - str = _("The option for specifying the number of copies to print."); + case RC_AUTOSAVE: + str = _("The time interval between auto-saves (in seconds). 0 means no auto-save."); break; - case RC_PRINTCOLLCOPIESFLAG: - str = _("The option for specifying whether the copies should be collated."); + case RC_AUTO_NUMBER: break; - case RC_PRINTREVERSEFLAG: - str = _("The option to reverse the order of the pages printed."); + case RC_BACKUPDIR_PATH: + str = _("The path for storing backup files. If it is an empty string, LyX will store the backup file in the same directory as the original file."); break; - case RC_PRINTLANDSCAPEFLAG: - str = _("The option to print out in landscape."); + case RC_BIBTEX_COMMAND: + str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus)."); break; - case RC_PRINTPAPERFLAG: - str = _("The option to specify paper type."); + case RC_BINDFILE: + str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories."); break; - case RC_PRINTPAPERDIMENSIONFLAG: - str = _("Option to specify the dimensions of the print paper."); + case RC_CHECKLASTFILES: + str = _("Select to check whether the lastfiles still exist."); break; - case RC_PRINTTOPRINTER: - str = _("Option to pass to the print program to print on a specific printer."); + case RC_CHKTEX_COMMAND: + str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation."); break; - case RC_PRINT_ADAPTOUTPUT: - str = _("Select for LyX to pass the name of the destination printer to your print command."); + case RC_CONVERTER: break; - case RC_PRINTTOFILE: - str = _("Option to pass to the print program to print to a file."); + case RC_COPIER: break; - case RC_PRINTFILEEXTENSION: - str = _("Extension of printer program output file. Usually \".ps\"."); + case RC_CURSOR_FOLLOWS_SCROLLBAR: + str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen."); break; - case RC_PRINTEXSTRAOPTIONS: - str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed."); + case RC_CUSTOM_EXPORT_COMMAND: break; - case RC_PRINTSPOOL_COMMAND: - str = _("When set, this printer option automatically prints to a file and then calls a separate print spooling program on that file with the given name and arguments."); + case RC_CUSTOM_EXPORT_FORMAT: break; - case RC_PRINTSPOOL_PRINTERPREFIX: - str = _("If you specify a printer name in the print dialog, the following argument is prepended along with the printer name after the spool command."); + case RC_CYGWIN_PATH_FIX: break; - case RC_SCREEN_DPI: - str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here."); + case RC_DATE_INSERT_FORMAT: + //xgettext:no-c-format + str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\"."); break; - case RC_SCREEN_ZOOM: - //xgettext:no-c-format - str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper."); + case RC_DEFAULT_LANGUAGE: + str = _("New documents will be assigned this language."); break; - case RC_SCREEN_FONT_SIZES: - str = _("The font sizes used for calculating the scaling of the screen fonts."); + case RC_DEFAULT_PAPERSIZE: + str = _("Specify the default paper size."); break; - case RC_SCREEN_FONT_ROMAN: - case RC_SCREEN_FONT_SANS: - case RC_SCREEN_FONT_TYPEWRITER: - str = _("The screen fonts used to display the text while editing."); + case RC_DIALOGS_ICONIFY_WITH_MAIN: + str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)"); break; - case RC_POPUP_BOLD_FONT: - str = _("The bold font in the dialogs."); + case RC_DISPLAY_GRAPHICS: + str = _("Select how LyX will display any graphics."); break; - case RC_POPUP_NORMAL_FONT: - str = _("The normal font in the dialogs."); + case RC_DOCUMENTPATH: + str = _("The default path for your documents. An empty value selects the directory LyX was started from."); break; - case RC_SCREEN_FONT_ENCODING: - str = _("The encoding for the screen fonts."); + case RC_ESC_CHARS: + case RC_USE_ESC_CHARS: + str = _("Specify additional chars that can be part of a word."); break; - case RC_POPUP_FONT_ENCODING: - str = _("The encoding for the menu/popups fonts."); + case RC_FONT_ENCODING: + str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages."); break; - case RC_SET_COLOR: + case RC_FORMAT: break; - case RC_AUTOSAVE: - str = _("The time interval between auto-saves (in seconds). 0 means no auto-save."); + case RC_INDEX_COMMAND: + str = _("Define the options of makeindex (cf. man makeindex) or select an alternative compiler. E.g., using xindy/make-rules, the command string would be \"makeindex.sh -m $$lang\"."); break; - case RC_DOCUMENTPATH: - str = _("The default path for your documents. An empty value selects the directory LyX was started from."); + case RC_INPUT: break; - case RC_TEMPLATEPATH: - str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from."); + case RC_KBMAP: + case RC_KBMAP_PRIMARY: + case RC_KBMAP_SECONDARY: + str = _("Use this to set the correct mapping file for your keyboard. You'll need this if you for instance want to type German documents on an American keyboard."); break; - case RC_TEMPDIRPATH: - str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX."); + case RC_LABEL_INIT_LENGTH: + str = _("Maximum number of words in the initialization string for a new label"); break; - case RC_LASTFILES: - str = _("The file where the last-files information should be stored."); + case RC_LANGUAGE_AUTO_BEGIN: + str = _("Select if a language switching command is needed at the beginning of the document."); break; - case RC_AUTOREGIONDELETE: - str = _("De-select if you don't want the current selection to be replaced automatically by what you type."); + case RC_LANGUAGE_AUTO_END: + str = _("Select if a language switching command is needed at the end of the document."); break; - case RC_AUTORESET_OPTIONS: - str = _("De-select if you don't want the class options to be reset to defaults after class change."); + case RC_LANGUAGE_COMMAND_BEGIN: + str = _("The LaTeX command for changing from the language of the document to another language. E.g. \\selectlanguage{$$lang} where $$lang is substituted by the name of the second language."); break; - case RC_SERVERPIPE: - str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users."); + case RC_LANGUAGE_COMMAND_END: + str = _("The LaTeX command for changing back to the language of the document."); break; - case RC_BINDFILE: - str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories."); + case RC_LANGUAGE_COMMAND_LOCAL: + str = _("The LaTeX command for local changing of the language."); break; - case RC_UIFILE: - str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories."); + case RC_LANGUAGE_GLOBAL_OPTIONS: + str = _("De-select if you don't want the language(s) used as an argument to \\documentclass."); break; - case RC_KBMAP: - case RC_KBMAP_PRIMARY: - case RC_KBMAP_SECONDARY: - str = _("Use this to set the correct mapping file for your keyboard. You'll need this if you for instance want to type German documents on an American keyboard."); + case RC_LANGUAGE_PACKAGE: + str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\"."); break; - case RC_ASCIIROFF_COMMAND: - str = _("Use to define an external program to render tables in the ASCII output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"none\" is specified, an internal routine is used."); + case RC_LANGUAGE_USE_BABEL: + str = _("De-select if you don't want babel to be used when the language of the document is the default language."); break; - case RC_ASCII_LINELEN: - str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text)."); + case RC_LASTFILES: + str = _("The file where the last-files information should be stored."); + break; + + case RC_MAKE_BACKUP: + str = _("De-select if you don't want LyX to create backup files."); + break; + + case RC_MARK_FOREIGN_LANGUAGE: + str = _("Select to control the highlighting of words with a language foreign to that of the document."); break; case RC_NUMLASTFILES: str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles); break; - case RC_CHECKLASTFILES: - str = _("Select to check whether the lastfiles still exist."); + case RC_PATH_PREFIX: break; - case RC_VIEWDVI_PAPEROPTION: - str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")"); + case RC_PERS_DICT: + case RC_USE_PERS_DICT: + str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\"."); break; - case RC_DEFAULT_PAPERSIZE: - str = _("Specify the default paper size."); + case RC_POPUP_BOLD_FONT: + str = _("The bold font in the dialogs."); break; - case RC_ACCEPT_COMPOUND: - str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?"); + case RC_POPUP_FONT_ENCODING: + str = _("The encoding for the menu/popups fonts."); break; - case RC_SPELL_COMMAND: - str = _("What command runs the spell checker?"); + case RC_POPUP_NORMAL_FONT: + str = _("The normal font in the dialogs."); break; - case RC_USE_INP_ENC: - str = _("Specify whether to pass the -T input encoding option to ispell. Enable this if you can't spellcheck words with international letters in them. This may not work with all dictionaries."); + case RC_PREVIEW: + str = _("Shows a typeset preview of things such as math"); break; - case RC_USE_ALT_LANG: - case RC_ALT_LANG: - str = _("Specify an alternate language. The default is to use the language of the document."); + case RC_PREVIEW_HASHED_LABELS: + str = _("Previewed equations will have \"(#)\" labels rather than numbered ones"); break; - case RC_USE_PERS_DICT: - case RC_PERS_DICT: - str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\"."); + case RC_PREVIEW_SCALE_FACTOR: + str = _("Scale the preview size to suit."); break; - case RC_USE_ESC_CHARS: - case RC_ESC_CHARS: - str = _("Specify additional chars that can be part of a word."); + case RC_PRINTCOLLCOPIESFLAG: + str = _("The option for specifying whether the copies should be collated."); break; - case RC_SCREEN_FONT_SCALABLE: - str = _("Allow bitmap fonts to be resized. If you are using a bitmap font, selecting this option may make some fonts look blocky in LyX. Deselecting this option makes LyX use the nearest bitmap font size available, instead of scaling."); + case RC_PRINTCOPIESFLAG: + str = _("The option for specifying the number of copies to print."); break; - case RC_CHKTEX_COMMAND: - str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation."); + case RC_PRINTER: + str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER."); break; - case RC_BIBTEX_COMMAND: - str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus)."); + case RC_PRINTEVENPAGEFLAG: + str = _("The option to print only even pages."); break; - case RC_INDEX_COMMAND: - str = _("Define the options of makeindex (cf. man makeindex) or select an alternative compiler. E.g., using xindy/make-rules, the command string would be \"makeindex.sh -m $$lang\"."); + case RC_PRINTEXSTRAOPTIONS: + str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed."); break; - case RC_CURSOR_FOLLOWS_SCROLLBAR: - str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen."); + case RC_PRINTFILEEXTENSION: + str = _("Extension of printer program output file. Usually \".ps\"."); break; - case RC_DIALOGS_ICONIFY_WITH_MAIN: - str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)"); + case RC_PRINTLANDSCAPEFLAG: + str = _("The option to print out in landscape."); break; - case RC_DISPLAY_GRAPHICS: - str = _("Select how LyX will display any graphics."); + case RC_PRINTODDPAGEFLAG: + str = _("The option to print only odd pages."); break; - case RC_MAKE_BACKUP: - str = _("De-select if you don't want LyX to create backup files."); + case RC_PRINTPAGERANGEFLAG: + str = _("The option for specifying a comma-separated list of pages to print."); break; - case RC_BACKUPDIR_PATH: - str = _("The path for storing backup files. If it is an empty string, LyX will store the backup file in the same directory as the original file."); + case RC_PRINTPAPERDIMENSIONFLAG: + str = _("Option to specify the dimensions of the print paper."); break; - case RC_RTL_SUPPORT: - str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic)."); + case RC_PRINTPAPERFLAG: + str = _("The option to specify paper type."); break; - case RC_MARK_FOREIGN_LANGUAGE: - str = _("Select to control the highlighting of words with a language foreign to that of the document."); + case RC_PRINTREVERSEFLAG: + str = _("The option to reverse the order of the pages printed."); break; - case RC_LANGUAGE_PACKAGE: - str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\"."); + case RC_PRINTSPOOL_COMMAND: + str = _("When set, this printer option automatically prints to a file and then calls a separate print spooling program on that file with the given name and arguments."); break; - case RC_LANGUAGE_GLOBAL_OPTIONS: - str = _("De-select if you don't want the language(s) used as an argument to \\documentclass."); + case RC_PRINTSPOOL_PRINTERPREFIX: + str = _("If you specify a printer name in the print dialog, the following argument is prepended along with the printer name after the spool command."); break; - case RC_LANGUAGE_USE_BABEL: - str = _("De-select if you don't want babel to be used when the language of the document is the default language."); + case RC_PRINTTOFILE: + str = _("Option to pass to the print program to print to a file."); break; - case RC_LANGUAGE_AUTO_BEGIN: - str = _("Select if a language switching command is needed at the beginning of the document."); + case RC_PRINTTOPRINTER: + str = _("Option to pass to the print program to print on a specific printer."); break; - case RC_LANGUAGE_AUTO_END: - str = _("Select if a language switching command is needed at the end of the document."); + case RC_PRINT_ADAPTOUTPUT: + str = _("Select for LyX to pass the name of the destination printer to your print command."); break; - case RC_LANGUAGE_COMMAND_BEGIN: - str = _("The LaTeX command for changing from the language of the document to another language. E.g. \\selectlanguage{$$lang} where $$lang is substituted by the name of the second language."); + case RC_PRINT_COMMAND: + str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\"."); break; - case RC_LANGUAGE_COMMAND_END: - str = _("The LaTeX command for changing back to the language of the document."); + case RC_RTL_SUPPORT: + str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic)."); break; - case RC_LANGUAGE_COMMAND_LOCAL: - str = _("The LaTeX command for local changing of the language."); + case RC_SCREEN_DPI: + str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here."); break; - case RC_DATE_INSERT_FORMAT: + case RC_SCREEN_FONT_ENCODING: + str = _("The encoding for the screen fonts."); + break; + + case RC_SCREEN_FONT_ROMAN: + case RC_SCREEN_FONT_SANS: + case RC_SCREEN_FONT_TYPEWRITER: + str = _("The screen fonts used to display the text while editing."); + break; + + case RC_SCREEN_FONT_ROMAN_FOUNDRY: + case RC_SCREEN_FONT_SANS_FOUNDRY: + case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY: + break; + + case RC_SCREEN_FONT_SCALABLE: + str = _("Allow bitmap fonts to be resized. If you are using a bitmap font, selecting this option may make some fonts look blocky in LyX. Deselecting this option makes LyX use the nearest bitmap font size available, instead of scaling."); + break; + + case RC_SCREEN_FONT_SIZES: + str = _("The font sizes used for calculating the scaling of the screen fonts."); + break; + + case RC_SCREEN_ZOOM: //xgettext:no-c-format - str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\"."); + str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper."); + break; + + case RC_SERVERPIPE: + str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users."); + break; + + case RC_SET_COLOR: break; case RC_SHOW_BANNER: str = _("De-select if you don't want the startup banner."); break; - case RC_WHEEL_JUMP: - str = _("The number of lines that are scrolled by mice with wheels or five button mice."); + case RC_SPELL_COMMAND: + str = _("What command runs the spell checker?"); break; - case RC_CONVERTER: + case RC_TEMPDIRPATH: + str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX."); break; - case RC_VIEWER: + case RC_TEMPLATEPATH: + str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from."); break; - case RC_FORMAT: + case RC_UIFILE: + str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories."); break; - case RC_DEFAULT_LANGUAGE: - str = _("New documents will be assigned this language."); + case RC_USER_EMAIL: break; - case RC_LABEL_INIT_LENGTH: - str = _("Maximum number of words in the initialization string for a new label"); + case RC_USER_NAME: break; - case RC_PREVIEW: - str = _("Shows a typeset preview of things such as math"); + case RC_USETEMPDIR: break; - case RC_PREVIEW_HASHED_LABELS: - str = _("Previewed equations will have \"(#)\" labels rather than numbered ones"); + case RC_USE_INP_ENC: + str = _("Specify whether to pass the -T input encoding option to ispell. Enable this if you can't spellcheck words with international letters in them. This may not work with all dictionaries."); break; - case RC_PREVIEW_SCALE_FACTOR: - str = _("Scale the preview size to suit."); + case RC_USE_SPELL_LIB: break; - default: + case RC_VIEWDVI_PAPEROPTION: + str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")"); + break; + + case RC_VIEWER: + break; + + case RC_WHEEL_JUMP: + str = _("The number of lines that are scrolled by mice with wheels or five button mice."); + break; + + case RC_LAST: break; } diff --git a/src/lyxrc.h b/src/lyxrc.h index 8eee3fe871..00271517f4 100644 --- a/src/lyxrc.h +++ b/src/lyxrc.h @@ -32,111 +32,111 @@ class LyXRC //: public noncopyable { // noncopyable again. For now I want to minimise changes. ARRae 20001010 { public: -enum LyXRCTags { - RC_FONT_ENCODING = 1, - RC_PRINTER, - RC_PRINT_COMMAND, - RC_PRINTEVENPAGEFLAG, - RC_PRINTODDPAGEFLAG, - RC_PRINTPAGERANGEFLAG, - RC_PRINTCOPIESFLAG, - RC_PRINTCOLLCOPIESFLAG, - RC_PRINTREVERSEFLAG, - RC_PRINTLANDSCAPEFLAG, - RC_PRINTTOPRINTER, - RC_PRINT_ADAPTOUTPUT, - RC_PRINTTOFILE, - RC_PRINTFILEEXTENSION, - RC_PRINTEXSTRAOPTIONS, - RC_PRINTSPOOL_COMMAND, - RC_PRINTSPOOL_PRINTERPREFIX, - RC_PRINTPAPERFLAG, - RC_PRINTPAPERDIMENSIONFLAG, - RC_CUSTOM_EXPORT_COMMAND, - RC_CUSTOM_EXPORT_FORMAT, - RC_SCREEN_DPI, - RC_SCREEN_ZOOM, - RC_SCREEN_FONT_SIZES, - RC_SCREEN_FONT_ROMAN, - RC_SCREEN_FONT_SANS, - RC_SCREEN_FONT_TYPEWRITER, - RC_SCREEN_FONT_ROMAN_FOUNDRY, - RC_SCREEN_FONT_SANS_FOUNDRY, - RC_SCREEN_FONT_TYPEWRITER_FOUNDRY, - RC_SCREEN_FONT_ENCODING, - RC_POPUP_BOLD_FONT, - RC_POPUP_NORMAL_FONT, - RC_POPUP_FONT_ENCODING, - RC_SET_COLOR, - RC_AUTOSAVE, - RC_DOCUMENTPATH, - RC_TEMPLATEPATH, - RC_TEMPDIRPATH, - RC_USETEMPDIR, - RC_LASTFILES, - RC_AUTOREGIONDELETE, - RC_AUTORESET_OPTIONS, - RC_SERVERPIPE, - RC_INPUT, - RC_BINDFILE, - RC_UIFILE, - RC_KBMAP, - RC_KBMAP_PRIMARY, - RC_KBMAP_SECONDARY, - RC_ASCIIROFF_COMMAND, - RC_ASCII_LINELEN, - RC_NUMLASTFILES, - RC_CHECKLASTFILES, - RC_VIEWDVI_PAPEROPTION, - RC_DEFAULT_PAPERSIZE, - RC_ACCEPT_COMPOUND, - RC_SPELL_COMMAND, - RC_USE_INP_ENC, - RC_USE_ALT_LANG, - RC_USE_PERS_DICT, - RC_USE_ESC_CHARS, - RC_SCREEN_FONT_SCALABLE, - RC_ALT_LANG, - RC_PERS_DICT, - RC_ESC_CHARS, - RC_CHKTEX_COMMAND, - RC_BIBTEX_COMMAND, - RC_CURSOR_FOLLOWS_SCROLLBAR, - RC_DIALOGS_ICONIFY_WITH_MAIN, - RC_MAKE_BACKUP, - RC_BACKUPDIR_PATH, - RC_RTL_SUPPORT, - RC_AUTO_NUMBER, - RC_MARK_FOREIGN_LANGUAGE, - RC_LANGUAGE_PACKAGE, - RC_LANGUAGE_AUTO_BEGIN, - RC_LANGUAGE_AUTO_END, - RC_LANGUAGE_COMMAND_BEGIN, - RC_LANGUAGE_COMMAND_END, - RC_LANGUAGE_COMMAND_LOCAL, - RC_LANGUAGE_GLOBAL_OPTIONS, - RC_LANGUAGE_USE_BABEL, - RC_DATE_INSERT_FORMAT, - RC_SHOW_BANNER, - RC_WHEEL_JUMP, - RC_CONVERTER, - RC_COPIER, - RC_VIEWER, - RC_FORMAT, - RC_DEFAULT_LANGUAGE, - RC_LABEL_INIT_LENGTH, - RC_DISPLAY_GRAPHICS, - RC_PREVIEW, - RC_PREVIEW_HASHED_LABELS, - RC_PREVIEW_SCALE_FACTOR, - RC_USE_SPELL_LIB, - RC_USER_NAME, - RC_USER_EMAIL, - RC_INDEX_COMMAND, - RC_CYGWIN_PATH_FIX, - RC_LAST -}; - + enum LyXRCTags { + RC_ACCEPT_COMPOUND = 1, + RC_ALT_LANG, + RC_ASCIIROFF_COMMAND, + RC_ASCII_LINELEN, + RC_AUTOREGIONDELETE, + RC_AUTORESET_OPTIONS, + RC_AUTOSAVE, + RC_AUTO_NUMBER, + RC_BACKUPDIR_PATH, + RC_BIBTEX_COMMAND, + RC_BINDFILE, + RC_CHECKLASTFILES, + RC_CHKTEX_COMMAND, + RC_CONVERTER, + RC_COPIER, + RC_CURSOR_FOLLOWS_SCROLLBAR, + RC_CUSTOM_EXPORT_COMMAND, + RC_CUSTOM_EXPORT_FORMAT, + RC_CYGWIN_PATH_FIX, + RC_DATE_INSERT_FORMAT, + RC_DEFAULT_LANGUAGE, + RC_DEFAULT_PAPERSIZE, + RC_DIALOGS_ICONIFY_WITH_MAIN, + RC_DISPLAY_GRAPHICS, + RC_DOCUMENTPATH, + RC_ESC_CHARS, + RC_FONT_ENCODING, + RC_FORMAT, + RC_INDEX_COMMAND, + RC_INPUT, + RC_KBMAP, + RC_KBMAP_PRIMARY, + RC_KBMAP_SECONDARY, + RC_LABEL_INIT_LENGTH, + RC_LANGUAGE_AUTO_BEGIN, + RC_LANGUAGE_AUTO_END, + RC_LANGUAGE_COMMAND_BEGIN, + RC_LANGUAGE_COMMAND_END, + RC_LANGUAGE_COMMAND_LOCAL, + RC_LANGUAGE_GLOBAL_OPTIONS, + RC_LANGUAGE_PACKAGE, + RC_LANGUAGE_USE_BABEL, + RC_LASTFILES, + RC_MAKE_BACKUP, + RC_MARK_FOREIGN_LANGUAGE, + RC_NUMLASTFILES, + RC_PATH_PREFIX, + RC_PERS_DICT, + RC_POPUP_BOLD_FONT, + RC_POPUP_FONT_ENCODING, + RC_POPUP_NORMAL_FONT, + RC_PREVIEW, + RC_PREVIEW_HASHED_LABELS, + RC_PREVIEW_SCALE_FACTOR, + RC_PRINTCOLLCOPIESFLAG, + RC_PRINTCOPIESFLAG, + RC_PRINTER, + RC_PRINTEVENPAGEFLAG, + RC_PRINTEXSTRAOPTIONS, + RC_PRINTFILEEXTENSION, + RC_PRINTLANDSCAPEFLAG, + RC_PRINTODDPAGEFLAG, + RC_PRINTPAGERANGEFLAG, + RC_PRINTPAPERDIMENSIONFLAG, + RC_PRINTPAPERFLAG, + RC_PRINTREVERSEFLAG, + RC_PRINTSPOOL_COMMAND, + RC_PRINTSPOOL_PRINTERPREFIX, + RC_PRINTTOFILE, + RC_PRINTTOPRINTER, + RC_PRINT_ADAPTOUTPUT, + RC_PRINT_COMMAND, + RC_RTL_SUPPORT, + RC_SCREEN_DPI, + RC_SCREEN_FONT_ENCODING, + RC_SCREEN_FONT_ROMAN, + RC_SCREEN_FONT_ROMAN_FOUNDRY, + RC_SCREEN_FONT_SANS, + RC_SCREEN_FONT_SANS_FOUNDRY, + RC_SCREEN_FONT_SCALABLE, + RC_SCREEN_FONT_SIZES, + RC_SCREEN_FONT_TYPEWRITER, + RC_SCREEN_FONT_TYPEWRITER_FOUNDRY, + RC_SCREEN_ZOOM, + RC_SERVERPIPE, + RC_SET_COLOR, + RC_SHOW_BANNER, + RC_SPELL_COMMAND, + RC_TEMPDIRPATH, + RC_TEMPLATEPATH, + RC_UIFILE, + RC_USER_EMAIL, + RC_USER_NAME, + RC_USETEMPDIR, + RC_USE_ALT_LANG, + RC_USE_ESC_CHARS, + RC_USE_INP_ENC, + RC_USE_PERS_DICT, + RC_USE_SPELL_LIB, + RC_VIEWDVI_PAPEROPTION, + RC_VIEWER, + RC_WHEEL_JUMP, + RC_LAST + }; /// LyXRC(); @@ -377,6 +377,10 @@ public: std::string user_email; /// bool cygwin_path_fix; + /** Prepend paths to the PATH environment variable. + * The string is input, stored and output in native format. + */ + std::string path_prefix; }; diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 2a4eec4dc8..e8c6702e5d 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,9 @@ +2005-01-16 Angus Leeming + + * filetools.[Ch] (prependEnvPath): prepend a list of paths to + that returned by the environment variable. Identical paths occurring + later in the list are removed. + 2005-01-16 Angus Leeming * filetools.C (createLyXTmpDir): add some missing brackets to the diff --git a/src/support/filetools.C b/src/support/filetools.C index fdae775024..eea9dc46e0 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -428,6 +428,34 @@ void setEnvPath(string const & name, vector const & env) } +void prependEnvPath(string const & name, string const & prefix) +{ + vector env_var = getEnvPath(name); + + typedef boost::char_separator Separator; + typedef boost::tokenizer Tokenizer; + + Separator const separator(string(1, os::path_separator()).c_str()); + + // Prepend each new element to the list, removing identical elements + // that occur later in the list. + Tokenizer const tokens(prefix, separator); + vector reversed_tokens(tokens.begin(), tokens.end()); + + typedef vector::const_reverse_iterator token_iterator; + token_iterator it = reversed_tokens.rbegin(); + token_iterator const end = reversed_tokens.rend(); + for (; it != end; ++it) { + vector::iterator remove_it = + std::remove(env_var.begin(), env_var.end(), *it); + env_var.erase(remove_it, env_var.end()); + env_var.insert(env_var.begin(), *it); + } + + setEnvPath(name, env_var); +} + + bool putEnv(string const & envstr) { // CHECK Look at and fix this. diff --git a/src/support/filetools.h b/src/support/filetools.h index eeb45188a2..69b5fb6408 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -129,6 +129,15 @@ std::vector const getEnvPath(std::string const & name); */ void setEnvPath(std::string const & name, std::vector const & env); +/** Prepend a list of paths to that returned by the environment variable. + * Identical paths occurring later in the list are removed. + * @param name the name of the environment variable. + * @prefix the list of paths in OS-native syntax. + * Eg "/foo/bar:/usr/bin:/usr/local/bin" on *nix, + * "C:\foo\bar;C:\windows" on Windows. + */ +void prependEnvPath(std::string const & name, std::string const & prefix); + /// Set an environment variable using a string of the form "name=FOO". bool putEnv(std::string const & envstr);