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();
+ else {
+ istringstream is(to_utf8(cmd.argument()));
+ int n = 0;
+ is >> n;
+ topaste = cap::getSelection(cur.buffer(), n);
+ }
InsetMathGrid grid(1, 1);
- mathed_parse_normal(grid, cap::getSelection(cur.buffer(), n));
+ if (!topaste.empty())
+ mathed_parse_normal(grid, topaste);
+
if (grid.nargs() == 1) {
// single cell/part of cell
recordUndo(cur);
Index: src/mathed/InsetMathNest.C
===================================================================
--- src/mathed/InsetMathNest.C (Revision 16479)
+++ src/mathed/InsetMathNest.C (Arbeitskopie)
@@ -50,6 +50,7 @@
#include "support/lstrings.h"
+#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
#include "frontends/Selection.h"
@@ -437,11 +438,16 @@ void InsetMathNest::doDispatch(LCursor &
recordUndo(cur);
cur.message(_("Paste"));
replaceSelection(cur);
- size_t n = 0;
- istringstream is(to_utf8(cmd.argument()));
- is >> n;
- docstring const selection = cap::getSelection(cur.buffer(), n);
- cur.niceInsert(selection);
+ docstring topaste;
+ if (cmd.argument().empty() && !theClipboard().isInternal())
+ topaste = theClipboard().get();
+ else {
+ size_t n = 0;
+ istringstream is(to_utf8(cmd.argument()));
+ is >> n;
+ topaste = cap::getSelection(cur.buffer(), n);
+ }
+ cur.niceInsert(topaste);
cur.clearSelection(); // bug 393
cur.bv().switchKeyMap();
finishUndo();
Index: src/CutAndPaste.C
===================================================================
--- src/CutAndPaste.C (Revision 16479)
+++ src/CutAndPaste.C (Arbeitskopie)
@@ -74,7 +74,7 @@ CutStack theCuts(10);
// store whether the tabular stack is newer than the normal copy stack
// FIXME: this is a workaround for bug 1919. Should be removed for 1.5,
// when we (hopefully) have a one-for-all paste mechanism.
-bool dirty_tabular_stack_;
+bool dirty_tabular_stack_ = false;
void region(CursorSlice const & i1, CursorSlice const & i2,
Index: src/text3.C
===================================================================
--- src/text3.C (Revision 16479)
+++ src/text3.C (Arbeitskopie)
@@ -267,7 +267,7 @@ bool doInsertInset(LCursor & cur, LyXTex
inset->edit(cur, true);
if (gotsel && pastesel) {
- lyx::dispatch(FuncRequest(LFUN_PASTE));
+ lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));
// reset first par to default
if (cur.lastpit() != 0 || cur.lastpos() != 0) {
LyXLayout_ptr const layout =
@@ -756,12 +756,14 @@ void LyXText::dispatch(LCursor & cur, Fu
case LFUN_PASTE:
cur.message(_("Paste"));
cap::replaceSelection(cur);
- if (isStrUnsignedInt(to_utf8(cmd.argument())))
+ if (cmd.argument().empty() && !theClipboard().isInternal())
+ pasteString(cur, theClipboard().get(), docstring());
+ else if (isStrUnsignedInt(to_utf8(cmd.argument())))
pasteSelection(cur, bv->buffer()->errorList("Paste"),
- convert<unsigned int>(to_utf8(cmd.argument())));
+ convert<unsigned int>(to_utf8(cmd.argument())));
else
pasteSelection(cur, bv->buffer()->errorList("Paste"),
- 0);
+ 0);
bv->buffer()->errors("Paste");
cur.clearSelection(); // bug 393
bv->switchKeyMap();
@@ -968,7 +970,7 @@ void LyXText::dispatch(LCursor & cur, Fu
// insert this
if (cmd.button() == mouse_button::button2) {
if (paste_internally)
- lyx::dispatch(FuncRequest(LFUN_PASTE));
+ lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));
else
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
}
@@ -1721,7 +1723,9 @@ bool LyXText::getStatus(LCursor & cur, F
break;
case LFUN_PASTE:
- enable = cap::numberOfSelections() > 0;
+ // FIXME: Should we evaluate cmd.argument() here?
+ enable = cap::numberOfSelections() > 0 ||
+ !theClipboard().isInternal();
break;
case LFUN_PARAGRAPH_MOVE_UP: