#include "lyxfunc.h"
#include "lyxlex.h"
#include "lyxrc.h"
-#include "lyxtextclasslist.h"
#include "lyxserver.h"
+#include "lyxtextclasslist.h"
#include "MenuBackend.h"
#include "mover.h"
#include "ToolbarBackend.h"
-#include "mathed/math_inset.h"
-
#include "frontends/Alert.h"
+#include "frontends/Application.h"
#include "frontends/lyx_gui.h"
#include "frontends/LyXView.h"
#include "support/environment.h"
#include "support/filetools.h"
+#include "support/fontutils.h"
#include "support/lyxlib.h"
#include "support/convert.h"
#include "support/os.h"
using lyx::support::i18nLibFileSearch;
using lyx::support::libFileSearch;
using lyx::support::package;
-using lyx::support::Path;
using lyx::support::prependEnvPath;
using lyx::support::rtrim;
using lyx::support::Systemcall;
+using lyx::docstring;
+
namespace os = lyx::support::os;
namespace fs = boost::filesystem;
using std::endl;
using std::string;
using std::vector;
+using std::for_each;
#ifndef CXX_GLOBAL_CSTD
using std::exit;
#endif
-extern LyXServer * lyxserver;
-
-// This is the global bufferlist object
-BufferList bufferlist;
-
// convenient to have it here.
boost::scoped_ptr<kb_keymap> toplevel_keymap;
// FIXME: We should not directly call exit(), since it only
// guarantees a return to the system, no application cleanup.
// This may cause troubles with not executed destructors.
- if (lyx_gui::use_gui)
- // lyx_gui::exit may return and only schedule the exit
- lyx_gui::exit(status);
+ if (lyx_gui::use_gui) {
+ theApp->exit(status);
+ // Restore original font resources after Application is destroyed.
+ lyx::support::restoreFontResources();
+ }
+
exit(status);
}
void showFileError(string const & error)
{
- Alert::warning(lyx::to_utf8(_("Could not read configuration file")),
- bformat(lyx::to_utf8(_("Error while reading the configuration file\n%1$s.\n"
- "Please check your installation.")), error));
+ Alert::warning(_("Could not read configuration file"),
+ bformat(_("Error while reading the configuration file\n%1$s.\n"
+ "Please check your installation."), lyx::from_utf8(error)));
}
string const configure_command = package().configure_command();
lyxerr << lyx::to_utf8(_("LyX: reconfiguring user directory")) << endl;
- Path p(package().user_support());
+ lyx::support::Path p(package().user_support());
Systemcall one;
one.startscript(Systemcall::Wait, configure_command);
lyxerr << "LyX: " << lyx::to_utf8(_("Done!")) << endl;
lyx::support::top_build_dir_is_one_level_up);
// Start the real execution loop.
- if (lyx_gui::use_gui)
+ if (lyx_gui::use_gui) {
+ // Force adding of font path _before_ Application is initialized
+ lyx::support::addFontResources();
return lyx_gui::exec(argc, argv);
+ }
else
return exec2(argc, argv);
}
// other than documents
for (int argi = 1; argi < argc ; ++argi) {
if (argv[argi][0] == '-') {
- lyxerr << bformat(lyx::to_utf8(_("Wrong command line option `%1$s'. Exiting.")),
- argv[argi]) << endl;
+ lyxerr << lyx::to_utf8(
+ bformat(_("Wrong command line option `%1$s'. Exiting."),
+ lyx::from_utf8(argv[argi]))) << endl;
return EXIT_FAILURE;
}
}
if (!success)
return EXIT_FAILURE;
- if (lyx_gui::use_gui)
- lyx_gui::parse_lyxrc();
-
vector<string> files;
for (int argi = argc - 1; argi >= 1; --argi)
if (b)
last_loaded = b;
} else {
- Buffer * buf = bufferlist.newBuffer(s, false);
+ Buffer * buf = theApp->bufferList().newBuffer(s, false);
if (loadLyXFile(buf, s)) {
last_loaded = buf;
ErrorList const & el = buf->errorList("Parse");
boost::bind(&LyX::printError, this, _1));
}
else
- bufferlist.release(buf);
+ theApp->bufferList().release(buf);
}
}
height = 0;
}
// create the main window
- LyXView * view = lyx_gui::create_view(width, height, posx, posy, maximize);
+ LyXView * view = &theApp->createView(width, height, posx, posy, maximize);
+ ref().addLyXView(view);
// load files
for_each(files.begin(), files.end(),
// clear this list to save a few bytes of RAM
session_->clearLastOpenedFiles();
- return lyx_gui::start(view, batch_command);
+ return theApp->start(batch_command);
} else {
// Something went wrong above
quitLyX(false);
void LyX::printError(ErrorItem const & ei)
{
- std::cerr << lyx::to_utf8(_("LyX: ")) << ei.error
- << ':' << ei.description << std::endl;
-
+ docstring tmp = _("LyX: ") + ei.error + lyx::char_type(':')
+ + ei.description;
+ std::cerr << lyx::to_utf8(tmp) << std::endl;
}
}
if (lyxrc.roman_font_name.empty())
- lyxrc.roman_font_name = lyx_gui::roman_font_name();
+ lyxrc.roman_font_name =
+ lyx_gui::use_gui? theApp->romanFontName(): "serif";
+
if (lyxrc.sans_font_name.empty())
- lyxrc.sans_font_name = lyx_gui::sans_font_name();
+ lyxrc.sans_font_name =
+ lyx_gui::use_gui? theApp->sansFontName(): "sans";
+
if (lyxrc.typewriter_font_name.empty())
- lyxrc.typewriter_font_name = lyx_gui::typewriter_font_name();
+ lyxrc.typewriter_font_name =
+ lyx_gui::use_gui? theApp->typewriterFontName(): "monospace";
//
// Read configuration files
package().temp_dir() = createLyXTmpDir(lyxrc.tempdir_path);
if (package().temp_dir().empty()) {
- Alert::error(lyx::to_utf8(_("Could not create temporary directory")),
- bformat(lyx::to_utf8(_("Could not create a temporary directory in\n"
+ Alert::error(_("Could not create temporary directory"),
+ bformat(_("Could not create a temporary directory in\n"
"%1$s. Make sure that this\n"
- "path exists and is writable and try again.")),
- lyxrc.tempdir_path));
+ "path exists and is writable and try again."),
+ lyx::from_utf8(lyxrc.tempdir_path)));
// createLyXTmpDir() tries sufficiently hard to create a
// usable temp dir, so the probability to come here is
// close to zero. We therefore don't try to overcome this
// contain documents etc. which might be helpful on
// a crash
- bufferlist.emergencyWriteAll();
- if (lyxserver)
- lyxserver->emergencyCleanup();
+ theApp->bufferList().emergencyWriteAll();
+ theApp->server().emergencyCleanup();
}
// to create it. If the user says "no", then exit.
if (explicit_userdir &&
Alert::prompt(
- lyx::to_utf8(_("Missing user LyX directory")),
- bformat(lyx::to_utf8(_("You have specified a non-existent user "
+ _("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.")),
- package().user_support()),
+ "It is needed to keep your own configuration."),
+ lyx::from_utf8(package().user_support())),
1, 0,
- lyx::to_utf8(_("&Create directory")),
- lyx::to_utf8(_("&Exit LyX")))) {
+ _("&Create directory"),
+ _("&Exit LyX"))) {
lyxerr << lyx::to_utf8(_("No user LyX directory. Exiting.")) << endl;
lyx_exit(EXIT_FAILURE);
}
- lyxerr << bformat(lyx::to_utf8(_("LyX: Creating directory %1$s")),
- package().user_support())
+ lyxerr << lyx::to_utf8(bformat(_("LyX: Creating directory %1$s"),
+ lyx::from_utf8(package().user_support())))
<< endl;
if (!createDirectory(package().user_support(), 0755)) {
Debug::showTags(lyxerr);
exit(0);
}
- lyxerr << bformat(lyx::to_utf8(_("Setting debug level to %1$s")), arg) << endl;
+ lyxerr << lyx::to_utf8(bformat(_("Setting debug level to %1$s"), lyx::from_utf8(arg))) << endl;
lyxerr.level(Debug::value(arg));
Debug::showLevel(lyxerr, lyxerr.level());