mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
rowlist3
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6647 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d2718b3669
commit
6778eeaa36
@ -1,5 +1,16 @@
|
||||
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
|
||||
|
@ -1,3 +1,7 @@
|
||||
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:
|
||||
|
@ -413,18 +413,20 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
|
||||
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
|
||||
|
@ -233,7 +233,7 @@ public:
|
||||
(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
|
||||
@ -244,7 +244,8 @@ public:
|
||||
/** 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_;
|
||||
|
31
src/text.C
31
src/text.C
@ -95,14 +95,14 @@ void LyXText::top_y(int newy)
|
||||
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;
|
||||
@ -152,10 +152,12 @@ int LyXText::workWidth(Inset * inset) const
|
||||
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
|
||||
|
||||
@ -163,7 +165,7 @@ int LyXText::workWidth(Inset * inset) const
|
||||
while (!frow->isParEnd()) {
|
||||
if ((frow != row) && (maxw < frow->width()))
|
||||
maxw = frow->width();
|
||||
frow = frow->next();
|
||||
++frow;
|
||||
}
|
||||
if (maxw)
|
||||
return maxw;
|
||||
@ -2770,10 +2772,11 @@ void LyXText::backspace()
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
@ -2794,11 +2797,11 @@ Row * LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
|
||||
++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;
|
||||
@ -2806,7 +2809,7 @@ Row * LyXText::getRowNearY(int & y) const
|
||||
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;
|
||||
}
|
||||
@ -2815,7 +2818,7 @@ Row * LyXText::getRowNearY(int & y) const
|
||||
|
||||
//lyxerr << "returned y = " << y << endl;
|
||||
|
||||
return &*rit;
|
||||
return rit;
|
||||
}
|
||||
|
||||
|
||||
|
54
src/text2.C
54
src/text2.C
@ -1558,24 +1558,25 @@ void LyXText::insertStringAsParagraphs(string const & str)
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
@ -1589,9 +1590,9 @@ void LyXText::checkParagraph(Paragraph * par,
|
||||
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);
|
||||
}
|
||||
@ -1599,7 +1600,7 @@ void LyXText::checkParagraph(Paragraph * par,
|
||||
// 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);
|
||||
@ -1681,25 +1682,27 @@ void LyXText::setCursor(LyXCursor & cur, Paragraph * par,
|
||||
|
||||
// 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
|
||||
@ -1724,18 +1727,18 @@ void LyXText::setCursor(LyXCursor & cur, Paragraph * par,
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
@ -2019,19 +2022,18 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
@ -2042,7 +2044,7 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur,
|
||||
} else {
|
||||
cur.iy(cur.y());
|
||||
cur.ix(cur.x());
|
||||
cur.irow(row);
|
||||
cur.irow(&*row);
|
||||
}
|
||||
cur.boundary(bound);
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
setUndo(bv, Undo::EDIT, tmp, tmp->next());
|
||||
tmp->params().startOfAppendix(false);
|
||||
int tmpy;
|
||||
setHeightOfRow(getRow(tmp, 0, tmpy));
|
||||
setHeightOfRow(&*getRow(tmp, 0, tmpy));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user