Le 08/01/2016 08:01, Guillaume Munch a écrit :

Ok, this is what I did.



The last patch contains a minor rephrasing that I did not try to compile
before showing it to you, because it was straightforward and unrelated
to anything we had discussed (isTable is now defined as a whitelist and
not as a blacklist for future-proofness). There was a typo, and the
correct patch is attached. I should have checked the final compilation
before sending it.


Guillaume
>From 7b9cacecbcc31c428b77d5bd9a5c0f5da40877bb Mon Sep 17 00:00:00 2001
From: Guillaume Munch <g...@lyx.org>
Date: Fri, 11 Dec 2015 20:45:57 +0000
Subject: [PATCH 9/9] Let tabular-feature commands fall through non-table math
 insets. (#4189)

---
 src/mathed/InsetMathHull.cpp | 37 +++++++++++++++++++++++++++----------
 src/mathed/InsetMathHull.h   |  2 ++
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 5b884b4..f6c1e00 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -1040,6 +1040,24 @@ void InsetMathHull::footer_write(WriteStream & os) const
 }
 
 
+bool InsetMathHull::isTable() const
+{
+	switch (type_) {
+	case hullEqnArray:
+	case hullAlign:
+	case hullAlignAt:
+	case hullXAlignAt:
+	case hullXXAlignAt:
+	case hullFlAlign:
+	case hullMultline:
+	case hullGather:
+		return true;
+	default:
+		return false;
+	}
+}
+
+
 bool InsetMathHull::rowChangeOK() const
 {
 	return
@@ -1702,6 +1720,13 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
 		break;
 	}
 
+	case LFUN_TABULAR_FEATURE:
+		if (!isTable())
+			cur.undispatched();
+		else
+			InsetMathGrid::doDispatch(cur, cmd);
+		break;
+
 	default:
 		InsetMathGrid::doDispatch(cur, cmd);
 		break;
@@ -1817,6 +1842,8 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
 		return InsetMathGrid::getStatus(cur, cmd, status);
 
 	case LFUN_TABULAR_FEATURE: {
+		if (!isTable())
+			return false;
 		string s = cmd.getArg(0);
 		if (!rowChangeOK()
 		    && (s == "append-row"
@@ -1838,16 +1865,6 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
 			status.setEnabled(false);
 			return true;
 		}
-		if ((type_ == hullSimple
-		  || type_ == hullEquation
-		  || type_ == hullNone) &&
-		    (s == "add-hline-above" || s == "add-hline-below")) {
-			status.message(bformat(
-				from_utf8(N_("Can't add horizontal grid lines in '%1$s'")),
-				hullName(type_)));
-			status.setEnabled(false);
-			return true;
-		}
 		if (s == "add-vline-left" || s == "add-vline-right") {
 			status.message(bformat(
 				from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h
index 9598ad4..e02c619 100644
--- a/src/mathed/InsetMathHull.h
+++ b/src/mathed/InsetMathHull.h
@@ -236,6 +236,8 @@ private:
 	ColorCode standardColor() const;
 	/// consistency check
 	void check() const;
+	/// does it understand tabular-feature commands?
+	bool isTable() const;
 	/// can this change its number of rows?
 	bool rowChangeOK() const;
 	/// can this change its number of cols?
-- 
2.1.4

Reply via email to