#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 "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 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);
}
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);
}
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);
}
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
// contain documents etc. which might be helpful on
// a crash
- bufferlist.emergencyWriteAll();
- if (lyxserver)
- lyxserver->emergencyCleanup();
+ theApp->bufferList().emergencyWriteAll();
+ theApp->server().emergencyCleanup();
}