]> git.lyx.org Git - features.git/commitdiff
set fill in fill(...) istead of returning it.
authorAndré Pönitz <poenitz@gmx.net>
Fri, 24 Oct 2003 07:59:04 +0000 (07:59 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 24 Oct 2003 07:59:04 +0000 (07:59 +0000)
use isLastRow()

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7974 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxfunc.C
src/lyxtext.h
src/rowpainter.C
src/text.C
src/text3.C

index e6e951fc26f57445165df27828b4d66abb8bbe2c..0f4ebdc03d78d303a5cb0f79eebdc5a848ed07b3 100644 (file)
@@ -1022,14 +1022,16 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                        owner->view_state_changed();
                                }
                                goto exit_with_message;
-                       case LFUN_DOWN:
-                               if (view()->text->cursorRow() != view()->text->lastRow())
+                       case LFUN_DOWN: {
+                               LyXText * text = view()->text;
+                               if (text->isLastRow(text->cursorPar(), *text->cursorRow()))
                                        view()->text->cursorDown(view());
                                else
                                        view()->text->cursorRight(view());
                                moveCursorUpdate();
                                owner->view_state_changed();
                                goto exit_with_message;
+                       }
                        default:
                                break;
                        }
index 25c63df039b867f4e1f9d0c399c4effe4d69b2e8..5709aeb10e3f97e005e61b03b1da59d8f94990ee 100644 (file)
@@ -415,8 +415,8 @@ private:
        /// for example, the pos after which isNewLine(pos) == true
        void rowBreakPoint(ParagraphList::iterator pit, Row & row) const;
 
-       /// returns the minimum space a row needs on the screen in pixel
-       int fill(ParagraphList::iterator pit, Row & row, int workwidth) const;
+       /// sets row.witdh to the minimum space a row needs on the screen in pixel
+       void fill(ParagraphList::iterator pit, Row & row, int workwidth) const;
 
        /**
         * returns the minimum space a manual label needs on the
index accc12d899efd3dbb19c75ee89ff587c81047b25..e21ce0cdb9efe8b1913890869fda3faf9c558ed3 100644 (file)
@@ -1055,7 +1055,6 @@ int paintRows(BufferView const & bv, LyXText const & text,
        int xo, int y, int yf, int yo)
 {
        //lyxerr << "  paintRows: rit: " << &*rit << endl;
-       //const_cast<LyXText&>(text).updateRowPositions();
        int const yy = yf - y;
        int const y2 = bv.painter().paperHeight();
 
index 053b668fd4047af41e65cf7da7ceb0e56071fa4a..31eebcf5f2ba373e9017604e7ca18449d8dbd95d 100644 (file)
@@ -601,13 +601,8 @@ void LyXText::rowBreakPoint(ParagraphList::iterator pit, Row & row) const
 
 
 // returns the minimum space a row needs on the screen in pixel
-int LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const
+void LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const
 {
-       if (paper_width < 0) {
-               lyxerr << "paperwidth < 0: " << paper_width << "  Why?" << endl;
-               return 0;
-       }
-
        int w;
        // get the pure distance
        pos_type const last = lastPos(*pit, row);
@@ -620,8 +615,9 @@ int LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const
                row.fill(0); // the minfill in leftMargin()
                w = leftMargin(pit, row);
                row.fill(tmpfill);
-       } else
+       } else {
                w = leftMargin(pit, row);
+       }
 
        pos_type const body_pos = pit->beginningOfBody();
        pos_type i = row.pos();
@@ -659,20 +655,8 @@ int LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const
        }
 
        int const fill = paper_width - w - rightMargin(*pit, *bv()->buffer(), row);
-
-       // If this case happens, it means that our calculation
-       // of the widths of the chars when we do rowBreakPoint()
-       // went wrong for some reason. Typically in list bodies.
-       // Things just about hobble on anyway, though you'll end
-       // up with a "fill_separator" less than zero, which corresponds
-       // to inter-word spacing being too small. Hopefully this problem
-       // will die when the label hacks die.
-       if (lyxerr.debugging() && fill < 0) {
-               lyxerr[Debug::GUI] << "Eek, fill() was < 0: " << fill
-                       << " w " << w << " paper_width " << paper_width
-                       << " right margin " << rightMargin(*pit, *bv()->buffer(), row) << endl;
-       }
-       return fill;
+       row.fill(fill);
+       row.width(paper_width - fill);
 }
 
 
@@ -1977,16 +1961,13 @@ void LyXText::redoParagraphInternal(ParagraphList::iterator pit)
                Row row(z);
                rowBreakPoint(pit, row);
                z = row.endpos();
-               int const f = fill(pit, row, ww);
-               unsigned int const w = ww - f;
-               pit->width = std::max(pit->width, w);
-               row.fill(f);
-               row.width(w);
+               fill(pit, row, ww);
                prepareToPrint(pit, row);
                setHeightOfRow(pit, row);
                row.y_offset(pit->height);
-               pit->height += row.height();
                pit->rows.push_back(row);
+               pit->width = std::max(pit->width, row.width());
+               pit->height += row.height();
        }
        height += pit->height;
        //lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n";
index 7c4430b526b41b278140c3537dedbb579a478f7d..3baec4a79416811405e9f0d2a78350b14353a9db 100644 (file)
@@ -302,7 +302,7 @@ void LyXText::cursorNext()
        int topy = bv_owner->top_y();
 
        RowList::iterator rit = cursorRow();
-       if (rit == lastRow()) {
+       if (isLastRow(cursorPar(), *cursorRow())) {
                int y = cursor.y() - rit->baseline() + cursorRow()->height();
                if (y > topy + bv()->workHeight())
                        bv_owner->updateScrollbar();