It is currently not possible to insert cross references in math (http://bugzilla.lyx.org/show_bug.cgi?id=2126). This is possible in 1.3, so it needs to be fixed. The attached patch re-enables reference insets in math. It is basically adding some missing bits that are needed due to the changes in getStatus/dispatch handling that where done somewhere on the way from 1.3 to 1.4. It also removes a chunk of dead code that is never reached (LFUN_INSET_APPLY never reaches any inset, it is handled only in LyXFunc::getStatus). There are still some problems with references in math (e.g. they cannot contain spaces or umlauts, http://bugzilla.lyx.org/show_bug.cgi?id=2116), but these problems are present in 1.3 as well, so I did not fix them I tested the patch and it works well for me. OK to apply?
Georg
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/ChangeLog lyx-1.4-cvs/src/mathed/ChangeLog --- lyx-1.4-clean/src/mathed/ChangeLog 2005-11-08 19:42:32.000000000 +0100 +++ lyx-1.4-cvs/src/mathed/ChangeLog 2005-11-15 19:40:27.467556368 +0100 @@ -1,3 +1,17 @@ +2005-11-15 Georg Baum <[EMAIL PROTECTED]> + + * command_inset.[Ch] (editXY): implement, since MathNestInset::editXY + loops through the cells and that is not possible here because they are + not visble + * math_hullinset.C (getStatus): allow reference and label in + LFUN_INSET_INSERT + * math_hullinset.C (doDispatch): create ref inset in LFUN_INSET_INSERT + * math_nestinset.C (doDispatch): allow references + * math_nestinset.C (doDispatch): remove never reached code for + LFUN_INSET_APPLY + * ref_inset.[Ch] (getStatus): implement, otherwise we'll trigger an + assertion in LyXFunc::getStatus + 2005-11-08 Georg Baum <[EMAIL PROTECTED]> * math_parser.C (delEmptyLastRow): Don't delete the dummy row, but diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/command_inset.C lyx-1.4-cvs/src/mathed/command_inset.C --- lyx-1.4-clean/src/mathed/command_inset.C 2004-11-24 17:46:16.000000000 +0100 +++ lyx-1.4-cvs/src/mathed/command_inset.C 2005-11-15 19:24:23.000000000 +0100 @@ -47,6 +47,13 @@ void CommandInset::metrics(MetricsInfo & } +InsetBase * CommandInset::editXY(LCursor & cur, int x, int y) +{ + edit(cur, true); + return this; +} + + void CommandInset::draw(PainterInfo & pi, int x, int y) const { button_.draw(pi, x, y); diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/command_inset.h lyx-1.4-cvs/src/mathed/command_inset.h --- lyx-1.4-clean/src/mathed/command_inset.h 2004-11-24 17:46:16.000000000 +0100 +++ lyx-1.4-cvs/src/mathed/command_inset.h 2005-11-15 19:23:41.000000000 +0100 @@ -28,6 +28,8 @@ public: /// void draw(PainterInfo & pi, int x, int y) const; /// + InsetBase * editXY(LCursor &, int, int); + /// void write(WriteStream & os) const; // // void infoize(std::ostream & os) const; diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/math_hullinset.C lyx-1.4-cvs/src/mathed/math_hullinset.C --- lyx-1.4-clean/src/mathed/math_hullinset.C 2005-10-14 19:59:32.000000000 +0200 +++ lyx-1.4-cvs/src/mathed/math_hullinset.C 2005-11-13 21:16:29.000000000 +0100 @@ -14,6 +14,7 @@ #include "math_colorinset.h" #include "math_data.h" #include "math_extern.h" +#include "math_factory.h" #include "math_hullinset.h" #include "math_mathmlstream.h" #include "math_streamstr.h" @@ -1075,7 +1076,14 @@ void MathHullInset::doDispatch(LCursor & cur.bv().buffer()->changeRefsIfUnique(old, str); label(r, str); } + break; } + MathArray ar; + if (createMathInset_fromDialogStr(cmd.argument, ar)) { + recordUndo(cur); + cur.insert(ar); + } else + cur.undispatched(); break; } @@ -1138,6 +1146,15 @@ bool MathHullInset::getStatus(LCursor & case LFUN_INSERT_LABEL: status.enabled(type_ != "simple"); return true; + case LFUN_INSET_INSERT: { + // Don't test createMathInset_fromDialogStr(), since + // getStatus is not called with a valid reference and the + // dialog would not be applyable. + string const name = cmd.getArg(0); + status.enabled(name == "ref" || + (name == "label" && type_ != "simple")); + break; + } case LFUN_TABULAR_FEATURE: { istringstream is(cmd.argument); string s; diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/math_nestinset.C lyx-1.4-cvs/src/mathed/math_nestinset.C --- lyx-1.4-clean/src/mathed/math_nestinset.C 2005-11-08 19:42:36.000000000 +0100 +++ lyx-1.4-cvs/src/mathed/math_nestinset.C 2005-11-13 21:16:29.000000000 +0100 @@ -30,6 +30,7 @@ #include "math_symbolinset.h" #include "math_support.h" #include "math_unknowninset.h" +#include "ref_inset.h" #include "BufferView.h" #include "CutAndPaste.h" @@ -56,7 +57,6 @@ using lyx::cap::copySelection; using lyx::cap::grabAndEraseSelection; using lyx::cap::cutSelection; -using lyx::cap::pasteSelection; using lyx::cap::replaceSelection; using lyx::cap::selClearOrDel; @@ -885,34 +885,14 @@ void MathNestInset::doDispatch(LCursor & case LFUN_DIALOG_SHOW_NEW_INSET: { string const & name = cmd.argument; string data; -#if 0 if (name == "ref") { RefInset tmp(name); data = tmp.createDialogStr(name); } -#endif cur.bv().owner()->getDialogs().show(name, data, 0); break; } - case LFUN_INSET_APPLY: { - string const name = cmd.getArg(0); - InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name); - - if (base) { - FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument); - base->dispatch(cur, fr); - break; - } - MathArray ar; - if (createMathInset_fromDialogStr(cmd.argument, ar)) { - cur.insert(ar); - break; - } - cur.undispatched(); - break; - } - default: MathDimInset::doDispatch(cur, cmd); break; diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/ref_inset.C lyx-1.4-cvs/src/mathed/ref_inset.C --- lyx-1.4-clean/src/mathed/ref_inset.C 2005-07-17 10:20:28.000000000 +0200 +++ lyx-1.4-cvs/src/mathed/ref_inset.C 2005-11-15 19:32:56.595099400 +0100 @@ -18,6 +18,7 @@ #include "cursor.h" #include "debug.h" #include "funcrequest.h" +#include "FuncStatus.h" #include "gettext.h" #include "math_data.h" #include "math_factory.h" @@ -97,6 +98,23 @@ void RefInset::doDispatch(LCursor & cur, } +bool RefInset::getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & status) const +{ + switch (cmd.action) { + // we handle these + case LFUN_INSET_MODIFY: + case LFUN_MOUSE_RELEASE: + case LFUN_MOUSE_PRESS: + case LFUN_MOUSE_MOTION: + status.enabled(true); + return true; + default: + return CommandInset::getStatus(cur, cmd, status); + } +} + + string const RefInset::screenLabel() const { string str; diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/mathed/ref_inset.h lyx-1.4-cvs/src/mathed/ref_inset.h --- lyx-1.4-clean/src/mathed/ref_inset.h 2005-07-17 10:20:28.000000000 +0200 +++ lyx-1.4-cvs/src/mathed/ref_inset.h 2005-11-15 19:17:44.000000000 +0100 @@ -55,7 +55,10 @@ public: /// static std::string const & getName(int type); protected: + /// virtual void doDispatch(LCursor & cur, FuncRequest & cmd); + /// + bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const; private: /// virtual std::auto_ptr<InsetBase> doClone() const;