Favicon

Pasting over a selection

If you make a selection and paste something, the selection will be
replaced in case of normal paste, but the selection will be retained in
the case of paste special (clipboard-paste). 

Does anyone know why there is the cur.clearSelection() in the code below
instead of cap::replaceSelection(cur) as for LFUN_PASTE ?

Text3.cpp <at> 1072--1077:

case LFUN_CLIPBOARD_PASTE:
  cur.clearSelection();
  pasteClipboardText(cur, bv->buffer().errorList("Paste"),
    cmd.argument() == "paragraph");
    bv->buffer().errors("Paste");
  break;

Vincent

Richard heck | 6 Oct 03:19
Favicon
Gravatar

Re: Pasting over a selection

Vincent van Ravesteijn wrote:
> If you make a selection and paste something, the selection will be
> replaced in case of normal paste, but the selection will be retained in
> the case of paste special (clipboard-paste). 
>
> Does anyone know why there is the cur.clearSelection() in the code below
> instead of cap::replaceSelection(cur) as for LFUN_PASTE ?
>
> Text3.cpp <at> 1072--1077:
>
> case LFUN_CLIPBOARD_PASTE:
>   cur.clearSelection();
>   pasteClipboardText(cur, bv->buffer().errorList("Paste"),
>     cmd.argument() == "paragraph");
>     bv->buffer().errors("Paste");
>   break;
>
>   
I rather doubt there is anything more than an historical reason for this.

The longer you work on LyX, the more such things you will find....

rh

Abdelrazak Younes | 6 Oct 08:49
Favicon

Re: Pasting over a selection

On 06/10/2008 00:40, Vincent van Ravesteijn wrote:
> If you make a selection and paste something, the selection will be
> replaced in case of normal paste, but the selection will be retained in
> the case of paste special (clipboard-paste).
>
> Does anyone know why there is the cur.clearSelection() in the code below
> instead of cap::replaceSelection(cur) as for LFUN_PASTE ?
>    

Beware that cap::replaceSelection() may have some X11 selection related 
code.

> Text3.cpp <at> 1072--1077:
>
> case LFUN_CLIPBOARD_PASTE:
>    cur.clearSelection();
>    

Just replace the above line with cur.cutSelection() IMO.

Abdel.

Favicon

Re: Pasting over a selection

Le 6 oct. 08 à 08:49, Abdelrazak Younes a écrit :
>> Does anyone know why there is the cur.clearSelection() in the code  
>> below
>> instead of cap::replaceSelection(cur) as for LFUN_PASTE ?

I think there is no valid reason.

> Beware that cap::replaceSelection() may have some X11 selection  
> related code.

Huh?

void replaceSelection(Cursor & cur)
{
	if (cur.selection())
		cutSelection(cur, true, false);
}

> Just replace the above line with cur.cutSelection() IMO.

This is a good recipe for clobbering the cut stack unexpectedly.

JMarc
Abdelrazak Younes | 6 Oct 12:59
Favicon

Re: Pasting over a selection

On 06/10/2008 09:08, Jean-Marc Lasgouttes wrote:
> Le 6 oct. 08 à 08:49, Abdelrazak Younes a écrit :
>>> Does anyone know why there is the cur.clearSelection() in the code 
>>> below
>>> instead of cap::replaceSelection(cur) as for LFUN_PASTE ?
>
> I think there is no valid reason.
>
>> Beware that cap::replaceSelection() may have some X11 selection 
>> related code.
>
> Huh?
>
> void replaceSelection(Cursor & cur)
> {
>     if (cur.selection())
>         cutSelection(cur, true, false);
> }

I did not checked, hence the conditional :-)

Why not create a Cursor::replaceSelection() instead?

Abdel.

Favicon

Re: Pasting over a selection

Abdelrazak Younes <younes@...> writes:
> I did not checked, hence the conditional :-)
>
> Why not create a Cursor::replaceSelection() instead?

