]> git.lyx.org Git - features.git/commitdiff
Alfredo's cursroRow() fix;
authorAndré Pönitz <poenitz@gmx.net>
Thu, 23 Oct 2003 15:38:48 +0000 (15:38 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 23 Oct 2003 15:38:48 +0000 (15:38 +0000)
directly set endpos in breakRowPos instead of returning it

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

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

index b48a8a580fcaf2b78ef2b022551f70df15db4517..25c63df039b867f4e1f9d0c399c4effe4d69b2e8 100644 (file)
@@ -413,8 +413,7 @@ private:
 
        /// sets row.end to the pos value *after* which a row should break.
        /// for example, the pos after which isNewLine(pos) == true
-       lyx::pos_type rowBreakPoint(ParagraphList::iterator pit,
-               Row const & row) const;
+       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;
index 739a2303010e1b1de24e95abe3f070473109ae06..053b668fd4047af41e65cf7da7ceb0e56071fa4a 100644 (file)
@@ -464,29 +464,34 @@ pos_type addressBreakPoint(pos_type i, Paragraph const & par)
 };
 
 
-pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
-       Row const & row) const
+void LyXText::rowBreakPoint(ParagraphList::iterator pit, Row & row) const
 {
        // maximum pixel width of a row.
        int width = workWidth() - rightMargin(*pit, *bv()->buffer(), row);
 
        // inset->textWidth() returns -1 via workWidth(),
        // but why ?
-       if (width < 0)
-               return pit->size();
+       if (width < 0) {
+               row.endpos(pit->size() + 1);
+               return;
+       }
 
        LyXLayout_ptr const & layout = pit->layout();
 
-       if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX)
-               return addressBreakPoint(row.pos(), *pit);
+       if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+               row.endpos(addressBreakPoint(row.pos(), *pit) + 1);
+               return;
+       }
 
        pos_type const pos = row.pos();
        pos_type const body_pos = pit->beginningOfBody();
        pos_type const last = pit->size();
        pos_type point = last;
 
-       if (pos == last)
-               return last;
+       if (pos == last) {
+               row.endpos(last + 1);
+               return;
+       }
 
        // Now we iterate through until we reach the right margin
        // or the end of the par, then choose the possible break
@@ -591,7 +596,7 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
        if (body_pos && point < body_pos)
                point = body_pos - 1;
 
-       return point;
+       row.endpos(point + 1);
 }
 
 
@@ -1970,8 +1975,8 @@ void LyXText::redoParagraphInternal(ParagraphList::iterator pit)
        int const ww = workWidth();
        for (pos_type z = 0; z < pit->size() + 1; ) {
                Row row(z);
-               z = rowBreakPoint(pit, row) + 1;
-               row.endpos(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);
index 2cf575b0d6672d3e24ffa87208a0296db3ffc449..5752802aa5924a832336b336b18abfe1e22464f7 100644 (file)
@@ -285,6 +285,7 @@ void LyXText::cursorPrevious()
 
        LyXCursor cur;
        ParagraphList::iterator pit = cursorPar();
+       rit = cursorRow();
        previousRow(pit, rit);
        setCursor(cur, parOffset(pit), rit->pos(), false);
        if (cur.y() > bv_owner->top_y())
@@ -342,6 +343,7 @@ void LyXText::cursorNext()
        }
 
        ParagraphList::iterator pit = cursorPar();
+       rit = cursorRow();
        nextRow(pit, rit);
        LyXCursor cur;
        setCursor(cur, parOffset(pit), rit->pos(), false);