// 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.
// 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();
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;
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
++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);
}
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.
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)
boundary = true;
else
--end;
- }
+ } else if (cur.paragraph().isEnvSeparator(end-1))
+ --end;
return text_->setCursor(cur, cur.pit(), end, true, boundary);
}