diff --git a/src/BufferView.cpp b/src/BufferView.cpp index cb45617831..261359217a 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -393,7 +393,7 @@ bool BufferView::fitCursor() theFontMetrics(d->cursor_.getFont().fontInfo()); int const asc = fm.maxAscent(); int const des = fm.maxDescent(); - Point const p = getPos(d->cursor_, d->cursor_.boundary()); + Point const p = getPos(d->cursor_); if (p.y_ - asc >= 0 && p.y_ + des < height_) return false; } @@ -646,7 +646,7 @@ void BufferView::setCursorFromScrollbar() newy = last; break; case CUR_INSIDE: - int const y = getPos(oldcur, oldcur.boundary()).y_; + int const y = getPos(oldcur).y_; newy = min(last, max(y, first)); if (y == newy) return; @@ -681,7 +681,7 @@ Change const BufferView::getCurrentChange() const // FIXME: This does not work within mathed! CursorStatus BufferView::cursorStatus(DocIterator const & dit) const { - Point const p = getPos(dit, dit.boundary()); + Point const p = getPos(dit); if (p.y_ < 0) return CUR_ABOVE; if (p.y_ > workHeight()) @@ -1580,13 +1580,13 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) case LFUN_SCREEN_UP: case LFUN_SCREEN_DOWN: { - Point p = getPos(cur, cur.boundary()); + Point p = getPos(cur); // This code has been commented out to enable to scroll down a // document, even if there are large insets in it (see bug #5465). /*if (p.y_ < 0 || p.y_ > height_) { // The cursor is off-screen so recenter before proceeding. showCursor(); - p = getPos(cur, cur.boundary()); + p = getPos(cur); }*/ int const scrolled = scroll(act == LFUN_SCREEN_UP ? -height_ : height_); @@ -1621,10 +1621,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) cur.finishUndo(); break; } - int y = getPos(cur, cur.boundary()).y_; + int y = getPos(cur).y_; int const ymin = y - height_ + defaultRowHeight(); while (y > ymin && cur.up()) - y = getPos(cur, cur.boundary()).y_; + y = getPos(cur).y_; cur.finishUndo(); dr.update(Update::SinglePar | Update::FitCursor); @@ -1638,10 +1638,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) cur.finishUndo(); break; } - int y = getPos(cur, cur.boundary()).y_; + int y = getPos(cur).y_; int const ymax = y + height_ - defaultRowHeight(); while (y < ymax && cur.down()) - y = getPos(cur, cur.boundary()).y_; + y = getPos(cur).y_; cur.finishUndo(); dr.update(Update::SinglePar | Update::FitCursor); @@ -2518,7 +2518,7 @@ Point BufferView::coordOffset(DocIterator const & dit, bool boundary) const } -Point BufferView::getPos(DocIterator const & dit, bool boundary) const +Point BufferView::getPos(DocIterator const & dit) const { if (!paragraphVisible(dit)) return Point(-1, -1); @@ -2526,7 +2526,7 @@ Point BufferView::getPos(DocIterator const & dit, bool boundary) const CursorSlice const & bot = dit.bottom(); TextMetrics const & tm = textMetrics(bot.text()); - Point p = coordOffset(dit, boundary); // offset from outer paragraph + Point p = coordOffset(dit, dit.boundary()); // offset from outer paragraph p.y_ += tm.parMetrics(bot.pit()).position(); return p; } @@ -2549,7 +2549,7 @@ void BufferView::cursorPosAndHeight(Point & p, int & h) const int const asc = fm.maxAscent(); int const des = fm.maxDescent(); h = asc + des; - p = getPos(cur, cur.boundary()); + p = getPos(cur); p.y_ -= asc; } diff --git a/src/BufferView.h b/src/BufferView.h index c3e184bd4e..f43d5a01e3 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -259,7 +259,7 @@ public: CoordCache const & coordCache() const; /// - Point getPos(DocIterator const & dit, bool boundary) const; + Point getPos(DocIterator const & dit) const; /// is the paragraph of the cursor visible ? bool paragraphVisible(DocIterator const & dit) const; /// is the cursor currently visible in the view diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 33536fae07..75f7a2df99 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -215,7 +215,9 @@ bool bruteFind3(Cursor & cur, int x, int y, bool up) // avoid invalid nesting when selecting if (bv.cursorStatus(it) == CUR_INSIDE && (!cur.selection() || positionable(it, cur.realAnchor()))) { - Point p = bv.getPos(it, false); + // If this function is ever used again, check whether this + // is the same as "bv.getPos(it, false)" with boundary = false. + Point p = bv.getPos(it); int xo = p.x_; int yo = p.y_; if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) { @@ -467,7 +469,7 @@ int Cursor::currentMode() void Cursor::getPos(int & x, int & y) const { - Point p = bv().getPos(*this, boundary()); + Point p = bv().getPos(*this); x = p.x_; y = p.y_; } @@ -1886,7 +1888,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded) // with and without selection are handled differently if (!selection()) { - int yo = bv().getPos(*this, boundary()).y_; + int yo = bv().getPos(*this).y_; Cursor old = *this; // To next/previous row if (up) diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 482b2a13bf..22c834e321 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -2218,7 +2218,7 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row, cur.boundary(begin_boundary); int x1 = cursorX(beg.top(), begin_boundary); int x2 = cursorX(end.top(), end_boundary); - int const y1 = bv_->getPos(cur, cur.boundary()).y_ - row.ascent(); + int const y1 = bv_->getPos(cur).y_ - row.ascent(); int const y2 = y1 + row.height(); int const rm = text_->isMainText() ? bv_->rightMargin() : 0; @@ -2307,8 +2307,10 @@ void TextMetrics::completionPosAndDim(Cursor const & cur, int & x, int & y, wordStart.pos() -= word.length(); // get position on screen of the word start and end - Point lxy = cur.bv().getPos(wordStart, false); - Point rxy = cur.bv().getPos(bvcur, bvcur.boundary()); + //FIXME: Is it necessary to explicitly set this to false? + wordStart.boundary(false); + Point lxy = cur.bv().getPos(wordStart); + Point rxy = cur.bv().getPos(bvcur); // calculate dimensions of the word dim = rowHeight(bvcur.pit(), wordStart.pos(), bvcur.pos(), false);