diff --git a/src/BufferView.cpp b/src/BufferView.cpp index c1afd76a5e..b30289d996 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2161,8 +2161,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) cur.setCursor(doc_iterator_begin(cur.buffer())); cur.selHandle(false); - d->text_metrics_[&buffer_.text()].editXY(cur, p.x, p.y, - false, act == LFUN_SCREEN_UP); + d->text_metrics_[&buffer_.text()].editXY(cur, p.x, p.y); //FIXME: what to do with cur.x_target()? bool update = in_texted && cur.bv().checkDepm(cur, old); cur.finishUndo(); diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index ea9efe776d..03b7424904 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -1515,8 +1515,7 @@ pit_type TextMetrics::getPitNearY(int y) } -Row const & TextMetrics::getPitAndRowNearY(int & y, pit_type & pit, - bool assert_in_view, bool up) +Row const & TextMetrics::getRowNearY(int & y, pit_type pit) { ParagraphMetrics const & pm = par_metrics_[pit]; @@ -1529,48 +1528,21 @@ Row const & TextMetrics::getPitAndRowNearY(int & y, pit_type & pit, if (yy + rit->height() > y) break; - if (assert_in_view) { - if (!up && yy + rit->height() > y) { - if (rit != pm.rows().begin()) { - y = yy; - --rit; - } else if (pit != 0) { - --pit; - newParMetricsUp(); - ParagraphMetrics const & pm2 = par_metrics_[pit]; - rit = pm2.rows().end(); - --rit; - y = yy; - } - } else if (up && yy != y) { - if (rit != rlast) { - y = yy + rit->height(); - ++rit; - } else if (pit < int(text_->paragraphs().size()) - 1) { - ++pit; - newParMetricsDown(); - ParagraphMetrics const & pm2 = par_metrics_[pit]; - rit = pm2.rows().begin(); - y = pm2.position(); - } - } - } return *rit; } // x,y are absolute screen coordinates // sets cursor recursively descending into nested editable insets -Inset * TextMetrics::editXY(Cursor & cur, int x, int y, - bool assert_in_view, bool up) +Inset * TextMetrics::editXY(Cursor & cur, int x, int y) { if (lyxerr.debugging(Debug::WORKAREA)) { LYXERR0("TextMetrics::editXY(cur, " << x << ", " << y << ")"); cur.bv().coordCache().dump(); } - pit_type pit = getPitNearY(y); + pit_type const pit = getPitNearY(y); LASSERT(pit != -1, return 0); - Row const & row = getPitAndRowNearY(y, pit, assert_in_view, up); + Row const & row = getRowNearY(y, pit); cur.pit() = pit; // Do we cover an inset? diff --git a/src/TextMetrics.h b/src/TextMetrics.h index 216b7014be..7719fcb0af 100644 --- a/src/TextMetrics.h +++ b/src/TextMetrics.h @@ -195,10 +195,8 @@ public: std::pair getPosNearX(Row const & row, int & x) const; /// returns the row near the specified y-coordinate in a given paragraph - /// (relative to the screen). If assert_in_view is true, it is made sure - /// that the row is on screen completely; this might change the given pit. - Row const & getPitAndRowNearY(int & y, pit_type & pit, - bool assert_in_view, bool up); + /// (relative to the screen). + Row const & getRowNearY(int & y, pit_type pit); /// returns the paragraph number closest to screen y-coordinate. /// This method uses the BufferView CoordCache to locate the @@ -211,18 +209,13 @@ public: /** \return the inset pointer if x,y is covering that inset \param x,y are absolute screen coordinates. - \param assert_in_view if true the cursor will be set on a row - that is completely visible - \param up whether we are going up or down (only used when - assert_in_view is true \retval inset is null if the cursor is positioned over normal text in the current Text object. Otherwise it is the inset that the cursor points to, like for Inset::editXY. */ /// FIXME: cleanup to use BufferView::getCoveringInset() and /// setCursorFromCoordinates() instead of checkInsetHit(). - Inset * editXY(Cursor & cur, int x, int y, - bool assert_in_view = false, bool up = true); + Inset * editXY(Cursor & cur, int x, int y); /// sets cursor only within this Text. /// x,y are screen coordinates