Alert.h
Alert_pimpl.h
Application.h
- Clipboard.h\r
- NoGuiFontLoader.h\r
- NoGuiFontMetrics.h\r
+ Clipboard.h
+ NoGuiFontLoader.h
+ NoGuiFontMetrics.h
Dialogs.h
FileDialog.h
FontLoader.h
Menu "file"
Item "New Window|W" "window-new"
+ Item "Close Window|d" "window-close"
Item "New|N" "buffer-new"
Item "New from Template...|m" "buffer-new-template"
Item "Open...|O" "file-open"
{ LFUN_PARAGRAPH_MOVE_DOWN, "paragraph-move-down", Noop },
{ LFUN_PARAGRAPH_MOVE_UP, "paragraph-move-up", Noop },
{ LFUN_WINDOW_NEW, "window-new", NoBuffer },
+ { LFUN_WINDOW_CLOSE, "window-close", NoBuffer },
{ LFUN_UNICODE_INSERT, "unicode-insert", Noop },
{ LFUN_NOACTION, "", Noop }
#include <boost/shared_ptr.hpp>
#include <map>
+#include <vector>
namespace lyx {
virtual int newView() = 0;
///
virtual LyXView & view(int id) = 0;
- ///
- virtual void destroyView(int id) = 0;
///
virtual int newWorkArea(unsigned int width, unsigned int height, int view_id) = 0;
///
virtual WorkArea & workArea(int id) = 0;
+
///
- virtual void destroyWorkArea(int id) = 0;
+ std::vector<int> const & viewIds() { return view_ids_; };
protected:
/// view of a buffer. Eventually there will be several.
std::map<int, boost::shared_ptr<BufferView> > buffer_views_;
+
+ std::vector<int> view_ids_;
};
} // namespace frontend
string current_layout;
-LyXView::LyXView()
- : work_area_(0),
+LyXView::LyXView(int id)
+ : id_(id), work_area_(0),
toolbars_(new Toolbars(*this)),
autosave_timeout_(new Timeout(5000)),
dialogs_(new Dialogs(*this)),
}
+// FIXME, there's only one WorkArea per LyXView possible for now.
void LyXView::setWorkArea(WorkArea * work_area)
{
work_area_ = work_area;
+ work_area_ids_.clear();
+ work_area_ids_.push_back(work_area_->id());
}
void LyXView::dispatch(FuncRequest const & cmd)
{
+ if (cmd.action == LFUN_WINDOW_CLOSE) {
+ close();
+ closed(id_);
+ return;
+ }
+
theLyXFunc().setLyXView(this);
lyx::dispatch(cmd);
}
#include <boost/signals/trackable.hpp>
#include <boost/utility.hpp>
+#include <vector>
+
namespace lyx {
class Buffer;
class LyXView : public boost::signals::trackable, boost::noncopyable {
public:
- LyXView();
+ LyXView(int id);
virtual ~LyXView();
+ int const id() const { return id_; }
+
+ virtual void close() = 0;
+
+ std::vector<int> const & workAreaIds() const { return work_area_ids_; }
+
void setWorkArea(frontend::WorkArea * work_area);
+ /// This signal is emitted with the LyXView id when it is closed.
+ boost::signal<void(int)> closed;
+
/**
* This is called after the concrete view has been created.
* We have to have the toolbar and the other stuff created
*/
virtual void init() = 0;
+ ///
virtual void setGeometry(
unsigned int width,
unsigned int height,
int posx, int posy,
bool maximize) = 0;
+ /// save the geometry state in the session manager.
+ virtual void saveGeometry() = 0;
+
/// show busy cursor
virtual void busy(bool) const = 0;
CommandBufferPtr;
CommandBufferPtr const controlcommand_;
+
+private:
+ int id_;
+ std::vector<int> work_area_ids_;
};
} // namespace lyx
namespace lyx {
namespace frontend {
-WorkArea::WorkArea(LyXView & lyx_view)
- : buffer_view_(0), lyx_view_(lyx_view), greyed_out_(true),
+WorkArea::WorkArea(int id, LyXView & lyx_view)
+ : id_(id), buffer_view_(0), lyx_view_(lyx_view), greyed_out_(true),
cursor_visible_(false), cursor_timeout_(400)
{
// Start loading the pixmap as soon as possible
*/
class WorkArea : public boost::signals::trackable {
public:
- WorkArea(LyXView & lyx_view);
+ WorkArea(int id, LyXView & lyx_view);
virtual ~WorkArea() {}
+ int const id() const { return id_; }
+
void setBufferView(BufferView * buffer_view);
///
bool greyed_out_;
private:
+ ///
+ int id_;
///
void displayMessage(docstring const &);
/// buffer messages signal connection
#include "BufferView.h"
#include "Color.h"
#include "debug.h"
+#include "funcrequest.h"
#include "lyx_main.h"
+#include "lyxfunc.h"
#include "lyxrc.h"
#include <QApplication>
LoaderQueue::setPriority(10,100);
+ setQuitOnLastWindowClosed(false);
+ QObject::connect(this, SIGNAL(lastWindowClosed()),
+ this, SLOT(quitLyX()));
+
guiApp = this;
}
+void GuiApplication::quitLyX()
+{
+ theLyXFunc().setLyXView(0);
+
+ // trigger LFUN_LYX_QUIT instead of QApplication::quit() directly
+ // since LFUN_LYX_QUIT may have more cleanup stuff
+ dispatch(FuncRequest(LFUN_LYX_QUIT));
+}
+
+
Clipboard& GuiApplication::clipboard()
{
return clipboard_;
} // namespace frontend
} // namespace lyx
+
+#include "GuiApplication_moc.cpp"
*/
class GuiApplication : public QApplication, public Application
{
+ Q_OBJECT
+
public:
GuiApplication(int & argc, char ** argv);
///
///
GuiFontLoader & guiFontLoader() { return font_loader_; }
+private Q_SLOTS:
+ /// request an LFUN_LYX_QUIT
+ void quitLyX();
+
private:
///
GuiImplementation gui_;
#include "GuiWorkArea.h"
#include "BufferView.h"
+#include "funcrequest.h"
+#include "lyxfunc.h"
using boost::shared_ptr;
namespace lyx {
namespace frontend {
+
GuiImplementation::GuiImplementation(): max_view_id_(0), max_wa_id_(0)
{
}
size_t const id = max_view_id_;
++max_view_id_;
- views_[id].reset(new GuiView());
+ views_[id] = new GuiView(id);
+ view_ids_.push_back(id);
+
+ QObject::connect(views_[id], SIGNAL(destroyed(QObject *)),
+ this, SLOT(cleanupViews(QObject *)));
return id;
}
{
BOOST_ASSERT(views_.find(id) != views_.end());
- return *views_[id].get();
+ return *views_[id];
+}
+
+
+void GuiImplementation::cleanupViews(QObject * qobj)
+{
+ GuiView * view = static_cast<GuiView *>(qobj);
+ std::map<int, GuiView *>::iterator I;
+
+ for (I = views_.begin(); I != views_.end(); ++I) {
+ if (I->second == view) {
+ views_.erase(I->first);
+ break;
+ }
+ }
+
+ buildViewIds();
+
+ if (views_.empty()) {
+ theLyXFunc().setLyXView(0);
+// dispatch(FuncRequest(LFUN_LYX_QUIT));
+ return;
+ }
+ theLyXFunc().setLyXView(views_.begin()->second);
}
-void GuiImplementation::destroyView(int id)
+void GuiImplementation::buildViewIds()
{
- views_.erase(id);
+ view_ids_.clear();
+ std::map<int, GuiView *>::const_iterator I;
+ for (I = views_.begin(); I != views_.end(); ++I)
+ view_ids_.push_back(I->first);
}
size_t const id = max_wa_id_;
++max_wa_id_;
- GuiView * view = views_[view_id].get();
+ GuiView * view = views_[view_id];
- work_areas_[id].reset(new GuiWorkArea(w, h, *view));
+ work_areas_[id] = new GuiWorkArea(w, h, id, *view);
// FIXME BufferView creation should be independant of WorkArea creation
buffer_views_[id].reset(new BufferView);
work_areas_[id]->setBufferView(buffer_views_[id].get());
- view->setWorkArea(work_areas_[id].get());
+ view->setWorkArea(work_areas_[id]);
- view->setCentralWidget(work_areas_[id].get());
+ view->setCentralWidget(work_areas_[id]);
return id;
}
{
BOOST_ASSERT(work_areas_.find(id) != work_areas_.end());
- return *work_areas_[id].get();
+ return *work_areas_[id];
}
-void GuiImplementation::destroyWorkArea(int id)
-{
- work_areas_.erase(id);
-}
-
} // namespace frontend
} // namespace lyx
+
+#include "GuiImplementation_moc.cpp"
#include "frontends/Gui.h"
-#include <boost/shared_ptr.hpp>
+#include <QObject>
#include <map>
/**
* The GuiImplementation class is the interface to all Qt4 components.
*/
-class GuiImplementation: public Gui
+class GuiImplementation: public QObject, public Gui
{
+ Q_OBJECT
+
public:
GuiImplementation();
virtual ~GuiImplementation() {}
int newView();
LyXView& view(int id);
- void destroyView(int id);
int newWorkArea(unsigned int width, unsigned int height, int view_id);
WorkArea& workArea(int id);
- void destroyWorkArea(int id);
+private Q_SLOTS:
+ ///
+ void cleanupViews(QObject * view);
private:
///
- std::map<int, boost::shared_ptr<GuiView> > views_;
- ///
- std::map<int, boost::shared_ptr<GuiWorkArea> > work_areas_;
+ void buildViewIds();
+
+ /// Multiple views container.
+ /**
+ * Warning: This must not be a smart pointer as the destruction of the
+ * object is handled by Qt when the view is closed
+ * \sa Qt::WA_DeleteOnClose attribute.
+ */
+ std::map<int, GuiView *> views_;
+
+ /// Multiple workareas container.
+ /**
+ * Warning: This must not be a smart pointer as the destruction of the
+ * object is handled by Qt when its parent view is closed.
+ */
+ std::map<int, GuiWorkArea *> work_areas_;
///
size_t max_view_id_;
///
} // namespace anon
-GuiView::GuiView()
- : QMainWindow(), LyXView(), commandbuffer_(0)
+GuiView::GuiView(int id)
+ : QMainWindow(), LyXView(id), commandbuffer_(0)
{
+ setAttribute(Qt::WA_DeleteOnClose, true);
+ setAttribute(Qt::WA_QuitOnClose, true);
+
// setToolButtonStyle(Qt::ToolButtonIconOnly);
// setIconSize(QSize(12,12));
}
+void GuiView::close()
+{
+ QMainWindow::close();
+}
+
+
void GuiView::init()
{
menubar_.reset(new QLMenubar(this, menubackend));
}
+void GuiView::saveGeometry()
+{
+ // FIXME:
+ // change the ifdef to 'geometry = normalGeometry();' only
+ // when Trolltech has fixed the broken normalGeometry on X11:
+ // http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
+ // Then also the moveEvent, resizeEvent, and the
+ // code for floatingGeometry_ can be removed;
+ // adjust GuiView::setGeometry()
+#ifdef Q_OS_WIN32
+ QRect geometry = normalGeometry();
+#else
+ updateFloatingGeometry();
+ QRect geometry = floatingGeometry_;
+#endif
+
+ // save windows size and position
+ Session & session = LyX::ref().session();
+ session.saveSessionInfo("WindowWidth", convert<string>(geometry.width()));
+ session.saveSessionInfo("WindowHeight", convert<string>(geometry.height()));
+ session.saveSessionInfo("WindowIsMaximized", (isMaximized() ? "yes" : "no"));
+ if (lyxrc.geometry_xysaved) {
+ session.saveSessionInfo("WindowPosX", convert<string>(geometry.x()));
+ session.saveSessionInfo("WindowPosY", convert<string>(geometry.y()));
+ }
+}
+
void GuiView::setGeometry(unsigned int width,
unsigned int height,
int posx, int posy,
void GuiView::closeEvent(QCloseEvent *)
{
- // FIXME:
- // change the ifdef to 'geometry = normalGeometry();' only
- // when Trolltech has fixed the broken normalGeometry on X11:
- // http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
- // Then also the moveEvent, resizeEvent, and the
- // code for floatingGeometry_ can be removed;
- // adjust GuiView::setGeometry()
-#ifdef Q_OS_WIN32
- QRect geometry = normalGeometry();
-#else
- updateFloatingGeometry();
- QRect geometry = floatingGeometry_;
-#endif
-
- // save windows size and position
- Session & session = LyX::ref().session();
- session.saveSessionInfo("WindowWidth", convert<string>(geometry.width()));
- session.saveSessionInfo("WindowHeight", convert<string>(geometry.height()));
- session.saveSessionInfo("WindowIsMaximized", (isMaximized() ? "yes" : "no"));
- if (lyxrc.geometry_xysaved) {
- session.saveSessionInfo("WindowPosX", convert<string>(geometry.x()));
- session.saveSessionInfo("WindowPosY", convert<string>(geometry.y()));
- }
- // trigger LFUN_LYX_QUIT instead of quit directly
- // since LFUN_LYX_QUIT may have more cleanup stuff
- dispatch(FuncRequest(LFUN_LYX_QUIT));
+ saveGeometry();
}
Q_OBJECT
public:
/// create a main window of the given dimensions
- GuiView();
+ GuiView(int id);
~GuiView();
- /// initialize the object
virtual void init();
-
- ///
+ virtual void close();
virtual void setGeometry(
unsigned int width,
unsigned int height,
int posx, int posy,
bool maximize);
-
- /// show - display the top-level window
- void show();
-
- /// show busy cursor
+ virtual void saveGeometry();
virtual void busy(bool) const;
-
Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
-
- /// display a status message
+ virtual void updateStatusBar();
virtual void message(lyx::docstring const & str);
-
- /// clear status message
virtual void clearMessage();
+ virtual bool hasFocus() const;
- /// update the status bar
- virtual void updateStatusBar();
+ /// show - display the top-level window
+ void show();
/// add the command buffer
void addCommandBuffer(QToolBar * toolbar);
/// menu item has been selected
void activated(FuncRequest const &);
- /// returns true if this view has the focus.
- virtual bool hasFocus() const;
+
+Q_SIGNALS:
+ void closing(int);
public Q_SLOTS:
/// idle timeout
{}
-GuiWorkArea::GuiWorkArea(int w, int h, LyXView & lyx_view)
- : WorkArea(lyx_view)
+GuiWorkArea::GuiWorkArea(int w, int h, int id, LyXView & lyx_view)
+ : WorkArea(id, lyx_view)
{
cursor_ = new frontend::CursorWidget(this);
cursor_->hide();
public:
///
- GuiWorkArea(int width, int height, LyXView & lyx_view);
+ GuiWorkArea(int width, int height, int id, LyXView & lyx_view);
/// return the width of the content pane
virtual int width() const { return viewport()->width(); }
ColorCache.h ColorCache.C \
Dialogs.C \
FileDialog.C \
- GuiApplication.C GuiApplication.h \
GuiClipboard.h GuiClipboard.C \
GuiFontLoader.h GuiFontLoader.C \
GuiFontMetrics.h GuiFontMetrics.C \
emptytable.C emptytable.h \
FileDialog_private.C FileDialog_private.h \
FloatPlacement.C FloatPlacement.h \
+ GuiApplication.C GuiApplication.h \
GuiView.C GuiView.h \
GuiWorkArea.C GuiWorkArea.h \
iconpalette.C iconpalette.h \
LFUN_INSET_DISSOLVE, // jspitzm 20060807
LFUN_CHANGE_NEXT,
LFUN_WINDOW_NEW, // Abdel 20061021
+ LFUN_WINDOW_CLOSE, // Abdel 20061023
LFUN_UNICODE_INSERT, // Lgb 20061022
LFUN_LASTACTION // end of the table
#include "frontends/Alert.h"
#include "frontends/Application.h"
+#include "frontends/Gui.h"
#include "frontends/LyXView.h"
#include "support/environment.h"
return *pimpl_->toplevel_keymap_.get();
}
-void LyX::addLyXView(LyXView * lyxview)
-{
- views_.push_back(lyxview);
-}
-
Buffer const * const LyX::updateInset(InsetBase const * inset) const
{
return 0;
Buffer const * buffer_ptr = 0;
- ViewList::const_iterator it = views_.begin();
- ViewList::const_iterator const end = views_.end();
+ vector<int> const & view_ids = pimpl_->application_->gui().viewIds();
+ vector<int>::const_iterator it = view_ids.begin();
+ vector<int>::const_iterator const end = view_ids.end();
for (; it != end; ++it) {
- Buffer const * ptr = (*it)->updateInset(inset);
+ Buffer const * ptr =
+ pimpl_->application_->gui().view(*it).updateInset(inset);
if (ptr)
buffer_ptr = ptr;
}
if (!noask && !pimpl_->buffer_list_.quitWriteAll())
return;
+ // The LyXView Geometry settings are stored when LyXView::close
+ // is called explicitely but a straight quit() command would not
+ // guarante that. So we make sure this is done here:
+ vector<int> const & view_ids = pimpl_->application_->gui().viewIds();
+ for (size_t i = 0; i < view_ids.size(); ++i)
+ pimpl_->application_->gui().view(view_ids[i]).saveGeometry();
+
pimpl_->session_->writeFile();
}
LyXView * LyX::newLyXView()
{
+ if (!lyx::use_gui)
+ return 0;
+
// determine windows size and position, from lyxrc and/or session
// initial geometry
unsigned int width = 690;
}
// create the main window
LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize);
- ref().addLyXView(view);
return view;
}
#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
-#include <list>
#include <string>
#include <vector>
/// Create a View and restore GUI Session.
void restoreGuiSession(std::vector<std::string> const & files);
- ///
- void addLyXView(LyXView * lyxview);
-
/// Initialize RC font for the GUI.
void initGuiFont();
/// Use the Pimpl idiom to hide the internals.
struct Singletons;
boost::scoped_ptr<Singletons> pimpl_;
- ///
- typedef std::list<LyXView *> ViewList;
- ViewList views_;
///
bool geometryOption_;
#include "frontends/Dialogs.h"
#include "frontends/FileDialog.h"
#include "frontends/FontLoader.h"
+#include "frontends/Gui.h"
#include "frontends/LyXKeySym.h"
#include "frontends/LyXView.h"
#include "frontends/Menubar.h"
{
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
FuncStatus flag;
+
+ if (cmd.action == LFUN_LYX_QUIT) {
+ flag.message(from_utf8(N_("Exiting")));
+ flag.enabled(true);
+ return flag;
+ }
+
LCursor & cur = view()->cursor();
/* In LyX/Mac, when a dialog is open, the menus of the
case LFUN_BUFFER_UPDATE:
case LFUN_BUFFER_VIEW:
case LFUN_BUFFER_IMPORT:
- case LFUN_LYX_QUIT:
case LFUN_TOC_VIEW:
case LFUN_BUFFER_AUTO_SAVE:
case LFUN_RECONFIGURE:
case LFUN_BUFFER_NEXT:
case LFUN_BUFFER_PREVIOUS:
case LFUN_WINDOW_NEW:
+ case LFUN_WINDOW_CLOSE:
// these are handled in our dispatch()
break;
void LyXFunc::dispatch(FuncRequest const & cmd)
{
- BOOST_ASSERT(view());
string const argument = to_utf8(cmd.argument());
kb_action const action = cmd.action;
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD: {
+ BOOST_ASSERT(lyx_view_ && lyx_view_->view());
static string last_search;
string searched_string;
}
case LFUN_COMMAND_PREFIX:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->message(from_utf8(keyseq->printOptions()));
break;
case LFUN_COMMAND_EXECUTE:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->getToolbars().display("minibuffer", true);
lyx_view_->focus_command_buffer();
break;
case LFUN_CANCEL:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->view());
keyseq->reset();
meta_fake_bit = key_modifier::none;
if (view()->buffer())
break;
case LFUN_BUFFER_TOGGLE_READ_ONLY:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->view() && lyx_view_->buffer());
if (lyx_view_->buffer()->lyxvc().inUse())
lyx_view_->buffer()->lyxvc().toggleReadOnly();
else
break;
case LFUN_BUFFER_WRITE:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
if (!lyx_view_->buffer()->isUnnamed()) {
docstring const str = bformat(_("Saving document %1$s..."),
makeDisplayPath(lyx_view_->buffer()->fileName()));
break;
case LFUN_BUFFER_WRITE_AS:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
writeAs(lyx_view_->buffer(), argument);
updateFlags = Update::None;
break;
case LFUN_BUFFER_RELOAD: {
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
docstring const file = makeDisplayPath(view()->buffer()->fileName(), 20);
docstring text = bformat(_("Any changes will be lost. Are you sure "
"you want to revert to the saved version of the document %1$s?"), file);
}
case LFUN_BUFFER_UPDATE:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
Exporter::Export(lyx_view_->buffer(), argument, true);
break;
case LFUN_BUFFER_VIEW:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
Exporter::preview(lyx_view_->buffer(), argument);
break;
case LFUN_BUILD_PROGRAM:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
Exporter::Export(lyx_view_->buffer(), "program", true);
break;
case LFUN_BUFFER_CHKTEX:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
lyx_view_->buffer()->runChktex();
break;
case LFUN_BUFFER_EXPORT:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
if (argument == "custom")
lyx_view_->getDialogs().show("sendto");
else {
break;
case LFUN_BUFFER_EXPORT_CUSTOM: {
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
string format_name;
string command = split(argument, format_name, ' ');
Format const * format = formats.getFormat(format_name);
}
case LFUN_BUFFER_PRINT: {
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
string target;
string target_name;
string command = split(split(argument, target, ' '),
break;
case LFUN_LYX_QUIT:
- if (view()->buffer()) {
+ if (lyx_view_ && lyx_view_->view()->buffer()) {
// save cursor Position for opened files to .lyx/session
LyX::ref().session().saveFilePosition(lyx_view_->buffer()->fileName(),
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
break;
case LFUN_TOC_VIEW: {
+ BOOST_ASSERT(lyx_view_);
InsetCommandParams p("tableofcontents");
string const data = InsetCommandMailer::params2string("toc", p);
lyx_view_->getDialogs().show("toc", data, 0);
break;
case LFUN_HELP_OPEN: {
+ BOOST_ASSERT(lyx_view_);
string const arg = argument;
if (arg.empty()) {
setErrorMessage(_("Missing argument"));
// --- version control -------------------------------
case LFUN_VC_REGISTER:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
if (!ensureBufferClean(view()))
break;
if (!lyx_view_->buffer()->lyxvc().inUse()) {
break;
case LFUN_VC_CHECK_IN:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
if (!ensureBufferClean(view()))
break;
if (lyx_view_->buffer()->lyxvc().inUse()
break;
case LFUN_VC_CHECK_OUT:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
if (!ensureBufferClean(view()))
break;
if (lyx_view_->buffer()->lyxvc().inUse()
break;
case LFUN_VC_REVERT:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
lyx_view_->buffer()->lyxvc().revert();
view()->reload();
break;
case LFUN_VC_UNDO_LAST:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
lyx_view_->buffer()->lyxvc().undoLast();
view()->reload();
break;
// --- buffers ----------------------------------------
case LFUN_BUFFER_SWITCH:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->setBuffer(theBufferList().getBuffer(argument));
break;
case LFUN_BUFFER_NEXT:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->setBuffer(theBufferList().next(view()->buffer()));
break;
case LFUN_BUFFER_PREVIOUS:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->setBuffer(theBufferList().previous(view()->buffer()));
break;
case LFUN_FILE_NEW:
+ BOOST_ASSERT(lyx_view_);
newFile(view(), argument);
break;
case LFUN_FILE_OPEN:
+ BOOST_ASSERT(lyx_view_);
open(argument);
break;
case LFUN_DROP_LAYOUTS_CHOICE:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->getToolbars().openLayoutList();
break;
case LFUN_MENU_OPEN:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->getMenubar().openByName(from_utf8(argument));
break;
// --- lyxserver commands ----------------------------
case LFUN_SERVER_GET_NAME:
+ BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
setMessage(from_utf8(lyx_view_->buffer()->fileName()));
lyxerr[Debug::INFO] << "FNAME["
<< lyx_view_->buffer()->fileName()
break;
case LFUN_SERVER_GOTO_FILE_ROW: {
+ BOOST_ASSERT(lyx_view_);
string file_name;
int row;
istringstream is(argument);
}
case LFUN_DIALOG_SHOW: {
+ BOOST_ASSERT(lyx_view_);
string const name = cmd.getArg(0);
string data = trim(to_utf8(cmd.argument()).substr(name.size()));
}
case LFUN_DIALOG_SHOW_NEW_INSET: {
+ BOOST_ASSERT(lyx_view_);
string const name = cmd.getArg(0);
string data = trim(to_utf8(cmd.argument()).substr(name.size()));
if (name == "bibitem" ||
}
case LFUN_DIALOG_UPDATE: {
+ BOOST_ASSERT(lyx_view_);
string const & name = argument;
// Can only update a dialog connected to an existing inset
InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
break;
case LFUN_DIALOG_DISCONNECT_INSET:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->getDialogs().disconnect(argument);
break;
case LFUN_CITATION_INSERT: {
+ BOOST_ASSERT(lyx_view_);
if (!argument.empty()) {
// we can have one optional argument, delimited by '|'
// citation-insert <key>|<text_before>
}
case LFUN_BUFFER_CHILD_OPEN: {
+ BOOST_ASSERT(lyx_view_);
string const filename =
makeAbsPath(argument, lyx_view_->buffer()->filePath());
// FIXME Should use bformat
}
case LFUN_TOGGLE_CURSOR_FOLLOWS_SCROLLBAR:
+ BOOST_ASSERT(lyx_view_);
lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
break;
case LFUN_KEYMAP_OFF:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->view()->getIntl().keyMapOn(false);
break;
case LFUN_KEYMAP_PRIMARY:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->view()->getIntl().keyMapPrim();
break;
case LFUN_KEYMAP_SECONDARY:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->view()->getIntl().keyMapSec();
break;
case LFUN_KEYMAP_TOGGLE:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->view()->getIntl().toggleKeyMap();
break;
}
case LFUN_SCREEN_FONT_UPDATE:
+ BOOST_ASSERT(lyx_view_);
// handle the screen font changes.
lyxrc.set_font_norm_type();
theFontLoader().update();
}
case LFUN_MESSAGE:
+ BOOST_ASSERT(lyx_view_);
lyx_view_->message(from_utf8(argument));
break;
case LFUN_EXTERNAL_EDIT: {
+ BOOST_ASSERT(lyx_view_);
FuncRequest fr(action, argument);
InsetExternal().dispatch(view()->cursor(), fr);
break;
}
case LFUN_INSET_APPLY: {
+ BOOST_ASSERT(lyx_view_);
string const name = cmd.getArg(0);
InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
if (inset) {
}
case LFUN_ALL_INSETS_TOGGLE: {
+ BOOST_ASSERT(lyx_view_);
string action;
string const name = split(argument, action, ' ');
InsetBase::Code const inset_code =
}
case LFUN_BUFFER_LANGUAGE: {
+ BOOST_ASSERT(lyx_view_);
Buffer & buffer = *lyx_view_->buffer();
Language const * oldL = buffer.params().language;
Language const * newL = languages.getLanguage(argument);
}
case LFUN_BUFFER_PARAMS_APPLY: {
+ BOOST_ASSERT(lyx_view_);
biblio::CiteEngine const engine =
lyx_view_->buffer()->params().cite_engine;
}
case LFUN_TEXTCLASS_APPLY: {
+ BOOST_ASSERT(lyx_view_);
Buffer * buffer = lyx_view_->buffer();
textclass_type const old_class =
}
case LFUN_WINDOW_NEW:
- BOOST_ASSERT(theApp);
LyX::ref().newLyXView();
+ break;
+
+ case LFUN_WINDOW_CLOSE:
+ BOOST_ASSERT(lyx_view_);
+ BOOST_ASSERT(theApp);
+ lyx_view_->close();
+ // We return here because lyx_view does not exists anymore.
+ return;
default: {
+ BOOST_ASSERT(lyx_view_);
view()->cursor().dispatch(cmd);
updateFlags = view()->cursor().result().update();
if (!view()->cursor().result().dispatched())
}
}
- if (view()->buffer()) {
+ if (lyx_view_ && view()->buffer()) {
// Redraw screen unless explicitly told otherwise.
// This also initializes the position cache for all insets
// in (at least partially) visible top-level paragraphs.