| 1 |
greg |
1.1 |
/* Copyright (c) 1987 Regents of the University of California */
|
| 2 |
|
|
|
| 3 |
|
|
/* SCCSid "$SunId$ LBL" */
|
| 4 |
|
|
|
| 5 |
|
|
/*
|
| 6 |
|
|
* driver.h - header file for interactive device drivers.
|
| 7 |
|
|
*
|
| 8 |
|
|
* 2/2/87
|
| 9 |
|
|
*/
|
| 10 |
|
|
|
| 11 |
|
|
struct driver { /* driver functions */
|
| 12 |
|
|
int (*close)(); /* close device */
|
| 13 |
|
|
int (*clear)(); /* clear device */
|
| 14 |
|
|
int (*paintr)(); /* paint rectangle */
|
| 15 |
|
|
int (*getcur)(); /* get cursor position */
|
| 16 |
|
|
int (*comout)(); /* command line output */
|
| 17 |
|
|
int (*comin)(); /* command line input */
|
| 18 |
greg |
1.6 |
int (*flush)(); /* flush output */
|
| 19 |
greg |
1.4 |
double pixaspect; /* pixel aspect ratio */
|
| 20 |
greg |
1.1 |
int xsiz, ysiz; /* device size */
|
| 21 |
|
|
int inpready; /* input ready on device */
|
| 22 |
|
|
};
|
| 23 |
|
|
|
| 24 |
|
|
extern int stderr_v(); /* error vectors */
|
| 25 |
|
|
extern int (*wrnvec)(), (*errvec)(), (*cmdvec)();
|
| 26 |
|
|
|
| 27 |
|
|
extern struct driver *comm_init(); /* stream interface */
|
| 28 |
greg |
1.3 |
/* magic numbers for verification */
|
| 29 |
|
|
#define COM_SENDM 0x6f37
|
| 30 |
|
|
#define COM_RECVM 0x51da
|
| 31 |
greg |
1.1 |
/* stream commands */
|
| 32 |
|
|
#define COM_CLEAR 0
|
| 33 |
|
|
#define COM_PAINTR 1
|
| 34 |
|
|
#define COM_GETCUR 2
|
| 35 |
|
|
#define COM_COMOUT 3
|
| 36 |
|
|
#define COM_COMIN 4
|
| 37 |
greg |
1.6 |
#define COM_FLUSH 5
|
| 38 |
|
|
#define NREQUESTS 6 /* number of valid requests */
|
| 39 |
greg |
1.1 |
|
| 40 |
greg |
1.4 |
extern struct device { /* interactive device */
|
| 41 |
greg |
1.1 |
char *name; /* device name */
|
| 42 |
|
|
char *descrip; /* description */
|
| 43 |
|
|
struct driver *(*init)(); /* initialize device */
|
| 44 |
greg |
1.4 |
} devtable[]; /* supported devices */
|
| 45 |
greg |
1.1 |
|
| 46 |
greg |
1.8 |
extern char dev_default[]; /* default device name */
|
| 47 |
|
|
|
| 48 |
greg |
1.1 |
#define MB1 ('\n') /* mouse button 1 */
|
| 49 |
|
|
#define MB2 ('\r') /* mouse button 2 */
|
| 50 |
|
|
#define MB3 (' ') /* mouse button 3 */
|
| 51 |
|
|
#define ABORT ('C'-'@') /* abort key */
|
| 52 |
|
|
|
| 53 |
|
|
/*
|
| 54 |
|
|
* struct driver *
|
| 55 |
greg |
1.3 |
* dname_init(name, id)
|
| 56 |
|
|
* char *name, *id;
|
| 57 |
greg |
1.1 |
* {
|
| 58 |
|
|
* Initialize device and return pointer to driver
|
| 59 |
|
|
* functions. Returns NULL if an error occurred.
|
| 60 |
greg |
1.3 |
* The name string identifies the driver,
|
| 61 |
|
|
* and the id string identifies the client.
|
| 62 |
greg |
1.1 |
* A device can be open by at most one client.
|
| 63 |
|
|
* Be verbose in error reports; call stderr_v().
|
| 64 |
greg |
1.2 |
* If device has its own error output, set errvec,
|
| 65 |
|
|
* cmdvec and wrnvec.
|
| 66 |
greg |
1.1 |
* }
|
| 67 |
|
|
* (*dev->close)()
|
| 68 |
|
|
* {
|
| 69 |
greg |
1.2 |
* Close the device. Reset error vectors.
|
| 70 |
greg |
1.1 |
* }
|
| 71 |
|
|
* (*dev->clear)(xres, yres)
|
| 72 |
|
|
* int xres, yres;
|
| 73 |
|
|
* {
|
| 74 |
greg |
1.2 |
* Clear the device for xres by yres output. This call will
|
| 75 |
greg |
1.1 |
* be made prior to any output.
|
| 76 |
|
|
* }
|
| 77 |
|
|
* (*dev->paintr)(col, xmin, ymin, xmax, ymax)
|
| 78 |
|
|
* COLOR col;
|
| 79 |
|
|
* int xmin, ymin, xmax, ymax;
|
| 80 |
|
|
* {
|
| 81 |
|
|
* Paint a half-open rectangle from (xmin,ymin) to (xmax,ymax)
|
| 82 |
greg |
1.6 |
* with the color col.
|
| 83 |
greg |
1.1 |
* }
|
| 84 |
|
|
* (*dev->getcur)(xp, yp)
|
| 85 |
|
|
* int *xp, *yp;
|
| 86 |
|
|
* {
|
| 87 |
|
|
* Get the cursor position entered by the user via mouse,
|
| 88 |
|
|
* joystick, etc. Return the key hit by the user (usually
|
| 89 |
|
|
* MB1 or MB2). Return ABORT to cancel.
|
| 90 |
|
|
* Can be NULL for devices without this capability.
|
| 91 |
|
|
* }
|
| 92 |
|
|
* (*dev->comout)(out)
|
| 93 |
|
|
* char *out;
|
| 94 |
|
|
* {
|
| 95 |
|
|
* Print the string out on the device command line. If the
|
| 96 |
|
|
* string ends with '\n', the message is considered complete,
|
| 97 |
|
|
* and the next call can erase it.
|
| 98 |
|
|
* }
|
| 99 |
greg |
1.5 |
* (*dev->comin)(in, prompt)
|
| 100 |
|
|
* char *in, *prompt;
|
| 101 |
greg |
1.1 |
* {
|
| 102 |
greg |
1.5 |
* Print a prompt then read an edited input command line
|
| 103 |
|
|
* assuming the in buffer is big enough. Unless prompt is NULL,
|
| 104 |
|
|
* the driver may substitute its own rview command. This is
|
| 105 |
|
|
* the most reliable way to repaint areas of the screen.
|
| 106 |
greg |
1.7 |
* If the user enters an unrecognized control character,
|
| 107 |
greg |
1.5 |
* terminate input and return the string with only that character.
|
| 108 |
|
|
* The input string should not contain a newline. The routines in
|
| 109 |
|
|
* editline.c may be useful. Comin must work in consort with comout.
|
| 110 |
greg |
1.6 |
* }
|
| 111 |
|
|
* (*dev->flush)()
|
| 112 |
|
|
* {
|
| 113 |
|
|
* Flush output to the display. This is guaranteed to be called
|
| 114 |
|
|
* frequently enough to keep the display up to date.
|
| 115 |
|
|
* This is an ideal time to check for device input.
|
| 116 |
|
|
* This function can be NULL for devices that don't need it.
|
| 117 |
greg |
1.1 |
* }
|
| 118 |
|
|
* xsiz, ysiz
|
| 119 |
|
|
* The maximum allowable x and y dimensions. If any
|
| 120 |
|
|
* size is allowable, these should be set to MAXRES.
|
| 121 |
|
|
* inpready
|
| 122 |
greg |
1.2 |
* This variable should be made positive asynchronously
|
| 123 |
|
|
* when characters are ready on the input. (Often easiest
|
| 124 |
|
|
* to check for input during calls to paintr.)
|
| 125 |
greg |
1.1 |
*/
|