Le 19/01/2016 16:52, Uwe Stöhr a écrit :
Am 11.01.2016 um 03:21 schrieb Guillaume Munch:

See the attached for two "safe" (and easy to read) patches, if you agree
that a safe patch that we have been discussing for a month can still get
in for 2.2.

I wanted to apply the patches at once and this way destroyed my complete
git folder. Seems to be a bug in TortoiseGit. After the application it
tells me that nothing was changed, also the Git log is empty. But all
line endings are destroyed and the editor of MSVC cannot read the files
anymore.


I was not quite expecting my patch to be unsafe in this way! Please tell us if you find the cause.



However, I think I fixed it, re-applied the patches and tried to compile
but get:

   ..\..\..\src\mathed\InsetMathHull.cpp(1257): error C2039:
'isMutable': Is no element of 'lyx::InsetMathHull'
[D:\LyXGit\Master\compile-2010\src\mathed\mathed.vcxproj]



You are right, this is something I just forgot to remove during the rebase (and belongs to the third patch not proposed here). Try the attached (if you fixed your other bug!).

Note that I do not know if it applies cleanly now. I tried to rebase against newest master but your manipulation error now inteferes. I will have to rebase by hand.
>From fd5691e6489c34db3120ba24ce03cd496aacb134 Mon Sep 17 00:00:00 2001
From: Guillaume Munch <g...@lyx.org>
Date: Sun, 13 Dec 2015 03:32:32 +0000
Subject: [PATCH 1/2] Display the correct horizontal alignment in AMS
 environments

A longstanding problem... (related: #1861)

The columns in AMS math environments have a fixed alignment (colAlign() in
InsetMathGrid.cpp). We set this alignment for display (Georg's
displayColAlign()) in InsetMathHull and InsetMathSplit. This is done according
to tests and documentation for the various environments.

There is also some mechanical code factoring via colAlign().

Finally, I disable setting the horizontal alignment in InsetMathSplit, which has
no impact on the LaTeX output, and has no longer any impact on the screen. (As
for vertical alignment I discovered that it was in fact customisable for
\aligned & friends! I hope that the more faithful interface will let other
users discover that too.)
---
 src/mathed/InsetMathGrid.cpp  | 25 +++++++++++++++++++++++++
 src/mathed/InsetMathGrid.h    |  5 +++--
 src/mathed/InsetMathHull.cpp  | 26 ++++++++++++++++----------
 src/mathed/InsetMathSplit.cpp | 37 +++++++++++++++++++++++++++++++------
 src/mathed/InsetMathSplit.h   |  2 ++
 5 files changed, 77 insertions(+), 18 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 536f4bd..fca5722 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1838,4 +1838,29 @@ bool InsetMathGrid::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
+// static
+char InsetMathGrid::colAlign(HullType type, col_type col)
+{
+	switch (type) {
+	case hullEqnArray:
+		return "rcl"[col % 3];
+
+	case hullMultline:
+	case hullGather:
+		return 'c';
+
+	case hullAlign:
+	case hullAlignAt:
+	case hullXAlignAt:
+	case hullXXAlignAt:
+	case hullFlAlign:
+		return "rl"[col & 1];
+
+	default:
+		return 'c';
+	}
+}
+
+
+
 } // namespace lyx
diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h
index bd3066d..709f492 100644
--- a/src/mathed/InsetMathGrid.h
+++ b/src/mathed/InsetMathGrid.h
@@ -258,10 +258,11 @@ protected:
 	virtual docstring eocString(col_type col, col_type lastcol) const;
 	/// splits cells and shifts right part to the next cell
 	void splitCell(Cursor & cur);
-	/// Column aligmment for display of cell \p idx.
+	/// Column alignment for display of cell \p idx.
 	/// Must not be written to file!
 	virtual char displayColAlign(idx_type idx) const;
-
+	/// The value of a fixed col align for a certain hull type 
+	static char colAlign(HullType type, col_type col);
 
 	/// row info.
 	/// rowinfo_[nrows()] is a dummy row used only for hlines.
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 097a344..78137de 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -349,28 +349,34 @@ bool InsetMathHull::idxLast(Cursor & cur) const
 }
 
 
+//FIXME: This has probably no effect and can be removed.
 char InsetMathHull::defaultColAlign(col_type col)
 {
-	if (type_ == hullEqnArray)
-		return "rcl"[col];
-	if (type_ == hullMultline)
-		return 'c';
-	if (type_ == hullGather)
-		return 'c';
-	if (type_ >= hullAlign)
-		return "rl"[col & 1];
-	return 'c';
+	return colAlign(type_, col);
 }
 
 
 char InsetMathHull::displayColAlign(idx_type idx) const
 {
-	if (type_ == hullMultline) {
+	switch (type_) {
+	case hullMultline: {
 		row_type const r = row(idx);
 		if (r == 0)
 			return 'l';
 		if (r == nrows() - 1)
 			return 'r';
+		return 'c';
+	}
+	case hullEqnArray:
+	case hullGather:
+	case hullAlign:
+	case hullAlignAt:
+	case hullXAlignAt:
+	case hullXXAlignAt:
+	case hullFlAlign:
+		return colAlign(type_, col(idx));
+	default:
+		break;
 	}
 	return InsetMathGrid::displayColAlign(idx);
 }
diff --git a/src/mathed/InsetMathSplit.cpp b/src/mathed/InsetMathSplit.cpp
index 5c425fb..28a339f 100644
--- a/src/mathed/InsetMathSplit.cpp
+++ b/src/mathed/InsetMathSplit.cpp
@@ -48,20 +48,41 @@ Inset * InsetMathSplit::clone() const
 }
 
 
