[comp.windows.open-look] A Unified Theory of Cut and Paste

dowding@ai.sri.com (John Dowding) (03/30/91)

I am using OpenWindows 2.0, and a variety of applications: cmdtools,
xterms, xmh, gnuemacs, calentool, plus many of the desk top tools that
come with Openwindows.  Is there a simple way to be able to cut and
paste across all these different application types?

Thanks,

John Dowding
dowding@ai.sri.com

kevin@ttidca.TTI.COM (Kevin Carothers) (04/03/91)

In article <DOWDING.91Mar29112851@palm.ai.sri.com> dowding@ai.sri.com (John Dowding) writes:
%
%I am using OpenWindows 2.0, and a variety of applications: cmdtools,
%xterms, xmh, gnuemacs, calentool, plus many of the desk top tools that
%come with Openwindows.  Is there a simple way to be able to cut and
%paste across all these different application types?

 I may be wrong, but I believe the answer is no.
 Xterm & Emacs utilize different selection property atoms  (XA_PRIMARY, etc)
 than calentool/cmdtool/shelltool clients (XV_DO_DRAG_LOAD, XV_DO_DRAG_COPY).

 Selection algorithms are (unfortunately)  pretty different between X11 &
 OpenWin. At least they look pretty different to me after running xscope
 across a variety of clients.

--
Kevin Carothers   {csun,psivax,philabs,retix}!ttidca!kevin

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

In article <DOWDING.91Mar29112851@palm.ai.sri.com> dowding@ai.sri.com (John Dowding) writes:

>I am using OpenWindows 2.0, and a variety of applications: cmdtools,
>xterms, xmh, gnuemacs, calentool, plus many of the desk top tools that
>come with Openwindows.  Is there a simple way to be able to cut and
>paste across all these different application types?

If you put this in your .Xdefaults, then by pressing a button in
xcutsel you can slam the CLIPBOARD into CUT_BUFFER0, or vice versa.
This is as "simple" a way I can find to cut and paste across
gnuemacs, Xaw-, and XView- based applications.

! Here's the deal.  Emacs only uses CUT_BUFFER0, xterm uses PRIMARY by
! default, and OpenWindows uses CLIPBOARD.  My solution is to have
! xterm cave in to the OpenWindows world by preferring CLIPBOARD
! whenever it is deciding what to insert, except I nod to Emacs by
! having middle click first try to insert not CLIPBOARD but
! CUT_BUFFER0. That way, Emacs-style pasting is always done with a
! middle click, and OpenWindows-style pasting is always done with the
! Paste button (L8). I convert between Emacs and OpenWindows by running
! xcutsel -selection CLIPBOARD.
!
! select-end():		order of arguments is insignificant
! insert-selection():	order of arguments is significant
!
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\
	<Key>L6:		start-extend() select-end(CLIPBOARD, CUT_BUFFER0, PRIMARY)
--
Brian Holtz

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

> I may be wrong, but I believe the answer is no.
> Xterm & Emacs utilize different selection property atoms  (XA_PRIMARY, etc)
> than calentool/cmdtool/shelltool clients (XV_DO_DRAG_LOAD, XV_DO_DRAG_COPY).
>
> Selection algorithms are (unfortunately)  pretty different between X11 &
> OpenWin.

You mean "selection algorithms are (unfortunately) pretty different
between various different X11 toolkits and applications"; it's not a
question of differences between "X11" and "OpenWin", because there's no
single convention that can be considered the "X11" convention.  As
another poster noted, some applications/toolkits use PRIMARY, some use
CLIPBOARD, some use CUT_BUFFER0 (or other cut buffers), and some (e.g. 
ATK) make a valiant effort to use several of 'em.... 

The XView text facility (atop which "textedit" and "cmdtool" are based)
uses, among other things, CLIPBOARD; the *_DRAG_* stuff is presumably
for drag'n'drop, but they most definitely are not the *only* selections
XView deals with.  Now, the XView selection stuff tends to require that
the selection owner support the LENGTH target, so if it doesn't support
it, you may have trouble pasting from it into XView applications; I
think Xt-based toolkits tend to support LENGTH, but ATK didn't do so
until I fixed it to do so in order to let you cut'n'paste between ATK
and XView....