git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6650 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-03-30 18:42:37 +00:00
parent eab9836ca2
commit 0eaa5ae519
7 changed files with 142 additions and 119 deletions

View File

@ -1,5 +1,23 @@
2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net> 2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net>
* text2.C (LyXText): adjust.
(init): adjust
(removeRow): make it take a RowList::iterator as arg, adjust.
(fullRebreak): adjust
(deleteEmptyParagraphMechanism): adjust
(clearPaint): adjust
(postPaint): adjust
* text.C (top_y): adjust
(setHeightOfRow): make it take a RowList::iterator as arg, adjust.
(breakAgain): make it take a RowList::iterator as arg, adjust.
(breakParagraph): adjust
(insertChar): adjust
(backspace): adjust
* lyxtext.h: make anchor_row_ be a RowList::iterator, ditto
need_break_row, and refresh_row.
* text3.C (dispatch): adjust * text3.C (dispatch): adjust
* text2.C (checkParagraph): adjust * text2.C (checkParagraph): adjust

View File

@ -1,6 +1,7 @@
2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net> 2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net>
* screen.C (drawFromTo): adjust for RowList. * screen.C (drawFromTo): adjust for RowList.
(update): adjust.
2003-03-29 John Levon <levon@movementarian.org> 2003-03-29 John Levon <levon@movementarian.org>

View File

