]> git.lyx.org Git - features.git/commitdiff
Fix and document middle mouse button paste. This is probably the last of
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 5 Jan 2007 14:40:49 +0000 (14:40 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 5 Jan 2007 14:40:49 +0000 (14:40 +0000)
the status quo fixes, I'll send a proposal how to proceed soon.

* src/CutAndPaste.[Ch]
(copySelection): Split into copySelection and copySelectionToStack

* src/text3.C
(LyXText::dispatch): Use copySelectionToStack instead of LFUN_COPY
to copy the selection to the cut buffer for two reasons:
- LFUN_COPY did not work (probably because bv.cursor() was not yet set)
- If it would work it would put the selection to the system clipboard
  which is clearly wrong.
Document why we put the selection to the stack.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16534 a592a061-630c-0410-9148-cb99ea01b6c8

src/CutAndPaste.C
src/CutAndPaste.h
src/text3.C

index a975b66378f2773f20c1b58f6e67f7d95b416022..e561f591c35b04bd82701c1ec4c5e10440c675dd 100644 (file)
@@ -559,6 +559,12 @@ void copySelection(LCursor & cur)
        // stuff the selection onto the X clipboard, from an explicit copy request
        theClipboard().put(cur.selectionAsString(true));
 
+       copySelectionToStack(cur);
+}
+
+
+void copySelectionToStack(LCursor & cur)
+{
        // this doesn't make sense, if there is no selection
        if (!cur.selection())
                return;
index 6d9aa935f389f5c8b8cc8e5c6fe790be18bc139d..2baaeb2ae8c88a6fef2423ccafaab52a1e05d3f1 100644 (file)
@@ -62,6 +62,8 @@ void replaceSelection(LCursor & cur);
 void cutSelection(LCursor & cur, bool doclear = true, bool realcut = true);
 /// Push the current selection to the cut buffer and the system clipboard.
 void copySelection(LCursor & cur);
+/// Push the current selection to the cut buffer.
+void copySelectionToStack(LCursor & cur);
 /// Paste the sel_index-th element of the cut buffer.
 /// Does handle undo. Does only work in text, not mathed.
 void pasteSelection(LCursor & cur, ErrorList &, size_t sel_index = 0);
index 1fdc5b736e075f8e2c59078cbb66d1e5372403ca..038354ea049d3222a27e7d0b14badf02c0072a17 100644 (file)
@@ -961,7 +961,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;
                }