]> git.lyx.org Git - features.git/commitdiff
Pointless third arg to nextBreakPoint
authorJohn Levon <levon@movementarian.org>
Sun, 9 Mar 2003 13:46:48 +0000 (13:46 +0000)
committerJohn Levon <levon@movementarian.org>
Sun, 9 Mar 2003 13:46:48 +0000 (13:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6398 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxtext.h
src/text.C
src/text2.C

index 15c4b0538fd42bf800d6ed1f3765098cb1faf317..e0cc6e809ee0609369d3ab0234e1899d122baa89 100644 (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>
 
        * lyxrow.C:
index e0dc6015ea5bee52a802835b8effb1a17b649ba9..745dcbdc2871a1b484b32803929638d235bf1fa7 100644 (file)
@@ -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;
 
index 4db76525d4aaa7c79f0259843d463dcf9a62f0c1..2ab8b444b43ac74e0eba3adf844540a93278d0ec 100644 (file)
@@ -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
index 11e8ba34cf2a472c9efd5d59c61bb4110c7b73e3..bd18bce0222da3a9eef900e3ac907e393815f219 100644 (file)
@@ -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();