[comp.windows.x] xterm Cut Buffer

rws@EXPO.LCS.MIT.EDU (04/28/89)

    Using the R3 xterm, when you select text to be put into the cut buffer it
    gets highlighted.  Then if you just click the cut button, without selecting
    any text, the highlighted area is unhighlighted.  This makes sense, because
    xterm is no longer the owner of the cut buffer.  Nobody owns it any more.

You are confusing selections (a protocol term) and cut buffers.  When you
select text, xterm (by default) is both asserting ownership of a selection, and
storing the text in a cut buffer.  When you de-select, it disowns the
selection, but it does not clear the cut buffer.  When you then attempt to
paste, xterm first tries for a selection (but nobody has it), and then falls
back to the cut buffer.

If you don't like this default behavior, you can change the translations
for xterm, e.g. to only deal with selections.  [I'm not sure xterm provides
a way to clear a cut buffer.]

    Instead of just
    repainting the text to be highlighted, it repaints the whole screen.

Not as far as I know.

phil@BRL.MIL (Phil Dykstra) (04/29/89)

Speaking of cut buffers, one thing I missed from SunView cut buffers
when I switched to X is that it would preserve the original newlines
in the underlying data.  I.e. if a line auto wrapped because it hit
the right margin, and you cut and pasted the multi line input, you
would not get a gratuitous newline in the middle.  This make pasting
e.g. long shell commands much easier.

As near as I can tell there is no way to tell xterm not to place newlines
in the cut buffer at the end of every screen line.  Perhaps it is a
byproduct of saving a selection in a cut buffer?  I haven't studied
the situation.  Could someone shed some light on whether this can be
done or not?

- Phil

rjshaw@ramius.llnl.gov (Robert Shaw) (06/18/91)

At the moment, to print highlighted text in an xterm, I use something like

cat > tmp  [RETURN] [click middle mouse button] [RETURN] [CTRL-D]
lpr tmp

OR 

cat | lpr  [blah blah blah.... ]

You get the idea.

Is there a better way? Say, an X client with some buttons to do different
things with the current cut buffer (print, append to a file, pipe thru an
arbitrary command, etc..) ?

What about printing very large regions, do I have to build a server with
increased internal buffer space? Is there no mechanism to transfer the 
buffer from one client to another by breaking it into multiple pieces that
the server can handle ?

Am I confused about what's really going on?

Thanx!

===============================================================================
 Rob Shaw                                              rjshaw@ocfmail.llnl.gov
===============================================================================

mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (06/18/91)

> At the moment, to print highlighted text in an xterm, I use something
> like

> cat > tmp  [RETURN] [click middle mouse button] [RETURN] [CTRL-D]
> lpr tmp
[...]
> Is there a better way?

Probably, but I don't offhand know what it is.  The reason I'm replying
is the other question....

> What about printing very large regions, do I have to build a server
> with increased internal buffer space?  Is there no mechanism to
> transfer the buffer from one client to another by breaking it into
> multiple pieces that the server can handle ?

There is such a mechanism; look up INCR properties in the ICCCM
(section 2.7.2).  They're designed specifically for transferring large
quantities of data through the selection mechanisms.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

jlee@sobeco.com (j.lee) (06/19/91)

In <9106180214.AA01964@lightning.McRCIM.McGill.EDU> mouse@lightning.mcrcim.mcgill.EDU (der Mouse) writes:

>> What about printing very large regions, do I have to build a server
>> with increased internal buffer space?  Is there no mechanism to
>> transfer the buffer from one client to another by breaking it into
>> multiple pieces that the server can handle ?

>There is such a mechanism; look up INCR properties in the ICCCM
>(section 2.7.2).  They're designed specifically for transferring large
>quantities of data through the selection mechanisms.

The original author may have been alluding to the problem with STREAMS
based ptys on some SYSV Unix versions that won't reliably accept
more than 256 bytes at a time without discarding data.  On these
systems, pasting large chunks of text into an xterm window can fail
(whereas pasting it into an emacs window will succeed -- since
emacs takes it straight for the server to the text buffer with no
pty involved).  Complain to the system vendor.  If enough of us
do, they might eventually fix it.

