Georg Baum wrote:
> I tested the patch and it works well for me. OK to apply?
Take this one instaed, I forgot to implement LFUN_INSET_DIALOG_UPDATE.
Georg
Index: src/mathed/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v
retrieving revision 1.532
diff -u -p -r1.532 ChangeLog
--- src/mathed/ChangeLog 8 Nov 2005 15:12:05 -0000 1.532
+++ src/mathed/ChangeLog 16 Nov 2005 09:26:22 -0000
@@ -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
Index: src/mathed/command_inset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/command_inset.C,v
retrieving revision 1.29
diff -u -p -r1.29 command_inset.C
--- src/mathed/command_inset.C 23 Nov 2004 23:04:49 -0000 1.29
+++ src/mathed/command_inset.C 16 Nov 2005 09:26:22 -0000
@@ -44,6 +45,13 @@ void CommandInset::metrics(MetricsInfo &
}
button_.metrics(mi, dim);
dim_ = dim;
+}
+
+
+InsetBase * CommandInset::editXY(LCursor & cur, int x, int y)
+{
+ edit(cur, true);
+ return this;
}
Index: src/mathed/command_inset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/command_inset.h,v
retrieving revision 1.21
diff -u -p -r1.21 command_inset.h
--- src/mathed/command_inset.h 23 Nov 2004 23:04:49 -0000 1.21
+++ src/mathed/command_inset.h 16 Nov 2005 09:26:22 -0000
@@ -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;
Index: src/mathed/math_hullinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hullinset.C,v
retrieving revision 1.180
diff -u -p -r1.180 math_hullinset.C
--- src/mathed/math_hullinset.C 14 Oct 2005 10:50:22 -0000 1.180
+++ src/mathed/math_hullinset.C 16 Nov 2005 09:26:22 -0000
@@ -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 +1159,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 +1245,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;
Index: src/mathed/math_nestinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.C,v
retrieving revision 1.176
diff -u -p -r1.176 math_nestinset.C
--- src/mathed/math_nestinset.C 2 Nov 2005 20:11:36 -0000 1.176
+++ src/mathed/math_nestinset.C 16 Nov 2005 09:26:22 -0000
@@ -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 +883,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;
Index: src/mathed/ref_inset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ref_inset.C,v
retrieving revision 1.52
diff -u -p -r1.52 ref_inset.C
--- src/mathed/ref_inset.C 17 Jul 2005 01:13:36 -0000 1.52
+++ src/mathed/ref_inset.C 16 Nov 2005 09:26:22 -0000
@@ -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"
@@ -70,6 +78,14 @@ void RefInset::doDispatch(LCursor & cur,
cur.undispatched();
break;
+ case LFUN_INSET_DIALOG_UPDATE: {
+ string const data = createDialogStr("ref");
+ if (cur.bv().owner()->getDialogs().visible("ref"))
+ cur.bv().owner()->getDialogs().update("ref", data);
+ break;
+ }
+
+ case LFUN_INSET_DIALOG_SHOW:
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3) {
lyxerr << "trying to goto ref '" << asString(cell(0)) << "'" << endl;
@@ -97,6 +113,25 @@ 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_INSET_DIALOG_UPDATE:
+ case LFUN_INSET_DIALOG_SHOW:
+ 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;
Index: src/mathed/ref_inset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ref_inset.h,v
retrieving revision 1.28
diff -u -p -r1.28 ref_inset.h
--- src/mathed/ref_inset.h 17 Jul 2005 01:13:36 -0000 1.28
+++ src/mathed/ref_inset.h 16 Nov 2005 09:26:22 -0000
@@ -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;