From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: Displaying positional text
Date: 1996/07/31
Date: 1996-07-31T00:00:00+00:00 [thread overview]
Message-ID: <4tp552$mh0@felix.seas.gwu.edu> (raw)
In-Reply-To: 4taun9$3i2@hq.hq.af.mil
In article <4taun9$3i2@hq.hq.af.mil>,
1Lt Joel Rudy <joel.rudy@comm.hq.af.mil> wrote:
>Is there an Ada95 package that allows you to display text at position(x,y)
>where x is the row, and y is the column (or something similar). I
>remember this capability in Ada83, but have been unable to find it in
>Ada95.
>
>Thanks.
>
>Joel
>
Here's simple version. Ada 83 had no standard way to do this, nor
does Ada 95, but if you have an ANSI-compatible 24x80 screen, this
will serve as a starting point. GNAT would call these screen.ad[sb].
Mike Feldman
PACKAGE Screen IS
------------------------------------------------------------------
--| Procedures for drawing pictures on ANSI Terminal Screen
--| Author: Michael B. Feldman, The George Washington University
--| Last Modified: October 1995
------------------------------------------------------------------
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 Ada.Text_IO;
WITH Ada.Integer_Text_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.
--| Author: Michael B. Feldman, The George Washington University
--| Last Modified: September 1995
------------------------------------------------------------------
PROCEDURE Beep IS
BEGIN
Ada.Text_IO.Flush;
Ada.Text_IO.Put (Item => ASCII.BEL);
END Beep;
PROCEDURE ClearScreen IS
BEGIN
Ada.Text_IO.Put (Item => ASCII.ESC);
Ada.Text_IO.Put (Item => "[2J");
Ada.Text_IO.Flush;
END ClearScreen;
PROCEDURE MoveCursor (To: IN Position) IS
BEGIN
Ada.Text_IO.Flush;
Ada.Text_IO.Put (Item => ASCII.ESC);
Ada.Text_IO.Put ("[");
Ada.Integer_Text_IO.Put (Item => To.Row, Width => 1);
Ada.Text_IO.Put (Item => ';');
Ada.Integer_Text_IO.Put (Item => To.Column, Width => 1);
Ada.Text_IO.Put (Item => 'f');
END MoveCursor;
END Screen;
prev parent reply other threads:[~1996-07-31 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-07-26 0:00 Displaying positional text 1Lt Joel Rudy
1996-07-28 0:00 ` Robert Dewar
1996-07-29 0:00 ` Do-While Jones
1996-07-30 0:00 ` Jerry van Dijk
1996-07-31 0:00 ` Michael Feldman [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox