From: André Pönitz Date: Fri, 24 Oct 2003 07:59:04 +0000 (+0000) Subject: set fill in fill(...) istead of returning it. X-Git-Tag: 1.6.10~15896 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=70f983b97f53282c2ed390306b62c29d2d766356;p=features.git set fill in fill(...) istead of returning it. use isLastRow() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7974 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/lyxfunc.C b/src/lyxfunc.C index e6e951fc26..0f4ebdc03d 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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; } diff --git a/src/lyxtext.h b/src/lyxtext.h index 25c63df039..5709aeb10e 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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 diff --git a/src/rowpainter.C b/src/rowpainter.C index accc12d899..e21ce0cdb9 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -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(text).updateRowPositions(); int const yy = yf - y; int const y2 = bv.painter().paperHeight(); diff --git a/src/text.C b/src/text.C index 053b668fd4..31eebcf5f2 100644 --- a/src/text.C +++ b/src/text.C @@ -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"; diff --git a/src/text3.C b/src/text3.C index 7c4430b526..3baec4a794 100644 --- a/src/text3.C +++ b/src/text3.C @@ -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();