andy@comp.lancs.ac.uk (Andy Colebourne) (03/22/91)
Xmless is a file viewer for X-Windows that needs Motif 1.1. It can be used in conjunction with Xbrowser or on it's own because it's lovely!!! TTFN Andy -------------------------cut here--------------------------------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # README # COPYRIGHT # Makefile # xmless.1 # xmless.c # This archive created: Fri Mar 22 13:49:40 1991 export PATH; PATH=/bin:$PATH if test -f 'README' then echo shar: will not over-write existing file "'README'" else sed 's/^X//' << \SHAR_EOF > 'README' XHello! I'm Xmless. Compile me with Motif 1.1. XThen use me for viewing files or standard-input. X XOoh! SHAR_EOF chmod +x 'README' fi # end of overwriting check if test -f 'COPYRIGHT' then echo shar: will not over-write existing file "'COPYRIGHT'" else sed 's/^X//' << \SHAR_EOF > 'COPYRIGHT' XCopyright (c) 1991 Andy Colebourne and the University of Lancaster X XPermission to use, copy, modify, distribute, and sell this software Xand its documentation for any purpose is hereby granted without fee, Xprovided that the above copyright notice appear in all copies and that Xboth that copyright notice and this permission notice appear in Xsupporting documentation, and that the names of Andy Colebourne and Xthe University of Lancaster not be used in advertising or publicity Xpertaining to distribution of the software without specific, written prior Xpermission. Andy Colebourne and the University of Lancaster make no Xrepresentations about the suitability of this software for any purpose. XIt is provided "as is" without express or implied warranty. X XAndy Colebourne and the University of Lancaster DISCLAIMS ALL WARRANTIES XWITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF XMERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Andy Colebourne and the XUniversity of Lancaster BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL XDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR XPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS XACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF XTHIS SOFTWARE. SHAR_EOF chmod +x 'COPYRIGHT' fi # end of overwriting check if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' XLIBS = -lXm -lXt -lX11 X Xxmless: xmless.c X cc -D_NO_PROTO -o xmless xmless.c $(LIBS) X SHAR_EOF chmod +x 'Makefile' fi # end of overwriting check if test -f 'xmless.1' then echo shar: will not over-write existing file "'xmless.1'" else sed 's/^X//' << \SHAR_EOF > 'xmless.1' X.TH xmless 1 "22 March 1991" X.SH NAME Xxmless \- X11 file viewer X.SH SYNOPSIS X.B xmless [filename ...] X.LP X X.SH DESCRIPTION X Xxmless is similar to X.I more; Xit displays the contents of files in a window. It can also Xdisplay text read from standard input, and thus may be used Xat the end of a pipeline. The window is not opened until Xthe whole file has been read. X XA separate window is opened for each filename supplied. Note Xthat standard input is only read if no filenames are given. To Xdisplay standard input alongside other files, include '-' as a Xparameter. X X.SH SEE ALSO X.nf Xxless(1) Xmore(1) X.fi X X.SH BUGS XMail andy@uk.ac.lancs.comp if you find any. X X X.SH AUTHORS XAndy Colebourne and Andrew Brooks X SHAR_EOF fi # end of overwriting check if test -f 'xmless.c' then echo shar: will not over-write existing file "'xmless.c'" else sed 's/^X//' << \SHAR_EOF > 'xmless.c' X/** xmless by Andy Colebourne and Andrew Brooks **/ X X X#include <stdio.h> X#include <stdlib.h> X#include <X11/Intrinsic.h> X#include <X11/Xlib.h> X#include <X11/X.h> X#include <Xm/Xm.h> X#include <Xm/Label.h> X#include <Xm/RowColumn.h> X#include <Xm/Text.h> X#include <Xm/List.h> X#include <Xm/PushB.h> X#include <Xm/Form.h> X X X#include <stdio.h> X#include <sys/file.h> X X XString fallback_resources[] = { X "*textwindow.rows: 24", X "*textwindow.columns: 80", X NULL, X}; X X XWidget toplevel; Xint popups; X X Xvoid killpop(w, c1, c2) XWidget w; X{ X XtUnmanageChild(w); X XtDestroyWidget(w); X popups--; X if (popups == 0) X exit(0); X} X Xstatic XtCallbackRec call_kill[] = { {(XtCallbackProc)killpop, (caddr_t)NULL}, X { (XtCallbackProc)NULL, (caddr_t)NULL} }; X X Xmain(argc,argv) Xint argc; Xchar* argv[]; X{ Xchar** arg = argv; XFILE* fp; XXtAppContext app_con; X X toplevel = XtAppInitialize(&app_con, "Xbrowser", NULL, 0, X &argc, argv, fallback_resources, NULL, 0); X popups = 0; X X if (argc==1) X dostdin(stdin); X else X { X while (argc--!=1) X { X if (!strcmp(*++arg,"-")) X dostdin(stdin); X else X { X fp=fopen(*arg,"r"); X if (fp==NULL) X { X fprintf(stderr,"%s: cannot open %s\n",argv[0],*arg); X continue; X } X dofile(fp, *arg, *arg); X fclose(fp); X } X } X } X X if (popups != 0 ) X XtAppMainLoop(app_con); X X} X Xdostdin(fp) XFILE* fp; X{ X char c; X char *name=tmpnam(NULL); X FILE *temp=fopen(name,"w"); X X while ((c=getc(fp))!=EOF) X putc(c, temp); X fclose(temp); X temp=fopen(name,"r"); X dofile(temp, name, "stdin"); X remove(name); X X} X Xvoid view_window(str, title) Xchar *str; Xchar *title; X{ XWidget pop, textwindow, outer; XArg al[10]; Xint ac; X X ac = 0; X XtSetArg(al[ac], XmNunmapCallback, call_kill); ac++; X X XtSetArg(al[ac], XmNokLabelString, XmStringCreateLtoR("Close", XmSTRING_DEFAULT_CHARSET) ); ac++; X pop = XmCreatePromptDialog(toplevel, "textpopup", al, ac); X outer = XtParent(pop); X X XtUnmanageChild(XmSelectionBoxGetChild(pop, XmDIALOG_SELECTION_LABEL) ); X XtUnmanageChild(XmSelectionBoxGetChild(pop, XmDIALOG_TEXT ) ); X XtUnmanageChild(XmSelectionBoxGetChild(pop, XmDIALOG_SEPARATOR ) ); X XtUnmanageChild(XmSelectionBoxGetChild(pop, XmDIALOG_APPLY_BUTTON) ); X XtUnmanageChild(XmSelectionBoxGetChild(pop, XmDIALOG_CANCEL_BUTTON) ); X XtUnmanageChild(XmSelectionBoxGetChild(pop, XmDIALOG_HELP_BUTTON) ); X X ac = 0; X XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; X XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; X XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++; X XtSetArg(al[ac], XmNscrollLeftSide, TRUE); ac++; X textwindow = XmCreateScrolledText(pop, "textwindow", al, ac); X XtManageChild(textwindow); X X ac = 0; X X XtSetArg (al[ac], XmNtitle, title); ac++; X XtSetValues(outer, al, ac); X X X ac = 0; X XtSetArg(al[ac], XmNdefaultPosition, FALSE); ac++; X XtSetValues(XtParent(textwindow), al, ac); X X if (str != NULL) X XmTextSetString(textwindow, str); X X XtManageChild(pop); X popups++; X} X X Xdofile(fp, name, title) XFILE* fp; Xchar *name; Xchar *title; X{ Xstruct stat buf; Xchar *string; Xint len; X X stat(name, &buf); X len = buf.st_size; X string = (char *)XtMalloc(len+1); X fread(string, sizeof(char), len, fp); X string[len]='\0'; X view_window(string, title); X XtFree(string); X} X SHAR_EOF fi # end of overwriting check # End of shell archive exit 0