Bo Peng wrote:
> If that's the case and Bo can see it, we're good (enough).

Just let you know that there is no such setting in gmail to view your
attachment as attachment.

So you do not see this attachment as attachment?

Index: CutAndPaste.cpp
===================================================================
--- CutAndPaste.cpp     (revision 18982)
+++ CutAndPaste.cpp     (working copy)
@@ -641,8 +641,10 @@
 }
 
 
-void copySelectionToStack()
+void copySelectionToStack(Cursor & cur)
 {
+       copySelectionToStack(cur, selectionBuffer);
+
        if (!selectionBuffer.empty())
                theCuts.push(selectionBuffer[0]);
 }
@@ -672,22 +674,6 @@
 
 void saveSelection(Cursor & cur)
 {
-       LYXERR(Debug::ACTION) << BOOST_CURRENT_FUNCTION << ": `"
-              << to_utf8(cur.selectionAsString(true)) << "'."
-              << endl;
-
-#if 0
-       // FIXME: The two lines below would allow middle-mouse 
-       // pasting that preserves the LyX formatting when the selection
-       // is internal. They would also allow to use the feature on
-       // Windows and Mac. In the future, we may want to optionally enable
-       // this feature via a rc setting.
-       // This is currently disabled because it eats too much resources
-       // while selecting (cf. bug 3877)
-       if (cur.selection())
-               copySelectionToStack(cur, selectionBuffer);
-#endif
-
        // tell X whether we now have a valid selection
        theSelection().haveSelection(cur.selection());
 }
Index: CutAndPaste.h
===================================================================
--- CutAndPaste.h       (revision 18982)
+++ CutAndPaste.h       (working copy)
@@ -68,7 +68,7 @@
  */
 void copySelection(Cursor & cur, docstring const & plaintext);
 /// Push the selection buffer to the cut buffer.
-void copySelectionToStack();
+void copySelectionToStack(Cursor & cur);
 /// Store the current selection in the internal selection buffer
 void saveSelection(Cursor & cur);
 /// Is a selection available in our selection buffer?
Index: insets/InsetTabular.cpp
===================================================================
--- insets/InsetTabular.cpp     (revision 18982)
+++ insets/InsetTabular.cpp     (working copy)
@@ -3193,6 +3193,14 @@
        case LFUN_MOUSE_PRESS:
                //lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() 
<< endl;
 
+               if (cmd.button() != mouse_button::button3
+                       && bvcur.selection())
+                       // Copy the current selection to the Selection buffer
+                       // so that it can be used internally. Copy it to the 
clipboard
+                       // stack too, because we want it to appear in the
+                       // "Edit->Paste recent" menu.
+                       cap::copySelectionToStack(bvcur);
+
                if (cmd.button() == mouse_button::button1
                    || (cmd.button() == mouse_button::button3
                        && (&bvcur.selBegin().inset() != this || 
!tablemode(bvcur)))) {
@@ -3205,12 +3213,9 @@
                }
 
                if (cmd.button() == mouse_button::button2) {
-                       if (cap::selection()) {
-                               // See comment in Text::dispatch why we
-                               // do this
+                       if (theSelection().empty() && cap::selection()) {
                                // FIXME This does not use paste_tabular,
                                // another reason why paste_tabular should go.
-                               cap::copySelectionToStack();
                                cmd = FuncRequest(LFUN_PASTE, "0");
                        } else {
                                cmd = FuncRequest(LFUN_PRIMARY_SELECTION_PASTE,
Index: LyXFunc.cpp
===================================================================
--- LyXFunc.cpp (revision 18982)
+++ LyXFunc.cpp (working copy)
@@ -218,6 +218,11 @@
 
 void LyXFunc::setLyXView(LyXView * lv)
 {
+       if (lyx_view_ && lyx_view_ != lv && 
lyx_view_->view()->cursor().selection())
+               // save current selection to the selection buffer to allow
+               // middle-button paste in another buffer
+               cap::copySelectionToStack(lyx_view_->view()->cursor());
+
        lyx_view_ = lv;
 }
 
@@ -1184,6 +1189,10 @@
                // --- buffers ----------------------------------------
                case LFUN_BUFFER_SWITCH:
                        BOOST_ASSERT(lyx_view_);
+                       if (lyx_view_->view()->cursor().selection())
+                   // save current selection to the selection buffer to allow
+                       // middle-button paste in another buffer
+                               
cap::copySelectionToStack(lyx_view_->view()->cursor());
                        
lyx_view_->setBuffer(theBufferList().getBuffer(argument));
                        break;
 
Index: mathed/InsetMathNest.cpp
===================================================================
--- mathed/InsetMathNest.cpp    (revision 18982)
+++ mathed/InsetMathNest.cpp    (working copy)
@@ -1154,6 +1154,15 @@
 {
        //lyxerr << "## lfunMousePress: buttons: " << cmd.button() << endl;
        BufferView & bv = cur.bv();
+       Cursor & bvcur = bv.cursor();
+       if (cmd.button() != mouse_button::button3
+               && bvcur.selection())
+               // Copy the current selection to the Selection buffer
+               // so that it can be used internally. Copy it to the clipboard
+               // stack too, because we want it to appear in the
+               // "Edit->Paste recent" menu.
+               cap::copySelectionToStack(bvcur);
+
        if (cmd.button() == mouse_button::button1) {
                //lyxerr << "## lfunMousePress: setting cursor to: " << cur << 
endl;
                bv.mouseSetCursor(cur);
@@ -1167,9 +1176,8 @@
                cur.updateFlags(Update::Decoration | Update::FitCursor | 
cur.result().update());
        } else if (cmd.button() == mouse_button::button2) {
                MathData ar;
-               if (cap::selection()) {
-                       // See comment in Text::dispatch why we do this
-                       cap::copySelectionToStack();
+               //if (cur.selection()) {
+               if (theSelection().empty() && cap::selection()) {
                        cmd = FuncRequest(LFUN_PASTE, "0");
                        doDispatch(cur, cmd);
                } else
Index: Text3.cpp
===================================================================
--- Text3.cpp   (revision 18982)
+++ Text3.cpp   (working copy)
@@ -1054,20 +1054,19 @@
                // We do this here as if the selection was inside an inset
                // it could get cleared on the unlocking of the inset so
                // we have to check this first
-               bool paste_internally = false;
-               if (cmd.button() == mouse_button::button2 && cap::selection()) {
-                       // Copy the selection buffer to the clipboard
-                       // stack, because we want it to appear in the
+               if (cmd.button() != mouse_button::button3
+                       && bv->cursor().selection())
+                       // Copy the current selection to the Selection buffer
+                       // so that it can be used internally. Copy it to the 
clipboard
+                       // stack too, because we want it to appear in the
                        // "Edit->Paste recent" menu.
-                       cap::copySelectionToStack();
-                       paste_internally = true;
-               }
+                       cap::copySelectionToStack(bv->cursor());
 
                // Insert primary selection with middle mouse
                // if there is a local selection in the current buffer,
                // insert this
                if (cmd.button() == mouse_button::button2) {
-                       if (paste_internally) {
+                       if (theSelection().empty() && cap::selection()) {
                                cap::pasteSelection(cur, 
bv->buffer()->errorList("Paste"));
                                bv->buffer()->errors("Paste");
                                cur.clearSelection(); // bug 393

Reply via email to