+//FIXME: This has probably no effect and can be removed.
 char InsetMathSplit::defaultColAlign(col_type col)
 {
-	if (name_ == "split")
-		return 'l';
 	if (name_ == "gathered")
 		return 'c';
-	if (name_ == "aligned" || name_ == "align")
-		return (col & 1) ? 'l' : 'r';
-	if (name_ == "alignedat")
-		return (col & 1) ? 'l' : 'r';
+	if (name_ == "lgathered")
+		return 'l';
+	if (name_ == "rgathered")
+		return 'r';
+	if (name_ == "split"
+	    || name_ == "aligned"
+	    || name_ == "align"
+	    || name_ == "alignedat")
+		return colAlign(hullAlign, col);
 	return 'l';
 }
 
 
+char InsetMathSplit::displayColAlign(idx_type idx) const
+{
+	if (name_ == "gathered")
+		return 'c';
+	if (name_ == "lgathered")
+		return 'l';
+	if (name_ == "rgathered")
+		return 'r';
+	if (name_ == "split"
+	    || name_ == "aligned"
+	    || name_ == "align"
+	    || name_ == "alignedat")
+		return colAlign(hullAlign, col(idx));
+	return InsetMathGrid::displayColAlign(idx);
+}
+
+
 void InsetMathSplit::draw(PainterInfo & pi, int x, int y) const
 {
 	InsetMathGrid::draw(pi, x, y);
@@ -86,6 +107,10 @@ bool InsetMathSplit::getStatus(Cursor & cur, FuncRequest const & cmd,
 			flag.setEnabled(false);
 			return true;
 		}
+		if (s == "align-left" || s == "align-center" || s == "align-right") {
+			flag.setEnabled(false);
+			return true;
+		}
 		break;
 	}
 	default:
diff --git a/src/mathed/InsetMathSplit.h b/src/mathed/InsetMathSplit.h
index b0ff437..1b2aa23 100644
--- a/src/mathed/InsetMathSplit.h
+++ b/src/mathed/InsetMathSplit.h
@@ -43,6 +43,8 @@ public:
 	///
 	char defaultColAlign(col_type);
 	///
+	char displayColAlign(idx_type idx) const;
+	///
 	InsetCode lyxCode() const { return MATH_SPLIT_CODE; }
 
 private:
-- 
2.1.4

>From 3dd03a665824baae5b9e8d3609e4d4af6913da06 Mon Sep 17 00:00:00 2001
From: Guillaume Munch <g...@lyx.org>
Date: Sun, 20 Dec 2015 20:56:34 +0000
Subject: [PATCH 2/2] Fix the display of column spacing in AMS environments

AMS align environment should have some spacing between odd and even columns.

Add a new virtual method displayColSpace() to InsetMathGrid, InsetMathHull and
InsetMathSplit.
---
 src/mathed/InsetMathGrid.cpp  | 40 ++++++++++++++++++++++++++++++++++++----
 src/mathed/InsetMathGrid.h    |  8 ++++++++
 src/mathed/InsetMathHull.cpp  |  7 +++++++
 src/mathed/InsetMathHull.h    |  2 ++
 src/mathed/InsetMathSplit.cpp | 11 +++++++++++
 src/mathed/InsetMathSplit.h   |  2 ++
 6 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index fca5722..2ea35a4 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -486,7 +486,7 @@ void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const
 		colinfo_[col].offset_ =
 			colinfo_[col - 1].offset_ +
 			colinfo_[col - 1].width_ +
-			colinfo_[col - 1].skip_ +
+			displayColSpace(col - 1) +
 			colsep() +
 			colinfo_[col].lines_ * vlinesep();
 	}
@@ -508,7 +508,7 @@ void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const
 			int const nextoffset =
 				colinfo_[first].offset_ +
 				wid +
-				colinfo_[last].skip_ +
+				displayColSpace(last) +
 				colsep() +
 				colinfo_[last+1].lines_ * vlinesep();
 			int const dx = nextoffset - colinfo_[last+1].offset_;
@@ -741,7 +741,7 @@ void InsetMathGrid::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
 		colinfo_[col].offset_ =
 			colinfo_[col - 1].offset_ +
 			colinfo_[col - 1].width_ +
