I want to ask for some opinions about this change:
* when you select multiple cells in an array-like math inset
* and then insert a InsetMathNest (e.g. a mathbf inset, a frac, a ^
inset)
* the inset is put into _each_ selected cell with the old cell's
contents put into the first cell of the new inset.
This is very natural for math font changes and also for the ^ case,
but maybe strange for things like frac. Currently in the case of non-
nest math insets (e.g. \alpha) a new inset is only put into the first
cell, though one could extend this as well to the upper behavior.
I am not sure about my opinion whether all this is a great feature
saving typing or a bug for cases like \frac.
Stefan
Am 18.03.2008 um 11:58 schrieb [EMAIL PROTECTED]:
Author: sts
Date: Tue Mar 18 11:58:57 2008
New Revision: 23804
URL: http://www.lyx.org/trac/changeset/23804
Log:
* another try on http://bugzilla.lyx.org/show_bug.cgi?id=4566:
"Eqnarray multiple cells size change erases what they contain"
We also apply LFUN_MATH_INSERT to every selected cell if a single
math inset is inserted.
Modified:
lyx-devel/trunk/src/mathed/InsetMathNest.cpp
Modified: lyx-devel/trunk/src/mathed/InsetMathNest.cpp
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/mathed/InsetMathNest.cpp?rev=23804
=
=
=
=
=
=
=
=
======================================================================
--- lyx-devel/trunk/src/mathed/InsetMathNest.cpp (original)
+++ lyx-devel/trunk/src/mathed/InsetMathNest.cpp Tue Mar 18 11:58:57
2008
@@ -412,15 +412,14 @@
void InsetMathNest::handleFont(Cursor & cur, docstring const & arg,
docstring const & font)
{
+ cur.recordUndoSelection();
+
// this whole function is a hack and won't work for incremental font
// changes...
-
- if (cur.inset().asInsetMath()->name() == font) {
- cur.recordUndoInset();
+ if (cur.inset().asInsetMath()->name() == font)
cur.handleFont(to_utf8(font));
- } else {
+ else
handleNest(cur, createInsetMath(font), arg);
- }
}
@@ -439,7 +438,6 @@
return;
if (i1.idx() == i2.idx()) {
// the easy case where only one cell is selected
- cur.recordUndo();
cur.handleNest(nest);
cur.insert(arg);
return;
@@ -447,7 +445,6 @@
// multiple selected cells in a simple non-grid inset
if (i1.asInsetMath()->nrows() == 0 || i1.asInsetMath()->ncols() ==
0) {
- cur.recordUndoInset();
for (idx_type i = i1.idx(); i <= i2.idx(); ++i) {
// select cell
cur.idx() = i;
@@ -469,7 +466,6 @@
}
// the complicated case with multiple selected cells in a grid
- cur.recordUndoInset();
row_type r1, r2;
col_type c1, c2;
cap::region(i1, i2, r1, r2, c1, c2);
@@ -497,7 +493,7 @@
void InsetMathNest::handleFont2(Cursor & cur, docstring const & arg)
{
- cur.recordUndo();
+ cur.recordUndoSelection();
Font font;
bool b;
font.fromString(to_utf8(arg), b);
@@ -1073,10 +1069,16 @@
// math-insert only handles special math things like "matrix".
case LFUN_MATH_INSERT: {
cur.recordUndoSelection();
- if (cmd.argument() == "^" || cmd.argument() == "_") {
+ if (cmd.argument() == "^" || cmd.argument() == "_")
interpretChar(cur, cmd.argument()[0]);
- } else
- cur.niceInsert(cmd.argument());
+ else {
+ MathData ar;
+ asArray(cmd.argument(), ar);
+ if (ar.size() == 1 && ar[0]->asNestInset())
+ handleNest(cur, ar[0]);
+ else
+ cur.niceInsert(cmd.argument());
+ }
break;
}