+bool Cursor::getStatus(FuncRequest const & cmd, FuncStatus & status) const
+{
+ Cursor cur = *this;
+
+ // Try to fix cursor in case it is broken.
+ cur.fixIfBroken();
+
+ // Is this a function that acts on inset at point?
+ Inset * inset = cur.nextInset();
+ if (lyxaction.funcHasFlag(cmd.action, LyXAction::AtPoint)
+ && inset && inset->getStatus(cur, cmd, status))
+ return true;
+
+ // This is, of course, a mess. Better create a new doc iterator and use
+ // this in Inset::getStatus. This might require an additional
+ // BufferView * arg, though (which should be avoided)
+ //Cursor safe = *this;
+ bool res = false;
+ for ( ; cur.depth(); cur.pop()) {
+ //lyxerr << "\nCursor::getStatus: cmd: " << cmd << endl << *this << endl;
+ LASSERT(cur.idx() <= cur.lastidx(), /**/);
+ LASSERT(cur.pit() <= cur.lastpit(), /**/);
+ LASSERT(cur.pos() <= cur.lastpos(), /**/);
+
+ // The inset's getStatus() will return 'true' if it made
+ // a definitive decision on whether it want to handle the
+ // request or not. The result of this decision is put into
+ // the 'status' parameter.
+ if (cur.inset().getStatus(cur, cmd, status)) {
+ res = true;
+ break;
+ }
+ }
+ return res;
+}
+
+