boyter@fstc-chville.army.mil (Maj Brian Boyter) (11/15/90)
One of the handiest features under Sunview was the ability to select text on the screen, and then print that text (in the rootmenu you had to select "Services" -> "Printing" -> "Print Selected Text"). That feature was not included in the move from Sunview to Openwindows. xlpr can be used to print the contents of the CLIPBOARD buffer. #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # made 11/14/1990 17:52 UTC by root@sg1-fstc.dodiis # Source directory /usr/share/local/src/xlpr # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 268 -rw-r--r-- Makefile # 665 -rw-r--r-- README # 1083 -rw-r--r-- copyright.h # 652 -rw-r--r-- xlpr.1 # 1163 -rw-r--r-- xlpr.c # # ============= Makefile ============== if test -f 'Makefile' -a X"$1" != X"-c"; then echo 'x - skipping Makefile (File already exists)' else echo 'x - extracting Makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'Makefile' && CFLAGS=-O BINDIR=/usr/local/bin MANDIR=/usr/local/man/man1 X all: xlpr X xlpr: xlpr.o X cc ${CFLAGS} -o xlpr xlpr.o -lXt -lX11 X clean: X rm -f *.o core xlpr X install: xlpr X install -o root -g wheel -m 755 xlpr ${BINDIR} X install -o root -g wheel -m 644 xlpr.1 ${MANDIR} SHAR_EOF chmod 0644 Makefile || echo 'restore of Makefile failed' Wc_c="`wc -c < 'Makefile'`" test 268 -eq "$Wc_c" || echo 'Makefile: original size 268, current size' "$Wc_c" fi # ============= README ============== if test -f 'README' -a X"$1" != X"-c"; then echo 'x - skipping README (File already exists)' else echo 'x - extracting README (Text)' sed 's/^X//' << 'SHAR_EOF' > 'README' && X xlpr - print contents of CLIPBOARD X This program gets the contents of the CLIPBOARD and pipes it to the printer. This was a feature under sunview which was deleted in Openwin. X To use xlpr, select the text using the left and middle mouse buttons, hit "copy" (L6 on the Sun-4 keyboard), go to another shelltool and type "xlpr". xlpr can also be added to your rootmenu. X The program has only been tested on a Sparcstation with SunOS 4.1 and Openwin 2.0. X There is a limit to the size of the CLIPBOARD you can pass with this program, but I don't know what it is. X Send all complaints to /dev/null. If you have improvements, send them to: boyter@fstc-chville.army.mil SHAR_EOF chmod 0644 README || echo 'restore of README failed' Wc_c="`wc -c < 'README'`" test 665 -eq "$Wc_c" || echo 'README: original size 665, current size' "$Wc_c" fi # ============= copyright.h ============== if test -f 'copyright.h' -a X"$1" != X"-c"; then echo 'x - skipping copyright.h (File already exists)' else echo 'x - extracting copyright.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'copyright.h' && #ifndef _COPYRIGHT_ /* X * Copyright 1990, Brian Boyter X * X * Permission to use, copy, modify, distribute, and sell this software X * and its documentation for any purpose is hereby granted without fee, X * provided that the above copyright notice appear in all copies and X * that both that copyright notice and this permission notice appear X * in supporting documentation. The author makes no representations X * about the suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN X * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS X * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE X * USE OR PERFORMANCE OF THIS SOFTWARE. X */ X static char *Copyright= "Copyright 1990 Brian Boyter"; #define _COPYRIGHT_ #endif SHAR_EOF chmod 0644 copyright.h || echo 'restore of copyright.h failed' Wc_c="`wc -c < 'copyright.h'`" test 1083 -eq "$Wc_c" || echo 'copyright.h: original size 1083, current size' "$Wc_c" fi # ============= xlpr.1 ============== if test -f 'xlpr.1' -a X"$1" != X"-c"; then echo 'x - skipping xlpr.1 (File already exists)' else echo 'x - extracting xlpr.1 (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xlpr.1' && '\\" t .TH xlpr 1 "Nov 14, 1990" .SH NAME xlpr \- print contents of the CLIPBOARD buffer .SH SYNOPSIS .B xlpr .SH DESCRIPTION .B xlpr gets the contents of the CLIPBOARD and pipes it to the printer. This was a feature under sunview which was deleted in Openwin. .PP To use xlpr, select the text using the left and middle mouse buttons, hit "copy" (L6 on the Sun-4 keyboard), go to another shelltool, and type "xlpr". xlpr can also be added to your rootmenu. .SH AUTHORS Major Brian Boyter - US Army Foreign Science and Technology Center .SH BUGS There is a limit to the size of the CLIPBOARD you can pass with this program, but I don't know what it is. SHAR_EOF chmod 0644 xlpr.1 || echo 'restore of xlpr.1 failed' Wc_c="`wc -c < 'xlpr.1'`" test 652 -eq "$Wc_c" || echo 'xlpr.1: original size 652, current size' "$Wc_c" fi # ============= xlpr.c ============== if test -f 'xlpr.c' -a X"$1" != X"-c"; then echo 'x - skipping xlpr.c (File already exists)' else echo 'x - extracting xlpr.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xlpr.c' && #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <X11/Xatom.h> #include <stdio.h> #include "copyright.h" X static Widget toplevel; X main (argc, argv) int argc; char *argv[]; { X void clipboard(); X Window window; X Arg args[10]; X int i; X X toplevel = XtInitialize(NULL, "xlpr", NULL, 0, &argc, argv); X XtSetMappedWhenManaged(toplevel, False); X X i = 0; X XtSetArg(args[i], XtNwidth, 100); i++; X XtSetArg(args[i], XtNheight, 100); i++; X XtSetValues(toplevel, args, i); X X XtRealizeWidget(toplevel); X X XtGetSelectionValue(toplevel, X XInternAtom(XtDisplay(toplevel), "CLIPBOARD", False), X XA_STRING, clipboard, NULL, CurrentTime); X X XtMainLoop(); } X void clipboard(w, client_data, selection, type, buf, length, format) Widget w; XXtPointer client_data; Atom *selection; Atom *type; XXtPointer buf; unsigned long *length; int *format; { X FILE *fp; X X if (*type == XT_CONVERT_FAIL || *length <= 0) X return; X X fp = popen("/usr/ucb/lpr", "w"); X if (fp == NULL) { X perror("xlpr: could not open pipe to /usr/ucb/lpr"); X } else { X fputs (buf, fp); X pclose(fp); X } X X XtFree (buf); X XtDestroyApplicationContext(XtWidgetToApplicationContext(toplevel)); X exit (0); } SHAR_EOF chmod 0644 xlpr.c || echo 'restore of xlpr.c failed' Wc_c="`wc -c < 'xlpr.c'`" test 1163 -eq "$Wc_c" || echo 'xlpr.c: original size 1163, current size' "$Wc_c" fi exit 0