1LIB2648(3X)                                                        LIB2648(3X)
2
3
4

NAME

6       lib2648 - subroutines for the HP 2648 graphics terminal
7

SYNOPSIS

9       #include <stdio.h>
10
11       typedef char *bitmat;
12       FILE *trace;
13
14       cc file.c -l2648
15

DESCRIPTION

17       Lib2648 is a general purpose library of subroutines useful for interac‐
18       tive graphics on the Hewlett-Packard 2648 graphics terminal.  To use it
19       you  must call the routine ttyinit() at the beginning of execution, and
20       done() at the end of execution.  All terminal input and output must  go
21       through the routines rawchar, readline, outchar, and outstr.
22
23       Lib2648  does  the  necessary  ^E/^F  handshaking  if  getenv(``TERM'')
24       returns ``hp2648'', as it will if set by  tset(1).   Any  other  value,
25       including for example ``2648'', will disable handshaking.
26
27       Bit  matrix  routines  are provided to model the graphics memory of the
28       2648.  These routines are generally useful, but are specifically useful
29       for the update function which efficiently changes what is on the screen
30       to what is supposed to be on the screen.  The primative bit matrix rou‐
31       tines are newmat, mat, and setmat.
32
33       The  file  trace,  if  non-null, is expected to be a file descriptor as
34       returned by fopen.  If so, lib2648 will trace the progress of the  out‐
35       put by writing onto this file.  It is provided to make debugging output
36       feasible for graphics programs without messing up  the  screen  or  the
37       escape sequences being sent.  Typical use of trace will include:
38            switch (argv[1][1]) {
39            case 'T':
40                 trace = fopen("trace", "w");
41                 break;
42            ...
43            if (trace)
44                 fprintf(trace, "x is %d, y is %s\n", x, y);
45            ...
46            dumpmat("before update", xmat);
47

ROUTINES

49       agoto(x, y)
50              Move  the  alphanumeric cursor to position (x, y), measured from
51              the upper left corner of the screen.
52
53       aoff() Turn the alphanumeric display off.
54
55       aon()  Turn the alphanumeric display on.
56
57       areaclear(rmin, cmin, rmax, cmax)
58              Clear the area on the graphics screen bordered by the four argu‐
59              ments.   In normal mode the area is set to all black, in inverse
60              video mode it is set to all white.
61
62       beep() Ring the bell on the terminal.
63
64       bitcopy(dest, src, rows, cols) bitmat dest, src;
65              Copy a rows by cols bit matrix from src to (user provided) dest.
66
67       cleara()
68              Clear the alphanumeric display.
69
70       clearg()
71              Clear the graphics display.  Note that the 2648 will only  clear
72              the part of the screen that is visible if zoomed in.
73
74       curoff()
75              Turn the graphics cursor off.
76
77       curon()
78              Turn the graphics cursor on.
79
80       dispmsg(str, x, y, maxlen) char *str;
81              Display  the  message  str  in graphics text at position (x, y).
82              The maximum message length is given by maxlen, and is needed for
83              dispmsg to know how big an area to clear before drawing the mes‐
84              sage.  The lower left corner of the first character  is  at  (x,
85              y).
86
87       done() Should  be called before the program exits.  Restores the tty to
88              normal, turns off graphics screen, turns on alphanumeric screen,
89              flushes the standard output, etc.
90
91       draw(x, y)
92              Draw a line from the pen location to (x, y).  As with all graph‐
93              ics coordinates, (x, y) is measured from the bottom left  corner
94              of  the screen.  (x, y) coordinates represent the first quadrant
95              of the usual Cartesian system.
96
97       drawbox(r, c, color, rows, cols)
98              Draw a rectangular box on the graphics screen.  The  lower  left
99              corner  is  at  location  (r, c).  The box is rows rows high and
100              cols columns wide.  The box is drawn if color is  1,  erased  if
101              color  is 0.  (r, c) absolute coordinates represent row and col‐
102              umn on the screen, with the origin at the lower left.  They  are
103              equivalent to (x, y) except for being reversed in order.
104
105       dumpmat(msg, m, rows, cols) char *msg; bitmat m;
106              If  trace  is non-null, write a readable ASCII representation of
107              the matrix m on trace.  Msg is a label to identify the output.
108
109       emptyrow(m, rows, cols, r) bitmat m;
110              Returns 1 if row r of matrix m is  all  zero,  else  returns  0.
111              This  routine  is  provided  because  it can be implemented more
112              efficiently with a knowledge of the internal representation than
113              a series of calls to mat.
114
115       error(msg) char *msg;
116              Default error handler.  Calls message(msg) and returns.  This is
117              called by certain routines in lib2648.  It is also suitable  for
118              calling  by  the user program.  It is probably a good idea for a
119              fancy graphics program to supply its own error  procedure  which
120              uses setjmp(3) to restart the program.
121
122       gdefault()
123              Set the terminal to the default graphics modes.
124
125       goff() Turn the graphics display off.
126
127       gon()  Turn the graphics display on.
128
129       koff() Turn the keypad off.
130
131       kon()  Turn  the  keypad  on.  This means that most special keys on the
132              terminal (such as the alphanumeric arrow keys) will transmit  an
133              escape sequence instead of doing their function locally.
134
135       line(x1, y1, x2, y2)
136              Draw a line in the current mode from (x1, y1) to (x2, y2).  This
137              is equivalent to move(x1, y1); draw(x2, y2); except that  a  bug
138              in  the terminal involving repeated lines from the same point is
139              compensated for.
140
141       lowleft()
142              Move the alphanumeric cursor to the lower left (home down) posi‐
143              tion.
144
145       mat(m, rows, cols, r, c) bitmat m;
146              Used  to  retrieve an element from a bit matrix.  Returns 1 or 0
147              as the value of the [r, c] element of the rows by cols matrix m.
148              Bit  matrices  are numbered (r, c) from the upper left corner of
149              the matrix, beginning at (0, 0).  R represents the  row,  and  c
150              represents the column.
151
152       message(str) char *str;
153              Display  the  text  message  str  at  the bottom of the graphics
154              screen.
155
156       minmax(g, rows, cols, rmin, cmin, rmax, cmax) bitmat g;
157         int *rmin, *cmin, *rmax, *cmax;
158              Find the smallest rectangle that contains all the  1  (on)  ele‐
159              ments  in the bit matrix g.  The coordinates are returned in the
160              variables pointed to by rmin, cmin, rmax, cmax.
161
162       move(x, y)
163              Move the pen to location (x, y).  Such motion  is  internal  and
164              will not cause output until a subsequent sync().
165
166       movecurs(x, y)
167              Move the graphics cursor to location (x, y).
168
169       bitmat newmat(rows, cols)
170              Create  (with  malloc(3)) a new bit matrix of size rows by cols.
171              The value created (e.g. a pointer  to  the  first  location)  is
172              returned.  A bit matrix can be freed directly with free.
173
174       outchar(c) char c;
175              Print the character c on the standard output.  All output to the
176              terminal should go through this routine or outstr.
177
178       outstr(str) char *str;
179              Print the string str on the standard output by repeated calls to
180              outchar.
181
182       printg()
183              Print  the graphics display on the printer.  The printer must be
184              configured as device 6 (the default) on the HPIB.
185
186       char rawchar()
187              Read one character from the terminal and return it.   This  rou‐
188              tine  or  readline  should be used to get all input, rather than
189              getchar(3).
190
191       rboff()
192              Turn the rubber band line off.
193
194       rbon() Turn the rubber band line on.
195
196       char *rdchar(c) char c;
197              Return a readable representation of the character c.  If c is  a
198              printing  character it returns itself, if a control character it
199              is shown in the  ^X  notation,  if  negative  an  apostrophe  is
200              prepended.  Space returns ^`, rubout returns ^?.
201
202              NOTE: A pointer to a static place is returned.  For this reason,
203              it  will  not  work  to  pass   rdchar   twice   to   the   same
204              fprintf/sprintf  call.   You must instead save one of the values
205              in your own buffer with strcpy.
206
207       readline(prompt, msg, maxlen) char *prompt, *msg;
208              Display prompt on the bottom line of the  graphics  display  and
209              read  one  line  of text from the user, terminated by a newline.
210              The line is placed in the buffer  msg,  which  has  size  maxlen
211              characters.  Backspace processing is supported.
212
213       setclear()
214              Set  the display to draw lines in erase mode.  (This is reversed
215              by inverse video mode.)
216
217       setmat(m, rows, cols, r, c, val) bitmat m;
218              The basic operation to store a value in  an  element  of  a  bit
219              matrix.   The [r, c] element of m is set to val, which should be
220              either 0 or 1.
221
222       setset()
223              Set the display to draw lines in normal (solid) mode.  (This  is
224              reversed by inverse video mode.)
225
226       setxor()
227              Set the display to draw lines in exclusive or mode.
228
229       sync() Force  all  accumulated  output  to  be displayed on the screen.
230              This should be followed by fflush(stdout).  The  cursor  is  not
231              affected  by this function.  Note that it is normally never nec‐
232              essary to call sync, since rawchar and readline call sync()  and
233              fflush(stdout) automatically.
234
235       togvid()
236              Toggle  the  state of video.  If in normal mode, go into inverse
237              video mode, and vice versa.  The screen is reversed as  well  as
238              the internal state of the library.
239
240       ttyinit()
241              Set  up  the  terminal  for  processing.  This routine should be
242              called at the beginning of execution.  It places the terminal in
243              CBREAK mode, turns off echo, sets the proper modes in the termi‐
244              nal, and initializes the library.
245
246       update(mold, mnew, rows, cols, baser, basec) bitmat mold, mnew;
247              Make whatever changes are needed to make a window on the  screen
248              look like mnew.  Mold is what the window on the screen currently
249              looks like.  The window has size rows by  cols,  and  the  lower
250              left  corner  on  the  screen  of  the window is [baser, basec].
251              Note: update was not intended to be used for the entire  screen.
252              It would work but be very slow and take 64K bytes of memory just
253              for mold and mnew.  It was intended for 100 by 100 windows  with
254              objects  in  the center of them, and is quite fast for such win‐
255              dows.
256
257       vidinv()
258              Set inverse video mode.
259
260       vidnorm()
261              Set normal video mode.
262
263       zermat(m, rows, cols) bitmat m;
264              Set the bit matrix m to all zeros.
265
266       zoomn(size)
267              Set the hardware zoom to value size, which can range from  1  to
268              15.
269
270       zoomoff()
271              Turn  zoom  off.  This forces the screen to zoom level 1 without
272              affecting the current internal zoom number.
273
274       zoomon()
275              Turn zoom on.  This restores the screen to the previously speci‐
276              fied zoom size.
277

DIAGNOSTICS

279       The  routine error is called when an error is detected.  The only error
280       currently detected is overflow of the buffer provided to readline.
281
282       Subscripts out of bounds to setmat return without setting anything.
283

FILES

285       /usr/lib/lib2648.a
286

SEE ALSO

288       fed(1)
289

AUTHOR

291       Mark Horton
292

BUGS

294       This library is not supported.  It makes no attempt to use all  of  the
295       features of the terminal, only those needed by fed.  Contributions from
296       users will be accepted for addition to the library.
297
298       The HP 2648 terminal is somewhat unreliable at speeds over  2400  baud,
299       even  with the ^E/^F handshaking.  In an effort to improve reliability,
300       handshaking is done every 32 characters.  (The manual claims it is only
301       necessary  every  80  characters.)   Nonetheless,  I/O errors sometimes
302       still occur.
303
304       There is no way to control the amount of debugging output generated  on
305       trace without modifying the source to the library.
306
307
308
3094.2 Berkeley Distribution        May 27, 1986                      LIB2648(3X)
Impressum