I really think that changing replaceSelection(cur) to
cur.replaceSelection() (one more character, BTW) is not a useful task.
Cursor is already much too fat. 

JMarc

Abdelrazak Younes | 6 Oct 15:21
Favicon

Re: Pasting over a selection

On 06/10/2008 14:18, Jean-Marc Lasgouttes wrote:
> Abdelrazak Younes<younes@...>  writes:
>    
>> I did not checked, hence the conditional :-)
>>
>> Why not create a Cursor::replaceSelection() instead?
>>      
>
> I really think that changing replaceSelection(cur) to
> cur.replaceSelection() (one more character, BTW) is not a useful task.
> Cursor is already much too fat.
>    
This can of method is fat free, 100% light, 100% discoverable
  :-)

But you're right that this is not the right time for this kind of cleanup.

Abdel.

Abdelrazak Younes | 6 Oct 15:27
Favicon

Re: Pasting over a selection

On 06/10/2008 15:21, Abdelrazak Younes wrote:
> On 06/10/2008 14:18, Jean-Marc Lasgouttes wrote:
>> Abdelrazak Younes<younes@...>  writes:
>>> I did not checked, hence the conditional :-)
>>>
>>> Why not create a Cursor::replaceSelection() instead?
>>
>> I really think that changing replaceSelection(cur) to
>> cur.replaceSelection() (one more character, BTW) is not a useful task.
>> Cursor is already much too fat.
> This can of method is fat free

err... I meant 'This _kind_ of method...

> , 100% light, 100% discoverable
>  :-)
>
> But you're right that this is not the right time for this kind of 
> cleanup.
>
> Abdel.
>
>
>

Favicon

RE: Pasting over a selection


>Abdelrazak Younes <younes@...> writes:
>> I did not checked, hence the conditional :-)
>>
>> Why not create a Cursor::replaceSelection() instead?
>
>I really think that changing replaceSelection(cur) to
>cur.replaceSelection() (one more character, BTW) is not a 
>useful task.

>Cursor is already much too fat. 

Indeed, I'm really eager to clean the Cursor, DocIterator and
CursorSlice classes as most methods don't have any functionality besides
relaying. There must be some really fancy design model. 

Next, I'd like to ask whether there are taboos ("heilige huisjes") wrt
to the following issues:

- Pasting text from outside LyX is defaulted to "Paste, Join Lines"
(which would not be my first choice),

- "Paste, Join Lines" doesn't work when copy-pasting within LyX,

- What is "Paste, Plain Text" supposed to do ? Should it dissolve Insets
in your selection ? Should it remove any font modifiers ?

PS. I didn't look in the code to find the answers.

>Jmarc
(Continue reading)

Andre Poenitz | 6 Oct 19:55

Re: Pasting over a selection

On Mon, Oct 06, 2008 at 03:29:05PM +0200, Vincent van Ravesteijn - TNW wrote:
>  
> >Abdelrazak Younes <younes@...> writes:
> >> I did not checked, hence the conditional :-)
> >>
> >> Why not create a Cursor::replaceSelection() instead?
> >
> >I really think that changing replaceSelection(cur) to
> >cur.replaceSelection() (one more character, BTW) is not a 
> >useful task.
> 
> >Cursor is already much too fat. 
> 
> Indeed, I'm really eager to clean the Cursor, DocIterator and
> CursorSlice classes as most methods don't have any functionality besides
> relaying. There must be some really fancy design model. 

'Design' in this case is spelled 'Fighting History'.

There was a time when the cursor was slice-by-slice part of the 
corresponding LyXText. Big fun, especially within math where there
is no LyXText and never has been.

It might be hard to imagine, but things can be way worse than what we
have now. There was, e.g., no way to iterate though a document.

Having said that, it was clear from the beginning of the standalone
cursor is too fat. There was a certain hope that parts get back into the
insets, which, in a few cases even came true.

(Continue reading)


Gmane