-			colinfo_[col - 1].skip_ +
+			displayColSpace(col - 1) +
 			1 ; //colsep() +
 			//colinfo_[col].lines_ * vlinesep();
 	}
@@ -953,7 +953,7 @@ int InsetMathGrid::cellWidth(idx_type idx) const
 		col_type c2 = c1 + ncellcols(idx);
 		return colinfo_[c2].offset_
 			- colinfo_[c1].offset_
-			- colinfo_[c2].skip_
+			- displayColSpace(c2)
 			- colsep()
 			- colinfo_[c2].lines_ * vlinesep();
 	}
@@ -1378,6 +1378,11 @@ char InsetMathGrid::displayColAlign(idx_type idx) const
 }
 
 
+int InsetMathGrid::displayColSpace(col_type col) const
+{
+	return colinfo_[col].skip_;
+}
+
 void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
 	//lyxerr << "*** InsetMathGrid: request: " << cmd << endl;
@@ -1862,5 +1867,32 @@ char InsetMathGrid::colAlign(HullType type, col_type col)
 }
 
 
+//static
+int InsetMathGrid::colSpace(HullType type, col_type col)
+{
+	int alignInterSpace;
+	switch (type) {
+	case hullEqnArray:
+		return 5;
+	
+	case hullAlign:
+		alignInterSpace = 20;
+		break;
+	case hullAlignAt:
+		alignInterSpace = 0;
+		break;
+	case hullXAlignAt:
+		alignInterSpace = 40;
+		break;
+	case hullXXAlignAt:
+	case hullFlAlign:
+		alignInterSpace = 60;
+		break;
+	default:
+		return 0;
+	}
+	return (col % 2) ? alignInterSpace : 0;
+}
+
 
 } // namespace lyx
diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h
index 709f492..7faf938 100644
--- a/src/mathed/InsetMathGrid.h
+++ b/src/mathed/InsetMathGrid.h
@@ -261,8 +261,16 @@ protected:
 	/// Column alignment for display of cell \p idx.
 	/// Must not be written to file!
 	virtual char displayColAlign(idx_type idx) const;
+	/// Column spacing for display of column \p col.
+	/// Must not be written to file!
+	virtual int displayColSpace(col_type col) const;
+
+	// The following two functions are used in InsetMathHull and
+	// InsetMathSplit.
 	/// The value of a fixed col align for a certain hull type 
 	static char colAlign(HullType type, col_type col);
+	/// The value of a fixed col spacing for a certain hull type
+	static int colSpace(HullType type, col_type col);
 
 	/// row info.
 	/// rowinfo_[nrows()] is a dummy row used only for hlines.
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 78137de..595f0f5 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -382,6 +382,13 @@ char InsetMathHull::displayColAlign(idx_type idx) const
 }
 
 
+int InsetMathHull::displayColSpace(col_type col) const
+{
+	return colSpace(type_, col);
+}
+
+
+//FIXME: This has probably no effect and can be removed.
 int InsetMathHull::defaultColSpace(col_type col)
 {
 	if (type_ == hullAlign || type_ == hullAlignAt)
diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h
index 9598ad4..1d82ed8 100644
--- a/src/mathed/InsetMathHull.h
+++ b/src/mathed/InsetMathHull.h
@@ -111,6 +111,8 @@ public:
 	///
 	int defaultColSpace(col_type col);
 	///
+	int displayColSpace(col_type col) const;
+	///
 	char defaultColAlign(col_type col);
 	///
 	char displayColAlign(idx_type idx) const;
diff --git a/src/mathed/InsetMathSplit.cpp b/src/mathed/InsetMathSplit.cpp
index 28a339f..ff3eaaa 100644
--- a/src/mathed/InsetMathSplit.cpp
+++ b/src/mathed/InsetMathSplit.cpp
@@ -83,6 +83,17 @@ char InsetMathSplit::displayColAlign(idx_type idx) const
 }
 
 
+int InsetMathSplit::displayColSpace(col_type col) const
+{
+	if (name_ == "split" || name_ == "aligned" || name_ == "align")
+		return colSpace(hullAlign, col);
+	if (name_ == "alignedat")
+		return colSpace(hullAlignAt, col);
+	return 0;
+}
+
+
+
 void InsetMathSplit::draw(PainterInfo & pi, int x, int y) const
 {
 	InsetMathGrid::draw(pi, x, y);
diff --git a/src/mathed/InsetMathSplit.h b/src/mathed/InsetMathSplit.h
index 1b2aa23..1226534 100644
--- a/src/mathed/InsetMathSplit.h
+++ b/src/mathed/InsetMathSplit.h
@@ -41,6 +41,8 @@ public:
 	///
 	int defaultColSpace(col_type) { return 0; }
 	///
+	int displayColSpace(col_type col) const;
+	///
 	char defaultColAlign(col_type);
 	///
 	char displayColAlign(idx_type idx) const;
-- 
2.1.4

Reply via email to