BSD 4_2 development
[unix-history] / usr / man / man3 / lib2648.3x
CommitLineData
0594cf07
C
1.TH LIB2648 3X "1 March 1980"
2.UC 4
3.SH NAME
4lib2648 \- subroutines for the HP 2648 graphics terminal
5.SH SYNOPSIS
6.B #include <stdio.h>
7.sp
8.B "typedef char"
9.RB * bitmat ;
10.br
11FILE *trace;
12.sp
13cc file.c
14.B \-l2648
15.SH DESCRIPTION
16.I Lib2648
17is a general purpose library of subroutines useful
18for interactive graphics on the Hewlett-Packard 2648 graphics terminal.
19To use it you must call the routine
20.IR ttyinit ()
21at the beginning of execution,
22and
23.IR done ()
24at the end of execution.
25All terminal input and output must go through the routines
26.IR rawchar ,
27.IR readline ,
28.IR outchar ,
29and
30.IR outstr .
31.PP
32.I Lib2648
33does the necessary ^E/^F handshaking if
34.I "getenv(``TERM'')"
35returns ``hp2648'', as it will if set by
36.IR tset (1).
37Any other value, including for example ``2648'', will disable handshaking.
38.PP
39Bit matrix routines are provided to model the graphics memory of the 2648.
40These routines are generally useful, but are specifically useful for the
41.I update
42function which efficiently changes what is on the screen to what is
43supposed to be on the screen.
44The primative bit matrix routines are
45.IR newmat ,
46.IR mat ,
47and
48.IR setmat .
49.PP
50The file
51.IR trace ,
52if non-null, is expected to be a file descriptor as returned by
53.IR fopen .
54If so,
55.I lib2648
56will trace the progress of the output by writing onto
57this file.
58It is provided to make debugging output feasible for graphics programs without
59messing up the screen or the escape sequences being sent.
60Typical use of trace will include:
61.nf
62 \fBswitch\fP (argv[1][1]) {
63 \fBcase\fP 'T':
64 trace = fopen("trace", "w");
65 \fBbreak\fP;
66 ...
67 \fBif\fP (trace)
68 fprintf(trace, "x is %d, y is %s\en", x, y);
69 ...
70 dumpmat("before update", xmat);
71.fi
72.SH ROUTINES
73.TP
74.B agoto(x, y)
75Move the alphanumeric cursor to position (x, y),
76measured from the upper left corner of the screen.
77.TP
78.B aoff()
79Turn the alphanumeric display off.
80.TP
81.B aon()
82Turn the alphanumeric display on.
83.TP
84.B areaclear(rmin, cmin, rmax, cmax)
85Clear the area on the graphics screen bordered by the four arguments.
86In normal mode the area is set to all black, in inverse video mode
87it is set to all white.
88.TP
89.B beep()
90Ring the bell on the terminal.
91.TP
92.B bitcopy(dest, src, rows, cols) bitmat dest, src;
93Copy a
94.I rows
95by
96.I cols
97bit matrix from
98.I src
99to (user provided)
100.I dest.
101.TP
102.B cleara()
103Clear the alphanumeric display.
104.TP
105.B clearg()
106Clear the graphics display.
107Note that the 2648 will only clear the part of the screen
108that is visible if zoomed in.
109.TP
110.B curoff()
111Turn the graphics cursor off.
112.TP
113.B curon()
114Turn the graphics cursor on.
115.TP
116.B dispmsg(str, x, y, maxlen) char *str;
117Display the message
118.I str
119in graphics text at position
120.I (x, y).
121The maximum message length is given by
122.IR maxlen ,
123and is needed to for dispmsg to know how big an area to clear
124before drawing the message.
125The lower left corner of the first character is at
126.I (x, y).
127.TP
128.B done()
129Should be called before the program exits.
130Restores the tty to normal, turns off graphics screen,
131turns on alphanumeric screen, flushes the standard output, etc.
132.TP
133.B draw(x, y)
134Draw a line from the pen location to
135.I (x, y).
136As with all graphics coordinates,
137.I (x, y)
138is measured from the bottom left corner of the screen.
139.I (x, y)
140coordinates represent the first quadrant of the usual Cartesian system.
141.TP
142.B drawbox(r, c, color, rows, cols)
143Draw a rectangular box on the graphics screen.
144The lower left corner is at location
145.I (r, c).
146The box is
147.I rows
148rows high and
149.I cols
150columns wide.
151The box is drawn if
152.I color
153is 1, erased if
154.I color
155is 0.
156.I (r, c)
157absolute coordinates represent row and column on the screen,
158with the origin at the lower left.
159They are equivalent to
160.I (x, y)
161except for being reversed in order.
162.TP
163.B "dumpmat(msg, m, rows, cols) char *msg; bitmat m;"
164If
165.I trace
166is non-null, write a readable ASCII representation
167of the matrix
168.I m
169on
170.I trace.
171.I Msg
172is a label to identify the output.
173.TP
174.B emptyrow(m, rows, cols, r) bitmat m;
175Returns 1 if row
176.I r
177of matrix
178.I m
179is all zero, else returns 0.
180This routine is provided because it can be implemented more
181efficiently with a knowledge of the internal representation
182than a series of calls to
183.I mat.
184.TP
185.B error(msg) char *msg;
186Default error handler.
187Calls
188.I message(msg)
189and returns.
190This is called by certain routines in
191.IR lib2648 .
192It is also suitable for calling by the user program.
193It is probably a good idea for a fancy graphics program
194to supply its own error procedure which uses
195.IR setjmp (3)
196to restart the program.
197.TP
198.B gdefault()
199Set the terminal to the default graphics modes.
200.TP
201.B goff()
202Turn the graphics display off.
203.TP
204.B gon()
205Turn the graphics display on.
206.TP
207.B koff()
208Turn the keypad off.
209.TP
210.B kon()
211Turn the keypad on.
212This means that most special keys on the terminal (such as the alphanumeric
213arrow keys) will transmit an escape sequence instead of doing their function
214locally.
215.TP
216.B line(x1, y1, x2, y2)
217Draw a line in the current mode from
218.I (x1, y1)
219to
220.I (x2, y2).
221This is equivalent to
222.I "move(x1, y1); draw(x2, y2);"
223except that a bug in the terminal involving repeated lines from the
224same point is compensated for.
225.TP
226.B lowleft()
227Move the alphanumeric cursor to the lower left (home down) position.
228.TP
229.B "mat(m, rows, cols, r, c) bitmat m;"
230Used to retrieve an element from a bit matrix.
231Returns 1 or 0 as the value of the
232.I [r, c]
233element of the
234.I rows
235by
236.I cols
237matrix
238.I m.
239Bit matrices are numbered
240.I (r, c)
241from the upper left corner of the matrix,
242beginning at (0, 0).
243.I R
244represents the row, and
245.I c
246represents the column.
247.TP
248.B message(str) char *str;
249Display the text message
250.I str
251at the bottom of the graphics screen.
252.TP
253.B "minmax(g, rows, cols, rmin, cmin, rmax, cmax) bitmat g;"
254.ti -.5i
255.B int *rmin, *cmin, *rmax, *cmax;
256.br
257Find the smallest rectangle that contains all the 1 (on) elements in
258the bit matrix g.
259The coordinates are returned in the variables
260pointed to by rmin, cmin, rmax, cmax.
261.TP
262.B move(x, y)
263Move the pen to location
264.I (x, y).
265Such motion is internal and will not cause output
266until a subsequent
267.I sync().
268.TP
269.B movecurs(x, y)
270Move the graphics cursor to location
271.I (x, y).
272.TP
273.B bitmat newmat(rows, cols)
274Create (with
275.IR malloc (3))
276a new bit matrix of size
277.I rows
278by
279.I cols.
280The value created (e.g. a pointer to the first location) is returned.
281A bit matrix can be freed directly with
282.IR free .
283.TP
284.B outchar(c) char c;
285Print the character
286.I c
287on the standard output.
288All output to the terminal should go through this routine or
289.IR outstr .
290.TP
291.B outstr(str) char *str;
292Print the string str on the standard output by repeated calls to
293.I outchar.
294.TP
295.B printg()
296Print the graphics display on the printer.
297The printer must be configured as device 6 (the default) on the HPIB.
298.TP
299.B char rawchar()
300Read one character from the terminal and return it.
301This routine or
302.I readline
303should be used to get all input,
304rather than
305.IR getchar (3).
306.TP
307.B rboff()
308Turn the rubber band line off.
309.TP
310.B rbon()
311Turn the rubber band line on.
312.TP
313.B char *rdchar(c) char c;
314Return a readable representation of the character
315.I c.
316If
317.I c
318is a printing character it returns itself, if a control
319character it is shown in the ^X notation, if negative
320an apostrophe is prepended. Space returns ^\`, rubout returns ^?.
321.IP
322.B NOTE:
323A pointer to a static place is returned.
324For this reason, it will not work to pass rdchar twice to the same
325.IR fprintf / sprintf
326call.
327You must instead save one of the values in your own buffer with strcpy.
328.TP
329.B readline(prompt, msg, maxlen) char *prompt, *msg;
330Display
331.I prompt
332on the bottom line of the graphics display
333and read one line of text from the user, terminated by a newline.
334The line is placed in the buffer
335.IR msg ,
336which has size
337.I maxlen
338characters.
339Backspace processing is supported.
340.TP
341.B setclear()
342Set the display to draw lines in erase mode.
343(This is reversed by inverse video mode.)
344.TP
345.B "setmat(m, rows, cols, r, c, val) bitmat m;"
346The basic operation to store a value in an element of a bit matrix.
347The
348.I [r, c]
349element of
350.I m
351is set to
352.I val,
353which should be either 0 or 1.
354.TP
355.B setset()
356Set the display to draw lines in normal (solid) mode.
357(This is reversed by inverse video mode.)
358.TP
359.B setxor()
360Set the display to draw lines in exclusive or mode.
361.TP
362.B sync()
363Force all accumulated output to be displayed on the screen.
364This should be followed by fflush(stdout).
365The cursor is not affected by this function.
366Note that it is normally never necessary to call
367.IR sync ,
368since
369.I rawchar
370and
371.I readline
372call
373.I sync()
374and
375.I fflush(stdout)
376automatically.
377.TP
378.B togvid()
379Toggle the state of video.
380If in normal mode, go into inverse video mode,
381and vice versa.
382The screen is reversed as well as the
383internal state of the library.
384.TP
385.B ttyinit()
386Set up the terminal for processing.
387This routine should be called at the beginning of execution.
388It places the terminal in CBREAK mode, turns off echo,
389sets the proper modes in the terminal,
390and initializes the library.
391.TP
392.B "update(mold, mnew, rows, cols, baser, basec) bitmat mold, mnew;"
393Make whatever changes are needed to make a window on the screen
394look like
395.IR mnew .
396.I Mold
397is what the window on the screen currently looks like.
398The window has size
399.I rows
400by
401.IR cols ,
402and the lower left corner on
403the screen of the window is
404.I [baser, basec].
405Note:
406.I update
407was not intended to be used for the entire screen.
408It would work but be very slow and take 64K bytes
409of memory just for mold and mnew.
410It was intended for 100 by 100 windows with objects in the center
411of them, and is quite fast for such windows.
412.TP
413.B vidinv()
414Set inverse video mode.
415.TP
416.B vidnorm()
417Set normal video mode.
418.TP
419.B zermat(m, rows, cols) bitmat m;
420Set the bit matrix
421.I m
422to all zeros.
423.TP
424.B zoomn(size)
425Set the hardware zoom to value
426.I size,
427which can range from 1 to 15.
428.TP
429.B zoomoff()
430Turn zoom off.
431This forces the screen to zoom level 1 without affecting the
432current internal zoom number.
433.TP
434.B zoomon()
435Turn zoom on.
436This restores the screen to the previously specified zoom size.
437.SH DIAGNOSTICS
438The routine
439.I error
440is called when an error is detected.
441The only error currently detected is overflow of the buffer
442provided to
443.IR readline .
444.PP
445Subscripts out of bounds to
446.I setmat
447return without setting anything.
448.SH FILES
449/usr/lib/lib2648.a
450.SH "SEE ALSO"
451fed(1)
452.SH AUTHOR
453Mark Horton
454.SH BUGS
455This library is not supported.
456It makes no attempt to use all of the features of the terminal,
457only those needed by fed.
458Contributions from users will be accepted for addition to the library.
459.PP
460The HP 2648 terminal is somewhat unreliable at speeds over 2400 baud,
461even with the ^E/^F handshaking.
462In an effort to improve reliability, handshaking is done every 32 characters.
463(The manual claims it is only necessary every 80 characters.)
464Nonetheless, I/O errors sometimes still occur.
465.PP
466There is no way to control the amount of debugging output generated
467on
468.I trace
469without modifying the source to the library.