+
+
+void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty)
+{
+ if (!inset)
+ return;
+
+ // first check for locking insets
+ if (bv_->theLockingInset()) {
+ if (bv_->theLockingInset() == inset) {
+ if (bv_->text->updateInset(bv_, inset)) {
+ update();
+ if (mark_dirty) {
+ buffer_->markDirty();
+ }
+ updateScrollbar();
+ return;
+ }
+ } else if (bv_->theLockingInset()->updateInsetInInset(bv_, inset)) {
+ if (bv_->text->updateInset(bv_,
+ bv_->theLockingInset())) {
+ update();
+ if (mark_dirty){
+ buffer_->markDirty();
+ }
+ updateScrollbar();
+ return;
+ }
+ }
+ }
+
+ // then check the current buffer
+ if (available()) {
+ hideCursor();
+ update(bv_->text, BufferView::UPDATE);
+ if (bv_->text->updateInset(bv_, inset)) {
+ if (mark_dirty) {
+ update(bv_->text,
+ BufferView::SELECT
+ | BufferView::FITCUR
+ | BufferView::CHANGE);
+ } else {
+ update(bv_->text, SELECT);
+ }
+ return;
+ }
+ }
+}
+
+
+void BufferView::Pimpl::gotoInset(vector<Inset::Code> const & codes,
+ bool same_content)
+{
+ if (!available()) return;
+
+ hideCursor();
+ beforeChange(bv_->text);
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
+
+ string contents;
+ if (same_content &&
+ bv_->text->cursor.par()->getChar(bv_->text->cursor.pos()) == Paragraph::META_INSET) {
+ Inset const * inset = bv_->text->cursor.par()->getInset(bv_->text->cursor.pos());
+ if (find(codes.begin(), codes.end(), inset->lyxCode())
+ != codes.end())
+ contents =
+ static_cast<InsetCommand const *>(inset)->getContents();
+ }
+
+ if (!bv_->text->gotoNextInset(bv_, codes, contents)) {
+ if (bv_->text->cursor.pos()
+ || bv_->text->cursor.par() != bv_->text->firstParagraph()) {
+ LyXCursor tmp = bv_->text->cursor;
+ bv_->text->cursor.par(bv_->text->firstParagraph());
+ bv_->text->cursor.pos(0);
+ if (!bv_->text->gotoNextInset(bv_, codes, contents)) {
+ bv_->text->cursor = tmp;
+ bv_->owner()->message(_("No more insets"));
+ }
+ } else {
+ bv_->owner()->message(_("No more insets"));
+ }
+ }
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
+ bv_->text->selection.cursor = bv_->text->cursor;
+}
+
+
+void BufferView::Pimpl::gotoInset(Inset::Code code, bool same_content)
+{
+ gotoInset(vector<Inset::Code>(1, code), same_content);
+}