From 3e97d1fee27499733d07ddb38d10ead8c0612c96 Mon Sep 17 00:00:00 2001 From: John Levon Date: Sun, 9 Mar 2003 13:46:48 +0000 Subject: [PATCH] Pointless third arg to nextBreakPoint git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6398 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 7 +++++++ src/lyxtext.h | 3 ++- src/text.C | 42 ++++++++++++++++++++++-------------------- src/text2.C | 2 +- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 15c4b0538f..e0cc6e809e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2003-03-09 John Levon + + * lyxtext.h: + * text.C: + * text2.C: 3rd arg to nextBreakPoint was always the same. + Use references. + 2003-03-08 John Levon * lyxrow.C: diff --git a/src/lyxtext.h b/src/lyxtext.h index e0dc6015ea..745dcbdc28 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -607,7 +607,8 @@ private: /// 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 int fill(BufferView &, Row & row, int workwidth) const; diff --git a/src/text.C b/src/text.C index 4db76525d4..2ab8b444b4 100644 --- a/src/text.C +++ b/src/text.C @@ -680,19 +680,22 @@ int LyXText::labelEnd(BufferView & bview, Row const & row) const // get the next breakpoint in a given paragraph 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) return par->size(); - pos_type const pos = row->pos(); + pos_type const pos = row.pos(); // position of the last possible breakpoint // -1 isn't a suitable value, but a flag pos_type last_separator = -1; - width -= rightMargin(*bview->buffer(), *row); + width -= rightMargin(*bview.buffer(), row); pos_type const body_pos = par->beginningOfBody(); LyXLayout_ptr const & layout = par->layout(); @@ -708,6 +711,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const //x = width; } else if (par->isInset(i) && par->getInset(i) && par->getInset(i)->display()) { + // FIXME: what are we doing modifying stuff here ! par->getInset(i)->display(false); } ++i; @@ -716,7 +720,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const // Last position is an invariant pos_type const last = par->size(); // this is the usual handling - int x = leftMargin(bview, row); + int x = leftMargin(&bview, &row); bool doitonetime = true; while (doitonetime || ((x < width) && (i < last))) { doitonetime = false; @@ -738,7 +742,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const { // display istn't allowd in->display(false); - x += singleWidth(bview, par, i, c); + x += singleWidth(&bview, par, i, c); } else if (in->display() || in->needFullRow()) { // So break the line here if (i == pos) { @@ -752,7 +756,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const last_separator = i - 1; x = width; // this means break } else { - x += singleWidth(bview, par, i, c); + x += singleWidth(&bview, par, i, c); // we have to check this separately as we could have a // lineseparator and then the algorithm below would prefer // 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 { if (par->isLineSeparator(i)) last_separator = i; - x += singleWidth(bview, par, i, c); + x += singleWidth(&bview, par, i, c); } ++i; if (i == body_pos) { x += font_metrics::width(layout->labelsep, - getLabelFont(bview->buffer(), par)); + getLabelFont(bview.buffer(), par)); if (par->isLineSeparator(i - 1)) - x-= singleWidth(bview, par, i - 1); - int left_margin = labelEnd(*bview, *row); + x-= singleWidth(&bview, par, i - 1); + int left_margin = labelEnd(bview, row); if (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(); do { // Get the next breakpoint - pos_type z = nextBreakPoint(bview, row, workWidth(*bview)); + pos_type z = nextBreakPoint(*bview, *row); Row * tmprow = row; @@ -1271,7 +1275,7 @@ void LyXText::breakAgain(BufferView * bview, Row * row) const do { // get the next breakpoint - pos_type z = nextBreakPoint(bview, row, workWidth(*bview)); + pos_type z = nextBreakPoint(*bview, *row); Row * tmprow = row; if (z < row->par()->size()) { @@ -1315,7 +1319,7 @@ void LyXText::breakAgain(BufferView * bview, Row * row) const void LyXText::breakAgainOneRow(BufferView * bview, Row * row) { // get the next breakpoint - pos_type z = nextBreakPoint(bview, row, workWidth(*bview)); + pos_type z = nextBreakPoint(*bview, *row); Row * tmprow = row; if (z < row->par()->size()) { @@ -1621,9 +1625,8 @@ void LyXText::insertChar(BufferView * bview, char c) cursor.par()->isInset(cursor.pos()+1)) || cursor.row()->fill() == -1)) { - pos_type z = nextBreakPoint(bview, - row->previous(), - workWidth(*bview)); + pos_type z = nextBreakPoint(*bview, *row->previous()); + if (z >= row->pos()) { row->pos(z + 1); @@ -2600,8 +2603,7 @@ void LyXText::backspace(BufferView * bview) // is there a break one row above if (row->previous() && row->previous()->par() == row->par()) { - z = nextBreakPoint(bview, row->previous(), - workWidth(*bview)); + z = nextBreakPoint(*bview, *row->previous()); if (z >= row->pos()) { row->pos(z + 1); @@ -2644,7 +2646,7 @@ void LyXText::backspace(BufferView * bview) // break the cursor row again if (row->next() && row->next()->par() == row->par() && (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 // without a real breakup. This is when a word diff --git a/src/text2.C b/src/text2.C index 11e8ba34cf..bd18bce022 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1643,7 +1643,7 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par, // is there a break one row above if (row->previous() && row->previous()->par() == row->par()) { - z = nextBreakPoint(bview, row->previous(), workWidth(*bview)); + z = nextBreakPoint(*bview, *row->previous()); if (z >= row->pos()) { // set the dimensions of the row above y -= row->previous()->height(); -- 2.39.2