///
Movers system_movers_;
- /// has this user started lyx for the first time?
- bool first_start;
/// the parsed command line batch command if any
vector<string> batch_commands;
{
int exit_status = init(argc, argv);
if (exit_status) {
- prepareExit();
- return exit_status;
- }
+ prepareExit();
+ return exit_status;
+ }
// this is correct, since return values are inverted.
exit_status = !loadFiles();
}
// Loop over the list of duplicated variables
- for (std::set<std::string>::iterator dupe = dupes.begin(); dupe != dupes.end(); ++dupe) {
+ std::set<std::string>::iterator dupe = dupes.begin();
+ std::set<std::string>::iterator const dend = dupes.end();
+ for (; dupe != dend; ++dupe) {
const char *name = (*dupe).c_str();
char *val = getenv(name);
if (val != NULL) {
}
#endif
+
+static void initTemplatePath()
+{
+ FileName const package_template_path =
+ FileName(addName(package().system_support().absFileName(), "templates"));
+
+ if (lyxrc.template_path.empty()) {
+ lyxrc.template_path = package_template_path.absFileName();
+ }
+#if defined (USE_MACOSX_PACKAGING)
+ FileName const user_template_path =
+ FileName(addName(package().user_support().absFileName(), "templates"));
+
+ if (package_template_path != FileName(lyxrc.template_path) &&
+ user_template_path != FileName(lyxrc.template_path))
+ {
+ return;
+ }
+ FileName const user_template_link =
+ FileName(addName(user_template_path.absFileName(),"SystemTemplates"));
+ if (user_template_link.isSymLink() && !equivalent(user_template_link, package_template_path)) {
+ user_template_link.removeFile();
+ }
+ if (!user_template_link.exists()) {
+ if (!package_template_path.link(user_template_link)) {
+ FileName const user_support = package().user_support();
+ if (user_support.exists() && user_support.isDirectory()) {
+ LYXERR(Debug::INIT, "Cannot create symlink " + user_template_link.absFileName());
+ lyxrc.template_path = package_template_path.absFileName();
+ }
+ return;
+ }
+ LYXERR(Debug::INIT, "Symlink \"" << user_template_link.absFileName() << "\" created.");
+ }
+ lyxrc.template_path = user_template_path.absFileName();
+#endif
+}
+
+
bool LyX::init()
{
#ifdef SIGHUP
lyxrc.example_path = addPath(package().system_support().absFileName(),
"examples");
}
- if (lyxrc.template_path.empty()) {
- lyxrc.template_path = addPath(package().system_support().absFileName(),
- "templates");
- }
+ initTemplatePath();
// init LyXDir environment variable
string const lyx_dir = package().lyx_dir().absFileName();
return false;
// Set the PATH correctly.
-#if !defined (USE_POSIX_PACKAGING)
+#if !defined (USE_POSIX_PACKAGING) && !defined (USE_HAIKU_PACKAGING)
// Add the directory containing the LyX executable to the path
// so that LyX can find things like tex2lyx.
if (package().build_support().empty())
if (queryUserLyXDir(package().explicit_user_support())) {
package().reconfigureUserLyXDir("");
+ // Now the user directory is present on first start.
+ initTemplatePath();
}
fileUnlock(fd, lock_file.c_str());
}
if (string(lyx_git_commit_hash) != "none")
cout << to_utf8(_(" Git commit hash "))
<< string(lyx_git_commit_hash).substr(0,8) << endl;
- cout << to_utf8(bformat(_("Built on %1$s[[date]], %2$s[[time]]"),
- from_ascii(lyx_build_date), from_ascii(lyx_build_time))) << endl;
cout << lyx_version_info << endl;
exit(0);
return 0;
cmdmap["-userdir"] = parse_userdir;
cmdmap["-x"] = parse_execute;
cmdmap["--execute"] = parse_execute;
- cmdmap["-e"] = parse_export;
+ cmdmap["-e"] = parse_export;
cmdmap["--export"] = parse_export;
cmdmap["-E"] = parse_export_to;
cmdmap["--export-to"] = parse_export_to;
}
-void dispatch(FuncRequest const & action)
+DispatchResult const & dispatch(FuncRequest const & action)
{
LAPPERR(theApp());
return theApp()->dispatch(action);
void dispatch(FuncRequest const & action, DispatchResult & dr)
{
LAPPERR(theApp());
- return theApp()->dispatch(action, dr);
+ theApp()->dispatch(action, dr);
}