Cover V02, I05
Article
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6

sep93.tar


Listing 3: cursor.c

/* Authors: Jon Alder/Ed Schaefer
* set cursor at row and column on screen
* usage:  <cursor> row col
* where row and col are integer screen coordinates
* with upper left corner being 0,0.
* TERM must be set and defined in the TERMINFO database
* or program aborts.
* to compile:  cc cursor.c -lcurses -o cursor
*/
#include        <stdio.h>
#include        <curses.h>
#include        <term.h>

main(argc, argv)
int argc;
char *argv[];
{
int row, col;

if(argc != 3)
{
fprintf(stderr, "Usage: <cursor> row column\n");
exit(1);
}

if((row = atoi(argv[1])), row == NULL)
row = 0; /*default to zero if illegal conversion*/

if((col = atoi(argv[2])), col == NULL)
col = 0; /*default to zero if illegal conversion*/

t_init();
if(cursor_address == NULL)
{
fprintf(stderr, "Can NOT set cursor motion string\n");
exit(1);
}

putp(tparm(cursor_address, row, col));
exit(0);
}

/*
* t_init()
*
* Initialize the terminfo system with the current
* terminal type.
*/
t_init()
{
int rv;
extern char     *getenv();
char            *term;

setupterm((char *)0, fileno(stdout), &rv);

if (rv != 1)

{
if (term = getenv("TERM"), term == NULL)
{
fprintf(stderr, "Cannot set up terminal %s\n", term);
exit(1);
}
}
}
/* end of file */