2002-06-12 02:54:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file BufferView_pimpl.C
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-12 02:54:19 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Asger Alstrup
|
|
|
|
|
* \author Alfredo Braustein
|
2003-06-30 23:56:22 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author Dekel Tsur
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-12 02:54:19 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "BufferView_pimpl.h"
|
2003-05-23 13:54:09 +00:00
|
|
|
|
#include "buffer.h"
|
2003-06-20 12:46:28 +00:00
|
|
|
|
#include "buffer_funcs.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "bufferlist.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2003-09-17 16:44:51 +00:00
|
|
|
|
#include "cursor.h"
|
2001-07-29 15:34:18 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-02-26 19:28:38 +00:00
|
|
|
|
#include "factory.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "FloatList.h"
|
2002-08-07 08:11:41 +00:00
|
|
|
|
#include "funcrequest.h"
|
2003-02-26 19:28:38 +00:00
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "intl.h"
|
2003-02-08 19:18:01 +00:00
|
|
|
|
#include "iterators.h"
|
2003-02-26 19:28:38 +00:00
|
|
|
|
#include "lyx_cb.h" // added for Dispatch functions
|
|
|
|
|
#include "lyx_main.h"
|
2003-02-08 19:18:01 +00:00
|
|
|
|
#include "lyxfind.h"
|
2003-02-26 19:28:38 +00:00
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
|
#include "lyxtext.h"
|
|
|
|
|
#include "lyxrc.h"
|
2003-06-20 12:46:28 +00:00
|
|
|
|
#include "lastfiles.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2003-08-27 13:51:18 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2003-02-26 19:28:38 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2003-10-14 13:01:49 +00:00
|
|
|
|
#include "undo.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "vspace.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2003-02-21 09:20:18 +00:00
|
|
|
|
#include "insets/insetfloatlist.h"
|
|
|
|
|
#include "insets/insetref.h"
|
2003-02-26 19:28:38 +00:00
|
|
|
|
|
|
|
|
|
#include "frontends/Alert.h"
|
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
|
#include "frontends/FileDialog.h"
|
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
#include "frontends/LyXScreenFactory.h"
|
|
|
|
|
#include "frontends/screen.h"
|
|
|
|
|
#include "frontends/WorkArea.h"
|
|
|
|
|
#include "frontends/WorkAreaFactory.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2002-07-05 21:24:15 +00:00
|
|
|
|
#include "graphics/Previews.h"
|
|
|
|
|
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "mathed/formulabase.h"
|
|
|
|
|
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "support/filetools.h"
|
2003-07-27 21:04:02 +00:00
|
|
|
|
#include "support/path_defines.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "support/tostr.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using bv_funcs::currentState;
|
|
|
|
|
|
|
|
|
|
using lyx::pos_type;
|
|
|
|
|
|
|
|
|
|
using lyx::support::AddPath;
|
|
|
|
|
using lyx::support::bformat;
|
|
|
|
|
using lyx::support::FileSearch;
|
|
|
|
|
using lyx::support::IsDirWriteable;
|
|
|
|
|
using lyx::support::MakeDisplayPath;
|
|
|
|
|
using lyx::support::strToUnsignedInt;
|
|
|
|
|
using lyx::support::system_lyxdir;
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2000-04-09 22:48:51 +00:00
|
|
|
|
using std::endl;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
using std::make_pair;
|
2001-01-28 18:31:36 +00:00
|
|
|
|
using std::min;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2001-11-29 17:12:21 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
|
|
|
|
extern BufferList bufferlist;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
2001-07-06 12:09:32 +00:00
|
|
|
|
|
2001-03-17 02:06:21 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2002-07-22 20:57:58 +00:00
|
|
|
|
unsigned int const saved_positions_num = 20;
|
|
|
|
|
|
|
|
|
|
// All the below connection objects are needed because of a bug in some
|
|
|
|
|
// versions of GCC (<=2.96 are on the suspects list.) By having and assigning
|
|
|
|
|
// to these connections we avoid a segfault upon startup, and also at exit.
|
|
|
|
|
// (Lgb)
|
|
|
|
|
|
2002-08-28 08:30:27 +00:00
|
|
|
|
boost::signals::connection dispatchcon;
|
2002-07-22 20:57:58 +00:00
|
|
|
|
boost::signals::connection timecon;
|
|
|
|
|
boost::signals::connection doccon;
|
|
|
|
|
boost::signals::connection resizecon;
|
|
|
|
|
boost::signals::connection kpresscon;
|
|
|
|
|
boost::signals::connection selectioncon;
|
|
|
|
|
boost::signals::connection lostcon;
|
2000-04-14 19:20:33 +00:00
|
|
|
|
|
2002-08-27 16:16:17 +00:00
|
|
|
|
|
2001-03-17 02:06:21 +00:00
|
|
|
|
} // anon namespace
|
|
|
|
|
|
2000-04-14 19:20:33 +00:00
|
|
|
|
|
2002-08-19 15:39:25 +00:00
|
|
|
|
BufferView::Pimpl::Pimpl(BufferView * bv, LyXView * owner,
|
2000-04-08 17:02:02 +00:00
|
|
|
|
int xpos, int ypos, int width, int height)
|
2002-08-19 15:39:25 +00:00
|
|
|
|
: bv_(bv), owner_(owner), buffer_(0), cursor_timeout(400),
|
2003-11-04 12:36:59 +00:00
|
|
|
|
using_xterm_cursor(false), cursor_(bv)
|
2000-04-08 17:02:02 +00:00
|
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
|
workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
|
|
|
|
|
screen_.reset(LyXScreenFactory::create(workarea()));
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
|
// Setup the signals
|
2002-08-19 15:39:25 +00:00
|
|
|
|
doccon = workarea().scrollDocView
|
|
|
|
|
.connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
|
2002-07-22 20:57:58 +00:00
|
|
|
|
resizecon = workarea().workAreaResize
|
2002-06-20 20:37:42 +00:00
|
|
|
|
.connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
|
2002-08-28 08:30:27 +00:00
|
|
|
|
dispatchcon = workarea().dispatch
|
2003-03-24 02:31:44 +00:00
|
|
|
|
.connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
|
2002-07-22 20:57:58 +00:00
|
|
|
|
kpresscon = workarea().workAreaKeyPress
|
2002-05-29 16:21:03 +00:00
|
|
|
|
.connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
|
2002-07-22 20:57:58 +00:00
|
|
|
|
selectioncon = workarea().selectionRequested
|
2002-05-29 16:21:03 +00:00
|
|
|
|
.connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
|
2002-07-22 20:57:58 +00:00
|
|
|
|
lostcon = workarea().selectionLost
|
2002-05-29 16:21:03 +00:00
|
|
|
|
.connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-08-19 15:39:25 +00:00
|
|
|
|
timecon = cursor_timeout.timeout
|
|
|
|
|
.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
|
2000-06-08 23:16:16 +00:00
|
|
|
|
cursor_timeout.start();
|
2001-01-28 18:31:36 +00:00
|
|
|
|
saved_positions.resize(saved_positions_num);
|
2000-04-08 17:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-09 22:48:51 +00:00
|
|
|
|
|
2003-06-20 23:03:43 +00:00
|
|
|
|
void BufferView::Pimpl::addError(ErrorItem const & ei)
|
|
|
|
|
{
|
|
|
|
|
errorlist_.push_back(ei);
|
2003-07-07 08:37:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 23:03:43 +00:00
|
|
|
|
|
2003-07-10 12:26:40 +00:00
|
|
|
|
void BufferView::Pimpl::showReadonly(bool)
|
|
|
|
|
{
|
|
|
|
|
owner_->updateWindowTitle();
|
|
|
|
|
owner_->getDialogs().updateBufferDependent(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-07 08:37:02 +00:00
|
|
|
|
void BufferView::Pimpl::connectBuffer(Buffer & buf)
|
|
|
|
|
{
|
|
|
|
|
if (errorConnection_.connected())
|
|
|
|
|
disconnectBuffer();
|
|
|
|
|
|
|
|
|
|
errorConnection_ = buf.error.connect(boost::bind(&BufferView::Pimpl::addError, this, _1));
|
|
|
|
|
messageConnection_ = buf.message.connect(boost::bind(&LyXView::message, owner_, _1));
|
|
|
|
|
busyConnection_ = buf.busy.connect(boost::bind(&LyXView::busy, owner_, _1));
|
2003-07-10 12:26:40 +00:00
|
|
|
|
titleConnection_ = buf.updateTitles.connect(boost::bind(&LyXView::updateWindowTitle, owner_));
|
|
|
|
|
timerConnection_ = buf.resetAutosaveTimers.connect(boost::bind(&LyXView::resetAutosaveTimer, owner_));
|
|
|
|
|
readonlyConnection_ = buf.readonly.connect(boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
|
2003-07-11 12:21:31 +00:00
|
|
|
|
closingConnection_ = buf.closing.connect(boost::bind(&BufferView::Pimpl::buffer, this, (Buffer *)0));
|
2003-07-07 08:37:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::Pimpl::disconnectBuffer()
|
|
|
|
|
{
|
|
|
|
|
errorConnection_.disconnect();
|
|
|
|
|
messageConnection_.disconnect();
|
|
|
|
|
busyConnection_.disconnect();
|
2003-07-10 12:26:40 +00:00
|
|
|
|
titleConnection_.disconnect();
|
|
|
|
|
timerConnection_.disconnect();
|
|
|
|
|
readonlyConnection_.disconnect();
|
2003-07-11 12:21:31 +00:00
|
|
|
|
closingConnection_.disconnect();
|
2003-07-07 08:37:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
bool BufferView::Pimpl::newFile(string const & filename,
|
2003-07-07 08:37:02 +00:00
|
|
|
|
string const & tname,
|
|
|
|
|
bool isNamed)
|
|
|
|
|
{
|
|
|
|
|
Buffer * b = ::newFile(filename, tname, isNamed);
|
|
|
|
|
buffer(b);
|
|
|
|
|
return true;
|
2003-06-20 23:03:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 12:46:28 +00:00
|
|
|
|
|
|
|
|
|
bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
|
|
|
|
{
|
|
|
|
|
// get absolute path of file and add ".lyx" to the filename if
|
|
|
|
|
// necessary
|
|
|
|
|
string s = FileSearch(string(), filename, "lyx");
|
2003-08-01 21:18:49 +00:00
|
|
|
|
|
2003-07-29 16:40:26 +00:00
|
|
|
|
bool const found = !s.empty();
|
|
|
|
|
|
2003-08-01 21:18:49 +00:00
|
|
|
|
if (!found)
|
2003-06-20 12:46:28 +00:00
|
|
|
|
s = filename;
|
|
|
|
|
|
|
|
|
|
// file already open?
|
|
|
|
|
if (bufferlist.exists(s)) {
|
|
|
|
|
string const file = MakeDisplayPath(s, 20);
|
|
|
|
|
string text = bformat(_("The document %1$s is already "
|
|
|
|
|
"loaded.\n\nDo you want to revert "
|
|
|
|
|
"to the saved version?"), file);
|
|
|
|
|
int const ret = Alert::prompt(_("Revert to saved document?"),
|
|
|
|
|
text, 0, 1, _("&Revert"), _("&Switch to document"));
|
|
|
|
|
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
buffer(bufferlist.getBuffer(s));
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
// FIXME: should be LFUN_REVERT
|
|
|
|
|
if (!bufferlist.close(bufferlist.getBuffer(s), false))
|
|
|
|
|
return false;
|
|
|
|
|
// Fall through to new load. (Asger)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-29 16:40:26 +00:00
|
|
|
|
Buffer * b;
|
2003-06-20 23:03:43 +00:00
|
|
|
|
|
2003-07-29 16:40:26 +00:00
|
|
|
|
if (found) {
|
|
|
|
|
b = bufferlist.newBuffer(s);
|
|
|
|
|
connectBuffer(*b);
|
|
|
|
|
if (!::loadLyXFile(b, s)) {
|
|
|
|
|
bufferlist.release(b);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2003-07-07 08:37:02 +00:00
|
|
|
|
string text = bformat(_("The document %1$s does not yet "
|
|
|
|
|
"exist.\n\nDo you want to create "
|
2003-06-20 12:46:28 +00:00
|
|
|
|
"a new document?"), s);
|
|
|
|
|
int const ret = Alert::prompt(_("Create new document?"),
|
|
|
|
|
text, 0, 1, _("&Create"), _("Cancel"));
|
|
|
|
|
|
2003-07-29 16:40:26 +00:00
|
|
|
|
if (ret == 0)
|
|
|
|
|
b = ::newFile(s, string(), true);
|
|
|
|
|
else
|
2003-06-27 07:11:31 +00:00
|
|
|
|
return false;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
}
|
2003-06-20 12:46:28 +00:00
|
|
|
|
|
|
|
|
|
buffer(b);
|
2003-07-29 16:40:26 +00:00
|
|
|
|
bv_->showErrorList(_("Parse"));
|
2003-06-20 12:46:28 +00:00
|
|
|
|
|
|
|
|
|
if (tolastfiles)
|
2003-10-14 21:30:23 +00:00
|
|
|
|
LyX::ref().lastfiles().newFile(b->fileName());
|
2003-06-20 12:46:28 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-07 08:37:02 +00:00
|
|
|
|
|
2002-06-11 22:38:49 +00:00
|
|
|
|
WorkArea & BufferView::Pimpl::workarea() const
|
|
|
|
|
{
|
|
|
|
|
return *workarea_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
LyXScreen & BufferView::Pimpl::screen() const
|
2002-06-11 23:47:58 +00:00
|
|
|
|
{
|
|
|
|
|
return *screen_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-12 02:54:19 +00:00
|
|
|
|
Painter & BufferView::Pimpl::painter() const
|
2000-04-09 22:48:51 +00:00
|
|
|
|
{
|
2002-06-11 22:38:49 +00:00
|
|
|
|
return workarea().getPainter();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-27 14:55:20 +00:00
|
|
|
|
void BufferView::Pimpl::top_y(int y)
|
|
|
|
|
{
|
|
|
|
|
top_y_ = y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int BufferView::Pimpl::top_y() const
|
|
|
|
|
{
|
|
|
|
|
return top_y_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-09 22:48:51 +00:00
|
|
|
|
void BufferView::Pimpl::buffer(Buffer * b)
|
|
|
|
|
{
|
|
|
|
|
lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
|
2002-11-27 10:30:28 +00:00
|
|
|
|
<< b << ')' << endl;
|
2000-04-09 22:48:51 +00:00
|
|
|
|
if (buffer_) {
|
2003-07-07 08:37:02 +00:00
|
|
|
|
disconnectBuffer();
|
2003-10-17 09:32:41 +00:00
|
|
|
|
delete bv_->text;
|
2000-04-09 22:48:51 +00:00
|
|
|
|
bv_->text = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-19 15:39:25 +00:00
|
|
|
|
// set current buffer
|
2000-04-09 22:48:51 +00:00
|
|
|
|
buffer_ = b;
|
|
|
|
|
|
2003-08-27 14:55:20 +00:00
|
|
|
|
top_y_ = 0;
|
2003-08-28 07:41:31 +00:00
|
|
|
|
|
2003-03-02 12:16:00 +00:00
|
|
|
|
// if we're quitting lyx, don't bother updating stuff
|
2003-02-15 19:21:11 +00:00
|
|
|
|
if (quitting)
|
2003-03-02 12:16:00 +00:00
|
|
|
|
return;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-08-19 15:39:25 +00:00
|
|
|
|
// if we are closing the buffer, use the first buffer as current
|
2003-07-29 16:40:26 +00:00
|
|
|
|
if (!buffer_)
|
2000-04-09 22:48:51 +00:00
|
|
|
|
buffer_ = bufferlist.first();
|
|
|
|
|
|
|
|
|
|
if (buffer_) {
|
|
|
|
|
lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
|
2003-07-07 08:37:02 +00:00
|
|
|
|
connectBuffer(*buffer_);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2000-04-09 22:48:51 +00:00
|
|
|
|
// If we don't have a text object for this, we make one
|
2003-07-29 16:40:26 +00:00
|
|
|
|
if (bv_->text == 0)
|
2000-04-09 22:48:51 +00:00
|
|
|
|
resizeCurrentBuffer();
|
2002-06-21 02:22:13 +00:00
|
|
|
|
|
|
|
|
|
// FIXME: needed when ?
|
2003-11-13 08:50:26 +00:00
|
|
|
|
fitCursor();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2003-04-02 09:10:08 +00:00
|
|
|
|
// Buffer-dependent dialogs should be updated or
|
2000-10-10 11:50:43 +00:00
|
|
|
|
// hidden. This should go here because some dialogs (eg ToC)
|
|
|
|
|
// require bv_->text.
|
2002-08-13 14:40:38 +00:00
|
|
|
|
owner_->getDialogs().updateBufferDependent(true);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
} else {
|
|
|
|
|
lyxerr[Debug::INFO] << " No Buffer!" << endl;
|
2002-08-13 14:40:38 +00:00
|
|
|
|
owner_->getDialogs().hideBufferDependent();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2003-08-01 15:27:57 +00:00
|
|
|
|
update();
|
2002-06-21 02:22:13 +00:00
|
|
|
|
updateScrollbar();
|
|
|
|
|
owner_->updateMenubar();
|
|
|
|
|
owner_->updateToolbar();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
owner_->updateLayoutChoice();
|
|
|
|
|
owner_->updateWindowTitle();
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
// Don't forget to update the Layout
|
|
|
|
|
if (buffer_)
|
|
|
|
|
owner_->setLayout(bv_->text->cursorPar()->layout()->name());
|
2003-04-02 09:10:08 +00:00
|
|
|
|
|
2003-07-21 21:30:57 +00:00
|
|
|
|
if (lyx::graphics::Previews::activated() && buffer_)
|
|
|
|
|
lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-20 21:37:05 +00:00
|
|
|
|
|
2001-08-02 14:55:06 +00:00
|
|
|
|
bool BufferView::Pimpl::fitCursor()
|
2000-04-09 22:48:51 +00:00
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
lyxerr << "BufferView::Pimpl::fitCursor." << endl;
|
2003-11-13 08:50:26 +00:00
|
|
|
|
if (screen().fitCursor(bv_)) {
|
2003-11-11 09:06:41 +00:00
|
|
|
|
updateScrollbar();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::Pimpl::redoCurrentBuffer()
|
|
|
|
|
{
|
|
|
|
|
lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl;
|
|
|
|
|
if (buffer_ && bv_->text) {
|
2002-06-20 20:37:42 +00:00
|
|
|
|
resizeCurrentBuffer();
|
2002-08-07 14:15:06 +00:00
|
|
|
|
updateScrollbar();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
owner_->updateLayoutChoice();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-11 09:09:01 +00:00
|
|
|
|
void BufferView::Pimpl::resizeCurrentBuffer()
|
2000-04-09 22:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-10-09 10:52:12 +00:00
|
|
|
|
int par = -1;
|
|
|
|
|
int selstartpar = -1;
|
|
|
|
|
int selendpar = -1;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
pos_type pos = 0;
|
|
|
|
|
pos_type selstartpos = 0;
|
|
|
|
|
pos_type selendpos = 0;
|
2001-03-08 12:58:40 +00:00
|
|
|
|
bool selection = false;
|
|
|
|
|
bool mark_set = false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-14 14:49:51 +00:00
|
|
|
|
owner_->busy(true);
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2001-04-24 17:33:01 +00:00
|
|
|
|
owner_->message(_("Formatting document..."));
|
2000-04-09 22:48:51 +00:00
|
|
|
|
|
|
|
|
|
if (bv_->text) {
|
2003-05-27 17:29:03 +00:00
|
|
|
|
par = bv_->text->cursor.par();
|
2000-06-08 23:16:16 +00:00
|
|
|
|
pos = bv_->text->cursor.pos();
|
2003-05-27 17:29:03 +00:00
|
|
|
|
selstartpar = bv_->text->selection.start.par();
|
2001-05-31 02:23:46 +00:00
|
|
|
|
selstartpos = bv_->text->selection.start.pos();
|
2003-05-27 17:29:03 +00:00
|
|
|
|
selendpar = bv_->text->selection.end.par();
|
2001-05-31 02:23:46 +00:00
|
|
|
|
selendpos = bv_->text->selection.end.pos();
|
|
|
|
|
selection = bv_->text->selection.set();
|
|
|
|
|
mark_set = bv_->text->selection.mark();
|
2003-07-10 13:21:45 +00:00
|
|
|
|
bv_->text->fullRebreak();
|
|
|
|
|
update();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
} else {
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs());
|
|
|
|
|
bv_->text->init(bv_);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
2002-03-12 17:15:44 +00:00
|
|
|
|
|
2003-10-09 10:52:12 +00:00
|
|
|
|
if (par != -1) {
|
2001-05-31 02:23:46 +00:00
|
|
|
|
bv_->text->selection.set(true);
|
2002-03-12 17:15:44 +00:00
|
|
|
|
// At this point just to avoid the Delete-Empty-Paragraph-
|
|
|
|
|
// Mechanism when setting the cursor.
|
2001-05-31 02:23:46 +00:00
|
|
|
|
bv_->text->selection.mark(mark_set);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
if (selection) {
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bv_->text->setCursor(selstartpar, selstartpos);
|
2001-05-31 02:23:46 +00:00
|
|
|
|
bv_->text->selection.cursor = bv_->text->cursor;
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bv_->text->setCursor(selendpar, selendpos);
|
|
|
|
|
bv_->text->setSelection();
|
|
|
|
|
bv_->text->setCursor(par, pos);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
} else {
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bv_->text->setCursor(par, pos);
|
2001-05-31 02:23:46 +00:00
|
|
|
|
bv_->text->selection.cursor = bv_->text->cursor;
|
|
|
|
|
bv_->text->selection.set(false);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-12 17:15:44 +00:00
|
|
|
|
|
2003-11-13 08:50:26 +00:00
|
|
|
|
fitCursor();
|
2002-03-12 17:15:44 +00:00
|
|
|
|
|
2002-07-17 04:13:41 +00:00
|
|
|
|
switchKeyMap();
|
2003-02-14 14:49:51 +00:00
|
|
|
|
owner_->busy(false);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
|
2003-04-07 16:57:38 +00:00
|
|
|
|
// reset the "Formatting..." message
|
|
|
|
|
owner_->clearMessage();
|
|
|
|
|
|
2002-08-07 14:15:06 +00:00
|
|
|
|
updateScrollbar();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::Pimpl::updateScrollbar()
|
|
|
|
|
{
|
2001-06-04 23:57:32 +00:00
|
|
|
|
if (!bv_->text) {
|
2002-03-25 17:00:04 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
|
2002-06-12 15:01:32 +00:00
|
|
|
|
workarea().setScrollbarParams(0, 0, 0);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
|
LyXText const & t = *bv_->text;
|
2002-07-22 20:57:58 +00:00
|
|
|
|
|
2003-03-06 20:21:21 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", top_y() "
|
2003-08-27 14:55:20 +00:00
|
|
|
|
<< top_y() << ", default height " << defaultRowHeight() << endl;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2003-08-27 14:55:20 +00:00
|
|
|
|
workarea().setScrollbarParams(t.height, top_y(), defaultRowHeight());
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
|
void BufferView::Pimpl::scrollDocView(int value)
|
2000-04-09 22:48:51 +00:00
|
|
|
|
{
|
2002-06-12 15:01:32 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
|
2002-04-05 15:17:24 +00:00
|
|
|
|
|
2002-08-29 13:05:55 +00:00
|
|
|
|
if (!buffer_)
|
|
|
|
|
return;
|
2000-04-09 22:48:51 +00:00
|
|
|
|
|
2003-05-03 18:05:53 +00:00
|
|
|
|
screen().hideCursor();
|
|
|
|
|
|
2003-08-27 14:55:20 +00:00
|
|
|
|
top_y(value);
|
2003-08-25 11:03:19 +00:00
|
|
|
|
screen().redraw(*bv_);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
|
2002-08-29 13:05:55 +00:00
|
|
|
|
if (!lyxrc.cursor_follows_scrollbar)
|
2001-02-07 16:44:49 +00:00
|
|
|
|
return;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-14 00:41:44 +00:00
|
|
|
|
int const height = defaultRowHeight();
|
2003-08-27 14:55:20 +00:00
|
|
|
|
int const first = top_y() + height;
|
|
|
|
|
int const last = top_y() + workarea().workHeight() - height;
|
2003-08-26 10:33:59 +00:00
|
|
|
|
|
|
|
|
|
LyXText * text = bv_->text;
|
|
|
|
|
if (text->cursor.y() < first)
|
|
|
|
|
text->setCursorFromCoordinates(0, first);
|
|
|
|
|
else if (text->cursor.y() > last)
|
|
|
|
|
text->setCursorFromCoordinates(0, last);
|
2003-03-18 20:54:01 +00:00
|
|
|
|
|
2003-03-26 15:55:52 +00:00
|
|
|
|
owner_->updateLayoutChoice();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-10-21 00:15:48 +00:00
|
|
|
|
void BufferView::Pimpl::scroll(int lines)
|
2000-04-08 17:02:02 +00:00
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
if (!buffer_)
|
2002-10-21 00:15:48 +00:00
|
|
|
|
return;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-06-12 15:01:32 +00:00
|
|
|
|
LyXText const * t = bv_->text;
|
2003-02-14 00:41:44 +00:00
|
|
|
|
int const line_height = defaultRowHeight();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2002-10-21 15:29:41 +00:00
|
|
|
|
// The new absolute coordinate
|
2003-08-27 14:55:20 +00:00
|
|
|
|
int new_top_y = top_y() + lines * line_height;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2002-10-21 00:15:48 +00:00
|
|
|
|
// Restrict to a valid value
|
2003-03-06 20:21:21 +00:00
|
|
|
|
new_top_y = std::min(t->height - 4 * line_height, new_top_y);
|
|
|
|
|
new_top_y = std::max(0, new_top_y);
|
2002-10-21 00:15:48 +00:00
|
|
|
|
|
2003-03-06 20:21:21 +00:00
|
|
|
|
scrollDocView(new_top_y);
|
2002-10-21 00:15:48 +00:00
|
|
|
|
|
|
|
|
|
// Update the scrollbar.
|
2003-08-27 14:55:20 +00:00
|
|
|
|
workarea().setScrollbarParams(t->height, top_y(), defaultRowHeight());
|
2000-04-08 17:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
|
|
|
|
|
key_modifier::state state)
|
2000-08-14 15:31:16 +00:00
|
|
|
|
{
|
2002-08-13 14:40:38 +00:00
|
|
|
|
bv_->owner()->getLyXFunc().processKeySym(key, state);
|
2003-05-03 18:05:53 +00:00
|
|
|
|
|
|
|
|
|
/* This is perhaps a bit of a hack. When we move
|
|
|
|
|
* around, or type, it's nice to be able to see
|
|
|
|
|
* the cursor immediately after the keypress. So
|
|
|
|
|
* we reset the toggle timeout and force the visibility
|
|
|
|
|
* of the cursor. Note we cannot do this inside
|
|
|
|
|
* dispatch() itself, because that's called recursively.
|
|
|
|
|
*/
|
|
|
|
|
if (available()) {
|
|
|
|
|
cursor_timeout.restart();
|
|
|
|
|
screen().showCursor(*bv_);
|
|
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-01-13 17:28:42 +00:00
|
|
|
|
void BufferView::Pimpl::selectionRequested()
|
|
|
|
|
{
|
2002-03-20 10:36:03 +00:00
|
|
|
|
static string sel;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-02-04 11:30:25 +00:00
|
|
|
|
if (!available())
|
|
|
|
|
return;
|
2002-03-20 10:36:03 +00:00
|
|
|
|
|
|
|
|
|
LyXText * text = bv_->getLyXText();
|
|
|
|
|
|
|
|
|
|
if (text->selection.set() &&
|
|
|
|
|
(!bv_->text->xsel_cache.set() ||
|
|
|
|
|
text->selection.start != bv_->text->xsel_cache.start ||
|
|
|
|
|
text->selection.end != bv_->text->xsel_cache.end))
|
|
|
|
|
{
|
|
|
|
|
bv_->text->xsel_cache = text->selection;
|
2003-08-28 07:41:31 +00:00
|
|
|
|
sel = text->selectionAsString(*bv_->buffer(), false);
|
2002-03-20 10:36:03 +00:00
|
|
|
|
} else if (!text->selection.set()) {
|
|
|
|
|
sel = string();
|
|
|
|
|
bv_->text->xsel_cache.set(false);
|
|
|
|
|
}
|
2002-01-13 17:28:42 +00:00
|
|
|
|
if (!sel.empty()) {
|
2002-06-11 22:38:49 +00:00
|
|
|
|
workarea().putClipboard(sel);
|
2002-01-13 17:28:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-02-07 16:43:54 +00:00
|
|
|
|
void BufferView::Pimpl::selectionLost()
|
|
|
|
|
{
|
2002-06-11 22:38:49 +00:00
|
|
|
|
if (available()) {
|
2003-05-03 18:05:53 +00:00
|
|
|
|
screen().hideCursor();
|
2002-03-05 16:18:02 +00:00
|
|
|
|
bv_->getLyXText()->clearSelection();
|
2002-03-20 10:36:03 +00:00
|
|
|
|
bv_->text->xsel_cache.set(false);
|
2002-03-05 16:18:02 +00:00
|
|
|
|
}
|
2002-02-07 16:43:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-06-20 20:37:42 +00:00
|
|
|
|
void BufferView::Pimpl::workAreaResize()
|
2000-04-08 17:02:02 +00:00
|
|
|
|
{
|
2001-06-04 23:57:32 +00:00
|
|
|
|
static int work_area_width;
|
2002-07-01 14:31:57 +00:00
|
|
|
|
static int work_area_height;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
2002-06-11 22:38:49 +00:00
|
|
|
|
bool const widthChange = workarea().workWidth() != work_area_width;
|
2002-06-12 00:51:45 +00:00
|
|
|
|
bool const heightChange = workarea().workHeight() != work_area_height;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
|
|
|
|
// update from work area
|
2002-06-11 22:38:49 +00:00
|
|
|
|
work_area_width = workarea().workWidth();
|
2002-06-12 00:51:45 +00:00
|
|
|
|
work_area_height = workarea().workHeight();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
if (buffer_ != 0) {
|
|
|
|
|
if (widthChange) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// The visible LyXView need a resize
|
2002-06-20 20:37:42 +00:00
|
|
|
|
resizeCurrentBuffer();
|
2002-06-11 23:47:58 +00:00
|
|
|
|
}
|
2000-04-08 17:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-01 15:27:57 +00:00
|
|
|
|
if (widthChange || heightChange)
|
|
|
|
|
update();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
// always make sure that the scrollbar is sane.
|
2000-04-09 22:48:51 +00:00
|
|
|
|
updateScrollbar();
|
2000-04-08 17:02:02 +00:00
|
|
|
|
owner_->updateLayoutChoice();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-09 22:48:51 +00:00
|
|
|
|
void BufferView::Pimpl::update()
|
|
|
|
|
{
|
2003-09-12 17:13:22 +00:00
|
|
|
|
//lyxerr << "BufferView::update()" << endl;
|
2003-08-11 09:09:01 +00:00
|
|
|
|
// fix cursor coordinate cache in case something went wrong
|
2003-11-10 13:23:14 +00:00
|
|
|
|
|
|
|
|
|
// check needed to survive LyX startup
|
2003-08-11 09:09:01 +00:00
|
|
|
|
if (bv_->getLyXText()) {
|
2003-11-10 13:23:14 +00:00
|
|
|
|
// update all 'visible' paragraphs
|
2003-11-10 18:15:55 +00:00
|
|
|
|
ParagraphList::iterator beg;
|
|
|
|
|
ParagraphList::iterator end;
|
|
|
|
|
getParsInRange(buffer_->paragraphs(),
|
|
|
|
|
top_y(), top_y() + workarea().workHeight(),
|
|
|
|
|
beg, end);
|
2003-11-10 13:23:14 +00:00
|
|
|
|
bv_->text->redoParagraphs(beg, end);
|
2003-11-11 13:17:28 +00:00
|
|
|
|
bv_->getLyXText()->redoCursor();
|
2003-11-10 13:23:14 +00:00
|
|
|
|
updateScrollbar();
|
2003-08-11 09:09:01 +00:00
|
|
|
|
}
|
2003-08-01 14:51:09 +00:00
|
|
|
|
screen().redraw(*bv_);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
2000-04-09 22:48:51 +00:00
|
|
|
|
// Callback for cursor timer
|
|
|
|
|
void BufferView::Pimpl::cursorToggle()
|
|
|
|
|
{
|
|
|
|
|
if (!buffer_) {
|
2001-02-07 16:44:49 +00:00
|
|
|
|
cursor_timeout.restart();
|
|
|
|
|
return;
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-05-03 18:05:53 +00:00
|
|
|
|
screen().toggleCursor(*bv_);
|
2000-06-08 23:16:16 +00:00
|
|
|
|
cursor_timeout.restart();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool BufferView::Pimpl::available() const
|
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
return buffer_ && bv_->text;
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change const BufferView::Pimpl::getCurrentChange()
|
|
|
|
|
{
|
2003-09-09 09:47:59 +00:00
|
|
|
|
if (!bv_->buffer()->params().tracking_changes)
|
2003-02-08 19:18:01 +00:00
|
|
|
|
return Change(Change::UNCHANGED);
|
|
|
|
|
|
2003-08-15 10:24:39 +00:00
|
|
|
|
LyXText * text = bv_->getLyXText();
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2003-08-15 10:24:39 +00:00
|
|
|
|
if (!text->selection.set())
|
2003-02-08 19:18:01 +00:00
|
|
|
|
return Change(Change::UNCHANGED);
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2003-10-09 10:52:12 +00:00
|
|
|
|
return text->getPar(text->selection.start)
|
|
|
|
|
->lookupChangeFull(text->selection.start.pos());
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-01-28 18:31:36 +00:00
|
|
|
|
void BufferView::Pimpl::savePosition(unsigned int i)
|
2000-04-09 22:48:51 +00:00
|
|
|
|
{
|
2001-01-28 18:31:36 +00:00
|
|
|
|
if (i >= saved_positions_num)
|
|
|
|
|
return;
|
|
|
|
|
saved_positions[i] = Position(buffer_->fileName(),
|
2003-10-09 10:52:12 +00:00
|
|
|
|
bv_->text->cursorPar()->id(),
|
2001-01-28 18:31:36 +00:00
|
|
|
|
bv_->text->cursor.pos());
|
2003-05-13 09:48:57 +00:00
|
|
|
|
if (i > 0)
|
|
|
|
|
owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-01-28 18:31:36 +00:00
|
|
|
|
void BufferView::Pimpl::restorePosition(unsigned int i)
|
2000-04-09 22:48:51 +00:00
|
|
|
|
{
|
2001-01-28 18:31:36 +00:00
|
|
|
|
if (i >= saved_positions_num)
|
|
|
|
|
return;
|
|
|
|
|
|
2001-05-03 14:31:33 +00:00
|
|
|
|
string const fname = saved_positions[i].filename;
|
2000-08-08 13:55:26 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bv_->text->clearSelection();
|
2000-08-08 13:55:26 +00:00
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (fname != buffer_->fileName()) {
|
2003-10-09 10:52:12 +00:00
|
|
|
|
Buffer * b = 0;
|
2003-06-20 12:46:28 +00:00
|
|
|
|
if (bufferlist.exists(fname))
|
|
|
|
|
b = bufferlist.getBuffer(fname);
|
|
|
|
|
else {
|
|
|
|
|
b = bufferlist.newBuffer(fname);
|
|
|
|
|
::loadLyXFile(b, fname); // don't ask, just load it
|
|
|
|
|
}
|
2003-10-09 10:52:12 +00:00
|
|
|
|
if (b)
|
2003-06-20 12:46:28 +00:00
|
|
|
|
buffer(b);
|
2000-08-08 13:55:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 08:01:41 +00:00
|
|
|
|
ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
|
|
|
|
|
if (par == buffer_->par_iterator_end())
|
2001-01-28 18:31:36 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2003-06-12 11:09:55 +00:00
|
|
|
|
bv_->text->setCursor(par.pit(),
|
|
|
|
|
min(par->size(), saved_positions[i].par_pos));
|
2001-05-03 14:31:33 +00:00
|
|
|
|
|
2003-05-13 09:48:57 +00:00
|
|
|
|
if (i > 0)
|
|
|
|
|
owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
|
2000-08-08 13:55:26 +00:00
|
|
|
|
}
|
2000-04-09 22:48:51 +00:00
|
|
|
|
|
2000-06-21 12:41:18 +00:00
|
|
|
|
|
2001-01-28 18:31:36 +00:00
|
|
|
|
bool BufferView::Pimpl::isSavedPosition(unsigned int i)
|
2000-06-05 15:12:09 +00:00
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
return i < saved_positions_num && !saved_positions[i].filename.empty();
|
2000-06-05 15:12:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-09 22:48:51 +00:00
|
|
|
|
|
2002-07-17 04:13:41 +00:00
|
|
|
|
void BufferView::Pimpl::switchKeyMap()
|
2000-04-09 22:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (!lyxrc.rtl_support)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
Intl & intl = owner_->getIntl();
|
|
|
|
|
if (bv_->getLyXText()->real_current_font.isRightToLeft()) {
|
|
|
|
|
if (intl.keymap == Intl::PRIMARY)
|
|
|
|
|
intl.KeyMapSec();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
} else {
|
2003-11-10 09:06:48 +00:00
|
|
|
|
if (intl.keymap == Intl::SECONDARY)
|
|
|
|
|
intl.KeyMapPrim();
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
void BufferView::Pimpl::center()
|
2000-04-09 22:48:51 +00:00
|
|
|
|
{
|
2003-08-18 08:23:03 +00:00
|
|
|
|
LyXText * text = bv_->text;
|
2002-07-22 20:57:58 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
text->clearSelection();
|
2002-07-09 16:19:14 +00:00
|
|
|
|
int const half_height = workarea().workHeight() / 2;
|
2003-09-02 11:10:19 +00:00
|
|
|
|
int new_y = std::max(0, text->cursor.y() - half_height);
|
2002-07-22 20:57:58 +00:00
|
|
|
|
|
2003-03-19 14:45:22 +00:00
|
|
|
|
// FIXME: look at this comment again ...
|
2003-03-06 20:21:21 +00:00
|
|
|
|
// This updates top_y() but means the fitCursor() call
|
2002-07-09 16:19:14 +00:00
|
|
|
|
// from the update(FITCUR) doesn't realise that we might
|
|
|
|
|
// have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
|
|
|
|
|
// the scrollbar to be updated as it should, so we have
|
|
|
|
|
// to do it manually. Any operation that does a center()
|
2003-03-06 20:21:21 +00:00
|
|
|
|
// and also might have moved top_y() must make sure to call
|
2002-07-22 20:57:58 +00:00
|
|
|
|
// updateScrollbar() currently. Never mind that this is a
|
2003-03-06 20:21:21 +00:00
|
|
|
|
// pretty obfuscated way of updating t->top_y()
|
2003-08-27 14:55:20 +00:00
|
|
|
|
top_y(new_y);
|
2000-04-09 22:48:51 +00:00
|
|
|
|
}
|
2000-05-20 01:38:25 +00:00
|
|
|
|
|
|
|
|
|
|
2000-05-20 21:37:05 +00:00
|
|
|
|
void BufferView::Pimpl::stuffClipboard(string const & stuff) const
|
|
|
|
|
{
|
2002-06-11 22:38:49 +00:00
|
|
|
|
workarea().putClipboard(stuff);
|
2000-05-20 21:37:05 +00:00
|
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld * BufferView::Pimpl::getInsetByCode(InsetOld::Code code)
|
2001-02-23 16:10:03 +00:00
|
|
|
|
{
|
2002-08-20 17:18:21 +00:00
|
|
|
|
#if 0
|
2001-05-29 09:50:02 +00:00
|
|
|
|
LyXCursor cursor = bv_->getLyXText()->cursor;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
Buffer::inset_iterator it =
|
|
|
|
|
find_if(Buffer::inset_iterator(
|
2003-10-09 10:52:12 +00:00
|
|
|
|
cursorPar(), cursor.pos()),
|
2001-02-23 16:10:03 +00:00
|
|
|
|
buffer_->inset_iterator_end(),
|
2001-06-28 10:25:20 +00:00
|
|
|
|
lyx::compare_memfun(&Inset::lyxCode, code));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
return it != buffer_->inset_iterator_end() ? (*it) : 0;
|
2002-08-20 17:18:21 +00:00
|
|
|
|
#else
|
|
|
|
|
// Ok, this is a little bit too brute force but it
|
2003-08-18 08:23:03 +00:00
|
|
|
|
// should work for now. Better infrastructure is coming. (Lgb)
|
2002-08-20 17:18:21 +00:00
|
|
|
|
|
|
|
|
|
Buffer * b = bv_->buffer();
|
2003-10-09 10:52:12 +00:00
|
|
|
|
LyXText * text = bv_->getLyXText();
|
2002-08-20 17:18:21 +00:00
|
|
|
|
|
|
|
|
|
Buffer::inset_iterator beg = b->inset_iterator_begin();
|
|
|
|
|
Buffer::inset_iterator end = b->inset_iterator_end();
|
|
|
|
|
|
2003-10-09 10:52:12 +00:00
|
|
|
|
bool cursorPar_seen = false;
|
2002-08-20 20:04:24 +00:00
|
|
|
|
|
2002-08-20 17:18:21 +00:00
|
|
|
|
for (; beg != end; ++beg) {
|
2003-10-09 10:52:12 +00:00
|
|
|
|
if (beg.getPar() == text->cursorPar()) {
|
|
|
|
|
cursorPar_seen = true;
|
2002-08-20 17:18:21 +00:00
|
|
|
|
}
|
2003-10-09 10:52:12 +00:00
|
|
|
|
if (cursorPar_seen) {
|
|
|
|
|
if (beg.getPar() == text->cursorPar()
|
|
|
|
|
&& beg.getPos() >= text->cursor.pos()) {
|
2002-08-20 17:18:21 +00:00
|
|
|
|
break;
|
2003-10-09 10:52:12 +00:00
|
|
|
|
} else if (beg.getPar() != text->cursorPar()) {
|
2002-08-20 17:18:21 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-08-20 20:04:24 +00:00
|
|
|
|
|
2002-08-20 17:18:21 +00:00
|
|
|
|
}
|
|
|
|
|
if (beg != end) {
|
|
|
|
|
// Now find the first inset that matches code.
|
|
|
|
|
for (; beg != end; ++beg) {
|
|
|
|
|
if (beg->lyxCode() == code) {
|
|
|
|
|
return &(*beg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
2001-02-23 16:10:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
|
|
|
|
|
{
|
|
|
|
|
string filename = filen;
|
|
|
|
|
|
|
|
|
|
if (filename.empty()) {
|
|
|
|
|
// Launch a file browser
|
|
|
|
|
string initpath = lyxrc.document_path;
|
|
|
|
|
|
|
|
|
|
if (available()) {
|
2002-01-14 23:31:23 +00:00
|
|
|
|
string const trypath = owner_->buffer()->filePath();
|
2001-02-23 16:10:03 +00:00
|
|
|
|
// If directory is writeable, use this as default.
|
2001-08-01 10:08:53 +00:00
|
|
|
|
if (IsDirWriteable(trypath))
|
2001-02-23 16:10:03 +00:00
|
|
|
|
initpath = trypath;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-21 12:22:25 +00:00
|
|
|
|
FileDialog fileDlg(_("Select LyX document to insert"),
|
2001-03-07 14:25:31 +00:00
|
|
|
|
LFUN_FILE_INSERT,
|
2002-01-13 15:01:25 +00:00
|
|
|
|
make_pair(string(_("Documents|#o#O")),
|
2001-05-29 09:50:02 +00:00
|
|
|
|
string(lyxrc.document_path)),
|
2002-01-13 15:01:25 +00:00
|
|
|
|
make_pair(string(_("Examples|#E#e")),
|
2003-07-27 21:04:02 +00:00
|
|
|
|
string(AddPath(system_lyxdir(), "examples"))));
|
2001-05-29 09:50:02 +00:00
|
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
2002-11-17 08:32:09 +00:00
|
|
|
|
fileDlg.open(initpath,
|
2001-05-29 09:50:02 +00:00
|
|
|
|
_("*.lyx| LyX Documents (*.lyx)"));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
filename = result.second;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
|
|
// check selected filename
|
|
|
|
|
if (filename.empty()) {
|
2001-04-24 17:33:01 +00:00
|
|
|
|
owner_->message(_("Canceled."));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2001-03-07 14:25:31 +00:00
|
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
|
// get absolute path of file and add ".lyx" to the filename if
|
|
|
|
|
// necessary
|
|
|
|
|
filename = FileSearch(string(), filename, "lyx");
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
2003-05-13 09:48:57 +00:00
|
|
|
|
string const disp_fn = MakeDisplayPath(filename);
|
|
|
|
|
owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
|
2003-07-10 12:26:40 +00:00
|
|
|
|
if (bv_->insertLyXFile(filename))
|
2003-07-25 17:11:25 +00:00
|
|
|
|
owner_->message(bformat(_("Document %1$s inserted."),
|
2003-07-10 12:26:40 +00:00
|
|
|
|
disp_fn));
|
2003-05-21 21:20:50 +00:00
|
|
|
|
else
|
2003-07-25 17:11:25 +00:00
|
|
|
|
owner_->message(bformat(_("Could not insert document %1$s"),
|
2003-07-10 12:26:40 +00:00
|
|
|
|
disp_fn));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void BufferView::Pimpl::trackChanges()
|
|
|
|
|
{
|
|
|
|
|
Buffer * buf(bv_->buffer());
|
2003-09-09 09:47:59 +00:00
|
|
|
|
bool const tracking(buf->params().tracking_changes);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
|
if (!tracking) {
|
|
|
|
|
ParIterator const end = buf->par_iterator_end();
|
2003-06-17 15:33:49 +00:00
|
|
|
|
for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
|
2003-06-12 11:09:55 +00:00
|
|
|
|
it->trackChanges();
|
2003-09-09 09:47:59 +00:00
|
|
|
|
buf->params().tracking_changes = true;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
|
// we cannot allow undos beyond the freeze point
|
2003-09-09 09:47:59 +00:00
|
|
|
|
buf->undostack().clear();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
} else {
|
2003-08-04 09:06:35 +00:00
|
|
|
|
update();
|
2003-10-09 10:52:12 +00:00
|
|
|
|
bv_->text->setCursor(0, 0);
|
2003-03-02 12:16:00 +00:00
|
|
|
|
#warning changes FIXME
|
2003-07-27 12:02:58 +00:00
|
|
|
|
bool found = lyx::find::findNextChange(bv_);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
if (found) {
|
2003-03-09 21:03:43 +00:00
|
|
|
|
owner_->getDialogs().show("changes");
|
2003-02-08 19:18:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParIterator const end = buf->par_iterator_end();
|
2003-06-12 11:09:55 +00:00
|
|
|
|
for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
|
|
|
|
|
it->untrackChanges();
|
2003-09-09 09:47:59 +00:00
|
|
|
|
buf->params().tracking_changes = false;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2003-09-09 09:47:59 +00:00
|
|
|
|
buf->redostack().clear();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
#warning remove me
|
|
|
|
|
LCursor theTempCursor(0);
|
|
|
|
|
|
|
|
|
|
namespace {
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
InsetOld * insetFromCoords(BufferView * bv, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
LyXText * text = bv->text;
|
|
|
|
|
InsetOld * inset = 0;
|
|
|
|
|
theTempCursor = LCursor(bv);
|
2003-11-10 11:26:33 +00:00
|
|
|
|
while (true) {
|
|
|
|
|
InsetOld * inset_hit = text->checkInsetHit(x, y);
|
2003-11-17 14:28:18 +00:00
|
|
|
|
if (!inset_hit) {
|
|
|
|
|
lyxerr << "no further inset hit" << endl;
|
2003-11-10 11:26:33 +00:00
|
|
|
|
break;
|
2003-11-17 14:28:18 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
inset = inset_hit;
|
2003-11-17 14:28:18 +00:00
|
|
|
|
if (!inset_hit->descendable()) {
|
|
|
|
|
lyxerr << "not descendable" << endl;
|
2003-11-10 11:26:33 +00:00
|
|
|
|
break;
|
2003-11-17 14:28:18 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
text = inset_hit->getText(0);
|
|
|
|
|
lyxerr << "Hit inset: " << inset << " at x: " << x
|
2003-11-10 11:26:33 +00:00
|
|
|
|
<< " text: " << text << " y: " << y << endl;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
theTempCursor.push(static_cast<UpdatableInset*>(inset));
|
|
|
|
|
}
|
2003-11-17 14:28:18 +00:00
|
|
|
|
lyxerr << "theTempCursor: " << theTempCursor << endl;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
return inset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
|
2003-08-05 19:51:45 +00:00
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
switch (cmd.action) {
|
2003-11-17 20:28:11 +00:00
|
|
|
|
case LFUN_MOUSE_MOTION: {
|
|
|
|
|
FuncRequest cmd1(cmd, bv_);
|
|
|
|
|
UpdatableInset * inset = bv_->cursor().innerInset();
|
|
|
|
|
DispatchResult res;
|
|
|
|
|
if (inset) {
|
|
|
|
|
cmd1.x -= inset->x();
|
|
|
|
|
cmd1.y -= inset->y();
|
|
|
|
|
res = inset->dispatch(cmd1);
|
|
|
|
|
} else {
|
|
|
|
|
cmd1.y += bv_->top_y();
|
|
|
|
|
res = bv_->cursor().innerText()->dispatch(cmd1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bv_->fitCursor() || res.update()) {
|
|
|
|
|
bv_->update();
|
|
|
|
|
bv_->cursor().updatePos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-05 19:51:45 +00:00
|
|
|
|
case LFUN_MOUSE_PRESS:
|
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
|
|
|
|
case LFUN_MOUSE_DOUBLE:
|
2003-11-10 09:06:48 +00:00
|
|
|
|
case LFUN_MOUSE_TRIPLE: {
|
2003-08-05 19:51:45 +00:00
|
|
|
|
// We pass those directly to the Bufferview, since
|
|
|
|
|
// otherwise selection handling breaks down
|
2003-03-24 02:31:44 +00:00
|
|
|
|
|
2003-08-05 19:51:45 +00:00
|
|
|
|
// Doesn't go through lyxfunc, so we need to update
|
|
|
|
|
// the layout choice etc. ourselves
|
2003-05-03 18:05:53 +00:00
|
|
|
|
|
2003-08-05 19:51:45 +00:00
|
|
|
|
// e.g. Qt mouse press when no buffer
|
|
|
|
|
if (!available())
|
|
|
|
|
return false;
|
2003-07-02 17:09:56 +00:00
|
|
|
|
|
2003-08-05 19:51:45 +00:00
|
|
|
|
screen().hideCursor();
|
2003-03-24 02:31:44 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
// either the inset under the cursor or the surrounding LyXText will
|
|
|
|
|
// handle this event.
|
|
|
|
|
|
|
|
|
|
// built temporary path to inset
|
|
|
|
|
InsetOld * inset = insetFromCoords(bv_, cmd.x, cmd.y);
|
|
|
|
|
FuncRequest cmd1(cmd, bv_);
|
|
|
|
|
DispatchResult res;
|
|
|
|
|
|
|
|
|
|
// try to dispatch to that inset
|
|
|
|
|
if (inset) {
|
|
|
|
|
FuncRequest cmd2 = cmd1;
|
|
|
|
|
lyxerr << "dispatching action " << cmd2.action
|
2003-11-17 20:28:11 +00:00
|
|
|
|
<< " to inset " << inset << endl;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
cmd2.x -= inset->x();
|
|
|
|
|
cmd2.y -= inset->y();
|
|
|
|
|
res = inset->dispatch(cmd2);
|
2003-11-11 13:17:28 +00:00
|
|
|
|
if (res.update()) {
|
2003-11-10 13:23:14 +00:00
|
|
|
|
bv_->update();
|
2003-11-11 13:17:28 +00:00
|
|
|
|
bv_->cursor().updatePos();
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
res.update(false);
|
2003-11-10 14:29:39 +00:00
|
|
|
|
switch (res.val()) {
|
|
|
|
|
case FINISHED:
|
|
|
|
|
case FINISHED_RIGHT:
|
|
|
|
|
case FINISHED_UP:
|
|
|
|
|
case FINISHED_DOWN:
|
|
|
|
|
theTempCursor.pop();
|
|
|
|
|
bv_->cursor() = theTempCursor;
|
2003-11-11 09:06:41 +00:00
|
|
|
|
bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
|
2003-11-13 08:50:26 +00:00
|
|
|
|
if (bv_->fitCursor())
|
|
|
|
|
bv_->update();
|
2003-11-10 14:29:39 +00:00
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
lyxerr << "not dispatched by inner inset val: " << res.val() << endl;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// otherwise set cursor to surrounding LyXText
|
|
|
|
|
if (!res.dispatched()) {
|
2003-11-13 08:50:26 +00:00
|
|
|
|
lyxerr << "temp cursor is: " << theTempCursor << endl;
|
2003-11-11 09:06:41 +00:00
|
|
|
|
lyxerr << "dispatching " << cmd1
|
|
|
|
|
<< " to surrounding LyXText "
|
2003-11-13 08:50:26 +00:00
|
|
|
|
<< theTempCursor.innerText() << endl;
|
2003-11-11 13:17:28 +00:00
|
|
|
|
bv_->cursor() = theTempCursor;
|
2003-11-17 20:28:11 +00:00
|
|
|
|
cmd1.y += bv_->top_y();
|
2003-11-13 08:50:26 +00:00
|
|
|
|
res = bv_->cursor().innerText()->dispatch(cmd1);
|
|
|
|
|
if (bv_->fitCursor() || res.update())
|
|
|
|
|
bv_->update();
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
//return DispatchResult(true, true);
|
|
|
|
|
}
|
2003-08-05 19:51:45 +00:00
|
|
|
|
// see workAreaKeyPress
|
|
|
|
|
cursor_timeout.restart();
|
|
|
|
|
screen().showCursor(*bv_);
|
2003-05-03 18:05:53 +00:00
|
|
|
|
|
2003-11-13 08:50:26 +00:00
|
|
|
|
// skip these when selecting
|
|
|
|
|
if (cmd.action != LFUN_MOUSE_MOTION) {
|
|
|
|
|
owner_->updateLayoutChoice();
|
|
|
|
|
owner_->updateToolbar();
|
|
|
|
|
}
|
2003-03-24 02:31:44 +00:00
|
|
|
|
|
2003-08-05 19:51:45 +00:00
|
|
|
|
// slight hack: this is only called currently when we
|
|
|
|
|
// clicked somewhere, so we force through the display
|
|
|
|
|
// of the new status here.
|
|
|
|
|
owner_->clearMessage();
|
2003-11-10 09:06:48 +00:00
|
|
|
|
return true;
|
2003-08-05 19:51:45 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2003-08-05 19:51:45 +00:00
|
|
|
|
default:
|
2003-11-10 09:06:48 +00:00
|
|
|
|
owner_->dispatch(cmd);
|
2003-08-05 19:51:45 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-03-24 02:31:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-26 19:28:38 +00:00
|
|
|
|
bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
2001-02-23 16:10:03 +00:00
|
|
|
|
{
|
2003-02-26 19:28:38 +00:00
|
|
|
|
// Make sure that the cached BufferView is correct.
|
|
|
|
|
FuncRequest ev = ev_in;
|
|
|
|
|
ev.setView(bv_);
|
|
|
|
|
|
2002-08-28 08:30:27 +00:00
|
|
|
|
lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
|
2002-11-27 10:30:28 +00:00
|
|
|
|
<< " action[" << ev.action << ']'
|
|
|
|
|
<< " arg[" << ev.argument << ']'
|
|
|
|
|
<< " x[" << ev.x << ']'
|
|
|
|
|
<< " y[" << ev.y << ']'
|
|
|
|
|
<< " button[" << ev.button() << ']'
|
2002-08-28 08:30:27 +00:00
|
|
|
|
<< endl;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-09-09 09:47:59 +00:00
|
|
|
|
LyXTextClass const & tclass = buffer_->params().getLyXTextClass();
|
2002-05-01 22:17:09 +00:00
|
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
|
switch (ev.action) {
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_SCROLL_INSET:
|
2002-08-19 15:39:25 +00:00
|
|
|
|
// this is not handled here as this function is only active
|
2001-02-23 16:10:03 +00:00
|
|
|
|
// if we have a locking_inset and that one is (or contains)
|
|
|
|
|
// a tabular-inset
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_FILE_INSERT:
|
2002-08-07 08:11:41 +00:00
|
|
|
|
MenuInsertLyXFile(ev.argument);
|
2001-11-29 17:12:21 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
case LFUN_FILE_INSERT_ASCII_PARA:
|
2002-08-07 08:11:41 +00:00
|
|
|
|
InsertAsciiFile(bv_, ev.argument, true);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
|
case LFUN_FILE_INSERT_ASCII:
|
2002-08-07 08:11:41 +00:00
|
|
|
|
InsertAsciiFile(bv_, ev.argument, false);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
|
case LFUN_FONT_STATE:
|
2002-08-13 14:40:38 +00:00
|
|
|
|
owner_->getLyXFunc().setMessage(currentState(bv_));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-27 16:24:14 +00:00
|
|
|
|
case LFUN_INSERT_LABEL: {
|
|
|
|
|
// Try and generate a valid label
|
|
|
|
|
string const contents = ev.argument.empty() ?
|
|
|
|
|
getPossibleLabel(*bv_) : ev.argument;
|
|
|
|
|
InsetCommandParams icp("label", contents);
|
|
|
|
|
string data = InsetCommandMailer::params2string("label", icp);
|
|
|
|
|
owner_->getDialogs().show("label", data, 0);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2003-02-27 16:24:14 +00:00
|
|
|
|
}
|
2001-11-09 13:44:48 +00:00
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
|
case LFUN_BOOKMARK_SAVE:
|
2002-08-07 08:11:41 +00:00
|
|
|
|
savePosition(strToUnsignedInt(ev.argument));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_BOOKMARK_GOTO:
|
2002-08-07 08:11:41 +00:00
|
|
|
|
restorePosition(strToUnsignedInt(ev.argument));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-03-29 10:29:38 +00:00
|
|
|
|
case LFUN_REF_GOTO: {
|
2002-08-07 08:11:41 +00:00
|
|
|
|
string label = ev.argument;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
if (label.empty()) {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
InsetRef * inset =
|
2003-07-25 21:20:24 +00:00
|
|
|
|
static_cast<InsetRef*>(getInsetByCode(InsetOld::REF_CODE));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
if (inset) {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
label = inset->getContents();
|
2001-02-23 16:10:03 +00:00
|
|
|
|
savePosition(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-03-29 10:29:38 +00:00
|
|
|
|
if (!label.empty())
|
|
|
|
|
bv_->gotoLabel(label);
|
2001-02-23 16:10:03 +00:00
|
|
|
|
}
|
2001-05-29 09:50:02 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
|
// --- accented characters ---------------------------
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
|
case LFUN_UMLAUT:
|
|
|
|
|
case LFUN_CIRCUMFLEX:
|
|
|
|
|
case LFUN_GRAVE:
|
|
|
|
|
case LFUN_ACUTE:
|
|
|
|
|
case LFUN_TILDE:
|
|
|
|
|
case LFUN_CEDILLA:
|
|
|
|
|
case LFUN_MACRON:
|
|
|
|
|
case LFUN_DOT:
|
|
|
|
|
case LFUN_UNDERDOT:
|
|
|
|
|
case LFUN_UNDERBAR:
|
|
|
|
|
case LFUN_CARON:
|
|
|
|
|
case LFUN_SPECIAL_CARON:
|
|
|
|
|
case LFUN_BREVE:
|
|
|
|
|
case LFUN_TIE:
|
|
|
|
|
case LFUN_HUNG_UMLAUT:
|
|
|
|
|
case LFUN_CIRCLE:
|
|
|
|
|
case LFUN_OGONEK:
|
2002-08-07 08:11:41 +00:00
|
|
|
|
if (ev.argument.empty()) {
|
2001-05-16 07:53:23 +00:00
|
|
|
|
// As always...
|
2002-08-13 14:40:38 +00:00
|
|
|
|
owner_->getLyXFunc().handleKeyFunc(ev.action);
|
2001-05-16 07:53:23 +00:00
|
|
|
|
} else {
|
2002-08-13 14:40:38 +00:00
|
|
|
|
owner_->getLyXFunc().handleKeyFunc(ev.action);
|
|
|
|
|
owner_->getIntl().getTransManager()
|
2002-08-07 08:11:41 +00:00
|
|
|
|
.TranslateAndInsert(ev.argument[0], bv_->getLyXText());
|
2003-08-04 09:06:35 +00:00
|
|
|
|
update();
|
2001-05-16 07:53:23 +00:00
|
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-07-06 12:09:32 +00:00
|
|
|
|
case LFUN_MATH_MACRO:
|
2002-03-21 17:27:08 +00:00
|
|
|
|
case LFUN_MATH_DELIM:
|
2001-02-23 16:10:03 +00:00
|
|
|
|
case LFUN_INSERT_MATRIX:
|
|
|
|
|
case LFUN_INSERT_MATH:
|
2001-07-06 12:09:32 +00:00
|
|
|
|
case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection
|
|
|
|
|
case LFUN_MATH_DISPLAY: // Open or create a displayed math inset
|
2002-03-21 17:27:08 +00:00
|
|
|
|
case LFUN_MATH_MODE: // Open or create an inlined math inset
|
2003-02-26 19:28:38 +00:00
|
|
|
|
mathDispatch(ev);
|
2001-10-19 15:13:49 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-27 13:26:07 +00:00
|
|
|
|
case LFUN_INSET_APPLY: {
|
2003-11-13 20:16:34 +00:00
|
|
|
|
#warning is this code ever called?
|
|
|
|
|
// Remove if not triggered. Mail lyx-devel if triggered.
|
|
|
|
|
// This code was replaced by code in text3.C.
|
|
|
|
|
BOOST_ASSERT(false);
|
2003-02-27 13:26:07 +00:00
|
|
|
|
string const name = ev.getArg(0);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-03-25 21:27:07 +00:00
|
|
|
|
InsetBase * inset = owner_->getDialogs().getOpenInset(name);
|
|
|
|
|
if (inset) {
|
2003-02-26 15:01:10 +00:00
|
|
|
|
// This works both for 'original' and 'mathed' insets.
|
2003-11-10 13:23:14 +00:00
|
|
|
|
// Note that the localDispatch performs update also.
|
2003-03-04 14:31:04 +00:00
|
|
|
|
FuncRequest fr(bv_, LFUN_INSET_MODIFY, ev.argument);
|
2003-10-17 18:01:15 +00:00
|
|
|
|
inset->dispatch(fr);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
} else {
|
2003-03-25 21:27:07 +00:00
|
|
|
|
FuncRequest fr(bv_, LFUN_INSET_INSERT, ev.argument);
|
|
|
|
|
dispatch(fr);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
}
|
2003-03-25 21:27:07 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_INSERT: {
|
2003-11-13 20:16:34 +00:00
|
|
|
|
// Same as above.
|
|
|
|
|
BOOST_ASSERT(false);
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld * inset = createInset(ev);
|
2003-11-10 13:23:14 +00:00
|
|
|
|
if (!inset || !insertInset(inset))
|
2003-03-25 21:27:07 +00:00
|
|
|
|
delete inset;
|
2003-11-10 13:23:14 +00:00
|
|
|
|
break;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
}
|
2003-03-30 21:42:09 +00:00
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
|
case LFUN_FLOAT_LIST:
|
2002-08-27 15:51:19 +00:00
|
|
|
|
if (tclass.floats().typeExist(ev.argument)) {
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld * inset = new InsetFloatList(ev.argument);
|
2002-05-01 22:17:09 +00:00
|
|
|
|
if (!insertInset(inset, tclass.defaultLayoutName()))
|
2002-04-28 14:00:48 +00:00
|
|
|
|
delete inset;
|
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "Non-existent float type: "
|
2002-08-07 08:11:41 +00:00
|
|
|
|
<< ev.argument << endl;
|
2002-04-28 14:00:48 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-03-13 13:56:25 +00:00
|
|
|
|
case LFUN_LAYOUT_PARAGRAPH: {
|
|
|
|
|
string data;
|
2003-10-09 10:52:12 +00:00
|
|
|
|
params2string(*bv_->getLyXText()->cursorPar(), data);
|
2003-03-13 13:56:25 +00:00
|
|
|
|
data = "show\n" + data;
|
|
|
|
|
bv_->owner()->getDialogs().show("paragraph", data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
case LFUN_PARAGRAPH_UPDATE:
|
|
|
|
|
updateParagraphDialog();
|
2003-03-13 13:56:25 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_PARAGRAPH_APPLY:
|
|
|
|
|
setParagraphParams(*bv_, ev.argument);
|
|
|
|
|
break;
|
2003-03-17 16:25:00 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
case LFUN_THESAURUS_ENTRY: {
|
2002-08-07 08:11:41 +00:00
|
|
|
|
string arg = ev.argument;
|
2001-07-29 10:42:11 +00:00
|
|
|
|
|
|
|
|
|
if (arg.empty()) {
|
2003-08-28 07:41:31 +00:00
|
|
|
|
arg = bv_->getLyXText()->selectionAsString(*buffer_,
|
2001-09-12 10:41:25 +00:00
|
|
|
|
false);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-07-29 10:42:11 +00:00
|
|
|
|
// FIXME
|
|
|
|
|
if (arg.size() > 100 || arg.empty()) {
|
|
|
|
|
// Get word or selection
|
2003-07-01 11:51:20 +00:00
|
|
|
|
bv_->getLyXText()->selectWordWhenUnderCursor(lyx::WHOLE_WORD);
|
2003-08-28 07:41:31 +00:00
|
|
|
|
arg = bv_->getLyXText()->selectionAsString(*buffer_, false);
|
2001-07-29 10:42:11 +00:00
|
|
|
|
// FIXME: where is getLyXText()->unselect(bv_) ?
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-26 12:17:20 +00:00
|
|
|
|
bv_->owner()->getDialogs().show("thesaurus", arg);
|
2001-07-29 10:42:11 +00:00
|
|
|
|
break;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
case LFUN_TRACK_CHANGES:
|
|
|
|
|
trackChanges();
|
|
|
|
|
break;
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
case LFUN_MERGE_CHANGES:
|
2003-03-09 21:03:43 +00:00
|
|
|
|
owner_->getDialogs().show("changes");
|
2003-02-08 19:18:01 +00:00
|
|
|
|
break;
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
case LFUN_ACCEPT_ALL_CHANGES: {
|
2003-10-09 10:52:12 +00:00
|
|
|
|
bv_->text->setCursor(0, 0);
|
2003-03-02 12:16:00 +00:00
|
|
|
|
#warning FIXME changes
|
2003-08-04 09:06:35 +00:00
|
|
|
|
while (lyx::find::findNextChange(bv_))
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bv_->getLyXText()->acceptChange();
|
2003-08-04 09:06:35 +00:00
|
|
|
|
update();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
case LFUN_REJECT_ALL_CHANGES: {
|
2003-10-09 10:52:12 +00:00
|
|
|
|
bv_->text->setCursor(0, 0);
|
2003-03-02 12:16:00 +00:00
|
|
|
|
#warning FIXME changes
|
2003-08-04 09:06:35 +00:00
|
|
|
|
while (lyx::find::findNextChange(bv_))
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bv_->getLyXText()->rejectChange();
|
2003-08-04 09:06:35 +00:00
|
|
|
|
update();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
case LFUN_ACCEPT_CHANGE: {
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bv_->getLyXText()->acceptChange();
|
2003-08-04 09:06:35 +00:00
|
|
|
|
update();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_REJECT_CHANGE: {
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bv_->getLyXText()->rejectChange();
|
2003-08-04 09:06:35 +00:00
|
|
|
|
update();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
|
case LFUN_UNKNOWN_ACTION:
|
2002-08-20 15:26:52 +00:00
|
|
|
|
ev.errorMessage(N_("Unknown function!"));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-09-21 23:00:47 +00:00
|
|
|
|
default:
|
2003-11-01 15:45:19 +00:00
|
|
|
|
return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)).dispatched();
|
2001-02-23 16:10:03 +00:00
|
|
|
|
} // end of switch
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2001-05-18 07:37:14 +00:00
|
|
|
|
|
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
|
2001-06-04 23:57:32 +00:00
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
#ifdef LOCK
|
2001-06-04 23:57:32 +00:00
|
|
|
|
// if we are in a locking inset we should try to insert the
|
|
|
|
|
// inset there otherwise this is a illegal function now
|
|
|
|
|
if (bv_->theLockingInset()) {
|
2001-07-19 08:52:59 +00:00
|
|
|
|
if (bv_->theLockingInset()->insetAllowed(inset))
|
2002-08-29 13:05:55 +00:00
|
|
|
|
return bv_->theLockingInset()->insertInset(bv_, inset);
|
2001-06-04 23:57:32 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
#endif
|
2001-06-04 23:57:32 +00:00
|
|
|
|
|
|
|
|
|
// not quite sure if we want this...
|
2003-10-13 10:59:31 +00:00
|
|
|
|
bv_->text->recUndo(bv_->text->cursor.par());
|
2001-07-06 15:57:54 +00:00
|
|
|
|
freezeUndo();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bv_->text->clearSelection();
|
2001-06-04 23:57:32 +00:00
|
|
|
|
if (!lout.empty()) {
|
2003-09-09 09:47:59 +00:00
|
|
|
|
bv_->text->breakParagraph(bv_->buffer()->paragraphs());
|
2001-06-04 23:57:32 +00:00
|
|
|
|
|
2003-10-09 10:52:12 +00:00
|
|
|
|
if (!bv_->text->cursorPar()->empty()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bv_->text->cursorLeft(bv_);
|
2003-09-09 09:47:59 +00:00
|
|
|
|
bv_->text->breakParagraph(bv_->buffer()->paragraphs());
|
2001-06-04 23:57:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
string lres = lout;
|
2003-09-09 09:47:59 +00:00
|
|
|
|
LyXTextClass const & tclass = buffer_->params().getLyXTextClass();
|
2002-03-02 16:39:54 +00:00
|
|
|
|
bool hasLayout = tclass.hasLayout(lres);
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bv_->text->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-10-27 12:41:26 +00:00
|
|
|
|
bv_->text->setParagraph(
|
2001-06-04 23:57:32 +00:00
|
|
|
|
VSpace(VSpace::NONE), VSpace(VSpace::NONE),
|
2001-08-16 10:14:48 +00:00
|
|
|
|
Spacing(),
|
2002-03-21 17:27:08 +00:00
|
|
|
|
LYX_ALIGN_LAYOUT,
|
2001-06-04 23:57:32 +00:00
|
|
|
|
string(),
|
|
|
|
|
0);
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bv_->cursor().innerText()->insertInset(inset);
|
2001-07-06 15:57:54 +00:00
|
|
|
|
unFreezeUndo();
|
2001-06-04 23:57:32 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-06 19:16:30 +00:00
|
|
|
|
bool BufferView::Pimpl::ChangeInsets(InsetOld::Code code,
|
|
|
|
|
string const & from, string const & to)
|
|
|
|
|
{
|
|
|
|
|
bool need_update = false;
|
|
|
|
|
LyXCursor cursor = bv_->text->cursor;
|
|
|
|
|
LyXCursor tmpcursor = cursor;
|
|
|
|
|
cursor.par(tmpcursor.par());
|
|
|
|
|
cursor.pos(tmpcursor.pos());
|
|
|
|
|
|
|
|
|
|
ParIterator end = bv_->buffer()->par_iterator_end();
|
|
|
|
|
for (ParIterator it = bv_->buffer()->par_iterator_begin();
|
|
|
|
|
it != end; ++it) {
|
|
|
|
|
bool changed_inset = false;
|
|
|
|
|
for (InsetList::iterator it2 = it->insetlist.begin();
|
|
|
|
|
it2 != it->insetlist.end(); ++it2) {
|
|
|
|
|
if (it2->inset->lyxCode() == code) {
|
|
|
|
|
InsetCommand * inset = static_cast<InsetCommand *>(it2->inset);
|
|
|
|
|
if (inset->getContents() == from) {
|
|
|
|
|
inset->setContents(to);
|
|
|
|
|
changed_inset = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (changed_inset) {
|
|
|
|
|
need_update = true;
|
|
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
|
|
|
|
|
|
// The test it.size()==1 was needed to prevent crashes.
|
2003-10-09 10:52:12 +00:00
|
|
|
|
// How to set the cursor correctly when it.size()>1 ??
|
2003-09-06 19:16:30 +00:00
|
|
|
|
if (it.size() == 1) {
|
2003-10-09 10:52:12 +00:00
|
|
|
|
bv_->text->setCursorIntern(bv_->text->parOffset(it.pit()), 0);
|
|
|
|
|
bv_->text->redoParagraph(bv_->text->cursorPar());
|
2003-09-06 19:16:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bv_->text->setCursorIntern(cursor.par(), cursor.pos());
|
|
|
|
|
return need_update;
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BufferView::Pimpl::updateParagraphDialog()
|
|
|
|
|
{
|
|
|
|
|
if (!bv_->owner()->getDialogs().visible("paragraph"))
|
|
|
|
|
return;
|
|
|
|
|
Paragraph const & par = *bv_->getLyXText()->cursorPar();
|
|
|
|
|
string data;
|
|
|
|
|
params2string(par, data);
|
|
|
|
|
|
|
|
|
|
// Will the paragraph accept changes from the dialog?
|
|
|
|
|
InsetOld * const inset = par.inInset();
|
|
|
|
|
bool const accept =
|
|
|
|
|
!(inset && inset->forceDefaultParagraphs(inset));
|
|
|
|
|
|
|
|
|
|
data = "update " + tostr(accept) + '\n' + data;
|
|
|
|
|
bv_->owner()->getDialogs().update("paragraph", data);
|
|
|
|
|
}
|
2003-11-10 13:23:14 +00:00
|
|
|
|
|
|
|
|
|
|