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
This commit is contained in:
André Pönitz 2003-10-23 15:38:48 +00:00
parent d42dd19a77
commit cf40d206dc
3 changed files with 19 additions and 13 deletions

View 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;

View 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);

View 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);