      A MFB(3)              UNIX Programmer's Manual               MFB(3)'       NAME'      mfb - model frame buffer interface3   SYNOPSIS9      #include <~cad/include/mfb.h> in the program source. 9      cc [ flags ] files  ~cad/lib/mfb.a -lm [ libraries ]e     DESCRIPTION<      These routines provide the user with a virtual graphics<      interface.  They perform the terminal dependent task of?      encoding/decoding graphics code, thereby allowing the user =      to write graphics programs to run on almost any graphics1      device.  @      The user opens and initializes a graphics device by callingN      the _M_F_B_O_p_e_n routine that returns a pointer to that device'sD      _M_F_B data structure defined at the end of this manual.  ByG      maintaining several _M_F_B data structures, an application pro-<      gram can drive several graphics devices simultaneously.C      Once opened, _M_F_B graphics routines can be called to draw >      geometries, draw graphics text, set device parameters, orA      receive keyboard input.  An application program can also use'@      any of the several utility routines that perform line clip-@      ping, polygon clipping, or window/viewport transformations.>      Control of the graphics device is released by calling the&      _M_F_B_C_l_o_s_e routine.  C      All programs that use _M_F_B routines must include the file3K      _m_f_b._h that defines the _M_F_B data structure to contain thex5      information provided by _M_F_B_C_A_P(_5).n     INITIALIZATION ROUTINES|6      MFB *MFBOpen(TerminalName, DeviceName, errorcode)%      char *TerminalName, *DeviceName;       int *errorcode;M           _M_F_B_O_p_e_n initializes the graphics device and fills thenU           _M_F_B data structure with information found in _M_F_B_C_A_P(_5).(W           _T_e_r_m_i_n_a_l_N_a_m_e is a pointer to a null terminated stringn?           containing the name of the graphics device as defined4H           in the _m_f_b_c_a_p database file.  This argument has noU           default and can never be null.  _D_e_v_i_c_e_N_a_m_e is a pointer4>           to a null terminated string containing the full pathJ           name to the respective graphics device. If null, _s_t_d_i_n]           and _s_t_d_o_u_t are used by default.  _e_r_r_o_r_c_o_d_e is a diag-\H           nostic integer returned by _M_F_B_O_p_e_n. The possibleZ           returned values for _e_r_r_o_r_c_o_d_e are defined in the _m_f_b._h           file as follows:            A Printed 9/3/83               6/21/83                            1            A MFB(3)              UNIX Programmer's Manual               MFB(3)3      >           #define MFBOK           1    /* successful return */B           #define MFBBADENT      -10   /* Unknown terminal type */C           #define MFBBADMCF      -20   /* Can't open MFBCAP file */(B           #define MFBMCELNG      -30   /* MFBCAP entry too long */=           #define MFBBADMCE      -40   /* Bad MFBCAP entry */'J           #define MFBINFMCE      -50   /* infinite loop in MFBCAP entry */?           #define MFBBADTTY      -60   /* stdout not in /dev */WG           #define MFBBADDEV      -180  /* Can't open or close device */nL           #define MFBBADOPT      -190  /* Can't access or set device stat */?           #define MFBBADWRT      -220  /* Error during write */  *           Only MFBOK is not a fatal error.          void SetCurrentMFB(mfb)      MFB *mfb;Z           _S_e_t_C_u_r_r_e_n_t_M_F_B allows the application program to define?           the current graphics device.  All subsequent calls to7G           _M_F_B routines will affect the specified device.  BecausenB           each _M_F_B data structure contains a separate output@           buffer, it is not necessary to flush the output beforeM           resetting the current output device.  _M_F_B_O_p_e_n returnsu@           with the opened graphics device defined as the current           output device.          int MFBInitialize()R           _M_F_B_I_n_i_t_i_a_l_i_z_e will flush the output buffer and<           (re)initialize the device for graphics input.  The=           graphics device or standard input will be placed in H           CBREAK mode.  See the manual _t_t_y(_4). MFBOK is returned?           if the device was successfully initialized; MFBBADOPTd@           is returned if an error was encountered while attempt-?           ing to access or set the device status, and MFBBADTTY <           is returned if standard output can bot be found or           accessed._          int MFBClose()eP           _M_F_B_C_l_o_s_e will flush the output buffer and release con->           trol of the graphics device driver.  If the graphicsA           device is a _t_t_y, it is returned to the state thateO           existed prior to the respective _M_F_B_O_p_e_n call.  MFBOK is_@           returned if the device was successfully closed; MFBBA-<           DOPT is returned if an error was encountered while<           attempting to access or set the device status, andA           MFBBADDEV is returned if the output device could not be            closed.'              A Printed 9/3/83               6/21/83                            2u            A MFB(3)              UNIX Programmer's Manual               MFB(3)t            int MFBHalt()M           _M_F_B_H_a_l_t will flush the output buffer and release con- >           trol of the graphics device driver.  If the graphicsA           device is a _t_t_y, it is returned to the state that \           existed prior to the respective _M_F_B_O_p_e_n call.  _M_F_B_H_a_l_tN           differs from _M_F_B_C_l_o_s_e in that the memory occupied byA           the respective, current _M_F_B data structure is notsY           freed.  By calling _M_F_B_I_n_i_t_i_a_l_i_z_e, the graphics device @           will be reinitialized.  This routine is typically usedA           by an application program for handling the SIGTSTP sig-t=           nal (the keyboard stop signal, usually control-Z ).h:           MFBOK is returned if the device was successfullyA           returned to its initial state; MFBBADOPT is returned if @           an error was encountered while attempting to access or            set the device status.     SETTING DEVICE PARAMETERSeA      Each of the following routines for setting device parameterseG      returns a diagnostice integer that is defined in the _m_f_b._hr      file as follows:d  9      #define MFBOK           1    /* successful return */:      #define MFBBADLST      -70   /* Illegal line style */:      #define MFBBADFST      -80   /* Illegal fill style */;      #define MFBBADCST      -90   /* Illegal color style */i@      #define MFBBADTM1      -100  /* No destructive text mode */A      #define MFBBADTM2      -110  /* No overstriking text mode */F=      #define MFBNOBLNK      -150  /* No definable blinkers */l9      #define MFBTMBLNK      -160  /* Too many blinkers */sG      #define MFBNOMASK      -170  /* No definable read or write mask */n;      #define MFBBADALU      -250  /* Cannot set ALU mode */_    !      int MFBSetLineStyle(styleId)       int styleId; [           _M_F_B_S_e_t_L_i_n_e_S_t_y_l_e sets the current line style to that_N           identified by the integer _s_t_y_l_e_I_d that is greater thanQ           or equal to zero and less than the value of _m_a_x_L_i_n_e_S_-cU           _t_y_l_e_s in the _M_F_B data structure.  The value of _m_a_x_-c_           _L_i_n_e_S_t_y_l_e_s can be obtained from the _M_F_B_I_n_f_o routinenL           defined below.  Zero is always the _s_t_y_l_e_I_d for solidG           lines.  Except for the solid line style, _M_F_B assumes nog@           default set of lines styles.  MFBOK is returned if the>           line style was successfully set to that specified byX           _s_t_y_l_e_I_d or if _s_t_y_l_e_I_d was already the current lineN           style; MFBBADLST is returned if _s_t_y_l_e_I_d has an illegal           value.              A Printed 9/3/83               6/21/83                            3             A MFB(3)              UNIX Programmer's Manual               MFB(3)       #      int MFBSetFillPattern(styleId)o      int styleId;Mc           _M_F_B_S_e_t_F_i_l_l_P_a_t_t_e_r_n sets the current fill pattern to thattN           identified by the integer _s_t_y_l_e_I_d that is greater thanW           or equal to zero and less than the value of _m_a_x_F_i_l_l_P_a_t_-oU           _t_e_r_n_s in the _M_F_B data structure.  The value of _m_a_x_-_e           _F_i_l_l_P_a_t_t_e_r_n_s can be obtained from the _M_F_B_I_n_f_o routine O           defined below.  Solid fill is always defined by _s_t_y_l_e_I_d E           equal to zero.  Other than solid fill, _M_F_B assumes noKA           default set of fill patterns.  MFBOK is returned if theB>           fill style was successfully set to that specified byX           _s_t_y_l_e_I_d or if _s_t_y_l_e_I_d was already the current fillN           style; MFBBADFST is returned if _s_t_y_l_e_I_d has an illegal           value.    '      int MFBSetChannelMask(channelMask)B      int channelMask; b           _M_F_B_S_e_t_C_h_a_n_n_e_l_M_a_s_k defines the current write mask to beQ           the value of _c_h_a_n_n_e_l_M_a_s_k. The channel mask allows A           specific memory planes to be written and erased without @           disturbing other memory planes.  The least significantU           bit of _c_h_a_n_n_e_l_M_a_s_k corresponds to the masked value ofy@           the first memory plane, etc.  If the corresponding bit<           is zero, the memory plane is write-protected.  The:           number of memory planes can be obtained from theL           _M_F_B_I_n_f_o routine defined below.  MFBOK is returned ifU           the write mask was successfully set to _c_h_a_n_n_e_l_M_a_s_k or R           if _c_h_a_n_n_e_l_M_a_s_k was already the current write mask;?           MFBNOMASK is returned if the graphics device does not_&           have a definable write mask.    !      int MFBSetReadMask(readmask)M      int readmask;\           _M_F_B_S_e_t_R_e_a_d_M_a_s_k defines the current read mask to be theO           value of _r_e_a_d_m_a_s_k. The read mask allows only specific=           memory planes to be read.  MFBOK is returned if theBZ           read mask was successfully set to _r_e_a_d_M_a_s_k or if _r_e_a_d_-G           _M_a_s_k was already the current read mask;  MFBNOMASK is @           returned if the graphics device does not have a defin-           able read mask.e                          A Printed 9/3/83               6/21/83                            4_            A MFB(3)              UNIX Programmer's Manual               MFB(3)             int MFBSetColor(colorId)       int colorId; U           _M_F_B_S_e_t_C_o_l_o_r sets the current foreground color to that N           identified by the integer _c_o_l_o_r_I_d that is greater thanQ           or equal to zero and less than the value of _m_a_x_C_o_l_o_r_sX           in the _M_F_B data structure.  The value of _m_a_x_C_o_l_o_r_s canK           be obtained from the _M_F_B_I_n_f_o routine defined below.sG           There is no default color map in _M_F_B. MFBOK is returnedh>           if the foreground color was successfully set to thatX           specified by _c_o_l_o_r_I_d or if _c_o_l_o_r_I_d was already the<           current foreground color; MFBBADCST is returned if5           _c_o_l_o_r_I_d has an illegal value.     (      int MFBSetTextMode(destructiveBool)      Bool destructiveBool;]           _M_F_B_S_e_t_T_e_x_t_M_o_d_e defines whether subsequent graphics textlP           will overstrike or replace previous text.  If _d_e_s_t_r_u_c_-O           _t_i_v_e_B_o_o_l is true, the text mode is set to destructives?           which means that graphic text will set the backgroundO?           color of the font grid to the color that is specifiedM@           by color style zero depending on the currently defined=           ALU operation.  Overstriking mode will only set the @           pixels of the character font to the current foreground?           color.  MFBOK is returned if the graphic text writingiQ           mode was successfully set to that specified by _d_e_s_t_r_u_c_-tn           _t_i_v_e_B_o_o_l or if _d_e_s_t_r_u_c_t_i_v_e_B_o_o_l was already the current>           graphic text writing mode;  MFBBADTM1 is returned ifA           the graphics device does not have a destructive graphicn>           text mode, and MFBBADTM2 is returned if the graphicsA           device does not have an overstriking graphic text mode.e          int MFBSetALUMode(alumode)n      int alumode; X           _M_F_B_S_e_t_A_L_U_M_o_d_e changes the mode by which the graphics;           display is changed when an area of the display islA           over-written.  The four possible modes are JAM (replaceA           mode), OR, EOR (exclusive OR), and NOR.  The four validMc           arguments to _M_F_B_S_e_t_A_L_U_M_o_d_e are defined in _m_f_b._h as fol-e           lows:e  @           #define MFBALUJAM      0     /* set ALU mode to JAM */?           #define MFBALUOR       1     /* set ALU mode to OR */c@           #define MFBALUNOR      2     /* set ALU mode to NOR */@           #define MFBALUEOR      3     /* set ALU mode to EOR */  @           MFBOK is returned if the ALU mode was successfully set\           to that specified by _a_l_u_m_o_d_e or if _a_l_u_m_o_d_e was already>           the current ALU operation;  MFBBADALU is returned if?           the graphics device does not have the ALU mode speci-w\           fied by _a_l_u_m_o_d_e or if _a_l_u_m_o_d_e is an invalid or illegal      A Printed 9/3/83               6/21/83                            5c            A MFB(3)              UNIX Programmer's Manual               MFB(3)n                 argument.S    .      int MFBSetCursorColor(colorId1, colorId2)      int colorId1, colorId2;_           _M_F_B_S_e_t_C_u_r_s_o_r_C_o_l_o_r sets the graphics cursor to blink_K           between the two colors identified by _c_o_l_o_r_I_d_1 andl^           _c_o_l_o_r_I_d_2. The constraints on the values for _c_o_l_o_r_I_d_1d           and _c_o_l_o_r_I_d_2 are the same as for _M_F_B_S_e_t_C_o_l_o_r defined?           above.  The frequency of the blinking cursor is fixedhK           and can be changed only by modifying the _m_f_b_c_a_p data-f>           base file.  MFBOK is returned if the blinking cursor?           colors were successfully set to the specified colors.r    *      int MFBSetRubberBanding(onFlag, X, Y)      int X, Y;      Bool onFlag;of           _M_F_B_S_e_t_R_u_b_b_e_r_B_a_n_d_i_n_g enables/disables rubber banding ofK           the pointing device.  If _o_n_F_l_a_g is false, then rubbert;           banding is disabled.  When enabled, the center of A           rubber banding is at _X, _Y. Rubber banding is alwaysiA           disabled immediately after the pointing device has been @           used.  MFBOK is returned if the rubberbanding mode wasM           successfully set to that specified by _o_n_F_l_a_g; MFBNORBND_?           is returned if the graphics device does not have rub-i,           berbanding in the pointing device.    9      int MFBSetBlinker(colorId, red, green, blue, onFlag)m      int colorId;c      int red, green, blue;      int onFlag;g           _M_F_B_S_e_t_B_l_i_n_k_e_r enables the color identified by _c_o_l_o_r_I_d>           to blink between its currently defined color and theY           color defined by the _r_e_d, _g_r_e_e_n, _b_l_u_e combination.  TheLX           values of _r_e_d, _g_r_e_e_n, and _b_l_u_e are normalized to 1000.G           If _o_n_F_l_a_g is zero, the blinking is disabled.  TheA           number of colors that may be defined as blinkers at any U           given time must be less than the value of _m_a_x_B_l_i_n_k_e_r_s G           in the _M_F_B data structure.  The frequency of the blink-o@           ing colors is fixed and can be changed only by modify-M           ing the _m_f_b_c_a_p database file.  MFBOK is returned if the_N           color specified by _c_o_l_o_r_I_d was successfully set to the=           desired blinking mode; MFBNOBLNK is returned if thes@           graphics device does not have blinking VLT layers, and=           MFBTMBLNK is returned if there are already too manyi!           active blinking layers.S              A Printed 9/3/83               6/21/83                            6             A MFB(3)              UNIX Programmer's Manual               MFB(3)        DEFINING DEVICE PARAMETERS?      Each of the following routines for defining device parame- ?      ters returns a negative value if any difficulty is encoun-H      tered.  The possible returned integers are defined in _m_f_b._h      as follows:  9      #define MFBOK           1    /* successful return */ B      #define MFBNODFLP      -120  /* No definable line patterns */B      #define MFBNODFFP      -130  /* No definable fill patterns */;      #define MFBNODFCO      -140  /* No definable colors */c    2      int MFBDefineColor(colorId, red, green, blue)      int colorId;o      int red, green, blue;Z           _M_F_B_D_e_f_i_n_e_C_o_l_o_r redefines the VLT entry for the colorL           identified by _c_o_l_o_r_I_d to be the color represented byh           the _r_e_d, _g_r_e_e_n, _b_l_u_e combination where _r_e_d, _g_r_e_e_n, and>           _b_l_u_e are normalized to 1000.  Once the colorM           corresponding to _c_o_l_o_r_I_d is redefined, all geometriesn>           that were written onto the display of a frame bufferM           with _c_o_l_o_r_I_d as the current color will become the newcN           color.  MFBOK is returned if the VLT entry for _c_o_l_o_r_I_d@           was successfully defined; MFBNODFCO is returned if the.           graphics device does not have a VLT.    0      int MFBDefineFillPattern(styleId, BitArray)      int styleId;t      int *BitArray;ei           _M_F_B_D_e_f_i_n_e_F_i_l_l_P_a_t_t_e_r_n redefines the fill pattern identi-g]           fied by _s_t_y_l_e_I_d and returns with _s_t_y_l_e_I_d as the current,Q           fill style.  _B_i_t_A_r_r_a_y is a pointer to an array of eight ?           integers whose least significant eight bits represente?           individual rows in an eight by eight intensity array.B@           For example, a fill pattern with an ascending diagonal>           line may be defined by the following eight (decimal)           integers:d    4                             1 2 4 8 16 32 64 128 256    >           A diagonal-grid fill pattern can be defined with the"           following integer array:    5                           257 130 68 40 40 68 130 257h              A Printed 9/3/83               6/21/83                            7y            A MFB(3)              UNIX Programmer's Manual               MFB(3)       O           MFBOK is returned if the new fill style for _s_t_y_l_e_I_d wasP=           successfully defined;  MFBNODFFP is returned if the @           graphics device does not have definable fill patterns.    *      int MFBDefineLineStyle(styleId, Mask)      int styleId;       int Mask;e           _M_F_B_D_e_f_i_n_e_L_i_n_e_S_t_y_l_e defines the line style identified byBN           _s_t_y_l_e_I_d to be the pattern contained in the eight leastT           significant bits of _M_a_s_k and returns with _s_t_y_l_e_I_d as@           the current line style.  MFBOK is returned if the lineN           style for _s_t_y_l_e_I_d was successfully defined;  MFBNODFFPA           is returned if the graphics device does not have defin-n           able line patterns.e     INPUT/OUTPUT ROUTINES       int MFBUpdate()O           _M_F_B_U_p_d_a_t_e flushes the internal output buffer to theg=           currently defined output device and will ignore any@           write error that may occur.  A call to this routine is?           ABSOLUTELY necessary to complete any graphics displayeQ           sequence.  _M_F_B_U_p_d_a_t_e returns the number of characters3=           sent to the output graphics device or -1 if a write            error occured.    $      int MFBPoint(X, Y, key, button)      int *X, *Y, *button;C      char *key;dP           _M_F_B_P_o_i_n_t enables the graphics pointing device and then>           waits for user input.  If a keyboard key is pressed,W           _M_F_B_P_o_i_n_t returns with _k_e_y containing the character thato:           was pressed.  If the pointing device is pressed,O           _M_F_B_P_o_i_n_t returns with the identified viewport coordi-MI           nate _X, _Y, the contents of _k_e_y equal to zero, and thetA           button mask of the button that was pushed.  The integerm[           array _b_u_t_t_o_n_M_a_s_k in the _M_F_B data structure contains alln;           possible button mask values that can be returned.fQ           _M_F_B_P_o_i_n_t returns one of the following values defined inB!           the _m_f_b._h file:S  >           #define MFBOK           1    /* successful return */E           #define MFBPNTERR      -230  /* Error in pointing device */s?           #define MFBNOPTFT      -240  /* No pointing format */d?           #define MFBNOPNT       -260  /* No pointing device */                 A Printed 9/3/83               6/21/83                            8e            A MFB(3)              UNIX Programmer's Manual               MFB(3)       4      char *MFBKeyboard(X, Y, background, foreground)      int background;      int foreground;      int X, Y;W           _M_F_B_K_e_y_b_o_a_r_d enables the graphics keyboard and waits forcA           user input.  A pointer to a character buffer containinglV           the keyboard input is returned by _M_F_B_K_e_y_b_o_a_r_d when the@           user presses the return or linefeed key.  Backspace is=           control-H or the delete character, and control-X orr@           control-U will kill the line.  Pressing the ESCAPE keyV           will cause _M_F_B_K_e_y_b_o_a_r_d to return with a null string in%           the input character buffer.   >           All keyboard input is displayed in the viewport withC           the lower left corner at the viewport coordinate _X, _YT           and is constrained to fit on one line.  _B_a_c_k_g_r_o_u_n_d andP           _f_o_r_e_g_r_o_u_n_d are the background and foreground colorA           styles respectively in which the keyboard input will bep           displayed.          void MFBAudio()N           _M_F_B_A_u_d_i_o will ring the bell or alarm on the graphics?           device.  If the graphics device does not have a bell,M;           then a control-G will be sent to standard output.c          int MFBPutchar(c)      char c;        int MFBPutstr(cp,nchars)g      int nchars;      char *cp;        int MFBGetchar()bC           These three routines are used internally by _M_F_B and ?           typically are not used within an application program. J           They are comparable to the _s_t_d_i_o routines having simi-W           lar names.  _M_F_B_P_u_t_c_h_a_r places a character _c in the out-_Q           put buffer.  _M_F_B_P_u_t_s_t_r inserts a string pointed to byhQ           _c_p containing _n_c_h_a_r_s characters into the output buffer.rI           The _n_c_h_a_r_s argument is necessary to permit embeddedu?           null characters in the output stream.  The charactersl<           remain in the output buffer until the next call toP           _M_F_B_U_p_d_a_t_e or until the contents of the output buffer!           exceed 4096 characters.p  U           _M_F_B_G_e_t_c_h_a_r returns a single character from the graphics ?           input device.  If the graphics device does not have a <           keyboard, input is obtained from the terminal from<           which the application program was invoked.  If theF           graphics device is a _t_t_y, it should be remembered that      A Printed 9/3/83               6/21/83                            9i            A MFB(3)              UNIX Programmer's Manual               MFB(3)o                 it is in CBREAK mode.t    ! TWO DIMENSIONAL GEOMETRY ROUTINESa>      All coordinates that are passed to the following geometry?      routines are with respect to the display resolution of the G      graphics device.  _M_F_B assumes that the lower, left corner ofe>      the display is the origin with an absolute coordinate (0,6      0).  All coordinate values are positive integers.        void MFBMoveTo(X1, Y1)       int X1, Y1;[           _M_F_B_M_o_v_e_T_o sets the current graphics position to _X_1, _Y_1.?           No line will be drawn from the old graphics position.e          void MFBDrawLineTo(X1, Y1)       int X1, Y1;X           _M_F_B_D_r_a_w_L_i_n_e_T_o draws a line from the current graphicsI           position to _X_1, _Y_1 in the current line style and color.lD           The current graphics position then becomes _X_1, _Y_1.    !      void MFBLine(X1, Y1, X2, Y2)       int X1, Y1, X2, Y2;J           _M_F_B_L_i_n_e draws a line in the current line style and6           color from _X_1, _Y_1 to _X_2, _Y_2.    *      void MFBBox(left, bottom, right, top)"      int left, bottom, right, top;M           _M_F_B_B_o_x displays a rectangle in the current fill pattern U           and color with diagonal coordinates at _l_e_f_t, _b_o_t_t_o_m and %           _r_i_g_h_t, _t_o_p.P          void MFBDrawPath(path)r      MFBPATH *path;tW           _M_F_B_D_r_a_w_P_a_t_h draws a path of vectors in the current linesI           style and color.  _P_a_t_h is a pointer to a data structure_7           defined in the _m_f_b._h file as follows:              struct mfbpath {E                 int nvertices; /* number of (x,y) coordinate pairs */sJ                 int *xy;       /* pointer to array of (x,y) coordinates */                 };  )           typedef struct mfbpath MFBPATH;   A           The contents of the coordinate array are organized suchn=           that xy[0] is the x coordinate of the first vertex,eA           xy[1] is the y coordinate of the first vertex, xy[2] is       A Printed 9/3/83               6/21/83                           10a            A MFB(3)              UNIX Programmer's Manual               MFB(3)      5           the x coordinate of the second vertex, etc.r          void MFBFlood()O           _M_F_B_F_l_o_o_d erases a frame buffer display to the currentFV           color as previously defined by _M_F_B_S_e_t_C_o_l_o_r. The result;           would be the same as drawing a solid box over theo           entire display.E          void MFBPixel(X, Y)      int X, Y;U           _M_F_B_P_i_x_e_l sets the pixel at location _X, _Y on the displayu7           to the current color as previously defined bya,           _M_F_B_S_e_t_C_o_l_o_r.    &      void MFBCircle(X, Y, rad, nsides)      int X, Y, rad, nsides;vL           _M_F_B_C_i_r_c_l_e draws the perimeter of a circle in theB           current line style and color with center at _X, _Y andQ           with radius _r_a_d. The argument _n_s_i_d_e_s is the number ofo>           line segments with which the circle will be drawn ifA           the frame buffer does not have a circle primitive.  Theo9           default value for _n_s_i_d_e_s is twenty.1    %      void MFBFlash(X, Y, rad, nsides)       int X, Y, rad, nsides;sQ           _M_F_B_F_l_a_s_h draws a round flash with the current fill pat-tJ           tern and color with center at _X, _Y and radius _r_a_d. TheI           argument _n_s_i_d_e_s is the number of line segments with ?           which the flash will be drawn.  The default value foro'           _n_s_i_d_e_s is twenty._    3      void MFBArc(X, Y, rad, angle1, angle2, nsides)       int X, Y, rad;d       int angle1, angle2, nsides;M           _M_F_B_A_r_c draws an arc in the current line style and coloriH           with center at _X, _Y and with radius _r_a_d beginning atK           _a_n_g_l_e_1 with respect to the positive y-axis and endingnG           at _a_n_g_l_e_2 in a counter-clockwise direction.  Bothe@           angles are in degrees and are greater than or equal to;           zero and less than or equal to 360.  The argumentiL           _n_s_i_d_e_s is the number of line segments with which a 360M           degree arc will be drawn.  The default value for _n_s_i_d_e_s            is twenty.              A Printed 9/3/83               6/21/83                           11r            A MFB(3)              UNIX Programmer's Manual               MFB(3)v            void MFBPolygon(poly)      MFBPOLYGON *poly;S           _M_F_B_P_o_l_y_g_o_n draws a polygon with the current fill pat-aH           tern and color.  _P_o_l_y is a pointer to a data structure7           defined in the _m_f_b._h file as follows:F             struct mfbpolygon { E                 int nvertices; /* number of (x,y) coordinate pairs */_J                 int *xy;       /* pointer to array of (x,y) coordinates */                 };  /           typedef struct mfbpolygon MFBPOLYGON;e  A           The contents of the coordinate array are organized such =           that xy[0] is the x coordinate of the first vertex,cA           xy[1] is the y coordinate of the first vertex, xy[2] ise:           the x coordinate of the second vertex, etc.  TheO           difference between the _M_F_B_P_O_L_Y_G_O_N typedef and the_`           _M_F_B_P_A_T_H typedef defined above is that the _M_F_B_P_O_L_Y_G_O_N>           struct is assumed to define a closed path of coordi-           nates.    ;      MFBPATH *MFBArcPath(X, Y, rad, angle1, angle2, nsides)a      int X, Y, rad;o       int angle1, angle2, nsides;a           _M_F_B_A_r_c_P_a_t_h returns a pointer to a _M_F_B_P_A_T_H struct thattK           contains an arc with center at _X, _Y and with radius _r_a_d M           beginning at _a_n_g_l_e_1 with respect to the positive y-axiseL           and ending at _a_n_g_l_e_2 in a counter-clockwise direction.<           Both angles are in degrees and are greater than orA           equal to zero and less than or equal to 360.  The argu- K           ment _n_s_i_d_e_s is the number of line segments with which M           the arc will be drawn.  The default value for _n_s_i_d_e_s ist           twenty.e    5      MFBPOLYGON *MFBEllipse(X, Y, radx, rady, nsides)3      int X, Y, rad, nsides;eq           _M_F_B_E_l_l_i_p_s_e_P_a_t_h returns a pointer to a _M_F_B_P_O_L_Y_G_O_N structoE           that contains an elliptical polygon with center at _X, _Y I           and with distance _r_a_d_x from the center to an edge alongoI           the x-axis and distance _r_a_d_y from the center to an edge M           along the y-axis.  The argument _n_s_i_d_e_s is the number ofn>           line segments with which the arc will be drawn.  The9           default value for _n_s_i_d_e_s is twenty.                   A Printed 9/3/83               6/21/83                           12             A MFB(3)              UNIX Programmer's Manual               MFB(3)       "      void MFBText(text, X, Y, phi)      char *text;      int X, Y, phi;tO           _M_F_B_T_e_x_t displays a null terminated string pointed to by L           _t_e_x_t with the lower left corner at _X, _Y in the display<           viewport with the current color and rotated at theI           angle _p_h_i in degrees.  The default value for _p_h_i isx           zero./    3      void MFBNaiveBoxFill(left, bottom, right, top)o"      int top, bottom, left, right;^           _M_F_B_N_a_i_v_e_B_o_x_F_i_l_l can be used to draw a filled rectangle>           on a graphics device that does not support fill pat-N           terns.  The _M_F_B_L_i_n_e routine is used to draw rectangles@           with eight different fixed fill styles.  If the graph-@           ics device does not have a command primitive for draw-F           ing a box, then the _M_F_B_B_o_x routine defined aboveD           defaults to _M_F_B_N_a_i_v_e_B_o_x_F_i_l_l.     RASTER ROUTINES /      void MFBRasterCopy(X,Y,DX,DY,DestX,DestY);r      int X,Y,DX,DY,DestX,DestY;iY           _M_F_B_R_a_s_t_e_r_C_o_p_y copies a rectangular area with the bot- E           tom, left corner at _X,_Y and with length _D_X in the XhA           direcion and width _D_Y in the Y direction to an arearS           with the bottom, left corner at _D_e_s_t_X,_D_e_s_t_Y. The modeeA           of the copy operation was specified by the last call toe2           _M_F_B_S_e_t_A_L_U_M_o_d_e.     INFORMATION ACQUISITIONu      int MFBInfo(info);_      int info;J           _M_F_B_I_n_f_o is a routine for obtaining device specificH           information.  The possible values for _i_n_f_o are defined&           in _m_f_b._h as follows:  A           #define MAXX               1     /* max x coordinate */A           #define MAXY               2     /* max y coordinate */_E           #define MAXCOLORS          3     /* max number of colors */nD           #define MAXINTENSITY       4     /* max color intensity */L           #define MAXFILLPATTERNS    5     /* max number of fill patterns */J           #define MAXLINESTYLES      6     /* max number of line styles */G           #define MAXBLINKERS        7     /* max number of blinkers */ M           #define POINTINGDEVICE     8     /* terminal has pointing device */rL           #define POINTINGBUTTONS    9     /* pointing device has buttons */N           #define NUMBUTTONS         10    /* num. of pointing dev. buttons */K           #define BUTTON1            11    /* value returned by button 1 */oK           #define BUTTON2            12    /* value returned by button 2 */_K           #define BUTTON3            13    /* value returned by button 3 */d      A Printed 9/3/83               6/21/83                           13h            A MFB(3)              UNIX Programmer's Manual               MFB(3)u      K           #define BUTTON4            14    /* value returned by button 4 */nK           #define BUTTON5            15    /* value returned by button 5 */ K           #define BUTTON6            16    /* value returned by button 6 */1K           #define BUTTON7            17    /* value returned by button 7 */ K           #define BUTTON8            18    /* value returned by button 8 */ K           #define BUTTON9            19    /* value returned by button 9 */ L           #define BUTTON10           20    /* value returned by button 10 */L           #define BUTTON11           21    /* value returned by button 11 */L           #define BUTTON12           22    /* value returned by button 12 */H           #define TEXTPOSITIONALBE   30    /* Bool: positionable text */E           #define TEXTROTATABLE      31    /* Bool: rotatable text */ F           #define FONTHEIGHT         32    /* font height in pixels */E           #define FONTWIDTH          33    /* font width in pixels */ H           #define FONTXOFFSET        34    /* font x offset in pixels */H           #define FONTYOFFSET        35    /* font y offset in pixels */N           #define DESTRUCTIVETEXT    36    /* Bool: text can be destructive */M           #define OVERSTRIKETEXT     37    /* Bool: text can be overstrike */eG           #define VLT                38    /* Bool: terminal has VLT */nL           #define BLINKERS           39    /* Bool: terminal has blinkers */Q           #define FILLEDPOLYGONS     40    /* Bool: terminal can fill polygons *//N           #define DEFFILLPATTERNS    41    /* Bool: definable fill patterns */K           #define DEFCHANNELMASK     42    /* Bool: definable write mask */sL           #define DEFLINEPATTERN     43    /* Bool: definable line styles */I           #define CURFGCOLOR         44    /* current foreground color */yE           #define CURFILLPATTERN     45    /* current fill pattern */nC           #define CURLINESTYLE       46    /* current line style */pE           #define CURCHANNELMASK     47    /* current channel mask */iB           #define CURREADMASK        48    /* current read mask */E           #define NUMBITPLANES       49    /* number of bit planes */ J           #define DEFREADMASK        50    /* Bool: definable read mask */K           #define RASTERCOPY         51    /* Bool: term has raster copy */ J           #define OFFSCREENX         52    /* left of off screen memory */L           #define OFFSCREENY         53    /* bottom of off screen memory */L           #define OFFSCREENDX        54    /* length of off screen memory */K           #define OFFSCREENDY        55    /* width of off screen memory */   O           If an invalid argument is used, _M_F_B_I_n_f_o will return -1.      WINDOW/VIEWPORT TRANSFORMATIONSnF      _M_F_B provides a set of procedures for converting from window?      coordinates to viewport coordinates and vice versa.  These G      transformation routines are NOT used by the _M_F_B display rou-a@      tines and must be invoked separately by an application pro-
      gram.  2      void MFBSetViewport(left, bottom, right, top)"      int left, bottom, right, top;  0      void MFBSetWindow(left, bottom, right, top)"      int left, bottom, right, top;        A Printed 9/3/83               6/21/83                           14x            A MFB(3)              UNIX Programmer's Manual               MFB(3)             int MFBScaleX(X)       int X;         int MFBScaleY(Y)       int Y;f        int MFBDescaleX(X)       int X;h        int MFBDescaleY(Y)d      int Y;F?           To use these routines, it is necessary to define both @           the viewport of the graphics display and the window inq           the working area by using _M_F_B_S_e_t_V_i_e_w_p_o_r_t and _M_F_B_S_e_t_W_i_n_- @           _d_o_w. The viewport must always be defined by non-A           negative integers that are within the resolution of theS`           graphics display.  Once defined, _M_F_B_S_c_a_l_e_X and _M_F_B_S_c_a_-A           _l_e_Y will convert from window coordinate values toom           viewport coordinates.  _M_F_B_D_e_s_c_a_l_e_X and _M_F_B_D_e_s_c_a_l_e_Y willA           perform the inverse transformation.  The transform rou-a)           tines return the scaled values.      GEOMETRY CLIPPING ROUTINES@      _M_F_B provides a set of routines for clipping lines and       polygons to a given window.  8      void MFB_Y_Intercept(X1, Y1, X2, Y2, value, Yvalue)      int X1, Y1, X2, Y2;      int value;o      int *Yvalue;d           _M_F_B__Y__I_n_t_e_r_c_e_p_t calculates the value _Y_v_a_l_u_e of the y;           coordinate at the point of intersection of a linetQ           defined by the two coordinates _X_1, _Y_1 and _X_2, _Y_2, and a_H           vertical line with all x coordinates equal to _v_a_l_u_e.    8      void MFB_X_Intercept(X1, Y1, X2, Y2, value, Xvalue)      int X1, Y1, X2, Y2;      int value;n      int *Xvalue; d           _M_F_B__X__I_n_t_e_r_c_e_p_t calculates the value _X_v_a_l_u_e of the x;           coordinate at the point of intersection of a lineFM           defined by _X_1, _Y_1 and _X_2, _Y_2, and a horizontal linen:           with all y coordinates equal to _v_a_l_u_e.    @      void MFBLineClip(X1, Y1, X2, Y2, left, bottom, right, top);      int *X1, *Y1, *X2, *Y2;"      int left, bottom, right, top;V           The above clipping routines are used by _M_F_B_L_i_n_e_C_l_i_p toO           clip the line segment defined by _X_1, _Y_1 and _X_2, _Y_2 toN      A Printed 9/3/83               6/21/83                           15N            A MFB(3)              UNIX Programmer's Manual               MFB(3)T      a           the window defined by _l_e_f_t, _b_o_t_t_o_m, _r_i_g_h_t, and _t_o_p.o    8      void MFBPolygonClip(poly, top, bottom, left, right)      MFBPOLYGON *poly;"      int top, bottom, left, right;\           _M_F_B_P_o_l_y_g_o_n_C_l_i_p clips a polygon with less than 200 ver-N           tices defined by _p_o_l_y to the window defined by _l_e_f_t,e           _b_o_t_t_o_m, _r_i_g_h_t, and _t_o_p. _p_o_l_y is replaced by the clipped_           polygon.    8      MFBPATH *MFBArcClip(path, left, bottom, right, top)      MFBPATH *path;a"      int left, bottom, right, top;Q           _M_F_B_A_r_c_C_l_i_p clips an arc with less than 200 verticesy\           defined by _p_a_t_h to the window defined by _l_e_f_t, _b_o_t_t_o_m,`           _r_i_g_h_t, and _t_o_p. _M_F_B_C_l_i_p_A_r_c returns a pointer to anM           array of five _M_F_B_P_A_T_H structs that define the clippedhA           arc.  The contents of several of these returned structsu!           may define a null path.Y     SPECIAL VIEWPORT ROUTINES_5      void MFBMore(left, bottom, right, top, Textfile) "      int left, bottom, right, top;      FILE *Textfile;_           _M_F_B_M_o_r_e will display the contents of a file _T_e_x_t_f_i_l_e in e           a viewport defined by _l_e_f_t, _b_o_t_t_o_m, _r_i_g_h_t, and _t_o_p in a >           manner similar to the UCB program _M_O_R_E(_1).    7      void MFBScroll(left, bottom, right, top, Textfile)2"      int left, bottom, right, top;      FILE *Textfile;]           _M_F_B_S_c_r_o_l_l is an enhanced version of _M_F_B_M_o_r_e defined @           above that allows you to scroll up or down through the\           contents of _T_e_x_t_f_i_l_e. The contents of _T_e_x_t_f_i_l_e are_           displayed in a viewport defined by _l_e_f_t, _b_o_t_t_o_m, _r_i_g_h_t,_           and _t_o_p.     DIAGNOSTICSl      char *MFBError(errnum)o      int errnum;Q           _M_F_B_E_r_r_o_r can be used to obtain a null terminated stringp=           that describes the error associated with any of the L           above mentioned error codes.  _e_r_r_n_u_m is the error codeV           returned by a _M_F_B routine.  _M_F_B_E_r_r_o_r returns a pointer?           to the error information string.  The possible values I           for _e_r_r_n_u_m are defined in _m_f_b._h as follows:         A Printed 9/3/83               6/21/83                           16            A MFB(3)              UNIX Programmer's Manual               MFB(3)p      B           #define MFBBADENT      -10   /* Unknown terminal type */C           #define MFBBADMCF      -20   /* Can't open mfbcap file */dB           #define MFBMCELNG      -30   /* MFBCAP entry too long */=           #define MFBBADMCE      -40   /* Bad mfbcap entry */ B           #define MFBINFMCE      -50   /* Infinite mfbcap entry */?           #define MFBBADTTY      -60   /* stdout not in /dev */d?           #define MFBBADLST      -70   /* Illegal line style */m?           #define MFBBADFST      -80   /* Illegal fill style *//@           #define MFBBADCST      -90   /* Illegal color style */@           #define MFBBADTM1      -100  /* No destructive text */A           #define MFBBADTM2      -110  /* No overstriking text */dE           #define MFBNODFLP      -120  /* No definable line styles */ E           #define MFBNODFFP      -130  /* No definable fill styles */ @           #define MFBNODFCO      -140  /* No definable colors */8           #define MFBNOBLNK      -150  /* No blinkers */>           #define MFBTMBLNK      -160  /* Too many blinkers */G           #define MFBBADDEV      -180  /* Can't open or close device */tL           #define MFBBADOPT      -190  /* Can't access or set device stat */L           #define MFBNOMASK      -170  /* No definable read or write mask */;           #define MFBBADWRT      -200  /* Error in write */ E           #define MFBPNTERR      -210  /* Error in pointing device */2J           #define MFBNOPTFT      -220  /* No format for pointing device */?           #define MFBNOPNT       -230  /* No pointing device */X=           #define MFBNORBND      -240  /* No Rubberbanding */_@           #define MFBBADALU      -250  /* Cannot set ALU mode */          void MFBZeroCounters()i  6      void MFBCounters(nCh,nBx,BxArea,nLn,LnLngth,nPxl)/      int *nCh,*nBx,*BxArea,*nLn,*LnLngth,*nPxl;aW           _M_F_B_C_o_u_n_t_e_r_s provides the ability to measure the commun-A>           ications bandwidth between the host and the graphics>           device.  To use these routines, MFB must be compiled@           with the DEBUG flag defined in the _m_f_b._h file.  K           The procedure is initialized by invoking _M_F_B_Z_e_r_o_-nQ           _C_o_u_n_t_e_r_s after which the geometry display routines suchsZ           as _M_F_B_B_o_x or _M_F_B_L_i_n_e may be called in any order.  WhenT           _M_F_B_C_o_u_n_t_e_r_s is invoked, it will return the number ofE           graphic text characters _n_C_h that where displayed, the L           number of boxes _n_B_x displayed, the number of lines _n_L_nL           displayed, the average pixel area of a box _B_x_A_r_e_a, theL           average line length _L_n_L_n_g_t_h in pixels, and the totalH           number of pixels _n_P_x_l that where affected.  InvocationO           of _M_F_B_C_o_u_n_t_e_r_s does not clear the the counters.-                  A Printed 9/3/83               6/21/83                           17e            A MFB(3)              UNIX Programmer's Manual               MFB(3)        THE MFB DATA STRUCTURE2      The _M_F_B data structure is listed below.        #define TTY     't'      #define HCOPY   'r'  %      typedef enum {false, true} Bool;e        struct mfb_window {          int left;          int right;n          int top;           int bottom;          double length,width;b          };s  &      typedef struct mfb_window WINDOW;(      typedef struct mfb_window VIEWPORT;        struct mfbpath {           int nvertices;           int *xy;N          };/  '      typedef struct mfbpath MFBPOLYGON;F$      typedef struct mfbpath MFBPATH;        #ifndef vms      struct mfbremttyb {          struct sgttyb oldttyb;e          struct sgttyb newttyb;F          };-        struct mfbremstat {K          int graphttyw;              /* old mode bits of graphics device */ H          int kybrdttyw;              /* old mode bits of standard I/O */H          struct stat graphstat;      /* old fstats of graphics device */E          struct stat kybrdstat;      /* old fstats of standard I/O */           };F  +      typedef struct mfbremttyb MFBSAVETTYB; +      typedef struct mfbremstat MFBSAVESTAT;s      #endif/        struct mfbformatstrs {(E          char *startSequence;        /* first transmitted sequence */*D          char *endSequence;          /* last transmitted sequence */A          char *initLineStyles;       /* initialize line styles */ A          char *initFillPatterns;     /* initialize fill styles */eB          char *initColorStyles;      /* initialize color styles */          A Printed 9/3/83               6/21/83                           18             A MFB(3)              UNIX Programmer's Manual               MFB(3)_      >          char *vltEntry;             /* define color in VLT */G          char *setForegroundColor;   /* set current foreground color */ H          char *screenFlood;          /* flood screen to current color */  9          char *channelMaskSet;       /* set write mask */O8          char *readMaskSet;          /* set read mask */  E          char *enablePointingDevice; /* initialize pointing device */ A          char *enableRubberBanding;  /* turn on rubber banding */_U          char *disablePointingDevice;        /* disable pointing device and cursor */_B          char *disableRubberBanding; /* turn off rubber banding */H          char *readPointingDevice;   /* wait and read pointing device */L          char *formatPointingDevice; /* decode format for pointing device */  >          char *keyboardStart;        /* initailize keyboard */C          char *keyboardEnd;          /* terminate keyboard input */oF          char *keyboardBackspace;    /* keyboard backspace sequence */B          char *audio;                /* ring the terminals bell */  H          char *lineDefineStart;      /* begin defining a line pattern */K          char *lineDefineFormat;     /* define bit array of line pattern */mL          char *lineDefineEnd;        /* terminate line pattern definition */A          char *setLineStyle;         /* set current line style */cJ          char *setSolidLineStyle;    /* set current line style to solid */I          char *movePenSequence;      /* move current graphics position */ G          char *drawLineSequence;     /* draw a line in current style */sD          char *drawSolidLineSequence;        /* draw a solid line */I          char *drawLineToSequence;   /* move and draw current position */kK          char *drawSolidLineToSequence;      /* move and draw solid line */   D          char *drawBoxSequence;      /* draw box in current style */;          char *drawSolidBoxSequence; /* draw a solid box */e  K          char *beginPlygnSequence;   /* begin polygon in cur. fill style */ F          char *beginSolidPlygnSequence;      /* begin solid polygon */F          char *sendPlygnVertex;      /* define one point in polygon */E          char *endPlygnSequence;     /* terminate polygon sequence */t  L          char *drawCircleSequence;   /* draw a circle in solid line style */  >          char *rotateTextSequence;   /* rotate graphic text */=          char *graphicsTextStart;    /* begin graphic text */ A          char *graphicsTextEnd;      /* terminate graphic text */oH          char *replaceON;            /* turn on destructive text mode */I          char *overstrikeON;         /* turn on overstriking text mode */ K          char *writePixel;           /* write one pixel in current color */o  >          char *setALUEOR;            /* set ALU mode to EOR */>          char *setALUNOR;            /* set ALU mode to NOR */=          char *setALUOR;             /* set ALU mode to OR */nI          char *setALUJAM;            /* set ALU mode to JAM or REPLACE */o        A Printed 9/3/83               6/21/83                           19l            A MFB(3)              UNIX Programmer's Manual               MFB(3)o      =          char *blinkerON;            /* make a color blink */dD          char *blinkerOFF;           /* turn off a blinking layer */  E          char *rastCopyStart;        /* begin raster copy sequence *//I          char *rastCopyEnd;          /* terminate raster copy sequence */ J          char *rastCopyDest;         /* define raster copy destionation */I          char *rastCopySource;       /* define raster copy source area */b  F          char *fillDefineStart;      /* begin defining a fill style */I          char *fillDefineFormat;     /* define bit array of row/column */pJ          char *fillDefineEnd;        /* terminate fill style definition */C          char *setFillPattern;       /* set current fill pattern */eL          char *setSolidFillPattern;  /* set current fill pattern to solid */          };     .      struct mfb {        /* MFB DATA STRUCT */                            /*a+                           * INTEGERS FIELDSr                           */Z      /* used for decode */                    int lastX,lastY;/* for Tektronix encoding */B                          int X,Y,Z,T;         /* parameter list */  I      /* Resolution */    int maxX;            /* horizontal resolution */uG                          int maxY;            /* vertical resolution */qL                          int maxColors;       /* maximum number of colors */M                          int minOffScreenX;   /* left of off screen memory */ M                          int minOffScreenY;   /* bottom of off screen mem. */ M                          int offScreenDX;     /* length of off screen mem. */ L                          int offScreenDY;     /* width of off screen mem. */  \      /* Video Layer Table */                  int maxIntensity;/* max RGB or LS intensity */H                          int lengthOfVLT;     /* number of bit planes */  \      /* Pointing Device */                    int buttonMask[12];/* returned button masks */>                          int numberOfButtons; /* 12 maximum */  B      /* Keyboard Control */                   int keyboardYOffset;-                          int keyboardXOffset;i  T      /* Line Drawing */  int lineDefineLength;        /* number of bytes in array */I                          int maxLineStyles;   /* number of line styles */   I      /* Text font */     int fontHeight;      /* font height in pixels */sH                          int fontWidth;       /* font width in pixels */)                          int fontXOffset;s)                          int fontYOffset;   F      /* Blinkers */      int maxBlinkers;     /* number of blinkers */          A Printed 9/3/83               6/21/83                           20a            A MFB(3)              UNIX Programmer's Manual               MFB(3)t      O      /* Fill Patterns */ int fillDefineHeight;        /* number of byte rows */bJ                          int fillDefineWidth; /* number of byte columns */K                          int maxFillPatterns; /* number of fill patterns */   ^      /* Current variables */                  int cursorColor1Id;/* blinked cursor color ID */M                          int cursorColor2Id;  /* unblinked cursor color ID */;L                          int fgColorId;       /* cur. foreground color ID */H                          int fillPattern;     /* cur. fill pattern ID */F                          int lineStyle;       /* cur. line style ID */C                          int channelMask;     /* cur. write mask */ B                          int readMask;        /* cur. read mask */K                          int numBlinkers;     /* cur. number of blinkers *//M                          int textMode;        /* text mode (1=dest, 0=rep) */ P                          int stipplePattern[8];       /* cur. stipple pattern */  M                          int fileDesc;        /* desc. for graphics device */ N                          int numTtyBuffer;    /* cur. chars in output queue */                              /*o$                           * POINTERS                           */J      /* for tty's only */                     char *name;/* device name */H                          char *terminalName;  /* name of MFBCAP entry */  0      /* I/O routines */  int (*dsply_getchar)();0                          int (*kybrd_getchar)();2                          int (*dsply_ungetchar)();2                          int (*kybrd_ungetchar)();*                          int (*outchar)();)                          int (*outstr)();t                              /* $                           * BOOLEANS                           */.                          Bool initializedBool;  ;      /* Video Layer Table */                  Bool vltBool;a,                          Bool vltUseHLSBool;  .      /* Channel Mask */  Bool channelMaskBool;+                          Bool readMaskBool;*  F      /* Pointing Device */                    Bool PointingDeviceBool;*                          Bool buttonsBool;0                          Bool readImmediateBool;  @      /* Keyboard Control */                   Bool keyboardBool;  4      /* Line Drawing */  Bool linePatternDefineBool;3                          Bool reissueLineStyleBool;       A Printed 9/3/83               6/21/83                           21             A MFB(3)              UNIX Programmer's Manual               MFB(3)e      C      /* Polygon Drawing */                    Bool filledPlygnBool;   3      /* Text font */     Bool textPositionableBool;u-                          Bool textRotateBool;t.                          Bool replaceTextBool;1                          Bool overstrikeTextBool;o  +      /* Blinkers */      Bool blinkersBool;   +      /* Raster Copy */   Bool rastCopyBool;c,                          Bool rastRSCSFBool;  1      /* Fill Patterns */ Bool fillPtrnDefineBool; 5                          Bool fillDefineRowMajorBool;l  :      /* for tty's only */                     Bool litout;"                          Bool raw;'                          Bool ttyIsSet;               /*u           * STRUCTURES           */=          struct mfbformatstrs strings;   /* format strings */   =          WINDOW currentWindow;           /* current window */r?          VIEWPORT currentViewport;       /* current viewport */O        #ifndef vms*          /* graphics device ttyb struct */          MFBSAVETTYB graphTtyb;   L          /* keyboard ttyb struct if graphics device does not have a kybrd */          MFBSAVETTYB kybrdTtyb;             /* tty status ints */          MFBSAVESTAT oldstat;       #endif               /*            * CHARACTERS           */G          char deviceType;                /* TTY=tty, HCOPY=hard copy */lI          char strBuf[BUFSIZE];           /* storage for format strings */a@          char ttyBuffer[TTYBUFSIZE];     /* tty output buffer */          };/        typedef struct mfb MFB;            A Printed 9/3/83               6/21/83                           22             A MFB(3)              UNIX Programmer's Manual               MFB(3)/       EXAMPLE :      The following C program is a simple example that usesD      several _M_F_B routines.  The terminal type is assumed to be@      the first command line argument.  This program will display@      several triangles in different line styles, display at fourL      angles of rotation the text that is returned from _M_F_B_K_e_y_-K      _b_o_a_r_d, draw a solid line between two points, and draw an arc       clipped to a rectangle.                   #include <cad/mfb.h>             main(argc, argv)               int argc;t               char *argv[];d               {                int i, j, k, m;s!               int X1, X2, Y1, Y2;/               int numcolors;                int numlinestyles;               int button;                int error;#               MFB *mfb, *MFBOpen();t               MFBPATH *pp;               char key;                char *TypeIn;e  (               /* open graphics device */3               mfb = MFBOpen(argv[1], NULL, &error);   %               /* exit on any error */                if(error < 0) {xC                   fprintf(stderr, "error:  %s\n", MFBError(error));                    exit(0);                   }a  *               /* get device information */#               X1 = MFBInfo(MAXX)/2;                X2 = X1/2;$               Y1 = MFBInfo(MAXY)/30;-               numcolors = MFBInfo(MAXCOLORS); 5               numlinestyles = MFBInfo(MAXLINESTYLES);;               if(numcolors > 7)a                    numcolors = 7;#               if(numlinestyles > 7) $                   numlinestyles = 7;              A Printed 9/3/83               6/21/83                           23W            A MFB(3)              UNIX Programmer's Manual               MFB(3)       B               /* draw pyramid of lines in different line styles */#               for(j=0; j<28; ++j) {gQ                   /* set color (increment by one to prevent 'invisible' lines) */y*                   k = j % (numcolors - 1);%                   MFBSetColor(k + 1);   1                   /* define and set line style */ (                   m = j % numlinestyles;/                   MFBDefineLineStyle(m, j * 6);,%                   MFBSetLineStyle(m);B  $                   /* draw pyramid */0                   MFBLine(0, 0, X2, Y1*j + 2*j);1                   MFBLine(X1, 0, X2, Y1*j + 2*j);                    }                   /* flush output */               MFBUpdate();  '               /* test of MFBKeyboard */ <               MFBText("Test of MFBKeyboard.", X2, Y1*28, 0);0               TypeIn = MFBKeyboard(X1, 5, 0, 1);)               MFBText(TypeIn, X1, 70, 0);B*               MFBText(TypeIn, X1, 70, 90);+               MFBText(TypeIn, X1, 70, 180);i+               MFBText(TypeIn, X1, 70, 270);s               MFBUpdate();               sleep(3);e  $               /* test of MFBPoint */               MFBSetColor(1);                MFBFlood();l               MFBSetColor(0); 9               MFBText("Test of MFBPoint.", X2, Y1*28, 0); 0               MFBPoint(&X1, &Y1, &key, &button);0               MFBPoint(&X2, &Y2, &key, &button);!               MFBSetLineStyle(0); &               MFBLine(X1, Y1, X2, Y2);  6               /* draw outline of box to contain arc */*               MFBLine(100, 100, 100, 350);*               MFBLine(100, 100, 370, 100);*               MFBLine(370, 100, 370, 350);*               MFBLine(100, 350, 370, 350);  5               /* test of MFBArcPath and MFBClipArc */t               i = 0;U               pp = MFBClipArc(MFBArcPath(70, 70, 200, 0, 0, 30), 100, 100, 370, 350); 4               while(pp[i].nvertices != 0 && i < 4) {&                   MFBDrawPath(&pp[i]);                   i++;                   }       A Printed 9/3/83               6/21/83                           24n            A MFB(3)              UNIX Programmer's Manual               MFB(3);      )               /* flush output and wait */(               MFBUpdate();               sleep(6);;                 MFBClose();t               }          DEBOUNCING THE POINTING DEVICEG      The following C program is another example of using _M_F_B rou- >      tines that demonstrates several methods of debouncing the<      pointing device.  Several graphics terminals can return?      bogus pointing reports that can be serious and annoying in @      some applications.  Identifying these bogus reports is very<      terminal dependent (e.g. the AED 512 returns bad button@      masks, the Metheus 400 returns negative coordinates, etc.),=      and it is therefore necessary to use all possible tests.;                 #include <cad/mfb.h>           #ifdef vms           #include <timeb.h>           #elsea            #include <sys/timeb.h>           #endif             /*5            * This is the minimum time in milliseconds .            * between accepted pointing events.
            */r"           #define DEBOUNCETIME 100             /*7            * we keep track of the time between pointinge*            * events to debounce the cursor
            */N(           static long LastPointTime = 0;             /*:            * routine to read and debounce pointing device.
            */%'           point(pointX,pointY,Key,Mask) (               int *pointX,*pointY,*Mask;               char *Key;               {                struct timeb now;                long newtime;                int X,Y,Buttons;               char KeyTyped;      A Printed 9/3/83               6/21/83                           25             A MFB(3)              UNIX Programmer's Manual               MFB(3)&                      SetDebounceTime();6               /* Loop until DEBOUNCETIME has passed */               while(True) {1  ;                   /* Loop until valid report is received */i                   while(True) {0  .                       /* Get pointing event */9                       MFBPoint(&X,&Y,&KeyTyped,&Buttons);   2                       /* Was a character typed? */"                       if(Key != 0)                            break;  B                       /* Does the pointing device have buttons? */3                       if(MFBInfo(POINTINGBUTTONS)){=                           /*J                            * Test button masks and vicinity of coordinate.8                            * Assume a four button mouse.                            */ <                           if((Buttons == MFBInfo(BUTTON1) ||<                               Buttons == MFBInfo(BUTTON2) ||<                               Buttons == MFBInfo(BUTTON3) ||=                               Buttons == MFBInfo(BUTTON4)) &&E<                               (X < MFBInfo(MAXX) && X > 0 &&:                               Y < MFBInfo(MAXY) && Y > 0))$                               break;                           }                        }i                   ftime(&now);:                   newtime = 1000 * now.time + now.millitm;H                   if((newtime - LastPointTime) < DEBOUNCETIME) continue;$                   SetDebounceTime();                   }c               *pointX = X;               *pointY = Y;               *Key = KeyTyped;               *Mask = Buttons;               }f               SetDebounceTime(){               struct timeb now;c               ftime(&now);<               LastPointTime = 1000 * now.time + now.millitm;               }                   A Printed 9/3/83               6/21/83                           26E            A MFB(3)              UNIX Programmer's Manual               MFB(3)p       NOTES F      On some systems, _M_F_B is contained in /usr rather than ~cad.  M      _M_F_B will also compile to run under _V_M_S (a trademark of Digi-c>      tal Equipment Corp.) or any other operating system.  How-0      ever, special I/O routines such as those inD      ~cad/src/mfb/vmsio.c must be provided for _M_F_B to function      properly.  F      _M_F_B was written to be utmost UNIX compatible and consistent@      with the style of the C programming language.  For example,O      a control sequence always begins with a call to an (_M_F_B)_O_p_e_nrQ      routine and is terminated by a call to a (_M_F_B)_C_l_o_s_e routine. O      Another example is the provision of the _M_F_B_H_a_l_t routine that ?      is intended primarily for the handling of the SIGTSTP sig- A      nal.  One possible exception to the style of C is the use ofr<      a global output descriptor that is set by a call to theV      _S_e_t_C_u_r_r_e_n_t_M_F_B routine, as opposed to passing the output<      descriptor as an argument to ever active function call.  G      _M_F_B was initially aimed toward the modeling of lower perfor- ?      mance graphics terminals (e.g., there is currently no sup-S?      port of segments or definable windows and viewports at the A      device level).  As a result, programs that use _M_F_B are <      likely to work on the low performance (least expensive)A      graphics terminals as well as on the more expensive devices.      BUGS6      Raster (hard copy) output is not yet implemented.     FUTURE ENHANCEMENTSsA      Future modifications to _M_F_B may include the following:a  2           Extension to hard copy graphics devices.  6           Definable vector and raster character fonts.  >           Improved cursor support including a definable cursorA           font, cursor tracking by the host, cursor-on/cursor-off(6           capability, and cursor report without event.  >           Window/viewport geometry clipping by the terminal if/           the device possesses that capability.)  &           Bit block transfer (BitBlt).     FILESM      ~cad/lib/mfbcap      ~cad/include/mfb.h       A Printed 9/3/83               6/21/83                           27l            A MFB(3)              UNIX Programmer's Manual               MFB(3)             ~cad/lib/mfb.a0      ~cad/src/mfb      SEE ALSO9      mfbcap(5), termcap(5), curses(3), more(1), kic(CAD1)T     AUTHOR      Giles Billingsley      Ken Kellera                                                                                        A Printed 9/3/83               6/21/83                           28o            A MFB(3)              UNIX Programmer's Manual               MFB(3).       STATUSA      The following is a list of the terminals that will currentlyh      work with _M_F_B:m  ,      4014    Tektronix 4014 with thumbwheels;      4113    Tektronix 4112/4113 with thumbwheels or tabletN,      AED5    AED 512 with joystick or tablet,      AED7    AED 767 with joystick or tabletB      2648    HP 2648 black and white grahpics terminal with tablet&      9872    HP 9872 color pen plotter8      D125    DEC VT125 black and white graphics terminal  =      The following table lists routines that depend on device;      capabilities and may not work on all graphics devices.nE      Other _M_F_B routines that are not listed below will work foro      all devices.    8          ____________________________________________________________________________________________________;                                   4   4   A   A   2   9   DB;                                   0   1   E   E   6   8   1 ;                Routine            1   1   D   D   4   7   2S;                                   4   3   5   7   8   2   5  8          ____________________________________________________________________________________________________;            MFBSetLineStyle        X   X   X   X   X   X   X ;            MFBSetFillPattern          X   X   X   X   X   XE/            MFBSetChannelMask              X   Xy/            MFBSetReadMask                 X   Xo;            MFBSetColor                X   X   X   X   X   Xd'            MFBSetTextMode             Xr3            MFBSetALUMode              X           X /            MFBSetCursorColor              X   Xn3            MFBSetRubberBanding        X           X /            MFBSetBlinker                  X   Xt> 8          __________________________________________________/            MFBDefineColor             X   X   X(3            MFBDefineFillPattern       X   X   X   X/3            MFBDefineLineStyle             X   X   X2> 8          __________________________________________________;            MFBMoveTo              X   X   X   X   X   X   X ;            MFBDrawLineTo          X   X   X   X   X   X   Xa;            MFBLine                X   X   X   X   X   X   X ;            MFBDrawPath            X   X   X   X   X   X   X ;            MFBBox                 X   X   X   X   X   X   Xa;            MFBPolygon             X   X   X   X   X   X   Xb;            MFBFlood                   X   X   X   X       X);            MFBPixel               X   X   X   X   X   X   X*;            MFBCircle              X   X   X   X   X   X   X ;            MFBFlash               X   X   X   X   X   X   X ;            MFBArc                 X   X   X   X   X   X   Xo;            MFBText                X   X   X   X   X   X   Xo> 8          __________________________________________________3            MFBPoint               X   X   X   X   XM;            MFBKeyboard            X   X   X   X   X       Xn;            MFBMore                    X   X   X   X       Xf;            MFBScroll                  X   X   X   X       X       A Printed 9/3/83               6/21/83                           29m     9    A MFB(3)              UNIX Programmer's Manual               MFB(3)        8          ____________________________________________________________________________________________________ 799         |99|99|99|99|99|99|99|99|99|99|99|99|99|99|99|99|7777777777777777|99|99|99|99|99|99|99|99|99|99|99|99|99|99|99|99|F77777777777777777799                                                           |99|99|99|99|99|99|99|99|99|99|99|99|99|99|99|99|7777777777777777|99|99|99|99|99|99|99|99|99|99|99|99|99|99|99|99|                                                                     9    A Printed 9/3/83               6/21/83                           30w      