home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
419b.lha
/
TERMLIB
/
cur.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-05
|
1KB
|
54 lines
/* Cur: Provide cursor addressing for shell scripts.
*
* Cur performs the same functions as echo, with 2 differences:
* 1.
* a. Arguments of the form -xx result in the generation of the capability
* string xx. The two special strings "cm" and "cs" are handled by
* cur ... -cm x y ... and ... -cs lo hi ...
* b. Arguments of the form #xx return the value of the numeric capability
* xx.
* c. Arguments of the form +terminal force cur to assume that as the
* terminal type. Any number of these can be included, and will be
* evaluated when encountered.
* 2. No newline is appended to the echoed string.
*
* Syntax: cur [string|-xx|#xx|+term]...
*
* Other notes: The code is obvious.
*/
#include <stdio.h>
#include "termlib.h"
extern char *junkptr;
main(ac, av)
int ac; char **av;
{
int line, col, outch();
char *val;
tinit(getenv("TERM"));
while(--ac)
if(**++av=='-') {
if(val=tgetstr(*av+1, &junkptr)) {
if(strcmp(*av+1, "cm") &&
strcmp(*av+1, "cs"))
tputs(val, 1, outch);
else {
col = atoi(*++av); --ac;
line = atoi(*++av); --ac;
tputs(tgoto(val, col, line), 0, outch);
}
}
} else if(**av=='#') {
if(val = tgetstr(*av+1, &junkptr))
fputs(val, stdout);
} else if(**av=='+') {
tinit(*av+1);
} else
fputs(*av, stdout);
}
outch(c) char c; { putchar(c); }