Pointless third arg to nextBreakPoint

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6398 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-03-09 13:46:48 +00:00
parent 27deed6ea3
commit 3e97d1fee2
4 changed files with 32 additions and 22 deletions

View File

@ -1,3 +1,10 @@
2003-03-09 John Levon <levon@movementarian.org>
* lyxtext.h:
* text.C:
* text2.C: 3rd arg to nextBreakPoint was always the same.
Use references.
2003-03-08 John Levon <levon@movementarian.org> 2003-03-08 John Levon <levon@movementarian.org>
* lyxrow.C: * lyxrow.C:

View File

@ -607,7 +607,8 @@ private:
/// get the next breakpoint in a given paragraph /// get the next breakpoint in a given paragraph
lyx::pos_type nextBreakPoint(BufferView *, Row const * row, int width) const; lyx::pos_type nextBreakPoint(BufferView &, Row const & row) const;
/// returns the minimum space a row needs on the screen in pixel /// returns the minimum space a row needs on the screen in pixel
int fill(BufferView &, Row & row, int workwidth) const; int fill(BufferView &, Row & row, int workwidth) const;

View File

@ -680,19 +680,22 @@ int LyXText::labelEnd(BufferView & bview, Row const & row) const
// get the next breakpoint in a given paragraph // get the next breakpoint in a given paragraph
pos_type pos_type
LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const LyXText::nextBreakPoint(BufferView & bview, Row const & row) const
{ {
Paragraph * par = row->par(); Paragraph * par = row.par();
int width = workWidth(bview);
/* inset->textWidth() returns -1 via workWidth(),
* but why ? */
if (width < 0) if (width < 0)
return par->size(); return par->size();
pos_type const pos = row->pos(); pos_type const pos = row.pos();
// position of the last possible breakpoint // position of the last possible breakpoint
// -1 isn't a suitable value, but a flag // -1 isn't a suitable value, but a flag
pos_type last_separator = -1; pos_type last_separator = -1;
width -= rightMargin(*bview->buffer(), *row); width -= rightMargin(*bview.buffer(), row);
pos_type const body_pos = par->beginningOfBody(); pos_type const body_pos = par->beginningOfBody();
LyXLayout_ptr const & layout = par->layout(); LyXLayout_ptr const & layout = par->layout();
@ -708,6 +711,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
//x = width; //x = width;
} else if (par->isInset(i) && par->getInset(i) } else if (par->isInset(i) && par->getInset(i)
&& par->getInset(i)->display()) { && par->getInset(i)->display()) {
// FIXME: what are we doing modifying stuff here !
par->getInset(i)->display(false); par->getInset(i)->display(false);
} }
++i; ++i;
@ -716,7 +720,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
// Last position is an invariant // Last position is an invariant
pos_type const last = par->size(); pos_type const last = par->size();
// this is the usual handling // this is the usual handling
int x = leftMargin(bview, row); int x = leftMargin(&bview, &row);
bool doitonetime = true; bool doitonetime = true;
while (doitonetime || ((x < width) && (i < last))) { while (doitonetime || ((x < width) && (i < last))) {
doitonetime = false; doitonetime = false;
@ -738,7 +742,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
{ {
// display istn't allowd // display istn't allowd
in->display(false); in->display(false);
x += singleWidth(bview, par, i, c); x += singleWidth(&bview, par, i, c);
} else if (in->display() || in->needFullRow()) { } else if (in->display() || in->needFullRow()) {
// So break the line here // So break the line here
if (i == pos) { if (i == pos) {
@ -752,7 +756,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
last_separator = i - 1; last_separator = i - 1;
x = width; // this means break x = width; // this means break
} else { } else {
x += singleWidth(bview, par, i, c); x += singleWidth(&bview, par, i, c);
// we have to check this separately as we could have a // we have to check this separately as we could have a
// lineseparator and then the algorithm below would prefer // lineseparator and then the algorithm below would prefer
// that which IS wrong! We should always break on an inset // that which IS wrong! We should always break on an inset
@ -767,15 +771,15 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
} else { } else {
if (par->isLineSeparator(i)) if (par->isLineSeparator(i))
last_separator = i; last_separator = i;
x += singleWidth(bview, par, i, c); x += singleWidth(&bview, par, i, c);
} }
++i; ++i;
if (i == body_pos) { if (i == body_pos) {
x += font_metrics::width(layout->labelsep, x += font_metrics::width(layout->labelsep,
getLabelFont(bview->buffer(), par)); getLabelFont(bview.buffer(), par));
if (par->isLineSeparator(i - 1)) if (par->isLineSeparator(i - 1))
x-= singleWidth(bview, par, i - 1); x-= singleWidth(&bview, par, i - 1);
int left_margin = labelEnd(*bview, *row); int left_margin = labelEnd(bview, row);
if (x < left_margin) if (x < left_margin)
x = left_margin; x = left_margin;
} }
@ -1218,7 +1222,7 @@ void LyXText::appendParagraph(BufferView * bview, Row * row) const
pos_type const lastposition = row->par()->size(); pos_type const lastposition = row->par()->size();
do { do {
// Get the next breakpoint // Get the next breakpoint
pos_type z = nextBreakPoint(bview, row, workWidth(*bview)); pos_type z = nextBreakPoint(*bview, *row);
Row * tmprow = row; Row * tmprow = row;
@ -1271,7 +1275,7 @@ void LyXText::breakAgain(BufferView * bview, Row * row) const
do { do {
// get the next breakpoint // get the next breakpoint
pos_type z = nextBreakPoint(bview, row, workWidth(*bview)); pos_type z = nextBreakPoint(*bview, *row);
Row * tmprow = row; Row * tmprow = row;
if (z < row->par()->size()) { if (z < row->par()->size()) {
@ -1315,7 +1319,7 @@ void LyXText::breakAgain(BufferView * bview, Row * row) const
void LyXText::breakAgainOneRow(BufferView * bview, Row * row) void LyXText::breakAgainOneRow(BufferView * bview, Row * row)
{ {
// get the next breakpoint // get the next breakpoint
pos_type z = nextBreakPoint(bview, row, workWidth(*bview)); pos_type z = nextBreakPoint(*bview, *row);
Row * tmprow = row; Row * tmprow = row;
if (z < row->par()->size()) { if (z < row->par()->size()) {
@ -1621,9 +1625,8 @@ void LyXText::insertChar(BufferView * bview, char c)
cursor.par()->isInset(cursor.pos()+1)) cursor.par()->isInset(cursor.pos()+1))
|| cursor.row()->fill() == -1)) || cursor.row()->fill() == -1))
{ {
pos_type z = nextBreakPoint(bview, pos_type z = nextBreakPoint(*bview, *row->previous());
row->previous(),
workWidth(*bview));
if (z >= row->pos()) { if (z >= row->pos()) {
row->pos(z + 1); row->pos(z + 1);
@ -2600,8 +2603,7 @@ void LyXText::backspace(BufferView * bview)
// is there a break one row above // is there a break one row above
if (row->previous() && row->previous()->par() == row->par()) { if (row->previous() && row->previous()->par() == row->par()) {
z = nextBreakPoint(bview, row->previous(), z = nextBreakPoint(*bview, *row->previous());
workWidth(*bview));
if (z >= row->pos()) { if (z >= row->pos()) {
row->pos(z + 1); row->pos(z + 1);
@ -2644,7 +2646,7 @@ void LyXText::backspace(BufferView * bview)
// break the cursor row again // break the cursor row again
if (row->next() && row->next()->par() == row->par() && if (row->next() && row->next()->par() == row->par() &&
(row->lastPos() == row->par()->size() - 1 || (row->lastPos() == row->par()->size() - 1 ||
nextBreakPoint(bview, row, workWidth(*bview)) != row->lastPos())) { nextBreakPoint(*bview, *row) != row->lastPos())) {
// it can happen that a paragraph loses one row // it can happen that a paragraph loses one row
// without a real breakup. This is when a word // without a real breakup. This is when a word

View File

@ -1643,7 +1643,7 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
// is there a break one row above // is there a break one row above
if (row->previous() && row->previous()->par() == row->par()) { if (row->previous() && row->previous()->par() == row->par()) {
z = nextBreakPoint(bview, row->previous(), workWidth(*bview)); z = nextBreakPoint(*bview, *row->previous());
if (z >= row->pos()) { if (z >= row->pos()) {
// set the dimensions of the row above // set the dimensions of the row above
y -= row->previous()->height(); y -= row->previous()->height();