home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / pascal / passrc / cursor.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-11-18  |  4.5 KB  |  147 lines

  1. { -----------------------------------------------------------------------------
  2.  
  3.                                  NOTICE:
  4.  
  5.       THESE MATERIALS are UNSUPPORTED by OSS!  If you do not understand how to
  6.       use them do not contact OSS for help!  We will not teach you how to 
  7.       program in Pascal.  If you find an error in these materials, feel free
  8.       to SEND US A LETTER explaining the error, and how to fix it.
  9.  
  10.       THE BOTTOM LINE:
  11.  
  12.          Use it, enjoy it, but you are on your own when using these materials!
  13.  
  14.  
  15.                                DISCLAIMER:
  16.  
  17.       OSS makes no representations or warranties with respect to the contents
  18.       hereof and specifically disclaim all warranties of merchantability or
  19.       fitness for any particular purpose.   This document is subject to change
  20.       without notice.
  21.       
  22.       OSS provides these materials for use with Personal Pascal.  Use them in
  23.       any way you wish.
  24.  
  25.    -------------------------------------------------------------------------- }
  26.  
  27.  
  28. { CURSOR.PAS - A collection of cursor movement and control routines for TOS
  29.     programs.  These routines provide access to the VT52 escape sequences, as
  30.     well as providing more compatibility with Turbo Pascal.  Include this file
  31.     along with your program in order to use the routines.  Alternatively, you
  32.     can make this a separate module.
  33. }
  34.  
  35.   { Put a single character to the console device (the character's value is
  36.     received as an integer!) }
  37.   PROCEDURE out_char( c: integer );
  38.  
  39.     CONST
  40.       screen = 2;
  41.  
  42.     PROCEDURE bconout( device, c: integer );
  43.       BIOS(3);
  44.  
  45.     BEGIN
  46.       bconout( screen, c );
  47.     END;
  48.  
  49.   { Put a two-character escape sequence to the console device (an escape
  50.     followed by a single character) }
  51.   PROCEDURE out_escape( c: char );
  52.  
  53.     CONST
  54.       escape = 27;
  55.  
  56.     BEGIN
  57.       out_char( escape );
  58.       out_char( ord(c) );
  59.     END;
  60.  
  61.   { Clear from the cursor to the end of the current line }
  62.   PROCEDURE ClrEol;
  63.     BEGIN out_escape( 'K' ) END;
  64.  
  65.   { Clear the screen and move the cursor to the upper left position }
  66.   PROCEDURE ClrScr;
  67.     BEGIN out_escape( 'E' ) END;
  68.  
  69.   { Initialize the console device }
  70.   PROCEDURE CrtInit;
  71.     BEGIN out_escape( 'v' ) END;
  72.  
  73.   { Reset the console device }
  74.   PROCEDURE CrtExit;
  75.     BEGIN out_escape( 'w' ) END;
  76.  
  77.   { Delete the current line, moving all lines below up by one line }
  78.   PROCEDURE DelLine;
  79.     BEGIN out_escape( 'M' ) END;
  80.  
  81.   { Insert a blank line at the current position, moving the current line and
  82.     all lines below down by one line.  The bottom line on the screen is lost }
  83.   PROCEDURE InsLine;
  84.     BEGIN out_escape( 'L' ) END;
  85.  
  86.   { Move to a specific screen coordinate.  Home is (1,1). }
  87.   PROCEDURE GotoXY( x, y: integer );
  88.     BEGIN out_escape( 'Y' ); out_char( 31+x ); out_char( 31+y ) END;
  89.  
  90.   { Reverse foreground and background colors for text display }
  91.   PROCEDURE InverseVideo;
  92.     BEGIN out_escape( 'p' ) END;
  93.  
  94.   { Restore normal colors }
  95.   PROCEDURE NormVideo;
  96.     BEGIN out_escape( 'q' ) END;
  97.  
  98.   { Choose a foreground color index for text display }
  99.   PROCEDURE TextColor( color: integer );
  100.     BEGIN out_escape( 'b' ); out_char( color ) END;
  101.  
  102.   { Choose a background color index for text display }
  103.   PROCEDURE TextBackground( color: integer );
  104.     BEGIN out_escape( 'c' ); out_char( color ) END;
  105.  
  106. { ---------------------------------------------------------------------------
  107.   The following procedures and functions are not in the Turbo Pascal library:
  108.   --------------------------------------------------------------------------- }
  109.  
  110.   { Move the cursor up one line }
  111.   PROCEDURE CursUp;
  112.     BEGIN out_escape( 'A' ) END;
  113.  
  114.   { Move the cursor down one line }
  115.   PROCEDURE CursDown;
  116.     BEGIN out_escape( 'B' ) END;
  117.  
  118.   { Move the cursor right one column }
  119.   PROCEDURE CursRight;
  120.     BEGIN out_escape( 'C' ) END;
  121.  
  122.   { Move the cursor left one column }
  123.   PROCEDURE CursLeft;
  124.     BEGIN out_escape( 'D' ) END;
  125.  
  126.   { Move the cursor to the upper left corner of the screen }
  127.   PROCEDURE CursHome;
  128.     BEGIN out_escape( 'H' ) END;
  129.  
  130.   { Same as CursUp, but inserts a blank line at the top of the screen }
  131.   PROCEDURE CursUp2;
  132.     BEGIN out_escape( 'I' ) END;
  133.  
  134.   { Clear from cursor to end of the screen }
  135.   PROCEDURE ClrEos;
  136.     BEGIN out_escape( 'J' ) END;
  137.  
  138.   { Turn on the flashing cursor }
  139.   PROCEDURE CursOn;
  140.     BEGIN out_escape( 'e' ) END;
  141.  
  142.   { Turn off the flashing cursor (i.e., no cursor is displayed) }
  143.   PROCEDURE CursOff;
  144.     BEGIN out_escape( 'f' ) END;
  145.  
  146. { End of CURSOR.PAS }
  147.