#include <config.h>
#include <version.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "lyx_main.h"
#include "support/filetools.h"
#include "gettext.h"
#include "lyxlex.h"
+#include "graphics/GraphicsTypes.h"
+
#include "bufferlist.h"
#include "buffer.h"
#include "lyxserver.h"
#include "lastfiles.h"
#include "encoding.h"
#include "converter.h"
+#include "format.h"
#include "lyxtextclasslist.h"
#include "frontends/Alert.h"
#include "frontends/lyx_gui.h"
+#include "BoostFormat.h"
#include <boost/function.hpp>
#include <cstdlib>
toplevel_keymap.reset(new kb_keymap);
defaultKeyBindings(toplevel_keymap.get());
+ // set the DisplayTranslator only once; should that be done here??
+ // if this should not be in this file, please also remove
+ // #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
+ grfx::setDisplayTranslator();
+
if (want_gui) {
lyx_gui::parse_init(argc, argv);
}
// other than documents
for (int argi = 1; argi < argc ; ++argi) {
if (argv[argi][0] == '-') {
+#if USE_BOOST_FORMAT
+ lyxerr << boost::format(_("Wrong command line option `%1$s'. Exiting."))
+ % argv[argi]
+ << endl;
+#else
lyxerr << _("Wrong command line option `")
- << argv[argi]
- << _("'. Exiting.") << endl;
+ << argv[argi] << _("'. Exiting.")
+ << endl;
+#endif
exit(1);
}
}
// Execute batch commands if available
if (!batch_command.empty()) {
lyxerr[Debug::INIT] << "About to handle -x '"
- << batch_command << "'" << endl;
+ << batch_command << '\'' << endl;
Buffer * last_loaded = 0;
FileInfo file(fullbinpath, true);
followlink = file.isLink();
if (followlink) {
- lyxerr << " directory " << fullbinpath
- << " is a link" << endl;
+ lyxerr[Debug::INIT] << " directory " << fullbinpath
+ << " is a link" << endl;
string link;
if (LyXReadLink(fullbinpath, link, true)) {
fullbinpath = link;
<< "Giving up." << endl;
exit(1);
}
- lyxerr << _("Using built-in default ")
- << LYX_DIR << _(" but expect problems.")
+#if USE_BOOST_FORMAT
+ lyxerr << boost::format(_("Using built-in default %1$s"
+ " but expect problems."))
+ % static_cast<char *>(LYX_DIR)
+ << endl;
+#else
+ lyxerr << _("Using built-in default ") << LYX_DIR
+ << _(" but expect problems.")
<< endl;
+#endif
} else {
lyxerr << _("Expect problems.") << endl;
}
// If there is a preferences file we read that instead
// of the old lyxrc file.
if (!readRcFile("preferences"))
- readRcFile("lyxrc");
+ readRcFile("lyxrc");
readEncodingsFile("encodings");
readLanguagesFile("languages");
// Read menus
readUIFile(lyxrc.ui_file);
- // Bind the X dead keys to the corresponding LyX functions if
- // necessary.
- if (lyxrc.override_x_deadkeys)
- deadKeyBindings(toplevel_keymap.get());
-
if (lyxerr.debugging(Debug::LYXRC)) {
lyxrc.print();
}
void LyX::queryUserLyXDir(bool explicit_userdir)
{
+ string const configure_script = AddName(system_lyxdir, "configure");
+
// Does user directory exist?
FileInfo fileInfo(user_lyxdir);
if (fileInfo.isOK() && fileInfo.isDir()) {
first_start = false;
+ FileInfo script(configure_script);
+ FileInfo defaults(AddName(user_lyxdir, "lyxrc.defaults"));
+ if (defaults.isOK() && script.isOK()
+ && defaults.getModificationTime() < script.getModificationTime()) {
+ lyxerr << _("LyX: reconfiguring user directory")
+ << endl;
+ Path p(user_lyxdir);
+ ::system(configure_script.c_str());
+ lyxerr << "LyX: " << _("Done!") << endl;
+ }
return;
}
-
+
first_start = !explicit_userdir;
// If the user specified explicitly a directory, ask whether
return;
}
+#if USE_BOOST_FORMAT
+ lyxerr << boost::format(_("LyX: Creating directory %1$s"
+ " and running configure..."))
+ % user_lyxdir
+ << endl;
+#else
lyxerr << _("LyX: Creating directory ") << user_lyxdir
- << _(" and running configure...") << endl;
+ << _(" and running configure...")
+ << endl;
+#endif
if (!createDirectory(user_lyxdir, 0755)) {
// Failed, let's use $HOME instead.
user_lyxdir = GetEnvPath("HOME");
- lyxerr << _("Failed. Will use ") << user_lyxdir
- << _(" instead.") << endl;
+#if USE_BOOST_FORMAT
+ lyxerr << boost::format(_("Failed. Will use %1$s instead."))
+ % user_lyxdir
+ << endl;
+#else
+ lyxerr << _("Failed. Will use ") << user_lyxdir <<
+ _(" instead.")
+ << endl;
+#endif
return;
}
// Run configure in user lyx directory
Path p(user_lyxdir);
- ::system(AddName(system_lyxdir, "configure").c_str());
+ ::system(configure_script.c_str());
lyxerr << "LyX: " << _("Done!") << endl;
}
lyxerr[Debug::INIT] << "Found " << name
<< " in " << lyxrc_path << endl;
if (lyxrc.read(lyxrc_path) < 0) {
+#if USE_BOOST_FORMAT
Alert::alert(_("LyX Warning!"),
- _("Error while reading ") + lyxrc_path + ".",
+ boost::io::str(boost::format(_("Error while reading %1$s.")) % lyxrc_path),
_("Using built-in defaults."));
+#else
+ Alert::alert(_("LyX Warning!"),
+ _("Error while reading ") + lyxrc_path,
+ _("Using built-in defaults."));
+#endif
return false;
}
return true;
ui_last
};
- struct keyword_item uitags[ui_last-1] = {
+ struct keyword_item uitags[ui_last - 1] = {
{ "menuset", ui_menuset },
{ "toolbar", ui_toolbar }
};
string batch;
/// return the the number of arguments consumed
-typedef boost::function<int, string const &, string const &> cmd_helper;
+typedef boost::function<int(string const &, string const &)> cmd_helper;
int parse_dbg(string const & arg, string const &)
{
Debug::showTags(lyxerr);
exit(0);
}
+#if USE_BOOST_FORMAT
+ lyxerr << boost::format(_("Setting debug level to %1$s"))
+ % arg
+ << endl;
+#else
lyxerr << _("Setting debug level to ") << arg << endl;
+#endif
+
lyxerr.level(Debug::value(arg));
Debug::showLevel(lyxerr, lyxerr.level());
return 1;
exit(1);
}
- batch = "buffer-import " + type + " " + file;
+ batch = "buffer-import " + type + ' ' + file;
return 2;
}
string arg((i + 1 < argc) ? argv[i + 1] : "");
string arg2((i + 2 < argc) ? argv[i + 2] : "");
-
+
int const remove = 1 + it->second(arg, arg2);
// Now, remove used arguments by shifting