On Sun, 2005-03-27 at 18:57, Georg Baum wrote:
> Happy Easter everybody!
> 
> Am Freitag, 25. MÃrz 2005 08:53 schrieb Martin Vermeer:
>  
> > Does anyone know what the status of these AMS array structures is? They
> > are things like bmatrix, pmatrix etc. etc. I couldn't get any of these
> > to work.
> 
> They do work. See the attached file which has one instance of every grid 
> like structure I know of. I do use bmatrix a lot also in 1.3.
> I have added hlines and vlines to every environment that supports them.
> 
> > Is there supposed to be a working UI to these?
> 
> I don't know any other than typing the environment name in a math box: 
> \bmatrix <space> gives a 1x1 bmatrix. I did not know that either until 
> recently (I believe I read it in Uwes excellent math guide). Before I 
> entered them with a text editor or copied from an existing file ;-(
> 
> BTW, I discovered that MathAmsArrayInset, MathSubstackInset and 
> MathArrayInset lack a validate method which requires amsmath. I attached 
> a patch that fixes this. This is going in unless somebody objects.
> 
> 
> Georg

Attached the fix for the grid lines for these exotic creatures. I
believe this should go in as it has the potential to get users into a
knot as it did Helge.

Georg, will you check in your validate patch first?

BTW I once managed to get LyX to crash moving around these insets.
Unfortunately I cannot reproduce it.

- Martin


Index: math_amsarrayinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_amsarrayinset.C,v
retrieving revision 1.25
diff -u -r1.25 math_amsarrayinset.C
--- math_amsarrayinset.C	23 Nov 2004 23:04:49 -0000	1.25
+++ math_amsarrayinset.C	29 Mar 2005 13:53:38 -0000
@@ -16,8 +16,18 @@
 #include "math_streamstr.h"
 #include "math_support.h"
 
+#include "funcrequest.h"
+#include "FuncStatus.h"
+#include "gettext.h"
+
+#include "support/lstrings.h"
+
+#include <sstream>
+
 using std::string;
+using std::istringstream;
 using std::auto_ptr;
+using lyx::support::bformat;
 
 
 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
@@ -86,6 +96,29 @@
 	mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), name_left());
 	mathed_draw_deco(pi, x + dim_.width() - 6, yy, 5, dim_.height(), name_right());
 	setPosCache(pi, x, y);
+}
+
+
+bool MathAMSArrayInset::getStatus(LCursor & cur, FuncRequest const & cmd,
+		FuncStatus & flag) const
+{
+	switch (cmd.action) {
+	case LFUN_TABULAR_FEATURE: {
+		istringstream is(cmd.argument);
+		string s;
+		is >> s;
+		if (s == "add-vline-left" || s == "add-vline-right") {
+			flag.message(bformat(
+			N_("Can't add vertical grid lines in '%1$s'"),
+				name_));
+			flag.enabled(false);
+			return true;
+		}
+		return MathGridInset::getStatus(cur, cmd, flag);	
+		}
+        default:
+		return MathGridInset::getStatus(cur, cmd, flag);
+        }
 }
 
 
Index: math_amsarrayinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_amsarrayinset.h,v
retrieving revision 1.18
diff -u -r1.18 math_amsarrayinset.h
--- math_amsarrayinset.h	23 Nov 2004 23:04:49 -0000	1.18
+++ math_amsarrayinset.h	29 Mar 2005 13:53:38 -0000
@@ -32,6 +32,9 @@
 	MathAMSArrayInset const * asAMSArrayInset() const { return this; }
 
 	///
+	bool getStatus(LCursor & cur, FuncRequest const & cmd,
+		FuncStatus & flag) const;
+	///
 	void write(WriteStream & os) const;
 	///
 	void normalize(NormalStream &) const;
Index: math_splitinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_splitinset.C,v
retrieving revision 1.15
diff -u -r1.15 math_splitinset.C
--- math_splitinset.C	23 Nov 2004 23:04:52 -0000	1.15
+++ math_splitinset.C	29 Mar 2005 13:53:38 -0000
@@ -15,7 +15,16 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 
+#include "funcrequest.h"
+#include "FuncStatus.h"
+#include "gettext.h"
 
