// slightly tricky because we want to loop around Buffer::inset_iterator const begin(bv_->buffer()->inset_iterator_begin()); Buffer::inset_iterator const end(bv_->buffer()->inset_iterator_end()); Buffer::inset_iterator orig(cur.par(), cur.pos()); if (orig == end) return; Buffer::inset_iterator it(orig); // skip the first inset ++it; if (it == end) return; for (; it != orig; ++it) { vector<Inset::Code>::iterator cit( find(codes.begin(), codes.end(), (*it)->lyxCode())); if (cit == codes.end()) { if (it == end) it = begin; continue; } if (!match.empty()) { // this relies on the caller getting this right :( InsetCommand * ic(static_cast<InsetCommand*>(*it)); if (ic->getContents() != match) { if (it == end) it = begin; continue; } } t->setCursor(bv_, it.getPar(), it.getPos(), false); break; }
orig(par, pos) creates an iterator with an "it" of 0. This is really bad semantics imho - an iterator should be valid, possibly == end() though How do I do the above code ? Basically I want to iterate (and looping from end back to begin) starting from the current cursor position. inset_iterator has no operator+() or operator<() ?? Does Buffer::inset_iterator traverse insets inside insets or not ? thanks john -- "The simpler it is, the harder it is." - Tim Van Holder