From mipos3!omepd!psu-cs!reed!tektronix!uunet!seismo!sundc!pitstop!sun!amdcad!ames!necntc!ncoast!allbery Tue Feb  2 18:43:16 PST 1988
Article 274 of comp.sources.misc:
Path: td2cad!mipos3!omepd!psu-cs!reed!tektronix!uunet!seismo!sundc!pitstop!sun!amdcad!ames!necntc!ncoast!allbery
From: allbery@ncoast.UUCP (Brandon S. Allbery)
Newsgroups: comp.sources.misc
Subject: v02i035: UNIFY(r) Screens with Curses, Part 3 of 4
Message-ID: <7162@ncoast.UUCP>
Date: 31 Jan 88 04:14:08 GMT
Sender: allbery@ncoast.UUCP
Organization: Cleveland Public Access UN*X, Cleveland, Oh
Lines: 2271
Approved: allbery@ncoast.UUCP
X-Archive: comp.sources.misc/8801/33
Comp.sources.misc: Volume 2, Issue 35
Submitted-By: The Moderator <allbery@ncoast.UUCP>
Archive-Name: usc/Part3

Comp.sources.misc: Volume 2, Issue 35
Submitted-By: The Moderator <allbery@ncoast.UUCP>
Archive-Name: usc/Part3

I've received so many requests for my Unify(r) screen routines that I am
posting them.  The USC library is in four parts; unshar them and type "make".
The curses used is System V; BSDers will want to tweak the usual stuff, such
as beep() and cbreak().

I also have a simple screen program using this; if demand warrants, I will
post it -- but in terms of features, you're probably better off with ENTER.

#--------------------------------CUT HERE-------------------------------------
#! /bin/sh
#
# This is a shell archive.  Save this into a file, edit it
# and delete all lines above this comment.  Then give this
# file to sh by executing the command "sh file".  The files
# will be extracted into the current directory owned by
# you with default permissions.
#
# The files contained herein are:
#
# -r--r--r--  1 allbery users       761 Jan 30 18:01 ptct_wrt.c
# -r--r--r--  1 allbery users       710 Jan 30 18:01 ptime.c
# -r--r--r--  1 allbery users       800 Jan 30 18:01 ptube.c
# -r--r--r--  1 allbery users      6626 Jan 30 18:01 ringmenu.c
# -rw-rw-rw-  1 allbery users       152 Jan 30 18:01 ringmenu.h
# -r--r--r--  1 allbery users       769 Jan 30 18:01 setcook.c
# -r--r--r--  1 allbery users       703 Jan 30 18:01 setraw.c
# -r--r--r--  1 allbery users       583 Jan 30 18:01 setxrc.c
# -r--r--r--  1 allbery users       761 Jan 30 18:01 sfldesc.c
# -r--r--r--  1 allbery users      2483 Jan 30 18:01 shellout.c
# -rw-r--r--  1 allbery users       302 Jan 30 18:01 tester.c
# -r--r--r--  1 allbery users      2314 Jan 30 18:01 uamt.c
# -r--r--r--  1 allbery users      5459 Jan 30 18:01 udate.c
# -r--r--r--  1 allbery users       789 Jan 30 18:01 uerror.c
# -r--r--r--  1 allbery users      2267 Jan 30 18:01 uflt.c
# -r--r--r--  1 allbery users      2325 Jan 30 18:01 uhamt.c
# -r--r--r--  1 allbery users      1929 Jan 30 18:01 ulong.c
# -r--r--r--  1 allbery users      1849 Jan 30 18:01 upbuf.c
# -r--r--r--  1 allbery users      2266 Jan 30 18:01 updata.c
# -r--r--r--  1 allbery users      1252 Jan 30 18:01 upfield.c
# -r--r--r--  1 allbery users      2779 Jan 30 18:01 upscrf.c
# -r--r--r--  1 allbery users      2172 Jan 30 18:01 uptube.c
# -rw-r--r--  1 allbery users      4578 Jan 30 18:01 usc.h
# -r--r--r--  1 allbery users      2034 Jan 30 18:01 ushort.c
# -r--r--r--  1 allbery users      1339 Jan 30 18:01 ustr.c
#
echo 'x - ptct_wrt.c'
if test -f ptct_wrt.c; then echo 'shar: not overwriting ptct_wrt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ptct_wrt.c
X/*
X * $Header: ptct_wrt.c,v 1.2 87/04/29 11:31:19 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log:	ptct_wrt.c,v $
X * Revision 1.2  87/04/29  11:31:19  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT:  ptct_wrt() -- Specify whether output is to be in protected
X * mode or not
X *
X * DIFFERENCE FROM UNIFY:  All we do is check fd == 1, since curses handles the
X * screen itself.
X */
X
Xvoid ptct_wrt(fd, flg) {
X	if (fd != 1)
X		xerror(-1, "ptct_wrt", "Multi-terminal operation on fd %d not supported", fd);
X}
________This_Is_The_END________
if test `wc -l < ptct_wrt.c` -ne 31; then
	echo 'shar: ptct_wrt.c was damaged during transit (should have been 31 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ptime.c'
