sources-request@mirror.UUCP (09/11/86)
Submitted by: seismo!rochester!ur-valhalla!badri (Badri Lokanathan) Mod.sources: Volume 7, Issue 24 Archive-name: tput I am enclosing "my version" of the system V utility tput. The shar file contains a C source file, a README, a Makefile and a man page. Since I do not have access to a system V machine I cannot vouch for compatibility. Badri Lokanathan --------------------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: # README # tput.1 # tput.c # Makefile # This archive created: Thu Aug 28 10:36:38 1986 export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'README' then echo shar: "will not over-write existing file 'README'" else cat << \SHAR_EOF > 'README' >From rochester!ur-valhalla!badri Aug 28 10:02 To: whom it may concern Subject: tput instructions This program is supposed to be equivalent to the system V utility tput, which handles screen parameters from termcap. It may take inputs in a slightly different format (basically because I wrote this program without actually having worked on the system V tput.) I suppose the man page is different too! Any suggestions/modifications are welcome. Your system is assumed to have termlib and associated functions (I wrote the program on BSD 4.2, assuming that termlib was fairly standard.) There is one include file in the program - sgtty.h which should be present. If not, I hope an equivalent exists. Other than that, the code should be fairly portable, since there isn't much to it! The make file is delibrately trivial. It does not do any installation - just compilation. make will make tput in the current directory. make man will make a man page in tput.doc. tput, written by Badri Lokanathan, is in the public domain, and may be used by any person or organization, in any way and for any purpose. There is no warranty of merchantability nor any warranty of fitness for a particular purpose nor any other warranty, either express or implied, as to the accuracy of the enclosed materials or as to their suitability for any particular purpose. Accordingly, the author assumes no respon- sibility for their use by the recipient. Further, the author assumes no obligation to furnish any assistance of any kind whatsoever, or to furnish any additional information or documentation. SHAR_EOF fi if test -f 'tput.1' then echo shar: "will not over-write existing file 'tput.1'" else cat << \SHAR_EOF > 'tput.1' .TH tput 1local "UR EE GRADUATE VLSI LAB" .SH NAME tput \- Change terminal display characteristics. .SH SYNOPSIS .B tput option [ .I "x" .I "y" ] .SH DESCRIPTION .I tput sends a sequence of characters corresponding to the operation specified in option. It is intended to emulate the system V utility tput. .PP Option is a two letter capability as specified in termcap(5). x and y are integer values for cursor movement. Typical options are given below. .SH REQUESTS .ti0 .I "Option Explanation" .ti0 .li bl Beep the terminal .ti0 .li cl Clear screen .ti0 .li mb Blink line .ti0 .li md Highlight line .ti0 .li me Restore normal mode .ti0 .li mr Reverse video line .ti0 .li se End Standout mode .ti0 .li so Begin Standout mode .ti0 .li ue End underlining mode .ti0 .li us Start underlining mode .PP A typical cursor addressing option would be set scroll region (if supported): .PP tput cs 5 3 .PP would set the scrolling between lines 3 and 5. .SH FILES /etc/termcap .SH SEE ALSO termcap(3X), termcap(5) .SH DIAGNOSTICS Returns 0 if it worked; else returns 1. .SH BUGS .PP The onus of handling unavailable options is on the user. .SH AUTHOR Badri Lokanathan SHAR_EOF fi if test -f 'tput.c' then echo shar: "will not over-write existing file 'tput.c'" else cat << \SHAR_EOF > 'tput.c' #ifndef LINT static char rcsid[] = "$Header: tput.c,v 1.2 86/08/22 13:39:27 badri Exp $" ; #endif LINT /* * Copyright (C) $Date: 86/08/22 13:39:27 $ * by $Author: badri $ * University of Rochester, * Department of Electrical Engineering. * * CoNtEnTs This file contains a program to emulate the system V * CoNtEnTs version of tput. * * $Locker: badri $ * $Source: /u/users/badri/usr/src/local/tput/RCS/tput.c,v $ * $Revision: 1.2 $ * * History of this release: * $Log: tput.c,v $ * Revision 1.2 86/08/22 13:39:27 badri * 1. Corrected a bug that would cause %d to fail after %%. * 2. Included XTABS handling. * 3. General cleanup of code. * * Revision 1.1 86/08/21 19:23:33 badri * Initial revision * */ #include <sgtty.h> #ifndef XTABS #define XTABS 0006000 #endif XTABS #define LARGEBUF 1024 #define SMALLBUF 64 #define OUTPUT 1 #define SUCCESS 0 #define FAILURE 1 #define AFFLINES 1 int errno; main(argc,argv) int argc; char *argv[]; { char bp[LARGEBUF], *getenv(), *tgetstr(), *tgoto(), buf[SMALLBUF], *area, *ptr; int outc(); struct sgttyb ttyprm; short ttyflg; if (argc < 2) exit(FAILURE); switch (tgetent(bp,getenv("TERM"))) { case -1: exit(FAILURE); case 0: exit(FAILURE); case 1: break; } area = buf; if (*(ptr=tgetstr(argv[1],&area)) == '\0') exit(FAILURE); /* * Examine if cursor movement specified. This is done * by looking for % followed by any but %. Since %% * is a single %, we have to make sure that %% followed * by any but % is not interpreted as a format. * If cursor movement is specified then tgoto needs * to be invoked. Else put as is. */ ptr = buf; while (*ptr != '\0') { if (*(ptr++) != '%') continue; if (*ptr != '\0' && *(ptr++) != '%') { /* This string is a cm string. */ if (argc != 4) exit(FAILURE); if (*(ptr=tgoto(buf,atoi(argv[2]),atoi(argv[3]))) == 'O' && *(ptr+1) == 'O' && *(ptr+2) == 'P' && *(ptr+3) == 'S') exit(FAILURE); /* Turn off XTABS, but save old flags first. */ if (gtty(OUTPUT,&ttyprm) < 0) exit(errno); ttyflg = ttyprm.sg_flags; ttyprm.sg_flags &= ~XTABS; if (stty(OUTPUT,&ttyprm) < 0) exit(errno); tputs(ptr,AFFLINES,outc); /* Restore old flags. */ ttyprm.sg_flags = ttyflg; if (stty(OUTPUT,&ttyprm) < 0) exit(errno); exit(SUCCESS); } exit(FAILURE); } tputs(buf,AFFLINES,outc); exit(errno); } outc(c) char c; { if (write(OUTPUT,&c,sizeof(char)) < 0) exit(errno); return(SUCCESS); } SHAR_EOF fi if test -f 'Makefile' then echo shar: "will not over-write existing file 'Makefile'" else cat << \SHAR_EOF > 'Makefile' tput: tput.c cc -o tput tput.c -ltermlib man: tput.1 nroff -man tput.1 > tput.doc dtput: tput.c cc -g -o dtput tput.c -ltermlib SHAR_EOF fi exit 0 # End of shell archive