That's most of the 'necessary infrastucture' for 'localized getStatus' (but none of the 'real' work).
It would work pretty much like dispatch: asking cursor-tip-to-bottom every inset whether it will later handle a certain request, stopping at the first one that says 'I know this LFUN and I decide now that this is allowed or not'. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)
Index: cursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v retrieving revision 1.63 diff -u -p -r1.63 cursor.C --- cursor.C 20 Feb 2004 11:00:40 -0000 1.63 +++ cursor.C 20 Feb 2004 11:31:45 -0000 @@ -125,6 +125,30 @@ DispatchResult LCursor::dispatch(FuncReq } +bool LCursor::getStatus(FuncRequest const & cmd, FuncStatus & status) +{ + lyxerr << "\nLCursor::getStatus: cmd: " << cmd << endl << *this << endl; + BOOST_ASSERT(pos() <= lastpos()); + BOOST_ASSERT(idx() <= lastidx()); + BOOST_ASSERT(par() <= lastpar()); + for (current_ = cursor_.size() - 1; current_ >= 1; --current_) { + // 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. + bool const res = inset()->getStatus(*this, cmd, status); + if (res) { + current_ = cursor_.size() - 1; + return true; + } + } + BOOST_ASSERT(current_ == 0); + bool const res = bv_->text()->getStatus(*this, cmd, status); + current_ = cursor_.size() - 1; + return res; +} + + void LCursor::push(InsetBase * inset) { lyxerr << "LCursor::push() inset: " << inset << endl; Index: cursor.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.h,v retrieving revision 1.38 diff -u -p -r1.38 cursor.h --- cursor.h 20 Feb 2004 11:00:40 -0000 1.38 +++ cursor.h 20 Feb 2004 11:31:45 -0000 @@ -22,6 +22,7 @@ class BufferView; class UpdatableInset; class MathAtom; class DispatchResult; +class FuncStatus; class FuncRequest; class InsetTabular; class LyXText; @@ -74,6 +75,9 @@ public: explicit LCursor(BufferView & bv); /// dispatch from innermost inset upwards DispatchResult dispatch(FuncRequest const & cmd); + /// are we willing to handle this event? + bool getStatus(FuncRequest const & cmd, FuncStatus & flag); + /// add a new cursor slice void push(InsetBase * inset); /// add a new cursor slice, place cursor on left end Index: lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.293 diff -u -p -r1.293 lyxtext.h --- lyxtext.h 16 Feb 2004 11:58:40 -0000 1.293 +++ lyxtext.h 20 Feb 2004 11:31:45 -0000 @@ -33,6 +33,7 @@ class Dimension; class InsetBase; class InsetOld_code; class FuncRequest; +class FuncStatus; class LColor_color; class LCursor; class LyXTextClass; @@ -130,6 +131,9 @@ public: /// try to handle that request DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd); + /// do we want to handle this event? + bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus & status); + /// access to out BufferView. This should go... BufferView * bv(); /// access to out BufferView. This should go... Index: insets/insetbase.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.C,v retrieving revision 1.21 diff -u -p -r1.21 insetbase.C --- insets/insetbase.C 16 Feb 2004 11:58:46 -0000 1.21 +++ insets/insetbase.C 20 Feb 2004 11:31:45 -0000 @@ -40,6 +40,12 @@ void InsetBase::priv_dispatch(LCursor & } +bool InsetBase::getStatus(LCursor &, FuncRequest const &, FuncStatus &) +{ + return false; +} + + void InsetBase::edit(LCursor &, bool) { lyxerr << "InsetBase: edit left/right" << std::endl; Index: insets/insetbase.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.h,v retrieving revision 1.29 diff -u -p -r1.29 insetbase.h --- insets/insetbase.h 16 Feb 2004 11:58:46 -0000 1.29 +++ insets/insetbase.h 20 Feb 2004 11:31:45 -0000 @@ -21,6 +21,7 @@ class BufferView; class CursorSlice; class DispatchResult; class FuncRequest; +class FuncStatus; class LaTeXFeatures; class LCursor; class LyXLex; @@ -69,6 +70,9 @@ public: // the real dispatcher void dispatch(LCursor & cur, FuncRequest const & cmd); + /// do we want to handle this event? + virtual bool getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & status); /// cursor enters virtual void edit(LCursor & cur, bool left);