]> git.lyx.org Git - features.git/commitdiff
Revert "When selecting text with the mouse, inset selection happens in the middle"
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 1 Apr 2017 11:09:23 +0000 (13:09 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 6 Apr 2017 13:17:00 +0000 (15:17 +0200)
This reverts commit eb4a2a190f2640d2a6ab7146cfcc347e70b57044.

src/Row.cpp
src/Row.h
src/Text3.cpp
src/TextMetrics.cpp
src/TextMetrics.h

index d6ea7275ba4174753a3a7a1911d62c2730b19c16..70e3dcafc3ac3683d72d4d9555e2b7a59df19fc3 100644 (file)
@@ -95,7 +95,7 @@ double Row::Element::pos2x(pos_type const i) const
 }
 
 
-pos_type Row::Element::x2pos(int &x, bool const select) const
+pos_type Row::Element::x2pos(int &x) const
 {
        //lyxerr << "x2pos: x=" << x << " w=" << width() << " " << *this;
        size_t i = 0;
@@ -112,18 +112,17 @@ pos_type Row::Element::x2pos(int &x, bool const select) const
                x = isRTL() ? int(full_width()) : 0;
                break;
        case INSET:
-       case SPACE: {
-               double const boundary = select ? (full_width() + 1) / 2 : full_width();
+       case SPACE:
                // those elements contain only one position. Round to
                // the closest side.
-               if (x > boundary) {
+               if (x > full_width()) {
                        x = int(full_width());
                        i = !isRTL();
                } else {
                        x = 0;
                        i = isRTL();
                }
-       }
+
        }
        //lyxerr << "=> p=" << pos + i << " x=" << x << endl;
        return pos + i;
index c840698f1c071b00bd1980197a8537270afe8f3a..498fd07d7f8f8ce5c08335171605061ed6269701 100644 (file)
--- a/src/Row.h
+++ b/src/Row.h
@@ -80,13 +80,12 @@ public:
                /** Return position in pixels (from the left) of position
                 * \param i in the row element.
                 */
-               double pos2x(pos_type i) const;
+               double pos2x(pos_type const i) const;
                /** Return character position that is the closest to
                 *  pixel position \param x. The value \param x is
                 *  adjusted to the actual pixel position.
-                *  \param select if true, return the right edge when closer.
-                */
-               pos_type x2pos(int & x, bool select = false) const;
+               */
+               pos_type x2pos(int &x) const;
                /** Break the element if possible, so that its width is less
                 * than \param w. Returns true on success. When \param force
                 * is true, the string is cut at any place, other wise it
index 617037f87168498c265897453cb9dbf117e14ad0..8cd6021d240036a461f74792d6df429d8f05e3c6 100644 (file)
@@ -1690,7 +1690,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                int const wh = bv->workHeight();
                int const y = max(0, min(wh - 1, cmd.y()));
 
-               tm->setCursorFromCoordinates(cur, cmd.x(), y, true);
+               tm->setCursorFromCoordinates(cur, cmd.x(), y);
                cur.setTargetX(cmd.x());
                // Don't allow selecting a separator inset
                if (cur.pos() && cur.paragraph().isEnvSeparator(cur.pos() - 1))
index ddb38572ab11218067b43594ed47d9acd62c00c5..13c1d02cdf83496c5c3951fc1ff0f9f0c44cc264 100644 (file)
@@ -1094,7 +1094,7 @@ void TextMetrics::setRowHeight(Row & row) const
 // returns the column near the specified x-coordinate of the row
 // x is set to the real beginning of this column
 pos_type TextMetrics::getPosNearX(Row const & row, int & x,
-                                  bool & boundary, bool const select) const
+                                 bool & boundary) const
 {
        //LYXERR0("getPosNearX(" << x << ") row=" << row);
        /// For the main Text, it is possible that this pit is not
@@ -1124,7 +1124,7 @@ pos_type TextMetrics::getPosNearX(Row const & row, int & x,
                for ( ; cit != cend; ++cit) {
                        if (w <= x &&  w + cit->full_width() > x) {
                                int x_offset = int(x - w);
-                               pos = cit->x2pos(x_offset, select);
+                               pos = cit->x2pos(x_offset);
                                x = int(x_offset + w);
                                break;
                        }
@@ -1372,8 +1372,7 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
 }
 
 
-void TextMetrics::setCursorFromCoordinates(Cursor & cur, int const x,
-                                           int const y, bool const select)
+void TextMetrics::setCursorFromCoordinates(Cursor & cur, int const x, int const y)
 {
        LASSERT(text_ == cur.text(), return);
        pit_type const pit = getPitNearY(y);
@@ -1400,7 +1399,7 @@ void TextMetrics::setCursorFromCoordinates(Cursor & cur, int const x,
 
        bool bound = false;
        int xx = x;
-       pos_type const pos = getPosNearX(row, xx, bound, select);
+       pos_type const pos = getPosNearX(row, xx, bound);
 
        LYXERR(Debug::DEBUG, "setting cursor pit: " << pit << " pos: " << pos);
 
index ade98739ed8c59d50c18d4f1a5860928fa12f48a..2f6181d0b0d91592d92198f0112473e5d83dd001 100644 (file)
@@ -150,8 +150,7 @@ public:
        /// returns the position near the specified x-coordinate of the row.
        /// x is an absolute screen coord, it is set to the real beginning
        /// of this column. This takes in account horizontal cursor row scrolling.
-       pos_type getPosNearX(Row const & row, int & x, bool & boundary,
-                            bool select = false) const;
+       pos_type getPosNearX(Row const & row, int & x, bool & boundary) const;
 
        /// returns pos in given par at given x coord.
        pos_type x2pos(pit_type pit, int row, int x) const;
@@ -189,10 +188,7 @@ public:
 
        /// sets cursor only within this Text.
        /// x,y are screen coordinates
-       /// If select is true, move to the next position if closer to the right
-       /// edge.
-       void setCursorFromCoordinates(Cursor & cur, int x, int y,
-                                     bool select = false);
+       void setCursorFromCoordinates(Cursor & cur, int x, int y);
 
        ///
        int cursorX(CursorSlice const & cursor, bool boundary) const;