home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / prog1 / ada-tutr.lzh / VANILLA.ADA < prev    next >
Encoding:
Text File  |  1988-12-21  |  2.6 KB  |  52 lines

  1. -- VANILLA.ADA   Ver. 1.20   21-DEC-1988
  2. -- Copyright 1988 John J. Herro
  3. -- Software Innovations Technology
  4. -- 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706   (407)951-0233
  5. --
  6. -- "Plain vanilla" version of CUSTOM_IO which should work with ANY standard Ada
  7. -- compiler.  Compile this before compiling ADA-TUTR.ADA.
  8. --
  9. with TEXT_IO;
  10. package CUSTOM_IO is
  11.    type COLOR is (BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE);
  12.    FOREGRND_COLOR   : COLOR := WHITE;                 -- Default values in case
  13.    BACKGRND_COLOR   : COLOR := BLACK;                 -- ADA-TUTR finds no User
  14.    BORDER_COLOR     : COLOR := BLACK;                 -- File.
  15.    FORE_COLOR_DIGIT : CHARACTER := CHARACTER'VAL(COLOR'POS(FOREGRND_COLOR)+48);
  16.    BACK_COLOR_DIGIT : CHARACTER := CHARACTER'VAL(COLOR'POS(BACKGRND_COLOR)+48);
  17.    NORMAL_COLORS    : STRING(1 .. 10) := ASCII.ESC & "[0;3" &
  18.                               FORE_COLOR_DIGIT & ";4" & BACK_COLOR_DIGIT & "m";
  19.    CLEAR_SCRN       : constant STRING := ASCII.ESC & "[H" & ASCII.ESC & "[2J";
  20.  
  21.    procedure SET_BORDER_COLOR (TO   : in COLOR);
  22.    procedure GET              (CHAR : out CHARACTER) renames TEXT_IO.GET;
  23.    procedure PUT              (CHAR : in  CHARACTER) renames TEXT_IO.PUT;
  24.    procedure PUT              (STR  : in  STRING)    renames TEXT_IO.PUT;
  25.    procedure PUT_LINE         (STR  : in  STRING)    renames TEXT_IO.PUT_LINE;
  26.    procedure GET_LINE         (STR  : out STRING;
  27.                                LAST : out NATURAL)   renames TEXT_IO.GET_LINE;
  28.    procedure NEW_LINE      (SPACING : in  TEXT_IO.COUNT := 1)
  29.                                                      renames TEXT_IO.NEW_LINE;
  30. end CUSTOM_IO;
  31.  
  32. package body CUSTOM_IO is
  33.    procedure SET_BORDER_COLOR(TO : in COLOR) is
  34.       --
  35.       -- This is a dummy procedure.  If your PC Ada compiler allows interrupt
  36.       -- calls or assembly language, you may want to write code to call
  37.       -- interrupt 10 hex.  (See MERIDIAN.ADA for an example.)  Before the
  38.       -- call, set register AH to service number 0B hex, set BH to zero, and
  39.       -- set BL to COLOR_NUMBER(TO), where COLOR_NUMBER is declared below.
  40.       -- Note that the integers in COLOR_NUMBER are bit reversed from the
  41.       -- integers defining foreground and background colors in ANSI escape
  42.       -- sequences.  Note also that some color PCs don't have separate border
  43.       -- colors.
  44.       --
  45.       COLOR_NUMBER : constant array(COLOR) of INTEGER :=
  46.           (BLACK   => 0,   RED     => 4,   GREEN   => 2,   YELLOW  => 6,
  47.            BLUE    => 1,   MAGENTA => 5,   CYAN    => 3,   WHITE   => 7);
  48.    begin
  49.       null;
  50.    end SET_BORDER_COLOR;
  51. end CUSTOM_IO;
  52.