[comp.windows.x] Xview and cut & paste

brossard@SASUN1.EPFL.CH ("", Alain Brossard EPFL-SIC/SII) (10/23/90)

	I'm having mucho problems with the interactions between the
Athena Widgets and the xview programs when it relates to cut & paste.
The Xaw, uses the primary selection: the left mouse button selects
and the selection is put in the primary buffer.
	But what do the xview programs use?  Their select has
the same behavior so going from xview -> Xaw is easy.  But where
do the selections go when you press "Copy" or "Cut"?  Following
the suggestion from Ridge McGhee, I tried using xcutsel.  Without
more informations than this I succeeded in pasting text from
Xaw -> xview by: using one xcutsel to copy the PRIMARY to buffer0
and one xcutsel to copy from buffer0 to the SECONDARY and then
paste to the xview application with the "paste" key.
	BUT it only works for ONE paste, doing two in a row
with "mail" in the buffer gives: "mail^@^@^@^D" (Sparring you
from the actual control characters).  From now on, cut and paste
within that xview application will never work!  It will always paste
"^@^@^@^D".  There is definite correlation between the length
of the strings.  Starting a new xview applications (eg: mailtool)
has no effect.  One more piece of information is that the
"copy 0 to SECONDARY" button of xcutsel stays activated during
this time (it stays the owner).  Doing a further use of
xcutsel works so now I have the following working:
	Xview -> Xaw
	Xaw -> Xview
but not Xview -> Xview !!!

      	So how to I make Xaw and Xview talk to each other?
Anybody from Sun cares to comment?  I don't think it is a
good reflection on the product if it doesn't talk to the
rest of the world and even worse I haven't found any
documentation on this particular problem.

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

kasso@eng.sun.COM (Chris Kasso) (10/24/90)

  From:  "(Alain Brossard EPFL-SIC/SII)" <brossard@sasun1.epfl.ch>
  Date:  Tue, 23 Oct 90 09:34:54 PDT

  	I'm having mucho problems with the interactions between the
  Athena Widgets and the xview programs when it relates to cut & paste.
  The Xaw, uses the primary selection: the left mouse button selects
  and the selection is put in the primary buffer.
  	But what do the xview programs use?  Their select has
  the same behavior so going from xview -> Xaw is easy.  But where
  do the selections go when you press "Copy" or "Cut"? 

XView follows a model similar to SunView.  Any text that is highlighted
belongs to the PRIMARY selection.  Pressing the ``Copy'' or ``Cut'' keys
[Meta-c and Meta-x if you don't have a Sun keyboard] will result in the
acquisition of the CLIPBOARD selection.   The contents of the current
selection will be placed on the CLIPBOARD selection or shelf as it was
once known.  Pressing the ``Paste'' key [Meta-v] will result in XView
asking for the contents of the CLIPBOARD selection from the current owner,
including SunView applications if you are running under OpenWindows.

The miscommunications between XView and Xaw apps results from the fact that
XView has no mechanism to ask for the contents of the PRIMARY selection
and Xaw apps, by default, do not know how to ask for the contents of the
CLIPBOARD selection.

To remedy this, you can make Xaw apps aware of the CLIPBOARD selection
by adding the following translations to a resource file:

*VT100.Translations: #override \
   <Key>L6:	start-extend() select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)\n\
   <Key>L8:	insert-selection(CLIPBOARD) \n\
   <Btn3Up>:	select-end(CLIPBOARD) \n\
   <Btn2Up>:	insert-selection(PRIMARY,CLIPBOARD) \n\
   <Btn2Down>:	ignore()

This allows you to use the Copy key to assert ownership of the CLIPBOARD
selection and the Paste key to access the contents of the CLIPBOARD selection.
Or, alternatively, use a mouse button 3 up event as a trigger to acquire
the CLIPBOARD selection and button 2 up to access the contents of the
CLIPBOARD if there currently is not a PRIMARY selection.

One other possibility is to use xclipboard to move the selections from
XView <=-=> Xaw.

For more information on the use of the CLIPBOARD selection, refer to
section 2.6.1.3 of the ICCCM.

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

Chris Kasso				ARPA: kasso@sun.COM
Window Systems Group			UUCP: ...!sun!kasso
Sun Microsystems, Inc.