2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net>
+ * text3.C (dispatch): adjust
+
+ * text2.C (checkParagraph): adjust
+ (setCursor): adjust
+ (setCursorFromCoordinates): adjust
+
+ * text.C (top_y): adjust
+ (workWidth): adjust
+ (getRow): make it return a RowList::iterator, adjust
+ (getRowNearY): make it return a RowList::iterator, adjust
+
* text2.C (init): adjust
(insertRow): remove function
(insertParagraph): adjust
+2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * screen.C (drawFromTo): adjust for RowList.
+
2003-03-29 John Levon <levon@movementarian.org>
* Alert.h:
int y_text = text->top_y() + y1;
// get the first needed row
- Row * row = text->getRowNearY(y_text);
+ RowList::iterator row = text->getRowNearY(y_text);
+ RowList::iterator end = text->rows().end();
+
// y_text is now the real beginning of the row
int y = y_text - text->top_y();
// y1 is now the real beginning of row on the screen
- while (row != 0 && y < y2) {
+ while (row != end && y < y2) {
RowPainter rp(*bv, *text, *row);
rp.paint(y + yo, xo, y + text->top_y());
y += row->height();
- row = row->next();
+ ++row;
}
// maybe we have to clear the screen at the bottom
(relative to the whole text). y is set to the real beginning
of this row
*/
- Row * getRowNearY(int & y) const;
+ RowList::iterator getRowNearY(int & y) const;
/** returns the column near the specified x-coordinate of the row
x is set to the real beginning of this column
/** returns a pointer to a specified row. y is set to the beginning
of the row
*/
- Row * getRow(Paragraph * par, lyx::pos_type pos, int & y) const;
+ RowList::iterator
+ getRow(Paragraph * par, lyx::pos_type pos, int & y) const;
RowList & rows() {
return rowlist_;
lyxerr[Debug::GUI] << "setting top y = " << newy << endl;
int y = newy;
- Row * row = getRowNearY(y);
+ RowList::iterator rit = getRowNearY(y);
- if (row == anchor_row_ && anchor_row_offset_ == newy - y) {
+ if (rit == anchor_row_ && anchor_row_offset_ == newy - y) {
lyxerr[Debug::GUI] << "top_y to same value, skipping update" << endl;
return;
}
- anchor_row_ = row;
+ anchor_row_ = &*rit;
anchor_row_offset_ = newy - y;
lyxerr[Debug::GUI] << "changing reference to row: " << anchor_row_
<< " offset: " << anchor_row_offset_ << endl;
return workWidth() - leftMargin(&dummyrow);
} else {
int dummy_y;
- Row * row = getRow(par, pos, dummy_y);
- Row * frow = row;
- while (frow->previous() && frow->par() == frow->previous()->par())
- frow = frow->previous();
+ RowList::iterator row = getRow(par, pos, dummy_y);
+ RowList::iterator frow = row;
+ RowList::iterator beg = rows().begin();
+
+ while (frow != beg && frow->par() == boost::prior(frow)->par())
+ --frow;
// FIXME: I don't understand this code - jbl
while (!frow->isParEnd()) {
if ((frow != row) && (maxw < frow->width()))
maxw = frow->width();
- frow = frow->next();
+ ++frow;
}
if (maxw)
return maxw;
// returns pointer to a specified row
-Row * LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
+RowList::iterator
+LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
{
if (rows().empty())
- return 0;
+ return rows().end();
y = 0;
++rit;
}
- return &*rit;
+ return rit;
}
-Row * LyXText::getRowNearY(int & y) const
+RowList::iterator LyXText::getRowNearY(int & y) const
{
// If possible we should optimize this method. (Lgb)
int tmpy = 0;
RowList::iterator rit = rows().begin();
RowList::iterator end = rows().end();
- while (boost::next(rit) != end && tmpy + rit->height() <= y) {
+ while (rit != end && boost::next(rit) != end && tmpy + rit->height() <= y) {
tmpy += rit->height();
++rit;
}
//lyxerr << "returned y = " << y << endl;
- return &*rit;
+ return rit;
}
} else {
insertParagraph(tmppar, tmprow->next());
}
-
+
if (!tmprow) {
tmprow = &*rows().begin();
}
-void LyXText::checkParagraph(Paragraph * par,
- pos_type pos)
+void LyXText::checkParagraph(Paragraph * par, pos_type pos)
{
LyXCursor tmpcursor;
int y = 0;
pos_type z;
- Row * row = getRow(par, pos, y);
+ RowList::iterator row = getRow(par, pos, y);
+ RowList::iterator beg = rows().begin();
// is there a break one row above
- if (row->previous() && row->previous()->par() == row->par()) {
- z = rowBreakPoint(*row->previous());
+ if (row != beg
+ && boost::prior(row)->par() == row->par()) {
+ z = rowBreakPoint(*boost::prior(row));
if (z >= row->pos()) {
// set the dimensions of the row above
- y -= row->previous()->height();
+ y -= boost::prior(row)->height();
postPaint(y);
- breakAgain(row->previous());
+ breakAgain(&*boost::prior(row));
// set the cursor again. Otherwise
// dangling pointers are possible
int const tmpheight = row->height();
pos_type const tmplast = row->lastPos();
- breakAgain(row);
+ breakAgain(&*row);
if (row->height() == tmpheight && row->lastPos() == tmplast) {
- postRowPaint(row, y);
+ postRowPaint(&*row, y);
} else {
postPaint(y);
}
// check the special right address boxes
if (par->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
tmpcursor.par(par);
- tmpcursor.row(row);
+ tmpcursor.row(&*row);
tmpcursor.y(y);
tmpcursor.x(0);
tmpcursor.x_fix(0);
// get the cursor y position in text
int y = 0;
- Row * row = getRow(par, pos, y);
- Row * old_row = row;
- cur.irow(row);
+ RowList::iterator row = getRow(par, pos, y);
+ RowList::iterator beg = rows().begin();
+
+ RowList::iterator old_row = row;
+ cur.irow(&*row);
// if we are before the first char of this row and are still in the
// same paragraph and there is a previous row then put the cursor on
// the end of the previous row
cur.iy(y + row->baseline());
Inset * ins;
- if (row->previous() && pos &&
- row->previous()->par() == row->par() &&
+ if (row != beg && pos &&
+ boost::prior(row)->par() == row->par() &&
pos < par->size() &&
par->getChar(pos) == Paragraph::META_INSET &&
(ins = par->getInset(pos)) && (ins->needFullRow() || ins->display()))
{
- row = row->previous();
+ --row;
y -= row->height();
}
- cur.row(row);
+ cur.row(&*row);
// y is now the beginning of the cursor row
y += row->baseline();
// y is now the cursor baseline
}
// now get the cursors x position
- float x = getCursorX(row, pos, last, boundary);
+ float x = getCursorX(&*row, pos, last, boundary);
cur.x(int(x));
cur.x_fix(cur.x());
if (old_row != row) {
- x = getCursorX(old_row, pos, last, boundary);
+ x = getCursorX(&*old_row, pos, last, boundary);
cur.ix(int(x));
} else
cur.ix(cur.x());
//if the cursor is in a visible row, anchor to it
int topy = top_y();
if (topy < y && y < topy + bv()->workHeight())
- anchor_row(row);
+ anchor_row(&*row);
}
}
-void LyXText::setCursorFromCoordinates(LyXCursor & cur,
- int x, int y)
+void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
{
// Get the row first.
- Row * row = getRowNearY(y);
+ RowList::iterator row = getRowNearY(y);
bool bound = false;
- pos_type const column = getColumnNearX(row, x, bound);
+ pos_type const column = getColumnNearX(&*row, x, bound);
cur.par(row->par());
cur.pos(row->pos() + column);
cur.x(x);
cur.y(y + row->baseline());
- cur.row(row);
+ cur.row(&*row);
if (beforeFullRowInset(*row, cur)) {
pos_type last = row->lastPrintablePos();
} else {
cur.iy(cur.y());
cur.ix(cur.x());
- cur.irow(row);
+ cur.irow(&*row);
}
cur.boundary(bound);
}
setUndo(bv, Undo::EDIT, tmp, tmp->next());
tmp->params().startOfAppendix(false);
int tmpy;
- setHeightOfRow(getRow(tmp, 0, tmpy));
+ setHeightOfRow(&*getRow(tmp, 0, tmpy));
break;
}
}