: bv_(bv), owner_(owner), buffer_(0), cursor_timeout(400),
using_xterm_cursor(false), cursor_(bv)
{
+ xsel_cache_.set = false;
+
workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
screen_.reset(LyXScreenFactory::create(workarea()));
// set current buffer
buffer_ = b;
- buffer_->text().init(bv_);
- buffer_->text().textwidth_ = workarea().workWidth();
- buffer_->text().fullRebreak();
top_y_ = 0;
lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
connectBuffer(*buffer_);
+ buffer_->text().init(bv_);
+ buffer_->text().textwidth_ = workarea().workWidth();
+ buffer_->text().fullRebreak();
+
// If we don't have a text object for this, we make one
if (bv_->text() == 0)
resizeCurrentBuffer();
owner_->message(_("Formatting document..."));
- lyxerr << "### resizeCurrentBuffer: text" << bv_->text() << endl;
+ lyxerr << "### resizeCurrentBuffer: text " << bv_->text() << endl;
if (!bv_->text())
return;
- //if (bv_->text()) {
- par = bv_->text()->cursor.par();
- pos = bv_->text()->cursor.pos();
- selstartpar = bv_->text()->selection.start.par();
- selstartpos = bv_->text()->selection.start.pos();
- selendpar = bv_->text()->selection.end.par();
- selendpos = bv_->text()->selection.end.pos();
- selection = bv_->text()->selection.set();
- mark_set = bv_->text()->selection.mark();
- bv_->text()->fullRebreak();
- update();
- //} else {
- // bv_->setText(new LyXText(bv_, 0, false, bv_->buffer()->paragraphs()));
- // bv_->text()->init(bv_);
- //}
+ par = bv_->text()->cursor.par();
+ pos = bv_->text()->cursor.pos();
+ selstartpar = bv_->text()->selStart().par();
+ selstartpos = bv_->text()->selStart().pos();
+ selendpar = bv_->text()->selEnd().par();
+ selendpos = bv_->text()->selEnd().pos();
+ selection = bv_->text()->selection.set();
+ mark_set = bv_->text()->selection.mark();
+ bv_->text()->textwidth_ = bv_->workWidth();
+ bv_->text()->fullRebreak();
+ update();
if (par != -1) {
bv_->text()->selection.set(true);
int const last = top_y() + workarea().workHeight() - height;
LyXText * text = bv_->text();
- if (text->cursor.y() < first)
+ if (text->cursorY() < first)
text->setCursorFromCoordinates(0, first);
- else if (text->cursor.y() > last)
+ else if (text->cursorY() > last)
text->setCursorFromCoordinates(0, last);
owner_->updateLayoutChoice();
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))
+ if (!text->selection.set()) {
+ xsel_cache_.set = false;
+ return;
+ }
+
+ if (!xsel_cache_.set ||
+ text->cursor != xsel_cache_.cursor ||
+ text->selection.cursor != xsel_cache_.selection_cursor)
{
- bv_->text()->xsel_cache = text->selection;
+ xsel_cache_.cursor = text->cursor;
+ xsel_cache_.selection_cursor = text->selection.cursor;
+ xsel_cache_.set = text->selection.set();
sel = text->selectionAsString(*bv_->buffer(), false);
- } else if (!text->selection.set()) {
- sel = string();
- bv_->text()->xsel_cache.set(false);
- }
- if (!sel.empty()) {
- workarea().putClipboard(sel);
- }
+ if (!sel.empty())
+ workarea().putClipboard(sel);
+ }
}
if (available()) {
screen().hideCursor();
bv_->getLyXText()->clearSelection();
- bv_->text()->xsel_cache.set(false);
+ xsel_cache_.set = false;
}
}
if (!text->selection.set())
return Change(Change::UNCHANGED);
- return text->getPar(text->selection.start)
- ->lookupChangeFull(text->selection.start.pos());
+ return text->getPar(text->selStart())
+ ->lookupChangeFull(text->selStart().pos());
}
text->clearSelection();
int const half_height = workarea().workHeight() / 2;
- int new_y = std::max(0, text->cursor.y() - half_height);
+ int new_y = std::max(0, text->cursorY() - half_height);
// FIXME: look at this comment again ...
// This updates top_y() but means the fitCursor() call
Buffer::inset_iterator beg = b->inset_iterator_begin();
Buffer::inset_iterator end = b->inset_iterator_end();
- bool cursorPar_seen = false;
+ bool cursor_par_seen = false;
for (; beg != end; ++beg) {
if (beg.getPar() == text->cursorPar()) {
- cursorPar_seen = true;
+ cursor_par_seen = true;
}
- if (cursorPar_seen) {
+ if (cursor_par_seen) {
if (beg.getPar() == text->cursorPar()
&& beg.getPos() >= text->cursor.pos()) {
break;
InsetOld * insetFromCoords(BufferView * bv, int x, int y)
{
+ lyxerr << "insetFromCoords" << endl;
LyXText * text = bv->text();
InsetOld * inset = 0;
theTempCursor = LCursor(bv);
while (true) {
- InsetOld * inset_hit = text->checkInsetHit(x, y);
+ InsetOld * const inset_hit = text->checkInsetHit(x, y);
if (!inset_hit) {
lyxerr << "no further inset hit" << endl;
break;
}
inset = inset_hit;
- if (!inset_hit->descendable()) {
+ if (!inset->descendable()) {
lyxerr << "not descendable" << endl;
break;
}
- text = inset_hit->getText(0);
+ int const cell = inset->getCell(x, y + bv->top_y());
+ if (cell == -1)
+ break;
+ text = inset_hit->getText(cell);
lyxerr << "Hit inset: " << inset << " at x: " << x
<< " text: " << text << " y: " << y << endl;
theTempCursor.push(static_cast<UpdatableInset*>(inset));
{
switch (cmd.action) {
case LFUN_MOUSE_MOTION: {
+ if (!available())
+ return false;
FuncRequest cmd1(cmd, bv_);
UpdatableInset * inset = bv_->cursor().innerInset();
DispatchResult res;
mathDispatch(ev);
break;
- case LFUN_INSET_APPLY: {
-#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);
- string const name = ev.getArg(0);
-
- InsetBase * inset = owner_->getDialogs().getOpenInset(name);
- if (inset) {
- // This works both for 'original' and 'mathed' insets.
- // Note that the localDispatch performs update also.
- FuncRequest fr(bv_, LFUN_INSET_MODIFY, ev.argument);
- inset->dispatch(fr);
- } else {
- FuncRequest fr(bv_, LFUN_INSET_INSERT, ev.argument);
- dispatch(fr);
- }
- }
- break;
-
case LFUN_INSET_INSERT: {
// Same as above.
BOOST_ASSERT(false);
bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
{
-#ifdef LOCK
- // 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()) {
- if (bv_->theLockingInset()->insetAllowed(inset))
- return bv_->theLockingInset()->insertInset(bv_, inset);
- return false;
- }
-#endif
-
// not quite sure if we want this...
bv_->text()->recUndo(bv_->text()->cursor.par());
freezeUndo();