Georg Baum wrote:
Am Mittwoch, 3. Januar 2007 16:06 schrieb Abdelrazak Younes:
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.
OK, I understand now but this looked weird (and still does). Maybe we
should think of adding an int argument() to the LFUN for internal
purpose. Wasn't that the purpose of the "any" branch that Lars was
talking about?
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?
IIRC an empty argument means "paste most recent clipboard (internal or
external)", doesn't it? If yes, I agree that it should stay empty.
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.
Here is what I think we should like to have:
if argument is
1) empty: "paste most recent clipboard (internal or external)"
2) "n": paste n-th element from the theCuts clipboard stack (n == 0 is
the most recent element).
3) "external clipboard line": paste external clipboard as lines
4) "external clipboard paragraph": paste external clipboard as paragraph.
5) "selection": paste selection (the internal/external detection should
be automatic here).
6) "selection line": paste selection as lines (the source will be
theSelection() independently from the internal or external state.)
7) "selection paragraph": paste selection as paragraph (the source will
be theSelection() independently from the internal or external state.)
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.
In the most common case (theClipboard().isInternal()), I reckon it won't
be very expensive.
Abdel.