From aec5a388c88c814ed341e411fc4b2acc0cf54576 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 22 Oct 2003 16:30:57 +0000 Subject: [PATCH] rename row.end into row.endpos git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7956 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 12 ++++++++++++ src/bufferview_funcs.C | 2 +- src/lyxrow.C | 4 ++-- src/lyxrow.h | 4 ++-- src/lyxrow_funcs.C | 12 +++--------- src/lyxrow_funcs.h | 2 -- src/rowpainter.C | 17 ++++++++++------- src/text.C | 27 ++++++++++++++------------- src/text2.C | 6 +++--- 9 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index fc6f716d7a..c438cc39c1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ + +2003-10-22 André Pönitz + + * lyxtext.h: + * text.C: use Row & instead of RowList::iterator + + * lyxrow.h: rename end() to endpos() + + * rowpainter.C: + * text.C: + * text2.C: adjust + 2003-10-22 Angus Leeming * buffer.[Ch] (fully_loaded): new member function, returning true diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 757c8ef000..58a8fbc497 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -365,7 +365,7 @@ string const currentState(BufferView * bv) state << _(", Paragraph: ") << text->cursorPar()->id(); state << _(", Position: ") << text->cursor.pos(); RowList::iterator rit = text->cursorRow(); - state << bformat(_(", Row b:%1$d e:%2$d"), rit->pos(), rit->end()); + state << bformat(_(", Row b:%1$d e:%2$d"), rit->pos(), rit->endpos()); state << _(", Inset: "); InsetOld * inset = text->cursorPar()->inInset(); if (inset) diff --git a/src/lyxrow.C b/src/lyxrow.C index 8ae4715e65..fadebef109 100644 --- a/src/lyxrow.C +++ b/src/lyxrow.C @@ -48,13 +48,13 @@ pos_type Row::pos() const } -void Row::end(pos_type p) +void Row::endpos(pos_type p) { end_ = p; } -pos_type Row::end() const +pos_type Row::endpos() const { return end_; } diff --git a/src/lyxrow.h b/src/lyxrow.h index 585b46cb8b..56f3430e26 100644 --- a/src/lyxrow.h +++ b/src/lyxrow.h @@ -29,9 +29,9 @@ public: /// lyx::pos_type pos() const; /// - void end(lyx::pos_type p); + void endpos(lyx::pos_type p); /// - lyx::pos_type end() const; + lyx::pos_type endpos() const; /// void fill(int f); /// diff --git a/src/lyxrow_funcs.C b/src/lyxrow_funcs.C index e7af3d086f..4510855ef9 100644 --- a/src/lyxrow_funcs.C +++ b/src/lyxrow_funcs.C @@ -24,17 +24,11 @@ using std::min; using std::endl; -bool isParEnd(Paragraph const & par, Row const & row) -{ - return row.end() == par.size(); -} - - pos_type lastPos(Paragraph const & par, Row const & row) { if (par.empty()) return 0; - pos_type pos = row.end() - 1; + pos_type pos = row.endpos() - 1; if (pos == par.size()) --pos; return pos; @@ -113,14 +107,14 @@ bool hfillExpansion(Paragraph const & par, Row const & row, pos_type pos) // at the end of a row it does not count // unless another hfill exists on the line - if (pos >= lastPos(par, row)) { + if (pos >= row.endpos()) { for (pos_type i = row.pos(); i < pos && !par.isHfill(i); ++i) return false; } // at the beginning of a row it does not count, if it is not // the first row of a paragaph - if (row.isParStart()) + if (row.pos() == 0) return true; // in some labels it does not count diff --git a/src/lyxrow_funcs.h b/src/lyxrow_funcs.h index 236584de7e..3eb84c1c3a 100644 --- a/src/lyxrow_funcs.h +++ b/src/lyxrow_funcs.h @@ -18,8 +18,6 @@ class Paragraph; class Row; -bool isParEnd(Paragraph const & par, Row const & row); - lyx::pos_type lastPos(Paragraph const & par, Row const & row); int numberOfSeparators(Paragraph const & par, Row const & row); diff --git a/src/rowpainter.C b/src/rowpainter.C index 82c5a08d49..efb9342e19 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -14,6 +14,7 @@ #include "rowpainter.h" #include "buffer.h" +#include "debug.h" #include "bufferparams.h" #include "BufferView.h" #include "encoding.h" @@ -527,7 +528,7 @@ void RowPainter::paintDepthBar() Paragraph::depth_type prev_depth = 0; if (row_ != text_.firstRow()) { ParagraphList::iterator pit2 = pit_; - if (row_ == pit2->rows.begin()) + if (row_->pos() == 0) --pit2; prev_depth = pit2->getDepth(); } @@ -535,7 +536,7 @@ void RowPainter::paintDepthBar() Paragraph::depth_type next_depth = 0; if (row_ != text_.lastRow()) { ParagraphList::iterator pit2 = pit_; - if (boost::next(row_) == pit2->rows.end()) + if (row_->endpos() >= pit2->size()) ++pit2; next_depth = pit2->getDepth(); } @@ -735,12 +736,14 @@ void RowPainter::paintFirst() } bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params()); + bool const is_seq = isFirstInSequence(pit_, text_.ownerParagraphs()); + //lyxerr << "paintFirst: " << pit_->id() << " is_seq: " << is_seq << std::endl; // should we print a label? if (layout->labeltype >= LABEL_STATIC && (layout->labeltype != LABEL_STATIC - || layout->latextype != LATEX_ENVIRONMENT - || isFirstInSequence(pit_, text_.ownerParagraphs()))) { + || layout->latextype != LATEX_ENVIRONMENT + || is_seq)) { LyXFont font = getLabelFont(); if (!pit_->getLabelstring().empty()) { @@ -788,7 +791,7 @@ void RowPainter::paintFirst() // the labels at the top of an environment. // More or less for bibliography - } else if (isFirstInSequence(pit_, text_.ownerParagraphs()) && + } else if (is_seq && (layout->labeltype == LABEL_TOP_ENVIRONMENT || layout->labeltype == LABEL_BIBLIO || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) { @@ -1036,10 +1039,10 @@ void RowPainter::paint() // changebar paintChangeBar(); - if (row_->isParStart()) + if (row_->pos() == 0) paintFirst(); - if (isParEnd(*pit_, *row_)) + if (row_->endpos() >= pit_->size()) paintLast(); // paint text diff --git a/src/text.C b/src/text.C index 582a91ec3f..654f2b39d2 100644 --- a/src/text.C +++ b/src/text.C @@ -769,8 +769,10 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit, // returns the minimum space a row needs on the screen in pixel int LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const { - if (paper_width < 0) + if (paper_width < 0) { + lyxerr << "paperwidth < 0: " << paper_width << " Why?" << endl; return 0; + } int w; // get the pure distance @@ -781,7 +783,7 @@ int LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const // special handling of the right address boxes if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) { int const tmpfill = row.fill(); - row.fill(0); // the minfill in MarginLeft() + row.fill(0); // the minfill in leftMargin() w = leftMargin(pit, row); row.fill(tmpfill); } else @@ -1106,7 +1108,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row) } // is it a bottom line? - if (row.end() == pit->size()) { + if (row.endpos() >= pit->size()) { // the bottom margin ParagraphList::iterator nextpit = boost::next(pit); if (nextpit == ownerParagraphs().end() && !isInInset()) @@ -1468,8 +1470,8 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const { int const ns = numberOfSeparators(*pit, row); bool disp_inset = false; - if (row.end() < pit->size()) { - InsetOld * in = pit->getInset(row.end()); + if (row.endpos() < pit->size()) { + InsetOld * in = pit->getInset(row.endpos()); if (in) disp_inset = in->display(); } @@ -1477,8 +1479,8 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const // par, does not end in newline, and is not row above a // display inset... then stretch it if (ns - && row.end() < pit->size() - && !pit->isNewline(row.end()) + && row.endpos() < pit->size() + && !pit->isNewline(row.endpos()) && !disp_inset ) { fill_separator = w / ns; @@ -2146,18 +2148,17 @@ int LyXText::redoParagraphInternal(ParagraphList::iterator pit) for (pos_type z = 0; z < pit->size() + 1; ) { Row row(z); z = rowBreakPoint(pit, row) + 1; - row.end(z); + row.endpos(z); int const f = fill(pit, row, ww); int const w = ww - f; par_width = std::max(par_width, w); row.fill(f); row.width(w); + prepareToPrint(pit, row); + setHeightOfRow(pit, row); + row.y_offset(pit->height); + pit->height += row.height(); pit->rows.push_back(row); - RowList::iterator rit = boost::prior(pit->rows.end()); - prepareToPrint(pit, *rit); - setHeightOfRow(pit, *rit); - rit->y_offset(pit->height); - pit->height += rit->height(); } height += pit->height; diff --git a/src/text2.C b/src/text2.C index 6df04db2c6..098a3168da 100644 --- a/src/text2.C +++ b/src/text2.C @@ -566,7 +566,7 @@ void LyXText::cursorHome() void LyXText::cursorEnd() { - setCursor(cursorPar(), cursorRow()->end() - 1); + setCursor(cursorPar(), cursorRow()->endpos() - 1); } @@ -1502,7 +1502,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit, boundary = false; // This (rtl_support test) is not needed, but gives // some speedup if rtl_support == false - bool const lastrow = lyxrc.rtl_support && row.end() == pit->size(); + bool const lastrow = lyxrc.rtl_support && row.endpos() == pit->size(); // If lastrow is false, we don't need to compute // the value of rtl. @@ -1511,7 +1511,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit, : false; if (lastrow && ((rtl && left_side && vc == row.pos() && x < tmpx - 5) || - (!rtl && !left_side && vc == last + 1 && x > tmpx + 5))) + (!rtl && !left_side && vc == last + 1 && x > tmpx + 5))) c = last + 1; else if (vc == row.pos()) { c = vis2log(vc); -- 2.39.2