On Sat, Mar 12, 2005 at 11:54:08AM +0100, Juergen Spitzmueller wrote:
> Martin Vermeer wrote:
> > Here, the command is dispatched only for the current cell, precisely the
> > behaviour we are seeing.
> >
> > Shouldn't we here test for "tablemode" and loop over the selected cells?
> >
> > Do you agree?
> 
> Yes, this sounds reasonable (though I haven't checked the code).
> 
> Jürgen 

Patch attached. Seems to work for me, at least for for various character
attributes, and for rows/columns/sub-rectangles of the table.

Please test. There are still easy ways to crash tables, but
I think this is an improvement. One crash you can get by painting
several cells and then typing C-l for ERT. This could be easily
eliminated by a separate switch case. Any others?

- Martin

Index: insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.454
diff -u -r1.454 insettabular.C
--- insettabular.C      8 Feb 2005 13:18:04 -0000       1.454
+++ insettabular.C      12 Mar 2005 16:51:24 -0000
@@ -725,9 +725,27 @@
                break;
 
        default:
-               // we try to handle this event in the insets dispatch function.
-               cell(cur.idx())->dispatch(cur, cmd);
-               break;
+               if (tablemode(cur)) {
+                       row_type rs, re;
+                       col_type cs, ce;
+                       getSelection(cur, rs, re, cs, ce);
+                       for (row_type i = rs; i <= re; ++i)
+                               for (col_type j = cs; j <= ce; ++j) {
+                                       // cursor follows cell:
+                                       cur.idx() = tabular.getCellNumber(i, j);
+                                       // select this cell only:
+                                       cur.pos() = 0;
+                                       cur.resetAnchor();
+                                       cur.pos() = cur.top().lastpos();
+                                       cur.setCursor(cur);
+                                       cur.setSelection();
+                                       cell(cur.idx())->dispatch(cur, cmd);
+                               }
+                       break;
+               } else {
+                       cell(cur.idx())->dispatch(cur, cmd);
+                       break;
+               }
        }
 
        InsetTabularMailer(*this).updateDialog(&cur.bv());

Attachment: pgpzYd1JY7Vgt.pgp
Description: PGP signature

Reply via email to