[comp.windows.open-look] Cut and Paste under OpenWindows

lwv27@CAS.BITNET (Larry W. Virden ext. 2487) (04/23/91)

Can someone provide me with a layman's explanation concerning cut
and pasting of text under OpenWindows?  We have folks trying to cut
and paste between XView, Xol and Xt based applications 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.
--
Larry W. Virden                 UUCP: osu-cis!chemabs!lwv27
Same Mbox: BITNET: lwv27@cas    INET: lwv27%cas.BITNET@CUNYVM.CUNY.Edu
Personal: 674 Falls Place,   Reynoldsburg,OH 43068-1614
America Online: lvirden

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.... 

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 					   -
--------------------------------------------------------------------