From: André Pönitz Date: Thu, 23 Oct 2003 15:38:48 +0000 (+0000) Subject: Alfredo's cursroRow() fix; X-Git-Tag: 1.6.10~15900 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=cf40d206dc00aec9c12b882cfa4972dc1fbbb845;p=features.git Alfredo's cursroRow() fix; 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 --- diff --git a/src/lyxtext.h b/src/lyxtext.h index b48a8a580f..25c63df039 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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; diff --git a/src/text.C b/src/text.C index 739a230301..053b668fd4 100644 --- a/src/text.C +++ b/src/text.C @@ -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); diff --git a/src/text3.C b/src/text3.C index 2cf575b0d6..5752802aa5 100644 --- a/src/text3.C +++ b/src/text3.C @@ -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);