using cap::copySelection;
using cap::cutSelection;
+using cap::pasteClipboard;
using cap::pasteSelection;
using cap::replaceSelection;
{
if (selecting || cur.mark())
cur.setSelection();
- if (!cur.selection())
- theSelection().haveSelection(false);
+ theSelection().haveSelection(cur.selection());
cur.bv().switchKeyMap();
}
case LFUN_BREAK_LINE: {
// Not allowed by LaTeX (labels or empty par)
if (cur.pos() > cur.paragraph().beginOfBody()) {
+ if (!cur.selection())
+ recordUndo(cur);
cap::replaceSelection(cur);
cur.insert(new InsetNewline);
cur.posRight();
cur.message(_("Paste"));
cap::replaceSelection(cur);
if (cmd.argument().empty() && !theClipboard().isInternal())
- pasteString(cur, theClipboard().get(), true);
+ pasteClipboard(cur, bv->buffer()->errorList("Paste"));
else {
string const arg(to_utf8(cmd.argument()));
pasteSelection(cur, bv->buffer()->errorList("Paste"),
isStrUnsignedInt(arg) ?
convert<unsigned int>(arg) :
0);
- bv->buffer()->errors("Paste");
}
+ bv->buffer()->errors("Paste");
cur.clearSelection(); // bug 393
bv->switchKeyMap();
finishUndo();
}
case LFUN_CLIPBOARD_PASTE:
- pasteString(cur, theClipboard().get(),
- cmd.argument() == "paragraph");
+ cur.clearSelection();
+ pasteClipboard(cur, bv->buffer()->errorList("Paste"),
+ cmd.argument() == "paragraph");
+ bv->buffer()->errors("Paste");
break;
case LFUN_PRIMARY_SELECTION_PASTE:
if (lyxrc.auto_region_delete) {
if (cur.selection())
cutSelection(cur, false, false);
- theSelection().haveSelection(false);
+ // cutSelection clears the X selection.
+ else
+ theSelection().haveSelection(false);
}
cur.clearSelection();
break;
case LFUN_PASTE:
- // FIXME: This is not correct, but the correct code below is
- // expensive
- enable = cap::numberOfSelections() > 0 ||
- !theClipboard().isInternal();
-#if 0
if (cmd.argument().empty()) {
if (theClipboard().isInternal())
enable = cap::numberOfSelections() > 0;
else
- enable = !theClipboard().get().empty();
- } else if (isStrUnsignedInt(to_utf8(cmd.argument()))) {
- int n = convert<unsigned int>(to_utf8(cmd.argument()));
- enable = cap::numberOfSelections() > n;
- } else
- // unknown argument
- enable = false;
-#endif
+ enable = !theClipboard().empty();
+ } else {
+ string const arg = to_utf8(cmd.argument());
+ if (isStrUnsignedInt(arg)) {
+ unsigned int n = convert<unsigned int>(arg);
+ enable = cap::numberOfSelections() > n;
+ } else
+ // unknown argument
+ enable = false;
+ }
+ break;
+
+ case LFUN_CLIPBOARD_PASTE:
+ enable = !theClipboard().empty();
+ break;
+
+ case LFUN_PRIMARY_SELECTION_PASTE:
+ enable = cur.selection() || !theSelection().empty();
break;
case LFUN_PARAGRAPH_MOVE_UP:
case LFUN_SERVER_GET_FONT:
case LFUN_SERVER_GET_LAYOUT:
case LFUN_LAYOUT:
- case LFUN_CLIPBOARD_PASTE:
- case LFUN_PRIMARY_SELECTION_PASTE:
case LFUN_DATE_INSERT:
case LFUN_SELF_INSERT:
case LFUN_LINE_INSERT: