🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #23946

Re: xterm Cut Buffer

#23946
From: Mark Martin
Date: Fri, 21 Jun 1991 12:44
46 lines
2171 bytes
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
Technical Details
Message-ID: <1991Jun21.124411.44@cetia.fr>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!mcsun!corton!gouldfr!vogon!cetia!cetia1!mmm

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!mcsun!corton!gouldfr!vogon!cetia!cetia1!mmm
From: mmm@cetia1.cetia.fr (Mark Martin)
Newsgroups: comp.windows.x
Subject: Re: xterm Cut Buffer
Message-ID: <1991Jun21.124411.44@cetia.fr>
Date: 21 Jun 91 12:44:11 GMT
Sender: news@cetia.fr (News Manager)
Organization: CETIA, France
Lines: 46