Mike Feldman
------------------------------------------------------------------------
Michael B. Feldman - chair, SIGAda Education Working Group
Professor, Dept. of Electrical Engineering and Computer Science
The George Washington University - Washington, DC 20052 USA
202-994-5253 (voice) - 202-994-0227 (fax) - mfel...@seas.gwu.edu (Internet)
"Pork is all that stuff the government gives the other guys."
------------------------------------------------------------------------
--- cut here ---
PACKAGE Screen IS
-- Procedures for drawing pictures on ANSI Terminal Screen
ScreenHeight : CONSTANT Integer := 24;
ScreenWidth : CONSTANT Integer := 80;
SUBTYPE Height IS Integer RANGE 1..ScreenHeight;
SUBTYPE Width IS Integer RANGE 1..ScreenWidth;
TYPE Position IS RECORD
Row : Height := 1;
Column: Width := 1;
END RECORD;
PROCEDURE Beep;
-- Pre: none
-- Post: the terminal beeps once
PROCEDURE ClearScreen;
-- Pre: none
-- Post: the terminal screen is cleared
PROCEDURE MoveCursor (To: IN Position);
-- Pre: To is defined
-- Post: the terminal cursor is moved to the given position
END Screen;
-------
WITH Text_IO;
WITH My_Int_IO;
PACKAGE BODY Screen IS
-- Procedures for drawing pictures on ANSI Terminal Screen
-- These procedures will work correctly only if the actual
-- terminal is ANSI compatible. ANSI.SYS on a DOS machine
-- will suffice.
PROCEDURE Beep IS
BEGIN
Text_IO.Put (Item => ASCII.BEL);
END Beep;
PROCEDURE ClearScreen IS
BEGIN
Text_IO.Put (Item => ASCII.ESC);
Text_IO.Put (Item => "[2J");
END ClearScreen;
PROCEDURE MoveCursor (To: IN Position) IS
BEGIN
Text_IO.New_Line;
Text_IO.Put (Item => ASCII.ESC);
Text_IO.Put ("[");
My_Int_IO.Put (Item => To.Row, Width => 1);
Text_IO.Put (Item => ';');
My_Int_IO.Put (Item => To.Column, Width => 1);
Text_IO.Put (Item => 'f');
END MoveCursor;
END Screen;