[comp.windows.x] Cut and Paste under OpenWindows

guy@auspex.auspex.com (Guy Harris) (04/26/91)

>Can someone provide me with a layman's explanation concerning cut
>and pasting of text under OpenWindows?

The server, of course, doesn't give a rat's ass about cut and paste; all
it knows is window properties.  The toolkits are what implement
cut'n'paste, and you can run the (X) toolkits in question even if you
aren't running OW, so it's more of a question of "cut and pasting of
text under various X toolkits" rather than "cut and pasting of text
under OpenWindows".

>We have folks trying to cut and paste between XView, Xol and Xt based
>applications

Well, Xol-based applications are "Xt based applications"; when you say
"Xt based applications", you presumably mean "Xt-based applications
using widget set Xyzzy".  Given the use of "net-grown", I suspect many
of them are Xaw-based.

Cut'n'paste generally takes place either through various selections, or
cut buffers, as per the ICCCM.  I can't speak for Xol, but XView seems
fairly insistent on using the CLIPBOARD selection as the source of a
"paste" operation, so if you want to be able to cut something from your
application and paste it into an XView application, your application
needs to be able to own the CLIPBOARD selection. 

The Xaw text widget, or whatever "xedit" is based on, seems not to bind
anything to "copy to CLIPBOARD" by default; I stuck

	#
	# Make <Meta>W be "copy to clipboard" in Text widget.
	#
	*Text.Translations: #override \
		Meta<Key>W:	extend-end(CLIPBOARD)

into my ".Xdefaults" file in order to have a way to copy stuff to the
CLIPBOARD selection.  That let me copy from "xedit" to "textedit".

For going the other way around, I just needed to select something in
"textedit" (which meant "textedit" now owned the PRIMARY selection) and
then hit the middle mouse button or whatever the "stuff the PRIMARY
selection here" function is.  That may not work as well for a "cut"
operation from "textedit"; to make that work, you'd need to coax "xedit"
into pasting the - you guessed it - CLIPBOARD selection.  It appears, at
least from the Athena Widgets documentation I have, that the
"insert-selection" action can be used to insert the CLIPBOARD selection.

Unfortunately, I have been unable to convince the stupid "xterm" widget
(i.e., the widget internal to "xterm" that implements "xterm") that I
want to have a *keyboard* event mean "copy to clipboard", which makes it
a real pain to copy from "xterm" to an XView application.

>and who are finding that it seems impossible to define things in such a way
>that commercial, net-grown and home-grown applications all work.

For home-grown applications: if they're not XView-based, but based on
some other toolkit, make sure you can coax them into cutting/copying to,
and pasting from, the CLIPBOARD selection.

For net-grown applications: if they don't already let you coax them into
doing so, e.g. by specifying translations to the appropriate actions,
make them do so and send the changes back to the authors.

For commercial applications: if they don't let you coax them into doing
so, throw them back at the vendor with great force.

BTW, the impression I get from the Motif style guide is that Motif is
also clipboard-oriented, so: if that's the case, and if your (non-Motif,
non-XView, non-Xol) application or toolkit can't deal with the CLIPBOARD
selection, get with the program.... 

brossard@sic.epfl.ch (Alain Brossard EPFL-SIC/SII) (04/26/91)

In article <7414@auspex.auspex.com>, guy@auspex.auspex.com (Guy Harris) writes:
|> >Can someone provide me with a layman's explanation concerning cut
|> >and pasting of text under OpenWindows?
|> 
|> 	#
|> 	# Make <Meta>W be "copy to clipboard" in Text widget.
|> 	#
|> 	*Text.Translations: #override \
|> 		Meta<Key>W:	extend-end(CLIPBOARD)

 I'm using the following bindings:
*Text.translations:     #override \n\
    <KeyPress>L6: extend-start() extend-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)\n\   
    <Key>L8:    insert-selection(CLIPBOARD) \n\
    <KeyPress>L10: extend-start() extend-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)\n\
    <KeyRelease>L10:    kill-selection() \n\

 But the insert-selection only works when the text is still highlighted
