using cap::pasteFromStack;
using cap::pasteClipboard;
using cap::replaceSelection;
-using cap::saveSelection;
using support::isStrUnsignedInt;
using support::token;
{
if (selecting || cur.mark())
cur.setSelection();
- saveSelection(cur);
- cur.bv().switchKeyMap();
}
}
case LFUN_WORD_DELETE_FORWARD:
- cur.clearSelection();
- deleteWordForward(cur);
+ if (cur.selection()) {
+ cutSelection(cur, true, false);
+ } else
+ deleteWordForward(cur);
finishChange(cur, false);
break;
case LFUN_WORD_DELETE_BACKWARD:
- cur.clearSelection();
- deleteWordBackward(cur);
+ if (cur.selection()) {
+ cutSelection(cur, true, false);
+ } else
+ deleteWordBackward(cur);
finishChange(cur, false);
break;
case LFUN_LINE_DELETE:
- cur.clearSelection();
- deleteLineForward(cur);
+ if (cur.selection()) {
+ cutSelection(cur, true, false);
+ } else
+ deleteLineForward(cur);
finishChange(cur, false);
break;
&& cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
- } else if (cur.selection())
- saveSelection(cur);
+ }
break;
case LFUN_CHAR_BACKWARD:
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_LEFT);
}
- if (cur.selection())
- saveSelection(cur);
break;
+ case LFUN_UP_SELECT:
+ case LFUN_DOWN_SELECT:
case LFUN_UP:
- case LFUN_UP_SELECT: {
- //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
- needsUpdate |= cur.selHandle(cmd.action == LFUN_UP_SELECT);
- bool const successful = cur.upDownInText(true, needsUpdate);
- if (!successful)
- cur.undispatched();
- if (cur.selection())
- saveSelection(cur);
- break;
- }
-
- case LFUN_DOWN:
- case LFUN_DOWN_SELECT: {
- //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
- needsUpdate |= cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
- bool const successful = cur.upDownInText(false, needsUpdate);
- if (!successful)
+ case LFUN_DOWN: {
+ // stop/start the selection
+ bool select = cmd.action == LFUN_DOWN_SELECT ||
+ cmd.action == LFUN_UP_SELECT;
+ cur.selHandle(select);
+
+ // move cursor up/down
+ bool up = cmd.action == LFUN_UP_SELECT || cmd.action == LFUN_UP;
+ bool const successful = cur.upDownInText(up, needsUpdate);
+ if (successful) {
+ // notify insets which were left and get their update flags
+ notifyCursorLeaves(cur.beforeDispatchCursor(), cur);
+ cur.fixIfBroken();
+
+ // redraw if you leave mathed (for the decorations)
+ needsUpdate |= cur.beforeDispatchCursor().inMathed();
+ } else
cur.undispatched();
- if (cur.selection())
- saveSelection(cur);
+
break;
}
case LFUN_PARAGRAPH_UP_SELECT:
needsUpdate |= cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
needsUpdate |= cursorUpParagraph(cur);
- if (cur.selection())
- saveSelection(cur);
break;
case LFUN_PARAGRAPH_DOWN:
case LFUN_PARAGRAPH_DOWN_SELECT:
needsUpdate |= cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
needsUpdate |= cursorDownParagraph(cur);
- if (cur.selection())
- saveSelection(cur);
break;
case LFUN_SCREEN_UP:
else {
cursorPrevious(cur);
}
- if (cur.selection())
- saveSelection(cur);
break;
case LFUN_SCREEN_DOWN:
else {
cursorNext(cur);
}
- if (cur.selection())
- saveSelection(cur);
break;
case LFUN_LINE_BEGIN:
case LFUN_LINE_END_SELECT:
needsUpdate |= cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
needsUpdate |= cursorEnd(cur);
- if (cur.selection())
- saveSelection(cur);
break;
case LFUN_WORD_FORWARD:
needsUpdate |= cursorLeftOneWord(cur);
else
needsUpdate |= cursorRightOneWord(cur);
- if (cur.selection())
- saveSelection(cur);
break;
case LFUN_WORD_BACKWARD:
needsUpdate |= cursorRightOneWord(cur);
else
needsUpdate |= cursorLeftOneWord(cur);
- if (cur.selection())
- saveSelection(cur);
break;
case LFUN_WORD_SELECT: {
cutSelection(cur, true, false);
singleParUpdate = false;
}
- bv->switchKeyMap();
break;
case LFUN_DELETE_BACKWARD_SKIP:
cap::replaceSelection(cur);
breakParagraph(cur, 0);
cur.resetAnchor();
- bv->switchKeyMap();
break;
case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
cap::replaceSelection(cur);
breakParagraph(cur, 1);
cur.resetAnchor();
- bv->switchKeyMap();
break;
case LFUN_BREAK_PARAGRAPH_SKIP: {
else
breakParagraph(cur, 0);
cur.resetAnchor();
- bv->switchKeyMap();
break;
}
}
bv->buffer()->errors("Paste");
cur.clearSelection(); // bug 393
- bv->switchKeyMap();
finishUndo();
break;
}
if (change_layout) {
- current_layout = layout;
setLayout(cur, layout);
// inform the GUI that the layout has changed.
bv->layoutChanged(layout);
- bv->switchKeyMap();
}
break;
}
docstring hexstring = cmd.argument();
if (lyx::support::isHex(hexstring)) {
char_type c = lyx::support::hexToInt(hexstring);
- if (c > 32 && c < 0x10ffff) {
+ if (c >= 32 && c < 0x10ffff) {
lyxerr << "Inserting c: " << c << endl;
docstring s = docstring(1, c);
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, s));
cursorEnd(cur);
cur.setSelection();
bv->cursor() = cur;
- saveSelection(cur);
}
break;
cap::pasteSelection(cur, bv->buffer()->errorList("Paste"));
bv->buffer()->errors("Paste");
cur.clearSelection(); // bug 393
- bv->switchKeyMap();
bv->buffer()->markDirty();
finishUndo();
} else {
// but bvcur is current mouse position
Cursor & bvcur = cur.bv().cursor();
bvcur.selection() = true;
- saveSelection(bvcur);
}
needsUpdate = false;
cur.noUpdate();
}
- bv->switchKeyMap();
break;
}
// "auto_region_delete", which defaults to
// true (on).
- if (lyxrc.auto_region_delete)
- if (cur.selection())
- cutSelection(cur, false, false);
+ if (lyxrc.auto_region_delete && cur.selection()) {
+ cutSelection(cur, false, false);
+ // When change tracking is set to off, the metrics update
+ // mechanism correctly detects if a full update is needed or not.
+ // This detection fails when a selection spans multiple rows and
+ // change tracking is enabled because the paragraph metrics stays
+ // the same. In this case, we force the full update:
+ // (see http://bugzilla.lyx.org/show_bug.cgi?id=3992)
+ if (cur.buffer().params().trackChanges)
+ cur.updateFlags(Update::Force);
+ }
cur.clearSelection();
Font const old_font = real_current_font;
docstring::const_iterator cit = cmd.argument().begin();
docstring::const_iterator end = cmd.argument().end();
for (; cit != end; ++cit)
- bv->getIntl().getTransManager().
- translateAndInsert(*cit, this, cur);
+ bv->translateAndInsert(*cit, this, cur);
cur.resetAnchor();
moveCursor(cur, false);
Font font(Font::ALL_IGNORE);
font.setLanguage(lang);
toggleAndShow(cur, this, font);
- bv->switchKeyMap();
break;
}
theLyXFunc().handleKeyFunc(cmd.action);
if (!cmd.argument().empty())
// FIXME: Are all these characters encoded in one byte in utf8?
- bv->getIntl().getTransManager()
- .translateAndInsert(cmd.argument()[0], this, cur);
+ bv->translateAndInsert(cmd.argument()[0], this, cur);
break;
case LFUN_FLOAT_LIST: {
case LFUN_ESCAPE:
if (cur.selection()) {
cur.selection() = false;
- saveSelection(cur);
} else {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
case LFUN_MATH_MATRIX:
case LFUN_MATH_DELIM:
case LFUN_MATH_BIGDELIM:
+ case LFUN_MATH_INSERT:
case LFUN_MATH_SUBSCRIPT:
case LFUN_MATH_SUPERSCRIPT:
case LFUN_FONT_DEFAULT: