resizeCurrentBuffer();
// FIXME: needed when ?
- top_y(screen().topCursorVisible(bv_->text));
+ fitCursor();
// Buffer-dependent dialogs should be updated or
// hidden. This should go here because some dialogs (eg ToC)
bool BufferView::Pimpl::fitCursor()
{
lyxerr << "BufferView::Pimpl::fitCursor." << endl;
- bool ret;
-
-#ifndef LOCK
- UpdatableInset * tli =
- static_cast<UpdatableInset *>(cursor_.innerInset());
- if (tli) {
- tli->fitInsetCursor(bv_);
- ret = true;
- } else {
- ret = screen().fitCursor(bv_->text, bv_);
+ if (screen().fitCursor(bv_)) {
+ updateScrollbar();
+ return true;
}
-#else
- ret = screen().fitCursor(bv_->text, bv_);
-#endif
-
- //dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
-
- // We need to always update, in case we did a
- // paste and we stayed anchored to a row, but
- // the actual height of the doc changed ...
- updateScrollbar();
- return ret;
+ return false;
}
resizeCurrentBuffer();
updateScrollbar();
owner_->updateLayoutChoice();
- update();
}
}
}
}
- top_y(screen().topCursorVisible(bv_->text));
+ fitCursor();
switchKeyMap();
owner_->busy(false);
{
//lyxerr << "BufferView::update()" << endl;
// fix cursor coordinate cache in case something went wrong
+
+ // check needed to survive LyX startup
if (bv_->getLyXText()) {
- // check needed to survive LyX startup
+ // update all 'visible' paragraphs
+ ParagraphList::iterator beg;
+ ParagraphList::iterator end;
+ getParsInRange(buffer_->paragraphs(),
+ top_y(), top_y() + workarea().workHeight(),
+ beg, end);
+ bv_->text->redoParagraphs(beg, end);
bv_->getLyXText()->redoCursor();
+ updateScrollbar();
}
screen().redraw(*bv_);
}
bv_->text->setCursor(par.pit(),
min(par->size(), saved_positions[i].par_pos));
- update();
if (i > 0)
owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
}
// updateScrollbar() currently. Never mind that this is a
// pretty obfuscated way of updating t->top_y()
top_y(new_y);
- update();
}
update();
bv_->text->setCursor(0, 0);
#warning changes FIXME
- //moveCursorUpdate(false);
-
bool found = lyx::find::findNextChange(bv_);
if (found) {
owner_->getDialogs().show("changes");
{
LyXText * text = bv->text;
InsetOld * inset = 0;
- InsetOld * inset_hit = 0;
theTempCursor = LCursor(bv);
- while ((inset_hit = text->checkInsetHit(x, y))) {
+ while (true) {
+ InsetOld * inset_hit = text->checkInsetHit(x, y);
+ if (!inset_hit)
+ break;
inset = inset_hit;
+ if (!inset_hit->descendable())
+ break;
text = inset_hit->getText(0);
lyxerr << "Hit inset: " << inset << " at x: " << x
- << " y: " << y << endl;
+ << " text: " << text << " y: " << y << endl;
theTempCursor.push(static_cast<UpdatableInset*>(inset));
}
return inset;
cmd2.x -= inset->x();
cmd2.y -= inset->y();
res = inset->dispatch(cmd2);
- if (res.update())
- bv_->updateInset(inset);
+ if (res.update()) {
+ bv_->update();
+ bv_->cursor().updatePos();
+ }
res.update(false);
+ switch (res.val()) {
+ case FINISHED:
+ case FINISHED_RIGHT:
+ case FINISHED_UP:
+ case FINISHED_DOWN:
+ theTempCursor.pop();
+ bv_->cursor() = theTempCursor;
+ bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
+ if (bv_->fitCursor())
+ bv_->update();
+ return true;
+ default:
+ lyxerr << "not dispatched by inner inset val: " << res.val() << endl;
+ break;
+ }
}
// otherwise set cursor to surrounding LyXText
if (!res.dispatched()) {
- lyxerr << "cursor is: " << bv_->cursor() << endl;
- lyxerr << "dispatching to surrounding LyXText "
- << bv_->cursor().innerText() << endl;
- bv_->cursor().innerText()->dispatch(cmd1);
+ lyxerr << "temp cursor is: " << theTempCursor << endl;
+ lyxerr << "dispatching " << cmd1
+ << " to surrounding LyXText "
+ << theTempCursor.innerText() << endl;
+ bv_->cursor() = theTempCursor;
+ res = bv_->cursor().innerText()->dispatch(cmd1);
+ if (bv_->fitCursor() || res.update())
+ bv_->update();
+
//return DispatchResult(true, true);
}
-
// see workAreaKeyPress
cursor_timeout.restart();
screen().showCursor(*bv_);
- // FIXME: we should skip these when selecting
- owner_->updateLayoutChoice();
- owner_->updateToolbar();
- fitCursor();
+ // skip these when selecting
+ if (cmd.action != LFUN_MOUSE_MOTION) {
+ owner_->updateLayoutChoice();
+ owner_->updateToolbar();
+ }
// slight hack: this is only called currently when we
// clicked somewhere, so we force through the display
InsetBase * inset = owner_->getDialogs().getOpenInset(name);
if (inset) {
// This works both for 'original' and 'mathed' insets.
- // Note that the localDispatch performs updateInset
- // also.
+ // Note that the localDispatch performs update also.
FuncRequest fr(bv_, LFUN_INSET_MODIFY, ev.argument);
inset->dispatch(fr);
} else {
case LFUN_INSET_INSERT: {
InsetOld * inset = createInset(ev);
- if (inset && insertInset(inset)) {
- updateInset(inset);
-
- string const name = ev.getArg(0);
- if (name == "bibitem") {
- // We need to do a redraw because the maximum
- // InsetBibitem width could have changed
-#warning check whether the update() is needed at all
- bv_->update();
- }
- } else {
+ if (!inset || !insertInset(inset))
delete inset;
- }
+ break;
}
- break;
case LFUN_FLOAT_LIST:
if (tclass.floats().typeExist(ev.argument)) {
case LFUN_ACCEPT_ALL_CHANGES: {
bv_->text->setCursor(0, 0);
#warning FIXME changes
- //moveCursorUpdate(false);
-
while (lyx::find::findNextChange(bv_))
bv_->getLyXText()->acceptChange();
-
update();
break;
}
case LFUN_REJECT_ALL_CHANGES: {
bv_->text->setCursor(0, 0);
#warning FIXME changes
- //moveCursorUpdate(false);
-
while (lyx::find::findNextChange(bv_))
bv_->getLyXText()->rejectChange();
-
update();
break;
}
string(),
0);
}
-
bv_->cursor().innerText()->insertInset(inset);
- update();
-
unFreezeUndo();
return true;
}
-void BufferView::Pimpl::updateInset(InsetOld const * /*inset*/)
-{
- if (!available())
- return;
-
-#warning used for asynchronous updates?
- //bv_->text->redoParagraph(outerPar(*bv_->buffer(), inset));
-
- // this should not be needed, but it is...
- bv_->text->redoParagraph(bv_->text->cursorPar());
- // bv_->text->fullRebreak();
-
- update();
- updateScrollbar();
-}
-
-
bool BufferView::Pimpl::ChangeInsets(InsetOld::Code code,
string const & from, string const & to)
{
data = "update " + tostr(accept) + '\n' + data;
bv_->owner()->getDialogs().update("paragraph", data);
}
+
+