rjb@ipsa.reuter.com (Ron Bodkin) (06/19/91)

In article <9106180214.AA01964@lightning.McRCIM.McGill.EDU> mouse@lightning.mcrcim.mcgill.EDU (der Mouse) writes:
[an original questioners question which has expired here:]
>> At the moment, to print highlighted text in an xterm, I use something
>> like
>
>> cat > tmp  [RETURN] [click middle mouse button] [RETURN] [CTRL-D]
>> lpr tmp
>[...]
>> Is there a better way?
	Try lpr [RETURN] [click middle mouse button] [RETURN] [CTRL-D]
or if lpr complains about being fed tty input (it shouldn't) you could do
cat | lpr.
		Ron

sinkwitz@ifi.unizh.ch (Rainer Sinkwitz) (06/19/91)

In article <1991Jun19.030547.27697@ipsa.reuter.com> rjb@ipsa.reuter.com (Ron Bodkin) writes:
>In article <9106180214.AA01964@lightning.McRCIM.McGill.EDU> mouse@lightning.mcrcim.mcgill.EDU (der Mouse) writes:
>[an original questioners question which has expired here:]
>>> At the moment, to print highlighted text in an xterm, I use something
>>> like
>>
>>> cat > tmp  [RETURN] [click middle mouse button] [RETURN] [CTRL-D]
>>> lpr tmp
>>[...]
>>> Is there a better way?

The best thing I know is the xselection program. 
Only type: xselection PRIMARY | lpr

xselection is available at export.lcs.mit.edu [18.30.0.238] .

-- 

Rainer Sinkwitz            | E-mail: sinkwitz@ifi.unizh.ch
Dept. of Computer Science  |    sinkwitz%ifi.unizh.ch@relay.eu.net
University of Zuerich      |     {backbone}!mcsun!unizh!sinkwitz

datpete@daimi.aau.dk (Peter Andersen) (06/19/91)

In article <9106180214.AA01964@lightning.McRCIM.McGill.EDU> mouse@lightning.mcrcim.mcgill.EDU (der Mouse) writes:
[an original questioners question which has expired here:]
>> At the moment, to print highlighted text in an xterm, I use something
>> like
>
>> cat > tmp  [RETURN] [click middle mouse button] [RETURN] [CTRL-D]
>> lpr tmp
>[...]
>> Is there a better way?

I made the following program and uses it like this, from e.g. mu TWM menus:

   xcutbuffer | lpr

-----------

/* include files */
#include <stdio.h>              /* /usr/include/stdio.h */

/* X include files */
#include <X11/Xlib.h>		/* /usr/include/X11/Xlib.h  */

main(argc, argv)
     int argc;
     char **argv;
{
  
  /* Declarations */
  Display *dpy;           /* current display */
  int nbytes_return;
  char *bytes_return;

  
  /* Initialization */
  dpy = XOpenDisplay("");
  if ( !dpy ) {
    fprintf (stderr, "xcutbuffer: cannot establish display connection\n");
    exit(1);
  }
  
  bytes_return = XFetchBytes( dpy, &nbytes_return );
  printf("%s", bytes_return);

  /* Termination */
  XFree(bytes_return);
  XCloseDisplay ( dpy );
  exit (0);
} 


--------


Peter

rjshaw@ramius.llnl.gov (Robert Shaw) (06/20/91)

Thanx to everyone who replied (and to those who haven't yet).

My question is answered, I have settled on using the xselection client.

===============================================================================
 Rob Shaw                                              rjshaw@ocfmail.llnl.gov
===============================================================================

mmm@cetia1.cetia.fr (Mark Martin) (06/21/91)

In article <873@llnl.LLNL.GOV> rjshaw@ramius.llnl.gov (Robert Shaw) writes:
> At the moment, to print highlighted text in an xterm, I use something like
> cat | lpr  [blah blah blah.... ]
> Is there a better way?

Someone else will have surely suggested it before this gets posted, but
xselection by Richard Hesketh in contrib/xselection.tar.Z on export.lcs.mit.edu
will get and set the selection you see highlighted in an xterm.
The selection is called the PRIMARY selection, so you can say
	xselection PRIMARY | lpr

Alternatively, and a little less robustly, since xterm by default puts
the selection in the CUT_BUFFER0 too, you can use the shell script
getselection given below:
	getselection | lpr

---
Mark M Martin			mmm@cetia.fr
Cetia (BP 244),			inria!cetia!mmm
150 rue Marcelin Berthelot,	tel +33 94 08 80 00
ZI Toulon Est,			fax +33 94 08 80 01
83078 TOULON CEDEX 9, France
----
#! /bin/sh
# return selected text. Mark M Martin.
# returned format is CUT_BUFFER0 = "echo \"cetia\\\"\n"
# get the \" and \\ and \n undone.  sadly sed wont take long lines.
# sed wont read input not ending in newline, so need to chop off final newline.
# use bell as newline marker and dle as any char not in text, such as control-a
# if echo '\007' (or echo -n '\007') doesnt give you just a bell
# try bell=`echo | tr '\012' '\007'` or just get the real character in there.
# This is sytemV echo. use echo -n instead of echo '...\c' on bsd.
bell=`echo '\007\c'`	# the single character control-G
dle=`echo '\001\c'`	# the single character control-A

xprop -root -notype CUT_BUFFER0 |
sed '1s/[^=]*= "//
	s/\\\\/'"$dle"'/g
	s/\\n/'"$bell"'/g
	s/\\"/"/g
	s/'"$dle"'/\\/g
	$s/"$//' |
tr -d '\012' |
tr $bell '\012'

# end of script

gk5g+@andrew.cmu.edu (Gary Keim) (06/22/91)

Excerpts from netnews.comp.windows.x: 19-Jun-91 Latest Version of ATK
Emmett Hogan@csl.sri.com (614)

> Where can I find the latest (fully patched) version of the Andrew
> Toolkit (along with the font compiler "fc")?  And what version is the
> latest?

Patch 10 of the Andrew Toolkit (ATK) is now available.  

You can pick up a copy of the entire source tree from the file
andrew.010.tar.Z via anonymous ftp from emsworth.andrew.cmu.edu
(128.2.30.62) in the top level directory; the patch is split in the
./patches directory as patch.010aa, patch.010ab, patch.010ac and
patch.010ad. You should apply them individually, starting with aa
through ad.

Here's an overview of what's new in patch 10:

Contributed code:

        Contributed code from MIT, including transient window support
        and header & footer object
        Contributed (untested) code from SCO w/ port to SCO Unix
        Port to HP RISC machine (HP-UX 7.0), contributed by BellSouth and HP
    Improved SunOS4.x support, including contributed code to use
        SunOS4.x native dynamic loading
    Contributed code from Bell Labs including vi-style editing

New ITC work:

        Motif style menu emulation, with optional pop-up menus
        Motif style scroll bar option
        Motif style dialog box option
        Motif style buttons

Changes to existing components:

    Improved Animation object that doesn't block while animating
    Improved Adew application builder w/ ability to create true
        insets (some of the new Adew features are not yet documented;
        contact Tom Neuendorffer (tpn+@andrew.cmu.edu) for more
        information)
    Improved text scrolling code that allows partial scrolling of insets
    Improved typescript completion code
    Improved tabs support (from MIT with some modification)
    Better support for handling ~ in file names (esp. w/ AFS)
    Improved RS/6000 support, including working typescript
    Color text support, including support for setting color styles in lookz
    Improved style editor, including ability to bring up lookz in a
        separate window
    Interline/Interparagraph spacing in text (and lookz)
    Improved style model, including ability to control styles with keystrokes
    Improved hyperlink, including 2 new button styles
    Raw mode reading of files and templates
    ^U handling now in interaction manager
    AFS 3.1 support
    Support for running under Sun OpenWindows
    *Lots* of small improvements

For further information related to ATK please monitor the newsgroup
comp.soft-sys.andrew.

Gary Keim
ATK Group