diff --git a/src/BufferView.C b/src/BufferView.C index 50b493990e..a041a3d716 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -197,6 +197,12 @@ void BufferView::update(LyXText * text, UpdateCodes f) } +void BufferView::update(UpdateCodes f) +{ + pimpl_->update(f); +} + + void BufferView::switchKeyMap() { pimpl_->switchKeyMap(); @@ -554,7 +560,7 @@ bool BufferView::gotoLabel(string const & label) beforeChange(text); text->setCursor(it.getPar(), it.getPos()); text->selection.cursor = text->cursor; - update(text, BufferView::SELECT|BufferView::FITCUR); + update(text, BufferView::SELECT); return true; } } @@ -570,11 +576,11 @@ void BufferView::undo() owner()->message(_("Undo")); hideCursor(); beforeChange(text); - update(text, BufferView::SELECT|BufferView::FITCUR); + update(text, BufferView::SELECT); if (!textUndo(this)) owner()->message(_("No further undo information")); else - update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(text, BufferView::SELECT); switchKeyMap(); } @@ -587,11 +593,11 @@ void BufferView::redo() owner()->message(_("Redo")); hideCursor(); beforeChange(text); - update(text, BufferView::SELECT|BufferView::FITCUR); + update(text, BufferView::SELECT); if (!textRedo(this)) owner()->message(_("No further redo information")); else - update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(text, BufferView::SELECT); switchKeyMap(); } @@ -610,7 +616,7 @@ void BufferView::pasteEnvironment() if (available()) { text->pasteEnvironmentType(); owner()->message(_("Paragraph environment type set")); - update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(text, BufferView::SELECT); } } @@ -638,7 +644,7 @@ void BufferView::selectLastWord() text->selection.cursor = cur; text->selectSelectedWord(); toggleSelection(false); - update(text, BufferView::SELECT|BufferView::FITCUR); + update(text, BufferView::SELECT); } @@ -650,7 +656,7 @@ void BufferView::endOfSpellCheck() beforeChange(text); text->selectSelectedWord(); text->clearSelection(); - update(text, BufferView::SELECT|BufferView::FITCUR); + update(text, BufferView::SELECT); } @@ -661,11 +667,11 @@ void BufferView::replaceWord(string const & replacestring) LyXText * tt = getLyXText(); hideCursor(); - update(tt, BufferView::SELECT|BufferView::FITCUR); + update(tt, BufferView::SELECT); // clear the selection (if there is any) toggleSelection(false); - update(tt, BufferView::SELECT|BufferView::FITCUR); + update(tt, BufferView::SELECT); // clear the selection (if there is any) toggleSelection(false); @@ -677,7 +683,11 @@ void BufferView::replaceWord(string const & replacestring) for (string::size_type i = 0; i < replacestring.length() + 1; ++i) { tt->cursorLeft(this); } - update(tt, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(tt, BufferView::SELECT); + + // FIXME: should be done through LFUN + buffer()->markDirty(); + fitCursor(); } // End of spellchecker stuff @@ -814,9 +824,9 @@ void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind) } -void BufferView::updateInset(Inset * inset, bool mark_dirty) +void BufferView::updateInset(Inset * inset) { - pimpl_->updateInset(inset, mark_dirty); + pimpl_->updateInset(inset); } diff --git a/src/BufferView.h b/src/BufferView.h index a7398d0777..1dba8da275 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -44,10 +44,8 @@ public: * of the document rendering. */ enum UpdateCodes { - UPDATE = 0, //< FIXME - SELECT = 1, //< selection change - FITCUR = 2, //< the cursor needs fitting into the view - CHANGE = 4 //< document data has changed + UPDATE = 0, //< repaint + SELECT = 1 //< reset selection to current cursor pos }; /** @@ -88,8 +86,10 @@ public: void update(); // update for a particular lyxtext void update(LyXText *, UpdateCodes uc); + /// update for the top-level lyxtext + void update(UpdateCodes uc); /// update for a particular inset - void updateInset(Inset * inset, bool mark_dirty); + void updateInset(Inset * inset); /// reset the scrollbar to reflect current view position void updateScrollbar(); /// FIXME diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index d90fc5578d..77bb954640 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -530,43 +530,6 @@ void BufferView::Pimpl::update() } } -// Values used when calling update: -// -3 - update -// -2 - update, move sel_cursor if selection, fitcursor -// -1 - update, move sel_cursor if selection, fitcursor, mark dirty -// 0 - update, move sel_cursor if selection, fitcursor -// 1 - update, move sel_cursor if selection, fitcursor, mark dirty -// 3 - update, move sel_cursor if selection -// -// update - -// a simple redraw of the parts that need refresh -// -// move sel_cursor if selection - -// the text's sel_cursor is moved if there is selection is progress -// -// fitcursor - -// fitCursor() is called and the scrollbar updated -// -// mark dirty - -// the buffer is marked dirty. -// -// enum { -// UPDATE = 0, -// SELECT = 1, -// FITCUR = 2, -// CHANGE = 4 -// }; -// -// UPDATE_ONLY = UPDATE; -// UPDATE_SELECT = UPDATE | SELECT; -// UPDATE_SELECT_MOVE = UPDATE | SELECT | FITCUR; -// UPDATE_SELECT_MOVE_AFTER_CHANGE = UPDATE | SELECT | FITCUR | CHANGE; -// -// update(-3) -> update(0) -> update(0) -> update(UPDATE) -// update(-2) -> update(1 + 2) -> update(3) -> update(SELECT|FITCUR) -// update(-1) -> update(1 + 2 + 4) -> update(7) -> update(SELECT|FITCUR|CHANGE) -// update(1) -> update(1 + 2 + 4) -> update(7) -> update(SELECT|FITCUR|CHANGE) -// update(3) -> update(1) -> update(1) -> update(SELECT) void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f) { @@ -578,17 +541,28 @@ void BufferView::Pimpl::update(LyXText * text, BufferView::UpdateCodes f) if (text->inset_owner) { text->inset_owner->setUpdateStatus(bv_, InsetText::NONE); - updateInset(text->inset_owner, false); + updateInset(text->inset_owner); } else { update(); } +} - if ((f & FITCUR)) { - fitCursor(); + +void BufferView::Pimpl::update(BufferView::UpdateCodes f) +{ + LyXText * text = bv_->text; + + if (!text->selection.set() && (f & SELECT)) { + text->selection.cursor = text->cursor; } - if ((f & CHANGE)) { - buffer_->markDirty(); + text->fullRebreak(); + + if (text->inset_owner) { + text->inset_owner->setUpdateStatus(bv_, InsetText::NONE); + updateInset(text->inset_owner); + } else { + update(); } } @@ -683,7 +657,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i) bv_->text->setCursor(par, min(par->size(), saved_positions[i].par_pos)); - update(bv_->text, BufferView::SELECT | BufferView::FITCUR); + update(BufferView::SELECT); if (i > 0) { ostringstream str; #if USE_BOOST_FORMAT @@ -776,6 +750,8 @@ void BufferView::Pimpl::center() new_y = t->cursor.y() - half_height; } + // FIXME: look at this comment again ... + // FIXME: can we do this w/o calling screen directly ? // This updates top_y() but means the fitCursor() call // from the update(FITCUR) doesn't realise that we might @@ -787,7 +763,7 @@ void BufferView::Pimpl::center() // pretty obfuscated way of updating t->top_y() screen().draw(t, bv_, new_y); - update(t, BufferView::SELECT | BufferView::FITCUR); + update(BufferView::SELECT); } @@ -939,7 +915,7 @@ void BufferView::Pimpl::trackChanges() // we cannot allow undos beyond the freeze point buf->undostack.clear(); } else { - bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); + update(BufferView::SELECT); bv_->text->setCursor(&(*buf->paragraphs.begin()), 0); #warning changes FIXME //moveCursorUpdate(false); @@ -1131,10 +1107,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) owner_->getLyXFunc().handleKeyFunc(ev.action); owner_->getIntl().getTransManager() .TranslateAndInsert(ev.argument[0], bv_->getLyXText()); - update(bv_->getLyXText(), - BufferView::SELECT - | BufferView::FITCUR - | BufferView::CHANGE); + update(bv_->getLyXText(), BufferView::SELECT); } break; @@ -1162,7 +1135,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) } else { Inset * inset = createInset(ev); if (inset && insertInset(inset)) { - updateInset(inset, true); + updateInset(inset); } else { delete inset; } @@ -1255,7 +1228,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) break; case LFUN_ACCEPT_ALL_CHANGES: { - bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); + update(BufferView::SELECT); bv_->text->setCursor(&(*bv_->buffer()->paragraphs.begin()), 0); #warning FIXME changes //moveCursorUpdate(false); @@ -1263,13 +1236,12 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) while (lyxfind::findNextChange(bv_)) { bv_->getLyXText()->acceptChange(); } - update(bv_->text, - BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + update(BufferView::SELECT); break; } case LFUN_REJECT_ALL_CHANGES: { - bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); + update(BufferView::SELECT); bv_->text->setCursor(&(*bv_->buffer()->paragraphs.begin()), 0); #warning FIXME changes //moveCursorUpdate(false); @@ -1277,22 +1249,19 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) while (lyxfind::findNextChange(bv_)) { bv_->getLyXText()->rejectChange(); } - update(bv_->text, - BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + update(BufferView::SELECT); break; } case LFUN_ACCEPT_CHANGE: { bv_->getLyXText()->acceptChange(); - update(bv_->text, - BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + update(BufferView::SELECT); break; } case LFUN_REJECT_CHANGE: { bv_->getLyXText()->rejectChange(); - update(bv_->text, - BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + update(BufferView::SELECT); break; } @@ -1324,15 +1293,15 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout) beforeChange(bv_->text); if (!lout.empty()) { - update(bv_->text, BufferView::SELECT|BufferView::FITCUR); + update(BufferView::SELECT); bv_->text->breakParagraph(bv_->buffer()->paragraphs); - update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(BufferView::SELECT); if (!bv_->text->cursor.par()->empty()) { bv_->text->cursorLeft(bv_); bv_->text->breakParagraph(bv_->buffer()->paragraphs); - update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(BufferView::SELECT); } string lres = lout; @@ -1358,18 +1327,18 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout) LYX_ALIGN_LAYOUT, string(), 0); - update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(BufferView::SELECT); } bv_->text->insertInset(inset); - update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + update(BufferView::SELECT); unFreezeUndo(); return true; } -void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty) +void BufferView::Pimpl::updateInset(Inset * inset) { if (!inset || !available()) return; @@ -1379,18 +1348,12 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty) if (bv_->theLockingInset() == inset) { if (bv_->text->updateInset(inset)) { update(); - if (mark_dirty) { - buffer_->markDirty(); - } updateScrollbar(); return; } } else if (bv_->theLockingInset()->updateInsetInInset(bv_, inset)) { if (bv_->text->updateInset(bv_->theLockingInset())) { update(); - if (mark_dirty) { - buffer_->markDirty(); - } updateScrollbar(); return; } @@ -1405,16 +1368,9 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty) tl_inset = tl_inset->owner(); hideCursor(); if (tl_inset == inset) { - update(bv_->text, BufferView::UPDATE); + update(BufferView::UPDATE); if (bv_->text->updateInset(inset)) { - if (mark_dirty) { - update(bv_->text, - BufferView::SELECT - | BufferView::FITCUR - | BufferView::CHANGE); - } else { - update(bv_->text, SELECT); - } + update(BufferView::SELECT); return; } } else if (static_cast(tl_inset) diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index e011a08990..2cb7730d40 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -47,6 +47,8 @@ struct BufferView::Pimpl : public boost::signals::trackable { void update(); // void update(LyXText *, BufferView::UpdateCodes); + /// update the toplevel lyx text + void update(BufferView::UpdateCodes); /** * Repaint pixmap. Used for when we've made a visible * change but don't need the full update() logic @@ -99,7 +101,7 @@ struct BufferView::Pimpl : public boost::signals::trackable { /// bool insertInset(Inset * inset, string const & lout = string()); /// - void updateInset(Inset * inset, bool mark_dirty); + void updateInset(Inset * inset); /// bool dispatch(FuncRequest const & ev); private: diff --git a/src/ChangeLog b/src/ChangeLog index e281448021..5b5f8b3110 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,26 @@ +2003-03-19 John Levon + + * lyxfunc.C: mark buffer dirty if we executed a "dirtying" lfun. + fit the cursor after an lfun + + * BufferView.h: + * BufferView.C: + * BufferView_pimpl.h: + * BufferView_pimpl.C: remove BufferView::FITCUR/CHANGE + + * LyXAction.C: layout-character should have ReadOnly + + * ParagraphParameters.C: + * buffer.C: + * bufferview_funcs.C: + * lyx_cb.C: + * lyxfind.C: + * lyxtext.h: + * text.C: + * text2.C: + * text3.C: + * undo_funcs.C: changes from above + 2003-03-18 John Levon * BufferView_pimpl.C (scrollDocView): add updateLayoutChoice(), diff --git a/src/LyXAction.C b/src/LyXAction.C index 8b5615df50..5bf1edd779 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -240,7 +240,7 @@ void LyXAction::init() { LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"), ReadOnly }, { LFUN_LAYOUT, "layout", "", Noop }, - { LFUN_LAYOUT_CHARACTER, "layout-character", "", Noop }, + { LFUN_LAYOUT_CHARACTER, "layout-character", "", ReadOnly }, { LFUN_LAYOUT_COPY, "layout-copy", N_("Copy paragraph environment type"), Noop }, { LFUN_LAYOUT_DOCUMENT, "layout-document", "", ReadOnly }, diff --git a/src/ParagraphParameters.C b/src/ParagraphParameters.C index b24aae0fd5..aca07b6b94 100644 --- a/src/ParagraphParameters.C +++ b/src/ParagraphParameters.C @@ -438,12 +438,7 @@ void setParagraphParams(BufferView & bv, string const & data) params.noindent()); // Actually apply these settings - bv.update(text, - BufferView::SELECT | - BufferView::FITCUR | - BufferView::CHANGE); - - bv.buffer()->markDirty(); + bv.update(text, BufferView::SELECT); bv.owner()->message(_("Paragraph layout set")); } diff --git a/src/buffer.C b/src/buffer.C index 358f27bc53..d0f4436673 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -338,7 +338,6 @@ bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator pit) } else { // We are inserting into an existing document users->text->breakParagraph(paragraphs); - markDirty(); // We don't want to adopt the parameters from the // document we insert, so read them into a temporary buffer diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index d4e7acb404..373004ed0e 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -177,7 +177,6 @@ void apply_freefont(BufferView * bv) { toggleAndShow(bv, freefont, toggleall); bv->owner()->view_state_changed(); - bv->buffer()->markDirty(); bv->owner()->message(_("Character set")); } @@ -234,14 +233,14 @@ void changeDepth(BufferView * bv, LyXText * text, int decInc) return; bv->hideCursor(); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR); + bv->update(BufferView::SELECT); if (decInc >= 0) text->incDepth(); else text->decDepth(); if (text->inset_owner) - bv->updateInset((Inset *)text->inset_owner, true); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + bv->updateInset((Inset *)text->inset_owner); + bv->update(BufferView::SELECT); } @@ -397,9 +396,9 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall) return; bv->hideCursor(); - bv->update(text, BufferView::SELECT | BufferView::FITCUR); + bv->update(text, BufferView::SELECT); text->toggleFree(font, toggleall); - bv->update(text, BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + bv->update(text, BufferView::SELECT); if (font.language() != ignore_language || font.number() != LyXFont::IGNORE) { diff --git a/src/graphics/PreviewedInset.C b/src/graphics/PreviewedInset.C index 2ee8774738..468d1f65ce 100644 --- a/src/graphics/PreviewedInset.C +++ b/src/graphics/PreviewedInset.C @@ -122,7 +122,7 @@ void PreviewedInset::imageReady(grfx::PreviewImage const & pimage) const pimage_ = &pimage; if (view()) - view()->updateInset(&inset_, false); + view()->updateInset(&inset_); } } // namespace grfx diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 3464d298e2..ddb3570ba6 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2003-03-19 John Levon + + * several files: bv->updateInset() doesn't take + a bool mark_dirty any more + 2003-03-17 Lars Gullik Bjønnes * adjust for BufferView* arg removal from lyxtext. diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 670c4d200e..7fb54eec61 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -66,7 +66,7 @@ dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) } setParams(p); - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 6796f5db48..8970efb576 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -63,7 +63,7 @@ dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd) } setParams(p); - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index f99bc2df90..1be8c4398c 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -24,6 +24,7 @@ #include "lyxtext.h" #include "WordLangTuple.h" #include "funcrequest.h" +#include "buffer.h" #include "frontends/font_metrics.h" #include "frontends/Painter.h" @@ -245,7 +246,8 @@ void InsetCollapsable::edit(BufferView * bv, int xp, int yp, first_after_edit = true; if (!bv->lockInset(this)) return; - bv->updateInset(this, false); + bv->updateInset(this); + bv->buffer()->markDirty(); inset.edit(bv); } else { if (!bv->lockInset(this)) @@ -273,7 +275,8 @@ void InsetCollapsable::edit(BufferView * bv, bool front) if (!bv->lockInset(this)) return; inset.setUpdateStatus(bv, InsetText::FULL); - bv->updateInset(this, false); + bv->updateInset(this); + bv->buffer()->markDirty(); inset.edit(bv, front); first_after_edit = true; } else { @@ -307,7 +310,7 @@ void InsetCollapsable::insetUnlock(BufferView * bv) inset.insetUnlock(bv); if (scroll()) scroll(bv, 0.0F); - bv->updateInset(this, false); + bv->updateInset(this); } @@ -337,11 +340,13 @@ bool InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd) // should not be called on inset open! // inset.insetButtonRelease(bv, 0, 0, button); inset.setUpdateStatus(bv, InsetText::FULL); - bv->updateInset(this, false); + bv->updateInset(this); + bv->buffer()->markDirty(); } else { collapsed_ = true; bv->unlockInset(this); - bv->updateInset(this, false); + bv->updateInset(this); + bv->buffer()->markDirty(); } } else if (!collapsed_ && (cmd.y > button_bottom_y)) { LyXFont font(LyXFont::ALL_SANE); @@ -624,7 +629,7 @@ void InsetCollapsable::open(BufferView * bv) if (!collapsed_) return; collapsed_ = false; - bv->updateInset(this, false); + bv->updateInset(this); } @@ -634,7 +639,7 @@ void InsetCollapsable::close(BufferView * bv) const return; collapsed_ = true; - bv->updateInset(const_cast(this), false); + bv->updateInset(const_cast(this)); } diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index c82a8e6d63..dd2ae21cc4 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -77,7 +77,7 @@ dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) break; setParams(p); - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 8513b19e8c..9261c351cd 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -445,7 +445,7 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd) InsetERTMailer::string2params(cmd.argument, status_); status(bv, status_); - bv->updateInset(this, true); + bv->updateInset(this); result = DISPATCHED; } break; @@ -640,8 +640,10 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const bv->unlockInset(const_cast(this)); break; } - if (bv) - bv->updateInset(const_cast(this), false); + if (bv) { + bv->updateInset(const_cast(this)); + bv->buffer()->markDirty(); + } } } diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 81980a9860..fd5fe30017 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -74,7 +74,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd) break; setFromParams(p); - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 4a261a507a..5e3ddf271a 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -165,7 +165,7 @@ dispatch_result InsetFloat::localDispatch(FuncRequest const & cmd) params_.placement = params.placement; params_.wide = params.wide; - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 817c23b8bb..63dc458487 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -230,7 +230,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd) string const filepath = cmd.view()->buffer()->filePath(); setParams(p, filepath); - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; @@ -835,7 +835,7 @@ void InsetGraphics::validate(LaTeXFeatures & features) const void InsetGraphics::statusChanged() { if (!cache_->view.expired()) - cache_->view.lock()->updateInset(this, false); + cache_->view.lock()->updateInset(this); } diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 53a560105e..ab4d2dc727 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -127,7 +127,7 @@ dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd) set(p); params_.masterFilename_ = cmd.view()->buffer()->fileName(); - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; @@ -624,7 +624,7 @@ void InsetInclude::PreviewImpl::restartLoading() lyxerr << "restartLoading()" << std::endl; removePreview(); if (view()) - view()->updateInset(&parent(), false); + view()->updateInset(&parent()); generatePreview(); } diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index bdb8ede6a5..66963db350 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -70,7 +70,7 @@ dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) } setParams(p); - cmd.view()->updateInset(this, !clean); + cmd.view()->updateInset(this); result = DISPATCHED; } break; diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 02d8a8f8ac..d61b119f65 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -117,7 +117,7 @@ dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd) params_.pos = params.pos; params_.width = params.width; - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index b0fface25d..c48a62b75f 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -535,7 +535,7 @@ void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what, need_update = what; // Dirty Cast! (Lgb) if (need_update != NONE) { - bv->updateInset(const_cast(this), mark_dirty); + bv->updateInset(const_cast(this)); if (locked) resetPos(bv); } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index cf899f5f27..3cfc909e55 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -586,7 +586,7 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) bv->fitCursor(); #endif if (flag) - bv->updateInset(const_cast(this), mark_dirty); + bv->updateInset(const_cast(this)); if (need_update == CURSOR) need_update = NONE; diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 92cdeaa4aa..b1d92c0d40 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -95,7 +95,7 @@ dispatch_result InsetWrap::localDispatch(FuncRequest const & cmd) params_.placement = params.placement; params_.width = params.width; - cmd.view()->updateInset(this, true); + cmd.view()->updateInset(this); result = DISPATCHED; } break; diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index 783f3c5dd0..9ba5820d56 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -110,8 +110,6 @@ void UpdatableInset::scroll(BufferView * bv, float s) const if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) { scx += (workW / 2) - (tmp_top_x + scx + width(bv, font)); } - - // bv->updateInset(const_cast(this), false); } void UpdatableInset::scroll(BufferView * bv, int offset) const @@ -134,7 +132,6 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const scx += offset; } } -// bv->updateInset(const_cast(this), false); } @@ -152,7 +149,7 @@ Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev) int const xx = strToInt(ev.argument); scroll(ev.view(), xx); } - ev.view()->updateInset(this, false); + ev.view()->updateInset(this); return DISPATCHED; } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 9c9c0c014f..df1a9530ef 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -408,8 +408,7 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph) else bv->getLyXText()->insertStringAsParagraphs(tmpstr); if (flag) - bv->update(bv->text, - BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + bv->update(BufferView::SELECT); } diff --git a/src/lyxfind.C b/src/lyxfind.C index 4615582731..77427ae82d 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -92,17 +92,21 @@ int LyXReplace(BufferView * bv, (text->inset_owner == text->inset_owner->getLockingInset()))) { bv->hideCursor(); - bv->update(text, BufferView::SELECT|BufferView::FITCUR); + bv->update(text, BufferView::SELECT); bv->toggleSelection(false); text->replaceSelectionWithString(replacestr); text->setSelectionRange(replacestr.length()); - bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + bv->update(text, BufferView::SELECT); ++replace_count; } if (!once) found = LyXFind(bv, searchstr, fw, casesens, matchwrd); } while (!once && replaceall && found); + // FIXME: should be called via an LFUN + bv->buffer()->markDirty(); + bv->fitCursor(); + return replace_count; } @@ -115,7 +119,7 @@ bool LyXFind(BufferView * bv, return false; bv->hideCursor(); - bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR); + bv->update(bv->getLyXText(), BufferView::SELECT); if (bv->theLockingInset()) { bool found = forward ? @@ -153,16 +157,18 @@ bool LyXFind(BufferView * bv, // inset did it already. if (result == SR_FOUND) { bv->unlockInset(bv->theLockingInset()); - bv->update(text, BufferView::SELECT|BufferView::FITCUR); + bv->update(text, BufferView::SELECT); text->setSelectionRange(searchstr.length()); bv->toggleSelection(false); - bv->update(text, BufferView::SELECT|BufferView::FITCUR); + bv->update(text, BufferView::SELECT); } else if (result == SR_NOT_FOUND) { bv->unlockInset(bv->theLockingInset()); - bv->update(text, BufferView::SELECT|BufferView::FITCUR); + bv->update(text, BufferView::SELECT); found = false; } + bv->fitCursor(); + return found; } @@ -383,7 +389,7 @@ bool findNextChange(BufferView * bv) return false; bv->hideCursor(); - bv->update(bv->getLyXText(), BufferView::SELECT | BufferView::FITCUR); + bv->update(bv->getLyXText(), BufferView::SELECT); pos_type length; @@ -421,16 +427,18 @@ bool findNextChange(BufferView * bv) // inset did it already. if (result == SR_FOUND) { bv->unlockInset(bv->theLockingInset()); - bv->update(text, BufferView::SELECT|BufferView::FITCUR); + bv->update(text, BufferView::SELECT); text->setSelectionRange(length); bv->toggleSelection(false); - bv->update(text, BufferView::SELECT|BufferView::FITCUR); + bv->update(text, BufferView::SELECT); } else if (result == SR_NOT_FOUND) { bv->unlockInset(bv->theLockingInset()); - bv->update(text, BufferView::SELECT|BufferView::FITCUR); + bv->update(text, BufferView::SELECT); found = false; } + bv->fitCursor(); + return found; } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 7c3436eee8..2e1e8656e2 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -125,7 +125,7 @@ void LyXFunc::moveCursorUpdate(bool flag, bool selecting) if (!TEXT(flag)->isInInset()) view()->toggleToggle(); } - view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR); + view()->update(TEXT(flag), BufferView::SELECT); view()->showCursor(); view()->switchKeyMap(); @@ -146,8 +146,7 @@ void LyXFunc::handleKeyFunc(kb_action action) // actions keyseq.clear(); // copied verbatim from do_accent_char - view()->update(TEXT(false), - BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + view()->update(TEXT(false), BufferView::SELECT); TEXT(false)->selection.cursor = TEXT(false)->cursor; } @@ -835,7 +834,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) moveCursorUpdate(true, false); owner->view_state_changed(); } else { - view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); + view()->update(TEXT(), BufferView::SELECT); } goto exit_with_message; } else if (result == FINISHED_DOWN) { @@ -948,8 +947,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) case LFUN_PREFIX: { if (view()->available() && !view()->theLockingInset()) { - view()->update(TEXT(), - BufferView::SELECT|BufferView::FITCUR); + view()->update(TEXT(), BufferView::SELECT); } owner->message(keyseq.printOptions()); } @@ -1580,6 +1578,12 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) } // end of switch view()->owner()->updateLayoutChoice(); + view()->fitCursor(); + + // If we executed a mutating lfun, mark the buffer as dirty + if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer) + && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly)) + view()->buffer()->markDirty(); exit_with_message: sendDispatchMessage(getMessage(), ev, verbose); diff --git a/src/lyxtext.h b/src/lyxtext.h index a7446769db..69e670251f 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -581,7 +581,7 @@ public: * with a dynamic left margin will be rebroken. */ void updateCounters(); /// - void update(bool changed = true); + void update(); /** * Returns an inset if inset was hit, or 0 if not. * If hit, the coordinates are changed relative to the inset. diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index a2bbcc57d0..9a61b32587 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,12 @@ +2003-03-19 John Levon + + * formulabase.h: + * formulabase.C: + * math_gridinset.C: + * math_hullinset.C: + * ref_inset.C: updateInset() doesn't take a bool + anymore + 2003-03-17 John Levon * formula.h: diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 16428223d7..171373abdc 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -127,15 +127,15 @@ void InsetFormulaBase::handleFont bv->lockedInsetStoreUndo(Undo::EDIT); if (mathcursor->par()->name() == font) { mathcursor->handleFont(font); - updateLocal(bv, true); + bv->updateInset(this); } else { bool sel = mathcursor->selection(); if (sel) - updateLocal(bv, true); + bv->updateInset(this); mathcursor->handleNest(createMathInset(font)); mathcursor->insert(arg); if (!sel) - updateLocal(bv, false); + bv->updateInset(this); } } @@ -185,7 +185,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state) mathcursor->setPos(x + xo_, y + yo_); // if that is removed, we won't get the magenta box when entering an // inset for the first time - bv->updateInset(this, false); + bv->updateInset(this); } @@ -196,7 +196,7 @@ void InsetFormulaBase::edit(BufferView * bv, bool front) releaseMathCursor(bv); mathcursor = new MathCursor(this, front); metrics(bv); - bv->updateInset(this, false); + bv->updateInset(this); } @@ -205,12 +205,12 @@ void InsetFormulaBase::insetUnlock(BufferView * bv) if (mathcursor) { if (mathcursor->inMacroMode()) { mathcursor->macroModeClose(); - updateLocal(bv, true); + bv->updateInset(this); } releaseMathCursor(bv); } generatePreview(); - bv->updateInset(this, false); + bv->updateInset(this); } @@ -291,7 +291,7 @@ void InsetFormulaBase::fitInsetCursor(BufferView * bv) const void InsetFormulaBase::toggleInsetSelection(BufferView * bv) { if (mathcursor) - bv->updateInset(this, false); + bv->updateInset(this); } @@ -301,12 +301,6 @@ vector const InsetFormulaBase::getLabelList() const } -void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty) -{ - bv->updateInset(this, dirty); -} - - dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd) { if (!mathcursor) @@ -315,7 +309,7 @@ dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd) BufferView * bv = cmd.view(); hideInsetCursor(bv); showInsetCursor(bv); - bv->updateInset(this, false); + bv->updateInset(this); //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl; if (cmd.button() == mouse_button::button3) { @@ -332,7 +326,7 @@ dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd) mathcursor->selClear(); mathcursor->setPos(cmd.x + xo_, cmd.y + yo_); mathcursor->insert(asArray(bv->getClipboard())); - bv->updateInset(this, true); + bv->updateInset(this); return DISPATCHED; } @@ -379,7 +373,7 @@ dispatch_result InsetFormulaBase::lfunMousePress(FuncRequest const & cmd) return DISPATCHED; } - bv->updateInset(this, false); + bv->updateInset(this); return DISPATCHED; } @@ -409,7 +403,7 @@ dispatch_result InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd) hideInsetCursor(bv); mathcursor->setPos(cmd.x + xo_, cmd.y + yo_); showInsetCursor(bv); - bv->updateInset(this, false); + bv->updateInset(this); return DISPATCHED; } @@ -472,7 +466,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_MATH_LIMITS: bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->dispatch(cmd); - updateLocal(bv, true); + bv->updateInset(this); break; case LFUN_RIGHTSEL: @@ -481,7 +475,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) result = mathcursor->right(sel) ? DISPATCHED : FINISHED_RIGHT; //lyxerr << "calling scroll 20\n"; //scroll(bv, 20); - updateLocal(bv, false); + bv->updateInset(this); // write something to the minibuffer //bv->owner()->message(mathcursor->info()); break; @@ -490,27 +484,27 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) sel = true; // fall through case LFUN_LEFT: result = mathcursor->left(sel) ? DISPATCHED : FINISHED; - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_UPSEL: sel = true; // fall through case LFUN_UP: result = mathcursor->up(sel) ? DISPATCHED : FINISHED_UP; - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_DOWNSEL: sel = true; // fall through case LFUN_DOWN: result = mathcursor->down(sel) ? DISPATCHED : FINISHED_DOWN; - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_WORDSEL: mathcursor->home(false); mathcursor->end(true); - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_UP_PARAGRAPHSEL: @@ -518,7 +512,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_DOWN_PARAGRAPHSEL: case LFUN_DOWN_PARAGRAPH: result = FINISHED; - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_HOMESEL: @@ -527,7 +521,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_HOME: case LFUN_WORDLEFT: result = mathcursor->home(sel) ? DISPATCHED : FINISHED; - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_ENDSEL: @@ -536,7 +530,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_END: case LFUN_WORDRIGHT: result = mathcursor->end(sel) ? DISPATCHED : FINISHED_RIGHT; - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_PRIORSEL: @@ -544,7 +538,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_BEGINNINGBUFSEL: case LFUN_BEGINNINGBUF: result = FINISHED; - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_NEXTSEL: @@ -552,17 +546,17 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_ENDBUFSEL: case LFUN_ENDBUF: result = FINISHED_RIGHT; - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_TAB: mathcursor->idxNext(); - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_SHIFT_TAB: mathcursor->idxPrev(); - updateLocal(bv, false); + bv->updateInset(this); break; case LFUN_DELETE_WORD_BACKWARD: @@ -574,7 +568,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) result = FINISHED; remove_inset = true; } - updateLocal(bv, true); + bv->updateInset(this); break; case LFUN_DELETE_WORD_FORWARD: @@ -586,7 +580,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) result = FINISHED; remove_inset = true; } - updateLocal(bv, true); + bv->updateInset(this); break; // case LFUN_GETXY: @@ -600,7 +594,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) istringstream is(cmd.argument.c_str()); is >> x >> y; mathcursor->setPos(x, y); - updateLocal(bv, false); + bv->updateInset(this); break; } @@ -609,13 +603,13 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) mathcursor->macroModeClose(); bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->selPaste(); - updateLocal(bv, true); + bv->updateInset(this); break; case LFUN_CUT: bv->lockedInsetStoreUndo(Undo::DELETE); mathcursor->selCut(); - updateLocal(bv, true); + bv->updateInset(this); break; case LFUN_COPY: @@ -631,7 +625,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) // deadkeys bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->script(true); - updateLocal(bv, true); + bv->updateInset(this); } break; @@ -673,7 +667,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_MATH_MODE: if (mathcursor->currentMode() == MathInset::TEXT_MODE) { mathcursor->niceInsert(MathAtom(new MathHullInset("simple"))); - updateLocal(bv, true); + bv->updateInset(this); } else { handleFont(bv, cmd.argument, "textrm"); } @@ -685,7 +679,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) if (!arg.empty()) { bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->setSize(arg); - updateLocal(bv, true); + bv->updateInset(this); } #endif break; @@ -703,7 +697,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) v_align += 'c'; mathcursor->niceInsert( MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align))); - updateLocal(bv, true); + bv->updateInset(this); break; } @@ -712,7 +706,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) { bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->script(cmd.action == LFUN_SUPERSCRIPT); - updateLocal(bv, true); + bv->updateInset(this); break; } @@ -729,7 +723,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs))); - updateLocal(bv, true); + bv->updateInset(this); break; } @@ -737,7 +731,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_MATH_SPACE: bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->insert(MathAtom(new MathSpaceInset(","))); - updateLocal(bv, true); + bv->updateInset(this); break; case LFUN_UNDO: @@ -753,7 +747,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) // interpret this as if a backslash was typed bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->interpret('\\'); - updateLocal(bv, true); + bv->updateInset(this); break; case LFUN_BREAKPARAGRAPH: @@ -768,7 +762,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_INSERT_MATH: bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->niceInsert(argument); - updateLocal(bv, true); + bv->updateInset(this); break; case -1: @@ -779,7 +773,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT; else mathcursor->insert(asArray(argument)); - updateLocal(bv, true); + bv->updateInset(this); } break; @@ -796,7 +790,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_INSET_TOGGLE: mathcursor->insetToggle(); - updateLocal(bv, true); + bv->updateInset(this); break; case LFUN_DIALOG_SHOW_NEW_INSET: { @@ -833,7 +827,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) } } if (result == DISPATCHED) - updateLocal(bv, true); + bv->updateInset(this); } break; @@ -970,7 +964,7 @@ bool InsetFormulaBase::searchForward(BufferView * bv, string const & str, mathcursor->setSelection(it, ar.size()); current = it; it.jump(ar.size()); - updateLocal(bv, false); + bv->updateInset(this); return true; } } diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index 8a99e1089d..1459c894a3 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -89,8 +89,6 @@ public: /// virtual MathAtom & par() = 0; /// - virtual void updateLocal(BufferView * bv, bool mark_dirty); - /// // And shouldn't this really return a shared_ptr instead? BufferView * view() const; diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 9798536ab9..7b773ed54d 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -1041,7 +1041,6 @@ dispatch_result MathGridInset::dispatch case LFUN_TABINSERT: //bv->lockedInsetStoreUndo(Undo::EDIT); splitCell(idx, pos); - //updateLocal(bv, true); return DISPATCHED_POP; case LFUN_BREAKLINE: { @@ -1061,7 +1060,6 @@ dispatch_result MathGridInset::dispatch pos = cell(idx).size(); //mathcursor->normalize(); - //updateLocal(bv, true); return DISPATCHED_POP; } diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 056d3bef3a..c70f25fa74 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -768,7 +768,6 @@ dispatch_result MathHullInset::dispatch for (row_type row = 0; row < nrows(); ++row) numbered(row, !old); //bv->owner()->message(old ? _("No number") : _("Number")); - //updateLocal(bv, true); } return DISPATCHED; @@ -779,7 +778,6 @@ dispatch_result MathHullInset::dispatch bool old = numbered(r); //bv->owner()->message(old ? _("No number") : _("Number")); numbered(r, !old); - //updateLocal(bv, true); } return DISPATCHED; diff --git a/src/mathed/ref_inset.C b/src/mathed/ref_inset.C index 7288930658..abc6a215bb 100644 --- a/src/mathed/ref_inset.C +++ b/src/mathed/ref_inset.C @@ -137,7 +137,7 @@ dispatch_result RefInset::localDispatch(FuncRequest const & cmd) // if (cmd.view()) // // This does not compile because updateInset expects // // an Inset* and 'this' isn't. -// cmd.view()->updateInset(this, true); +// cmd.view()->updateInset(this); return DISPATCHED; } diff --git a/src/text.C b/src/text.C index cc988c28ad..fb2d38610d 100644 --- a/src/text.C +++ b/src/text.C @@ -82,6 +82,8 @@ int LyXText::top_y() const row && row != anchor_row_; row = row->next()) { y += row->height(); } + lyxerr << "Returning y as " << y << endl; + lyxerr << "But row->y is " << anchor_row_->y() << endl; return y + anchor_row_offset_; } diff --git a/src/text2.C b/src/text2.C index 29ebcd2d13..e2f6f4f765 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1129,7 +1129,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom, setSelection(); setCursor(tmpcursor.par(), tmpcursor.pos()); if (inset_owner) - bv()->updateInset(inset_owner, true); + bv()->updateInset(inset_owner); } diff --git a/src/text3.C b/src/text3.C index 13e494e488..fb2c66dfc2 100644 --- a/src/text3.C +++ b/src/text3.C @@ -60,19 +60,16 @@ namespace { if (selecting || lt->selection.mark()) { lt->setSelection(); if (lt->isInInset()) - bv->updateInset(lt->inset_owner, false); + bv->updateInset(lt->inset_owner); else bv->toggleToggle(); } if (!lt->isInInset()) { - //if (fitcur) - // bv->update(lt, BufferView::SELECT|BufferView::FITCUR); - //else - bv->update(lt, BufferView::SELECT|BufferView::FITCUR); + bv->update(lt, BufferView::SELECT); bv->showCursor(); } else if (bv->text->status() != LyXText::UNCHANGED) { bv->theLockingInset()->hideInsetCursor(bv); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR); + bv->update(BufferView::SELECT); bv->showCursor(); } @@ -205,7 +202,7 @@ void LyXText::gotoInset(vector const & codes, { bv()->hideCursor(); bv()->beforeChange(this); - update(false); + update(); string contents; if (same_content && cursor.par()->isInset(cursor.pos())) { @@ -228,7 +225,7 @@ void LyXText::gotoInset(vector const & codes, bv()->owner()->message(_("No more insets")); } } - update(false); + update(); selection.cursor = cursor; } @@ -241,8 +238,10 @@ void LyXText::gotoInset(Inset::Code code, bool same_content) void LyXText::cursorPrevious() { + int y = top_y(); + if (!cursor.row()->previous()) { - if (top_y() > 0) { + if (y > 0) { int new_y = bv()->text->top_y() - bv()->workHeight(); bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y); bv()->updateScrollbar(); @@ -250,7 +249,6 @@ void LyXText::cursorPrevious() return; } - int y = top_y(); Row * cursorrow = cursor.row(); setCursorFromCoordinates(cursor.x_fix(), y); @@ -295,18 +293,20 @@ void LyXText::cursorPrevious() void LyXText::cursorNext() { + int top_y = top_y(); + if (!cursor.row()->next()) { int y = cursor.y() - cursor.row()->baseline() + cursor.row()->height(); - if (y > top_y() + bv()->workHeight()) { + if (y > top_y + bv()->workHeight()) { bv()->screen().draw(bv()->text, bv(), bv()->text->top_y() + bv()->workHeight()); bv()->updateScrollbar(); } return; } - int y = top_y() + bv()->workHeight(); - if (inset_owner && !top_y()) { + int y = top_y + bv()->workHeight(); + if (inset_owner && !top_y) { y -= (bv()->text->cursor.iy() - bv()->text->top_y() + bv()->theLockingInset()->insetInInsetY()); @@ -352,13 +352,9 @@ void LyXText::cursorNext() } -void LyXText::update(bool changed) +void LyXText::update() { - BufferView::UpdateCodes c = BufferView::SELECT | BufferView::FITCUR; - if (changed) - bv()->update(this, c | BufferView::CHANGE); - else - bv()->update(this, c); + bv()->update(this, BufferView::SELECT); } namespace { @@ -366,12 +362,12 @@ namespace { void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind) { bv->hideCursor(); - lt->update(bv); + lt->update(); InsetSpecialChar * new_inset = new InsetSpecialChar(kind); if (!bv->insertInset(new_inset)) delete new_inset; else - bv->updateInset(new_inset, true); + bv->updateInset(new_inset); } @@ -433,29 +429,29 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) redoHeightOfParagraph(); postPaint(0); setCursor(cursor.par(), cursor.pos()); - update(bv); + update(); break; } case LFUN_DELETE_WORD_FORWARD: bv->beforeChange(this); - update(false); + update(); deleteWordForward(); - update(bv); + update(); finishChange(bv); break; case LFUN_DELETE_WORD_BACKWARD: bv->beforeChange(this); - update(false); + update(); deleteWordBackward(); - update(true); + update(); finishChange(bv); break; case LFUN_DELETE_LINE_FORWARD: bv->beforeChange(this); - update(false); + update(); deleteLineForward(); update(); finishChange(bv); @@ -465,7 +461,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_TAB: if (!selection.mark()) bv->beforeChange(this); - update(false); + update(); cursorTab(); finishChange(bv); break; @@ -473,7 +469,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_WORDRIGHT: if (!selection.mark()) bv->beforeChange(this); - update(false); + update(); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) cursorLeftOneWord(); else @@ -484,7 +480,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_WORDLEFT: if (!selection.mark()) bv->beforeChange(this); - update(false); + update(); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) cursorRightOneWord(); else @@ -495,7 +491,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_BEGINNINGBUF: if (!selection.mark()) bv->beforeChange(this); - update(false); + update(); cursorTop(); finishChange(bv); break; @@ -503,13 +499,13 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_ENDBUF: if (selection.mark()) bv->beforeChange(this); - update(false); + update(); cursorBottom(); finishChange(bv); break; case LFUN_RIGHTSEL: - update(false); + update(); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) cursorLeft(bv); else @@ -518,7 +514,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_LEFTSEL: - update(false); + update(); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) cursorRight(bv); else @@ -527,55 +523,55 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_UPSEL: - update(false); + update(); cursorUp(true); finishChange(bv, true); break; case LFUN_DOWNSEL: - update(false); + update(); cursorDown(true); finishChange(bv, true); break; case LFUN_UP_PARAGRAPHSEL: - update(false); + update(); cursorUpParagraph(); finishChange(bv, true); break; case LFUN_DOWN_PARAGRAPHSEL: - update(false); + update(); cursorDownParagraph(); finishChange(bv, true); break; case LFUN_PRIORSEL: - update(false); + update(); cursorPrevious(); finishChange(bv, true); break; case LFUN_NEXTSEL: - update(false); + update(); cursorNext(); finishChange(bv, true); break; case LFUN_HOMESEL: - update(false); + update(); cursorHome(); finishChange(bv, true); break; case LFUN_ENDSEL: - update(false); + update(); cursorEnd(); finishChange(bv, true); break; case LFUN_WORDRIGHTSEL: - update(false); + update(); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) cursorLeftOneWord(); else @@ -584,7 +580,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_WORDLEFTSEL: - update(false); + update(); if (cursor.par()->isRightToLeftPar(bv->buffer()->params)) cursorRightOneWord(); else @@ -593,7 +589,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_WORDSEL: { - update(false); + update(); LyXCursor cur1; LyXCursor cur2; getWord(cur1, cur2, WHOLE_WORD); @@ -608,7 +604,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bool is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params); if (!selection.mark()) bv->beforeChange(this); - update(false); + update(); if (is_rtl) cursorLeft(false); if (cursor.pos() < cursor.par()->size() @@ -631,7 +627,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bool const is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params); if (!selection.mark()) bv->beforeChange(this); - update(false); + update(); LyXCursor const cur = cursor; if (!is_rtl) cursorLeft(false); @@ -705,7 +701,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_HOME: if (!selection.mark()) bv->beforeChange(this); - update(bv); + update(); cursorHome(); finishChange(bv, false); break; @@ -713,7 +709,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_END: if (!selection.mark()) bv->beforeChange(this); - update(bv); + update(); cursorEnd(); finishChange(bv, false); break; @@ -727,7 +723,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bv->beforeChange(this); insertInset(new InsetNewline); - update(true); + update(); setCursor(cursor.par(), cursor.pos()); moveCursorUpdate(bv, false); break; @@ -737,14 +733,14 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!selection.set()) { Delete(); selection.cursor = cursor; - update(bv); + update(); // It is possible to make it a lot faster still // just comment out the line below... bv->showCursor(); } else { - update(false); + update(); cutSelection(bv, true); - update(bv); + update(); } moveCursorUpdate(bv, false); bv->owner()->view_state_changed(); @@ -772,7 +768,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) cur.par()->params().align(), cur.par()->params().labelWidthString(), 0); cursorLeft(bv); - update(bv); + update(); } else { cursorLeft(bv); Delete(); @@ -783,10 +779,10 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) selection.cursor = cursor; } } else { - update(false); + update(); cutSelection(bv, true); } - update(bv); + update(); break; @@ -795,15 +791,15 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (bv->owner()->getIntl().getTransManager().backspace()) { backspace(); selection.cursor = cursor; - update(bv); + update(); // It is possible to make it a lot faster still // just comment out the line below... bv->showCursor(); } } else { - update(false); + update(); cutSelection(bv, true); - update(bv); + update(); } bv->owner()->view_state_changed(); bv->switchKeyMap(); @@ -830,16 +826,16 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) selection.cursor = cur; } } else { - update(false); + update(); cutSelection(bv, true); } - update(bv); + update(); break; case LFUN_BREAKPARAGRAPH: bv->beforeChange(this); breakParagraph(bv->buffer()->paragraphs, 0); - update(bv); + update(); selection.cursor = cursor; bv->switchKeyMap(); bv->owner()->view_state_changed(); @@ -848,7 +844,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_BREAKPARAGRAPHKEEPLAYOUT: bv->beforeChange(this); breakParagraph(bv->buffer()->paragraphs, 1); - update(bv); + update(); selection.cursor = cursor; bv->switchKeyMap(); bv->owner()->view_state_changed(); @@ -871,14 +867,12 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) cur.par()->params().spacing(), cur.par()->params().align(), cur.par()->params().labelWidthString(), 1); - //update(bv); } } else { breakParagraph(bv->buffer()->paragraphs, 0); - //update(bv); } - update(bv); + update(); selection.cursor = cur; bv->switchKeyMap(); bv->owner()->view_state_changed(); @@ -922,7 +916,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (cur_spacing != new_spacing || cur_value != new_value) { par->params().spacing(Spacing(new_spacing, new_value)); redoParagraph(); - update(bv); + update(); } break; } @@ -930,16 +924,16 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_INSET_TOGGLE: bv->hideCursor(); bv->beforeChange(this); - update(false); + update(); toggleInset(); - update(false); + update(); bv->switchKeyMap(); break; case LFUN_PROTECTEDSPACE: if (cursor.par()->layout()->free_spacing) { insertChar(' '); - update(bv); + update(); } else { specialChar(this, bv, InsetSpecialChar::PROTECTED_SEPARATOR); } @@ -968,7 +962,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_MARK_OFF: bv->beforeChange(this); - update(false); + update(); selection.cursor = cursor; cmd.message(N_("Mark off")); break; @@ -976,7 +970,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_MARK_ON: bv->beforeChange(this); selection.mark(true); - update(false); + update(); selection.cursor = cursor; cmd.message(N_("Mark on")); break; @@ -984,46 +978,46 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_SETMARK: bv->beforeChange(this); if (selection.mark()) { - update(bv); + update(); cmd.message(N_("Mark removed")); } else { selection.mark(true); - update(bv); + update(); cmd.message(N_("Mark set")); } selection.cursor = cursor; break; case LFUN_UPCASE_WORD: - update(false); + update(); changeCase(LyXText::text_uppercase); if (inset_owner) - bv->updateInset(inset_owner, true); - update(bv); + bv->updateInset(inset_owner); + update(); break; case LFUN_LOWCASE_WORD: - update(false); + update(); changeCase(LyXText::text_lowercase); if (inset_owner) - bv->updateInset(inset_owner, true); + bv->updateInset(inset_owner); update(); break; case LFUN_CAPITALIZE_WORD: - update(false); + update(); changeCase(LyXText::text_capitalization); if (inset_owner) - bv->updateInset(inset_owner, true); - update(bv); + bv->updateInset(inset_owner); + update(); break; case LFUN_TRANSPOSE_CHARS: - update(false); + update(); transposeChars(); if (inset_owner) - bv->updateInset(inset_owner, true); - update(bv); + bv->updateInset(inset_owner); + update(); break; case LFUN_PASTE: @@ -1032,19 +1026,18 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) // clear the selection bv->toggleSelection(); clearSelection(); - update(false); + update(); pasteSelection(); clearSelection(); // bug 393 - update(false); - update(bv); + update(); bv->switchKeyMap(); break; case LFUN_CUT: bv->hideCursor(); - update(false); + update(); cutSelection(bv, true); - update(bv); + update(); cmd.message(_("Cut")); break; @@ -1056,7 +1049,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_BEGINNINGBUFSEL: if (inset_owner) return UNDISPATCHED; - update(false); + update(); cursorTop(); finishChange(bv, true); break; @@ -1064,7 +1057,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_ENDBUFSEL: if (inset_owner) return UNDISPATCHED; - update(false); + update(); cursorBottom(); finishChange(bv, true); break; @@ -1149,10 +1142,10 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (change_layout) { bv->hideCursor(); current_layout = layout; - update(false); + update(); setLayout(layout); bv->owner()->setLayout(layout); - update(bv); + update(); bv->switchKeyMap(); } break; @@ -1172,7 +1165,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) else insertStringAsLines(clip); clearSelection(); - update(bv); + update(); } break; } @@ -1231,7 +1224,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) for (int i = 0; i < datetmp_len; i++) { insertChar(datetmp[i]); - update(true); + update(); } selection.cursor = cursor; moveCursorUpdate(bv, false); @@ -1254,7 +1247,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) setSelection(); if (!isInInset()) bv->screen().toggleSelection(this, bv, false); - update(false); + update(); bv->haveSelection(selection.set()); } break; @@ -1273,7 +1266,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) } else { selectWord(LyXText::WHOLE_WORD_STRICT); } - update(false); + update(); bv->haveSelection(selection.set()); } break; @@ -1336,7 +1329,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) // Maybe an empty line was deleted if (!bv->text->selection.set()) - bv->update(bv->text, BufferView::UPDATE); + bv->update(BufferView::UPDATE); bv->text->setSelection(); bv->screen().toggleToggle(bv->text, bv); bv->fitCursor(); @@ -1548,7 +1541,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) if (lyxrc.auto_region_delete) { if (selection.set()) { cutSelection(false, false); - update(bv); + update(); } bv->haveSelection(false); } @@ -1562,7 +1555,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) bv->owner()->getIntl().getTransManager(). TranslateAndInsert(*cit, this); - update(bv); + update(); selection.cursor = cursor; moveCursorUpdate(bv, false); diff --git a/src/undo_funcs.C b/src/undo_funcs.C index c61b888e4f..882f5e1668 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -232,7 +232,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo) t->updateCounters(); bv->fitCursor(); } - bv->updateInset(it, false); + bv->updateInset(it); bv->text->setCursorIntern(bv->text->cursor.par(), bv->text->cursor.pos()); } else {