#include "Language.h"
#include "Session.h"
#include "Color.h"
-#include "callback.h"
#include "LyXAction.h"
#include "LyXFunc.h"
#include "Lexer.h"
#include "support/Systemcall.h"
#include <boost/bind.hpp>
-#include <boost/filesystem/operations.hpp>
#include <algorithm>
#include <iostream>
using std::system;
#endif
-namespace fs = boost::filesystem;
-
namespace lyx {
using support::addName;
using support::addPath;
using support::bformat;
using support::changeExtension;
-using support::createDirectory;
using support::createLyXTmpDir;
-using support::destroyDir;
using support::FileName;
using support::fileSearch;
using support::getEnv;
*/
bool use_gui = true;
+bool quitting; // flag, that we are quitting the program
namespace {
// we need to parse for "-dbg" and "-help"
easyParse(argc, argv);
- try { support::init_package(to_utf8(from_local8bit(argv[0])),
+ try {
+ support::init_package(to_utf8(from_local8bit(argv[0])),
cl_system_support, cl_user_support,
support::top_build_dir_is_one_level_up);
} catch (support::ExceptionMessage const & message) {
bool final_success = false;
for (BufferList::iterator I = begin; I != pimpl_->buffer_list_.end(); ++I) {
Buffer * buf = *I;
- if (buf != buf->getMasterBuffer())
+ if (buf != buf->masterBuffer())
continue;
bool success = false;
buf->dispatch(batch_command, &success);
LYXERR(Debug::INFO) << "Deleting tmp dir "
<< package().temp_dir().absFilename() << endl;
- if (!destroyDir(package().temp_dir())) {
+ if (!package().temp_dir().destroyDirectory()) {
docstring const msg =
bformat(_("Unable to remove the temporary directory %1$s"),
from_utf8(package().temp_dir().absFilename()));
BufferList::iterator end = pimpl_->buffer_list_.end();
for (; I != end; ++I) {
Buffer * buf = *I;
- if (buf != buf->getMasterBuffer())
+ if (buf != buf->masterBuffer())
continue;
updateLabels(*buf);
}
//...and the modules
moduleList.load();
- if (use_gui) {
- // Set the language defined by the user.
- //setGuiLanguage(lyxrc.gui_language);
+ // read keymap and ui files in batch mode as well
+ // because InsetInfo needs to know these to produce
+ // the correct output
+
+ // Set the language defined by the user.
+ //setGuiLanguage(lyxrc.gui_language);
- // Set up bindings
- pimpl_->toplevel_keymap_.reset(new KeyMap);
- defaultKeyBindings(pimpl_->toplevel_keymap_.get());
- pimpl_->toplevel_keymap_->read(lyxrc.bind_file);
+ // Set up bindings
+ pimpl_->toplevel_keymap_.reset(new KeyMap);
+ defaultKeyBindings(pimpl_->toplevel_keymap_.get());
+ pimpl_->toplevel_keymap_->read(lyxrc.bind_file);
+ // load user bind file user.bind
+ pimpl_->toplevel_keymap_->read("user");
- pimpl_->lyxfunc_.initKeySequences(pimpl_->toplevel_keymap_.get());
+ pimpl_->lyxfunc_.initKeySequences(pimpl_->toplevel_keymap_.get());
- // Read menus
- if (!readUIFile(lyxrc.ui_file))
- return false;
- }
+ // Read menus
+ if (!readUIFile(lyxrc.ui_file))
+ return false;
if (lyxerr.debugging(Debug::LYXRC))
lyxrc.print();
prependEnvPath("PATH", lyxrc.path_prefix);
FileName const document_path(lyxrc.document_path);
- if (fs::exists(document_path.toFilesystemEncoding()) &&
- fs::is_directory(document_path.toFilesystemEncoding()))
+ if (document_path.exists() && document_path.isDirectory())
package().document_dir() = document_path;
package().temp_dir() = createLyXTmpDir(FileName(lyxrc.tempdir_path));
}
-namespace {
-
// return true if file does not exist or is older than configure.py.
-bool needsUpdate(string const & file)
+static bool needsUpdate(string const & file)
{
// We cannot initialize configure_script directly because the package
// is not initialized yet when static objects are constructed.
- static string configure_script;
+ static FileName configure_script;
static bool firstrun = true;
if (firstrun) {
- configure_script = FileName(addName(
- package().system_support().absFilename(),
- "configure.py")).toFilesystemEncoding();
+ configure_script =
+ FileName(addName(package().system_support().absFilename(),
+ "configure.py"));
firstrun = false;
}
- string const absfile = FileName(addName(
- package().user_support().absFilename(), file)).toFilesystemEncoding();
- return (! fs::exists(absfile))
- || (fs::last_write_time(configure_script)
- > fs::last_write_time(absfile));
-}
-
+ FileName absfile =
+ FileName(addName(package().user_support().absFilename(), file));
+ return !absfile.exists()
+ || configure_script.lastModified() > absfile.lastModified();
}
bool LyX::queryUserLyXDir(bool explicit_userdir)
{
// Does user directory exist?
- string const user_support =
- package().user_support().toFilesystemEncoding();
- if (fs::exists(user_support) && fs::is_directory(user_support)) {
+ FileName const sup = package().user_support();
+ if (sup.exists() && sup.isDirectory()) {
first_start = false;
return needsUpdate("lyxrc.defaults")
}
lyxerr << to_utf8(bformat(_("LyX: Creating directory %1$s"),
- from_utf8(package().user_support().absFilename())))
- << endl;
+ from_utf8(sup.absFilename()))) << endl;
- if (!createDirectory(package().user_support(), 0755)) {
+ if (!sup.createDirectory(0755)) {
// Failed, so let's exit.
lyxerr << to_utf8(_("Failed to create directory. Exiting."))
<< endl;
KeyMap & theTopLevelKeymap()
{
- BOOST_ASSERT(use_gui);
return LyX::ref().topLevelKeymap();
}