mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Turn LyX into a singleton class. Kill the BufferView cache.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7922 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6fc6d7e010
commit
50257b8690
@ -255,7 +255,7 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
bv_->showErrorList(_("Parse"));
|
||||
|
||||
if (tolastfiles)
|
||||
lastfiles->newFile(b->fileName());
|
||||
LyX::ref().lastfiles().newFile(b->fileName());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,4 +1,20 @@
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyx_main.[Ch]: make LyX a singleton class, accessible though the new
|
||||
static member functions LyX::ref() and LyX::cref.
|
||||
(lastfiles): new accessor functions for the new lastfiles_ member var.
|
||||
(addLyXView, views_): add a new LyXView to the list of views_.
|
||||
(updateInset): loop over all LyXViews to call their own updateInset
|
||||
member function, returning a pointer to the Buffer owning the inset.
|
||||
|
||||
* BufferView_pimpl.C (loadLyXFile):
|
||||
* MenuBackend.C (expandLastfiles):
|
||||
* bufferlist.C (MenuWrite, QuitLyX):
|
||||
lastfiles is no longer a global variable.
|
||||
Access through LyX::ref().lastfiles(), LyX::cref().lastfiles().
|
||||
|
||||
* boost.C (emergencyCleanup): LyX::emergencyCleanup is no longer a
|
||||
static function. Access through LyX::cref().emergencyCleanup().
|
||||
|
||||
2003-10-14 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
@ -375,9 +375,11 @@ string const limit_string_length(string const & str)
|
||||
|
||||
void expandLastfiles(Menu & tomenu, LyXView const * view)
|
||||
{
|
||||
LastFiles const & lastfiles = LyX::cref().lastfiles();
|
||||
|
||||
int ii = 1;
|
||||
LastFiles::const_iterator lfit = lastfiles->begin();
|
||||
LastFiles::const_iterator end = lastfiles->end();
|
||||
LastFiles::const_iterator lfit = lastfiles.begin();
|
||||
LastFiles::const_iterator end = lastfiles.end();
|
||||
|
||||
for (; lfit != end && ii < 10; ++lfit, ++ii) {
|
||||
string const label = tostr(ii) + ". "
|
||||
|
@ -40,7 +40,7 @@ void emergencyCleanup()
|
||||
|
||||
didCleanup = true;
|
||||
|
||||
LyX::emergencyCleanup();
|
||||
LyX::cref().emergencyCleanup();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ bool BufferList::close(Buffer * buf, bool ask)
|
||||
if (!WriteAs(buf))
|
||||
return false;
|
||||
} else if (buf->save()) {
|
||||
lastfiles->newFile(buf->fileName());
|
||||
LyX::ref().lastfiles().newFile(buf->fileName());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* LyXView.[Ch] (updateInset): invoke BufferView::updateInset, returning
|
||||
a pointer to the Buffer owning the inset.
|
||||
|
||||
2003-10-13 Joao Luis Meloni Assirati <assirati@fma.if.usp.br>
|
||||
|
||||
* lyx_gui.h (set_datasocket_callback, set_serversocket_callback,
|
||||
|
@ -192,3 +192,14 @@ void LyXView::dispatch(FuncRequest const & req)
|
||||
r.setView(view().get());
|
||||
getLyXFunc().dispatch(r);
|
||||
}
|
||||
|
||||
|
||||
Buffer const * const LyXView::updateInset(InsetOld const * inset) const
|
||||
{
|
||||
Buffer const * buffer_ptr = 0;
|
||||
if (inset) {
|
||||
buffer_ptr = bufferview_->buffer();
|
||||
bufferview_->updateInset(inset);
|
||||
}
|
||||
return buffer_ptr;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
class Buffer;
|
||||
class Toolbar;
|
||||
class InsetOld;
|
||||
class Intl;
|
||||
class Menubar;
|
||||
class ControlCommandBuffer;
|
||||
@ -131,6 +132,11 @@ public:
|
||||
/// dispatch to current BufferView
|
||||
void dispatch(FuncRequest const & req);
|
||||
|
||||
/** redraw \c inset in all the BufferViews in which it is currently
|
||||
* visible. If successful return a pointer to the owning Buffer.
|
||||
*/
|
||||
Buffer const * const updateInset(InsetOld const *) const;
|
||||
|
||||
protected:
|
||||
/// view of a buffer. Eventually there will be several.
|
||||
boost::shared_ptr<BufferView> bufferview_;
|
||||
|
@ -1,3 +1,7 @@
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyx_gui.C (start): store the LyXView in the LyX list of all LyXViews.
|
||||
|
||||
2003-10-13 José Matos <jamatos@lyx.org>
|
||||
|
||||
* lyx_gui.C (set_datasocket_callback, set_serversocket_callback,
|
||||
|
@ -313,7 +313,11 @@ void lyx_gui::start(string const & batch, std::vector<string> const & files)
|
||||
start_xforms();
|
||||
// just for debug
|
||||
XSynchronize(getDisplay(), true);
|
||||
GView view;
|
||||
|
||||
boost::shared_ptr<GView> view_ptr(new GView);
|
||||
LyX::ref().addLyXView(view_ptr);
|
||||
|
||||
GView & view = *view_ptr.get();
|
||||
view.show();
|
||||
view.init();
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyx_gui.C (start): store the LyXView in the LyX list of all LyXViews.
|
||||
|
||||
2003-10-13 João Luis Meloni Assirati <assirati@fma.if.usp.br>
|
||||
|
||||
* lyx_gui.C: Declared and allocated lyxsocket.
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
// FIXME: move this stuff out again
|
||||
#include "bufferlist.h"
|
||||
#include "lyx_main.h"
|
||||
#include "LyXAction.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "lyxrc.h"
|
||||
@ -136,7 +137,10 @@ void start(string const & batch, vector<string> const & files)
|
||||
unsigned int width = 690;
|
||||
unsigned int height = 510;
|
||||
|
||||
QtView view(width, height);
|
||||
boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
|
||||
LyX::ref().addLyXView(view_ptr);
|
||||
|
||||
QtView & view = *view_ptr.get();
|
||||
view.show();
|
||||
view.init();
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyx_gui.C (start): store the LyXView in the LyX list of all LyXViews.
|
||||
(LyX_XErrHandler): LyX::emergencyCleanup is no longer a static function.
|
||||
Access through LyX::cref().emergencyCleanup().
|
||||
|
||||
2003-10-13 Joao Luis Meloni Assirati <assirati@fma.if.usp.br>
|
||||
|
||||
* lyx_gui.C (set_datasocket_callback, set_serversocket_callback,
|
||||
|
@ -121,7 +121,7 @@ int LyX_XErrHandler(Display * display, XErrorEvent * xeev) {
|
||||
}
|
||||
|
||||
// emergency cleanup
|
||||
LyX::emergencyCleanup();
|
||||
LyX::cref().emergencyCleanup();
|
||||
|
||||
// Get the reason for the crash.
|
||||
char etxt[513];
|
||||
@ -284,7 +284,10 @@ void start(string const & batch, vector<string> const & files)
|
||||
lyxerr[Debug::GUI] << "Creating view: " << width << 'x' << height
|
||||
<< '+' << xpos << '+' << ypos << endl;
|
||||
|
||||
XFormsView view(width, height);
|
||||
boost::shared_ptr<XFormsView> view_ptr(new XFormsView(width, height));
|
||||
LyX::ref().addLyXView(view_ptr);
|
||||
|
||||
XFormsView & view = *view_ptr.get();
|
||||
view.show(xpos, ypos, "LyX");
|
||||
view.init();
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetexternal.[Ch] (view, cache, view_):
|
||||
* insetgraphics.[Ch] (view, cache, view_):
|
||||
* insetinclude.[Ch] (view, cache, view_): remove the BufferView cache.
|
||||
(statusChanged): call LyX::cref().updateInset.
|
||||
|
||||
* insetinclude.C (fileChanged): use LyX::cref().updateInset rather than
|
||||
the BufferView cache.
|
||||
|
||||
* insetlabel.h: remove #include <boost/weak_ptr.hpp>. Cruft from an
|
||||
earlier clean-up.
|
||||
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetinclude.C (metrics, draw): only draw the preview when previews
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "latexrunparams.h"
|
||||
#include "lyx_main.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxrc.h"
|
||||
#include "metricsinfo.h"
|
||||
@ -380,23 +381,9 @@ InsetExternal::~InsetExternal()
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::cache(BufferView * view) const
|
||||
{
|
||||
BOOST_ASSERT(view);
|
||||
view_ = view->owner()->view();
|
||||
}
|
||||
|
||||
BufferView * InsetExternal::view() const
|
||||
{
|
||||
return view_.lock().get();
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::statusChanged() const
|
||||
{
|
||||
BufferView * const bv = view();
|
||||
if (bv)
|
||||
bv->updateInset(this);
|
||||
LyX::cref().updateInset(this);
|
||||
}
|
||||
|
||||
|
||||
@ -449,7 +436,6 @@ void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetExternal::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
cache(pi.base.bv);
|
||||
renderer_->draw(pi, x, y);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/signals/trackable.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
|
||||
/** No two InsetExternalParams variables can have the same temporary file.
|
||||
@ -129,8 +128,6 @@ public:
|
||||
void setParams(InsetExternalParams const &, Buffer const &);
|
||||
|
||||
private:
|
||||
void cache(BufferView *) const;
|
||||
BufferView * view() const;
|
||||
/** This method is connected to the graphics loader, so we are
|
||||
* informed when the image has been loaded.
|
||||
*/
|
||||
@ -140,9 +137,6 @@ private:
|
||||
InsetExternalParams params_;
|
||||
/// The thing that actually draws the image on LyX's screen.
|
||||
boost::scoped_ptr<RenderBase> renderer_;
|
||||
|
||||
/// Cached
|
||||
mutable boost::weak_ptr<BufferView> view_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -64,6 +64,7 @@ TODO
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "latexrunparams.h"
|
||||
#include "lyx_main.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxrc.h"
|
||||
#include "metricsinfo.h"
|
||||
@ -183,23 +184,9 @@ InsetGraphics::~InsetGraphics()
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphics::cache(BufferView * view) const
|
||||
{
|
||||
BOOST_ASSERT(view);
|
||||
view_ = view->owner()->view();
|
||||
}
|
||||
|
||||
BufferView * InsetGraphics::view() const
|
||||
{
|
||||
return view_.lock().get();
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphics::statusChanged() const
|
||||
{
|
||||
BufferView * bv = view();
|
||||
if (bv)
|
||||
bv->updateInset(this);
|
||||
LyX::cref().updateInset(this);
|
||||
}
|
||||
|
||||
|
||||
@ -241,7 +228,6 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
cache(pi.base.bv);
|
||||
graphic_->draw(pi, x, y);
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,6 @@
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/signals/trackable.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
|
||||
class Dialogs;
|
||||
class RenderGraphic;
|
||||
@ -83,9 +81,6 @@ private:
|
||||
///
|
||||
friend class InsetGraphicsMailer;
|
||||
|
||||
void cache(BufferView *) const;
|
||||
BufferView * view() const;
|
||||
|
||||
/** This method is connected to the graphics loader, so we are
|
||||
* informed when the image has been loaded.
|
||||
*/
|
||||
@ -109,9 +104,6 @@ private:
|
||||
|
||||
/// The thing that actually draws the image on LyX's screen.
|
||||
boost::scoped_ptr<RenderGraphic> const graphic_;
|
||||
|
||||
/// Cached
|
||||
mutable boost::weak_ptr<BufferView> view_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "latexrunparams.h"
|
||||
#include "lyx_main.h"
|
||||
#include "lyxlex.h"
|
||||
#include "metricsinfo.h"
|
||||
|
||||
@ -540,16 +541,15 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetInclude::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
cache(pi.base.bv);
|
||||
|
||||
if (!RenderPreview::activated() || !preview_->previewReady()) {
|
||||
button_.draw(pi, x + button_.box().x1, y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preview_->monitoring()) {
|
||||
string const included_file =
|
||||
includedFilename(*view()->buffer(), params_);
|
||||
BOOST_ASSERT(pi.base.bv);
|
||||
Buffer const * const buffer = pi.base.bv->buffer();
|
||||
if (!preview_->monitoring() && buffer) {
|
||||
string const included_file = includedFilename(*buffer, params_);
|
||||
preview_->startMonitoring(included_file);
|
||||
}
|
||||
|
||||
@ -557,40 +557,23 @@ void InsetInclude::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::cache(BufferView * view) const
|
||||
{
|
||||
BOOST_ASSERT(view);
|
||||
view_ = view->owner()->view();
|
||||
}
|
||||
|
||||
BufferView * InsetInclude::view() const
|
||||
{
|
||||
return view_.lock().get();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// preview stuff
|
||||
//
|
||||
|
||||
void InsetInclude::statusChanged() const
|
||||
{
|
||||
if (view())
|
||||
view()->updateInset(this);
|
||||
LyX::cref().updateInset(this);
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::fileChanged() const
|
||||
{
|
||||
BufferView * const bv = view();
|
||||
if (!bv)
|
||||
Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
|
||||
if (!buffer_ptr)
|
||||
return;
|
||||
bv->updateInset(this);
|
||||
|
||||
if (!bv->buffer())
|
||||
return;
|
||||
Buffer const & buffer = *bv->buffer();
|
||||
|
||||
Buffer const & buffer = *buffer_ptr;
|
||||
preview_->removePreview(buffer);
|
||||
generate_preview(*preview_.get(), *this, buffer);
|
||||
}
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include "insetcommandparams.h"
|
||||
#include "render_button.h"
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
|
||||
class Buffer;
|
||||
class Dimension;
|
||||
@ -82,9 +80,6 @@ public:
|
||||
void addPreview(lyx::graphics::PreviewLoader &) const;
|
||||
|
||||
private:
|
||||
void cache(BufferView *) const;
|
||||
BufferView * view() const;
|
||||
|
||||
/// Slot receiving a signal that the preview is ready to display.
|
||||
void statusChanged() const;
|
||||
/** Slot receiving a signal that the external file has changed
|
||||
@ -112,7 +107,6 @@ private:
|
||||
boost::scoped_ptr<RenderMonitoredPreview> const preview_;
|
||||
|
||||
/// cache
|
||||
mutable boost::weak_ptr<BufferView> view_;
|
||||
mutable bool set_label_;
|
||||
mutable RenderButton button_;
|
||||
};
|
||||
|
@ -12,9 +12,7 @@
|
||||
#ifndef INSET_LABEL_H
|
||||
#define INSET_LABEL_H
|
||||
|
||||
|
||||
#include "insetcommand.h"
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
class InsetLabel : public InsetCommand {
|
||||
public:
|
||||
|
@ -90,7 +90,7 @@ bool quitting; // flag, that we are quitting the program
|
||||
bool MenuWrite(Buffer * buffer)
|
||||
{
|
||||
if (buffer->save()) {
|
||||
lastfiles->newFile(buffer->fileName());
|
||||
LyX::ref().lastfiles().newFile(buffer->fileName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ void QuitLyX()
|
||||
if (!bufferlist.quitWriteAll())
|
||||
return;
|
||||
|
||||
lastfiles->writeFile(lyxrc.lastfiles);
|
||||
LyX::cref().lastfiles().writeFile(lyxrc.lastfiles);
|
||||
}
|
||||
|
||||
// Set a flag that we do quitting from the program,
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/lyx_gui.h"
|
||||
#include "frontends/LyXView.h"
|
||||
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/filetools.h"
|
||||
@ -87,8 +88,6 @@ extern void QuitLyX();
|
||||
|
||||
extern LyXServer * lyxserver;
|
||||
|
||||
boost::scoped_ptr<LastFiles> lastfiles;
|
||||
|
||||
// This is the global bufferlist object
|
||||
BufferList bufferlist;
|
||||
|
||||
@ -105,9 +104,80 @@ void showFileError(string const & error)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
boost::scoped_ptr<LyX> LyX::singleton_;
|
||||
|
||||
void LyX::exec(int & argc, char * argv[])
|
||||
{
|
||||
BOOST_ASSERT(!singleton_.get());
|
||||
// We must return from this before launching the gui so that
|
||||
// other parts of the code can access singleton_ through
|
||||
// LyX::ref and LyX::cref.
|
||||
singleton_.reset(new LyX);
|
||||
// Start the real execution loop.
|
||||
singleton_->priv_exec(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
LyX & LyX::ref()
|
||||
{
|
||||
BOOST_ASSERT(singleton_.get());
|
||||
return *singleton_.get();
|
||||
}
|
||||
|
||||
LyX::LyX(int & argc, char * argv[])
|
||||
|
||||
LyX const & LyX::cref()
|
||||
{
|
||||
BOOST_ASSERT(singleton_.get());
|
||||
return *singleton_.get();
|
||||
}
|
||||
|
||||
|
||||
LyX::LyX()
|
||||
: first_start(false)
|
||||
{}
|
||||
|
||||
|
||||
LastFiles & LyX::lastfiles()
|
||||
{
|
||||
BOOST_ASSERT(lastfiles_.get());
|
||||
return *lastfiles_.get();
|
||||
}
|
||||
|
||||
|
||||
LastFiles const & LyX::lastfiles() const
|
||||
{
|
||||
BOOST_ASSERT(lastfiles_.get());
|
||||
return *lastfiles_.get();
|
||||
}
|
||||
|
||||
|
||||
void LyX::addLyXView(boost::shared_ptr<LyXView> const & lyxview)
|
||||
{
|
||||
views_.push_back(lyxview);
|
||||
}
|
||||
|
||||
|
||||
Buffer const * const LyX::updateInset(InsetOld const * inset) const
|
||||
{
|
||||
if (!inset)
|
||||
return 0;
|
||||
|
||||
Buffer const * buffer_ptr = 0;
|
||||
ViewList::const_iterator it = views_.begin();
|
||||
ViewList::const_iterator const end = views_.end();
|
||||
for (; it != end; ++it) {
|
||||
Buffer const * ptr = (*it)->updateInset(inset);
|
||||
if (ptr)
|
||||
buffer_ptr = ptr;
|
||||
}
|
||||
return buffer_ptr;
|
||||
}
|
||||
|
||||
|
||||
void LyX::priv_exec(int & argc, char * argv[])
|
||||
{
|
||||
// Here we need to parse the command line. At least
|
||||
// we need to parse for "-dbg" and "-help"
|
||||
@ -226,7 +296,7 @@ static void error_handler(int err_sig)
|
||||
signal(SIGTERM, SIG_DFL);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
|
||||
LyX::emergencyCleanup();
|
||||
LyX::cref().emergencyCleanup();
|
||||
|
||||
lyxerr << "Bye." << endl;
|
||||
if (err_sig!= SIGHUP &&
|
||||
@ -327,9 +397,9 @@ void LyX::init(bool gui)
|
||||
|
||||
lyxerr[Debug::INIT] << "Reading lastfiles `"
|
||||
<< lyxrc.lastfiles << "'..." << endl;
|
||||
lastfiles.reset(new LastFiles(lyxrc.lastfiles,
|
||||
lyxrc.check_lastfiles,
|
||||
lyxrc.num_lastfiles));
|
||||
lastfiles_.reset(new LastFiles(lyxrc.lastfiles,
|
||||
lyxrc.check_lastfiles,
|
||||
lyxrc.num_lastfiles));
|
||||
}
|
||||
|
||||
|
||||
@ -391,7 +461,7 @@ void LyX::defaultKeyBindings(kb_keymap * kbmap)
|
||||
}
|
||||
|
||||
|
||||
void LyX::emergencyCleanup()
|
||||
void LyX::emergencyCleanup() const
|
||||
{
|
||||
// what to do about tmpfiles is non-obvious. we would
|
||||
// like to delete any we find, but our lyxdir might
|
||||
|
@ -15,31 +15,46 @@
|
||||
#define LYX_MAIN_H
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
class ErrorItem;
|
||||
class LyXRC;
|
||||
class LastFiles;
|
||||
class Buffer;
|
||||
class ErrorItem;
|
||||
class InsetOld;
|
||||
class LastFiles;
|
||||
class LyXView;
|
||||
class kb_keymap;
|
||||
|
||||
|
||||
/// last files loaded
|
||||
extern boost::scoped_ptr<LastFiles> lastfiles;
|
||||
|
||||
|
||||
/// initial startup
|
||||
class LyX : boost::noncopyable {
|
||||
public:
|
||||
LyX(int & argc, char * argv[]);
|
||||
static void exec(int & argc, char * argv[]);
|
||||
static LyX & ref();
|
||||
static LyX const & cref();
|
||||
|
||||
/// in the case of failure
|
||||
static void emergencyCleanup();
|
||||
void emergencyCleanup() const;
|
||||
|
||||
LastFiles & lastfiles();
|
||||
LastFiles const & lastfiles() const;
|
||||
|
||||
void addLyXView(boost::shared_ptr<LyXView> const & lyxview);
|
||||
|
||||
/** redraw \c inset in all the BufferViews in which it is currently
|
||||
* visible. If successful return a pointer to the owning Buffer.
|
||||
*/
|
||||
Buffer const * const updateInset(InsetOld const *) const;
|
||||
|
||||
private:
|
||||
static boost::scoped_ptr<LyX> singleton_;
|
||||
|
||||
LyX();
|
||||
void priv_exec(int & argc, char * argv[]);
|
||||
|
||||
/// initial LyX set up
|
||||
void init(bool);
|
||||
/// set up the default key bindings
|
||||
@ -65,6 +80,12 @@ private:
|
||||
bool first_start;
|
||||
/// the parsed command line batch command if any
|
||||
std::string batch_command;
|
||||
|
||||
/// last files loaded
|
||||
boost::scoped_ptr<LastFiles> lastfiles_;
|
||||
///
|
||||
typedef std::list<boost::shared_ptr<LyXView> > ViewList;
|
||||
ViewList views_;
|
||||
};
|
||||
|
||||
#endif // LYX_MAIN_H
|
||||
|
@ -34,6 +34,6 @@ int main(int argc, char * argv[])
|
||||
// initialize for internationalized version *EK*
|
||||
locale_init();
|
||||
|
||||
LyX lyx(argc, argv);
|
||||
LyX::exec(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetformulabase.[Ch] (view, cache, view_): remove the BufferView cache.
|
||||
|
||||
* insetformula.C (statusChanged): call LyX::cref().updateInset.
|
||||
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* formula.C (metrics, draw): only draw the preview when previews
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "debug.h"
|
||||
#include "latexrunparams.h"
|
||||
#include "LColor.h"
|
||||
#include "lyx_main.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
@ -191,8 +192,6 @@ bool editing_inset(InsetFormula const * inset)
|
||||
|
||||
void InsetFormula::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
cache(pi.base.bv);
|
||||
|
||||
// The previews are drawn only when we're not editing the inset.
|
||||
bool const use_preview = (!editing_inset(this) &&
|
||||
RenderPreview::activated() &&
|
||||
@ -300,8 +299,7 @@ void InsetFormula::mutate(string const & type)
|
||||
|
||||
void InsetFormula::statusChanged() const
|
||||
{
|
||||
if (view())
|
||||
view()->updateInset(this);
|
||||
LyX::cref().updateInset(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,12 +14,6 @@
|
||||
#include "formulabase.h"
|
||||
#include "formula.h"
|
||||
#include "formulamacro.h"
|
||||
#include "funcrequest.h"
|
||||
#include "BufferView.h"
|
||||
#include "bufferview_funcs.h"
|
||||
#include "lyxtext.h"
|
||||
#include "gettext.h"
|
||||
#include "debug.h"
|
||||
#include "math_support.h"
|
||||
#include "math_arrayinset.h"
|
||||
#include "math_deliminset.h"
|
||||
@ -28,17 +22,24 @@
|
||||
#include "math_hullinset.h"
|
||||
#include "math_parser.h"
|
||||
#include "math_spaceinset.h"
|
||||
#include "undo.h"
|
||||
#include "ref_inset.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "bufferview_funcs.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "LColor.h"
|
||||
#include "lyxtext.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
#include "support/std_sstream.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
using lyx::support::atoi;
|
||||
using lyx::support::split;
|
||||
using lyx::support::token;
|
||||
@ -139,18 +140,6 @@ void InsetFormulaBase::handleFont2(BufferView * bv, string const & arg)
|
||||
|
||||
|
||||
|
||||
void InsetFormulaBase::cache(BufferView * view) const
|
||||
{
|
||||
BOOST_ASSERT(view);
|
||||
view_ = view->owner()->view();
|
||||
}
|
||||
|
||||
BufferView * InsetFormulaBase::view() const
|
||||
{
|
||||
return view_.lock().get();
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaBase::validate(LaTeXFeatures &) const
|
||||
{}
|
||||
|
||||
|
@ -15,8 +15,6 @@
|
||||
#define INSET_FORMULABASE_H
|
||||
|
||||
#include "insets/updatableinset.h"
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
|
||||
class Buffer;
|
||||
class BufferView;
|
||||
@ -98,10 +96,6 @@ private:
|
||||
///
|
||||
dispatch_result lfunMouseMotion(FuncRequest const &);
|
||||
|
||||
protected:
|
||||
void cache(BufferView *) const;
|
||||
BufferView * view() const;
|
||||
|
||||
protected:
|
||||
|
||||
/** Find the PreviewLoader, add a LaTeX snippet to it and
|
||||
@ -121,9 +115,6 @@ protected:
|
||||
mutable int xo_;
|
||||
///
|
||||
mutable int yo_;
|
||||
private:
|
||||
// Cache
|
||||
mutable boost::weak_ptr<BufferView> view_;
|
||||
};
|
||||
|
||||
// We don't really mess want around with mathed stuff outside mathed.
|
||||
|
@ -1,3 +1,13 @@
|
||||
2003-10-14 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* Makefile.am: move boost.C from the linked_files section
|
||||
to the tex2lyx_SOURCES section.
|
||||
|
||||
* boost.C: new file. Simpler than the version in the main lyx source.
|
||||
No reference to the emergencyCleanup stuff.
|
||||
|
||||
* tex2lyx.C: remove emergencyCleanup() stuff.
|
||||
|
||||
2003-10-08 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
Fix doxygen warnings.
|
||||
|
@ -16,7 +16,6 @@ bin_PROGRAMS = tex2lyx
|
||||
linked_files = \
|
||||
FloatList.C \
|
||||
Floating.C \
|
||||
boost.C \
|
||||
counters.C \
|
||||
lyxlayout.h \
|
||||
lyxlayout.C \
|
||||
@ -28,6 +27,7 @@ linked_files = \
|
||||
tex2lyx_SOURCES = \
|
||||
$(linked_files) \
|
||||
Spacing.h \
|
||||
boost.C \
|
||||
context.C \
|
||||
context.h \
|
||||
gettext.C \
|
||||
|
41
src/tex2lyx/boost.C
Normal file
41
src/tex2lyx/boost.C
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* \file boost.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Lars Gullik Bjønnes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
|
||||
using std::endl;
|
||||
|
||||
namespace boost {
|
||||
|
||||
void throw_exception(std::exception const & e)
|
||||
{
|
||||
lyxerr << "Exception caught:\n"
|
||||
<< e.what() << endl;
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
|
||||
|
||||
void assertion_failed(char const * expr, char const * function,
|
||||
char const * file, long line)
|
||||
{
|
||||
lyxerr << "Assertion triggered in " << function
|
||||
<< " by failing check \"" << expr << "\""
|
||||
<< " in file " << file << ":" << line << endl;
|
||||
::abort();
|
||||
}
|
||||
|
||||
} // namespace boost
|
@ -16,7 +16,6 @@
|
||||
#include "context.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "lyx_main.h"
|
||||
#include "lyxtextclass.h"
|
||||
#include "support/path_defines.h"
|
||||
#include "support/os.h"
|
||||
@ -43,8 +42,6 @@ using std::vector;
|
||||
// Hacks to allow the thing to link in the lyxlayout stuff
|
||||
LyXErr lyxerr(std::cerr.rdbuf());
|
||||
|
||||
void LyX::emergencyCleanup() {}
|
||||
|
||||
void handle_comment(Parser & p)
|
||||
{
|
||||
string s;
|
||||
|
Loading…
Reference in New Issue
Block a user