]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
* src/frontends/qt4/QTocDialog.C (updateGui):
[lyx.git] / src / text3.C
index 840ec68e1caabfc67a5d8bbe4b08b4a79fd3eb1c..2e595fadb85da2a8faf1220fbba20f3a588a9b9f 100644 (file)
@@ -121,8 +121,7 @@ namespace {
        {
                if (selecting || cur.mark())
                        cur.setSelection();
-               if (!cur.selection())
-                       theSelection().haveSelection(false);
+               theSelection().haveSelection(cur.selection());
                cur.bv().switchKeyMap();
        }
 
@@ -759,7 +758,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                cur.message(_("Paste"));
                cap::replaceSelection(cur);
                if (cmd.argument().empty() && !theClipboard().isInternal())
-                       pasteString(cur, theClipboard().get(), docstring());
+                       pasteString(cur, theClipboard().get(), true);
                else {
                        string const arg(to_utf8(cmd.argument()));
                        pasteSelection(cur, bv->buffer()->errorList("Paste"),
@@ -866,11 +865,13 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_CLIPBOARD_PASTE:
-               pasteString(cur, theClipboard().get(), cmd.argument());
+               pasteString(cur, theClipboard().get(),
+                           cmd.argument() == "paragraph");
                break;
 
        case LFUN_PRIMARY_SELECTION_PASTE:
-               pasteString(cur, theSelection().get(), cmd.argument());
+               pasteString(cur, theSelection().get(),
+                           cmd.argument() == "paragraph");
                break;
 
        case LFUN_UNICODE_INSERT: {
@@ -961,7 +962,14 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                // we have to check this first
                bool paste_internally = false;
                if (cmd.button() == mouse_button::button2 && cur.selection()) {
-                       lyx::dispatch(FuncRequest(LFUN_COPY));
+                       // Copy the selection to the clipboard stack. This
+                       // is done for two reasons:
+                       // - We want it to appear in the "Edit->Paste recent"
+                       //   menu.
+                       // - We can then use the normal copy/paste machinery
+                       //   instead of theSelection().get() to preserve
+                       //   formatting of the pasted stuff.
+                       cap::copySelectionToStack(cur.bv().cursor());
                        paste_internally = true;
                }
 
@@ -1034,7 +1042,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                // finish selection
                if (cmd.button() == mouse_button::button1) {
                        if (cur.selection())
-                               theSelection().haveSelection(cur.selection());
+                               theSelection().haveSelection(true);
                        needsUpdate = false;
                        cur.noUpdate();
                }
@@ -1056,7 +1064,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                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();
@@ -1883,12 +1893,12 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
 
 
 void LyXText::pasteString(LCursor & cur, docstring const & clip,
-               docstring const & argument)
+               bool asParagraphs)
 {
        cur.clearSelection();
        if (!clip.empty()) {
                recordUndo(cur);
-               if (argument == "paragraph")
+               if (asParagraphs)
                        insertStringAsParagraphs(cur, clip);
                else
                        insertStringAsLines(cur, clip);