Vincent van Ravesteijn <v.f.vanraveste...@tudelft.nl> writes: >> I think the distinction between 'do not handle' and 'handle but is >> disabled' captures what you want. It might even be that all uses of >> OptItem could be replaced by that in the code. > > Well, it's a not-so-very-well-defined difference in my opinion. At > least in my example, it would be both 'handle but is disabled'.
In my view, it boils down to have enabled/disabled/notapplicable. With the following untested trivial patch, all lfuns that do not get handled by _someone_ become unknown() (which is admittedly a bit strong, but efficient). This means that getStatus for inline equation can say that COPY_AS_REF does not make sense for an inline equation and in this sense cannot be implemented. If inline equations and display equations had two separate implmentations, we would have implemented COPY_AS_REF only in the second case, anyway. A second problem I have with your proposal, is that the new flag describes an effect on the interface, and not a property of the lfun/inset couple. Does the attached patch make sense? It does not work (yet) but I did not have time to debug it. JMarc
svndiff src/mathed/InsetMathHull.cpp src/LyXFunc.cpp lib/ui/stdcontext.inc Index: src/mathed/InsetMathHull.cpp =================================================================== --- src/mathed/InsetMathHull.cpp (révision 29865) +++ src/mathed/InsetMathHull.cpp (copie de travail) @@ -1388,13 +1388,19 @@ bool InsetMathHull::getStatus(Cursor & c } case LFUN_LABEL_INSERT: - status.setEnabled(type_ != hullSimple); + if (type_ == hullSimple) + // the lfun makes no sense for inline math + return false; + status.setEnabled(true); return true; case LFUN_LABEL_COPY_AS_REF: { bool enabled = false; row_type row; if (cmd.argument().empty() && &cur.inset() == this) { + if (type_ == hullSimple) + // the lfun makes no sense for inline math + return false; // if there is no argument and we're inside math, we retrieve // the row number from the cursor position. row = (type_ == hullMultline) ? nrows() - 1 : cur.row(); Index: src/LyXFunc.cpp =================================================================== --- src/LyXFunc.cpp (révision 29866) +++ src/LyXFunc.cpp (copie de travail) @@ -684,7 +684,11 @@ FuncStatus LyXFunc::getStatus(FuncReques decided = view()->getStatus(cmd, flag); if (!decided) // try the Buffer - view()->buffer().getStatus(cmd, flag); + decided = view()->buffer().getStatus(cmd, flag); + if (!decided) { + lyxerr <<"Unknown lfun " << cmd <<endl; + flag.unknown(true); + } } if (!enable) Index: lib/ui/stdcontext.inc =================================================================== --- lib/ui/stdcontext.inc (révision 29865) +++ lib/ui/stdcontext.inc (copie de travail) @@ -46,7 +46,7 @@ Menuset OptItem "Number whole Formula|N" "math-number-toggle" OptItem "Number this Line|u" "math-number-line-toggle" OptItem "Equation Label|L" "label-insert" - OptItem "Copy as Reference|R" "copy-label-as-reference" + Item "Copy as Reference|R" "copy-label-as-reference" Separator Item "Split Cell|C" "cell-split" Separator