On Mon, 2005-02-07 at 17:50, Martin Vermeer wrote:
> On Sun, 2005-02-06 at 13:01, Martin Vermeer wrote:
> > Something I was very happy discovering, as I was already mentally
> > prepared to install the 'pmat' package and engage in ERT :-/
> > 
> > In the matrix set-up dialogue on the math panel, you can add pipe
> > characters to the "ccccc" alignment string, and they will come out as
> > vertical lines in the displayed AND printed matrix... cool. Thus
> > encouraged, I added \hline to the start of the first cell on a line, and
> > true enough a horizontal line appeared in the printout. And after saving
> > and reloading also in the display.
> > 
> > I haven't looked very hard, but couldn't find reference to this in the
> > documentation, or on the Web by googling. This is the kind of thing that
> > is not very discoverable for someone not already proficient in LaTeX
> > math.
> > 
> > It should at least be in the docs, but better even, in the UI. And there
> > are already menu shortcuts for aligning and even swapping matrix rows;
> > how hard would it be to add one for a horizontal line?
> > 
> > - Martin
> 
> Here is a patch that removes the discoverability problem at least for
> vertical rules.
> 
> (First time I used Qt Designer BTW!)
> 
> - Martin

So I went the whole way and implemented the horizontal line UI too. It
wasn't even difficult, and looks remarkably clean now that especially
mathed is so well organized.

Questions around this patch:

1) What about getStatus... appears disabled.
2) Do we need a way to delete a horizontal line too?

- Martin

Index: src/mathed/math_gridinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.C,v
retrieving revision 1.154
diff -u -r1.154 math_gridinset.C
--- src/mathed/math_gridinset.C	24 Nov 2004 21:58:41 -0000	1.154
+++ src/mathed/math_gridinset.C	7 Feb 2005 16:39:12 -0000
@@ -679,6 +679,16 @@
 }
 
 
+void MathGridInset::horLine(row_type row)
+{
+	if (nrows() == 1)
+		return;
+	if (row + 1 == nrows())
+		--row;
+	rowinfo_[row].lines_++;
+}
+
+
 void MathGridInset::addCol(col_type newcol)
 {
 	const col_type nc = ncols();
@@ -1100,6 +1110,8 @@
 				copyRow(cur.row());
 		else if (s == "swap-row")
 			swapRow(cur.row());
+		else if (s == "hor-line")
+			horLine(cur.row());
 		else if (s == "append-column")
 			for (int i = 0, n = extractInt(is); i < n; ++i) {
 				row_type r = cur.row();
Index: src/mathed/math_gridinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.h,v
retrieving revision 1.85
diff -u -r1.85 math_gridinset.h
--- src/mathed/math_gridinset.h	19 Jan 2005 15:03:31 -0000	1.85
+++ src/mathed/math_gridinset.h	7 Feb 2005 16:39:12 -0000
@@ -168,6 +168,8 @@
 	///
 	virtual void swapRow(row_type r);
 	///
+	virtual void horLine(row_type r);
+	///
 	virtual void addCol(col_type c);
 	///
 	virtual void delCol(col_type c);
Index: lib/ui/stdmenus.ui
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ui/stdmenus.ui,v
retrieving revision 1.39
diff -u -r1.39 stdmenus.ui
--- lib/ui/stdmenus.ui	24 Jan 2005 17:12:14 -0000	1.39
+++ lib/ui/stdmenus.ui	7 Feb 2005 16:39:12 -0000
@@ -158,6 +158,7 @@
 		Item "Delete Row|D" "tabular-feature delete-row"
 		Item "Copy Row" "tabular-feature copy-row"
 		Item "Swap Rows" "tabular-feature swap-row"
+		Item "Add Line Above" "tabular-feature hor-line"
 		Separator
 		Item "Add Column|C" "tabular-feature append-column"
 		Item "Delete Column|e" "tabular-feature delete-column"

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

Reply via email to