home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / SCRNMS.ZIP / SCREEN.DOC < prev    next >
Text File  |  1990-03-15  |  32KB  |  1,080 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.               --------------------------------------------------------
  13.  
  14.                             Screen and Keyboard Functions                            Screen and Keyboard Functions
  15.  
  16.               --------------------------------------------------------
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.                      Copyright (c) 1988-89, Christopher Laforet
  39.                      Copyright (c) 1990, Chris Laforet Software
  40.                                  All Rights Reserved
  41.  
  42.  
  43.  
  44.  
  45.  
  46.           _________________________________________________________________
  47.  
  48.                                       Chapter 1                                      Chapter 1
  49.  
  50.                                     Introduction                                    Introduction
  51.           _________________________________________________________________
  52.  
  53.  
  54.                The Screen and Keyboard Library contains a great number of
  55.           functions for non-graphics (read text-mode) screen handling under
  56.           DOS and OS/2.  These routines contain functions which range from
  57.           putting one character on the screen to functions which allow
  58.           shadowed windows to be manipulated.  There are also a number of
  59.           low level keyboard accessing functions.   These routines are
  60.           created for LARGE MODEL, the only model available for serious
  61.           applications.
  62.  
  63.                The routines in this library are Copyrighted (c) 1989-89 by
  64.           Christopher Laforet and (c) 1990 by Chris Laforet Software and
  65.           all rights are reserved by the author.  There are absolutely no
  66.           warranties implied or otherwise on these routines.  Use them at
  67.           your own risk.  While no software can be guaranteed absolutely
  68.           bug-free, these routines have been extensively tested and work on
  69.           most IBM-PC compatible displays.  The author and copyright holder
  70.           shall in no way be held liable for any damages incurred by the
  71.           use of these routines.
  72.  
  73.                The following mnemonics are copyright (c) 1987-90 by Dave
  74.           Neathery Software, and are used with express permission.  The
  75.           permit portability to QNX systems using the library available
  76.           from Dave Neathery Software.  The mnemonics are:
  77.  
  78.                _vcw, _vcw, _bcw, _bsw, _vbr, prntnomov, prntnomovf,
  79.                prntmov, prntmovf, open_window, close_window, scr_init,
  80.                clrblk, phantom, _read_keyboard, _scan_keyboard and
  81.                _get_shift_status.
  82.  
  83.                These routines contain my ideas insofar as screen routines
  84.           are concerned.  Most of the time spent in writing to the display
  85.           using other routines is spent pushing the cursor around the
  86.           screen.  Moving the cursor is a very intensive task, and it is
  87.           one of the reasons that BIOS video routines are so slow.  My
  88.           contention is that there should be routines to write to the
  89.           screen and routines to write to the screen and move the cursor
  90.           ONCE to its final resting place.  Hence, here is my philosophy of
  91.           video handling in a small neat package.
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.                ------------------------------------------------------
  105.                         Screen and Keyboard Function Library
  106.                                        Page 2
  107.  
  108.  
  109.  
  110.  
  111.           _________________________________________________________________
  112.  
  113.                                       Chapter 2                                      Chapter 2
  114.  
  115.                            Structures, Globals and Macros                           Structures, Globals and Macros
  116.           _________________________________________________________________
  117.  
  118.  
  119.                The purpose of this chapter is to present the various
  120.           structures and macros available for your use when accessing the
  121.           functions in the library.
  122.  
  123.  
  124.  
  125.           2.1-Colors          2.1-Colors
  126.           _________________________________________________________________
  127.  
  128.  
  129.                There is an extensive array of color macros available in the
  130.           header file SCREEN.H.  Here is a listing of the available colors.
  131.  
  132.           Foreground:
  133.  
  134.                BLACK
  135.                BLUE
  136.                GREEN
  137.                CYAN
  138.                RED
  139.                MAGENTA
  140.                BROWN
  141.                LT_GRAY -or- NORMAL
  142.                GRAY
  143.                LT_BLUE
  144.                LT_GREEN
  145.                LT_CYAN
  146.                LT_RED
  147.                LT_MAGENTA
  148.                YELLOW
  149.                WHITE -or- INTENSE
  150.  
  151.  
  152.           Modifier:
  153.  
  154.                BLINK
  155.  
  156.  
  157.           Background:
  158.  
  159.                ON_BLUE
  160.                ON_GREEN
  161.                ON_CYAN
  162.                ON_RED
  163.                ON_MAGENTA
  164.                ON_YELLOW
  165.                ON_WHITE -or- INVERSE
  166.  
  167.  
  168.  
  169.                ------------------------------------------------------
  170.                         Screen and Keyboard Function Library
  171.                                        Page 3
  172.  
  173.  
  174.  
  175.  
  176.  
  177.                These macros can be used anytime you need to pass colors to
  178.           a function (e.g WHITE).  To create a complex color, simply OR the
  179.           individual values together.  For example, blinking yellow on a
  180.           blue background will be YELLOW | ON_BLUE | BLINK.
  181.  
  182.  
  183.  
  184.           2.2-Coordinates          2.2-Coordinates
  185.           _________________________________________________________________
  186.  
  187.  
  188.                Coordinates are specified as unsigned shorts encoded as (row
  189.           << 8) + column.  Rows and columns start at 0 from the top left
  190.           corner of the screen.  For example, the bottom right corner of
  191.           the screen in 25 line mode will be specified as 0x184f (0x18 << 8
  192.           + 0x4f) since line 24 is 0x18 and column 79 is 0x4f.
  193.  
  194.  
  195.  
  196.           2.3-Cursor Shapes          2.3-Cursor Shapes
  197.           _________________________________________________________________
  198.  
  199.  
  200.                There are macros defined in SCREEN.H which define cursor
  201.           shapes and sizes.  These are as follows:
  202.  
  203.                HIDDEN         - this may not work on ALL video cards
  204.                LINE           - the underline cursor
  205.                UPPER_HALF     - a block in the top half of the character
  206.                LOWER_HALF     - a block in the bottom half of the character
  207.                FULL           - a complete character block
  208.  
  209.           Notice that due to a bug, some hardware implementations do not
  210.           set hidden cursors correctly.  If this is the case (under DOS
  211.           only), you may park the cursor at the first column of one line
  212.           below the bottom line of the screen (in 25 line mode, 0x1900).
  213.           This is effective in hiding the cursor on ALL systems.
  214.  
  215.  
  216.  
  217.           2.4-Current Cursor Position          2.4-Current Cursor Position
  218.           _________________________________________________________________
  219.  
  220.  
  221.                There is a macro in SCREEN.H which will return the current
  222.           cursor position mapped in the standard way for the use of the
  223.           library.  The format is ((row << 8) + column) mapped into an
  224.           unsigned short.  The macro that returns the current position is
  225.           CURPOS.  Should you wish to print a string at the current cursor
  226.           position, you may do the following:
  227.  
  228.                prntmovf(CURPOS,80,LIGHT_GRAY | ON_RED,"Here is a string!");
  229.  
  230.  
  231.  
  232.  
  233.  
  234.                ------------------------------------------------------
  235.                         Screen and Keyboard Function Library
  236.                                        Page 4
  237.  
  238.  
  239.  
  240.  
  241.  
  242.           The CURPOS macro will pass the current cursor position to the
  243.           prntmovf() function.  The 80 merely indicates to the function
  244.           that the maximum length to print is 80 characters.  The printing
  245.           will actually stop after the ! in the string.
  246.  
  247.  
  248.  
  249.           2.5-Window Structure          2.5-Window Structure
  250.           _________________________________________________________________
  251.  
  252.  
  253.                The windowing functions return or accept a pointer to a
  254.           structure called window.  This structure is declared in the
  255.           header WINDOW.H.  Here is the structure for your information:
  256.  
  257.                struct window
  258.                    {
  259.                    int *save;
  260.                    int curpos;
  261.                    int curmode;
  262.                    int start;     /* the upper left corner of window */
  263.                    int stop;      /* the lower left corner of window */
  264.                    };
  265.  
  266.  
  267.  
  268.           2.6-CGA Snow Flag          2.6-CGA Snow Flag
  269.           _________________________________________________________________
  270.  
  271.  
  272.                There is a global integer variable called _snow_flag which
  273.           is used only under DOS.  This variable is used to select retrace
  274.           checking on old CGA monitors to reduce video snow while accessing
  275.           video RAM.  By default, it is set to 0 which disables snow
  276.           checking, but may be set to 1 to enable snow checking on snowy
  277.           monitors.  Notice that this variable is not present (nor needed)
  278.           under OS/2.
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.                ------------------------------------------------------
  300.                         Screen and Keyboard Function Library
  301.                                        Page 5
  302.  
  303.  
  304.  
  305.  
  306.           _________________________________________________________________
  307.  
  308.                                       Chapter 3                                      Chapter 3
  309.  
  310.                                     Header Files                                    Header Files
  311.           _________________________________________________________________
  312.  
  313.  
  314.                There are four header files for this library.  They are
  315.           SCREEN.H, WINDOW.H, KB.H, and KEYS.H.  KEYS.H contains macro
  316.           definitions for most of the extended keystrokes as they would be
  317.           returned by the _read_keyboard() function.
  318.  
  319.                If you are using MSC, the headers automatically insert the
  320.           name of the correct library for your application into the object
  321.           file using the #pragma comment(lib,...) statement of the
  322.           Microsoft compiler.  To specify the protected mode (OS/2)
  323.           library, you must #define PROTECTED (either in the source file or
  324.           using the -DPROTECTED option on the compiler's command line) at
  325.           some point in your program prior to calling any of the screen
  326.           library headers.
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.                ------------------------------------------------------
  365.                         Screen and Keyboard Function Library
  366.                                        Page 6
  367.  
  368.  
  369.  
  370.  
  371.           _________________________________________________________________
  372.  
  373.                                       Chapter 4                                      Chapter 4
  374.  
  375.                                 Function Descriptions                                Function Descriptions
  376.           _________________________________________________________________
  377.  
  378.  
  379.  
  380.           4.1-Screen Handling Functions          4.1-Screen Handling Functions
  381.           _________________________________________________________________
  382.  
  383.  
  384.           * int scr_init(void)
  385.  
  386.                This function MUST be called before calling any other screen
  387.           library function.  It needs to be called only once.  It sets the
  388.           video library into motion, detects the type of adapter card, and
  389.           initializes all of the necessary variables.
  390.  
  391.           Returns:  At this time, the return value is not implemented.
  392.  
  393.  
  394.           * void _cls(int attribute);
  395.  
  396.                This function clears the screen to the requested color
  397.           (attribute).  It does not move the cursor.
  398.  
  399.           Example:  _cls(YELLOW | ON_BLUE);
  400.  
  401.  
  402.           * int prntnomov(int cursor,int length,int attribute,
  403.                           char *string);
  404.  
  405.                This function will print up to length characters of the
  406.           passed string with the requested attribute starting at the
  407.           requested cursor position (encoded ((col << 8) + row)).  If the
  408.           string is longer than length, then it is truncated.  If the
  409.           string is shorter than length, then only strlen(string)
  410.           characters are printed to the screen.  The cursor is not moved at
  411.           any time during this operation.
  412.  
  413.           Example:  prntnomov(0x100,80,WHITE,"Copyright (c) 1990.");
  414.  
  415.           Returns:  Number of characters written.
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.                ------------------------------------------------------
  430.                         Screen and Keyboard Function Library
  431.                                        Page 7
  432.  
  433.  
  434.  
  435.  
  436.  
  437.           * int prntnomovf(int cursor,int length,int attribute,
  438.                            char *format,...);
  439.  
  440.                This function will print up to length characters of the
  441.           passed string with the requested attribute starting at the
  442.           requested cursor position (encoded ((col << 8) + row)).  If the
  443.           string is longer than length, then it is truncated.  This
  444.           function allows the use of formatting statements in the string
  445.           which correspond to arguments passed after string (eg %s or %u)
  446.           just like printf().  If the expanded string is shorter than
  447.           length, then only strlen(string) characters are printed to the
  448.           screen.  The cursor is not moved at any time during this
  449.           operation.
  450.  
  451.           Example:  char name[11];
  452.                     prntnomovf(0x1010,20,YELLOW,"Name is %s",name);
  453.  
  454.           Returns:  Number of characters written.
  455.  
  456.  
  457.           * int prntmov(int cursor,int length,int attribute,
  458.                         char *string);
  459.  
  460.                This function will print up to length characters of the
  461.           passed string with the requested attribute starting at the
  462.           requested cursor position (encoded ((col << 8) + row)).  If the
  463.           string is longer than length, then it is truncated.  If the
  464.           string is shorter than length, then only strlen(string)
  465.           characters are printed to the screen.  The cursor is moved to the
  466.           end of the printed string.
  467.  
  468.           Example:  prntmov(0,50,LT_CYAN | ON_RED,"Do you want to exit? ");
  469.  
  470.           Returns:  Number of characters written.
  471.  
  472.  
  473.           * int prntmovf(int cursor,int length,int attribute,
  474.                          char *format,...);
  475.  
  476.                This function will print up to length characters of the
  477.           passed string with the requested attribute starting at the
  478.           requested cursor position (encoded ((col << 8) + row)).  If the
  479.           string is longer than length, then it is truncated.  This
  480.           function allows the use of formatting statements in the string
  481.           which correspond to arguments passed after string (eg %s or %u)
  482.           just like printf().  If the expanded string is shorter than
  483.           length, then only strlen(string) characters are printed to the
  484.           screen.  The cursor is moved to the end of the printed string.
  485.  
  486.           Example:  char username[21];
  487.                     prntmovf(0x1800,80,WHITE,"Are you %s? ",username);
  488.  
  489.           Returns:  Number of characters written.
  490.  
  491.  
  492.  
  493.  
  494.                ------------------------------------------------------
  495.                         Screen and Keyboard Function Library
  496.                                        Page 8
  497.  
  498.  
  499.  
  500.  
  501.  
  502.           * int prntmem(int length,int attribute,void *buffer,
  503.                         char *string);
  504.  
  505.                This function will format up to length characters of the
  506.           passed string with the requested attribute to the passed buffer
  507.           location.  The buffer must be capable of holding (length * 2)
  508.           characters.  If the expanded string is longer than length, then
  509.           it is truncated.  If the string is shorter than length, then only
  510.           strlen(string) characters are printed to the buffer.
  511.  
  512.           Example:  char image[40];
  513.                     prntmem(20,GREEN,image,"Memory image!");
  514.  
  515.           Returns:  Number of characters formatted into buffer.
  516.  
  517.  
  518.           * int prntmemf(int length,int attribute,void *buffer,
  519.                          char *format,...);
  520.  
  521.                This function will format up to length characters of the
  522.           passed string with the requested attribute to the passed buffer
  523.           location.  The buffer must be capable of holding (length * 2)
  524.           characters.  This function allows the use of formatting
  525.           statements in the string which correspond to arguments passed
  526.           after string (eg %s or %u) just like printf().  If the string is
  527.           longer than length, then it is truncated.  If the string is
  528.           shorter than length, then only strlen(string) characters are
  529.           printed to the buffer.
  530.  
  531.           Example:  char func_name[32];
  532.                     char message[160];
  533.                     prntmemf(80,WHITE,message,"Error in %s",func_name);
  534.  
  535.           Returns:  Number of characters formatted into buffer.
  536.  
  537.  
  538.           * int prntcenter(int cursor,int width,int color,
  539.                            char *string);
  540.  
  541.                This function will print a string centered in an imaginary
  542.           block starting at cursor and extending for width characters with
  543.           the respective color.
  544.  
  545.           Example:  prntcenter(0x0,80,LT_BLUE,"*** Presenting ***");
  546.  
  547.           Returns:  Number of characters written.
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.                ------------------------------------------------------
  560.                         Screen and Keyboard Function Library
  561.                                        Page 9
  562.  
  563.  
  564.  
  565.  
  566.  
  567.           * int _vcw(char character,int attribute,int cursor,
  568.                      int length);
  569.  
  570.                This is one of the low level functions and is fast.  It
  571.           prints a character with the respective attribute for length
  572.           repetitions starting at cursor.  The cursor is not moved.
  573.  
  574.           Example:  _vcw('▓',LT_GRAY | ON_BLUE,0x0,80);
  575.  
  576.           Returns:  Number of characters written.
  577.  
  578.  
  579.           * int _vsw(char far *string,int cursor,int length,
  580.                      int attribute);
  581.  
  582.                This function is one of the low-level functions and can be
  583.           expected to be fast.  It prints a string with the respective
  584.           attribute for length starting at cursor.  The cursor is not
  585.           moved.
  586.  
  587.           Example:  _vsw("This is a test",0x900,80,LT_GREEN);
  588.  
  589.           Returns:  Number of characters written.
  590.  
  591.  
  592.           * int _bcw(char character,int attribute,int length,
  593.                      void *buffer);
  594.  
  595.                This is one of the low level functions.  It prints a
  596.           character with the respective attribute for length repetitions to
  597.           the passed buffer.  The buffer must be at least (length * 2)
  598.           characters long.  This function is useful in preparing buffered
  599.           screens.
  600.  
  601.           Example:  char buffer[20];
  602.                     _bcw('_',WHITE | ON_RED,10,buffer);
  603.  
  604.           Returns:  Number of characters formatted.
  605.  
  606.  
  607.           * int _bsw(char *string,int attribute,int length,void *buffer);
  608.  
  609.                This function is a low-level function.  It prints a string
  610.           with the respective attribute for length into the passed buffer.
  611.           The buffer must at least be (length * 2) characters long.  It is
  612.           useful in preparing buffered screens.
  613.  
  614.           Example:  char buffer[32];
  615.                     _bsw("This is buffered",WHITE,16,buffer);
  616.  
  617.           Returns:  Number of characters formatted.
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.                ------------------------------------------------------
  625.                         Screen and Keyboard Function Library
  626.                                        Page 10
  627.  
  628.  
  629.  
  630.  
  631.  
  632.           * int _vbw(void *buffer,int cursor,int length);
  633.  
  634.                This function is low level and hence should be fast.  It
  635.           will write a previously buffered character-attribute list to the
  636.           screen at the specified cursor location and for the specified
  637.           length.  The cursor is not moved.
  638.  
  639.           Example:  char buffer[32];
  640.                     _bsw("This is buffered",WHITE,16,buffer);
  641.                     _vbw(buffer,0x1020,16);
  642.  
  643.           Returns:  Number of characters written.
  644.  
  645.  
  646.           * int _vbr(void * buffer,int cursor,int length);
  647.  
  648.                This function is low level.  It will read the length of
  649.           character-attribute pairs from the screen memory into the
  650.           specified buffer.  The buffer must be at least (length * 2)
  651.           characters long.
  652.  
  653.           Example:  char cell[2];
  654.                     _vbr(cell,0x0,1);
  655.                     _cls(cell[1]);  /* clear the screen to same color */
  656.  
  657.           Returns:  Number of character-attribute pairs read.
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.                ------------------------------------------------------
  690.                         Screen and Keyboard Function Library
  691.                                        Page 11
  692.  
  693.  
  694.  
  695.  
  696.  
  697.           4.2-Windowing Functions          4.2-Windowing Functions
  698.           _________________________________________________________________
  699.  
  700.  
  701.           * struct window *open_window(int start,int stop,int attribute,
  702.                                        int type);
  703.  
  704.                This function will open a window on the screen extending
  705.           from the start (top-left corner) to the stop (bottom-left corner)
  706.           positions.  The window will have the attribute (color) specified.
  707.           The type refers to the type of box to draw around it and can be
  708.           one of the following:
  709.  
  710.           0────┐  1════╕  2────╖  3════╗  4
  711.           │    │  │    │  ║    ║  ║    ║   No Box
  712.           └────┘  ╘════╛  ╙────╜  ╚════╝
  713.  
  714.           The function returns a pointer to a window structure if it is
  715.           successful, else it returns NULL.
  716.  
  717.           Example:  struct window *wndw;
  718.                     if (wndw = open_window(0x0,0x184f,WHITE,3))
  719.                          {
  720.                          ...
  721.                          close_window(wndw);
  722.                          }
  723.  
  724.           Returns:  Pointer to struct window or NULL if error.
  725.  
  726.  
  727.           * void close_window(struct window *scrn);
  728.  
  729.                This function closes a window previously opened with
  730.           open_window().  It frees any memory used to hold screen
  731.           information.
  732.  
  733.           Example:  See open_window() for example.
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.                ------------------------------------------------------
  755.                         Screen and Keyboard Function Library
  756.                                        Page 12
  757.  
  758.  
  759.  
  760.  
  761.  
  762.           * struct window *open_shadow_window(int start,int stop,
  763.                                               int attribute,
  764.                                               int type);
  765.  
  766.                This function will open a window on the screen extending
  767.           from the start (top-left corner) to the stop (bottom-left corner)
  768.           positions.  The window will have the attribute specified and will
  769.           have a shadow around the bottom and right hand sides.  The type
  770.           refers to the type of box to draw around it and can be one of the
  771.           following:
  772.  
  773.           0────┐  1════╕  2────╖  3════╗  4
  774.           │    │  │    │  ║    ║  ║    ║   No Box
  775.           └────┘  ╘════╛  ╙────╜  ╚════╝
  776.  
  777.           The function returns a pointer to a window structure if it is
  778.           successful, else it returns NULL.
  779.  
  780.           Example:  struct window *wndw;
  781.                     if (wndw = open_shadow_window(0x101,0x174e,WHITE,3))
  782.                          {
  783.                          ...
  784.                          close_shadow_window(wndw);
  785.                          }
  786.  
  787.           Returns:  Pointer to struct window or NULL if error.
  788.  
  789.  
  790.           * void close_shadow_window(struct window *scrn);
  791.  
  792.                This function closes a window previously opened with
  793.           open_shadow_window().  It frees any memory used to hold screen
  794.           information.
  795.  
  796.           Example:  See open_shadow_window() for example.
  797.  
  798.  
  799.           * int scroll_down(int tlc,int brc,int attribute,int lines);
  800.  
  801.                This function scrolls the window specified by the
  802.           coordinates tlc (top left corner) and brc (bottom right corner)
  803.           down by the specified number of lines.  Any lines left clear will
  804.           be set to the specified attribute (color).
  805.  
  806.           Example:  scroll_down(0x0,0x184f,GREEN,2);
  807.  
  808.           Returns:  The number of lines scrolled.
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.                ------------------------------------------------------
  820.                         Screen and Keyboard Function Library
  821.                                        Page 13
  822.  
  823.  
  824.  
  825.  
  826.  
  827.           * int scroll_up(int tlc,int brc,int attribute,int lines);
  828.  
  829.                This function scrolls the window specified by the
  830.           coordinates tlc (top left corner) and brc (bottom right corner)
  831.           up by the specified number of lines.  Any lines left clear will
  832.           be set to the specified attribute (color).
  833.  
  834.           Example:  scroll_up(0x0,0x184f,WHITE | ON_BLUE,1);
  835.  
  836.           Returns:  The number of lines scrolled.
  837.  
  838.  
  839.  
  840.           4.3-Box Handling Functions          4.3-Box Handling Functions
  841.           _________________________________________________________________
  842.  
  843.  
  844.           * void clrblk(int start,int stop,int attribute);
  845.  
  846.                This function will clear a block on the screen extending
  847.           from the top-left (start) coordinate to the bottom-right (stop)
  848.           coordinate to the desired attribute.
  849.  
  850.           Example:  clrblk(0x101,0x174e,WHITE | ON_GREEN);
  851.  
  852.  
  853.           * void drawbox(int start,int stop,int attribute,int type);
  854.  
  855.           This function will draw a box frame (perimeter only, not the
  856.           inside) from the specified top-left coordinate to the bottom-
  857.           right coordinate and will use the specified attribute.  The type
  858.           refers to the type of box to draw and can be one of the
  859.           following:
  860.  
  861.           0────┐  1════╕  2────╖  3════╗  4
  862.           │    │  │    │  ║    ║  ║    ║   No Box
  863.           └────┘  ╘════╛  ╙────╜  ╚════╝
  864.  
  865.           Example:  drawbox(0x0,0x184f,WHITE | ON_RED,1);
  866.  
  867.  
  868.           * int phantom(int cursor,int length,int attribute);
  869.  
  870.                This function is used to draw "phantom" cursors or to
  871.           otherwise change the attributes of a part of the screen.  The
  872.           function will change the attributes starting at cursor on the
  873.           screen to the specified attribute for the specified length.
  874.  
  875.           Example:  phantom(0x100a,20,ON_WHITE);
  876.  
  877.           Returns:  Number of characters with changed attributes.
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.                ------------------------------------------------------
  885.                         Screen and Keyboard Function Library
  886.                                        Page 14
  887.  
  888.  
  889.  
  890.  
  891.  
  892.           4.4-Cursor Handling Functions          4.4-Cursor Handling Functions
  893.           _________________________________________________________________
  894.  
  895.  
  896.           * void _setcurpos(int cursor);
  897.  
  898.                This function sets the cursor to the specified cursor
  899.           position (encoded ((row << 8) + column)).
  900.  
  901.           Example:  _setcurpos(0);
  902.  
  903.  
  904.           * void set_cursor_type(int type);
  905.  
  906.                This function sets the specified cursor type (see above
  907.           macros).
  908.  
  909.           Example:  set_cursor_type(LINE);
  910.  
  911.  
  912.  
  913.           4.5-Keyboard Routines          4.5-Keyboard Routines
  914.           _________________________________________________________________
  915.  
  916.  
  917.           * int _read_keyboard(void);
  918.  
  919.                This function does a destructive read from the keyboard and
  920.           returns the key scan code in the low byte and a 1 in the high
  921.           byte if it was an extended keystroke (like F1 or Home) or a 0 in
  922.           the high byte if the ASCII value is in the low byte.  This
  923.           function will wait for a keystroke if none is waiting.
  924.  
  925.           Example:  int key;
  926.                     key = _read_keyboard();
  927.                     if (key == 0x12d)   /* key is Alt-X */
  928.                          ....
  929.                     else if (key == 'A')
  930.                          ....
  931.  
  932.           Returns:  Key pressed.
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.                ------------------------------------------------------
  950.                         Screen and Keyboard Function Library
  951.                                        Page 15
  952.  
  953.  
  954.  
  955.  
  956.  
  957.           * int far _scan_keyboard(void);
  958.  
  959.                This function polls the keyboard and returns a 0 if there is
  960.           not a keystroke waiting.  If it returns a value other than 0,
  961.           then there is a key waiting to be retrieved with
  962.           _read_keyboard().  Watch out for polling loops under OS/2 as they
  963.           will bring the system down.
  964.  
  965.           Example:  while (!_scan_keyboard())     /* under DOS */
  966.                          ....
  967.                     key = _read_keyboard();
  968.  
  969.                     while (!_scan_keyboard())     /* under OS/2 */
  970.                          {
  971.                          ...
  972.                          DosSleep(10L);      /* sleep 10 msecs */
  973.                          }
  974.                     key = _read_keyboard();
  975.  
  976.           Returns:  0 if no key is ready, or the keycode for the next key.
  977.  
  978.  
  979.           * int far _get_shift_status(void);
  980.  
  981.                This function returns the state of the shift keys mapped
  982.           into a byte thus:
  983.  
  984.            Ins  Caps-Lock Num-Lock Scroll-Lock  Alt   Ctrl  L-Shift R-Shift
  985.             7       6        5           4       3      2       1      0
  986.  
  987.  
  988.           Example:  if (_get_shift_status() & 32)
  989.                          prntnomov(0x40,8,YELLOW,"Num Lock");
  990.  
  991.           Returns:  Bitmapped status of shift keys.
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.                ------------------------------------------------------
  1015.                         Screen and Keyboard Function Library
  1016.                                        Page 16
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.                                     Contents                                    Contents
  1023.  
  1024.  
  1025.  
  1026.                Chapter 1  Introduction                               2
  1027.  
  1028.                Chapter 2  Structures, Globals and Macros             3
  1029.                   2.1  Colors  . . . . . . . . . . . . . . . . . . . 3
  1030.                   2.2  Coordinates . . . . . . . . . . . . . . . . . 4
  1031.                   2.3  Cursor Shapes . . . . . . . . . . . . . . . . 4
  1032.                   2.4  Current Cursor Position . . . . . . . . . . . 4
  1033.                   2.5  Window Structure  . . . . . . . . . . . . . . 5
  1034.                   2.6  CGA Snow Flag . . . . . . . . . . . . . . . . 5
  1035.  
  1036.                Chapter 3  Header Files                               6
  1037.  
  1038.                Chapter 4  Function Descriptions                      7
  1039.                   4.1  Screen Handling Functions . . . . . . . . . . 7
  1040.                   4.2  Windowing Functions . . . . . . . . . . . .  12
  1041.                   4.3  Box Handling Functions  . . . . . . . . . .  14
  1042.                   4.4  Cursor Handling Functions . . . . . . . . .  15
  1043.                   4.5  Keyboard Routines . . . . . . . . . . . . .  15
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.                                           i
  1080.