#include "frontends/lyx_gui.h"
#include "frontends/LyXView.h"
-#include "support/FileInfo.h"
+#include "support/environment.h"
#include "support/filetools.h"
#include "support/lyxlib.h"
#include "support/os.h"
#include "support/path.h"
#include <boost/bind.hpp>
+#include <boost/filesystem/operations.hpp>
#include <iostream>
#include <csignal>
using lyx::support::bformat;
using lyx::support::createDirectory;
using lyx::support::createLyXTmpDir;
-using lyx::support::FileInfo;
using lyx::support::FileSearch;
-using lyx::support::GetEnv;
+using lyx::support::getEnv;
using lyx::support::i18nLibFileSearch;
using lyx::support::LibFileSearch;
using lyx::support::package;
using lyx::support::rtrim;
namespace os = lyx::support::os;
+namespace fs = boost::filesystem;
using std::endl;
using std::string;
#endif
-extern void QuitLyX();
+extern void QuitLyX(bool);
extern LyXServer * lyxserver;
// we need to parse for "-dbg" and "-help"
bool const want_gui = easyParse(argc, argv);
- lyx::support::init_package(argv[0], cl_system_support, cl_user_support);
+ lyx::support::init_package(argv[0], cl_system_support, cl_user_support,
+ lyx::support::top_build_dir_is_one_level_up);
if (want_gui)
lyx_gui::parse_init(argc, argv);
vector<string> files;
for (int argi = argc - 1; argi >= 1; --argi)
- files.push_back(argv[argi]);
+ files.push_back(os::internal_path(argv[argi]));
if (first_start)
files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
if (last_loaded) {
bool success = false;
if (last_loaded->dispatch(batch_command, &success)) {
- QuitLyX();
+ QuitLyX(false);
exit(!success);
}
}
files.clear(); // the files are already loaded
}
- lyx_gui::start(batch_command, files);
+ if (want_gui)
+ lyx_gui::start(batch_command, files);
+ else {
+ // Something went wrong above
+ QuitLyX(false);
+ exit(EXIT_FAILURE);
+ }
}
#ifdef SIGHUP
if (err_sig == SIGSEGV ||
- (err_sig != SIGHUP && !GetEnv("LYXDEBUG").empty()))
+ (err_sig != SIGHUP && !getEnv("LYXDEBUG").empty()))
#else
- if (err_sig == SIGSEGV || !GetEnv("LYXDEBUG").empty())
+ if (err_sig == SIGSEGV || !getEnv("LYXDEBUG").empty())
#endif
lyx::support::abort();
exit(0);
signal(SIGTERM, error_handler);
// SIGPIPE can be safely ignored.
-#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())
- 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;
lyxrc.print();
os::cygwin_path_fix(lyxrc.cygwin_path_fix);
- prependEnvPath("PATH", lyxrc.path_prefix);
+ if (!lyxrc.path_prefix.empty())
+ prependEnvPath("PATH", lyxrc.path_prefix);
+
+#if !defined (USE_POSIX_PACKAGING)
+ // Add the directory containing the LyX executable to the path
+ // so that LyX can find things like tex2lyx.
+ if (package().build_support().empty())
+ prependEnvPath("PATH", package().binary_dir());
+#endif
// 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())
+ if (fs::exists(lyxrc.document_path) &&
+ fs::is_directory(lyxrc.document_path))
package().document_dir() = lyxrc.document_path;
package().temp_dir() = createLyXTmpDir(lyxrc.tempdir_path);
kbmap->bind("Down", FuncRequest(LFUN_DOWN));
kbmap->bind("Tab", FuncRequest(LFUN_CELL_FORWARD));
- kbmap->bind("ISO_Left_Tab", FuncRequest(LFUN_CELL_FORWARD));
+ kbmap->bind("C-Tab", FuncRequest(LFUN_CELL_SPLIT));
+ kbmap->bind("~S-ISO_Left_Tab", FuncRequest(LFUN_CELL_BACKWARD));
+ kbmap->bind("~S-BackTab", FuncRequest(LFUN_CELL_BACKWARD));
kbmap->bind("Home", FuncRequest(LFUN_HOME));
kbmap->bind("End", FuncRequest(LFUN_END));
kbmap->bind("KP_End", FuncRequest(LFUN_END));
kbmap->bind("KP_Prior", FuncRequest(LFUN_PRIOR));
kbmap->bind("KP_Next", FuncRequest(LFUN_NEXT));
-
- kbmap->bind("C-Tab", FuncRequest(LFUN_CELL_SPLIT));
- kbmap->bind("S-Tab", FuncRequest(LFUN_CELL_BACKWARD));
- kbmap->bind("S-ISO_Left_Tab", FuncRequest(LFUN_CELL_BACKWARD));
}
bool reconfigure = false;
// Does user directory exist?
- FileInfo fileInfo(package().user_support());
- if (fileInfo.isOK() && fileInfo.isDir()) {
+ if (fs::exists(package().user_support()) &&
+ fs::is_directory(package().user_support())) {
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()) {
+ string const userDefaults =
+ AddName(package().user_support(), "lyxrc.defaults");
+ if (fs::exists(configure_script) &&
+ fs::exists(userDefaults) &&
+ fs::last_write_time(configure_script)
+ > fs::last_write_time(userDefaults)) {
reconfigure = true;
}
return reconfigure;
// If the user specified explicitly a directory, ask whether
// to create it. If the user says "no", then exit.
if (explicit_userdir &&
- !Alert::prompt(
- _("Missing LyX support directory"),
+ Alert::prompt(
+ _("Missing user LyX directory"),
bformat(_("You have specified a non-existent user "
"LyX directory, %1$s.\n"
"It is needed to keep your own configuration."),
exit(1);
}
batch = arg;
- // Argh. Setting gui to false segfaults..
- // FIXME: when ? how ?
- // is_gui = false;
return 1;
}