This is xterm.c in view mode; [Download] [Up]
#include "plplot.h"
#include <stdio.h>
/* This file contains the xterm dependent routines for use with plplot. */
#define TEKX 1023
#define TEKY 779
/* Define graphics control characters. */
#define FF 12
#define CAN 24
#define ESC 27
#define GS 29
#define US 31
#define ETX 003
void xtesetup(xdpi, ydpi, xwid, ywid)
int xwid, ywid;
double xdpi, ydpi;
{
/* the user doesn't know what he's talking about. ignore this stuff */
}
void xteorient(ori)
int ori;
{
}
void xteselect(file)
FILE *file;
{
}
void xteinit()
{
/* tell plplot that this is an interactive device (so pause after */
/* drawing graph). use if smod(0) if sending grphx to a file. */
smod(1); /* interactive device */
/* set default pen color (this should be the desired pen number) */
/* plplot will actually tell the device to use this pen by */
/* making a call to plcolor. */
scol(1);
swid(1);
/* Use factor of 16 for resolution and page size. This allows the
area fill stuff to work on low resolution devices. (slower) */
/* set device resolution in dots/mm */
setpxl(4.771*16,4.653*16);
/* set page size using setphy(xmin,xmax,ymin,ymax) */
/* plplot assumes that the min coordinates are in the lower left */
setphy(0,16*TEKX,0,16*TEKY);
printf("%c[?38h",ESC); /* open graphics window */
printf("%c",GS); /* set to vector mode */
printf("%c%c",ESC,FF);
}
/* Sets to text mode */
void xtetext()
{
printf("%c",US);
}
/* Sets to graphics mode */
void xtegraph()
{
printf("%c",GS); /* set to vector mode */
}
/* Clears the screen */
void xteclear()
{
printf("%c%c",ESC,FF);
fflush(stdout);
}
static int xold, yold;
void xtepage()
{
xold = -100000;
yold = -100000;
}
void xteeop()
{
fflush(stdout);
}
/* Change color */
void xtecolor(colour)
int colour;
{
}
void xtewidth(width)
int width;
{
}
/* Draws a line in the current colour from (x1,y1) to (x2,y2) */
void xteline(x1,y1,x2,y2)
int x1,y1,x2,y2;
{
int hy,ly,hx,lx;
x1 >>= 4;
y1 >>= 4;
x2 >>= 4;
y2 >>= 4;
/* If continuation of previous line just send new point */
if(x1 == xold && y1 == yold) {
hy = y2/32 + 32;
ly = y2 - (y2/32)*32 + 96;
hx = x2/32 + 32;
lx = x2 - (x2/32)*32 + 64;
printf("%c%c%c%c",hy,ly,hx,lx);
}
else {
printf("%c",GS);
hy = y1/32 + 32;
ly = y1 - (y1/32)*32 + 96;
hx = x1/32 + 32;
lx = x1 - (x1/32)*32 + 64;
printf("%c%c%c%c",hy,ly,hx,lx);
hy = y2/32 + 32;
ly = y2 - (y2/32)*32 + 96;
hx = x2/32 + 32;
lx = x2 - (x2/32)*32 + 64;
printf("%c%c%c%c",hy,ly,hx,lx);
}
xold = x2;
yold = y2;
}
void xtetidy()
{
printf("%c%c",US,CAN);
printf("%c%c",ESC,ETX);
fflush(stdout);
}
void xtecwin()
{
printf("%c%c",US,CAN);
printf("%c%c",ESC,ETX);
fflush(stdout); /* flush graphics to window */
}
void xtegwin()
{
printf("%c[?38h",ESC); /* go to graphics window */
printf("%c",GS); /* set to vector mode */
fflush(stdout);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.