]> git.lyx.org Git - features.git/commitdiff
Updates to splitting of consecutive environments.
authorRichard Heck <rgheck@lyx.org>
Thu, 21 Apr 2016 21:44:14 +0000 (17:44 -0400)
committerRichard Heck <rgheck@lyx.org>
Wed, 15 Jun 2016 21:32:52 +0000 (22:32 +0100)
From Enrico.

(cherry picked from commit ee82dd604010d4c1bf250640a3df6d790ea08380)

src/BufferView.cpp
src/Row.cpp
src/Text.cpp
src/Text3.cpp
src/TextMetrics.cpp

index 56ecd94e29694099a67855963092d3db506cbf6a..72b2bd4dcb392181f3ebd80605ff54afb31d6134 100644 (file)
@@ -2203,9 +2203,14 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
                // inset (depending on cmd.x(), cmd.y()). This is needed for
                // editing to fix bug 9628, but e.g. the context menu needs a
                // cursor in front of the inset.
-               if ((inset->hasSettings() || !inset->contextMenuName().empty()) &&
+               if ((inset->hasSettings() || !inset->contextMenuName().empty()
+                    || inset->lyxCode() == SEPARATOR_CODE) &&
                    cur.nextInset() != inset && cur.prevInset() == inset)
                        cur.posBackward();
+       } else if (cur.inTexted() && cur.pos()
+                       && cur.paragraph().isEnvSeparator(cur.pos() - 1)) {
+               // Always place cursor in front of a separator inset.
+               cur.posBackward();
        }
 
        // Put anchor at the same position.
@@ -2512,12 +2517,8 @@ bool BufferView::mouseSetCursor(Cursor & cur, bool select)
        // FIXME: (2) if we had a working InsetText::notifyCursorLeaves,
        // the leftinset bool would not be necessary (badcursor instead).
        bool update = leftinset;
-       if (!do_selection && d->cursor_.inTexted()) {
+       if (!do_selection && d->cursor_.inTexted())
                update |= checkDepm(cur, d->cursor_);
-               if (cur.inTexted() && cur.pos()
-                       && cur.paragraph().isEnvSeparator(cur.pos() - 1))
-                   cur.posBackward();
-       }
 
        if (!do_selection)
                d->cursor_.resetAnchor();
index 8af6fa9ae173f426d600ad2572dfbe134bb3f868..d0694f7d2e8539ffd328127786274eb97355beab 100644 (file)
@@ -66,8 +66,7 @@ double Row::Element::pos2x(pos_type const i) const
 
        double w = 0;
        //handle first the two bounds of the element
-       if (i == endpos && type != VIRTUAL
-               && !(inset && inset->lyxCode() == SEPARATOR_CODE))
+       if (i == endpos && type != VIRTUAL)
                w = isRTL() ? 0 : full_width();
        else if (i == pos || type != STRING)
                w = isRTL() ? full_width() : 0;
index 29ff6cfe57cca0f81ef4b0a17b786c43e31bd085..f6c1d392e5ab171ee114289b3e4918d3db20d3b5 100644 (file)
@@ -1110,7 +1110,7 @@ bool Text::cursorForwardOneWord(Cursor & cur)
        Paragraph const & par = cur.paragraph();
 
        // Paragraph boundary is a word boundary
-       if (pos == lastpos) {
+       if (pos == lastpos || (pos + 1 == lastpos && par.isEnvSeparator(pos))) {
                if (pit != cur.lastpit())
                        return setCursor(cur, pit + 1, 0);
                else
@@ -1143,6 +1143,10 @@ bool Text::cursorForwardOneWord(Cursor & cur)
                             ++pos;
        }
 
+       // Don't skip a separator inset at the end of a paragraph
+       if (pos == lastpos && pos && par.isEnvSeparator(pos - 1))
+               --pos;
+
        return setCursor(cur, pit, pos);
 }
 
@@ -1156,8 +1160,14 @@ bool Text::cursorBackwardOneWord(Cursor & cur)
        Paragraph & par = cur.paragraph();
 
        // Paragraph boundary is a word boundary
-       if (pos == 0 && pit != 0)
-               return setCursor(cur, pit - 1, getPar(pit - 1).size());
+       if (pos == 0 && pit != 0) {
+               Paragraph & prevpar = getPar(pit - 1);
+               pos = prevpar.size();
+               // Don't stop after an environment separator
+               if (pos && prevpar.isEnvSeparator(pos - 1))
+                       --pos;
+               return setCursor(cur, pit - 1, pos);
+       }
 
        if (lyxrc.mac_like_cursor_movement) {
                // Skip through punctuation and spaces.
index 15ffb2881f6b4cee7b6449363ec49e53b101618a..49df75efa34096447d3043c91591d3227777383f 100644 (file)
@@ -1661,6 +1661,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
                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))
+                       cur.posBackward();
                if (cmd.y() >= wh)
                        lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT));
                else if (cmd.y() < 0)
index 8b5842f9028b2fd1b7b7f3ca4e4130e64814ac48..816f4bacd6115d741dce60cee8a3b7dee569900c 100644 (file)
@@ -1596,7 +1596,8 @@ bool TextMetrics::cursorEnd(Cursor & cur)
                        boundary = true;
                else
                        --end;
-       }
+       } else if (cur.paragraph().isEnvSeparator(end-1))
+               --end;
        return text_->setCursor(cur, cur.pit(), end, true, boundary);
 }