📄 lib2648.3x
字号:
.\" SCCSID: @(#)lib2648.3x 8.1 9/11/90.TH lib2648 3x "" "" Unsupported.SH Namelib2648 \- subroutines for the HP 2648 graphics terminal.SH Syntax.B #include <stdio.h>.sp.B "typedef char".RB * bitmat ;.brFILE *trace;.spcc file.c.B \-l2648.SH Description.I Lib2648is a general purpose library of subroutines usefulfor interactive graphics on the Hewlett-Packard 2648 graphics terminal.To use it you must call the routine.IR ttyinit ()at the beginning of execution,and.IR done ()at the end of execution.All terminal input and output must go through the routines.IR rawchar ,.IR readline ,.IR outchar ,and.IR outstr ..PP.I Lib2648does the necessary ^E/^F handshaking if.I "getenv(``TERM'')"returns ``hp2648'', as it will if set by.IR tset (1).Any other value, including for example ``2648'', will disable handshaking..PPBit matrix routines are provided to model the graphics memory of the 2648.These routines are generally useful, but are specifically useful for the.I updatefunction which efficiently changes what is on the screen to what issupposed to be on the screen.The primative bit matrix routines are.IR newmat ,.IR mat ,and.IR setmat ..PPThe file.IR trace ,if non-null, is expected to be a file descriptor as returned by.IR fopen .If so,.I lib2648will trace the progress of the output by writing ontothis file.It is provided to make debugging output feasible for graphics programs withoutmessing up the screen or the escape sequences being sent.Typical use of trace will include:.nf \fBswitch\fP (argv[1][1]) { \fBcase\fP 'T': trace = fopen("trace", "w"); \fBbreak\fP; ... \fBif\fP (trace) fprintf(trace, "x is %d, y is %s\en", x, y); ... dumpmat("before update", xmat);.fi.SH Routines.TP.B agoto(x, y)Move the alphanumeric cursor to position (x, y),measured from the upper left corner of the screen..TP.B aoff()Turn the alphanumeric display off..TP.B aon()Turn the alphanumeric display on..TP.B areaclear(rmin, cmin, rmax, cmax)Clear the area on the graphics screen bordered by the four arguments.In normal mode the area is set to all black, in inverse video modeit is set to all white..TP.B beep()Ring the bell on the terminal..TP.B bitcopy(dest, src, rows, cols) bitmat dest, src;Copy a.I rowsby.I colsbit matrix from.I srcto (user provided).I dest..TP.B cleara()Clear the alphanumeric display..TP.B clearg()Clear the graphics display.Note that the 2648 will only clear the part of the screenthat is visible if zoomed in..TP.B curoff()Turn the graphics cursor off..TP.B curon()Turn the graphics cursor on..TP.B dispmsg(str, x, y, maxlen) char *str;Display the message .I strin graphics text at position.I (x, y).The maximum message length is given by.IR maxlen ,and is needed to for dispmsg to know how big an area to clearbefore drawing the message.The lower left corner of the first character is at.I (x, y)..TP.B done()Should be called before the program exits.Restores the tty to normal, turns off graphics screen,turns on alphanumeric screen, flushes the standard output, etc..TP.B draw(x, y)Draw a line from the pen location to.I (x, y).As with all graphics coordinates,.I (x, y)is measured from the bottom left corner of the screen..I (x, y)coordinates represent the first quadrant of the usual Cartesian system..TP.B drawbox(r, c, color, rows, cols)Draw a rectangular box on the graphics screen.The lower left corner is at location.I (r, c).The box is.I rowsrows high and.I colscolumns wide.The box is drawn if.I coloris 1, erased if.I coloris 0..I (r, c)absolute coordinates represent row and column on the screen,with the origin at the lower left.They are equivalent to.I (x, y)except for being reversed in order..TP.B "dumpmat(msg, m, rows, cols) char *msg; bitmat m;"If.I traceis non-null, write a readable ASCII representationof the matrix.I mon.I trace..I Msgis a label to identify the output..TP.B emptyrow(m, rows, cols, r) bitmat m;Returns 1 if row.I rof matrix.I mis all zero, else returns 0.This routine is provided because it can be implemented moreefficiently with a knowledge of the internal representationthan a series of calls to.I mat..TP.B error(msg) char *msg;Default error handler.Calls.I message(msg)and returns.This is called by certain routines in.IR lib2648 .It is also suitable for calling by the user program.It is probably a good idea for a fancy graphics programto supply its own error procedure which uses.IR setjmp (3)to restart the program..TP.B gdefault()Set the terminal to the default graphics modes..TP.B goff()Turn the graphics display off..TP.B gon()Turn the graphics display on..TP.B koff()Turn the keypad off..TP.B kon()Turn the keypad on.This means that most special keys on the terminal (such as the alphanumericarrow keys) will transmit an escape sequence instead of doing their functionlocally..TP.B line(x1, y1, x2, y2)Draw a line in the current mode from.I (x1, y1)to.I (x2, y2).This is equivalent to.I "move(x1, y1); draw(x2, y2);"except that a bug in the terminal involving repeated lines from thesame point is compensated for..TP.B lowleft()Move the alphanumeric cursor to the lower left (home down) position..TP.B "mat(m, rows, cols, r, c) bitmat m;"Used to retrieve an element from a bit matrix.Returns 1 or 0 as the value of the.I [r, c]element of the.I rowsby.I colsmatrix.I m.Bit matrices are numbered.I (r, c)from the upper left corner of the matrix,beginning at (0, 0)..I Rrepresents the row, and.I crepresents the column..TP.B message(str) char *str;Display the text message.I strat the bottom of the graphics screen..TP.B "minmax(g, rows, cols, rmin, cmin, rmax, cmax) bitmat g;".ti -.5i.B int *rmin, *cmin, *rmax, *cmax;.brFind the smallest rectangle that contains all the 1 (on) elements inthe bit matrix g.The coordinates are returned in the variablespointed to by rmin, cmin, rmax, cmax..TP.B move(x, y)Move the pen to location.I (x, y).Such motion is internal and will not cause outputuntil a subsequent.I sync()..TP.B movecurs(x, y)Move the graphics cursor to location.I (x, y)..TP.B bitmat newmat(rows, cols)Create (with.IR malloc (3))a new bit matrix of size.I rowsby.I cols.The value created (e.g. a pointer to the first location) is returned.A bit matrix can be freed directly with.IR free ..TP.B outchar(c) char c;Print the character.I con the standard output.All output to the terminal should go through this routine or.IR outstr ..TP.B outstr(str) char *str;Print the string str on the standard output by repeated calls to.I outchar..TP.B printg()Print the graphics display on the printer.The printer must be configured as device 6 (the default) on the HPIB..TP.B char rawchar()Read one character from the terminal and return it.This routine or.I readlineshould be used to get all input,rather than.IR getchar (3)..TP.B rboff()Turn the rubber band line off..TP.B rbon()Turn the rubber band line on..TP.B char *rdchar(c) char c;Return a readable representation of the character.I c.If.I cis a printing character it returns itself, if a controlcharacter it is shown in the ^X notation, if negativean apostrophe is prepended. Space returns ^\`, rubout returns ^?..IP.B NOTE:A pointer to a static place is returned.For this reason, it will not work to pass rdchar twice to the same.IR fprintf / sprintfcall.You must instead save one of the values in your own buffer with strcpy..TP.B readline(prompt, msg, maxlen) char *prompt, *msg;Display.I prompton the bottom line of the graphics displayand read one line of text from the user, terminated by a newline.The line is placed in the buffer.IR msg ,which has size.I maxlencharacters.Backspace processing is supported..TP.B setclear()Set the display to draw lines in erase mode.(This is reversed by inverse video mode.).TP.B "setmat(m, rows, cols, r, c, val) bitmat m;"The basic operation to store a value in an element of a bit matrix.The.I [r, c]element of.I mis set to.I val,which should be either 0 or 1..TP.B setset()Set the display to draw lines in normal (solid) mode.(This is reversed by inverse video mode.).TP.B setxor()Set the display to draw lines in exclusive or mode..TP.B sync()Force all accumulated output to be displayed on the screen.This should be followed by fflush(stdout).The cursor is not affected by this function.Note that it is normally never necessary to call.IR sync ,since.I rawcharand.I readlinecall.I sync()and.I fflush(stdout)automatically..TP.B togvid()Toggle the state of video.If in normal mode, go into inverse video mode,and vice versa.The screen is reversed as well as theinternal state of the library..TP.B ttyinit()Set up the terminal for processing.This routine should be called at the beginning of execution.It places the terminal in CBREAK mode, turns off echo,sets the proper modes in the terminal,and initializes the library..TP.B "update(mold, mnew, rows, cols, baser, basec) bitmat mold, mnew;"Make whatever changes are needed to make a window on the screenlook like.IR mnew ..I Moldis what the window on the screen currently looks like.The window has size.I rowsby.IR cols ,and the lower left corner onthe screen of the window is.I [baser, basec].Note:.I updatewas not intended to be used for the entire screen.It would work but be very slow and take 64K bytesof memory just for mold and mnew.It was intended for 100 by 100 windows with objects in the centerof them, and is quite fast for such windows..TP.B vidinv()Set inverse video mode..TP.B vidnorm()Set normal video mode..TP.B zermat(m, rows, cols) bitmat m;Set the bit matrix.I mto all zeros..TP.B zoomn(size)Set the hardware zoom to value.I size,which can range from 1 to 15..TP.B zoomoff()Turn zoom off.This forces the screen to zoom level 1 without affecting thecurrent internal zoom number..TP.B zoomon()Turn zoom on.This restores the screen to the previously specified zoom size..SH DiagnosticsThe routine.I erroris called when an error is detected.The only error currently detected is overflow of the bufferprovided to.IR readline ..PPSubscripts out of bounds to.I setmatreturn without setting anything..SH Files/usr/lib/lib2648.a.SH See Alsofed(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -