From 594a589bc46be12e99c20fa7be65e713c3fabb24 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Fri, 5 Jan 2007 14:40:49 +0000 Subject: [PATCH] Fix and document middle mouse button paste. This is probably the last of 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 | 6 ++++++ src/CutAndPaste.h | 2 ++ src/text3.C | 9 ++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index a975b66378..e561f591c3 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -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; diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index 6d9aa935f3..2baaeb2ae8 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -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); diff --git a/src/text3.C b/src/text3.C index 1fdc5b736e..038354ea04 100644 --- a/src/text3.C +++ b/src/text3.C @@ -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; } -- 2.39.2