(selected?).  It looks like the insert-selection only works using the
PRIMARY rather than the specified CLIPBOARD?  But L6 and L10 do work
as I'm able to paste into xview applications (like mailtool).
 
|> It appears, at
|> least from the Athena Widgets documentation I have, that the
|> "insert-selection" action can be used to insert the CLIPBOARD selection.
|> 
|> Unfortunately, I have been unable to convince the stupid "xterm" widget
|> (i.e., the widget internal to "xterm" that implements "xterm") that I
|> want to have a *keyboard* event mean "copy to clipboard", which makes it
|> a real pain to copy from "xterm" to an XView application.

 Here I have a working solution:
XTerm*VT100.Translations: \
        <Key>L6:        start-extend() select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)\n\
        <Key>L8:        insert-selection(CLIPBOARD) \n\
        <Key>L10:       start-extend() select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)\n\

  This definitely works to and from xview applications.  But as mentionned
above I have been unable to get it to work with the Xaw Text widget.

-- 

Alain Brossard, Ecole Polytechnique Federale de Lausanne,
	SIC/SII, EL-Ecublens, CH-1015 Lausanne, Suisse
brossard@sasun1.epfl.ch

devil@diablery.10A.com (Gil Tene) (04/29/91)

In article <7414@auspex.auspex.com>, guy@auspex.auspex.com (Guy Harris) writes:
> 	*Text.Translations: #override \
> 		Meta<Key>W:	extend-end(CLIPBOARD)

Thanks! I needed that one... now my rn can interact with textedit...

> Unfortunately, I have been unable to convince the stupid "xterm" widget
> (i.e., the widget internal to "xterm" that implements "xterm") that I
> want to have a *keyboard* event mean "copy to clipboard", which makes it
> a real pain to copy from "xterm" to an XView application.

Let me return the favor. I got this off the net a while back,
and don't remember the source (Thanks to whomever it was!) :

XTerm*VT100.Translations: #override \
        Shift <KeyPress> Select:        select-cursor-start()\
                                        select-cursor-end(CLIPBOARD, CUT_BUFFER0, PRIMARY)\n\
        ~Ctrl ~Meta <Btn2Up>:   insert-selection(CUT_BUFFER0, CLIPBOARD, PRIMARY)\n\
        ~Ctrl ~Meta <BtnUp>:    select-end(CLIPBOARD, CUT_BUFFER0, PRIMARY)\n\
        <Key>L8:                insert-selection(CLIPBOARD, CUT_BUFFER0, PRIMARY)\n

This works for me in an xterm. it makes the normal Xaw-style selection
in the xterm go automatically into the clipboard, so a paste in an 
Xview based app works fine with it.

Have fun,

-- Gil.
--------------------------------------------------------------------
-- Gil Tene			"Some days it just dosn't pay      -
-- devil%imp@uunet.uu.net	   to go to sleep in the morning." -
-- devil@diablery.10A.com 					   -
--------------------------------------------------------------------

guy@auspex.auspex.com (Guy Harris) (04/30/91)

>Let me return the favor. I got this off the net a while back,
>and don't remember the source (Thanks to whomever it was!) :

Comes close, but unfortunately "select-cursor-start()" sometimes seems
to change the current selection; I'm looking for something to bind to a
keyboard key that merely copies the current selection to the CLIPBOARD
selection, without modifying what's being selected in the "xterm" window.

holtz@netcord.Eng.Sun.COM (Brian Holtz) (05/01/91)

In article <7513@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
>
>I'm looking for something to bind to a
>keyboard key that merely copies the current selection to the CLIPBOARD
>selection, without modifying what's being selected in the "xterm" window.

Well, there's always xcutsel -selection CLIPBOARD...
--
Brian Holtz