@ -263,11 +263,11 @@ void LyXScreen::update(BufferView & bv, int yo, int xo)
case LyXText::REFRESH_ROW: case LyXText::REFRESH_ROW:
{ {
// ok I will update the current cursor row // ok I will update the current cursor row
drawOneRow(text, &bv, text->refresh_row, text->refresh_y, drawOneRow(text, &bv, &*text->refresh_row, text->refresh_y,
yo, xo); yo, xo);
// this because if we had a major update the refresh_row could // this because if we had a major update the refresh_row could
// have been set to 0! // have been set to 0!
if (text->refresh_row) { if (text->refresh_row != text->rows().end()) {
expose(0, text->refresh_y - text->top_y() + yo, expose(0, text->refresh_y - text->top_y() + yo,
vwidth, text->refresh_row->height()); vwidth, text->refresh_row->height());
} }

View File

@ -147,7 +147,7 @@ enum kb_action {
LFUN_GOTOFILEROW, LFUN_GOTOFILEROW,
// 100 // 100
LFUN_INSERT_NOTE, LFUN_INSERT_NOTE,
LFUN_ENVIRONMENT_INSERT, LFUN_ENVIRONMENT_INSERT,
LFUN_KMAP_OFF, LFUN_KMAP_OFF,
LFUN_KMAP_PRIM, LFUN_KMAP_PRIM,
LFUN_KMAP_SEC, LFUN_KMAP_SEC,

View File

@ -80,7 +80,7 @@ private:
/** the 'anchor' row: the position of this row remains constant /** the 'anchor' row: the position of this row remains constant
* with respect to the top of the screen * with respect to the top of the screen
*/ */
Row * anchor_row_; RowList::iterator anchor_row_;
/** the pixel offset with respect to this row of top_y /** the pixel offset with respect to this row of top_y
*/ */
int anchor_row_offset_; int anchor_row_offset_;
@ -177,7 +177,7 @@ public:
void fullRebreak(); void fullRebreak();
/// ///
Row * need_break_row; RowList::iterator need_break_row;
/// clear any pending paints /// clear any pending paints
void clearPaint(); void clearPaint();
@ -221,7 +221,7 @@ private:
* This must be set if the pending update is REFRESH_ROW. * This must be set if the pending update is REFRESH_ROW.
* It doesn't make any difference for REFRESH_AREA. * It doesn't make any difference for REFRESH_AREA.
*/ */
Row * refresh_row; RowList::iterator refresh_row;
refresh_status refresh_status_; refresh_status refresh_status_;
@ -512,7 +512,7 @@ private:
string copylayouttype; string copylayouttype;
/// removes the row and reset the touched counters /// removes the row and reset the touched counters
void removeRow(Row * row); void removeRow(RowList::iterator rit);
/// remove all following rows of the paragraph of the specified row. /// remove all following rows of the paragraph of the specified row.
void removeParagraph(Row * row); void removeParagraph(Row * row);
@ -525,9 +525,9 @@ private:
void appendParagraph(RowList::iterator rowit); void appendParagraph(RowList::iterator rowit);
/// ///
void breakAgain(Row * row); void breakAgain(RowList::iterator rit);
/// Calculate and set the height of the row /// Calculate and set the height of the row
void setHeightOfRow(Row * row_ptr); void setHeightOfRow(RowList::iterator rit);
// fix the cursor `cur' after a characters has been deleted at `where' // fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism // position. Called by deleteEmptyParagraphMechanism

View File

@ -74,7 +74,7 @@ BufferView * LyXText::bv() const
int LyXText::top_y() const int LyXText::top_y() const
{ {
if (!anchor_row_) if (anchor_row_ == rows().end())
return 0; return 0;
int y = 0; int y = 0;
@ -102,9 +102,9 @@ void LyXText::top_y(int newy)
return; return;
} }
anchor_row_ = &*rit; anchor_row_ = rit;
anchor_row_offset_ = newy - y; anchor_row_offset_ = newy - y;
lyxerr[Debug::GUI] << "changing reference to row: " << anchor_row_ lyxerr[Debug::GUI] << "changing reference to row: " << &*anchor_row_
<< " offset: " << anchor_row_offset_ << endl; << " offset: " << anchor_row_offset_ << endl;
postPaint(0); postPaint(0);
} }
@ -117,7 +117,7 @@ void LyXText::anchor_row(Row * row)
anchor_row_ = row; anchor_row_ = row;
anchor_row_offset_ = old_y - top_y(); anchor_row_offset_ = old_y - top_y();
lyxerr[Debug::GUI] << "anchor_row(): changing reference to row: " lyxerr[Debug::GUI] << "anchor_row(): changing reference to row: "
<< anchor_row_ << " offset: " << anchor_row_offset_ << &*anchor_row_ << " offset: " << anchor_row_offset_
<< endl; << endl;
} }
@ -998,7 +998,7 @@ LColor::color LyXText::backgroundColor() const
} }
void LyXText::setHeightOfRow(Row * row) void LyXText::setHeightOfRow(RowList::iterator rit)
{ {
// get the maximum ascent and the maximum descent // get the maximum ascent and the maximum descent
int asc = 0; int asc = 0;
@ -1016,15 +1016,15 @@ void LyXText::setHeightOfRow(Row * row)
// Correction: only the fontsize count. The other properties // Correction: only the fontsize count. The other properties
// are taken from the layoutfont. Nicer on the screen :) // are taken from the layoutfont. Nicer on the screen :)
Paragraph * par = row->par(); Paragraph * par = rit->par();
Paragraph * firstpar = row->par(); Paragraph * firstpar = par;
LyXLayout_ptr const & layout = firstpar->layout(); LyXLayout_ptr const & layout = firstpar->layout();
// as max get the first character of this row then it can increase but not // as max get the first character of this row then it can increase but not
// decrease the height. Just some point to start with so we don't have to // decrease the height. Just some point to start with so we don't have to
// do the assignment below too often. // do the assignment below too often.
LyXFont font = getFont(bv()->buffer(), par, row->pos()); LyXFont font = getFont(bv()->buffer(), par, rit->pos());
LyXFont::FONT_SIZE const tmpsize = font.size(); LyXFont::FONT_SIZE const tmpsize = font.size();
font = getLayoutFont(bv()->buffer(), par); font = getLayoutFont(bv()->buffer(), par);
LyXFont::FONT_SIZE const size = font.size(); LyXFont::FONT_SIZE const size = font.size();
@ -1033,8 +1033,8 @@ void LyXText::setHeightOfRow(Row * row)
LyXFont labelfont = getLabelFont(bv()->buffer(), par); LyXFont labelfont = getLabelFont(bv()->buffer(), par);
float spacing_val = 1.0; float spacing_val = 1.0;
if (!row->par()->params().spacing().isDefault()) { if (!rit->par()->params().spacing().isDefault()) {
spacing_val = row->par()->params().spacing().getValue(); spacing_val = rit->par()->params().spacing().getValue();
} else { } else {
spacing_val = bv()->buffer()->params.spacing.getValue(); spacing_val = bv()->buffer()->params.spacing.getValue();
} }
@ -1047,16 +1047,16 @@ void LyXText::setHeightOfRow(Row * row)
layout->spacing.getValue() * layout->spacing.getValue() *
spacing_val); spacing_val);
pos_type const pos_end = row->lastPos(); pos_type const pos_end = rit->lastPos();
int labeladdon = 0; int labeladdon = 0;
int maxwidth = 0; int maxwidth = 0;
if (!row->par()->empty()) { if (!rit->par()->empty()) {
// Check if any insets are larger // Check if any insets are larger
for (pos_type pos = row->pos(); pos <= pos_end; ++pos) { for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) {
if (row->par()->isInset(pos)) { if (rit->par()->isInset(pos)) {
tmpfont = getFont(bv()->buffer(), row->par(), pos); tmpfont = getFont(bv()->buffer(), rit->par(), pos);
tmpinset = row->par()->getInset(pos); tmpinset = rit->par()->getInset(pos);
if (tmpinset) { if (tmpinset) {
#if 1 // this is needed for deep update on initialitation #if 1 // this is needed for deep update on initialitation
#warning inset->update FIXME #warning inset->update FIXME
@ -1069,7 +1069,7 @@ void LyXText::setHeightOfRow(Row * row)
maxdesc = max(maxdesc, desc); maxdesc = max(maxdesc, desc);
} }
} else { } else {
maxwidth += singleWidth(row->par(), pos); maxwidth += singleWidth(rit->par(), pos);
} }
} }
} }
@ -1078,7 +1078,7 @@ void LyXText::setHeightOfRow(Row * row)
// This is not completely correct, but we can live with the small, // This is not completely correct, but we can live with the small,
// cosmetic error for now. // cosmetic error for now.
LyXFont::FONT_SIZE maxsize = LyXFont::FONT_SIZE maxsize =
row->par()->highestFontInRange(row->pos(), pos_end, size); rit->par()->highestFontInRange(rit->pos(), pos_end, size);
if (maxsize > font.size()) { if (maxsize > font.size()) {
font.setSize(maxsize); font.setSize(maxsize);
@ -1094,10 +1094,10 @@ void LyXText::setHeightOfRow(Row * row)
++maxasc; ++maxasc;
++maxdesc; ++maxdesc;
row->ascent_of_text(maxasc); rit->ascent_of_text(maxasc);
// is it a top line? // is it a top line?
if (!row->pos() && (row->par() == firstpar)) { if (!rit->pos() && (rit->par() == firstpar)) {
// some parksips VERY EASY IMPLEMENTATION // some parksips VERY EASY IMPLEMENTATION
if (bv()->buffer()->params.paragraph_separation == if (bv()->buffer()->params.paragraph_separation ==
@ -1118,7 +1118,7 @@ void LyXText::setHeightOfRow(Row * row)
} }
// the top margin // the top margin
if (!row->par()->previous() && !isInInset()) if (!rit->par()->previous() && !isInInset())
maxasc += PAPER_MARGIN; maxasc += PAPER_MARGIN;
// add the vertical spaces, that the user added // add the vertical spaces, that the user added
@ -1143,8 +1143,8 @@ void LyXText::setHeightOfRow(Row * row)
&& bv()->buffer()->params.secnumdepth >= 0) && bv()->buffer()->params.secnumdepth >= 0)
{ {
float spacing_val = 1.0; float spacing_val = 1.0;
if (!row->par()->params().spacing().isDefault()) { if (!rit->par()->params().spacing().isDefault()) {
spacing_val = row->par()->params().spacing().getValue(); spacing_val = rit->par()->params().spacing().getValue();
} else { } else {
spacing_val = bv()->buffer()->params.spacing.getValue(); spacing_val = bv()->buffer()->params.spacing.getValue();
} }
@ -1161,12 +1161,12 @@ void LyXText::setHeightOfRow(Row * row)
if ((layout->labeltype == LABEL_TOP_ENVIRONMENT if ((layout->labeltype == LABEL_TOP_ENVIRONMENT
|| layout->labeltype == LABEL_BIBLIO || layout->labeltype == LABEL_BIBLIO
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
&& row->par()->isFirstInSequence() && rit->par()->isFirstInSequence()
&& !row->par()->getLabelstring().empty()) && !rit->par()->getLabelstring().empty())
{ {
float spacing_val = 1.0; float spacing_val = 1.0;
if (!row->par()->params().spacing().isDefault()) { if (!rit->par()->params().spacing().isDefault()) {
spacing_val = row->par()->params().spacing().getValue(); spacing_val = rit->par()->params().spacing().getValue();
} else { } else {
spacing_val = bv()->buffer()->params.spacing.getValue(); spacing_val = bv()->buffer()->params.spacing.getValue();
} }
@ -1186,30 +1186,30 @@ void LyXText::setHeightOfRow(Row * row)
// or between the items of a itemize or enumerate environment // or between the items of a itemize or enumerate environment
if (!firstpar->params().pagebreakTop()) { if (!firstpar->params().pagebreakTop()) {
Paragraph * prev = row->par()->previous(); Paragraph * prev = rit->par()->previous();
if (prev) if (prev)
prev = row->par()->depthHook(row->par()->getDepth()); prev = rit->par()->depthHook(rit->par()->getDepth());
if (prev && prev->layout() == firstpar->layout() && if (prev && prev->layout() == firstpar->layout() &&
prev->getDepth() == firstpar->getDepth() && prev->getDepth() == firstpar->getDepth() &&
prev->getLabelWidthString() == firstpar->getLabelWidthString()) prev->getLabelWidthString() == firstpar->getLabelWidthString())
{ {
layoutasc = (layout->itemsep * defaultRowHeight()); layoutasc = (layout->itemsep * defaultRowHeight());
} else if (row->previous()) { } else if (rit != rows().begin()) {
tmptop = layout->topsep; tmptop = layout->topsep;
if (row->previous()->par()->getDepth() >= row->par()->getDepth()) if (boost::prior(rit)->par()->getDepth() >= rit->par()->getDepth())
tmptop -= row->previous()->par()->layout()->bottomsep; tmptop -= boost::prior(rit)->par()->layout()->bottomsep;
if (tmptop > 0) if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight()); layoutasc = (tmptop * defaultRowHeight());
} else if (row->par()->params().lineTop()) { } else if (rit->par()->params().lineTop()) {
tmptop = layout->topsep; tmptop = layout->topsep;
if (tmptop > 0) if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight()); layoutasc = (tmptop * defaultRowHeight());
} }
prev = row->par()->outerHook(); prev = rit->par()->outerHook();
if (prev) { if (prev) {
maxasc += int(prev->layout()->parsep * defaultRowHeight()); maxasc += int(prev->layout()->parsep * defaultRowHeight());
} else { } else {
@ -1227,8 +1227,9 @@ void LyXText::setHeightOfRow(Row * row)
} }
// is it a bottom line? // is it a bottom line?
if (row->par() == par if (rit->par() == par
&& (!row->next() || row->next()->par() != row->par())) { && (boost::next(rit) == rows().end() ||
boost::next(rit)->par() != rit->par())) {
// the bottom margin // the bottom margin
if (!par->next() && !isInInset()) if (!par->next() && !isInInset())
maxdesc += PAPER_MARGIN; maxdesc += PAPER_MARGIN;
@ -1252,9 +1253,9 @@ void LyXText::setHeightOfRow(Row * row)
// a section, or between the items of a itemize or enumerate // a section, or between the items of a itemize or enumerate
// environment // environment
if (!firstpar->params().pagebreakBottom() if (!firstpar->params().pagebreakBottom()
&& row->par()->next()) { && rit->par()->next()) {
Paragraph * nextpar = row->par()->next(); Paragraph * nextpar = rit->par()->next();
Paragraph * comparepar = row->par(); Paragraph * comparepar = rit->par();
float usual = 0; float usual = 0;
float unusual = 0; float unusual = 0;
@ -1286,30 +1287,30 @@ void LyXText::setHeightOfRow(Row * row)
maxdesc += int(layoutdesc * 2 / (2 + firstpar->getDepth())); maxdesc += int(layoutdesc * 2 / (2 + firstpar->getDepth()));
// calculate the new height of the text // calculate the new height of the text
height -= row->height(); height -= rit->height();
row->height(maxasc + maxdesc + labeladdon); rit->height(maxasc + maxdesc + labeladdon);
row->baseline(maxasc + labeladdon); rit->baseline(maxasc + labeladdon);
height += row->height(); height += rit->height();
row->top_of_text(row->baseline() - font_metrics::maxAscent(font)); rit->top_of_text(rit->baseline() - font_metrics::maxAscent(font));
float x = 0; float x = 0;
if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) { if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) {
float dummy; float dummy;
// this IS needed // this IS needed
row->width(maxwidth); rit->width(maxwidth);
prepareToPrint(row, x, dummy, dummy, dummy, false); prepareToPrint(&*rit, x, dummy, dummy, dummy, false);
} }
row->width(int(maxwidth + x)); rit->width(int(maxwidth + x));
if (inset_owner) { if (inset_owner) {
width = max(0, workWidth()); width = max(0, workWidth());
RowList::iterator rit = rows().begin(); RowList::iterator it = rows().begin();
RowList::iterator end = rows().end(); RowList::iterator end = rows().end();
for (; rit != end; ++rit) { for (; it != end; ++it) {
if (rit->width() > width) if (it->width() > width)
width = rit->width(); width = it->width();
} }
} }
} }
@ -1347,48 +1348,50 @@ void LyXText::appendParagraph(RowList::iterator rowit)
} }
void LyXText::breakAgain(Row * row) void LyXText::breakAgain(RowList::iterator rit)
{ {
lyx::Assert(row); lyx::Assert(rit != rows().end());
bool not_ready = true; bool not_ready = true;
do { do {
pos_type z = rowBreakPoint(*row); pos_type z = rowBreakPoint(*rit);
Row * tmprow = row; RowList::iterator tmprit = rit;
RowList::iterator end = rows().end();
if (z < row->par()->size()) { if (z < rit->par()->size()) {
if (!row->next() || (row->next() && row->next()->par() != row->par())) { if (boost::next(rit) == end ||
(boost::next(rit) != end &&
boost::next(rit)->par() != rit->par())) {
// insert a new row // insert a new row
++z; ++z;
rowlist_.insert(row->next(), new Row(row->par(), z)); rit = rowlist_.insert(boost::next(rit), new Row(rit->par(), z));
row = row->next();
} else { } else {
row = row->next(); ++rit;
++z; ++z;
if (row->pos() == z) if (rit->pos() == z)
not_ready = false; // the rest will not change not_ready = false; // the rest will not change
else { else {
row->pos(z); rit->pos(z);
} }
} }
} else { } else {
// if there are some rows too much, delete them // if there are some rows too much, delete them
// only if you broke the whole paragraph! // only if you broke the whole paragraph!
Row * tmprow2 = row; RowList::iterator tmprit2 = rit;
while (tmprow2->next() && tmprow2->next()->par() == row->par()) { while (boost::next(tmprit2) != end && boost::next(tmprit2)->par() == rit->par()) {
tmprow2 = tmprow2->next(); ++tmprit2;
} }
while (tmprow2 != row) { while (tmprit2 != rit) {
tmprow2 = tmprow2->previous(); --tmprit2;
removeRow(tmprow2->next()); removeRow(boost::next(tmprit2));
} }
not_ready = false; not_ready = false;
} }
// set the dimensions of the row // set the dimensions of the row
tmprow->fill(fill(*tmprow, workWidth())); tmprit->fill(fill(*tmprit, workWidth()));
setHeightOfRow(tmprow); setHeightOfRow(tmprit);
} while (not_ready); } while (not_ready);
} }
@ -1537,7 +1540,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
if (cursor.row()->next()) if (cursor.row()->next())
breakAgain(cursor.row()->next()); breakAgain(cursor.row()->next());
need_break_row = 0; need_break_row = rows().end();
} }
@ -1716,7 +1719,7 @@ void LyXText::insertChar(char c)
if (row->next() && row->next()->par() == row->par()) if (row->next() && row->next()->par() == row->par())
need_break_row = row->next(); need_break_row = row->next();
else else
need_break_row = 0; need_break_row = rows().end();
// check, wether the last characters font has changed. // check, wether the last characters font has changed.
if (cursor.pos() && cursor.pos() == cursor.par()->size() if (cursor.pos() && cursor.pos() == cursor.par()->size()
@ -1757,7 +1760,7 @@ void LyXText::insertChar(char c)
if (row->next() && row->next()->par() == row->par()) if (row->next() && row->next()->par() == row->par())
need_break_row = row->next(); need_break_row = row->next();
else else
need_break_row = 0; need_break_row = rows().end();
} else { } else {
// FIXME: similar code is duplicated all over - make resetHeightOfRow // FIXME: similar code is duplicated all over - make resetHeightOfRow
int const tmpheight = row->height(); int const tmpheight = row->height();
@ -2674,13 +2677,13 @@ void LyXText::backspace()
if (row->pos() >= row->par()->size()) { if (row->pos() >= row->par()->size()) {
// remove it // remove it
removeRow(row); removeRow(row);
need_break_row = 0; need_break_row = rows().end();
} else { } else {
breakAgainOneRow(row); breakAgainOneRow(row);
if (row->next() && row->next()->par() == row->par()) if (row->next() && row->next()->par() == row->par())
need_break_row = row->next(); need_break_row = row->next();
else else
need_break_row = 0; need_break_row = rows().end();
} }
// set the dimensions of the row above // set the dimensions of the row above
@ -2730,7 +2733,7 @@ void LyXText::backspace()
if (row->next() && row->next()->par() == row->par()) if (row->next() && row->next()->par() == row->par())
need_break_row = row->next(); need_break_row = row->next();
else else
need_break_row = 0; need_break_row = rows().end();
} else { } else {
// set the dimensions of the row // set the dimensions of the row
row->fill(fill(*row, workWidth())); row->fill(fill(*row, workWidth()));
@ -2775,11 +2778,12 @@ void LyXText::backspace()
RowList::iterator RowList::iterator
LyXText::getRow(Paragraph * par, pos_type pos, int & y) const LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
{ {
if (rows().empty())
return rows().end();
y = 0; y = 0;
if (rows().empty()) {
return rows().end();
}
// find the first row of the specified paragraph // find the first row of the specified paragraph
RowList::iterator rit = rows().begin(); RowList::iterator rit = rows().begin();
RowList::iterator end = rows().end(); RowList::iterator end = rows().end();

View File

@ -52,21 +52,23 @@ using lyx::pos_type;
LyXText::LyXText(BufferView * bv) LyXText::LyXText(BufferView * bv)
: height(0), width(0), anchor_row_(0), anchor_row_offset_(0), : height(0), width(0), anchor_row_offset_(0),
inset_owner(0), the_locking_inset(0), need_break_row(0), inset_owner(0), the_locking_inset(0), bv_owner(bv)
bv_owner(bv)
{ {
refresh_row = 0; anchor_row_ = rows().end();
need_break_row = rows().end();
refresh_row = rows().end();
clearPaint(); clearPaint();
} }
LyXText::LyXText(BufferView * bv, InsetText * inset) LyXText::LyXText(BufferView * bv, InsetText * inset)
: height(0), width(0), anchor_row_(0), anchor_row_offset_(0), : height(0), width(0), anchor_row_offset_(0),
inset_owner(inset), the_locking_inset(0), need_break_row(0), inset_owner(inset), the_locking_inset(0), bv_owner(bv)
bv_owner(bv)
{ {
refresh_row = 0; anchor_row_ = rows().end();
need_break_row = rows().end();
refresh_row = rows().end();
clearPaint(); clearPaint();
} }
@ -75,7 +77,7 @@ void LyXText::init(BufferView * bview, bool reinit)
{ {
if (reinit) { if (reinit) {
rowlist_.clear(); rowlist_.clear();
need_break_row = 0; need_break_row = rows().end();
width = height = 0; width = height = 0;
copylayouttype.erase(); copylayouttype.erase();
top_y(0); top_y(0);
@ -259,35 +261,33 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
// removes the row and reset the touched counters // removes the row and reset the touched counters
void LyXText::removeRow(Row * row) void LyXText::removeRow(RowList::iterator rit)
{ {
lyx::Assert(row);
Row * row_prev = row->previous();
Row * row_next = row->next();
int const row_height = row->height();
/* FIXME: when we cache the bview, this should just /* FIXME: when we cache the bview, this should just
* become a postPaint(), I think */ * become a postPaint(), I think */
if (refresh_row == row) { if (refresh_row == rit) {
refresh_row = row_prev ? row_prev : row_next; if (rit == rows().begin())
refresh_row = boost::next(rit);
else
refresh_row = boost::prior(rit);
// what about refresh_y // what about refresh_y
} }
if (anchor_row_ == row) { if (anchor_row_ == rit) {
if (row_prev) { if (rit != rows().begin()) {
anchor_row_ = row_prev; anchor_row_ = boost::prior(rit);
anchor_row_offset_ += row_prev->height(); anchor_row_offset_ += boost::prior(rit)->height();
} else { } else {
anchor_row_ = row_next; anchor_row_ = boost::next(rit);
anchor_row_offset_ -= row_height; anchor_row_offset_ -= rit->height();
} }
} }
// the text becomes smaller // the text becomes smaller
height -= row_height; height -= rit->height();
rowlist_.erase(row); rowlist_.erase(rit);
} }
@ -767,9 +767,9 @@ void LyXText::fullRebreak()
init(bv()); init(bv());
return; return;
} }
if (need_break_row) { if (need_break_row != rows().end()) {
breakAgain(need_break_row); breakAgain(need_break_row);
need_break_row = 0; need_break_row = rows().end();
return; return;
} }
} }
@ -2292,7 +2292,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
* the parindent that can occur or dissappear. * the parindent that can occur or dissappear.
* The next row can change its height, if * The next row can change its height, if
* there is another layout before */ * there is another layout before */
if (refresh_row) { if (refresh_row != rows().end()) {
if (refresh_row->next()) { if (refresh_row->next()) {
breakAgain(refresh_row->next()); breakAgain(refresh_row->next());
updateCounters(); updateCounters();
@ -2395,7 +2395,7 @@ LyXText::refresh_status LyXText::refreshStatus() const
void LyXText::clearPaint() void LyXText::clearPaint()
{ {
refresh_status_ = REFRESH_NONE; refresh_status_ = REFRESH_NONE;
refresh_row = 0; refresh_row = rows().end();
refresh_y = 0; refresh_y = 0;
} }
@ -2405,7 +2405,7 @@ void LyXText::postPaint(int start_y)
refresh_status old = refresh_status_; refresh_status old = refresh_status_;
refresh_status_ = REFRESH_AREA; refresh_status_ = REFRESH_AREA;
refresh_row = 0; refresh_row = rows().end();
if (old != REFRESH_NONE && refresh_y < start_y) if (old != REFRESH_NONE && refresh_y < start_y)
return; return;