-
-//takes absolute x,y coordinates
-InsetBase * LyXText::checkInsetHit(int x, int y)
-{
- par_type pit;
- par_type end;
-
- getParsInRange(paragraphs(),
- bv()->top_y() - yo_,
- bv()->top_y() - yo_ + bv()->workHeight(),
- pit, end);
-
- //lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
- for ( ; pit != end; ++pit) {
- InsetList::iterator iit = pars_[pit].insetlist.begin();
- InsetList::iterator iend = pars_[pit].insetlist.end();
- for ( ; iit != iend; ++iit) {
- InsetBase * inset = iit->inset;
-#if 0
- lyxerr << "examining inset " << inset
- << " xo: " << inset->xo() << "..." << inset->xo() + inset->width()
- << " yo: " << inset->yo() - inset->ascent() << "..."
- << inset->yo() + inset->descent() << endl;
-#endif
- if (inset->covers(x, y)) {
- lyxerr << "Hit inset: " << inset << endl;
- return inset;
- }
- }
- }
- //lyxerr << "No inset hit. " << endl;
- return 0;
-}
-
-
-bool LyXText::gotoNextInset(LCursor & cur,
- vector<InsetOld_code> const & codes, string const & contents)
-{
- BOOST_ASSERT(this == cur.text());
- par_type end = paragraphs().size();
- par_type pit = cur.par();
- pos_type pos = cur.pos();
-
- InsetBase * inset;
- do {
- if (pos + 1 < pars_[pit].size()) {
- ++pos;
- } else {
- ++pit;
- pos = 0;
- }
-
- } while (pit != end &&
- !(pars_[pit].isInset(pos) &&
- (inset = pars_[pit].getInset(pos)) != 0 &&
- find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() &&
- (contents.empty() ||
- static_cast<InsetCommand *>(pars_[pit].getInset(pos))->getContents()
- == contents)));
-
- if (pit == end)
- return false;
-
- setCursor(cur, pit, pos, false);
- return true;
-}
-
-
-void LyXText::gotoInset(LCursor & cur,
- vector<InsetOld_code> const & codes, bool same_content)
-{
- cur.clearSelection();
-
- string contents;
- if (same_content
- && cur.pos() < cur.lastpos()
- && cur.paragraph().isInset(cur.pos())) {
- InsetBase const * inset = cur.paragraph().getInset(cur.pos());
- if (find(codes.begin(), codes.end(), inset->lyxCode())
- != codes.end())
- contents = static_cast<InsetCommand const *>(inset)->getContents();
- }
-
- if (!gotoNextInset(cur, codes, contents)) {
- if (cur.pos() || cur.par() != 0) {
- CursorSlice tmp = cur.top();
- cur.par() = 0;
- cur.pos() = 0;
- if (!gotoNextInset(cur, codes, contents)) {
- cur.top() = tmp;
- cur.message(_("No more insets"));
- }
- } else {
- cur.message(_("No more insets"));
- }
- }
- cur.resetAnchor();
-}
-
-
-void LyXText::gotoInset(LCursor & cur, InsetOld_code code, bool same_content)
-{
- gotoInset(cur, vector<InsetOld_code>(1, code), same_content);
-}
-
-
-void LyXText::cursorPrevious(LCursor & cur)