Am Mittwoch, 3. Januar 2007 16:06 schrieb Abdelrazak Younes:
> Georg Baum wrote:
> > 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.
"0" is no dummy string. As I explained in an earlier mail the lfun,
paste n
pastes the internal cut buffer n. Right now, a missing n is equivalent to
an n of 0. This is not the case anymore after this patch (because a simple
paste may paste from the external clipboard), therefore the only thing
that this "0" ensures is that the same code is executed as before.
I do not want to introduce an additional argument of LFUN_PASTE on purpose.
I want a simple LFUN_PASTE without argument use the most recent clipboard.
If I would use an additional argument, to what lfun would you want to bind
C-v?
> > 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?
See above. I added this FIXME because I really don't know what to do here.
If we want to be fully correct we would need to do something like this:
if (cmd.argument().empty()) {
if (theClipboard().isInternal())
enable = cap::numberOfSelections() > 0;
else
enable = !theClipboard().empty();
} else if (isStrUnsignedInt(to_utf8(cmd.argument()))) {
int const n = convert<unsigned int>(to_utf8(cmd.argument()));
enable = cap::numberOfSelections() > n;
} else
enable = false;
That might be expensive, therefore I did not do that.
Georg