| 1 |
< |
/* Copyright (c) 1987 Regents of the University of California */ |
| 2 |
< |
|
| 3 |
< |
/* SCCSid "$SunId$ LBL" */ |
| 4 |
< |
|
| 1 |
> |
/* RCSid $Id$ */ |
| 2 |
|
/* |
| 3 |
|
* driver.h - header file for interactive device drivers. |
| 7 |
– |
* |
| 8 |
– |
* 2/2/87 |
| 4 |
|
*/ |
| 5 |
+ |
#ifndef _RAD_DRIVER_H_ |
| 6 |
+ |
#define _RAD_DRIVER_H_ |
| 7 |
|
|
| 8 |
+ |
#include "color.h" |
| 9 |
+ |
|
| 10 |
+ |
#ifdef __cplusplus |
| 11 |
+ |
extern "C" { |
| 12 |
+ |
#endif |
| 13 |
+ |
|
| 14 |
|
struct driver { /* driver functions */ |
| 15 |
< |
int (*close)(); /* close device */ |
| 16 |
< |
int (*clear)(); /* clear device */ |
| 17 |
< |
int (*paintr)(); /* paint rectangle */ |
| 18 |
< |
int (*getcur)(); /* get cursor position */ |
| 19 |
< |
int (*comout)(); /* command line output */ |
| 20 |
< |
int (*comin)(); /* command line input */ |
| 15 |
> |
void (*close)(void); /* close device */ |
| 16 |
> |
void (*clear)(int, int); /* clear device */ |
| 17 |
> |
void (*paintr)(COLOR col, int xmin, int ymin, int xmax, int ymax); /* paint rectangle */ |
| 18 |
> |
int (*getcur)(int*,int*); /* get cursor position */ |
| 19 |
> |
void (*comout)(char*); /* command line output */ |
| 20 |
> |
void (*comin)(); /* command line input */ |
| 21 |
> |
void (*flush)(); /* flush output */ |
| 22 |
|
double pixaspect; /* pixel aspect ratio */ |
| 23 |
|
int xsiz, ysiz; /* device size */ |
| 24 |
|
int inpready; /* input ready on device */ |
| 25 |
|
}; |
| 22 |
– |
|
| 23 |
– |
extern int stderr_v(); /* error vectors */ |
| 24 |
– |
extern int (*wrnvec)(), (*errvec)(), (*cmdvec)(); |
| 25 |
– |
|
| 26 |
– |
extern struct driver *comm_init(); /* stream interface */ |
| 26 |
|
/* magic numbers for verification */ |
| 27 |
|
#define COM_SENDM 0x6f37 |
| 28 |
|
#define COM_RECVM 0x51da |
| 32 |
|
#define COM_GETCUR 2 |
| 33 |
|
#define COM_COMOUT 3 |
| 34 |
|
#define COM_COMIN 4 |
| 35 |
< |
#define NREQUESTS 5 /* number of valid requests */ |
| 35 |
> |
#define COM_FLUSH 5 |
| 36 |
> |
#define NREQUESTS 6 /* number of valid requests */ |
| 37 |
|
|
| 38 |
|
extern struct device { /* interactive device */ |
| 39 |
|
char *name; /* device name */ |
| 41 |
|
struct driver *(*init)(); /* initialize device */ |
| 42 |
|
} devtable[]; /* supported devices */ |
| 43 |
|
|
| 44 |
+ |
extern char dev_default[]; /* default device name */ |
| 45 |
+ |
|
| 46 |
|
#define MB1 ('\n') /* mouse button 1 */ |
| 47 |
|
#define MB2 ('\r') /* mouse button 2 */ |
| 48 |
|
#define MB3 (' ') /* mouse button 3 */ |
| 58 |
|
* The name string identifies the driver, |
| 59 |
|
* and the id string identifies the client. |
| 60 |
|
* A device can be open by at most one client. |
| 61 |
< |
* Be verbose in error reports; call stderr_v(). |
| 62 |
< |
* If device has its own error output, set errvec, |
| 61 |
< |
* cmdvec and wrnvec. |
| 61 |
> |
* Be verbose in error reports; call eputs(). |
| 62 |
> |
* If device has its own error output, set erract. |
| 63 |
|
* } |
| 64 |
|
* (*dev->close)() |
| 65 |
|
* { |
| 76 |
|
* int xmin, ymin, xmax, ymax; |
| 77 |
|
* { |
| 78 |
|
* Paint a half-open rectangle from (xmin,ymin) to (xmax,ymax) |
| 79 |
< |
* with the color col. Can call repaint() if necessary. |
| 79 |
> |
* with the color col. |
| 80 |
|
* } |
| 81 |
|
* (*dev->getcur)(xp, yp) |
| 82 |
|
* int *xp, *yp; |
| 100 |
|
* assuming the in buffer is big enough. Unless prompt is NULL, |
| 101 |
|
* the driver may substitute its own rview command. This is |
| 102 |
|
* the most reliable way to repaint areas of the screen. |
| 103 |
< |
* If the user enters an unrecognized control character is entered, |
| 103 |
> |
* If the user enters an unrecognized control character, |
| 104 |
|
* terminate input and return the string with only that character. |
| 105 |
|
* The input string should not contain a newline. The routines in |
| 106 |
|
* editline.c may be useful. Comin must work in consort with comout. |
| 107 |
|
* } |
| 108 |
+ |
* (*dev->flush)() |
| 109 |
+ |
* { |
| 110 |
+ |
* Flush output to the display. This is guaranteed to be called |
| 111 |
+ |
* frequently enough to keep the display up to date. |
| 112 |
+ |
* This is an ideal time to check for device input. |
| 113 |
+ |
* This function can be NULL for devices that don't need it. |
| 114 |
+ |
* } |
| 115 |
|
* xsiz, ysiz |
| 116 |
|
* The maximum allowable x and y dimensions. If any |
| 117 |
|
* size is allowable, these should be set to MAXRES. |
| 120 |
|
* when characters are ready on the input. (Often easiest |
| 121 |
|
* to check for input during calls to paintr.) |
| 122 |
|
*/ |
| 123 |
+ |
|
| 124 |
+ |
/* defined in editline.c */ |
| 125 |
+ |
extern void editline(char *buf, int (*c_get)(), void (*s_put)()); |
| 126 |
+ |
extern void tocombuf(char *b, struct driver *d); |
| 127 |
+ |
extern int fromcombuf(char *b, struct driver *d); |
| 128 |
+ |
/* defined in devcomm.c */ |
| 129 |
+ |
extern struct driver *slave_init(char *dname, char *id); |
| 130 |
+ |
extern struct driver *comm_init(char *dname, char *id); |
| 131 |
+ |
/* defined in colortab.c */ |
| 132 |
+ |
extern int new_ctab(int ncolors); |
| 133 |
+ |
extern int get_pixel(COLOR col, void (*set_pixel)()); |
| 134 |
+ |
extern void make_gmap(double gam); |
| 135 |
+ |
extern void set_cmap(BYTE *rmap, BYTE *gmap, BYTE *bmap); |
| 136 |
+ |
extern void map_color(BYTE rgb[3], COLOR col); |
| 137 |
+ |
|
| 138 |
+ |
|
| 139 |
+ |
#ifdef __cplusplus |
| 140 |
+ |
} |
| 141 |
+ |
#endif |
| 142 |
+ |
#endif /* _RAD_DRIVER_H_ */ |
| 143 |
+ |
|