]> git.lyx.org Git - lyx.git/commitdiff
Fix more of bug #5446: Enable to copy the contents of an InsetInfo through the contex...
authorVincent van Ravesteijn <vfr@lyx.org>
Mon, 19 Apr 2010 21:36:32 +0000 (21:36 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Mon, 19 Apr 2010 21:36:32 +0000 (21:36 +0000)
This introduces a new LFUN LFUN_INSET_COPY_AS, which copies a certain Inset to the clipboard. For InsetInfo this is the text that is visible, but this could also replace LFUN_LABEL_COPY_AS_REF, by copying the INSET to the clipboard as a reference, and also a Math inset to copy to the clipboard as latex (including $'s or \[..\]).

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

lib/ui/stdcontext.inc
src/FuncCode.h
src/LyXAction.cpp
src/insets/InsetInfo.cpp

index 207f992e58984afcfb9198c0d94f154f113fde2f..50486b6993902bb72944ccada3e4769e89fd17c1 100644 (file)
@@ -453,6 +453,7 @@ Menuset
        Menu "context-info"
                Submenu "Document Info|D" "buffer-info"
                Separator
+               Item "Copy Text|o" "inset-copy-as"
                Item "Settings...|S" "inset-settings info"
        End
 
index c545feea75b623bfff2cc2487fff8ae58eac0a95..6137f2a3dbc9126b46055e937ae4724d1527458f 100644 (file)
@@ -446,6 +446,7 @@ enum FuncCode
        // 345
        LFUN_PREVIEW_INSERT,            // vfr, 20100328
        LFUN_FORWARD_SEARCH,
+       LFUN_INSET_COPY_AS,             // vfr, 20100419
 
        LFUN_LASTACTION                 // end of the table
 };
index b43b426c60c98700574a4f88a0e4f46ee1c1bcac..0b7cb9296759a284b19455543deb3389e8895fa6 100644 (file)
@@ -3496,7 +3496,17 @@ void LyXAction::init()
  */
                { LFUN_BUFFER_ZOOM_OUT, "buffer-zoom-out", ReadOnly, Buffer },
 
-
+/*!
+ * \var lyx::FuncCode lyx::LFUN_INSET_COPY_AS
+ * \li Action: Copies the inset to the clipboard as a certain type
+ * \li Syntax: inset-copy-as [<TYPE>]
+ * \li Params: <TYPE>: The type as which the inset is copied. This 
+                       can vary from inset to inset.
+ * \li Sample: InsetInfo is copied as text
+ * \li Origin: vfr, 18 Apr 2010
+ * \endvar
+ */
+               { LFUN_INSET_COPY_AS, "inset-copy-as", ReadOnly | NoUpdate | AtPoint, Edit },
 
                { LFUN_NOACTION, "", Noop, Hidden }
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
index a575c8363d4b9ccac83471fd690e2b626b406a83..317a9539c8094f814b0c84c09c9af65711a9da6f 100644 (file)
@@ -14,6 +14,7 @@
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
+#include "CutAndPaste.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "InsetGraphics.h"
@@ -209,6 +210,7 @@ bool InsetInfo::getStatus(Cursor & cur, FuncRequest const & cmd,
                return InsetCollapsable::getStatus(cur, cmd, flag);
                
        case LFUN_INSET_DIALOG_UPDATE:
+       case LFUN_INSET_COPY_AS:
                flag.setEnabled(true);
                return true;
                
@@ -232,6 +234,20 @@ void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
                setInfo(to_utf8(cmd.argument()));
                break;
 
+       case LFUN_INSET_COPY_AS: {
+               cap::clearSelection();
+               Cursor copy(cur);
+               copy.pushBackward(*this);
+               copy.pit() = 0;
+               copy.pos() = 0;
+               copy.resetAnchor();
+               copy.pit() = copy.lastpit();
+               copy.pos() = copy.lastpos();
+               copy.setSelection();
+               cap::copySelection(copy);
+               break;
+       }
+
        default:
                InsetCollapsable::doDispatch(cur, cmd);
                break;