}
-void BufferView::updateInset(InsetOld const * inset)
-{
- pimpl_->updateInset(inset);
-}
-
-
bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
{
// Check if the label 'from' appears more than once
bool fitCursor();
/// perform pending painting updates
void update();
- /** update for a particular inset. Gets a pointer and not a
- * reference because we really need the pointer information
- * to find it in the buffer.
- *
- * Extracted from Matthias notes:
- *
- * If a inset wishes any redraw and/or update it just has to call
- * updateInset(this). It's is completly irrelevant, where the inset is.
- * UpdateInset will find it in any paragraph in any buffer.
- * Of course the insets in the current paragraph/buffer
- * are checked first, so no performance problem should occur.
- */
- void updateInset(InsetOld const *);
/// reset the scrollbar to reflect current view position
void updateScrollbar();
/// FIXME
bool dispatch(FuncRequest const & argument);
/// set target x position of cursor
- void BufferView::x_target(int x);
+ void x_target(int x);
/// return target x position of cursor
- int BufferView::x_target() const;
+ int x_target() const;
/// access to cursor
LCursor & cursor();
{
//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
bv_->getLyXText()->redoCursor();
+
+ // update all 'visible' paragraphs
+ ParagraphList::iterator beg, end;
+ getVisiblePars(beg, end);
+ bv_->text->redoParagraphs(beg, end);
+
+ updateScrollbar();
}
screen().redraw(*bv_);
}
cmd2.y -= inset->y();
res = inset->dispatch(cmd2);
if (res.update())
- bv_->updateInset(inset);
+ bv_->update();
res.update(false);
}
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)) {
}
-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);
}
+
+
+void BufferView::Pimpl::getVisiblePars
+ (ParagraphList::iterator & beg, ParagraphList::iterator & end)
+{
+ beg = bv_->text->cursorPar();
+ end = beg;
+
+ for ( ; beg != bv_->text->ownerParagraphs().begin(); --beg)
+ if (beg->y - top_y() < 0)
+ break;
+
+ if (beg != bv_->text->ownerParagraphs().begin())
+ --beg;
+
+ for ( ; end != bv_->text->ownerParagraphs().end(); ++end)
+ if (end->y - top_y() > workarea().workHeight())
+ break;
+}
void center();
///
bool insertInset(InsetOld * inset, std::string const & lout = std::string());
- ///
- void updateInset(InsetOld const * inset);
/// a function should be executed from the workarea
bool workAreaDispatch(FuncRequest const & ev);
/// a function should be executed
void MenuInsertLyXFile(std::string const & filen);
/// our workarea
WorkArea & workarea() const;
+ /// range of visible main text paragraphs
+ void getVisiblePars(ParagraphList::iterator &, ParagraphList::iterator &);
+
///
LCursor cursor_;
};
+2003-11-10 André Pönitz <poenitz@gmx.net>
+
+ * BufferView.[Ch]:
+ * BufferView_pimpl.[Ch]: merge update() and updateInset()
+
2003-11-10 André Pönitz <poenitz@gmx.net>
* lfuns.h: new LFUN_FINISHED_LEFT, LFUN_FINISHED_RIGHT,
return text->changeDepth(type, true);
bool const changed = text->changeDepth(type, false);
- if (text->inset_owner)
- bv->updateInset(text->inset_owner);
+ bv->update();
return changed;
}
lyxerr << "trying to dispatch to inset " << citem.inset_ << endl;
DispatchResult res = citem.inset_->dispatch(cmd);
if (res.update())
- bv_->updateInset(citem.inset_);
+ bv_->update();
if (res.dispatched()) {
lyxerr << " successfully dispatched to inset " << citem.inset_ << endl;
return DispatchResult(true, true);
Buffer const * buffer_ptr = 0;
if (inset) {
buffer_ptr = bufferview_->buffer();
- bufferview_->updateInset(inset);
+ bufferview_->update();
}
return buffer_ptr;
}
if (p.getCmdName().empty())
return DispatchResult(true, true);
setParams(p);
- cmd.view()->updateInset(this);
+ cmd.view()->update();
cmd.view()->fitCursor();
return DispatchResult(true, true);
}
lyxerr << "InsetBox::dispatch MODIFY" << endl;
InsetBoxMailer::string2params(cmd.argument, params_);
setButtonLabel();
- bv->updateInset(this);
result.dispatched(true);
result.update(true);
return result;
InsetBranchMailer::string2params(cmd.argument, params);
params_.branch = params.branch;
setButtonLabel();
- bv->updateInset(this);
return DispatchResult(true, true);
}
collapsed_ = false;
edit(bv, true);
bv->buffer()->markDirty();
- bv->updateInset(this);
bv->update();
return result;
}
return result;
}
result.update(true);
- bv->updateInset(this);
+ bv->update();
bv->buffer()->markDirty();
} else if (!collapsed_ && cmd.y > button_dim.y2) {
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
collapsed_ = false;
// set this only here as it should be recollapsed only if
// it was already collapsed!
- bv->updateInset(this);
+ bv->update();
bv->buffer()->markDirty();
inset.edit(bv, x, y);
} else {
return;
collapsed_ = false;
- bv->updateInset(this);
+ bv->update();
}
return;
collapsed_ = true;
- bv->updateInset(this);
+ bv->update();
}
return DispatchResult(false);
setParams(p);
- cmd.view()->updateInset(this);
+ cmd.view()->update();
return DispatchResult(true, true);
}
InsetERT::ERTStatus status_;
InsetERTMailer::string2params(cmd.argument, status_);
status(bv, status_);
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
break;
}
if (bv) {
- bv->updateInset(this);
+ bv->update();
bv->buffer()->markDirty();
}
}
InsetExternalParams p;
InsetExternalMailer::string2params(cmd.argument, buffer, p);
setParams(p, buffer);
- cmd.view()->updateInset(this);
+ cmd.view()->update();
return DispatchResult(true, true);
}
params_.wide = params.wide;
wide(params_.wide, cmd.view()->buffer()->params());
- cmd.view()->updateInset(this);
+ cmd.view()->update();
return DispatchResult(true, true);
}
InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
if (!p.filename.empty()) {
setParams(p);
- cmd.view()->updateInset(this);
+ cmd.view()->update();
}
return DispatchResult(true, true);
}
InsetIncludeMailer::string2params(cmd.argument, p);
if (!p.getCmdName().empty()) {
set(p, *cmd.view()->buffer());
- cmd.view()->updateInset(this);
+ cmd.view()->update();
}
return DispatchResult(true, true);
}
}
setParams(p);
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
InsetMinipageMailer::string2params(cmd.argument, params);
params_.pos = params.pos;
params_.width = params.width;
- cmd.view()->updateInset(this);
+ cmd.view()->update();
return DispatchResult(true, true);
}
case LFUN_INSET_MODIFY: {
InsetNoteMailer::string2params(cmd.argument, params_);
setButtonLabel();
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
void InsetTabular::updateLocal(BufferView * bv) const
{
- bv->updateInset(this);
+ bv->update();
resetPos(bv);
}
scroll(cmd.view(), static_cast<float>(strToDbl(cmd.argument)));
else
scroll(cmd.view(), strToInt(cmd.argument));
- cmd.view()->updateInset(this);
+ cmd.view()->update();
return DispatchResult(true, true);
}
text_.selection.cursor = text_.cursor;
bv->fitCursor();
- bv->updateInset(this);
+ bv->update();
bv->owner()->view_state_changed();
bv->owner()->updateMenubar();
bv->owner()->updateToolbar();
params_.placement = params.placement;
params_.width = params.width;
- cmd.view()->updateInset(this);
+ cmd.view()->update();
return DispatchResult(true, true);
}
scroll(cmd.view(), static_cast<float>(strToDbl(cmd.argument)));
else
scroll(cmd.view(), strToInt(cmd.argument));
- cmd.view()->updateInset(this);
+ cmd.view()->update();
return DispatchResult(true, true);
}
void InsetFormulaBase::insetUnlock(BufferView * bv)
{
if (mathcursor) {
- if (mathcursor->inMacroMode()) {
+ if (mathcursor->inMacroMode())
mathcursor->macroModeClose();
- bv->updateInset(this);
- }
releaseMathCursor(bv);
}
if (bv->buffer())
generatePreview(*bv->buffer());
- bv->updateInset(this);
+ bv->update();
}
void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
{
if (mathcursor)
- bv->updateInset(this);
+ bv->update();
}
return DispatchResult(false);
BufferView * bv = cmd.view();
- bv->updateInset(this);
+ bv->update();
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
if (cmd.button() == mouse_button::button3) {
mathcursor->selClear();
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
mathcursor->insert(ar);
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
return DispatchResult(true, true);
}
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
BufferView * bv = cmd.view();
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
bv->cursor().push(this);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
- bv->updateInset(this);
+ bv->update();
}
bv->cursor().push(this);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
- bv->updateInset(this);
+ bv->update();
}
}
if (result == DispatchResult(true, true))
- bv->updateInset(this);
+ bv->update();
mathcursor->normalize();
mathcursor->touch();
mathcursor->setSelection(it, ar.size());
current = it;
it.jump(ar.size());
- bv->updateInset(this);
+ bv->update();
return true;
}
}
else
inset->open(bv());
- bv()->updateInset(inset);
+ bv()->update();
}
setCursor(selection.end.par(), selection.end.pos());
setSelection();
setCursor(tmpcursor.par(), tmpcursor.pos());
- if (inset_owner)
- bv()->updateInset(inset_owner);
+ bv()->update();
}
InsetList::iterator iend = pit->insetlist.end();
for ( ; iit != iend; ++iit) {
InsetOld * inset = iit->inset;
- lyxerr << "examining inset " << inset
- << " xy: " << inset->x() << "/" << inset->y()
- << " x: " << inset->x() << "..." << inset->x() + inset->width()
- << " y: " << inset->y() - inset->ascent() << "..."
- << inset->y() + inset->descent()
- << endl;
+ //lyxerr << "examining inset " << inset
+ // << " xy: " << inset->x() << "/" << inset->y()
+ // << " x: " << inset->x() << "..." << inset->x() + inset->width()
+ // << " y: " << inset->y() - inset->ascent() << "..."
+ // << inset->y() + inset->descent()
+ // << endl;
if (x >= inset->x()
&& x <= inset->x() + inset->width()
&& y >= inset->y() - inset->ascent()
if (!bv->insertInset(new_inset))
delete new_inset;
else
- bv->updateInset(new_inset);
+ bv->update();
}