Georg Baum wrote:
Am Mittwoch, 3. Januar 2007 12:44 schrieb Abdelrazak Younes:
OK, I see the logic and agree. Could you please then take the patch and modify it to implement that?

That would look like the attached, please test. And before we introduce the forth clipboard I suggest to merge the tabular and normal cut buffers ;-)


Georg


------------------------------------------------------------------------

Index: src/insets/insettabular.C
===================================================================
--- src/insets/insettabular.C   (Revision 16479)
+++ src/insets/insettabular.C   (Arbeitskopie)
@@ -174,12 +174,6 @@ string const featureAsString(LyXTabular:
 }
-bool InsetTabular::hasPasteBuffer() const
-{
-       return (paste_tabular.get() != 0);
-}
-
-
 InsetTabular::InsetTabular(Buffer const & buf, row_type rows,
                           col_type columns)
        : tabular(buf.params(), max(rows, row_type(1)),
@@ -733,7 +727,7 @@ void InsetTabular::doDispatch(LCursor & } case LFUN_PASTE:
-               if (hasPasteBuffer() && tabularStackDirty()) {
+               if (theClipboard().isInternal() && tabularStackDirty()) {
                        recordUndoInset(cur, Undo::INSERT);
                        pasteSelection(cur);
                        break;
@@ -1043,7 +1037,7 @@ bool InsetTabular::getStatus(LCursor & c
        }
case LFUN_PASTE:
-               if (tabularStackDirty()) {
+               if (theClipboard().isInternal() && tabularStackDirty()) {
                        status.enabled(true);
                        return true;
                }
Index: src/insets/insettabular.h
===================================================================
--- src/insets/insettabular.h   (Revision 16479)
+++ src/insets/insettabular.h   (Arbeitskopie)
@@ -177,8 +177,6 @@ private:
        ///
        void removeTabularRow();
        ///
-       bool hasPasteBuffer() const;
-       ///
        bool copySelection(LCursor & cur);
        ///
        bool pasteSelection(LCursor & cur);
Index: src/mathed/InsetMathGrid.C
===================================================================
--- src/mathed/InsetMathGrid.C  (Revision 16479)
+++ src/mathed/InsetMathGrid.C  (Arbeitskopie)
@@ -25,6 +25,7 @@
 #include "gettext.h"
 #include "undo.h"
+#include "frontends/Clipboard.h"
 #include "frontends/Painter.h"
#include "insets/mailinset.h"
@@ -1210,11 +1211,19 @@ void InsetMathGrid::doDispatch(LCursor &
        case LFUN_PASTE: {
                cur.message(_("Paste"));
                cap::replaceSelection(cur);
-               istringstream is(to_utf8(cmd.argument()));
-               int n = 0;
-               is >> n;
+               docstring topaste;
+               if (cmd.argument().empty() && !theClipboard().isInternal())
+                       topaste = theClipboard().get();

Please use this instead:

 +  if (cmd.argument() == "external" && !theClipboard().isInternal())

Because I think it is better to explicitly specify what you want to do in cmd.argument() instead of using dummy string "0" below.

+               if (cmd.argument().empty() && !theClipboard().isInternal())

ditto.

-               lyx::dispatch(FuncRequest(LFUN_PASTE));
+               lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));

So here that would be:
+               lyx::dispatch(FuncRequest(LFUN_PASTE));


+               if (cmd.argument().empty() && !theClipboard().isInternal())

and here:
 +              if (cmd.argument() == "external") ...

[...]
        case LFUN_PASTE:
-               enable = cap::numberOfSelections() > 0;
+               // FIXME: Should we evaluate cmd.argument() here?

What would be the purpose of the "0" argument if not?

+               enable = cap::numberOfSelections() > 0 ||
+                       !theClipboard().isInternal();
                break;
case LFUN_PARAGRAPH_MOVE_UP:

Reply via email to