2002-06-12 02:54:19 +00:00
|
|
|
|
/**
|
2007-04-26 04:02:55 +00:00
|
|
|
|
* \file LyXView.cpp
|
2002-09-05 15:14:23 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-11-27 10:30:28 +00:00
|
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-12 02:54:19 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2002-06-12 02:54:19 +00:00
|
|
|
|
#include "LyXView.h"
|
2007-08-14 09:54:59 +00:00
|
|
|
|
|
2003-09-05 10:55:42 +00:00
|
|
|
|
#include "Dialogs.h"
|
2004-04-29 09:54:59 +00:00
|
|
|
|
#include "Toolbars.h"
|
2006-07-03 22:31:51 +00:00
|
|
|
|
#include "WorkArea.h"
|
2006-12-02 17:39:31 +00:00
|
|
|
|
#include "Gui.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
2007-06-19 14:56:52 +00:00
|
|
|
|
#include "buffer_funcs.h"
|
2007-06-04 14:09:51 +00:00
|
|
|
|
#include "BufferList.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "BufferParams.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "bufferview_funcs.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
#include "Cursor.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#include "debug.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "ErrorList.h"
|
|
|
|
|
#include "FuncRequest.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Intl.h"
|
2007-04-28 20:44:46 +00:00
|
|
|
|
#include "callback.h"
|
2007-06-19 14:56:52 +00:00
|
|
|
|
#include "LyX.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXFunc.h"
|
|
|
|
|
#include "LyXRC.h"
|
2007-04-29 23:33:02 +00:00
|
|
|
|
#include "Text.h"
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#include "MenuBackend.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Paragraph.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-07-14 21:47:48 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2002-06-12 02:54:19 +00:00
|
|
|
|
#include "support/filetools.h" // OnlyFilename()
|
2007-08-11 22:37:09 +00:00
|
|
|
|
#include "support/Timeout.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2005-04-26 10:30:24 +00:00
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
|
# include <sys/time.h>
|
|
|
|
|
#endif
|
2005-01-19 15:26:41 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-01-20 15:38:14 +00:00
|
|
|
|
# include <unistd.h>
|
2005-01-19 15:26:41 +00:00
|
|
|
|
#endif
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
|
using std::endl;
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2006-06-26 16:55:35 +00:00
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
using support::bformat;
|
|
|
|
|
using support::FileName;
|
|
|
|
|
using support::makeDisplayPath;
|
|
|
|
|
using support::onlyFilename;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
|
namespace frontend {
|
2003-09-05 10:55:42 +00:00
|
|
|
|
|
2007-07-11 13:39:08 +00:00
|
|
|
|
docstring current_layout;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
LyXView::LyXView(int id)
|
2007-08-21 07:33:46 +00:00
|
|
|
|
: toolbars_(new Toolbars(*this)),
|
2002-08-13 14:40:38 +00:00
|
|
|
|
autosave_timeout_(new Timeout(5000)),
|
2002-08-15 17:48:53 +00:00
|
|
|
|
dialogs_(new Dialogs(*this)),
|
2007-08-23 13:20:01 +00:00
|
|
|
|
id_(id)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-09-29 23:10:17 +00:00
|
|
|
|
// Start autosave timer
|
|
|
|
|
if (lyxrc.autosave) {
|
|
|
|
|
autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
|
|
|
|
|
autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
|
|
|
|
|
autosave_timeout_->start();
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
|
|
2006-07-08 20:24:32 +00:00
|
|
|
|
LyXView::~LyXView()
|
|
|
|
|
{
|
2006-12-22 02:57:25 +00:00
|
|
|
|
disconnectBuffer();
|
2007-08-21 07:33:46 +00:00
|
|
|
|
disconnectBufferView();
|
2006-07-08 20:24:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
Buffer * LyXView::buffer()
|
2006-06-26 16:55:35 +00:00
|
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
|
WorkArea * work_area = currentWorkArea();
|
|
|
|
|
if (work_area)
|
2007-08-21 13:03:55 +00:00
|
|
|
|
return &work_area->bufferView().buffer();
|
2007-08-21 07:33:46 +00:00
|
|
|
|
return 0;
|
2006-06-26 16:55:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
Buffer const * LyXView::buffer() const
|
2007-01-05 13:31:34 +00:00
|
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
|
WorkArea const * work_area = currentWorkArea();
|
|
|
|
|
if (work_area)
|
2007-08-21 13:03:55 +00:00
|
|
|
|
return &work_area->bufferView().buffer();
|
2007-08-21 07:33:46 +00:00
|
|
|
|
return 0;
|
2007-01-05 13:31:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
void LyXView::setBuffer(Buffer * newBuffer)
|
2006-07-13 16:37:55 +00:00
|
|
|
|
{
|
2007-08-22 08:48:01 +00:00
|
|
|
|
BOOST_ASSERT(newBuffer);
|
2006-10-26 13:29:10 +00:00
|
|
|
|
busy(true);
|
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
WorkArea * wa = workArea(*newBuffer);
|
|
|
|
|
if (wa == 0) {
|
|
|
|
|
updateLabels(*newBuffer->getMasterBuffer());
|
|
|
|
|
wa = addWorkArea(*newBuffer);
|
2007-09-11 21:27:57 +00:00
|
|
|
|
} else {
|
2007-08-03 14:07:39 +00:00
|
|
|
|
//Disconnect the old buffer...there's no new one.
|
|
|
|
|
disconnectBuffer();
|
2007-09-11 21:27:57 +00:00
|
|
|
|
}
|
2007-08-21 07:33:46 +00:00
|
|
|
|
connectBuffer(*newBuffer);
|
|
|
|
|
connectBufferView(wa->bufferView());
|
|
|
|
|
setCurrentWorkArea(wa);
|
2006-08-17 21:46:52 +00:00
|
|
|
|
|
2006-10-26 13:29:10 +00:00
|
|
|
|
busy(false);
|
2006-07-13 16:37:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
Buffer * LyXView::loadLyXFile(FileName const & filename, bool tolastfiles)
|
2006-07-13 16:37:55 +00:00
|
|
|
|
{
|
2006-10-26 13:29:10 +00:00
|
|
|
|
busy(true);
|
2007-06-19 14:56:52 +00:00
|
|
|
|
|
2007-06-19 16:03:47 +00:00
|
|
|
|
Buffer * newBuffer = checkAndLoadLyXFile(filename);
|
2007-06-19 14:56:52 +00:00
|
|
|
|
|
2007-06-19 16:03:47 +00:00
|
|
|
|
if (!newBuffer) {
|
2007-06-19 14:56:52 +00:00
|
|
|
|
message(_("Document not loaded."));
|
2007-06-19 16:03:47 +00:00
|
|
|
|
updateStatusBar();
|
|
|
|
|
busy(false);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
return 0;
|
2007-06-19 16:03:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-24 07:19:40 +00:00
|
|
|
|
WorkArea * wa = workArea(*newBuffer);
|
|
|
|
|
if (wa == 0)
|
|
|
|
|
wa = addWorkArea(*newBuffer);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
|
|
|
|
|
// scroll to the position when the file was last closed
|
|
|
|
|
if (lyxrc.use_lastfilepos) {
|
|
|
|
|
pit_type pit;
|
|
|
|
|
pos_type pos;
|
|
|
|
|
boost::tie(pit, pos) = LyX::ref().session().lastFilePos().load(filename);
|
|
|
|
|
// if successfully move to pit (returned par_id is not zero),
|
|
|
|
|
// update metrics and reset font
|
2007-08-22 14:25:51 +00:00
|
|
|
|
wa->bufferView().moveToPosition(pit, pos, 0, 0);
|
2007-06-19 16:03:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 09:04:31 +00:00
|
|
|
|
if (tolastfiles)
|
|
|
|
|
LyX::ref().session().lastFiles().add(filename);
|
|
|
|
|
|
2006-10-26 13:29:10 +00:00
|
|
|
|
busy(false);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
return newBuffer;
|
2006-07-13 16:37:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-07-14 21:47:48 +00:00
|
|
|
|
|
|
|
|
|
void LyXView::connectBuffer(Buffer & buf)
|
|
|
|
|
{
|
2006-07-15 22:43:37 +00:00
|
|
|
|
if (errorsConnection_.connected())
|
2006-07-14 21:47:48 +00:00
|
|
|
|
disconnectBuffer();
|
|
|
|
|
|
2007-03-12 11:23:41 +00:00
|
|
|
|
bufferStructureChangedConnection_ =
|
2007-05-17 19:19:37 +00:00
|
|
|
|
buf.getMasterBuffer()->structureChanged.connect(
|
2007-03-12 11:23:41 +00:00
|
|
|
|
boost::bind(&LyXView::updateToc, this));
|
|
|
|
|
|
2007-09-04 14:34:42 +00:00
|
|
|
|
bufferEmbeddingChangedConnection_ =
|
|
|
|
|
buf.embeddingChanged.connect(
|
|
|
|
|
boost::bind(&LyXView::updateEmbeddedFiles, this));
|
|
|
|
|
|
2006-07-15 22:43:37 +00:00
|
|
|
|
errorsConnection_ =
|
|
|
|
|
buf.errors.connect(
|
|
|
|
|
boost::bind(&LyXView::showErrorList, this, _1));
|
2006-07-14 21:47:48 +00:00
|
|
|
|
|
|
|
|
|
messageConnection_ =
|
|
|
|
|
buf.message.connect(
|
|
|
|
|
boost::bind(&LyXView::message, this, _1));
|
|
|
|
|
|
|
|
|
|
busyConnection_ =
|
|
|
|
|
buf.busy.connect(
|
|
|
|
|
boost::bind(&LyXView::busy, this, _1));
|
|
|
|
|
|
|
|
|
|
titleConnection_ =
|
|
|
|
|
buf.updateTitles.connect(
|
|
|
|
|
boost::bind(&LyXView::updateWindowTitle, this));
|
|
|
|
|
|
|
|
|
|
timerConnection_ =
|
|
|
|
|
buf.resetAutosaveTimers.connect(
|
|
|
|
|
boost::bind(&LyXView::resetAutosaveTimer, this));
|
|
|
|
|
|
|
|
|
|
readonlyConnection_ =
|
|
|
|
|
buf.readonly.connect(
|
|
|
|
|
boost::bind(&LyXView::showReadonly, this, _1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::disconnectBuffer()
|
|
|
|
|
{
|
2006-10-22 10:51:59 +00:00
|
|
|
|
errorsConnection_.disconnect();
|
2007-03-12 11:23:41 +00:00
|
|
|
|
bufferStructureChangedConnection_.disconnect();
|
2007-09-04 14:34:42 +00:00
|
|
|
|
bufferEmbeddingChangedConnection_.disconnect();
|
2006-07-14 21:47:48 +00:00
|
|
|
|
messageConnection_.disconnect();
|
|
|
|
|
busyConnection_.disconnect();
|
|
|
|
|
titleConnection_.disconnect();
|
|
|
|
|
timerConnection_.disconnect();
|
|
|
|
|
readonlyConnection_.disconnect();
|
2006-09-26 10:06:46 +00:00
|
|
|
|
layout_changed_connection_.disconnect();
|
2006-07-14 21:47:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
|
void LyXView::connectBufferView(BufferView & bv)
|
|
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
|
message_connection_ = bv.message.connect(
|
|
|
|
|
boost::bind(&LyXView::message, this, _1));
|
2006-09-19 13:36:20 +00:00
|
|
|
|
show_dialog_connection_ = bv.showDialog.connect(
|
|
|
|
|
boost::bind(&LyXView::showDialog, this, _1));
|
|
|
|
|
show_dialog_with_data_connection_ = bv.showDialogWithData.connect(
|
|
|
|
|
boost::bind(&LyXView::showDialogWithData, this, _1, _2));
|
|
|
|
|
show_inset_dialog_connection_ = bv.showInsetDialog.connect(
|
|
|
|
|
boost::bind(&LyXView::showInsetDialog, this, _1, _2, _3));
|
|
|
|
|
update_dialog_connection_ = bv.updateDialog.connect(
|
|
|
|
|
boost::bind(&LyXView::updateDialog, this, _1, _2));
|
2006-09-26 10:06:46 +00:00
|
|
|
|
layout_changed_connection_ = bv.layoutChanged.connect(
|
|
|
|
|
boost::bind(&Toolbars::setLayout, toolbars_.get(), _1));
|
2006-09-19 13:36:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::disconnectBufferView()
|
|
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
|
message_connection_.disconnect();
|
2006-09-19 13:36:20 +00:00
|
|
|
|
show_dialog_connection_.disconnect();
|
|
|
|
|
show_dialog_with_data_connection_.disconnect();
|
|
|
|
|
show_inset_dialog_connection_.disconnect();
|
|
|
|
|
update_dialog_connection_.disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-08-13 16:16:43 +00:00
|
|
|
|
void LyXView::showErrorList(string const & error_type)
|
2006-07-14 21:47:48 +00:00
|
|
|
|
{
|
2006-08-13 16:16:43 +00:00
|
|
|
|
ErrorList & el = buffer()->errorList(error_type);
|
|
|
|
|
if (!el.empty()) {
|
|
|
|
|
getDialogs().show("errorlist", error_type);
|
2006-07-14 21:47:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
|
void LyXView::showDialog(string const & name)
|
|
|
|
|
{
|
|
|
|
|
getDialogs().show(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-18 08:44:44 +00:00
|
|
|
|
void LyXView::showDialogWithData(string const & name, string const & data)
|
2006-09-19 13:36:20 +00:00
|
|
|
|
{
|
|
|
|
|
getDialogs().show(name, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::showInsetDialog(string const & name, string const & data,
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Inset * inset)
|
2006-09-19 13:36:20 +00:00
|
|
|
|
{
|
2006-10-02 15:40:39 +00:00
|
|
|
|
getDialogs().show(name, data, inset);
|
2006-09-19 13:36:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::updateDialog(string const & name, string const & data)
|
|
|
|
|
{
|
|
|
|
|
if (getDialogs().visible(name))
|
|
|
|
|
getDialogs().update(name, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-07-14 21:47:48 +00:00
|
|
|
|
void LyXView::showReadonly(bool)
|
|
|
|
|
{
|
|
|
|
|
updateWindowTitle();
|
|
|
|
|
getDialogs().updateBufferDependent(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
BufferView * LyXView::view()
|
2000-04-08 17:02:02 +00:00
|
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
|
WorkArea * wa = currentWorkArea();
|
|
|
|
|
return wa? &wa->bufferView() : 0;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-03-12 11:23:41 +00:00
|
|
|
|
void LyXView::updateToc()
|
|
|
|
|
{
|
|
|
|
|
updateDialog("toc", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-04 14:34:42 +00:00
|
|
|
|
void LyXView::updateEmbeddedFiles()
|
|
|
|
|
{
|
|
|
|
|
updateDialog("embedding", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-04-29 09:54:59 +00:00
|
|
|
|
void LyXView::updateToolbars()
|
2000-07-25 10:46:18 +00:00
|
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
|
WorkArea * wa = currentWorkArea();
|
|
|
|
|
if (wa) {
|
|
|
|
|
bool const math =
|
|
|
|
|
wa->bufferView().cursor().inMathed();
|
|
|
|
|
bool const table =
|
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
|
|
|
|
|
bool const review =
|
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
|
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
|
|
|
|
|
|
|
|
|
|
toolbars_->update(math, table, review);
|
|
|
|
|
} else
|
|
|
|
|
toolbars_->update(false, false, false);
|
|
|
|
|
|
2007-08-23 12:44:21 +00:00
|
|
|
|
// update redaonly status of open dialogs.
|
2005-04-13 09:43:58 +00:00
|
|
|
|
getDialogs().checkStatus();
|
2000-07-25 10:46:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-07-09 20:33:32 +00:00
|
|
|
|
ToolbarInfo * LyXView::getToolbarInfo(string const & name)
|
2006-11-02 18:59:33 +00:00
|
|
|
|
{
|
2007-07-09 20:33:32 +00:00
|
|
|
|
return toolbars_->getToolbarInfo(name);
|
2006-11-02 18:59:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-06 13:52:31 +00:00
|
|
|
|
void LyXView::toggleToolbarState(string const & name, bool allowauto)
|
2006-11-02 16:01:36 +00:00
|
|
|
|
{
|
|
|
|
|
// it is possible to get current toolbar status like this,...
|
|
|
|
|
// but I decide to obey the order of ToolbarBackend::flags
|
|
|
|
|
// and disregard real toolbar status.
|
|
|
|
|
// toolbars_->saveToolbarInfo();
|
|
|
|
|
//
|
|
|
|
|
// toggle state on/off/auto
|
2007-06-06 13:52:31 +00:00
|
|
|
|
toolbars_->toggleToolbarState(name, allowauto);
|
2006-11-02 16:01:36 +00:00
|
|
|
|
// update toolbar
|
|
|
|
|
updateToolbars();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
void LyXView::autoSave()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::INFO) << "Running autoSave()" << endl;
|
2002-06-12 11:34:13 +00:00
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
if (buffer())
|
2006-10-21 00:16:43 +00:00
|
|
|
|
lyx::autoSave(view());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void LyXView::resetAutosaveTimer()
|
|
|
|
|
{
|
2000-03-12 10:35:05 +00:00
|
|
|
|
if (lyxrc.autosave)
|
2002-06-12 02:54:19 +00:00
|
|
|
|
autosave_timeout_->restart();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::updateLayoutChoice()
|
|
|
|
|
{
|
2005-02-08 13:18:05 +00:00
|
|
|
|
// Don't show any layouts without a buffer
|
2007-08-21 07:33:46 +00:00
|
|
|
|
if (!buffer()) {
|
2004-04-29 09:54:59 +00:00
|
|
|
|
toolbars_->clearLayoutList();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-08 13:18:05 +00:00
|
|
|
|
// Update the layout display
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This first patch does some reworking of the infrastructrue. We need to distinguish between the TextClass that a particular document is using and the layout of that document, since modules, in particular, can modify the layout. The solution adopted here is to add a TextClass pointer to BufferParams, which will hold the layout. The layout itself is then constructed from the TextClass the document is using. At present, this is completely trivial, but that will change when modules are added.
The pointer in question is a boost::shared_ptr. This is needed because CutAndPaste saves a copy of the layout with each cut or copied selection. We cannot assume the selection vanishes when the document is closed, so there are two options: (i) keep a list of all the layouts that have ever been used by any document; (ii) used some kind of smart pointer. The latter seems preferable, as the former would waste memory. More importantly, the use of a smart pointer allows modules to be modified on disk and then reloaded while LyX is running, and it will eventually allow the same for layout files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19756 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-23 16:41:13 +00:00
|
|
|
|
if (toolbars_->updateLayoutList(buffer()->params().getTextClass_ptr())) {
|
2007-04-29 19:53:54 +00:00
|
|
|
|
current_layout = buffer()->params().getTextClass().defaultLayoutName();
|
2001-08-03 18:28:11 +00:00
|
|
|
|
}
|
2002-03-02 16:39:54 +00:00
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
docstring const & layout = currentWorkArea()->bufferView().cursor().
|
2007-06-11 16:38:45 +00:00
|
|
|
|
innerParagraph().layout()->name();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-12-05 23:16:13 +00:00
|
|
|
|
if (layout != current_layout) {
|
2004-04-29 09:54:59 +00:00
|
|
|
|
toolbars_->setLayout(layout);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
current_layout = layout;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
|
void LyXView::updateWindowTitle()
|
|
|
|
|
{
|
2007-09-11 21:27:57 +00:00
|
|
|
|
docstring maximize_title = from_ascii("LyX");
|
|
|
|
|
docstring minimize_title = from_ascii("LyX");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
Buffer * buf = buffer();
|
|
|
|
|
if (buf) {
|
|
|
|
|
string const cur_title = buf->fileName();
|
2002-02-16 15:59:55 +00:00
|
|
|
|
if (!cur_title.empty()) {
|
2006-10-11 19:40:50 +00:00
|
|
|
|
maximize_title += ": " + makeDisplayPath(cur_title, 30);
|
2006-09-11 08:54:10 +00:00
|
|
|
|
minimize_title = lyx::from_utf8(onlyFilename(cur_title));
|
2007-08-21 07:33:46 +00:00
|
|
|
|
if (!buf->isClean()) {
|
2006-09-11 08:54:10 +00:00
|
|
|
|
maximize_title += _(" (changed)");
|
2007-09-11 21:27:57 +00:00
|
|
|
|
minimize_title += char_type('*');
|
2002-09-11 18:05:42 +00:00
|
|
|
|
}
|
2007-08-21 07:33:46 +00:00
|
|
|
|
if (buf->isReadonly())
|
2006-09-11 08:54:10 +00:00
|
|
|
|
maximize_title += _(" (read only)");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-06-12 02:54:19 +00:00
|
|
|
|
|
2006-11-05 15:34:18 +00:00
|
|
|
|
setWindowTitle(maximize_title, minimize_title);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-08-13 17:43:40 +00:00
|
|
|
|
|
|
|
|
|
|
2004-01-15 17:34:44 +00:00
|
|
|
|
void LyXView::dispatch(FuncRequest const & cmd)
|
2002-08-13 17:43:40 +00:00
|
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
|
string const argument = to_utf8(cmd.argument());
|
|
|
|
|
switch(cmd.action) {
|
|
|
|
|
case LFUN_BUFFER_SWITCH:
|
|
|
|
|
setBuffer(theBufferList().getBuffer(to_utf8(cmd.argument())));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
theLyXFunc().setLyXView(this);
|
|
|
|
|
lyx::dispatch(cmd);
|
|
|
|
|
}
|
2002-08-13 17:43:40 +00:00
|
|
|
|
}
|
2003-10-14 21:30:23 +00:00
|
|
|
|
|
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
Buffer const * const LyXView::updateInset(Inset const * inset)
|
2003-10-14 21:30:23 +00:00
|
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
|
WorkArea * work_area = currentWorkArea();
|
|
|
|
|
if (!work_area)
|
|
|
|
|
return 0;
|
2007-01-16 15:16:09 +00:00
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
if (inset) {
|
|
|
|
|
BOOST_ASSERT(work_area);
|
|
|
|
|
work_area->scheduleRedraw();
|
2003-10-14 21:30:23 +00:00
|
|
|
|
}
|
2007-08-21 13:03:55 +00:00
|
|
|
|
return &work_area->bufferView().buffer();
|
2003-10-14 21:30:23 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-08-23 12:21:47 +00:00
|
|
|
|
|
|
|
|
|
void LyXView::openLayoutList()
|
|
|
|
|
{
|
|
|
|
|
toolbars_->openLayoutList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LyXView::isToolbarVisible(std::string const & id)
|
|
|
|
|
{
|
|
|
|
|
return toolbars_->visible(id);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
|
} // namespace frontend
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|