From: Lars Gullik Bjønnes Date: Thu, 4 Sep 2003 15:21:34 +0000 (+0000) Subject: fix cursorEnd, remove lastPrintablePos X-Git-Tag: 1.6.10~16173 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=bf053299a6cd0381a8894d0cb70a825b7fd76301;p=lyx.git fix cursorEnd, remove lastPrintablePos git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7664 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 741491691f..d09477a021 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2003-09-04 Lars Gullik Bjønnes + + * text2.C (cursorEnd): simplify + (setCursor): adjust + (getColumnNearX): adjust + + * text.C (computeBidiTables): adjust + (fill): adjust + + * rowpainter.C (paintChars): adjust + (paintSelection): adjust + (paintChangeBar): adjust + (paintText): adjust + + * lyxrow_funcs.C (lastPrintablePos): remove, all users now call + lastPos instead. + (numberOfSeparators): adjust + 2003-09-03 Martin Vermeer * LyXAction.C: diff --git a/src/lyxrow_funcs.C b/src/lyxrow_funcs.C index 9dacc2aa21..54cbdc3251 100644 --- a/src/lyxrow_funcs.C +++ b/src/lyxrow_funcs.C @@ -44,7 +44,7 @@ bool isParEnd(Paragraph const & par, RowList::iterator rit) return boost::next(rit) == par.rows.end(); } - +#if 1 pos_type lastPos(Paragraph const & par, RowList::iterator rit) { if (par.empty()) @@ -62,23 +62,17 @@ pos_type lastPos(Paragraph const & par, RowList::iterator rit) } return boost::next(rit)->pos() - 1; } - - -pos_type lastPrintablePos(Paragraph const & par, RowList::iterator rit) +#else +pos_type lastPos(Paragraph const &, RowList::iterator rit) { - pos_type const last = lastPos(par, rit); - - // if this row is an end of par, just act like lastPos() - if (isParEnd(par, rit)) - return last; - - return last; + return rit->end() - 1; } +#endif int numberOfSeparators(Paragraph const & par, RowList::iterator rit) { - pos_type const last = lastPrintablePos(par, rit); + pos_type const last = lastPos(par, rit); int n = 0; pos_type p = max(rit->pos(), par.beginningOfBody()); for ( ; p < last; ++p) diff --git a/src/lyxrow_funcs.h b/src/lyxrow_funcs.h index 046e3c9d7d..a3f012054c 100644 --- a/src/lyxrow_funcs.h +++ b/src/lyxrow_funcs.h @@ -22,8 +22,6 @@ bool isParEnd(Paragraph const & par, RowList::iterator rit); lyx::pos_type lastPos(Paragraph const & par, RowList::iterator rit); -lyx::pos_type lastPrintablePos(Paragraph const & par, RowList::iterator rit); - int numberOfSeparators(Paragraph const & par, RowList::iterator rit); int numberOfHfills(Paragraph const & par, RowList::iterator rit); diff --git a/src/rowpainter.C b/src/rowpainter.C index a59e8385bb..7801f9115b 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -257,7 +257,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos) void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic) { pos_type pos = text_.vis2log(vpos); - pos_type const last = lastPrintablePos(*pit_, row_); + pos_type const last = lastPos(*pit_, row_); LyXFont orig_font = getFont(pos); // first character @@ -434,7 +434,7 @@ void RowPainter::paintSelection() int(x_), row_->height(), LColor::selection); pos_type const body_pos = pit_->beginningOfBody(); - pos_type const last = lastPrintablePos(*pit_, row_); + pos_type const last = lastPos(*pit_, row_); double tmpx = x_; for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) { @@ -486,7 +486,7 @@ void RowPainter::paintSelection() void RowPainter::paintChangeBar() { pos_type const start = row_->pos(); - pos_type const end = lastPrintablePos(*pit_, row_); + pos_type const end = lastPos(*pit_, row_); if (!pit_->isChanged(start, end)) return; @@ -896,7 +896,7 @@ void RowPainter::paintLast() void RowPainter::paintText() { - pos_type const last = lastPrintablePos(*pit_, row_); + pos_type const last = lastPos(*pit_, row_); pos_type body_pos = pit_->beginningOfBody(); if (body_pos > 0 && (body_pos - 1 > last || !pit_->isLineSeparator(body_pos - 1))) { diff --git a/src/text.C b/src/text.C index 4cc0cee594..26460846e8 100644 --- a/src/text.C +++ b/src/text.C @@ -287,7 +287,7 @@ void LyXText::computeBidiTables(ParagraphList::iterator pit, } bidi_start = row->pos(); - bidi_end = lastPrintablePos(*pit, row); + bidi_end = lastPos(*pit, row); if (bidi_start > bidi_end) { bidi_start = -1; @@ -779,7 +779,7 @@ int LyXText::fill(ParagraphList::iterator pit, int w; // get the pure distance - pos_type const last = lastPrintablePos(*pit, row); + pos_type const last = lastPos(*pit, row); LyXLayout_ptr const & layout = pit->layout(); diff --git a/src/text2.C b/src/text2.C index 8158ebaa6c..b1318017c1 100644 --- a/src/text2.C +++ b/src/text2.C @@ -672,16 +672,7 @@ void LyXText::cursorHome() void LyXText::cursorEnd() { - if (cursor.par()->empty()) - return; - - RowList::iterator rit = cursorRow(); - ParagraphList::iterator pit = cursor.par(); - pos_type pos = lastPos(*pit, rit); - /* cursor should be before a hard newline only */ - if (!pit->isNewline(pos)) - ++pos; - setCursor(pit, pos); + setCursor(cursor.par(), cursorRow()->end() - 1); } @@ -1358,7 +1349,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit, // y is now the cursor baseline cur.y(y); - pos_type last = lastPrintablePos(*pit, row); + pos_type last = lastPos(*pit, row); // None of these should happen, but we're scaredy-cats if (pos > pit->size()) { @@ -1497,7 +1488,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit, double fill_label_hfill = rit->fill_label_hfill(); pos_type vc = rit->pos(); - pos_type last = lastPrintablePos(*pit, rit); + pos_type last = lastPos(*pit, rit); pos_type c = 0; LyXLayout_ptr const & layout = pit->layout();