Alfredo Braunstein <[EMAIL PROTECTED]> writes: | So the change of behaviour of insertRow is intended? (now insertRow(0,...) | will insert at the end, instead of the beginning). Note that you have losed | completely the ability to insert at the beginning (this may be the reason | it doesn't work). I don't understand this "half" move.
This is an updated patch, in this version insertRow with an iterator of end() just inserts on the beginning. However, the case <new doc> 1 2 3 4<left><up><up><up><kill-line> still have problems with row reordering, and I do not really see why. But it is better I guess.
? src/newfile1.lyx Index: src/lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.151 diff -u -p -r1.151 lyxtext.h --- src/lyxtext.h 27 Mar 2003 12:41:46 -0000 1.151 +++ src/lyxtext.h 28 Mar 2003 09:06:19 -0000 @@ -510,8 +510,9 @@ private: /** inserts a new row behind the specified row, increments the touched counters */ - void insertRow(Row * row, Paragraph * par, lyx::pos_type pos); - + RowList::iterator + insertRow(RowList::iterator rowit, + Paragraph * par, lyx::pos_type pos); /// removes the row and reset the touched counters void removeRow(Row * row); @@ -519,11 +520,11 @@ private: void removeParagraph(Row * row); /// insert the specified paragraph behind the specified row - void insertParagraph(Paragraph * par, Row * row); + void insertParagraph(Paragraph * par, RowList::iterator rowit); /** appends the implizit specified paragraph behind the specified row, * start at the implizit given position */ - void appendParagraph(Row * row); + void appendParagraph(RowList::iterator rowit); /// void breakAgain(Row * row); Index: src/text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.328 diff -u -p -r1.328 text.C --- src/text.C 27 Mar 2003 12:41:46 -0000 1.328 +++ src/text.C 28 Mar 2003 09:06:20 -0000 @@ -1312,20 +1312,21 @@ void LyXText::setHeightOfRow(Row * row) // Appends the implicit specified paragraph before the specified row, // start at the implicit given position -void LyXText::appendParagraph(Row * row) +void LyXText::appendParagraph(RowList::iterator rowit) { - pos_type const last = row->par()->size(); + lyx::Assert(rowit != rowlist_.end()); + + pos_type const last = rowit->par()->size(); bool done = false; do { - pos_type z = rowBreakPoint(*row); + pos_type z = rowBreakPoint(*rowit); - Row * tmprow = row; + RowList::iterator tmprow = rowit; if (z < last) { ++z; - insertRow(row, row->par(), z); - row = row->next(); + rowit = insertRow(rowit, rowit->par(), z); } else { done = true; } @@ -1334,7 +1335,7 @@ void LyXText::appendParagraph(Row * row) // fixed fill setting now by calling inset->update() in // SingleWidth when needed! tmprow->fill(fill(*tmprow, workWidth())); - setHeightOfRow(tmprow); + setHeightOfRow(&*tmprow); } while (!done); } @@ -1342,6 +1343,8 @@ void LyXText::appendParagraph(Row * row) void LyXText::breakAgain(Row * row) { + lyx::Assert(row); + bool not_ready = true; do { @@ -1387,6 +1390,8 @@ void LyXText::breakAgain(Row * row) // this is just a little changed version of break again void LyXText::breakAgainOneRow(Row * row) { + lyx::Assert(row); + pos_type z = rowBreakPoint(*row); Row * tmprow = row; Index: src/text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.304 diff -u -p -r1.304 text2.C --- src/text2.C 28 Mar 2003 04:04:35 -0000 1.304 +++ src/text2.C 28 Mar 2003 09:06:22 -0000 @@ -88,7 +88,7 @@ void LyXText::init(BufferView * bview, b while (par) { if (rowlist_.empty()) - insertParagraph(par, 0); + insertParagraph(par, rowlist_.end()); else insertParagraph(par, lastRow()); par = par->next(); @@ -263,18 +263,18 @@ void LyXText::setCharFont(Buffer const * // inserts a new row before the specified row, increments // the touched counters -void LyXText::insertRow(Row * row, Paragraph * par, - pos_type pos) +RowList::iterator + LyXText::insertRow(RowList::iterator rowit, Paragraph * par, + pos_type pos) { Row * tmprow = new Row; tmprow->par(par); tmprow->pos(pos); - if (!row) { - rowlist_.insert(rowlist_.begin(), tmprow); - } else { - rowlist_.insert(row->next(), tmprow); - } + if (rowit == rowlist_.end()) + return rowlist_.insert(rowlist_.begin(), tmprow); + else + return rowlist_.insert(boost::next(rowit), tmprow); } @@ -326,17 +326,13 @@ void LyXText::removeParagraph(Row * row) } -void LyXText::insertParagraph(Paragraph * par, Row * row) +void LyXText::insertParagraph(Paragraph * par, RowList::iterator rowit) { // insert a new row, starting at position 0 - insertRow(row, par, 0); + RowList::iterator rit = insertRow(rowit, par, 0); // and now append the whole paragraph before the new row - if (!row) { - appendParagraph(firstRow()); - } else { - appendParagraph(row->next()); - } + appendParagraph(rit); } @@ -718,11 +714,8 @@ void LyXText::redoParagraphs(LyXCursor c // the ownerParagrah() so the paragraph inside the row is NOT // my really first par anymore. Got it Lars ;) (Jug 20011206) first_phys_par = ownerParagraph(); - lyxerr << "ownerParagraph" << endl; - } else { first_phys_par = tmprow->par(); - lyxerr << "tmprow->par()" << endl; // Find first row of this paragraph. while (tmprow->previous() @@ -758,7 +751,11 @@ void LyXText::redoParagraphs(LyXCursor c tmppar = first_phys_par; do { if (tmppar) { - insertParagraph(tmppar, tmprow); + if (!tmprow) + insertParagraph(tmppar, firstRow()); + else + insertParagraph(tmppar, tmprow); + if (!tmprow) { tmprow = firstRow(); }
-- Lgb