if test -f ptime.c; then echo 'shar: not overwriting ptime.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ptime.c
X/*
X * $Header: ptime.c,v 1.2 87/04/29 12:57:34 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log:	ptime.c,v $
X * Revision 1.2  87/04/29  12:57:34  brandon
X * DUMB!!!  Forgot to deref the buffer
X * 
X * Revision 1.1  87/04/29  12:49:31  brandon
X * Initial revision
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Display a value of type HR.
X */
X
Xvoid ptime(buf)
Xshort *buf; {
X	(void) setraw();
X	(void) attron(A_UNDERLINE);
X	(void) printw("%02d:%02d", *buf / 100, *buf % 100);
X	(void) attroff(A_UNDERLINE);
X}
________This_Is_The_END________
if test `wc -l < ptime.c` -ne 33; then
	echo 'shar: ptime.c was damaged during transit (should have been 33 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ptube.c'
if test -f ptube.c; then echo 'shar: not overwriting ptube.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ptube.c
X/*
X * $Header: ptube.c,v 1.1 87/04/29 13:37:02 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log:	ptube.c,v $
X * Revision 1.1  87/04/29  13:37:02  brandon
X * Initial revision
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT:  ptube() -- Display data from a buffer in the format of a
X * database field
X *
X * DIFFERENCE FROM UNIFY:  FLT ends up being printed with %g.  See pflt()
X * for the gory details.
X */
X
Xvoid ptube(x, y, fld, buf)
Xchar *buf; {
X	FLDESC fd;
X
X	if (!fldesc(fld, &fd))
X		xerror(-1, "ptube", "Invalid database field %d", fld);
X	outscrf(x, y, fd.f_typ, fd.f_len, buf);
X}
________This_Is_The_END________
if test `wc -l < ptube.c` -ne 35; then
	echo 'shar: ptube.c was damaged during transit (should have been 35 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ringmenu.c'
if test -f ringmenu.c; then echo 'shar: not overwriting ringmenu.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ringmenu.c
X/*
X * $Header: ringmenu.c,v 1.9 87/06/11 15:50:36 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log:	ringmenu.c,v $
X * Revision 1.9  87/06/11  15:50:36  brandon
X * Fixed page backup bug, used XRC_NOFLSH in showmenu(), misc. other fixes.
X * 
X * Revision 1.8  87/06/02  18:47:53  brandon
X * Had forgotten to force input to uppercase.
X * 
X * Revision 1.7  87/06/02  18:41:05  brandon
X * Now uses XRC_FWDGO, so pressing RETURN has a more intuitive result.
X * 
X * Revision 1.6  87/06/02  18:23:10  brandon
X * Fixed another page-number bug.
X * 
X * Revision 1.5  87/06/02  17:35:22  brandon
X * Fixed bug with `page' numbering, and added a setraw() in case it's called
X * before any other USC functions.
X * 
X * Revision 1.4  87/06/02  16:14:38  brandon
X * Fully linted.
X * 
X * Revision 1.3  87/06/02  16:02:33  brandon
X * Partially linted.
X * 
X * Revision 1.2  87/06/02  15:47:15  brandon
X * Partially linted.
X * 
X * Revision 1.1  87/06/02  15:37:27  brandon
X * Initial revision
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Ring menu manager.  You haven't seen a real ring menu yet; this one uses
X * the full capability of the key primitives (including using "view" to show
X * all the entries on the menu, one per line in a temp window), it scrolls if
X * the menu is wider than th