+#include "support/lstrings.h"
+
+#include <sstream>
+
+using std::istringstream;
+using lyx::support::bformat;
 using std::string;
 using std::auto_ptr;
 
@@ -44,6 +53,29 @@
 	if (name_ == "alignedat")
 		return (col & 1) ? 'l' : 'r';
 	return 'l';
+}
+
+
+bool MathSplitInset::getStatus(LCursor & cur, FuncRequest const & cmd,
+		FuncStatus & flag) const
+{
+	switch (cmd.action) {
+	case LFUN_TABULAR_FEATURE: {
+		istringstream is(cmd.argument);
+		string s;
+		is >> s;
+		if (s == "add-vline-left" || s == "add-vline-right") {
+			flag.message(bformat(
+			N_("Can't add vertical grid lines in '%1$s'"),
+				name_));
+			flag.enabled(false);
+			return true;
+		}
+		return MathGridInset::getStatus(cur, cmd, flag);
+		}
+	default:
+		return MathGridInset::getStatus(cur, cmd, flag);
+	}
 }
 
 
Index: math_splitinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_splitinset.h,v
retrieving revision 1.13
diff -u -r1.13 math_splitinset.h
--- math_splitinset.h	23 Nov 2004 23:04:52 -0000	1.13
+++ math_splitinset.h	29 Mar 2005 13:53:38 -0000
@@ -19,7 +19,11 @@
 public:
 	///
 	explicit MathSplitInset(std::string const & name);
+
 	///
+	bool getStatus(LCursor & cur, FuncRequest const & cmd,
+		FuncStatus & flag) const;
+
 	void write(WriteStream & os) const;
 	///
 	int defaultColSpace(col_type) { return 0; }
Index: math_substackinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_substackinset.C,v
retrieving revision 1.18
diff -u -r1.18 math_substackinset.C
--- math_substackinset.C	23 Nov 2004 23:04:52 -0000	1.18
+++ math_substackinset.C	29 Mar 2005 13:53:38 -0000
@@ -15,6 +15,17 @@
 #include "math_mathmlstream.h"
 #include "support/std_ostream.h"
 
+#include "funcrequest.h"
+#include "FuncStatus.h"
+#include "gettext.h"
+
+#include "support/lstrings.h"
+
+#include <sstream>
+
+using std::istringstream;
+using lyx::support::bformat;
+using std::string;
 using std::auto_ptr;
 
 
@@ -44,6 +55,29 @@
 void MathSubstackInset::draw(PainterInfo & pi, int x, int y) const
 {
 	MathGridInset::draw(pi, x + 1, y);
+}
+
+
+bool MathSubstackInset::getStatus(LCursor & cur, FuncRequest const & cmd,
+		FuncStatus & flag) const
+{
+	switch (cmd.action) {
+	case LFUN_TABULAR_FEATURE: {
+		istringstream is(cmd.argument);
+		string const name("substack");
+		string s;
+		is >> s;
+		if (s == "add-vline-left" || s == "add-vline-right") {
+			flag.message(bformat(
+			N_("Can't add vertical grid lines in '%1$s'"), name));
+			flag.enabled(false);
+			return true;
+		}
+		return MathGridInset::getStatus(cur, cmd, flag);
+		}
+	default:
+		return MathGridInset::getStatus(cur, cmd, flag);
+	}
 }
 
 
Index: math_substackinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_substackinset.h,v
retrieving revision 1.14
diff -u -r1.14 math_substackinset.h
--- math_substackinset.h	23 Nov 2004 23:04:52 -0000	1.14
+++ math_substackinset.h	29 Mar 2005 13:53:38 -0000
@@ -31,6 +31,9 @@
 	///
 	void normalize();
 	///
+	bool getStatus(LCursor & cur, FuncRequest const & cmd,
+		FuncStatus & flag) const;
+	///
 	void infoize(std::ostream & os) const;
 	///
 	void write(WriteStream & os) const;

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to